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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/coverage_test.cc ('k') | runtime/vm/service_test.cc » ('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 "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const String& script_url, 187 const String& script_url,
188 const Class& cls, 188 const Class& cls,
189 const Function& func) const { 189 const Function& func) const {
190 return cls.raw() == cls_.raw(); 190 return cls.raw() == cls_.raw();
191 } 191 }
192 private: 192 private:
193 const Class& cls_; 193 const Class& cls_;
194 }; 194 };
195 195
196 196
197 class FunctionCoverageFilter : public CoverageFilter {
198 public:
199 explicit FunctionCoverageFilter(const Function& func) : func_(func) {}
200 bool ShouldOutputCoverageFor(const Library& lib,
201 const String& script_url,
202 const Class& cls,
203 const Function& func) const {
204 return func.raw() == func_.raw();
205 }
206 private:
207 const Function& func_;
208 };
209
210
197 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 211 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
198 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 212 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
199 return reinterpret_cast<uint8_t*>(new_ptr); 213 return reinterpret_cast<uint8_t*>(new_ptr);
200 } 214 }
201 215
202 216
203 static void SendIsolateServiceMessage(Dart_NativeArguments args) { 217 static void SendIsolateServiceMessage(Dart_NativeArguments args) {
204 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 218 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
205 Isolate* isolate = arguments->isolate(); 219 Isolate* isolate = arguments->isolate();
206 StackZone zone(isolate); 220 StackZone zone(isolate);
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 func ^= cls.InvocationDispatcherFunctionFromIndex(id); 1118 func ^= cls.InvocationDispatcherFunctionFromIndex(id);
1105 if (func.IsNull()) { 1119 if (func.IsNull()) {
1106 PrintError(js, "Dispatcher %" Pd " not found", id); 1120 PrintError(js, "Dispatcher %" Pd " not found", id);
1107 return true; 1121 return true;
1108 } 1122 }
1109 func.PrintJSON(js, false); 1123 func.PrintJSON(js, false);
1110 return true; 1124 return true;
1111 } 1125 }
1112 1126
1113 1127
1128 static bool HandleClassesFunctionsCoverage(
1129 Isolate* isolate, const Function& func, JSONStream* js) {
1130 FunctionCoverageFilter filter(func);
1131 CodeCoverage::PrintJSON(isolate, js, &filter);
1132 return true;
1133 }
1134
1135
1114 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls, 1136 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls,
1115 JSONStream* js) { 1137 JSONStream* js) {
1116 intptr_t id; 1138 intptr_t id;
1117 if (js->num_arguments() > 4) { 1139 if (js->num_arguments() > 5) {
1118 PrintError(js, "Command too long"); 1140 PrintError(js, "Command too long");
1119 return true; 1141 return true;
1120 } 1142 }
1121 if (!GetIntegerId(js->GetArgument(3), &id)) { 1143 if (!GetIntegerId(js->GetArgument(3), &id)) {
1122 PrintError(js, "Must specify collection object id: functions/id"); 1144 PrintError(js, "Must specify collection object id: functions/id");
1123 return true; 1145 return true;
1124 } 1146 }
1125 Function& func = Function::Handle(); 1147 Function& func = Function::Handle();
1126 func ^= cls.FunctionFromIndex(id); 1148 func ^= cls.FunctionFromIndex(id);
1127 if (func.IsNull()) { 1149 if (func.IsNull()) {
1128 PrintError(js, "Function %" Pd " not found", id); 1150 PrintError(js, "Function %" Pd " not found", id);
1129 return true; 1151 return true;
1130 } 1152 }
1131 func.PrintJSON(js, false); 1153 if (js->num_arguments() == 4) {
1154 func.PrintJSON(js, false);
1155 return true;
1156 } else {
1157 const char* subcollection = js->GetArgument(4);
1158 if (strcmp(subcollection, "coverage") == 0) {
1159 return HandleClassesFunctionsCoverage(isolate, func, js);
1160 } else {
1161 PrintError(js, "Invalid sub collection %s", subcollection);
1162 return true;
1163 }
1164 }
1165 UNREACHABLE();
1132 return true; 1166 return true;
1133 } 1167 }
1134 1168
1135 1169
1136 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls, 1170 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls,
1137 JSONStream* js) { 1171 JSONStream* js) {
1138 intptr_t id; 1172 intptr_t id;
1139 if (js->num_arguments() > 4) { 1173 if (js->num_arguments() > 4) {
1140 PrintError(js, "Command too long"); 1174 PrintError(js, "Command too long");
1141 return true; 1175 return true;
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 while (current != NULL) { 2381 while (current != NULL) {
2348 if (strcmp(name, current->name()) == 0) { 2382 if (strcmp(name, current->name()) == 0) {
2349 return current; 2383 return current;
2350 } 2384 }
2351 current = current->next(); 2385 current = current->next();
2352 } 2386 }
2353 return NULL; 2387 return NULL;
2354 } 2388 }
2355 2389
2356 } // namespace dart 2390 } // namespace dart
OLDNEW
« 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