Chromium Code Reviews| 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 } | 297 } |
| 298 return (strcmp("true", value) == 0) || (strcmp("false", value) == 0); | 298 return (strcmp("true", value) == 0) || (strcmp("false", value) == 0); |
| 299 } | 299 } |
| 300 | 300 |
| 301 static bool Interpret(const char* value) { | 301 static bool Interpret(const char* value) { |
| 302 return strcmp("true", value) == 0; | 302 return strcmp("true", value) == 0; |
| 303 } | 303 } |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 | 306 |
| 307 class IntParameter : public MethodParameter { | |
| 308 public: | |
| 309 IntParameter(const char* name, bool required) | |
| 310 : MethodParameter(name, required) { | |
| 311 } | |
| 312 | |
| 313 virtual bool Validate(const char* value) const { | |
| 314 if (value == NULL) { | |
| 315 return false; | |
| 316 } | |
| 317 for (const char* cp = value; *cp != '\0'; cp++) { | |
| 318 if (*cp < '0' || *cp > '9') { | |
| 319 return false; | |
| 320 } | |
| 321 } | |
| 322 return true; | |
| 323 } | |
|
Cutch
2015/02/13 19:30:52
add:
static intptr_t Interpret(const char* value)
turnidge
2015/02/13 22:37:19
Done. Changed the name to "Parse".
| |
| 324 }; | |
| 325 | |
| 326 | |
| 307 class IdParameter : public MethodParameter { | 327 class IdParameter : public MethodParameter { |
| 308 public: | 328 public: |
| 309 IdParameter(const char* name, bool required) | 329 IdParameter(const char* name, bool required) |
| 310 : MethodParameter(name, required) { | 330 : MethodParameter(name, required) { |
| 311 } | 331 } |
| 312 | 332 |
| 313 virtual bool Validate(const char* value) const { | 333 virtual bool Validate(const char* value) const { |
| 314 return (value != NULL); | 334 return (value != NULL); |
| 315 } | 335 } |
| 316 }; | 336 }; |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 } | 1725 } |
| 1706 PrintError(js, "%s: Invalid 'targetId' parameter value: " | 1726 PrintError(js, "%s: Invalid 'targetId' parameter value: " |
| 1707 "id '%s' does not correspond to a " | 1727 "id '%s' does not correspond to a " |
| 1708 "script, library, class, or function", js->method(), target_id); | 1728 "script, library, class, or function", js->method(), target_id); |
| 1709 return true; | 1729 return true; |
| 1710 } | 1730 } |
| 1711 | 1731 |
| 1712 | 1732 |
| 1713 static const MethodParameter* add_breakpoint_params[] = { | 1733 static const MethodParameter* add_breakpoint_params[] = { |
| 1714 ISOLATE_PARAMETER, | 1734 ISOLATE_PARAMETER, |
| 1735 new IdParameter("scriptId", true), | |
| 1736 new IntParameter("line", true), | |
| 1715 NULL, | 1737 NULL, |
| 1716 }; | 1738 }; |
| 1717 | 1739 |
| 1718 | 1740 |
| 1719 static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) { | 1741 static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1720 if (!js->HasParam("line")) { | |
| 1721 PrintMissingParamError(js, "line"); | |
| 1722 return true; | |
| 1723 } | |
| 1724 const char* line_param = js->LookupParam("line"); | 1742 const char* line_param = js->LookupParam("line"); |
| 1725 intptr_t line = -1; | 1743 intptr_t line = -1; |
| 1726 if (!GetIntegerId(line_param, &line)) { | 1744 if (!GetIntegerId(line_param, &line)) { |
| 1727 PrintInvalidParamError(js, "line"); | 1745 PrintInvalidParamError(js, "line"); |
| 1728 return true; | 1746 return true; |
| 1729 } | 1747 } |
| 1730 const char* script_id = js->LookupParam("script"); | 1748 const char* script_id = js->LookupParam("scriptId"); |
| 1731 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); | 1749 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); |
| 1732 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 1750 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
| 1733 PrintInvalidParamError(js, "script"); | 1751 PrintInvalidParamError(js, "scriptId"); |
| 1734 return true; | 1752 return true; |
| 1735 } | 1753 } |
| 1736 const Script& script = Script::Cast(obj); | 1754 const Script& script = Script::Cast(obj); |
| 1737 const String& script_url = String::Handle(script.url()); | 1755 const String& script_url = String::Handle(script.url()); |
| 1738 SourceBreakpoint* bpt = | 1756 SourceBreakpoint* bpt = |
| 1739 isolate->debugger()->SetBreakpointAtLine(script_url, line); | 1757 isolate->debugger()->SetBreakpointAtLine(script_url, line); |
| 1740 if (bpt == NULL) { | 1758 if (bpt == NULL) { |
| 1741 PrintError(js, "Unable to set breakpoint at line %s", line_param); | 1759 PrintError(js, "Unable to set breakpoint at line %s", line_param); |
| 1742 return true; | 1760 return true; |
| 1743 } | 1761 } |
| 1744 bpt->PrintJSON(js); | 1762 bpt->PrintJSON(js); |
| 1745 return true; | 1763 return true; |
| 1746 } | 1764 } |
| 1747 | 1765 |
| 1748 | 1766 |
| 1767 static const MethodParameter* add_breakpoint_at_entry_params[] = { | |
| 1768 ISOLATE_PARAMETER, | |
| 1769 new IdParameter("functionId", true), | |
| 1770 NULL, | |
| 1771 }; | |
| 1772 | |
| 1773 | |
| 1774 static bool HandleIsolateAddBreakpointAtEntry(Isolate* isolate, | |
|
Cutch
2015/02/13 19:30:52
The RPC is "addBreakpointAtEntry" so this function
turnidge
2015/02/13 22:37:20
Acknowledged.
| |
| 1775 JSONStream* js) { | |
| 1776 const char* function_id = js->LookupParam("functionId"); | |
| 1777 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); | |
| 1778 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { | |
| 1779 PrintInvalidParamError(js, "functionId"); | |
| 1780 return true; | |
| 1781 } | |
| 1782 const Function& function = Function::Cast(obj); | |
| 1783 SourceBreakpoint* bpt = | |
| 1784 isolate->debugger()->SetBreakpointAtEntry(function); | |
| 1785 if (bpt == NULL) { | |
| 1786 const String& funcName = String::Handle(function.PrettyName()); | |
| 1787 PrintError(js, "Unable to set breakpoint at function '%s'", | |
| 1788 funcName.ToCString()); | |
| 1789 return true; | |
| 1790 } | |
| 1791 bpt->PrintJSON(js); | |
| 1792 return true; | |
| 1793 } | |
| 1794 | |
| 1795 | |
| 1749 static const MethodParameter* remove_breakpoint_params[] = { | 1796 static const MethodParameter* remove_breakpoint_params[] = { |
| 1750 ISOLATE_PARAMETER, | 1797 ISOLATE_PARAMETER, |
| 1751 NULL, | 1798 NULL, |
| 1752 }; | 1799 }; |
| 1753 | 1800 |
| 1754 | 1801 |
| 1755 static bool HandleIsolateRemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 1802 static bool HandleIsolateRemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1756 if (!js->HasParam("breakpointId")) { | 1803 if (!js->HasParam("breakpointId")) { |
| 1757 PrintMissingParamError(js, "breakpointId"); | 1804 PrintMissingParamError(js, "breakpointId"); |
| 1758 return true; | 1805 return true; |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2443 { "_echo", HandleIsolateEcho, | 2490 { "_echo", HandleIsolateEcho, |
| 2444 NULL }, | 2491 NULL }, |
| 2445 { "_respondWithMalformedJson", HandleIsolateRespondWithMalformedJson, | 2492 { "_respondWithMalformedJson", HandleIsolateRespondWithMalformedJson, |
| 2446 NULL }, | 2493 NULL }, |
| 2447 { "_respondWithMalformedObject", HandleIsolateRespondWithMalformedObject, | 2494 { "_respondWithMalformedObject", HandleIsolateRespondWithMalformedObject, |
| 2448 NULL }, | 2495 NULL }, |
| 2449 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, | 2496 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, |
| 2450 NULL }, | 2497 NULL }, |
| 2451 { "addBreakpoint", HandleIsolateAddBreakpoint, | 2498 { "addBreakpoint", HandleIsolateAddBreakpoint, |
| 2452 add_breakpoint_params }, | 2499 add_breakpoint_params }, |
| 2500 { "addBreakpointAtEntry", HandleIsolateAddBreakpointAtEntry, | |
| 2501 add_breakpoint_at_entry_params }, | |
| 2453 { "eval", HandleIsolateEval, | 2502 { "eval", HandleIsolateEval, |
| 2454 eval_params }, | 2503 eval_params }, |
| 2455 { "getAllocationProfile", HandleIsolateGetAllocationProfile, | 2504 { "getAllocationProfile", HandleIsolateGetAllocationProfile, |
| 2456 get_allocation_profile_params }, | 2505 get_allocation_profile_params }, |
| 2457 { "getBreakpoints", HandleIsolateGetBreakpoints, | 2506 { "getBreakpoints", HandleIsolateGetBreakpoints, |
| 2458 get_breakpoints_params }, | 2507 get_breakpoints_params }, |
| 2459 { "getCallSiteData", HandleIsolateGetCallSiteData, | 2508 { "getCallSiteData", HandleIsolateGetCallSiteData, |
| 2460 get_call_site_data_params }, | 2509 get_call_site_data_params }, |
| 2461 { "getClassList", HandleIsolateGetClassList, | 2510 { "getClassList", HandleIsolateGetClassList, |
| 2462 get_class_list_params }, | 2511 get_class_list_params }, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2518 ServiceMethodDescriptor& method = service_methods_[i]; | 2567 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2519 if (strcmp(method_name, method.name) == 0) { | 2568 if (strcmp(method_name, method.name) == 0) { |
| 2520 return &method; | 2569 return &method; |
| 2521 } | 2570 } |
| 2522 } | 2571 } |
| 2523 return NULL; | 2572 return NULL; |
| 2524 } | 2573 } |
| 2525 | 2574 |
| 2526 | 2575 |
| 2527 } // namespace dart | 2576 } // namespace dart |
| OLD | NEW |