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

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

Issue 1846443002: - Remove --coverage_dir flag and old-style coverage service requests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove obsolete tests. Created 4 years, 8 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/object.cc ('k') | runtime/vm/vm_sources.gypi » ('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
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/coverage.h"
13 #include "vm/cpu.h" 12 #include "vm/cpu.h"
14 #include "vm/dart_api_impl.h" 13 #include "vm/dart_api_impl.h"
15 #include "vm/dart_api_state.h" 14 #include "vm/dart_api_state.h"
16 #include "vm/dart_entry.h" 15 #include "vm/dart_entry.h"
17 #include "vm/debugger.h" 16 #include "vm/debugger.h"
18 #include "vm/isolate.h" 17 #include "vm/isolate.h"
19 #include "vm/lockers.h" 18 #include "vm/lockers.h"
20 #include "vm/message.h" 19 #include "vm/message.h"
21 #include "vm/message_handler.h" 20 #include "vm/message_handler.h"
22 #include "vm/native_entry.h" 21 #include "vm/native_entry.h"
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 JSONArray samples(&jsobj, "samples"); 2277 JSONArray samples(&jsobj, "samples");
2279 for (int i = 0; i < storage.Length(); i++) { 2278 for (int i = 0; i < storage.Length(); i++) {
2280 const Object& sample = Object::Handle(storage.At(i)); 2279 const Object& sample = Object::Handle(storage.At(i));
2281 samples.AddValue(sample); 2280 samples.AddValue(sample);
2282 } 2281 }
2283 } 2282 }
2284 return true; 2283 return true;
2285 } 2284 }
2286 2285
2287 2286
2288 class LibraryCoverageFilter : public CoverageFilter {
2289 public:
2290 explicit LibraryCoverageFilter(const Library& lib) : lib_(lib) {}
2291 bool ShouldOutputCoverageFor(const Library& lib,
2292 const Script& script,
2293 const Class& cls,
2294 const Function& func) const {
2295 return lib.raw() == lib_.raw();
2296 }
2297 private:
2298 const Library& lib_;
2299 };
2300
2301
2302 class ScriptCoverageFilter : public CoverageFilter {
2303 public:
2304 explicit ScriptCoverageFilter(const Script& script)
2305 : script_(script) {}
2306 bool ShouldOutputCoverageFor(const Library& lib,
2307 const Script& script,
2308 const Class& cls,
2309 const Function& func) const {
2310 return script.raw() == script_.raw();
2311 }
2312 private:
2313 const Script& script_;
2314 };
2315
2316
2317 class ClassCoverageFilter : public CoverageFilter {
2318 public:
2319 explicit ClassCoverageFilter(const Class& cls) : cls_(cls) {}
2320 bool ShouldOutputCoverageFor(const Library& lib,
2321 const Script& script,
2322 const Class& cls,
2323 const Function& func) const {
2324 return cls.raw() == cls_.raw();
2325 }
2326 private:
2327 const Class& cls_;
2328 };
2329
2330
2331 class FunctionCoverageFilter : public CoverageFilter {
2332 public:
2333 explicit FunctionCoverageFilter(const Function& func) : func_(func) {}
2334 bool ShouldOutputCoverageFor(const Library& lib,
2335 const Script& script,
2336 const Class& cls,
2337 const Function& func) const {
2338 return func.raw() == func_.raw();
2339 }
2340 private:
2341 const Function& func_;
2342 };
2343
2344
2345 static bool GetHitsOrSites(Thread* thread, JSONStream* js, bool as_sites) {
2346 if (!thread->isolate()->compilation_allowed()) {
2347 js->PrintError(kFeatureDisabled,
2348 "Cannot get coverage data when running a precompiled program.");
2349 return true;
2350 }
2351 if (!js->HasParam("targetId")) {
2352 CodeCoverage::PrintJSON(thread, js, NULL, as_sites);
2353 return true;
2354 }
2355 const char* target_id = js->LookupParam("targetId");
2356 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, NULL));
2357 if (obj.raw() == Object::sentinel().raw()) {
2358 PrintInvalidParamError(js, "targetId");
2359 return true;
2360 }
2361 if (obj.IsScript()) {
2362 ScriptCoverageFilter sf(Script::Cast(obj));
2363 CodeCoverage::PrintJSON(thread, js, &sf, as_sites);
2364 return true;
2365 }
2366 if (obj.IsLibrary()) {
2367 LibraryCoverageFilter lf(Library::Cast(obj));
2368 CodeCoverage::PrintJSON(thread, js, &lf, as_sites);
2369 return true;
2370 }
2371 if (obj.IsClass()) {
2372 ClassCoverageFilter cf(Class::Cast(obj));
2373 CodeCoverage::PrintJSON(thread, js, &cf, as_sites);
2374 return true;
2375 }
2376 if (obj.IsFunction()) {
2377 FunctionCoverageFilter ff(Function::Cast(obj));
2378 CodeCoverage::PrintJSON(thread, js, &ff, as_sites);
2379 return true;
2380 }
2381 js->PrintError(kInvalidParams,
2382 "%s: invalid 'targetId' parameter: "
2383 "id '%s' does not correspond to a "
2384 "script, library, class, or function",
2385 js->method(), target_id);
2386 return true;
2387 }
2388
2389
2390 static const MethodParameter* get_coverage_params[] = {
2391 RUNNABLE_ISOLATE_PARAMETER,
2392 new IdParameter("targetId", false),
2393 NULL,
2394 };
2395
2396
2397 static bool GetCoverage(Thread* thread, JSONStream* js) {
2398 // TODO(rmacnak): Remove this response; it is subsumed by GetCallSiteData.
2399 return GetHitsOrSites(thread, js, false);
2400 }
2401
2402
2403 static const char* const report_enum_names[] = { 2287 static const char* const report_enum_names[] = {
2404 SourceReport::kCallSitesStr, 2288 SourceReport::kCallSitesStr,
2405 SourceReport::kCoverageStr, 2289 SourceReport::kCoverageStr,
2406 SourceReport::kPossibleBreakpointsStr, 2290 SourceReport::kPossibleBreakpointsStr,
2407 SourceReport::kProfileStr, 2291 SourceReport::kProfileStr,
2408 NULL, 2292 NULL,
2409 }; 2293 };
2410 2294
2411 2295
2412 static const MethodParameter* get_source_report_params[] = { 2296 static const MethodParameter* get_source_report_params[] = {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2481 } 2365 }
2482 SourceReport report(report_set, compile_mode); 2366 SourceReport report(report_set, compile_mode);
2483 report.PrintJSON(js, 2367 report.PrintJSON(js,
2484 script, 2368 script,
2485 TokenPosition(start_pos), 2369 TokenPosition(start_pos),
2486 TokenPosition(end_pos)); 2370 TokenPosition(end_pos));
2487 return true; 2371 return true;
2488 } 2372 }
2489 2373
2490 2374
2491 static const MethodParameter* get_call_site_data_params[] = {
2492 RUNNABLE_ISOLATE_PARAMETER,
2493 new IdParameter("targetId", false),
2494 NULL,
2495 };
2496
2497
2498 static bool GetCallSiteData(Thread* thread, JSONStream* js) {
2499 return GetHitsOrSites(thread, js, true);
2500 }
2501
2502
2503 static bool AddBreakpointCommon(Thread* thread, 2375 static bool AddBreakpointCommon(Thread* thread,
2504 JSONStream* js, 2376 JSONStream* js,
2505 const String& script_uri) { 2377 const String& script_uri) {
2506 if (!thread->isolate()->compilation_allowed()) { 2378 if (!thread->isolate()->compilation_allowed()) {
2507 js->PrintError(kFeatureDisabled, 2379 js->PrintError(kFeatureDisabled,
2508 "Cannot use breakpoints when running a precompiled program."); 2380 "Cannot use breakpoints when running a precompiled program.");
2509 return true; 2381 return true;
2510 } 2382 }
2511 const char* line_param = js->LookupParam("line"); 2383 const char* line_param = js->LookupParam("line");
2512 intptr_t line = UIntParameter::Parse(line_param); 2384 intptr_t line = UIntParameter::Parse(line_param);
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
4007 { "_clearVMTimeline", ClearVMTimeline, 3879 { "_clearVMTimeline", ClearVMTimeline,
4008 clear_vm_timeline_params, }, 3880 clear_vm_timeline_params, },
4009 { "evaluate", Evaluate, 3881 { "evaluate", Evaluate,
4010 evaluate_params }, 3882 evaluate_params },
4011 { "evaluateInFrame", EvaluateInFrame, 3883 { "evaluateInFrame", EvaluateInFrame,
4012 evaluate_in_frame_params }, 3884 evaluate_in_frame_params },
4013 { "_getAllocationProfile", GetAllocationProfile, 3885 { "_getAllocationProfile", GetAllocationProfile,
4014 get_allocation_profile_params }, 3886 get_allocation_profile_params },
4015 { "_getAllocationSamples", GetAllocationSamples, 3887 { "_getAllocationSamples", GetAllocationSamples,
4016 get_allocation_samples_params }, 3888 get_allocation_samples_params },
4017 { "_getCallSiteData", GetCallSiteData,
4018 get_call_site_data_params },
4019 { "getClassList", GetClassList, 3889 { "getClassList", GetClassList,
4020 get_class_list_params }, 3890 get_class_list_params },
4021 { "_getCoverage", GetCoverage,
4022 get_coverage_params },
4023 { "_getCpuProfile", GetCpuProfile, 3891 { "_getCpuProfile", GetCpuProfile,
4024 get_cpu_profile_params }, 3892 get_cpu_profile_params },
4025 { "_getCpuProfileTimeline", GetCpuProfileTimeline, 3893 { "_getCpuProfileTimeline", GetCpuProfileTimeline,
4026 get_cpu_profile_timeline_params }, 3894 get_cpu_profile_timeline_params },
4027 { "getFlagList", GetFlagList, 3895 { "getFlagList", GetFlagList,
4028 get_flag_list_params }, 3896 get_flag_list_params },
4029 { "_getHeapMap", GetHeapMap, 3897 { "_getHeapMap", GetHeapMap,
4030 get_heap_map_params }, 3898 get_heap_map_params },
4031 { "_getInboundReferences", GetInboundReferences, 3899 { "_getInboundReferences", GetInboundReferences,
4032 get_inbound_references_params }, 3900 get_inbound_references_params },
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 if (strcmp(method_name, method.name) == 0) { 3975 if (strcmp(method_name, method.name) == 0) {
4108 return &method; 3976 return &method;
4109 } 3977 }
4110 } 3978 }
4111 return NULL; 3979 return NULL;
4112 } 3980 }
4113 3981
4114 #endif // !PRODUCT 3982 #endif // !PRODUCT
4115 3983
4116 } // namespace dart 3984 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698