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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 GrowableObjectArray& wrapper = GrowableObjectArray::Handle( 1188 GrowableObjectArray& wrapper = GrowableObjectArray::Handle(
1189 GrowableObjectArray::New(storage)); 1189 GrowableObjectArray::New(storage));
1190 wrapper.SetLength(count); 1190 wrapper.SetLength(count);
1191 storage = Array::MakeArray(wrapper); 1191 storage = Array::MakeArray(wrapper);
1192 } 1192 }
1193 storage.PrintJSON(js, true); 1193 storage.PrintJSON(js, true);
1194 return true; 1194 return true;
1195 } 1195 }
1196 1196
1197 1197
1198 static bool HandleClassesCoverage(Isolate* isolate,
1199 const Class& cls,
1200 JSONStream* stream) {
1201 CodeCoverage::PrintJSONForClass(cls, stream);
1202 return true;
1203 }
1204
1205
1198 static bool HandleClasses(Isolate* isolate, JSONStream* js) { 1206 static bool HandleClasses(Isolate* isolate, JSONStream* js) {
1199 if (js->num_arguments() == 1) { 1207 if (js->num_arguments() == 1) {
1200 ClassTable* table = isolate->class_table(); 1208 ClassTable* table = isolate->class_table();
1201 JSONObject jsobj(js); 1209 JSONObject jsobj(js);
1202 table->PrintToJSONObject(&jsobj); 1210 table->PrintToJSONObject(&jsobj);
1203 return true; 1211 return true;
1204 } 1212 }
1205 ASSERT(js->num_arguments() >= 2); 1213 ASSERT(js->num_arguments() >= 2);
1206 intptr_t id; 1214 intptr_t id;
1207 if (!GetIntegerId(js->GetArgument(1), &id)) { 1215 if (!GetIntegerId(js->GetArgument(1), &id)) {
(...skipping 22 matching lines...) Expand all
1230 } else if (strcmp(second, "implicit_closures") == 0) { 1238 } else if (strcmp(second, "implicit_closures") == 0) {
1231 return HandleClassesImplicitClosures(isolate, cls, js); 1239 return HandleClassesImplicitClosures(isolate, cls, js);
1232 } else if (strcmp(second, "dispatchers") == 0) { 1240 } else if (strcmp(second, "dispatchers") == 0) {
1233 return HandleClassesDispatchers(isolate, cls, js); 1241 return HandleClassesDispatchers(isolate, cls, js);
1234 } else if (strcmp(second, "types") == 0) { 1242 } else if (strcmp(second, "types") == 0) {
1235 return HandleClassesTypes(isolate, cls, js); 1243 return HandleClassesTypes(isolate, cls, js);
1236 } else if (strcmp(second, "retained") == 0) { 1244 } else if (strcmp(second, "retained") == 0) {
1237 return HandleClassesRetained(isolate, cls, js); 1245 return HandleClassesRetained(isolate, cls, js);
1238 } else if (strcmp(second, "instances") == 0) { 1246 } else if (strcmp(second, "instances") == 0) {
1239 return HandleClassesInstances(isolate, cls, js); 1247 return HandleClassesInstances(isolate, cls, js);
1248 } else if (strcmp(second, "coverage") == 0) {
1249 return HandleClassesCoverage(isolate, cls, js);
1240 } else { 1250 } else {
1241 PrintError(js, "Invalid sub collection %s", second); 1251 PrintError(js, "Invalid sub collection %s", second);
1242 return true; 1252 return true;
1243 } 1253 }
1244 } 1254 }
1245 UNREACHABLE(); 1255 UNREACHABLE();
1246 return true; 1256 return true;
1247 } 1257 }
1248 1258
1249 1259
(...skipping 11 matching lines...) Expand all
1261 } 1271 }
1262 const String& expr_str = String::Handle(isolate, String::New(expr)); 1272 const String& expr_str = String::Handle(isolate, String::New(expr));
1263 const Object& result = Object::Handle(lib.Evaluate(expr_str, 1273 const Object& result = Object::Handle(lib.Evaluate(expr_str,
1264 Array::empty_array(), 1274 Array::empty_array(),
1265 Array::empty_array())); 1275 Array::empty_array()));
1266 result.PrintJSON(js, true); 1276 result.PrintJSON(js, true);
1267 return true; 1277 return true;
1268 } 1278 }
1269 1279
1270 1280
1281 static bool HandleLibrariesCoverage(Isolate* isolate,
1282 const Library& lib,
1283 JSONStream* js) {
1284 CodeCoverage::PrintJSONForLibrary(lib, js);
1285 return true;
1286 }
1287
1288
1271 static bool HandleLibraries(Isolate* isolate, JSONStream* js) { 1289 static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
1272 // TODO(johnmccutchan): Support fields and functions on libraries. 1290 // TODO(johnmccutchan): Support fields and functions on libraries.
1273 REQUIRE_COLLECTION_ID("libraries"); 1291 REQUIRE_COLLECTION_ID("libraries");
1274 const GrowableObjectArray& libs = 1292 const GrowableObjectArray& libs =
1275 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 1293 GrowableObjectArray::Handle(isolate->object_store()->libraries());
1276 ASSERT(!libs.IsNull()); 1294 ASSERT(!libs.IsNull());
1277 intptr_t id = 0; 1295 intptr_t id = 0;
1278 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1), 1296 CHECK_COLLECTION_ID_BOUNDS("libraries", libs.Length(), js->GetArgument(1),
1279 id, js); 1297 id, js);
1280 Library& lib = Library::Handle(); 1298 Library& lib = Library::Handle();
1281 lib ^= libs.At(id); 1299 lib ^= libs.At(id);
1282 ASSERT(!lib.IsNull()); 1300 ASSERT(!lib.IsNull());
1283 if (js->num_arguments() == 2) { 1301 if (js->num_arguments() == 2) {
1284 lib.PrintJSON(js, false); 1302 lib.PrintJSON(js, false);
1285 return true; 1303 return true;
1286 } else if (js->num_arguments() >= 3) { 1304 } else if (js->num_arguments() >= 3) {
1287 const char* second = js->GetArgument(2); 1305 const char* second = js->GetArgument(2);
1288 if (strcmp(second, "eval") == 0) { 1306 if (strcmp(second, "eval") == 0) {
1289 return HandleLibrariesEval(isolate, lib, js); 1307 return HandleLibrariesEval(isolate, lib, js);
1308 } else if (strcmp(second, "coverage") == 0) {
1309 return HandleLibrariesCoverage(isolate, lib, js);
1290 } else { 1310 } else {
1291 PrintError(js, "Invalid sub collection %s", second); 1311 PrintError(js, "Invalid sub collection %s", second);
1292 return true; 1312 return true;
1293 } 1313 }
1294 } 1314 }
1295 UNREACHABLE(); 1315 UNREACHABLE();
1296 return true; 1316 return true;
1297 } 1317 }
1298 1318
1299 1319
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 return true; 1505 return true;
1486 } 1506 }
1487 } 1507 }
1488 } 1508 }
1489 PrintErrorWithKind(js, "NotFoundError", "Cannot find script %s", 1509 PrintErrorWithKind(js, "NotFoundError", "Cannot find script %s",
1490 requested_url.ToCString()); 1510 requested_url.ToCString());
1491 return true; 1511 return true;
1492 } 1512 }
1493 1513
1494 1514
1515 static bool HandleScriptsCoverage(Isolate* isolate, JSONStream* js) {
1516 String& script_uri = String::Handle(String::DecodeURI(
1517 String::Handle(String::New(js->GetArgument(1)))));
1518 CodeCoverage::PrintJSONForScript(script_uri, js);
1519 return true;
1520 }
1521
1522
1495 static bool HandleScripts(Isolate* isolate, JSONStream* js) { 1523 static bool HandleScripts(Isolate* isolate, JSONStream* js) {
1496 if (js->num_arguments() == 1) { 1524 if (js->num_arguments() == 1) {
1497 // Enumerate all scripts. 1525 // Enumerate all scripts.
1498 return HandleScriptsEnumerate(isolate, js); 1526 return HandleScriptsEnumerate(isolate, js);
1499 } else if (js->num_arguments() == 2) { 1527 } else if (js->num_arguments() == 2) {
1500 // Fetch specific script. 1528 // Fetch specific script.
1501 return HandleScriptsFetch(isolate, js); 1529 return HandleScriptsFetch(isolate, js);
1530 } else if (js->num_arguments() == 3) {
1531 const char* arg = js->GetArgument(2);
1532 if (strcmp(arg, "coverage") == 0) {
1533 return HandleScriptsCoverage(isolate, js);
1534 }
1535 PrintError(js, "Unrecognized subcommand '%s'", arg);
1536 return true;
1502 } else { 1537 } else {
1503 PrintError(js, "Command too long"); 1538 PrintError(js, "Command too long");
1504 return true; 1539 return true;
1505 } 1540 }
1506 } 1541 }
1507 1542
1508 1543
1509 static bool HandleDebugResume(Isolate* isolate, JSONStream* js) { 1544 static bool HandleDebugResume(Isolate* isolate, JSONStream* js) {
1510 if (isolate->message_handler()->paused_on_start()) { 1545 if (isolate->message_handler()->paused_on_start()) {
1511 isolate->message_handler()->set_pause_on_start(false); 1546 isolate->message_handler()->set_pause_on_start(false);
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 while (current != NULL) { 2208 while (current != NULL) {
2174 if (strcmp(name, current->name()) == 0) { 2209 if (strcmp(name, current->name()) == 0) {
2175 return current; 2210 return current;
2176 } 2211 }
2177 current = current->next(); 2212 current = current->next();
2178 } 2213 }
2179 return NULL; 2214 return NULL;
2180 } 2215 }
2181 2216
2182 } // namespace dart 2217 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698