OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/service.h" | 5 #include "vm/service.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 jsobj.AddProperty("kind", "Free"); | 1189 jsobj.AddProperty("kind", "Free"); |
1190 jsobj.AddProperty("valueAsString", "<free>"); | 1190 jsobj.AddProperty("valueAsString", "<free>"); |
1191 break; | 1191 break; |
1192 default: | 1192 default: |
1193 UNIMPLEMENTED(); | 1193 UNIMPLEMENTED(); |
1194 break; | 1194 break; |
1195 } | 1195 } |
1196 } | 1196 } |
1197 | 1197 |
1198 | 1198 |
1199 static Breakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { | 1199 static SourceBreakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { |
1200 size_t end_pos = strcspn(id, "/"); | 1200 size_t end_pos = strcspn(id, "/"); |
1201 if (end_pos == strlen(id)) { | 1201 if (end_pos == strlen(id)) { |
1202 return NULL; | 1202 return NULL; |
1203 } | 1203 } |
1204 const char* rest = id + end_pos + 1; // +1 for '/'. | 1204 const char* rest = id + end_pos + 1; // +1 for '/'. |
1205 if (strncmp("breakpoints", id, end_pos) == 0) { | 1205 if (strncmp("breakpoints", id, end_pos) == 0) { |
1206 intptr_t bpt_id = 0; | 1206 intptr_t bpt_id = 0; |
1207 Breakpoint* bpt = NULL; | 1207 SourceBreakpoint* bpt = NULL; |
1208 if (GetIntegerId(rest, &bpt_id)) { | 1208 if (GetIntegerId(rest, &bpt_id)) { |
1209 bpt = isolate->debugger()->GetBreakpointById(bpt_id); | 1209 bpt = isolate->debugger()->GetBreakpointById(bpt_id); |
1210 } | 1210 } |
1211 return bpt; | 1211 return bpt; |
1212 } | 1212 } |
1213 return NULL; | 1213 return NULL; |
1214 } | 1214 } |
1215 | 1215 |
1216 | 1216 |
1217 // Scans |isolate|'s message queue looking for a message with |id|. | 1217 // Scans |isolate|'s message queue looking for a message with |id|. |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 const char* line_param = js->LookupParam("line"); | 1801 const char* line_param = js->LookupParam("line"); |
1802 intptr_t line = UIntParameter::Parse(line_param); | 1802 intptr_t line = UIntParameter::Parse(line_param); |
1803 const char* script_id = js->LookupParam("scriptId"); | 1803 const char* script_id = js->LookupParam("scriptId"); |
1804 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); | 1804 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); |
1805 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 1805 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
1806 PrintInvalidParamError(js, "scriptId"); | 1806 PrintInvalidParamError(js, "scriptId"); |
1807 return true; | 1807 return true; |
1808 } | 1808 } |
1809 const Script& script = Script::Cast(obj); | 1809 const Script& script = Script::Cast(obj); |
1810 const String& script_url = String::Handle(script.url()); | 1810 const String& script_url = String::Handle(script.url()); |
1811 Breakpoint* bpt = | 1811 SourceBreakpoint* bpt = |
1812 isolate->debugger()->SetBreakpointAtLine(script_url, line); | 1812 isolate->debugger()->SetBreakpointAtLine(script_url, line); |
1813 if (bpt == NULL) { | 1813 if (bpt == NULL) { |
1814 js->PrintError(kNoBreakAtLine, NULL); | 1814 js->PrintError(kNoBreakAtLine, NULL); |
1815 return true; | 1815 return true; |
1816 } | 1816 } |
1817 bpt->PrintJSON(js); | 1817 bpt->PrintJSON(js); |
1818 return true; | 1818 return true; |
1819 } | 1819 } |
1820 | 1820 |
1821 | 1821 |
1822 static const MethodParameter* add_breakpoint_at_entry_params[] = { | 1822 static const MethodParameter* add_breakpoint_at_entry_params[] = { |
1823 ISOLATE_PARAMETER, | 1823 ISOLATE_PARAMETER, |
1824 new IdParameter("functionId", true), | 1824 new IdParameter("functionId", true), |
1825 NULL, | 1825 NULL, |
1826 }; | 1826 }; |
1827 | 1827 |
1828 | 1828 |
1829 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { | 1829 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { |
1830 const char* function_id = js->LookupParam("functionId"); | 1830 const char* function_id = js->LookupParam("functionId"); |
1831 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); | 1831 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); |
1832 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { | 1832 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { |
1833 PrintInvalidParamError(js, "functionId"); | 1833 PrintInvalidParamError(js, "functionId"); |
1834 return true; | 1834 return true; |
1835 } | 1835 } |
1836 const Function& function = Function::Cast(obj); | 1836 const Function& function = Function::Cast(obj); |
1837 Breakpoint* bpt = | 1837 SourceBreakpoint* bpt = |
1838 isolate->debugger()->SetBreakpointAtEntry(function, false); | 1838 isolate->debugger()->SetBreakpointAtEntry(function); |
1839 if (bpt == NULL) { | 1839 if (bpt == NULL) { |
1840 js->PrintError(kNoBreakAtFunction, NULL); | 1840 js->PrintError(kNoBreakAtFunction, NULL); |
1841 return true; | 1841 return true; |
1842 } | |
1843 bpt->PrintJSON(js); | |
1844 return true; | |
1845 } | |
1846 | |
1847 | |
1848 static const MethodParameter* add_breakpoint_at_activation_params[] = { | |
1849 ISOLATE_PARAMETER, | |
1850 new IdParameter("objectId", true), | |
1851 NULL, | |
1852 }; | |
1853 | |
1854 | |
1855 static bool AddBreakpointAtActivation(Isolate* isolate, JSONStream* js) { | |
1856 const char* object_id = js->LookupParam("objectId"); | |
1857 Object& obj = Object::Handle(LookupHeapObject(isolate, object_id, NULL)); | |
1858 if (obj.raw() == Object::sentinel().raw() || !obj.IsInstance()) { | |
1859 PrintInvalidParamError(js, "objectId"); | |
1860 return true; | |
1861 } | |
1862 const Instance& closure = Instance::Cast(obj); | |
1863 Breakpoint* bpt = | |
1864 isolate->debugger()->SetBreakpointAtActivation(closure); | |
1865 if (bpt == NULL) { | |
1866 js->PrintError(kNoBreakAtFunction, NULL); | |
1867 return true; | |
1868 } | 1842 } |
1869 bpt->PrintJSON(js); | 1843 bpt->PrintJSON(js); |
1870 return true; | 1844 return true; |
1871 } | 1845 } |
1872 | 1846 |
1873 | 1847 |
1874 static const MethodParameter* remove_breakpoint_params[] = { | 1848 static const MethodParameter* remove_breakpoint_params[] = { |
1875 ISOLATE_PARAMETER, | 1849 ISOLATE_PARAMETER, |
1876 NULL, | 1850 NULL, |
1877 }; | 1851 }; |
1878 | 1852 |
1879 | 1853 |
1880 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 1854 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
1881 if (!js->HasParam("breakpointId")) { | 1855 if (!js->HasParam("breakpointId")) { |
1882 PrintMissingParamError(js, "breakpointId"); | 1856 PrintMissingParamError(js, "breakpointId"); |
1883 return true; | 1857 return true; |
1884 } | 1858 } |
1885 const char* bpt_id = js->LookupParam("breakpointId"); | 1859 const char* bpt_id = js->LookupParam("breakpointId"); |
1886 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 1860 SourceBreakpoint* bpt = LookupBreakpoint(isolate, bpt_id); |
1887 if (bpt == NULL) { | 1861 if (bpt == NULL) { |
1888 fprintf(stderr, "ERROR1"); | 1862 fprintf(stderr, "ERROR1"); |
1889 PrintInvalidParamError(js, "breakpointId"); | 1863 PrintInvalidParamError(js, "breakpointId"); |
1890 return true; | 1864 return true; |
1891 } | 1865 } |
1892 isolate->debugger()->RemoveBreakpoint(bpt->id()); | 1866 isolate->debugger()->RemoveBreakpoint(bpt->id()); |
1893 | 1867 |
1894 // TODO(turnidge): Consider whether the 'Success' type is proper. | 1868 // TODO(turnidge): Consider whether the 'Success' type is proper. |
1895 JSONObject jsobj(js); | 1869 JSONObject jsobj(js); |
1896 jsobj.AddProperty("type", "Success"); | 1870 jsobj.AddProperty("type", "Success"); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 return true; | 2377 return true; |
2404 } else if (lookup_result == ObjectIdRing::kCollected) { | 2378 } else if (lookup_result == ObjectIdRing::kCollected) { |
2405 PrintSentinel(js, kCollectedSentinel); | 2379 PrintSentinel(js, kCollectedSentinel); |
2406 return true; | 2380 return true; |
2407 } else if (lookup_result == ObjectIdRing::kExpired) { | 2381 } else if (lookup_result == ObjectIdRing::kExpired) { |
2408 PrintSentinel(js, kExpiredSentinel); | 2382 PrintSentinel(js, kExpiredSentinel); |
2409 return true; | 2383 return true; |
2410 } | 2384 } |
2411 | 2385 |
2412 // Handle non-heap objects. | 2386 // Handle non-heap objects. |
2413 Breakpoint* bpt = LookupBreakpoint(isolate, id); | 2387 SourceBreakpoint* bpt = LookupBreakpoint(isolate, id); |
2414 if (bpt != NULL) { | 2388 if (bpt != NULL) { |
2415 bpt->PrintJSON(js); | 2389 bpt->PrintJSON(js); |
2416 return true; | 2390 return true; |
2417 } | 2391 } |
2418 | 2392 |
2419 if (PrintMessage(js, isolate, id)) { | 2393 if (PrintMessage(js, isolate, id)) { |
2420 return true; | 2394 return true; |
2421 } | 2395 } |
2422 | 2396 |
2423 PrintInvalidParamError(js, "objectId"); | 2397 PrintInvalidParamError(js, "objectId"); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 { "_respondWithMalformedJson", RespondWithMalformedJson, | 2567 { "_respondWithMalformedJson", RespondWithMalformedJson, |
2594 NULL }, | 2568 NULL }, |
2595 { "_respondWithMalformedObject", RespondWithMalformedObject, | 2569 { "_respondWithMalformedObject", RespondWithMalformedObject, |
2596 NULL }, | 2570 NULL }, |
2597 { "_triggerEchoEvent", TriggerEchoEvent, | 2571 { "_triggerEchoEvent", TriggerEchoEvent, |
2598 NULL }, | 2572 NULL }, |
2599 { "addBreakpoint", AddBreakpoint, | 2573 { "addBreakpoint", AddBreakpoint, |
2600 add_breakpoint_params }, | 2574 add_breakpoint_params }, |
2601 { "addBreakpointAtEntry", AddBreakpointAtEntry, | 2575 { "addBreakpointAtEntry", AddBreakpointAtEntry, |
2602 add_breakpoint_at_entry_params }, | 2576 add_breakpoint_at_entry_params }, |
2603 { "_addBreakpointAtActivation", AddBreakpointAtActivation, | |
2604 add_breakpoint_at_activation_params }, | |
2605 { "clearCpuProfile", ClearCpuProfile, | 2577 { "clearCpuProfile", ClearCpuProfile, |
2606 clear_cpu_profile_params }, | 2578 clear_cpu_profile_params }, |
2607 { "evaluate", Evaluate, | 2579 { "evaluate", Evaluate, |
2608 evaluate_params }, | 2580 evaluate_params }, |
2609 { "evaluateInFrame", EvaluateInFrame, | 2581 { "evaluateInFrame", EvaluateInFrame, |
2610 evaluate_in_frame_params }, | 2582 evaluate_in_frame_params }, |
2611 { "_getAllocationProfile", GetAllocationProfile, | 2583 { "_getAllocationProfile", GetAllocationProfile, |
2612 get_allocation_profile_params }, | 2584 get_allocation_profile_params }, |
2613 { "_getCallSiteData", GetCallSiteData, | 2585 { "_getCallSiteData", GetCallSiteData, |
2614 get_call_site_data_params }, | 2586 get_call_site_data_params }, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 ServiceMethodDescriptor& method = service_methods_[i]; | 2646 ServiceMethodDescriptor& method = service_methods_[i]; |
2675 if (strcmp(method_name, method.name) == 0) { | 2647 if (strcmp(method_name, method.name) == 0) { |
2676 return &method; | 2648 return &method; |
2677 } | 2649 } |
2678 } | 2650 } |
2679 return NULL; | 2651 return NULL; |
2680 } | 2652 } |
2681 | 2653 |
2682 | 2654 |
2683 } // namespace dart | 2655 } // namespace dart |
OLD | NEW |