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

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

Issue 351373002: Coverage API revamp (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 unified diff | Download patch | Annotate | Revision Log
« runtime/vm/coverage.cc ('K') | « runtime/vm/object_test.cc ('k') | no next file » | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 private: 146 private:
147 char* name_; 147 char* name_;
148 Dart_ServiceRequestCallback callback_; 148 Dart_ServiceRequestCallback callback_;
149 void* user_data_; 149 void* user_data_;
150 EmbedderServiceHandler* next_; 150 EmbedderServiceHandler* next_;
151 }; 151 };
152 152
153 153
154 class LibraryFilter : public CoverageFilter {
Michael Lippautz (Google) 2014/06/27 00:16:48 We could name those to SimpleXXXFilter and include
Cutch 2014/06/27 15:07:19 I think it's okay to leave them here with the name
Michael Lippautz (Google) 2014/06/27 17:12:24 Done.
155 public:
156 explicit LibraryFilter(const Library& lib) : lib_(lib) {}
157 ~LibraryFilter() {}
158 bool GetCoverage(const Library& lib,
159 const Script& script,
160 const Class& cls,
161 const Function& func) {
162 return lib.raw() == lib_.raw();
163 }
164 private:
165 const Library& lib_;
166 };
167
168
169 class ScriptFilter : public CoverageFilter {
170 public:
171 explicit ScriptFilter(const Script& script) : script_(script) {}
172 ~ScriptFilter() {}
173 bool GetCoverage(const Library& lib,
174 const Script& script,
175 const Class& cls,
176 const Function& func) {
177 return script.raw() == script_.raw();
178 }
179 private:
180 const Script& script_;
181 };
182
183
184 class ClassFilter : public CoverageFilter {
185 public:
186 explicit ClassFilter(const Class& cls) : cls_(cls) {}
187 ~ClassFilter() {}
188 bool GetCoverage(const Library& lib,
189 const Script& script,
190 const Class& cls,
191 const Function& func) {
192 return cls.raw() == cls_.raw();
193 }
194 private:
195 const Class& cls_;
196 };
197
198
154 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 199 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
155 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 200 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
156 return reinterpret_cast<uint8_t*>(new_ptr); 201 return reinterpret_cast<uint8_t*>(new_ptr);
157 } 202 }
158 203
159 204
160 static void SendIsolateServiceMessage(Dart_NativeArguments args) { 205 static void SendIsolateServiceMessage(Dart_NativeArguments args) {
161 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 206 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
162 Isolate* isolate = arguments->isolate(); 207 Isolate* isolate = arguments->isolate();
163 StackZone zone(isolate); 208 StackZone zone(isolate);
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 jsobj.AddProperty("totalCount", count); 1245 jsobj.AddProperty("totalCount", count);
1201 jsobj.AddProperty("sampleCount", storage.Length()); 1246 jsobj.AddProperty("sampleCount", storage.Length());
1202 jsobj.AddProperty("sample", storage); 1247 jsobj.AddProperty("sample", storage);
1203 return true; 1248 return true;
1204 } 1249 }
1205 1250
1206 1251
1207 static bool HandleClassesCoverage(Isolate* isolate, 1252 static bool HandleClassesCoverage(Isolate* isolate,
1208 const Class& cls, 1253 const Class& cls,
1209 JSONStream* stream) { 1254 JSONStream* stream) {
1210 CodeCoverage::PrintJSONForClass(cls, stream); 1255 ClassFilter cf(cls);
1256 CodeCoverage::PrintJSON(isolate, stream, &cf);
1211 return true; 1257 return true;
1212 } 1258 }
1213 1259
1214 1260
1215 static bool HandleClasses(Isolate* isolate, JSONStream* js) { 1261 static bool HandleClasses(Isolate* isolate, JSONStream* js) {
1216 if (js->num_arguments() == 1) { 1262 if (js->num_arguments() == 1) {
1217 ClassTable* table = isolate->class_table(); 1263 ClassTable* table = isolate->class_table();
1218 JSONObject jsobj(js); 1264 JSONObject jsobj(js);
1219 table->PrintToJSONObject(&jsobj); 1265 table->PrintToJSONObject(&jsobj);
1220 return true; 1266 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 Array::empty_array(), 1329 Array::empty_array(),
1284 Array::empty_array())); 1330 Array::empty_array()));
1285 result.PrintJSON(js, true); 1331 result.PrintJSON(js, true);
1286 return true; 1332 return true;
1287 } 1333 }
1288 1334
1289 1335
1290 static bool HandleLibrariesCoverage(Isolate* isolate, 1336 static bool HandleLibrariesCoverage(Isolate* isolate,
1291 const Library& lib, 1337 const Library& lib,
1292 JSONStream* js) { 1338 JSONStream* js) {
1293 CodeCoverage::PrintJSONForLibrary(lib, Script::Handle(), js); 1339 LibraryFilter lf(lib);
1340 CodeCoverage::PrintJSON(isolate, js, &lf);
1294 return true; 1341 return true;
1295 } 1342 }
1296 1343
1297 1344
1298 static bool HandleLibraries(Isolate* isolate, JSONStream* js) { 1345 static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
1299 // TODO(johnmccutchan): Support fields and functions on libraries. 1346 // TODO(johnmccutchan): Support fields and functions on libraries.
1300 REQUIRE_COLLECTION_ID("libraries"); 1347 REQUIRE_COLLECTION_ID("libraries");
1301 const GrowableObjectArray& libs = 1348 const GrowableObjectArray& libs =
1302 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 1349 GrowableObjectArray::Handle(isolate->object_store()->libraries());
1303 ASSERT(!libs.IsNull()); 1350 ASSERT(!libs.IsNull());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 1536
1490 static bool HandleScriptsFetch( 1537 static bool HandleScriptsFetch(
1491 Isolate* isolate, const Script& script, JSONStream* js) { 1538 Isolate* isolate, const Script& script, JSONStream* js) {
1492 script.PrintJSON(js, false); 1539 script.PrintJSON(js, false);
1493 return true; 1540 return true;
1494 } 1541 }
1495 1542
1496 1543
1497 static bool HandleScriptsCoverage( 1544 static bool HandleScriptsCoverage(
1498 Isolate* isolate, const Script& script, JSONStream* js) { 1545 Isolate* isolate, const Script& script, JSONStream* js) {
1499 CodeCoverage::PrintJSONForScript(script, js); 1546 ScriptFilter sf(script);
1547 CodeCoverage::PrintJSON(isolate, js, &sf);
1500 return true; 1548 return true;
1501 } 1549 }
1502 1550
1503 1551
1504 static bool HandleScripts(Isolate* isolate, JSONStream* js) { 1552 static bool HandleScripts(Isolate* isolate, JSONStream* js) {
1505 if (js->num_arguments() == 1) { 1553 if (js->num_arguments() == 1) {
1506 // Enumerate all scripts. 1554 // Enumerate all scripts.
1507 return HandleScriptsEnumerate(isolate, js); 1555 return HandleScriptsEnumerate(isolate, js);
1508 } 1556 }
1509 // Subcommands of scripts require a valid script id. 1557 // Subcommands of scripts require a valid script id.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 } else { 1767 } else {
1720 PrintError(js, "Invalid tags option value: %s\n", tags_option); 1768 PrintError(js, "Invalid tags option value: %s\n", tags_option);
1721 return true; 1769 return true;
1722 } 1770 }
1723 } 1771 }
1724 Profiler::PrintJSON(isolate, js, full_profile, tag_order); 1772 Profiler::PrintJSON(isolate, js, full_profile, tag_order);
1725 return true; 1773 return true;
1726 } 1774 }
1727 1775
1728 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { 1776 static bool HandleCoverage(Isolate* isolate, JSONStream* js) {
1729 CodeCoverage::PrintJSON(isolate, js); 1777 CodeCoverage::PrintJSON(isolate, js, NULL);
1730 return true; 1778 return true;
1731 } 1779 }
1732 1780
1733 1781
1734 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) { 1782 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) {
1735 bool should_reset_accumulator = false; 1783 bool should_reset_accumulator = false;
1736 bool should_collect = false; 1784 bool should_collect = false;
1737 if (js->num_arguments() != 1) { 1785 if (js->num_arguments() != 1) {
1738 PrintError(js, "Command too long"); 1786 PrintError(js, "Command too long");
1739 return true; 1787 return true;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 while (current != NULL) { 2250 while (current != NULL) {
2203 if (strcmp(name, current->name()) == 0) { 2251 if (strcmp(name, current->name()) == 0) {
2204 return current; 2252 return current;
2205 } 2253 }
2206 current = current->next(); 2254 current = current->next();
2207 } 2255 }
2208 return NULL; 2256 return NULL;
2209 } 2257 }
2210 2258
2211 } // namespace dart 2259 } // namespace dart
OLDNEW
« runtime/vm/coverage.cc ('K') | « runtime/vm/object_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698