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

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

Issue 1645423002: Return an error in many service RPCs if the isolate is not runnable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/json_stream.h ('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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 static void PrintUnrecognizedMethodError(JSONStream* js) { 227 static void PrintUnrecognizedMethodError(JSONStream* js) {
228 js->PrintError(kMethodNotFound, NULL); 228 js->PrintError(kMethodNotFound, NULL);
229 } 229 }
230 230
231 231
232 static void PrintSuccess(JSONStream* js) { 232 static void PrintSuccess(JSONStream* js) {
233 JSONObject jsobj(js); 233 JSONObject jsobj(js);
234 jsobj.AddProperty("type", "Success"); 234 jsobj.AddProperty("type", "Success");
235 } 235 }
236 236
237
237 static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) { 238 static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) {
238 if ((s == NULL) || (*s == '\0')) { 239 if ((s == NULL) || (*s == '\0')) {
239 // Empty string. 240 // Empty string.
240 return false; 241 return false;
241 } 242 }
242 if (id == NULL) { 243 if (id == NULL) {
243 // No id pointer. 244 // No id pointer.
244 return false; 245 return false;
245 } 246 }
246 intptr_t r = 0; 247 intptr_t r = 0;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 398 }
398 399
399 const char* name() const { 400 const char* name() const {
400 return name_; 401 return name_;
401 } 402 }
402 403
403 bool required() const { 404 bool required() const {
404 return required_; 405 return required_;
405 } 406 }
406 407
408 virtual void PrintError(const char* name,
409 const char* value,
410 JSONStream* js) const {
411 PrintInvalidParamError(js, name);
412 }
413
407 private: 414 private:
408 const char* name_; 415 const char* name_;
409 bool required_; 416 bool required_;
410 }; 417 };
411 418
412 419
413 class NoSuchParameter : public MethodParameter { 420 class NoSuchParameter : public MethodParameter {
414 public: 421 public:
415 explicit NoSuchParameter(const char* name) 422 explicit NoSuchParameter(const char* name)
416 : MethodParameter(name, false) { 423 : MethodParameter(name, false) {
417 } 424 }
418 425
419 virtual bool Validate(const char* value) const { 426 virtual bool Validate(const char* value) const {
420 return (value == NULL); 427 return (value == NULL);
421 } 428 }
422 }; 429 };
423 430
424 431
425 #define NO_ISOLATE_PARAMETER new NoSuchParameter("isolateId")
426
427
428 class BoolParameter : public MethodParameter { 432 class BoolParameter : public MethodParameter {
429 public: 433 public:
430 BoolParameter(const char* name, bool required) 434 BoolParameter(const char* name, bool required)
431 : MethodParameter(name, required) { 435 : MethodParameter(name, required) {
432 } 436 }
433 437
434 virtual bool Validate(const char* value) const { 438 virtual bool Validate(const char* value) const {
435 if (value == NULL) { 439 if (value == NULL) {
436 return false; 440 return false;
437 } 441 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 IdParameter(const char* name, bool required) 516 IdParameter(const char* name, bool required)
513 : MethodParameter(name, required) { 517 : MethodParameter(name, required) {
514 } 518 }
515 519
516 virtual bool Validate(const char* value) const { 520 virtual bool Validate(const char* value) const {
517 return (value != NULL); 521 return (value != NULL);
518 } 522 }
519 }; 523 };
520 524
521 525
526 class RunnableIsolateParameter : public MethodParameter {
527 public:
528 explicit RunnableIsolateParameter(const char* name)
529 : MethodParameter(name, true) {
530 }
531
532 virtual bool Validate(const char* value) const {
533 Isolate* isolate = Isolate::Current();
534 return (value != NULL) && (isolate != NULL) && (isolate->is_runnable());
535 }
536
537 virtual void PrintError(const char* name,
538 const char* value,
539 JSONStream* js) const {
540 js->PrintError(kIsolateMustBeRunnable,
541 "Isolate must be runnable before this request is made.");
542 }
543 };
544
545
522 #define ISOLATE_PARAMETER new IdParameter("isolateId", true) 546 #define ISOLATE_PARAMETER new IdParameter("isolateId", true)
523 547 #define NO_ISOLATE_PARAMETER new NoSuchParameter("isolateId")
548 #define RUNNABLE_ISOLATE_PARAMETER new RunnableIsolateParameter("isolateId")
524 549
525 class EnumParameter : public MethodParameter { 550 class EnumParameter : public MethodParameter {
526 public: 551 public:
527 EnumParameter(const char* name, bool required, const char* const* enums) 552 EnumParameter(const char* name, bool required, const char* const* enums)
528 : MethodParameter(name, required), 553 : MethodParameter(name, required),
529 enums_(enums) { 554 enums_(enums) {
530 } 555 }
531 556
532 virtual bool Validate(const char* value) const { 557 virtual bool Validate(const char* value) const {
533 if (value == NULL) { 558 if (value == NULL) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 const MethodParameter* parameter = parameters[i]; 726 const MethodParameter* parameter = parameters[i];
702 const char* name = parameter->name(); 727 const char* name = parameter->name();
703 const bool required = parameter->required(); 728 const bool required = parameter->required();
704 const char* value = js->LookupParam(name); 729 const char* value = js->LookupParam(name);
705 const bool has_parameter = (value != NULL); 730 const bool has_parameter = (value != NULL);
706 if (required && !has_parameter) { 731 if (required && !has_parameter) {
707 PrintMissingParamError(js, name); 732 PrintMissingParamError(js, name);
708 return false; 733 return false;
709 } 734 }
710 if (has_parameter && !parameter->Validate(value)) { 735 if (has_parameter && !parameter->Validate(value)) {
711 PrintInvalidParamError(js, name); 736 parameter->PrintError(name, value, js);
712 return false; 737 return false;
713 } 738 }
714 } 739 }
715 return true; 740 return true;
716 } 741 }
717 742
718 743
719 void Service::PostError(const String& method_name, 744 void Service::PostError(const String& method_name,
720 const Array& parameter_keys, 745 const Array& parameter_keys,
721 const Array& parameter_values, 746 const Array& parameter_values,
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 }; 1188 };
1164 1189
1165 1190
1166 static bool GetIsolate(Thread* thread, JSONStream* js) { 1191 static bool GetIsolate(Thread* thread, JSONStream* js) {
1167 thread->isolate()->PrintJSON(js, false); 1192 thread->isolate()->PrintJSON(js, false);
1168 return true; 1193 return true;
1169 } 1194 }
1170 1195
1171 1196
1172 static const MethodParameter* get_stack_params[] = { 1197 static const MethodParameter* get_stack_params[] = {
1173 ISOLATE_PARAMETER, 1198 RUNNABLE_ISOLATE_PARAMETER,
1174 new BoolParameter("_full", false), 1199 new BoolParameter("_full", false),
1175 NULL, 1200 NULL,
1176 }; 1201 };
1177 1202
1178 1203
1179 static bool GetStack(Thread* thread, JSONStream* js) { 1204 static bool GetStack(Thread* thread, JSONStream* js) {
1180 if (!thread->isolate()->compilation_allowed()) { 1205 if (!thread->isolate()->compilation_allowed()) {
1181 js->PrintError(kFeatureDisabled, 1206 js->PrintError(kFeatureDisabled,
1182 "Cannot get stack when running a precompiled program."); 1207 "Cannot get stack when running a precompiled program.");
1183 return true; 1208 return true;
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 // reporting suprious references when repeatedly looking for the 1797 // reporting suprious references when repeatedly looking for the
1773 // references to an object. 1798 // references to an object.
1774 path.SetAt(i * 2, Object::null_object()); 1799 path.SetAt(i * 2, Object::null_object());
1775 } 1800 }
1776 } 1801 }
1777 return true; 1802 return true;
1778 } 1803 }
1779 1804
1780 1805
1781 static const MethodParameter* get_inbound_references_params[] = { 1806 static const MethodParameter* get_inbound_references_params[] = {
1782 ISOLATE_PARAMETER, 1807 RUNNABLE_ISOLATE_PARAMETER,
1783 NULL, 1808 NULL,
1784 }; 1809 };
1785 1810
1786 1811
1787 static bool GetInboundReferences(Thread* thread, JSONStream* js) { 1812 static bool GetInboundReferences(Thread* thread, JSONStream* js) {
1788 const char* target_id = js->LookupParam("targetId"); 1813 const char* target_id = js->LookupParam("targetId");
1789 if (target_id == NULL) { 1814 if (target_id == NULL) {
1790 PrintMissingParamError(js, "targetId"); 1815 PrintMissingParamError(js, "targetId");
1791 return true; 1816 return true;
1792 } 1817 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 // after looking for a retaining path. 1896 // after looking for a retaining path.
1872 for (intptr_t i = 0; i < limit; ++i) { 1897 for (intptr_t i = 0; i < limit; ++i) {
1873 path.SetAt(i * 2, Object::null_object()); 1898 path.SetAt(i * 2, Object::null_object());
1874 } 1899 }
1875 1900
1876 return true; 1901 return true;
1877 } 1902 }
1878 1903
1879 1904
1880 static const MethodParameter* get_retaining_path_params[] = { 1905 static const MethodParameter* get_retaining_path_params[] = {
1881 ISOLATE_PARAMETER, 1906 RUNNABLE_ISOLATE_PARAMETER,
1882 NULL, 1907 NULL,
1883 }; 1908 };
1884 1909
1885 1910
1886 static bool GetRetainingPath(Thread* thread, JSONStream* js) { 1911 static bool GetRetainingPath(Thread* thread, JSONStream* js) {
1887 const char* target_id = js->LookupParam("targetId"); 1912 const char* target_id = js->LookupParam("targetId");
1888 if (target_id == NULL) { 1913 if (target_id == NULL) {
1889 PrintMissingParamError(js, "targetId"); 1914 PrintMissingParamError(js, "targetId");
1890 return true; 1915 return true;
1891 } 1916 }
(...skipping 22 matching lines...) Expand all
1914 } else { 1939 } else {
1915 PrintInvalidParamError(js, "targetId"); 1940 PrintInvalidParamError(js, "targetId");
1916 } 1941 }
1917 return true; 1942 return true;
1918 } 1943 }
1919 return PrintRetainingPath(thread, &obj, limit, js); 1944 return PrintRetainingPath(thread, &obj, limit, js);
1920 } 1945 }
1921 1946
1922 1947
1923 static const MethodParameter* get_retained_size_params[] = { 1948 static const MethodParameter* get_retained_size_params[] = {
1924 ISOLATE_PARAMETER, 1949 RUNNABLE_ISOLATE_PARAMETER,
1925 new IdParameter("targetId", true), 1950 new IdParameter("targetId", true),
1926 NULL, 1951 NULL,
1927 }; 1952 };
1928 1953
1929 1954
1930 static bool GetRetainedSize(Thread* thread, JSONStream* js) { 1955 static bool GetRetainedSize(Thread* thread, JSONStream* js) {
1931 const char* target_id = js->LookupParam("targetId"); 1956 const char* target_id = js->LookupParam("targetId");
1932 ASSERT(target_id != NULL); 1957 ASSERT(target_id != NULL);
1933 ObjectIdRing::LookupResult lookup_result; 1958 ObjectIdRing::LookupResult lookup_result;
1934 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, 1959 Object& obj = Object::Handle(LookupHeapObject(thread, target_id,
(...skipping 21 matching lines...) Expand all
1956 1981
1957 ObjectGraph graph(thread); 1982 ObjectGraph graph(thread);
1958 intptr_t retained_size = graph.SizeRetainedByInstance(obj); 1983 intptr_t retained_size = graph.SizeRetainedByInstance(obj);
1959 const Object& result = Object::Handle(Integer::New(retained_size)); 1984 const Object& result = Object::Handle(Integer::New(retained_size));
1960 result.PrintJSON(js, true); 1985 result.PrintJSON(js, true);
1961 return true; 1986 return true;
1962 } 1987 }
1963 1988
1964 1989
1965 static const MethodParameter* get_reachable_size_params[] = { 1990 static const MethodParameter* get_reachable_size_params[] = {
1966 ISOLATE_PARAMETER, 1991 RUNNABLE_ISOLATE_PARAMETER,
1967 new IdParameter("targetId", true), 1992 new IdParameter("targetId", true),
1968 NULL, 1993 NULL,
1969 }; 1994 };
1970 1995
1971 1996
1972 static bool GetReachableSize(Thread* thread, JSONStream* js) { 1997 static bool GetReachableSize(Thread* thread, JSONStream* js) {
1973 const char* target_id = js->LookupParam("targetId"); 1998 const char* target_id = js->LookupParam("targetId");
1974 ASSERT(target_id != NULL); 1999 ASSERT(target_id != NULL);
1975 ObjectIdRing::LookupResult lookup_result; 2000 ObjectIdRing::LookupResult lookup_result;
1976 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, 2001 Object& obj = Object::Handle(LookupHeapObject(thread, target_id,
(...skipping 21 matching lines...) Expand all
1998 2023
1999 ObjectGraph graph(thread); 2024 ObjectGraph graph(thread);
2000 intptr_t retained_size = graph.SizeReachableByInstance(obj); 2025 intptr_t retained_size = graph.SizeReachableByInstance(obj);
2001 const Object& result = Object::Handle(Integer::New(retained_size)); 2026 const Object& result = Object::Handle(Integer::New(retained_size));
2002 result.PrintJSON(js, true); 2027 result.PrintJSON(js, true);
2003 return true; 2028 return true;
2004 } 2029 }
2005 2030
2006 2031
2007 static const MethodParameter* evaluate_params[] = { 2032 static const MethodParameter* evaluate_params[] = {
2008 ISOLATE_PARAMETER, 2033 RUNNABLE_ISOLATE_PARAMETER,
2009 NULL, 2034 NULL,
2010 }; 2035 };
2011 2036
2012 2037
2013 static bool Evaluate(Thread* thread, JSONStream* js) { 2038 static bool Evaluate(Thread* thread, JSONStream* js) {
2014 if (!thread->isolate()->compilation_allowed()) { 2039 if (!thread->isolate()->compilation_allowed()) {
2015 js->PrintError(kFeatureDisabled, 2040 js->PrintError(kFeatureDisabled,
2016 "Cannot evaluate when running a precompiled program."); 2041 "Cannot evaluate when running a precompiled program.");
2017 return true; 2042 return true;
2018 } 2043 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 } 2094 }
2070 js->PrintError(kInvalidParams, 2095 js->PrintError(kInvalidParams,
2071 "%s: invalid 'targetId' parameter: " 2096 "%s: invalid 'targetId' parameter: "
2072 "id '%s' does not correspond to a " 2097 "id '%s' does not correspond to a "
2073 "library, class, or instance", js->method(), target_id); 2098 "library, class, or instance", js->method(), target_id);
2074 return true; 2099 return true;
2075 } 2100 }
2076 2101
2077 2102
2078 static const MethodParameter* evaluate_in_frame_params[] = { 2103 static const MethodParameter* evaluate_in_frame_params[] = {
2079 ISOLATE_PARAMETER, 2104 RUNNABLE_ISOLATE_PARAMETER,
2080 new UIntParameter("frameIndex", true), 2105 new UIntParameter("frameIndex", true),
2081 new MethodParameter("expression", true), 2106 new MethodParameter("expression", true),
2082 NULL, 2107 NULL,
2083 }; 2108 };
2084 2109
2085 2110
2086 static bool EvaluateInFrame(Thread* thread, JSONStream* js) { 2111 static bool EvaluateInFrame(Thread* thread, JSONStream* js) {
2087 Isolate* isolate = thread->isolate(); 2112 Isolate* isolate = thread->isolate();
2088 if (!isolate->compilation_allowed()) { 2113 if (!isolate->compilation_allowed()) {
2089 js->PrintError(kFeatureDisabled, 2114 js->PrintError(kFeatureDisabled,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 intptr_t count() const { return count_; } 2159 intptr_t count() const { return count_; }
2135 2160
2136 private: 2161 private:
2137 const Class& cls_; 2162 const Class& cls_;
2138 const Array& storage_; 2163 const Array& storage_;
2139 intptr_t count_; 2164 intptr_t count_;
2140 }; 2165 };
2141 2166
2142 2167
2143 static const MethodParameter* get_instances_params[] = { 2168 static const MethodParameter* get_instances_params[] = {
2144 ISOLATE_PARAMETER, 2169 RUNNABLE_ISOLATE_PARAMETER,
2145 NULL, 2170 NULL,
2146 }; 2171 };
2147 2172
2148 2173
2149 static bool GetInstances(Thread* thread, JSONStream* js) { 2174 static bool GetInstances(Thread* thread, JSONStream* js) {
2150 const char* target_id = js->LookupParam("classId"); 2175 const char* target_id = js->LookupParam("classId");
2151 if (target_id == NULL) { 2176 if (target_id == NULL) {
2152 PrintMissingParamError(js, "classId"); 2177 PrintMissingParamError(js, "classId");
2153 return true; 2178 return true;
2154 } 2179 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 js->PrintError(kInvalidParams, 2317 js->PrintError(kInvalidParams,
2293 "%s: invalid 'targetId' parameter: " 2318 "%s: invalid 'targetId' parameter: "
2294 "id '%s' does not correspond to a " 2319 "id '%s' does not correspond to a "
2295 "script, library, class, or function", 2320 "script, library, class, or function",
2296 js->method(), target_id); 2321 js->method(), target_id);
2297 return true; 2322 return true;
2298 } 2323 }
2299 2324
2300 2325
2301 static const MethodParameter* get_coverage_params[] = { 2326 static const MethodParameter* get_coverage_params[] = {
2302 ISOLATE_PARAMETER, 2327 RUNNABLE_ISOLATE_PARAMETER,
2303 new IdParameter("targetId", false), 2328 new IdParameter("targetId", false),
2304 NULL, 2329 NULL,
2305 }; 2330 };
2306 2331
2307 2332
2308 static bool GetCoverage(Thread* thread, JSONStream* js) { 2333 static bool GetCoverage(Thread* thread, JSONStream* js) {
2309 // TODO(rmacnak): Remove this response; it is subsumed by GetCallSiteData. 2334 // TODO(rmacnak): Remove this response; it is subsumed by GetCallSiteData.
2310 return GetHitsOrSites(thread, js, false); 2335 return GetHitsOrSites(thread, js, false);
2311 } 2336 }
2312 2337
2313 2338
2314 static const char* kCallSitesStr = "_CallSites"; 2339 static const char* kCallSitesStr = "_CallSites";
2315 static const char* kCoverageStr = "Coverage"; 2340 static const char* kCoverageStr = "Coverage";
2316 static const char* kPossibleBreakpointsStr = "PossibleBreakpoints"; 2341 static const char* kPossibleBreakpointsStr = "PossibleBreakpoints";
2317 2342
2318 2343
2319 static const char* const report_enum_names[] = { 2344 static const char* const report_enum_names[] = {
2320 kCallSitesStr, 2345 kCallSitesStr,
2321 kCoverageStr, 2346 kCoverageStr,
2322 kPossibleBreakpointsStr, 2347 kPossibleBreakpointsStr,
2323 NULL, 2348 NULL,
2324 }; 2349 };
2325 2350
2326 2351
2327 static const EnumListParameter* reports_parameter = 2352 static const EnumListParameter* reports_parameter =
2328 new EnumListParameter("reports", true, report_enum_names); 2353 new EnumListParameter("reports", true, report_enum_names);
2329 2354
2330 2355
2331 static const MethodParameter* get_source_report_params[] = { 2356 static const MethodParameter* get_source_report_params[] = {
2332 ISOLATE_PARAMETER, 2357 RUNNABLE_ISOLATE_PARAMETER,
2333 reports_parameter, 2358 reports_parameter,
2334 new IdParameter("scriptId", false), 2359 new IdParameter("scriptId", false),
2335 new UIntParameter("tokenPos", false), 2360 new UIntParameter("tokenPos", false),
2336 new UIntParameter("endTokenPos", false), 2361 new UIntParameter("endTokenPos", false),
2337 new BoolParameter("forceCompile", false), 2362 new BoolParameter("forceCompile", false),
2338 NULL, 2363 NULL,
2339 }; 2364 };
2340 2365
2341 2366
2342 static bool GetSourceReport(Thread* thread, JSONStream* js) { 2367 static bool GetSourceReport(Thread* thread, JSONStream* js) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 return true; 2414 return true;
2390 } 2415 }
2391 } 2416 }
2392 SourceReport report(report_set, compile_mode); 2417 SourceReport report(report_set, compile_mode);
2393 report.PrintJSON(js, script, start_pos, end_pos); 2418 report.PrintJSON(js, script, start_pos, end_pos);
2394 return true; 2419 return true;
2395 } 2420 }
2396 2421
2397 2422
2398 static const MethodParameter* get_call_site_data_params[] = { 2423 static const MethodParameter* get_call_site_data_params[] = {
2399 ISOLATE_PARAMETER, 2424 RUNNABLE_ISOLATE_PARAMETER,
2400 new IdParameter("targetId", false), 2425 new IdParameter("targetId", false),
2401 NULL, 2426 NULL,
2402 }; 2427 };
2403 2428
2404 2429
2405 static bool GetCallSiteData(Thread* thread, JSONStream* js) { 2430 static bool GetCallSiteData(Thread* thread, JSONStream* js) {
2406 return GetHitsOrSites(thread, js, true); 2431 return GetHitsOrSites(thread, js, true);
2407 } 2432 }
2408 2433
2409 2434
(...skipping 26 matching lines...) Expand all
2436 "%s: Cannot add breakpoint at line '%s'", 2461 "%s: Cannot add breakpoint at line '%s'",
2437 js->method(), line_param); 2462 js->method(), line_param);
2438 return true; 2463 return true;
2439 } 2464 }
2440 bpt->PrintJSON(js); 2465 bpt->PrintJSON(js);
2441 return true; 2466 return true;
2442 } 2467 }
2443 2468
2444 2469
2445 static const MethodParameter* add_breakpoint_params[] = { 2470 static const MethodParameter* add_breakpoint_params[] = {
2446 ISOLATE_PARAMETER, 2471 RUNNABLE_ISOLATE_PARAMETER,
2447 new IdParameter("scriptId", true), 2472 new IdParameter("scriptId", true),
2448 new UIntParameter("line", true), 2473 new UIntParameter("line", true),
2449 new UIntParameter("column", false), 2474 new UIntParameter("column", false),
2450 NULL, 2475 NULL,
2451 }; 2476 };
2452 2477
2453 2478
2454 static bool AddBreakpoint(Thread* thread, JSONStream* js) { 2479 static bool AddBreakpoint(Thread* thread, JSONStream* js) {
2455 if (!thread->isolate()->compilation_allowed()) { 2480 if (!thread->isolate()->compilation_allowed()) {
2456 js->PrintError(kFeatureDisabled, 2481 js->PrintError(kFeatureDisabled,
2457 "Cannot use breakpoints when running a precompiled program."); 2482 "Cannot use breakpoints when running a precompiled program.");
2458 return true; 2483 return true;
2459 } 2484 }
2460 const char* script_id_param = js->LookupParam("scriptId"); 2485 const char* script_id_param = js->LookupParam("scriptId");
2461 Object& obj = Object::Handle(LookupHeapObject(thread, script_id_param, NULL)); 2486 Object& obj = Object::Handle(LookupHeapObject(thread, script_id_param, NULL));
2462 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { 2487 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) {
2463 PrintInvalidParamError(js, "scriptId"); 2488 PrintInvalidParamError(js, "scriptId");
2464 return true; 2489 return true;
2465 } 2490 }
2466 const Script& script = Script::Cast(obj); 2491 const Script& script = Script::Cast(obj);
2467 const String& script_uri = String::Handle(script.url()); 2492 const String& script_uri = String::Handle(script.url());
2468 ASSERT(!script_uri.IsNull()); 2493 ASSERT(!script_uri.IsNull());
2469 return AddBreakpointCommon(thread, js, script_uri); 2494 return AddBreakpointCommon(thread, js, script_uri);
2470 } 2495 }
2471 2496
2472 2497
2473 static const MethodParameter* add_breakpoint_with_script_uri_params[] = { 2498 static const MethodParameter* add_breakpoint_with_script_uri_params[] = {
2474 ISOLATE_PARAMETER, 2499 RUNNABLE_ISOLATE_PARAMETER,
2475 new IdParameter("scriptUri", true), 2500 new IdParameter("scriptUri", true),
2476 new UIntParameter("line", true), 2501 new UIntParameter("line", true),
2477 new UIntParameter("column", false), 2502 new UIntParameter("column", false),
2478 NULL, 2503 NULL,
2479 }; 2504 };
2480 2505
2481 2506
2482 static bool AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) { 2507 static bool AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) {
2483 if (!thread->isolate()->compilation_allowed()) { 2508 if (!thread->isolate()->compilation_allowed()) {
2484 js->PrintError(kFeatureDisabled, 2509 js->PrintError(kFeatureDisabled,
2485 "Cannot use breakpoints when running a precompiled program."); 2510 "Cannot use breakpoints when running a precompiled program.");
2486 return true; 2511 return true;
2487 } 2512 }
2488 const char* script_uri_param = js->LookupParam("scriptUri"); 2513 const char* script_uri_param = js->LookupParam("scriptUri");
2489 const String& script_uri = String::Handle(String::New(script_uri_param)); 2514 const String& script_uri = String::Handle(String::New(script_uri_param));
2490 return AddBreakpointCommon(thread, js, script_uri); 2515 return AddBreakpointCommon(thread, js, script_uri);
2491 } 2516 }
2492 2517
2493 2518
2494 static const MethodParameter* add_breakpoint_at_entry_params[] = { 2519 static const MethodParameter* add_breakpoint_at_entry_params[] = {
2495 ISOLATE_PARAMETER, 2520 RUNNABLE_ISOLATE_PARAMETER,
2496 new IdParameter("functionId", true), 2521 new IdParameter("functionId", true),
2497 NULL, 2522 NULL,
2498 }; 2523 };
2499 2524
2500 2525
2501 static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) { 2526 static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) {
2502 if (!thread->isolate()->compilation_allowed()) { 2527 if (!thread->isolate()->compilation_allowed()) {
2503 js->PrintError(kFeatureDisabled, 2528 js->PrintError(kFeatureDisabled,
2504 "Cannot use breakpoints when running a precompiled program."); 2529 "Cannot use breakpoints when running a precompiled program.");
2505 return true; 2530 return true;
(...skipping 12 matching lines...) Expand all
2518 "%s: Cannot add breakpoint at function '%s'", 2543 "%s: Cannot add breakpoint at function '%s'",
2519 js->method(), function.ToCString()); 2544 js->method(), function.ToCString());
2520 return true; 2545 return true;
2521 } 2546 }
2522 bpt->PrintJSON(js); 2547 bpt->PrintJSON(js);
2523 return true; 2548 return true;
2524 } 2549 }
2525 2550
2526 2551
2527 static const MethodParameter* add_breakpoint_at_activation_params[] = { 2552 static const MethodParameter* add_breakpoint_at_activation_params[] = {
2528 ISOLATE_PARAMETER, 2553 RUNNABLE_ISOLATE_PARAMETER,
2529 new IdParameter("objectId", true), 2554 new IdParameter("objectId", true),
2530 NULL, 2555 NULL,
2531 }; 2556 };
2532 2557
2533 2558
2534 static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) { 2559 static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) {
2535 if (!thread->isolate()->compilation_allowed()) { 2560 if (!thread->isolate()->compilation_allowed()) {
2536 js->PrintError(kFeatureDisabled, 2561 js->PrintError(kFeatureDisabled,
2537 "Cannot use breakpoints when running a precompiled program."); 2562 "Cannot use breakpoints when running a precompiled program.");
2538 return true; 2563 return true;
(...skipping 12 matching lines...) Expand all
2551 "%s: Cannot add breakpoint at activation", 2576 "%s: Cannot add breakpoint at activation",
2552 js->method()); 2577 js->method());
2553 return true; 2578 return true;
2554 } 2579 }
2555 bpt->PrintJSON(js); 2580 bpt->PrintJSON(js);
2556 return true; 2581 return true;
2557 } 2582 }
2558 2583
2559 2584
2560 static const MethodParameter* remove_breakpoint_params[] = { 2585 static const MethodParameter* remove_breakpoint_params[] = {
2561 ISOLATE_PARAMETER, 2586 RUNNABLE_ISOLATE_PARAMETER,
2562 NULL, 2587 NULL,
2563 }; 2588 };
2564 2589
2565 2590
2566 static bool RemoveBreakpoint(Thread* thread, JSONStream* js) { 2591 static bool RemoveBreakpoint(Thread* thread, JSONStream* js) {
2567 if (!thread->isolate()->compilation_allowed()) { 2592 if (!thread->isolate()->compilation_allowed()) {
2568 js->PrintError(kFeatureDisabled, 2593 js->PrintError(kFeatureDisabled,
2569 "Cannot use breakpoints when running a precompiled program."); 2594 "Cannot use breakpoints when running a precompiled program.");
2570 return true; 2595 return true;
2571 } 2596 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 TextBuffer* buffer = js->buffer(); 2706 TextBuffer* buffer = js->buffer();
2682 buffer->AddString(String::Cast(result).ToCString()); 2707 buffer->AddString(String::Cast(result).ToCString());
2683 return true; 2708 return true;
2684 } 2709 }
2685 PrintInvalidParamError(js, "metricId"); 2710 PrintInvalidParamError(js, "metricId");
2686 return true; 2711 return true;
2687 } 2712 }
2688 2713
2689 2714
2690 static const MethodParameter* get_isolate_metric_list_params[] = { 2715 static const MethodParameter* get_isolate_metric_list_params[] = {
2691 ISOLATE_PARAMETER, 2716 RUNNABLE_ISOLATE_PARAMETER,
2692 NULL, 2717 NULL,
2693 }; 2718 };
2694 2719
2695 2720
2696 static bool GetIsolateMetricList(Thread* thread, JSONStream* js) { 2721 static bool GetIsolateMetricList(Thread* thread, JSONStream* js) {
2697 bool native_metrics = false; 2722 bool native_metrics = false;
2698 if (js->HasParam("type")) { 2723 if (js->HasParam("type")) {
2699 if (js->ParamIs("type", "Native")) { 2724 if (js->ParamIs("type", "Native")) {
2700 native_metrics = true; 2725 native_metrics = true;
2701 } else if (js->ParamIs("type", "Dart")) { 2726 } else if (js->ParamIs("type", "Dart")) {
2702 native_metrics = false; 2727 native_metrics = false;
2703 } else { 2728 } else {
2704 PrintInvalidParamError(js, "type"); 2729 PrintInvalidParamError(js, "type");
2705 return true; 2730 return true;
2706 } 2731 }
2707 } else { 2732 } else {
2708 PrintMissingParamError(js, "type"); 2733 PrintMissingParamError(js, "type");
2709 return true; 2734 return true;
2710 } 2735 }
2711 if (native_metrics) { 2736 if (native_metrics) {
2712 return HandleNativeMetricsList(thread, js); 2737 return HandleNativeMetricsList(thread, js);
2713 } 2738 }
2714 return HandleDartMetricsList(thread, js); 2739 return HandleDartMetricsList(thread, js);
2715 } 2740 }
2716 2741
2717 2742
2718 static const MethodParameter* get_isolate_metric_params[] = { 2743 static const MethodParameter* get_isolate_metric_params[] = {
2719 ISOLATE_PARAMETER, 2744 RUNNABLE_ISOLATE_PARAMETER,
2720 NULL, 2745 NULL,
2721 }; 2746 };
2722 2747
2723 2748
2724 static bool GetIsolateMetric(Thread* thread, JSONStream* js) { 2749 static bool GetIsolateMetric(Thread* thread, JSONStream* js) {
2725 const char* metric_id = js->LookupParam("metricId"); 2750 const char* metric_id = js->LookupParam("metricId");
2726 if (metric_id == NULL) { 2751 if (metric_id == NULL) {
2727 PrintMissingParamError(js, "metricId"); 2752 PrintMissingParamError(js, "metricId");
2728 return true; 2753 return true;
2729 } 2754 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2857 Int64Parameter::Parse(js->LookupParam("timeOriginMicros")); 2882 Int64Parameter::Parse(js->LookupParam("timeOriginMicros"));
2858 int64_t time_extent_micros = 2883 int64_t time_extent_micros =
2859 Int64Parameter::Parse(js->LookupParam("timeExtentMicros")); 2884 Int64Parameter::Parse(js->LookupParam("timeExtentMicros"));
2860 TimelineEventFilter filter(time_origin_micros, time_extent_micros); 2885 TimelineEventFilter filter(time_origin_micros, time_extent_micros);
2861 timeline_recorder->PrintJSON(js, &filter); 2886 timeline_recorder->PrintJSON(js, &filter);
2862 return true; 2887 return true;
2863 } 2888 }
2864 2889
2865 2890
2866 static const MethodParameter* resume_params[] = { 2891 static const MethodParameter* resume_params[] = {
2867 ISOLATE_PARAMETER, 2892 RUNNABLE_ISOLATE_PARAMETER,
2868 NULL, 2893 NULL,
2869 }; 2894 };
2870 2895
2871 2896
2872 static bool Resume(Thread* thread, JSONStream* js) { 2897 static bool Resume(Thread* thread, JSONStream* js) {
2873 const char* step_param = js->LookupParam("step"); 2898 const char* step_param = js->LookupParam("step");
2874 Isolate* isolate = thread->isolate(); 2899 Isolate* isolate = thread->isolate();
2875 if (isolate->message_handler()->paused_on_start()) { 2900 if (isolate->message_handler()->paused_on_start()) {
2876 // If the user is issuing a 'Over' or an 'Out' step, that is the 2901 // If the user is issuing a 'Over' or an 'Out' step, that is the
2877 // same as a regular resume request. 2902 // same as a regular resume request.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 PrintSuccess(js); 2935 PrintSuccess(js);
2911 return true; 2936 return true;
2912 } 2937 }
2913 2938
2914 js->PrintError(kVMMustBePaused, NULL); 2939 js->PrintError(kVMMustBePaused, NULL);
2915 return true; 2940 return true;
2916 } 2941 }
2917 2942
2918 2943
2919 static const MethodParameter* pause_params[] = { 2944 static const MethodParameter* pause_params[] = {
2920 ISOLATE_PARAMETER, 2945 RUNNABLE_ISOLATE_PARAMETER,
2921 NULL, 2946 NULL,
2922 }; 2947 };
2923 2948
2924 2949
2925 static bool Pause(Thread* thread, JSONStream* js) { 2950 static bool Pause(Thread* thread, JSONStream* js) {
2926 // TODO(turnidge): This interrupt message could have been sent from 2951 // TODO(turnidge): This interrupt message could have been sent from
2927 // the service isolate directly, but would require some special case 2952 // the service isolate directly, but would require some special case
2928 // code. That would prevent this isolate getting double-interrupted 2953 // code. That would prevent this isolate getting double-interrupted
2929 // with OOB messages. 2954 // with OOB messages.
2930 Isolate* isolate = thread->isolate(); 2955 Isolate* isolate = thread->isolate();
2931 isolate->SendInternalLibMessage(Isolate::kInterruptMsg, 2956 isolate->SendInternalLibMessage(Isolate::kInterruptMsg,
2932 isolate->pause_capability()); 2957 isolate->pause_capability());
2933 PrintSuccess(js); 2958 PrintSuccess(js);
2934 return true; 2959 return true;
2935 } 2960 }
2936 2961
2937 2962
2938 static const MethodParameter* get_tag_profile_params[] = { 2963 static const MethodParameter* get_tag_profile_params[] = {
2939 ISOLATE_PARAMETER, 2964 RUNNABLE_ISOLATE_PARAMETER,
2940 NULL, 2965 NULL,
2941 }; 2966 };
2942 2967
2943 2968
2944 static bool GetTagProfile(Thread* thread, JSONStream* js) { 2969 static bool GetTagProfile(Thread* thread, JSONStream* js) {
2945 JSONObject miniProfile(js); 2970 JSONObject miniProfile(js);
2946 miniProfile.AddProperty("type", "TagProfile"); 2971 miniProfile.AddProperty("type", "TagProfile");
2947 thread->isolate()->vm_tag_counters()->PrintToJSONObject(&miniProfile); 2972 thread->isolate()->vm_tag_counters()->PrintToJSONObject(&miniProfile);
2948 return true; 2973 return true;
2949 } 2974 }
(...skipping 13 matching lines...) Expand all
2963 Profile::kNoTags, 2988 Profile::kNoTags,
2964 Profile::kUserVM, 2989 Profile::kUserVM,
2965 Profile::kUser, 2990 Profile::kUser,
2966 Profile::kVMUser, 2991 Profile::kVMUser,
2967 Profile::kVM, 2992 Profile::kVM,
2968 Profile::kNoTags, // Default value. 2993 Profile::kNoTags, // Default value.
2969 }; 2994 };
2970 2995
2971 2996
2972 static const MethodParameter* get_cpu_profile_params[] = { 2997 static const MethodParameter* get_cpu_profile_params[] = {
2973 ISOLATE_PARAMETER, 2998 RUNNABLE_ISOLATE_PARAMETER,
2974 new EnumParameter("tags", true, tags_enum_names), 2999 new EnumParameter("tags", true, tags_enum_names),
2975 new BoolParameter("_codeTransitionTags", false), 3000 new BoolParameter("_codeTransitionTags", false),
2976 new Int64Parameter("timeOriginMicros", false), 3001 new Int64Parameter("timeOriginMicros", false),
2977 new Int64Parameter("timeExtentMicros", false), 3002 new Int64Parameter("timeExtentMicros", false),
2978 NULL, 3003 NULL,
2979 }; 3004 };
2980 3005
2981 3006
2982 // TODO(johnmccutchan): Rename this to GetCpuSamples. 3007 // TODO(johnmccutchan): Rename this to GetCpuSamples.
2983 static bool GetCpuProfile(Thread* thread, JSONStream* js) { 3008 static bool GetCpuProfile(Thread* thread, JSONStream* js) {
(...skipping 10 matching lines...) Expand all
2994 ProfilerService::PrintJSON(js, 3019 ProfilerService::PrintJSON(js,
2995 tag_order, 3020 tag_order,
2996 extra_tags, 3021 extra_tags,
2997 time_origin_micros, 3022 time_origin_micros,
2998 time_extent_micros); 3023 time_extent_micros);
2999 return true; 3024 return true;
3000 } 3025 }
3001 3026
3002 3027
3003 static const MethodParameter* get_cpu_profile_timeline_params[] = { 3028 static const MethodParameter* get_cpu_profile_timeline_params[] = {
3004 ISOLATE_PARAMETER, 3029 RUNNABLE_ISOLATE_PARAMETER,
3005 new EnumParameter("tags", true, tags_enum_names), 3030 new EnumParameter("tags", true, tags_enum_names),
3006 new Int64Parameter("timeOriginMicros", false), 3031 new Int64Parameter("timeOriginMicros", false),
3007 new Int64Parameter("timeExtentMicros", false), 3032 new Int64Parameter("timeExtentMicros", false),
3008 NULL, 3033 NULL,
3009 }; 3034 };
3010 3035
3011 3036
3012 static bool GetCpuProfileTimeline(Thread* thread, JSONStream* js) { 3037 static bool GetCpuProfileTimeline(Thread* thread, JSONStream* js) {
3013 Profile::TagOrder tag_order = 3038 Profile::TagOrder tag_order =
3014 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); 3039 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values);
3015 int64_t time_origin_micros = 3040 int64_t time_origin_micros =
3016 UIntParameter::Parse(js->LookupParam("timeOriginMicros")); 3041 UIntParameter::Parse(js->LookupParam("timeOriginMicros"));
3017 int64_t time_extent_micros = 3042 int64_t time_extent_micros =
3018 UIntParameter::Parse(js->LookupParam("timeExtentMicros")); 3043 UIntParameter::Parse(js->LookupParam("timeExtentMicros"));
3019 ProfilerService::PrintTimelineJSON(js, 3044 ProfilerService::PrintTimelineJSON(js,
3020 tag_order, 3045 tag_order,
3021 time_origin_micros, 3046 time_origin_micros,
3022 time_extent_micros); 3047 time_extent_micros);
3023 return true; 3048 return true;
3024 } 3049 }
3025 3050
3026 3051
3027 static const MethodParameter* get_allocation_samples_params[] = { 3052 static const MethodParameter* get_allocation_samples_params[] = {
3028 ISOLATE_PARAMETER, 3053 RUNNABLE_ISOLATE_PARAMETER,
3029 new EnumParameter("tags", true, tags_enum_names), 3054 new EnumParameter("tags", true, tags_enum_names),
3030 new IdParameter("classId", false), 3055 new IdParameter("classId", false),
3031 new Int64Parameter("timeOriginMicros", false), 3056 new Int64Parameter("timeOriginMicros", false),
3032 new Int64Parameter("timeExtentMicros", false), 3057 new Int64Parameter("timeExtentMicros", false),
3033 NULL, 3058 NULL,
3034 }; 3059 };
3035 3060
3036 3061
3037 static bool GetAllocationSamples(Thread* thread, JSONStream* js) { 3062 static bool GetAllocationSamples(Thread* thread, JSONStream* js) {
3038 Profile::TagOrder tag_order = 3063 Profile::TagOrder tag_order =
(...skipping 14 matching lines...) Expand all
3053 time_origin_micros, 3078 time_origin_micros,
3054 time_extent_micros); 3079 time_extent_micros);
3055 } else { 3080 } else {
3056 PrintInvalidParamError(js, "classId"); 3081 PrintInvalidParamError(js, "classId");
3057 } 3082 }
3058 return true; 3083 return true;
3059 } 3084 }
3060 3085
3061 3086
3062 static const MethodParameter* clear_cpu_profile_params[] = { 3087 static const MethodParameter* clear_cpu_profile_params[] = {
3063 ISOLATE_PARAMETER, 3088 RUNNABLE_ISOLATE_PARAMETER,
3064 NULL, 3089 NULL,
3065 }; 3090 };
3066 3091
3067 3092
3068 static bool ClearCpuProfile(Thread* thread, JSONStream* js) { 3093 static bool ClearCpuProfile(Thread* thread, JSONStream* js) {
3069 ProfilerService::ClearSamples(); 3094 ProfilerService::ClearSamples();
3070 PrintSuccess(js); 3095 PrintSuccess(js);
3071 return true; 3096 return true;
3072 } 3097 }
3073 3098
3074 3099
3075 static const MethodParameter* get_allocation_profile_params[] = { 3100 static const MethodParameter* get_allocation_profile_params[] = {
3076 ISOLATE_PARAMETER, 3101 RUNNABLE_ISOLATE_PARAMETER,
3077 NULL, 3102 NULL,
3078 }; 3103 };
3079 3104
3080 3105
3081 static bool GetAllocationProfile(Thread* thread, JSONStream* js) { 3106 static bool GetAllocationProfile(Thread* thread, JSONStream* js) {
3082 bool should_reset_accumulator = false; 3107 bool should_reset_accumulator = false;
3083 bool should_collect = false; 3108 bool should_collect = false;
3084 if (js->HasParam("reset")) { 3109 if (js->HasParam("reset")) {
3085 if (js->ParamIs("reset", "true")) { 3110 if (js->ParamIs("reset", "true")) {
3086 should_reset_accumulator = true; 3111 should_reset_accumulator = true;
(...skipping 18 matching lines...) Expand all
3105 if (should_collect) { 3130 if (should_collect) {
3106 isolate->UpdateLastAllocationProfileGCTimestamp(); 3131 isolate->UpdateLastAllocationProfileGCTimestamp();
3107 isolate->heap()->CollectAllGarbage(); 3132 isolate->heap()->CollectAllGarbage();
3108 } 3133 }
3109 isolate->class_table()->AllocationProfilePrintJSON(js); 3134 isolate->class_table()->AllocationProfilePrintJSON(js);
3110 return true; 3135 return true;
3111 } 3136 }
3112 3137
3113 3138
3114 static const MethodParameter* get_heap_map_params[] = { 3139 static const MethodParameter* get_heap_map_params[] = {
3115 ISOLATE_PARAMETER, 3140 RUNNABLE_ISOLATE_PARAMETER,
3116 NULL, 3141 NULL,
3117 }; 3142 };
3118 3143
3119 3144
3120 static bool GetHeapMap(Thread* thread, JSONStream* js) { 3145 static bool GetHeapMap(Thread* thread, JSONStream* js) {
3121 Isolate* isolate = thread->isolate(); 3146 Isolate* isolate = thread->isolate();
3122 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); 3147 isolate->heap()->PrintHeapMapToJSONStream(isolate, js);
3123 return true; 3148 return true;
3124 } 3149 }
3125 3150
3126 3151
3127 static const MethodParameter* request_heap_snapshot_params[] = { 3152 static const MethodParameter* request_heap_snapshot_params[] = {
3128 ISOLATE_PARAMETER, 3153 RUNNABLE_ISOLATE_PARAMETER,
3129 NULL, 3154 NULL,
3130 }; 3155 };
3131 3156
3132 3157
3133 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) { 3158 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) {
3134 if (Service::graph_stream.enabled()) { 3159 if (Service::graph_stream.enabled()) {
3135 Service::SendGraphEvent(thread); 3160 Service::SendGraphEvent(thread);
3136 } 3161 }
3137 // TODO(koda): Provide some id that ties this request to async response(s). 3162 // TODO(koda): Provide some id that ties this request to async response(s).
3138 JSONObject jsobj(js); 3163 JSONObject jsobj(js);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 uword obj_begin = RawObject::ToAddr(obj); 3297 uword obj_begin = RawObject::ToAddr(obj);
3273 uword obj_end = obj_begin + obj->Size(); 3298 uword obj_end = obj_begin + obj->Size();
3274 return obj_begin <= addr_ && addr_ < obj_end; 3299 return obj_begin <= addr_ && addr_ < obj_end;
3275 } 3300 }
3276 private: 3301 private:
3277 uword addr_; 3302 uword addr_;
3278 }; 3303 };
3279 3304
3280 3305
3281 static const MethodParameter* get_object_by_address_params[] = { 3306 static const MethodParameter* get_object_by_address_params[] = {
3282 ISOLATE_PARAMETER, 3307 RUNNABLE_ISOLATE_PARAMETER,
3283 NULL, 3308 NULL,
3284 }; 3309 };
3285 3310
3286 3311
3287 static RawObject* GetObjectHelper(Thread* thread, uword addr) { 3312 static RawObject* GetObjectHelper(Thread* thread, uword addr) {
3288 Object& object = Object::Handle(thread->zone()); 3313 Object& object = Object::Handle(thread->zone());
3289 3314
3290 { 3315 {
3291 NoSafepointScope no_safepoint; 3316 NoSafepointScope no_safepoint;
3292 Isolate* isolate = thread->isolate(); 3317 Isolate* isolate = thread->isolate();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 if (obj.IsNull()) { 3352 if (obj.IsNull()) {
3328 PrintSentinel(js, kFreeSentinel); 3353 PrintSentinel(js, kFreeSentinel);
3329 } else { 3354 } else {
3330 obj.PrintJSON(js, ref); 3355 obj.PrintJSON(js, ref);
3331 } 3356 }
3332 return true; 3357 return true;
3333 } 3358 }
3334 3359
3335 3360
3336 static const MethodParameter* get_ports_params[] = { 3361 static const MethodParameter* get_ports_params[] = {
3337 ISOLATE_PARAMETER, 3362 RUNNABLE_ISOLATE_PARAMETER,
3338 NULL, 3363 NULL,
3339 }; 3364 };
3340 3365
3341 3366
3342 static bool GetPorts(Thread* thread, JSONStream* js) { 3367 static bool GetPorts(Thread* thread, JSONStream* js) {
3343 MessageHandler* message_handler = thread->isolate()->message_handler(); 3368 MessageHandler* message_handler = thread->isolate()->message_handler();
3344 PortMap::PrintPortsForMessageHandler(message_handler, js); 3369 PortMap::PrintPortsForMessageHandler(message_handler, js);
3345 return true; 3370 return true;
3346 } 3371 }
3347 3372
(...skipping 12 matching lines...) Expand all
3360 3385
3361 3386
3362 static bool RespondWithMalformedObject(Thread* thread, JSONStream* js) { 3387 static bool RespondWithMalformedObject(Thread* thread, JSONStream* js) {
3363 JSONObject jsobj(js); 3388 JSONObject jsobj(js);
3364 jsobj.AddProperty("bart", "simpson"); 3389 jsobj.AddProperty("bart", "simpson");
3365 return true; 3390 return true;
3366 } 3391 }
3367 3392
3368 3393
3369 static const MethodParameter* get_object_params[] = { 3394 static const MethodParameter* get_object_params[] = {
3370 ISOLATE_PARAMETER, 3395 RUNNABLE_ISOLATE_PARAMETER,
3371 new UIntParameter("offset", false), 3396 new UIntParameter("offset", false),
3372 new UIntParameter("count", false), 3397 new UIntParameter("count", false),
3373 NULL, 3398 NULL,
3374 }; 3399 };
3375 3400
3376 3401
3377 static bool GetObject(Thread* thread, JSONStream* js) { 3402 static bool GetObject(Thread* thread, JSONStream* js) {
3378 const char* id = js->LookupParam("objectId"); 3403 const char* id = js->LookupParam("objectId");
3379 if (id == NULL) { 3404 if (id == NULL) {
3380 PrintMissingParamError(js, "objectId"); 3405 PrintMissingParamError(js, "objectId");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 PrintSentinel(js, kCollectedSentinel); 3447 PrintSentinel(js, kCollectedSentinel);
3423 return true; 3448 return true;
3424 } 3449 }
3425 3450
3426 PrintInvalidParamError(js, "objectId"); 3451 PrintInvalidParamError(js, "objectId");
3427 return true; 3452 return true;
3428 } 3453 }
3429 3454
3430 3455
3431 static const MethodParameter* get_class_list_params[] = { 3456 static const MethodParameter* get_class_list_params[] = {
3432 ISOLATE_PARAMETER, 3457 RUNNABLE_ISOLATE_PARAMETER,
3433 NULL, 3458 NULL,
3434 }; 3459 };
3435 3460
3436 3461
3437 static bool GetClassList(Thread* thread, JSONStream* js) { 3462 static bool GetClassList(Thread* thread, JSONStream* js) {
3438 ClassTable* table = thread->isolate()->class_table(); 3463 ClassTable* table = thread->isolate()->class_table();
3439 JSONObject jsobj(js); 3464 JSONObject jsobj(js);
3440 table->PrintToJSONObject(&jsobj); 3465 table->PrintToJSONObject(&jsobj);
3441 return true; 3466 return true;
3442 } 3467 }
3443 3468
3444 3469
3445 static const MethodParameter* get_type_arguments_list_params[] = { 3470 static const MethodParameter* get_type_arguments_list_params[] = {
3446 ISOLATE_PARAMETER, 3471 RUNNABLE_ISOLATE_PARAMETER,
3447 NULL, 3472 NULL,
3448 }; 3473 };
3449 3474
3450 3475
3451 static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) { 3476 static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) {
3452 bool only_with_instantiations = false; 3477 bool only_with_instantiations = false;
3453 if (js->ParamIs("onlyWithInstantiations", "true")) { 3478 if (js->ParamIs("onlyWithInstantiations", "true")) {
3454 only_with_instantiations = true; 3479 only_with_instantiations = true;
3455 } 3480 }
3456 ObjectStore* object_store = thread->isolate()->object_store(); 3481 ObjectStore* object_store = thread->isolate()->object_store();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 } else { 3670 } else {
3646 JSONObject jsobj(js); 3671 JSONObject jsobj(js);
3647 jsobj.AddProperty("type", "Error"); 3672 jsobj.AddProperty("type", "Error");
3648 jsobj.AddProperty("message", error); 3673 jsobj.AddProperty("message", error);
3649 return true; 3674 return true;
3650 } 3675 }
3651 } 3676 }
3652 3677
3653 3678
3654 static const MethodParameter* set_library_debuggable_params[] = { 3679 static const MethodParameter* set_library_debuggable_params[] = {
3655 ISOLATE_PARAMETER, 3680 RUNNABLE_ISOLATE_PARAMETER,
3656 new IdParameter("libraryId", true), 3681 new IdParameter("libraryId", true),
3657 new BoolParameter("isDebuggable", true), 3682 new BoolParameter("isDebuggable", true),
3658 NULL, 3683 NULL,
3659 }; 3684 };
3660 3685
3661 3686
3662 static bool SetLibraryDebuggable(Thread* thread, JSONStream* js) { 3687 static bool SetLibraryDebuggable(Thread* thread, JSONStream* js) {
3663 const char* lib_id = js->LookupParam("libraryId"); 3688 const char* lib_id = js->LookupParam("libraryId");
3664 ObjectIdRing::LookupResult lookup_result; 3689 ObjectIdRing::LookupResult lookup_result;
3665 Object& obj = Object::Handle(LookupHeapObject(thread, lib_id, 3690 Object& obj = Object::Handle(LookupHeapObject(thread, lib_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3709 if (Service::vm_stream.enabled()) { 3734 if (Service::vm_stream.enabled()) {
3710 ServiceEvent event(NULL, ServiceEvent::kVMUpdate); 3735 ServiceEvent event(NULL, ServiceEvent::kVMUpdate);
3711 Service::HandleEvent(&event); 3736 Service::HandleEvent(&event);
3712 } 3737 }
3713 PrintSuccess(js); 3738 PrintSuccess(js);
3714 return true; 3739 return true;
3715 } 3740 }
3716 3741
3717 3742
3718 static const MethodParameter* set_trace_class_allocation_params[] = { 3743 static const MethodParameter* set_trace_class_allocation_params[] = {
3719 ISOLATE_PARAMETER, 3744 RUNNABLE_ISOLATE_PARAMETER,
3720 new IdParameter("classId", true), 3745 new IdParameter("classId", true),
3721 new BoolParameter("enable", true), 3746 new BoolParameter("enable", true),
3722 NULL, 3747 NULL,
3723 }; 3748 };
3724 3749
3725 3750
3726 static bool SetTraceClassAllocation(Thread* thread, JSONStream* js) { 3751 static bool SetTraceClassAllocation(Thread* thread, JSONStream* js) {
3727 if (!thread->isolate()->compilation_allowed()) { 3752 if (!thread->isolate()->compilation_allowed()) {
3728 js->PrintError(kFeatureDisabled, 3753 js->PrintError(kFeatureDisabled,
3729 "Cannot trace allocation when running a precompiled program."); 3754 "Cannot trace allocation when running a precompiled program.");
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 const ServiceMethodDescriptor& method = service_methods_[i]; 3891 const ServiceMethodDescriptor& method = service_methods_[i];
3867 if (strcmp(method_name, method.name) == 0) { 3892 if (strcmp(method_name, method.name) == 0) {
3868 return &method; 3893 return &method;
3869 } 3894 }
3870 } 3895 }
3871 return NULL; 3896 return NULL;
3872 } 3897 }
3873 3898
3874 3899
3875 } // namespace dart 3900 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/service/service.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698