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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 5ca023d230a1bc9c166e0ad1cfe6a07249b163d8..78fa79f190a73b5f730f38430be191640f6c7f7a 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -304,6 +304,26 @@ class BoolParameter : public MethodParameter {
};
+class IntParameter : public MethodParameter {
+ public:
+ IntParameter(const char* name, bool required)
+ : MethodParameter(name, required) {
+ }
+
+ virtual bool Validate(const char* value) const {
+ if (value == NULL) {
+ return false;
+ }
+ for (const char* cp = value; *cp != '\0'; cp++) {
+ if (*cp < '0' || *cp > '9') {
+ return false;
+ }
+ }
+ return true;
+ }
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".
+};
+
+
class IdParameter : public MethodParameter {
public:
IdParameter(const char* name, bool required)
@@ -1712,25 +1732,23 @@ static bool HandleIsolateGetCoverage(Isolate* isolate, JSONStream* js) {
static const MethodParameter* add_breakpoint_params[] = {
ISOLATE_PARAMETER,
+ new IdParameter("scriptId", true),
+ new IntParameter("line", true),
NULL,
};
static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) {
- if (!js->HasParam("line")) {
- PrintMissingParamError(js, "line");
- return true;
- }
const char* line_param = js->LookupParam("line");
intptr_t line = -1;
if (!GetIntegerId(line_param, &line)) {
PrintInvalidParamError(js, "line");
return true;
}
- const char* script_id = js->LookupParam("script");
+ const char* script_id = js->LookupParam("scriptId");
Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL));
if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
- PrintInvalidParamError(js, "script");
+ PrintInvalidParamError(js, "scriptId");
return true;
}
const Script& script = Script::Cast(obj);
@@ -1746,6 +1764,35 @@ static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) {
}
+static const MethodParameter* add_breakpoint_at_entry_params[] = {
+ ISOLATE_PARAMETER,
+ new IdParameter("functionId", true),
+ NULL,
+};
+
+
+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.
+ JSONStream* js) {
+ const char* function_id = js->LookupParam("functionId");
+ Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL));
+ if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) {
+ PrintInvalidParamError(js, "functionId");
+ return true;
+ }
+ const Function& function = Function::Cast(obj);
+ SourceBreakpoint* bpt =
+ isolate->debugger()->SetBreakpointAtEntry(function);
+ if (bpt == NULL) {
+ const String& funcName = String::Handle(function.PrettyName());
+ PrintError(js, "Unable to set breakpoint at function '%s'",
+ funcName.ToCString());
+ return true;
+ }
+ bpt->PrintJSON(js);
+ return true;
+}
+
+
static const MethodParameter* remove_breakpoint_params[] = {
ISOLATE_PARAMETER,
NULL,
@@ -2450,6 +2497,8 @@ static ServiceMethodDescriptor service_methods_[] = {
NULL },
{ "addBreakpoint", HandleIsolateAddBreakpoint,
add_breakpoint_params },
+ { "addBreakpointAtEntry", HandleIsolateAddBreakpointAtEntry,
+ add_breakpoint_at_entry_params },
{ "eval", HandleIsolateEval,
eval_params },
{ "getAllocationProfile", HandleIsolateGetAllocationProfile,

Powered by Google App Engine
This is Rietveld 408576698