Chromium Code Reviews| Index: runtime/vm/service.cc |
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
| index 0928897c9ab60950c6b009fa7bb4736edf763b6d..9ce068bc3e299e3c7fffdb19053c31f10000f2b0 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,13 +1125,17 @@ 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) { |
| - PrintError(js, "Command too long"); |
| - return true; |
| - } |
| if (!GetIntegerId(js->GetArgument(3), &id)) { |
|
Cutch
2014/07/10 20:21:06
Please re-insert the check for num_arguments > 5.
Michael Lippautz (Google)
2014/07/11 16:26:53
Done.
|
| PrintError(js, "Must specify collection object id: functions/id"); |
| return true; |
| @@ -1128,7 +1146,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(); |
|
Cutch
2014/07/10 20:21:06
I don't like the way this reads. This code can't e
Michael Lippautz (Google)
2014/07/11 16:26:53
As discussed, ignored :)
|
| return true; |
| } |