Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: runtime/vm/service.cc

Issue 920313003: Implement function entry breakpoints in Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/observatory/test/debugging_test.dart ('k') | runtime/vm/service/service.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 : MethodParameter(name, required) { 291 : MethodParameter(name, required) {
292 } 292 }
293 293
294 virtual bool Validate(const char* value) const { 294 virtual bool Validate(const char* value) const {
295 if (value == NULL) { 295 if (value == NULL) {
296 return false; 296 return false;
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 Parse(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 UIntParameter : public MethodParameter {
308 public:
309 UIntParameter(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 }
324
325 static intptr_t Parse(const char* value) {
326 char* end_ptr = NULL;
327 uintptr_t result = strtoul(value, &end_ptr, 10);
328 ASSERT(*end_ptr == '\0'); // Parsed full string
329 return result;
330 }
331 };
332
333
307 class IdParameter : public MethodParameter { 334 class IdParameter : public MethodParameter {
308 public: 335 public:
309 IdParameter(const char* name, bool required) 336 IdParameter(const char* name, bool required)
310 : MethodParameter(name, required) { 337 : MethodParameter(name, required) {
311 } 338 }
312 339
313 virtual bool Validate(const char* value) const { 340 virtual bool Validate(const char* value) const {
314 return (value != NULL); 341 return (value != NULL);
315 } 342 }
316 }; 343 };
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 } 1732 }
1706 PrintError(js, "%s: Invalid 'targetId' parameter value: " 1733 PrintError(js, "%s: Invalid 'targetId' parameter value: "
1707 "id '%s' does not correspond to a " 1734 "id '%s' does not correspond to a "
1708 "script, library, class, or function", js->method(), target_id); 1735 "script, library, class, or function", js->method(), target_id);
1709 return true; 1736 return true;
1710 } 1737 }
1711 1738
1712 1739
1713 static const MethodParameter* add_breakpoint_params[] = { 1740 static const MethodParameter* add_breakpoint_params[] = {
1714 ISOLATE_PARAMETER, 1741 ISOLATE_PARAMETER,
1742 new IdParameter("scriptId", true),
1743 new UIntParameter("line", true),
1715 NULL, 1744 NULL,
1716 }; 1745 };
1717 1746
1718 1747
1719 static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) { 1748 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"); 1749 const char* line_param = js->LookupParam("line");
1725 intptr_t line = -1; 1750 intptr_t line = UIntParameter::Parse(line_param);
1726 if (!GetIntegerId(line_param, &line)) { 1751 const char* script_id = js->LookupParam("scriptId");
1727 PrintInvalidParamError(js, "line");
1728 return true;
1729 }
1730 const char* script_id = js->LookupParam("script");
1731 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); 1752 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL));
1732 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { 1753 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
1733 PrintInvalidParamError(js, "script"); 1754 PrintInvalidParamError(js, "scriptId");
1734 return true; 1755 return true;
1735 } 1756 }
1736 const Script& script = Script::Cast(obj); 1757 const Script& script = Script::Cast(obj);
1737 const String& script_url = String::Handle(script.url()); 1758 const String& script_url = String::Handle(script.url());
1738 SourceBreakpoint* bpt = 1759 SourceBreakpoint* bpt =
1739 isolate->debugger()->SetBreakpointAtLine(script_url, line); 1760 isolate->debugger()->SetBreakpointAtLine(script_url, line);
1740 if (bpt == NULL) { 1761 if (bpt == NULL) {
1741 PrintError(js, "Unable to set breakpoint at line %s", line_param); 1762 PrintError(js, "Unable to set breakpoint at line %s", line_param);
1742 return true; 1763 return true;
1743 } 1764 }
1744 bpt->PrintJSON(js); 1765 bpt->PrintJSON(js);
1745 return true; 1766 return true;
1746 } 1767 }
1747 1768
1748 1769
1770 static const MethodParameter* add_breakpoint_at_entry_params[] = {
1771 ISOLATE_PARAMETER,
1772 new IdParameter("functionId", true),
1773 NULL,
1774 };
1775
1776
1777 static bool HandleIsolateAddBreakpointAtEntry(Isolate* isolate,
1778 JSONStream* js) {
1779 const char* function_id = js->LookupParam("functionId");
1780 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL));
1781 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) {
1782 PrintInvalidParamError(js, "functionId");
1783 return true;
1784 }
1785 const Function& function = Function::Cast(obj);
1786 SourceBreakpoint* bpt =
1787 isolate->debugger()->SetBreakpointAtEntry(function);
1788 if (bpt == NULL) {
1789 const String& funcName = String::Handle(function.PrettyName());
1790 PrintError(js, "Unable to set breakpoint at function '%s'",
1791 funcName.ToCString());
1792 return true;
1793 }
1794 bpt->PrintJSON(js);
1795 return true;
1796 }
1797
1798
1749 static const MethodParameter* remove_breakpoint_params[] = { 1799 static const MethodParameter* remove_breakpoint_params[] = {
1750 ISOLATE_PARAMETER, 1800 ISOLATE_PARAMETER,
1751 NULL, 1801 NULL,
1752 }; 1802 };
1753 1803
1754 1804
1755 static bool HandleIsolateRemoveBreakpoint(Isolate* isolate, JSONStream* js) { 1805 static bool HandleIsolateRemoveBreakpoint(Isolate* isolate, JSONStream* js) {
1756 if (!js->HasParam("breakpointId")) { 1806 if (!js->HasParam("breakpointId")) {
1757 PrintMissingParamError(js, "breakpointId"); 1807 PrintMissingParamError(js, "breakpointId");
1758 return true; 1808 return true;
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 { "_echo", HandleIsolateEcho, 2493 { "_echo", HandleIsolateEcho,
2444 NULL }, 2494 NULL },
2445 { "_respondWithMalformedJson", HandleIsolateRespondWithMalformedJson, 2495 { "_respondWithMalformedJson", HandleIsolateRespondWithMalformedJson,
2446 NULL }, 2496 NULL },
2447 { "_respondWithMalformedObject", HandleIsolateRespondWithMalformedObject, 2497 { "_respondWithMalformedObject", HandleIsolateRespondWithMalformedObject,
2448 NULL }, 2498 NULL },
2449 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, 2499 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent,
2450 NULL }, 2500 NULL },
2451 { "addBreakpoint", HandleIsolateAddBreakpoint, 2501 { "addBreakpoint", HandleIsolateAddBreakpoint,
2452 add_breakpoint_params }, 2502 add_breakpoint_params },
2503 { "addBreakpointAtEntry", HandleIsolateAddBreakpointAtEntry,
2504 add_breakpoint_at_entry_params },
2453 { "eval", HandleIsolateEval, 2505 { "eval", HandleIsolateEval,
2454 eval_params }, 2506 eval_params },
2455 { "getAllocationProfile", HandleIsolateGetAllocationProfile, 2507 { "getAllocationProfile", HandleIsolateGetAllocationProfile,
2456 get_allocation_profile_params }, 2508 get_allocation_profile_params },
2457 { "getBreakpoints", HandleIsolateGetBreakpoints, 2509 { "getBreakpoints", HandleIsolateGetBreakpoints,
2458 get_breakpoints_params }, 2510 get_breakpoints_params },
2459 { "getCallSiteData", HandleIsolateGetCallSiteData, 2511 { "getCallSiteData", HandleIsolateGetCallSiteData,
2460 get_call_site_data_params }, 2512 get_call_site_data_params },
2461 { "getClassList", HandleIsolateGetClassList, 2513 { "getClassList", HandleIsolateGetClassList,
2462 get_class_list_params }, 2514 get_class_list_params },
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 ServiceMethodDescriptor& method = service_methods_[i]; 2570 ServiceMethodDescriptor& method = service_methods_[i];
2519 if (strcmp(method_name, method.name) == 0) { 2571 if (strcmp(method_name, method.name) == 0) {
2520 return &method; 2572 return &method;
2521 } 2573 }
2522 } 2574 }
2523 return NULL; 2575 return NULL;
2524 } 2576 }
2525 2577
2526 2578
2527 } // namespace dart 2579 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/test/debugging_test.dart ('k') | runtime/vm/service/service.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698