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

Unified Diff: runtime/vm/service.cc

Issue 376333002: vm/service/observatory: Add coverage for functions, some tests, and fix buggy filter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add observatory deployed/ Created 6 years, 5 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
« no previous file with comments | « runtime/vm/coverage_test.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 0928897c9ab60950c6b009fa7bb4736edf763b6d..4acc49b499f38407e169135d0499a8243e3b71f5 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -194,6 +194,20 @@ class ClassCoverageFilter : public CoverageFilter {
};
+class FunctionCoverageFilter : public CoverageFilter {
+ public:
+ explicit FunctionCoverageFilter(const Function& func) : func_(func) {}
+ bool ShouldOutputCoverageFor(const Library& lib,
+ const String& script_url,
+ const Class& cls,
+ const Function& func) const {
+ return func.raw() == func_.raw();
+ }
+ private:
+ const Function& func_;
+};
+
+
static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
return reinterpret_cast<uint8_t*>(new_ptr);
@@ -1111,10 +1125,18 @@ static bool HandleClassesDispatchers(Isolate* isolate, const Class& cls,
}
+static bool HandleClassesFunctionsCoverage(
+ Isolate* isolate, const Function& func, JSONStream* js) {
+ FunctionCoverageFilter filter(func);
+ CodeCoverage::PrintJSON(isolate, js, &filter);
+ return true;
+}
+
+
static bool HandleClassesFunctions(Isolate* isolate, const Class& cls,
JSONStream* js) {
intptr_t id;
- if (js->num_arguments() > 4) {
+ if (js->num_arguments() > 5) {
PrintError(js, "Command too long");
return true;
}
@@ -1128,7 +1150,19 @@ static bool HandleClassesFunctions(Isolate* isolate, const Class& cls,
PrintError(js, "Function %" Pd " not found", id);
return true;
}
- func.PrintJSON(js, false);
+ if (js->num_arguments() == 4) {
+ func.PrintJSON(js, false);
+ return true;
+ } else {
+ const char* subcollection = js->GetArgument(4);
+ if (strcmp(subcollection, "coverage") == 0) {
+ return HandleClassesFunctionsCoverage(isolate, func, js);
+ } else {
+ PrintError(js, "Invalid sub collection %s", subcollection);
+ return true;
+ }
+ }
+ UNREACHABLE();
return true;
}
« no previous file with comments | « runtime/vm/coverage_test.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698