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

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

Issue 1312763010: Support column-based breakpoints in the VM and Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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 "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 }; 2032 };
2033 2033
2034 2034
2035 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { 2035 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) {
2036 return GetHitsOrSites(isolate, js, true); 2036 return GetHitsOrSites(isolate, js, true);
2037 } 2037 }
2038 2038
2039 2039
2040 static const MethodParameter* add_breakpoint_params[] = { 2040 static const MethodParameter* add_breakpoint_params[] = {
2041 ISOLATE_PARAMETER, 2041 ISOLATE_PARAMETER,
2042 new IdParameter("scriptId", true), 2042 new IdParameter("scriptId", false),
2043 new IdParameter("scriptUrl", false),
2043 new UIntParameter("line", true), 2044 new UIntParameter("line", true),
2045 new UIntParameter("column", false),
2044 NULL, 2046 NULL,
2045 }; 2047 };
2046 2048
2047 2049
2048 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { 2050 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) {
2049 const char* line_param = js->LookupParam("line"); 2051 const char* line_param = js->LookupParam("line");
2050 intptr_t line = UIntParameter::Parse(line_param); 2052 intptr_t line = UIntParameter::Parse(line_param);
2051 const char* script_id = js->LookupParam("scriptId"); 2053 const char* col_param = js->LookupParam("column");
2052 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); 2054 intptr_t col = -1;
2053 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { 2055 if (col_param != NULL) {
2054 PrintInvalidParamError(js, "scriptId"); 2056 col = UIntParameter::Parse(col_param);
2057 if (col == 0) {
2058 // Column number is 1-based.
2059 PrintInvalidParamError(js, "column");
2060 return true;
2061 }
2062 }
2063 const char* script_id_param = js->LookupParam("scriptId");
2064 const char* script_url_param = js->LookupParam("scriptUrl");
2065 if (script_id_param == NULL && script_url_param == NULL) {
2066 js->PrintError(kInvalidParams,
2067 "%s expects the 'scriptId' or the 'scriptUrl' parameter",
2068 js->method());
2055 return true; 2069 return true;
2056 } 2070 }
2057 const Script& script = Script::Cast(obj); 2071 String& script_url = String::Handle(isolate);
2058 const String& script_url = String::Handle(script.url()); 2072 if (script_id_param != NULL) {
2059 Breakpoint* bpt = 2073 Object& obj =
2060 isolate->debugger()->SetBreakpointAtLine(script_url, line); 2074 Object::Handle(LookupHeapObject(isolate, script_id_param, NULL));
2075 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
2076 PrintInvalidParamError(js, "scriptId");
2077 return true;
2078 }
2079 const Script& script = Script::Cast(obj);
2080 script_url = script.url();
2081 }
2082 if (script_url_param != NULL) {
2083 script_url = String::New(script_url_param);
2084 }
2085 ASSERT(!script_url.IsNull());
2086 Breakpoint* bpt = NULL;
2087 bpt = isolate->debugger()->SetBreakpointAtLineCol(script_url, line, col);
2061 if (bpt == NULL) { 2088 if (bpt == NULL) {
2062 js->PrintError(kCannotAddBreakpoint, 2089 js->PrintError(kCannotAddBreakpoint,
2063 "%s: Cannot add breakpoint at line '%s'", 2090 "%s: Cannot add breakpoint at line '%s'",
2064 js->method(), line_param); 2091 js->method(), line_param);
2065 return true; 2092 return true;
2066 } 2093 }
2067 bpt->PrintJSON(js); 2094 bpt->PrintJSON(js);
2068 return true; 2095 return true;
2069 } 2096 }
2070 2097
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 ServiceMethodDescriptor& method = service_methods_[i]; 3199 ServiceMethodDescriptor& method = service_methods_[i];
3173 if (strcmp(method_name, method.name) == 0) { 3200 if (strcmp(method_name, method.name) == 0) {
3174 return &method; 3201 return &method;
3175 } 3202 }
3176 } 3203 }
3177 return NULL; 3204 return NULL;
3178 } 3205 }
3179 3206
3180 3207
3181 } // namespace dart 3208 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698