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

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

Issue 1379163002: Some changes to service protocol before we land 1.13. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: CHANGELOG Created 5 years, 2 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/service/service.md » ('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 "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 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 new IdParameter("targetId", false), 2034 new IdParameter("targetId", false),
2035 NULL, 2035 NULL,
2036 }; 2036 };
2037 2037
2038 2038
2039 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { 2039 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) {
2040 return GetHitsOrSites(isolate, js, true); 2040 return GetHitsOrSites(isolate, js, true);
2041 } 2041 }
2042 2042
2043 2043
2044 static const MethodParameter* add_breakpoint_params[] = { 2044 static bool AddBreakpointCommon(Isolate* isolate,
2045 ISOLATE_PARAMETER, 2045 JSONStream* js,
2046 new IdParameter("scriptId", false), 2046 const String& script_uri) {
2047 new IdParameter("scriptUri", false),
2048 new UIntParameter("line", true),
2049 new UIntParameter("column", false),
2050 NULL,
2051 };
2052
2053
2054 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) {
2055 const char* line_param = js->LookupParam("line"); 2047 const char* line_param = js->LookupParam("line");
2056 intptr_t line = UIntParameter::Parse(line_param); 2048 intptr_t line = UIntParameter::Parse(line_param);
2057 const char* col_param = js->LookupParam("column"); 2049 const char* col_param = js->LookupParam("column");
2058 intptr_t col = -1; 2050 intptr_t col = -1;
2059 if (col_param != NULL) { 2051 if (col_param != NULL) {
2060 col = UIntParameter::Parse(col_param); 2052 col = UIntParameter::Parse(col_param);
2061 if (col == 0) { 2053 if (col == 0) {
2062 // Column number is 1-based. 2054 // Column number is 1-based.
2063 PrintInvalidParamError(js, "column"); 2055 PrintInvalidParamError(js, "column");
2064 return true; 2056 return true;
2065 } 2057 }
2066 } 2058 }
2067 const char* script_id_param = js->LookupParam("scriptId");
2068 const char* script_uri_param = js->LookupParam("scriptUri");
2069 if (script_id_param == NULL && script_uri_param == NULL) {
2070 js->PrintError(kInvalidParams,
2071 "%s expects the 'scriptId' or the 'scriptUri' parameter",
2072 js->method());
2073 return true;
2074 }
2075 String& script_uri = String::Handle(isolate);
2076 if (script_id_param != NULL) {
2077 Object& obj =
2078 Object::Handle(LookupHeapObject(isolate, script_id_param, NULL));
2079 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
2080 PrintInvalidParamError(js, "scriptId");
2081 return true;
2082 }
2083 const Script& script = Script::Cast(obj);
2084 script_uri = script.url();
2085 }
2086 if (script_uri_param != NULL) {
2087 script_uri = String::New(script_uri_param);
2088 }
2089 ASSERT(!script_uri.IsNull()); 2059 ASSERT(!script_uri.IsNull());
2090 Breakpoint* bpt = NULL; 2060 Breakpoint* bpt = NULL;
2091 bpt = isolate->debugger()->SetBreakpointAtLineCol(script_uri, line, col); 2061 bpt = isolate->debugger()->SetBreakpointAtLineCol(script_uri, line, col);
2092 if (bpt == NULL) { 2062 if (bpt == NULL) {
2093 js->PrintError(kCannotAddBreakpoint, 2063 js->PrintError(kCannotAddBreakpoint,
2094 "%s: Cannot add breakpoint at line '%s'", 2064 "%s: Cannot add breakpoint at line '%s'",
2095 js->method(), line_param); 2065 js->method(), line_param);
2096 return true; 2066 return true;
2097 } 2067 }
2098 bpt->PrintJSON(js); 2068 bpt->PrintJSON(js);
2099 return true; 2069 return true;
2100 } 2070 }
2101 2071
2102 2072
2073 static const MethodParameter* add_breakpoint_params[] = {
2074 ISOLATE_PARAMETER,
2075 new IdParameter("scriptId", true),
2076 new UIntParameter("line", true),
2077 new UIntParameter("column", false),
2078 NULL,
2079 };
2080
2081
2082 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) {
2083 const char* script_id_param = js->LookupParam("scriptId");
2084 Object& obj =
2085 Object::Handle(LookupHeapObject(isolate, script_id_param, NULL));
2086 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
2087 PrintInvalidParamError(js, "scriptId");
2088 return true;
2089 }
2090 const Script& script = Script::Cast(obj);
2091 const String& script_uri = String::Handle(script.url());
2092 ASSERT(!script_uri.IsNull());
2093 return AddBreakpointCommon(isolate, js, script_uri);
2094 }
2095
2096
2097 static const MethodParameter* add_breakpoint_with_script_uri_params[] = {
2098 ISOLATE_PARAMETER,
2099 new IdParameter("scriptUri", true),
2100 new UIntParameter("line", true),
2101 new UIntParameter("column", false),
2102 NULL,
2103 };
2104
2105
2106 static bool AddBreakpointWithScriptUri(Isolate* isolate, JSONStream* js) {
2107 const char* script_uri_param = js->LookupParam("scriptUri");
2108 const String& script_uri = String::Handle(String::New(script_uri_param));
2109 return AddBreakpointCommon(isolate, js, script_uri);
2110 }
2111
2112
2103 static const MethodParameter* add_breakpoint_at_entry_params[] = { 2113 static const MethodParameter* add_breakpoint_at_entry_params[] = {
2104 ISOLATE_PARAMETER, 2114 ISOLATE_PARAMETER,
2105 new IdParameter("functionId", true), 2115 new IdParameter("functionId", true),
2106 NULL, 2116 NULL,
2107 }; 2117 };
2108 2118
2109 2119
2110 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { 2120 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) {
2111 const char* function_id = js->LookupParam("functionId"); 2121 const char* function_id = js->LookupParam("functionId");
2112 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); 2122 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL));
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 { "_echo", Echo, 3124 { "_echo", Echo,
3115 NULL }, 3125 NULL },
3116 { "_respondWithMalformedJson", RespondWithMalformedJson, 3126 { "_respondWithMalformedJson", RespondWithMalformedJson,
3117 NULL }, 3127 NULL },
3118 { "_respondWithMalformedObject", RespondWithMalformedObject, 3128 { "_respondWithMalformedObject", RespondWithMalformedObject,
3119 NULL }, 3129 NULL },
3120 { "_triggerEchoEvent", TriggerEchoEvent, 3130 { "_triggerEchoEvent", TriggerEchoEvent,
3121 NULL }, 3131 NULL },
3122 { "addBreakpoint", AddBreakpoint, 3132 { "addBreakpoint", AddBreakpoint,
3123 add_breakpoint_params }, 3133 add_breakpoint_params },
3134 { "addBreakpointWithScriptUri", AddBreakpointWithScriptUri,
3135 add_breakpoint_with_script_uri_params },
3124 { "addBreakpointAtEntry", AddBreakpointAtEntry, 3136 { "addBreakpointAtEntry", AddBreakpointAtEntry,
3125 add_breakpoint_at_entry_params }, 3137 add_breakpoint_at_entry_params },
3126 { "_addBreakpointAtActivation", AddBreakpointAtActivation, 3138 { "_addBreakpointAtActivation", AddBreakpointAtActivation,
3127 add_breakpoint_at_activation_params }, 3139 add_breakpoint_at_activation_params },
3128 { "_clearCpuProfile", ClearCpuProfile, 3140 { "_clearCpuProfile", ClearCpuProfile,
3129 clear_cpu_profile_params }, 3141 clear_cpu_profile_params },
3130 { "evaluate", Evaluate, 3142 { "evaluate", Evaluate,
3131 evaluate_params }, 3143 evaluate_params },
3132 { "evaluateInFrame", EvaluateInFrame, 3144 { "evaluateInFrame", EvaluateInFrame,
3133 evaluate_in_frame_params }, 3145 evaluate_in_frame_params },
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3209 ServiceMethodDescriptor& method = service_methods_[i]; 3221 ServiceMethodDescriptor& method = service_methods_[i];
3210 if (strcmp(method_name, method.name) == 0) { 3222 if (strcmp(method_name, method.name) == 0) {
3211 return &method; 3223 return &method;
3212 } 3224 }
3213 } 3225 }
3214 return NULL; 3226 return NULL;
3215 } 3227 }
3216 3228
3217 3229
3218 } // namespace dart 3230 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/service/service.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698