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 SourceBreakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { | 1199 static Breakpoint* 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 SourceBreakpoint* bpt = NULL; | 1207 Breakpoint* 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 SourceBreakpoint* bpt = | 1811 Breakpoint* 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 SourceBreakpoint* bpt = | 1837 Breakpoint* bpt = |
1838 isolate->debugger()->SetBreakpointAtEntry(function); | 1838 isolate->debugger()->SetBreakpointAtEntry(function, false); |
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; |
1842 } | 1868 } |
1843 bpt->PrintJSON(js); | 1869 bpt->PrintJSON(js); |
1844 return true; | 1870 return true; |
1845 } | 1871 } |
1846 | 1872 |
1847 | 1873 |
1848 static const MethodParameter* remove_breakpoint_params[] = { | 1874 static const MethodParameter* remove_breakpoint_params[] = { |
1849 ISOLATE_PARAMETER, | 1875 ISOLATE_PARAMETER, |
1850 NULL, | 1876 NULL, |
1851 }; | 1877 }; |
1852 | 1878 |
1853 | 1879 |
1854 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 1880 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
1855 if (!js->HasParam("breakpointId")) { | 1881 if (!js->HasParam("breakpointId")) { |
1856 PrintMissingParamError(js, "breakpointId"); | 1882 PrintMissingParamError(js, "breakpointId"); |
1857 return true; | 1883 return true; |
1858 } | 1884 } |
1859 const char* bpt_id = js->LookupParam("breakpointId"); | 1885 const char* bpt_id = js->LookupParam("breakpointId"); |
1860 SourceBreakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 1886 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); |
1861 if (bpt == NULL) { | 1887 if (bpt == NULL) { |
1862 fprintf(stderr, "ERROR1"); | 1888 fprintf(stderr, "ERROR1"); |
1863 PrintInvalidParamError(js, "breakpointId"); | 1889 PrintInvalidParamError(js, "breakpointId"); |
1864 return true; | 1890 return true; |
1865 } | 1891 } |
1866 isolate->debugger()->RemoveBreakpoint(bpt->id()); | 1892 isolate->debugger()->RemoveBreakpoint(bpt->id()); |
1867 | 1893 |
1868 // TODO(turnidge): Consider whether the 'Success' type is proper. | 1894 // TODO(turnidge): Consider whether the 'Success' type is proper. |
1869 JSONObject jsobj(js); | 1895 JSONObject jsobj(js); |
1870 jsobj.AddProperty("type", "Success"); | 1896 jsobj.AddProperty("type", "Success"); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 return true; | 2403 return true; |
2378 } else if (lookup_result == ObjectIdRing::kCollected) { | 2404 } else if (lookup_result == ObjectIdRing::kCollected) { |
2379 PrintSentinel(js, kCollectedSentinel); | 2405 PrintSentinel(js, kCollectedSentinel); |
2380 return true; | 2406 return true; |
2381 } else if (lookup_result == ObjectIdRing::kExpired) { | 2407 } else if (lookup_result == ObjectIdRing::kExpired) { |
2382 PrintSentinel(js, kExpiredSentinel); | 2408 PrintSentinel(js, kExpiredSentinel); |
2383 return true; | 2409 return true; |
2384 } | 2410 } |
2385 | 2411 |
2386 // Handle non-heap objects. | 2412 // Handle non-heap objects. |
2387 SourceBreakpoint* bpt = LookupBreakpoint(isolate, id); | 2413 Breakpoint* bpt = LookupBreakpoint(isolate, id); |
2388 if (bpt != NULL) { | 2414 if (bpt != NULL) { |
2389 bpt->PrintJSON(js); | 2415 bpt->PrintJSON(js); |
2390 return true; | 2416 return true; |
2391 } | 2417 } |
2392 | 2418 |
2393 if (PrintMessage(js, isolate, id)) { | 2419 if (PrintMessage(js, isolate, id)) { |
2394 return true; | 2420 return true; |
2395 } | 2421 } |
2396 | 2422 |
2397 PrintInvalidParamError(js, "objectId"); | 2423 PrintInvalidParamError(js, "objectId"); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 { "_respondWithMalformedJson", RespondWithMalformedJson, | 2593 { "_respondWithMalformedJson", RespondWithMalformedJson, |
2568 NULL }, | 2594 NULL }, |
2569 { "_respondWithMalformedObject", RespondWithMalformedObject, | 2595 { "_respondWithMalformedObject", RespondWithMalformedObject, |
2570 NULL }, | 2596 NULL }, |
2571 { "_triggerEchoEvent", TriggerEchoEvent, | 2597 { "_triggerEchoEvent", TriggerEchoEvent, |
2572 NULL }, | 2598 NULL }, |
2573 { "addBreakpoint", AddBreakpoint, | 2599 { "addBreakpoint", AddBreakpoint, |
2574 add_breakpoint_params }, | 2600 add_breakpoint_params }, |
2575 { "addBreakpointAtEntry", AddBreakpointAtEntry, | 2601 { "addBreakpointAtEntry", AddBreakpointAtEntry, |
2576 add_breakpoint_at_entry_params }, | 2602 add_breakpoint_at_entry_params }, |
| 2603 { "_addBreakpointAtActivation", AddBreakpointAtActivation, |
| 2604 add_breakpoint_at_activation_params }, |
2577 { "clearCpuProfile", ClearCpuProfile, | 2605 { "clearCpuProfile", ClearCpuProfile, |
2578 clear_cpu_profile_params }, | 2606 clear_cpu_profile_params }, |
2579 { "evaluate", Evaluate, | 2607 { "evaluate", Evaluate, |
2580 evaluate_params }, | 2608 evaluate_params }, |
2581 { "evaluateInFrame", EvaluateInFrame, | 2609 { "evaluateInFrame", EvaluateInFrame, |
2582 evaluate_in_frame_params }, | 2610 evaluate_in_frame_params }, |
2583 { "_getAllocationProfile", GetAllocationProfile, | 2611 { "_getAllocationProfile", GetAllocationProfile, |
2584 get_allocation_profile_params }, | 2612 get_allocation_profile_params }, |
2585 { "_getCallSiteData", GetCallSiteData, | 2613 { "_getCallSiteData", GetCallSiteData, |
2586 get_call_site_data_params }, | 2614 get_call_site_data_params }, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 ServiceMethodDescriptor& method = service_methods_[i]; | 2674 ServiceMethodDescriptor& method = service_methods_[i]; |
2647 if (strcmp(method_name, method.name) == 0) { | 2675 if (strcmp(method_name, method.name) == 0) { |
2648 return &method; | 2676 return &method; |
2649 } | 2677 } |
2650 } | 2678 } |
2651 return NULL; | 2679 return NULL; |
2652 } | 2680 } |
2653 | 2681 |
2654 | 2682 |
2655 } // namespace dart | 2683 } // namespace dart |
OLD | NEW |