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

Unified Diff: runtime/vm/service.cc

Issue 346003003: vmservice: Add /coverage collection to scripts, classes and libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 036abe06fe1c27bf8494d08469f28b0d7f077ca4..73635ef078fb4db9499b33321fc8665d8f3a5013 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -1195,6 +1195,14 @@ static bool HandleClassesInstances(Isolate* isolate, const Class& cls,
}
+static bool HandleClassesCoverage(Isolate* isolate,
+ const Class& cls,
+ JSONStream* stream) {
+ CodeCoverage::PrintJSONForClass(cls, stream);
+ return true;
+}
+
+
static bool HandleClasses(Isolate* isolate, JSONStream* js) {
if (js->num_arguments() == 1) {
ClassTable* table = isolate->class_table();
@@ -1237,6 +1245,8 @@ static bool HandleClasses(Isolate* isolate, JSONStream* js) {
return HandleClassesRetained(isolate, cls, js);
} else if (strcmp(second, "instances") == 0) {
return HandleClassesInstances(isolate, cls, js);
+ } else if (strcmp(second, "coverage") == 0) {
+ return HandleClassesCoverage(isolate, cls, js);
} else {
PrintError(js, "Invalid sub collection %s", second);
return true;
@@ -1268,6 +1278,14 @@ static bool HandleLibrariesEval(Isolate* isolate, const Library& lib,
}
+static bool HandleLibrariesCoverage(Isolate* isolate,
+ const Library& lib,
+ JSONStream* js) {
+ CodeCoverage::PrintJSONForLibrary(lib, js);
+ return true;
+}
+
+
static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
// TODO(johnmccutchan): Support fields and functions on libraries.
REQUIRE_COLLECTION_ID("libraries");
@@ -1287,6 +1305,8 @@ static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
const char* second = js->GetArgument(2);
if (strcmp(second, "eval") == 0) {
return HandleLibrariesEval(isolate, lib, js);
+ } else if (strcmp(second, "coverage") == 0) {
+ return HandleLibrariesCoverage(isolate, lib, js);
} else {
PrintError(js, "Invalid sub collection %s", second);
return true;
@@ -1492,6 +1512,14 @@ static bool HandleScriptsFetch(Isolate* isolate, JSONStream* js) {
}
+static bool HandleScriptsCoverage(Isolate* isolate, JSONStream* js) {
+ String& script_uri = String::Handle(String::DecodeURI(
+ String::Handle(String::New(js->GetArgument(1)))));
+ CodeCoverage::PrintJSONForScript(script_uri, js);
+ return true;
+}
+
+
static bool HandleScripts(Isolate* isolate, JSONStream* js) {
if (js->num_arguments() == 1) {
// Enumerate all scripts.
@@ -1499,6 +1527,13 @@ static bool HandleScripts(Isolate* isolate, JSONStream* js) {
} else if (js->num_arguments() == 2) {
// Fetch specific script.
return HandleScriptsFetch(isolate, js);
+ } else if (js->num_arguments() == 3) {
+ const char* arg = js->GetArgument(2);
+ if (strcmp(arg, "coverage") == 0) {
+ return HandleScriptsCoverage(isolate, js);
+ }
+ PrintError(js, "Unrecognized subcommand '%s'", arg);
+ return true;
} else {
PrintError(js, "Command too long");
return true;

Powered by Google App Engine
This is Rietveld 408576698