Chromium Code Reviews| Index: runtime/vm/service.cc |
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
| index 0928897c9ab60950c6b009fa7bb4736edf763b6d..b26b5f95d021921044034354f480aca652a2c95c 100644 |
| --- a/runtime/vm/service.cc |
| +++ b/runtime/vm/service.cc |
| @@ -1590,6 +1590,29 @@ static bool HandleScriptsCoverage( |
| } |
| +static bool HandleScriptsSetBreakpoint( |
| + Isolate* isolate, const String& script_url, JSONStream* js) { |
| + if (!js->HasOption("line")) { |
| + PrintError(js, "Missing 'line' option"); |
| + return true; |
| + } |
| + const char* line_option = js->LookupOption("line"); |
| + intptr_t line = -1; |
| + if (!GetIntegerId(line_option, &line)) { |
| + PrintError(js, "Invalid 'line' value: %s", line_option); |
| + return true; |
| + } |
| + SourceBreakpoint* bpt = |
| + isolate->debugger()->SetBreakpointAtLine(script_url, line); |
| + if (bpt == NULL) { |
| + PrintError(js, "Unable to set breakpoint at line %s", line_option); |
| + return true; |
| + } |
| + bpt->PrintJSON(js); |
| + return true; |
| +} |
| + |
| + |
| static bool HandleScripts(Isolate* isolate, JSONStream* js) { |
| if (js->num_arguments() == 1) { |
| // Enumerate all scripts. |
| @@ -1635,6 +1658,9 @@ static bool HandleScripts(Isolate* isolate, JSONStream* js) { |
| if (strcmp(arg, "coverage") == 0) { |
| return HandleScriptsCoverage(isolate, requested_url, js); |
| } |
| + if (strcmp(arg, "setBreakpoint") == 0) { |
| + return HandleScriptsSetBreakpoint(isolate, requested_url, js); |
| + } |
| PrintError(js, "Unrecognized subcommand '%s'", arg); |
| return true; |
| } else { |
| @@ -1644,7 +1670,9 @@ static bool HandleScripts(Isolate* isolate, JSONStream* js) { |
| } |
| -static bool HandleDebugResume(Isolate* isolate, JSONStream* js) { |
| +static bool HandleDebugResume(Isolate* isolate, |
| + const char* step_option, |
| + JSONStream* js) { |
| if (isolate->message_handler()->paused_on_start()) { |
| isolate->message_handler()->set_pause_on_start(false); |
| JSONObject jsobj(js); |
| @@ -1660,6 +1688,19 @@ static bool HandleDebugResume(Isolate* isolate, JSONStream* js) { |
| return true; |
| } |
| if (isolate->debugger()->PauseEvent() != NULL) { |
| + if (step_option != NULL) { |
| + fprintf(stderr, "step option is %s\n", step_option); |
|
Cutch
2014/07/15 19:42:34
remove before committing.
turnidge
2014/07/15 23:37:24
Done.
|
| + if (strcmp(step_option, "into") == 0) { |
| + isolate->debugger()->SetSingleStep(); |
| + } else if (strcmp(step_option, "over") == 0) { |
| + isolate->debugger()->SetStepOver(); |
| + } else if (strcmp(step_option, "out") == 0) { |
| + isolate->debugger()->SetStepOut(); |
| + } else { |
| + PrintError(js, "Invalid 'step' option: %s", step_option); |
| + return true; |
| + } |
| + } |
| isolate->Resume(); |
| JSONObject jsobj(js); |
| jsobj.AddProperty("type", "Success"); |
| @@ -1683,26 +1724,42 @@ static bool HandleDebug(Isolate* isolate, JSONStream* js) { |
| // Print breakpoint list. |
| JSONObject jsobj(js); |
| jsobj.AddProperty("type", "BreakpointList"); |
| + jsobj.AddProperty("id", "debug/breakpoints"); |
| JSONArray jsarr(&jsobj, "breakpoints"); |
| isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr); |
| return true; |
| - } else if (js->num_arguments() == 3) { |
| - // Print individual breakpoint. |
| + } else { |
| intptr_t id = 0; |
| SourceBreakpoint* bpt = NULL; |
| if (GetIntegerId(js->GetArgument(2), &id)) { |
| bpt = isolate->debugger()->GetBreakpointById(id); |
| } |
| - if (bpt != NULL) { |
| + if (bpt == NULL) { |
| + PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2)); |
| + return true; |
| + } |
| + if (js->num_arguments() == 3) { |
| + // Print individual breakpoint. |
| bpt->PrintJSON(js); |
| return true; |
| + } else if (js->num_arguments() == 4) { |
| + const char* sub_command = js->GetArgument(3); |
| + if (strcmp(sub_command, "clear") == 0) { |
| + // Clear this breakpoint. |
| + isolate->debugger()->RemoveBreakpoint(id); |
| + |
| + JSONObject jsobj(js); |
| + jsobj.AddProperty("type", "Success"); |
| + jsobj.AddProperty("id", ""); |
| + return true; |
| + } else { |
| + PrintError(js, "Unrecognized subcommand %s", sub_command); |
| + return true; |
| + } |
| } else { |
| - PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2)); |
| + PrintError(js, "Command too long"); |
| return true; |
| } |
| - } else { |
| - PrintError(js, "Command too long"); |
| - return true; |
| } |
| } else if (strcmp(command, "pause") == 0) { |
| if (js->num_arguments() == 2) { |
| @@ -1718,7 +1775,8 @@ static bool HandleDebug(Isolate* isolate, JSONStream* js) { |
| } |
| } else if (strcmp(command, "resume") == 0) { |
| if (js->num_arguments() == 2) { |
| - return HandleDebugResume(isolate, js); |
| + const char* step_option = js->LookupOption("step"); |
| + return HandleDebugResume(isolate, step_option, js); |
| } else { |
| PrintError(js, "Command too long"); |
| return true; |