OLD | NEW |
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 Loading... |
2034 }; | 2034 }; |
2035 | 2035 |
2036 | 2036 |
2037 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { | 2037 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { |
2038 return GetHitsOrSites(isolate, js, true); | 2038 return GetHitsOrSites(isolate, js, true); |
2039 } | 2039 } |
2040 | 2040 |
2041 | 2041 |
2042 static const MethodParameter* add_breakpoint_params[] = { | 2042 static const MethodParameter* add_breakpoint_params[] = { |
2043 ISOLATE_PARAMETER, | 2043 ISOLATE_PARAMETER, |
2044 new IdParameter("scriptId", true), | 2044 new IdParameter("scriptId", false), |
| 2045 new IdParameter("scriptUri", false), |
2045 new UIntParameter("line", true), | 2046 new UIntParameter("line", true), |
| 2047 new UIntParameter("column", false), |
2046 NULL, | 2048 NULL, |
2047 }; | 2049 }; |
2048 | 2050 |
2049 | 2051 |
2050 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { | 2052 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { |
2051 const char* line_param = js->LookupParam("line"); | 2053 const char* line_param = js->LookupParam("line"); |
2052 intptr_t line = UIntParameter::Parse(line_param); | 2054 intptr_t line = UIntParameter::Parse(line_param); |
2053 const char* script_id = js->LookupParam("scriptId"); | 2055 const char* col_param = js->LookupParam("column"); |
2054 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); | 2056 intptr_t col = -1; |
2055 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 2057 if (col_param != NULL) { |
2056 PrintInvalidParamError(js, "scriptId"); | 2058 col = UIntParameter::Parse(col_param); |
| 2059 if (col == 0) { |
| 2060 // Column number is 1-based. |
| 2061 PrintInvalidParamError(js, "column"); |
| 2062 return true; |
| 2063 } |
| 2064 } |
| 2065 const char* script_id_param = js->LookupParam("scriptId"); |
| 2066 const char* script_uri_param = js->LookupParam("scriptUri"); |
| 2067 if (script_id_param == NULL && script_uri_param == NULL) { |
| 2068 js->PrintError(kInvalidParams, |
| 2069 "%s expects the 'scriptId' or the 'scriptUri' parameter", |
| 2070 js->method()); |
2057 return true; | 2071 return true; |
2058 } | 2072 } |
2059 const Script& script = Script::Cast(obj); | 2073 String& script_uri = String::Handle(isolate); |
2060 const String& script_url = String::Handle(script.url()); | 2074 if (script_id_param != NULL) { |
2061 Breakpoint* bpt = | 2075 Object& obj = |
2062 isolate->debugger()->SetBreakpointAtLine(script_url, line); | 2076 Object::Handle(LookupHeapObject(isolate, script_id_param, NULL)); |
| 2077 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
| 2078 PrintInvalidParamError(js, "scriptId"); |
| 2079 return true; |
| 2080 } |
| 2081 const Script& script = Script::Cast(obj); |
| 2082 script_uri = script.url(); |
| 2083 } |
| 2084 if (script_uri_param != NULL) { |
| 2085 script_uri = String::New(script_uri_param); |
| 2086 } |
| 2087 ASSERT(!script_uri.IsNull()); |
| 2088 Breakpoint* bpt = NULL; |
| 2089 bpt = isolate->debugger()->SetBreakpointAtLineCol(script_uri, line, col); |
2063 if (bpt == NULL) { | 2090 if (bpt == NULL) { |
2064 js->PrintError(kCannotAddBreakpoint, | 2091 js->PrintError(kCannotAddBreakpoint, |
2065 "%s: Cannot add breakpoint at line '%s'", | 2092 "%s: Cannot add breakpoint at line '%s'", |
2066 js->method(), line_param); | 2093 js->method(), line_param); |
2067 return true; | 2094 return true; |
2068 } | 2095 } |
2069 bpt->PrintJSON(js); | 2096 bpt->PrintJSON(js); |
2070 return true; | 2097 return true; |
2071 } | 2098 } |
2072 | 2099 |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 | 2886 |
2860 static const MethodParameter* get_version_params[] = { | 2887 static const MethodParameter* get_version_params[] = { |
2861 NO_ISOLATE_PARAMETER, | 2888 NO_ISOLATE_PARAMETER, |
2862 NULL, | 2889 NULL, |
2863 }; | 2890 }; |
2864 | 2891 |
2865 | 2892 |
2866 static bool GetVersion(Isolate* isolate, JSONStream* js) { | 2893 static bool GetVersion(Isolate* isolate, JSONStream* js) { |
2867 JSONObject jsobj(js); | 2894 JSONObject jsobj(js); |
2868 jsobj.AddProperty("type", "Version"); | 2895 jsobj.AddProperty("type", "Version"); |
2869 jsobj.AddProperty("major", static_cast<intptr_t>(2)); | 2896 jsobj.AddProperty("major", static_cast<intptr_t>(3)); |
2870 jsobj.AddProperty("minor", static_cast<intptr_t>(1)); | 2897 jsobj.AddProperty("minor", static_cast<intptr_t>(0)); |
2871 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); | 2898 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); |
2872 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); | 2899 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); |
2873 return true; | 2900 return true; |
2874 } | 2901 } |
2875 | 2902 |
2876 | 2903 |
2877 class ServiceIsolateVisitor : public IsolateVisitor { | 2904 class ServiceIsolateVisitor : public IsolateVisitor { |
2878 public: | 2905 public: |
2879 explicit ServiceIsolateVisitor(JSONArray* jsarr) | 2906 explicit ServiceIsolateVisitor(JSONArray* jsarr) |
2880 : jsarr_(jsarr) { | 2907 : jsarr_(jsarr) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 ServiceMethodDescriptor& method = service_methods_[i]; | 3201 ServiceMethodDescriptor& method = service_methods_[i]; |
3175 if (strcmp(method_name, method.name) == 0) { | 3202 if (strcmp(method_name, method.name) == 0) { |
3176 return &method; | 3203 return &method; |
3177 } | 3204 } |
3178 } | 3205 } |
3179 return NULL; | 3206 return NULL; |
3180 } | 3207 } |
3181 | 3208 |
3182 | 3209 |
3183 } // namespace dart | 3210 } // namespace dart |
OLD | NEW |