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

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

Issue 271153002: Add pause/resume for isolates in vmservice/observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/json_stream.h ('K') | « runtime/vm/message_handler.h ('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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } else if (js->num_arguments() == 2) { 1382 } else if (js->num_arguments() == 2) {
1383 // Fetch specific script. 1383 // Fetch specific script.
1384 return HandleScriptsFetch(isolate, js); 1384 return HandleScriptsFetch(isolate, js);
1385 } else { 1385 } else {
1386 PrintError(js, "Command too long"); 1386 PrintError(js, "Command too long");
1387 return true; 1387 return true;
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 1391
1392 static bool HandleDebugResume(Isolate* isolate, JSONStream* js) {
1393 if (isolate->message_handler()->paused_on_start()) {
1394 isolate->message_handler()->set_pause_on_start(false);
1395 JSONObject jsobj(js);
1396 jsobj.AddProperty("type", "Success");
1397 jsobj.AddProperty("id", "");
1398 return true;
1399 }
1400 if (isolate->message_handler()->paused_on_exit()) {
1401 isolate->message_handler()->set_pause_on_exit(false);
1402 JSONObject jsobj(js);
1403 jsobj.AddProperty("type", "Success");
1404 jsobj.AddProperty("id", "");
1405 return true;
1406 }
1407 if (isolate->debugger()->PauseEvent() != NULL) {
1408 isolate->Resume();
1409 JSONObject jsobj(js);
1410 jsobj.AddProperty("type", "Success");
1411 jsobj.AddProperty("id", "");
1412 return true;
1413 }
1414
1415 PrintError(js, "VM was not paused");
1416 return true;
1417 }
1418
1419
1392 static bool HandleDebug(Isolate* isolate, JSONStream* js) { 1420 static bool HandleDebug(Isolate* isolate, JSONStream* js) {
1393 if (js->num_arguments() == 1) { 1421 if (js->num_arguments() == 1) {
1394 PrintError(js, "Must specify a subcommand"); 1422 PrintError(js, "Must specify a subcommand");
1395 return true; 1423 return true;
1396 } 1424 }
1397 const char* command = js->GetArgument(1); 1425 const char* command = js->GetArgument(1);
1398 if (strcmp(command, "breakpoints") == 0) { 1426 if (strcmp(command, "breakpoints") == 0) {
1399 if (js->num_arguments() == 2) { 1427 if (js->num_arguments() == 2) {
1400 // Print breakpoint list. 1428 // Print breakpoint list.
1401 JSONObject jsobj(js); 1429 JSONObject jsobj(js);
(...skipping 12 matching lines...) Expand all
1414 bpt->PrintJSON(js); 1442 bpt->PrintJSON(js);
1415 return true; 1443 return true;
1416 } else { 1444 } else {
1417 PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2)); 1445 PrintError(js, "Unrecognized breakpoint id %s", js->GetArgument(2));
1418 return true; 1446 return true;
1419 } 1447 }
1420 } else { 1448 } else {
1421 PrintError(js, "Command too long"); 1449 PrintError(js, "Command too long");
1422 return true; 1450 return true;
1423 } 1451 }
1452 } else if (strcmp(command, "pause") == 0) {
1453 if (js->num_arguments() == 2) {
1454 // TODO(turnidge): Don't double-interrupt the isolate here.
1455 isolate->ScheduleInterrupts(Isolate::kApiInterrupt);
1456 JSONObject jsobj(js);
1457 jsobj.AddProperty("type", "Success");
1458 jsobj.AddProperty("id", "");
1459 return true;
1460 } else {
1461 PrintError(js, "Command too long");
1462 return true;
1463 }
1464 } else if (strcmp(command, "resume") == 0) {
1465 if (js->num_arguments() == 2) {
1466 return HandleDebugResume(isolate, js);
1467 } else {
1468 PrintError(js, "Command too long");
1469 return true;
1470 }
1424 } else { 1471 } else {
1425 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); 1472 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1));
1426 return true; 1473 return true;
1427 } 1474 }
1428 } 1475 }
1429 1476
1430 1477
1431 static bool HandleNullCode(uintptr_t pc, JSONStream* js) { 1478 static bool HandleNullCode(uintptr_t pc, JSONStream* js) {
1432 // TODO(turnidge): Consider adding/using Object::null_code() for 1479 // TODO(turnidge): Consider adding/using Object::null_code() for
1433 // consistent "type". 1480 // consistent "type".
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 isolate->class_table()->ResetAllocationAccumulators(); 1613 isolate->class_table()->ResetAllocationAccumulators();
1567 } 1614 }
1568 if (should_collect) { 1615 if (should_collect) {
1569 isolate->heap()->CollectAllGarbage(); 1616 isolate->heap()->CollectAllGarbage();
1570 } 1617 }
1571 isolate->class_table()->AllocationProfilePrintJSON(js); 1618 isolate->class_table()->AllocationProfilePrintJSON(js);
1572 return true; 1619 return true;
1573 } 1620 }
1574 1621
1575 1622
1576 static bool HandleResume(Isolate* isolate, JSONStream* js) {
1577 if (isolate->message_handler()->pause_on_start()) {
1578 isolate->message_handler()->set_pause_on_start(false);
1579 JSONObject jsobj(js);
1580 jsobj.AddProperty("type", "Success");
1581 jsobj.AddProperty("id", "");
1582 return true;
1583 }
1584 if (isolate->message_handler()->pause_on_exit()) {
1585 isolate->message_handler()->set_pause_on_exit(false);
1586 JSONObject jsobj(js);
1587 jsobj.AddProperty("type", "Success");
1588 jsobj.AddProperty("id", "");
1589 return true;
1590 }
1591
1592 PrintError(js, "VM was not paused");
1593 return true;
1594 }
1595
1596
1597 static bool HandleTypeArguments(Isolate* isolate, JSONStream* js) { 1623 static bool HandleTypeArguments(Isolate* isolate, JSONStream* js) {
1598 ObjectStore* object_store = isolate->object_store(); 1624 ObjectStore* object_store = isolate->object_store();
1599 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 1625 const Array& table = Array::Handle(object_store->canonical_type_arguments());
1600 ASSERT(table.Length() > 0); 1626 ASSERT(table.Length() > 0);
1601 TypeArguments& type_args = TypeArguments::Handle(); 1627 TypeArguments& type_args = TypeArguments::Handle();
1602 const intptr_t table_size = table.Length() - 1; 1628 const intptr_t table_size = table.Length() - 1;
1603 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); 1629 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size)));
1604 bool only_with_instantiations = false; 1630 bool only_with_instantiations = false;
1605 if (js->num_arguments() >= 2) { 1631 if (js->num_arguments() >= 2) {
1606 const char* second = js->GetArgument(1); 1632 const char* second = js->GetArgument(1);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 { "address", HandleAddress }, 1747 { "address", HandleAddress },
1722 { "allocationprofile", HandleAllocationProfile }, 1748 { "allocationprofile", HandleAllocationProfile },
1723 { "classes", HandleClasses }, 1749 { "classes", HandleClasses },
1724 { "code", HandleCode }, 1750 { "code", HandleCode },
1725 { "coverage", HandleCoverage }, 1751 { "coverage", HandleCoverage },
1726 { "debug", HandleDebug }, 1752 { "debug", HandleDebug },
1727 { "heapmap", HandleHeapMap }, 1753 { "heapmap", HandleHeapMap },
1728 { "libraries", HandleLibraries }, 1754 { "libraries", HandleLibraries },
1729 { "objects", HandleObjects }, 1755 { "objects", HandleObjects },
1730 { "profile", HandleProfile }, 1756 { "profile", HandleProfile },
1731 { "resume", HandleResume },
1732 { "scripts", HandleScripts }, 1757 { "scripts", HandleScripts },
1733 { "stacktrace", HandleStackTrace }, 1758 { "stacktrace", HandleStackTrace },
1734 { "typearguments", HandleTypeArguments }, 1759 { "typearguments", HandleTypeArguments },
1735 }; 1760 };
1736 1761
1737 1762
1738 static IsolateMessageHandler FindIsolateMessageHandler(const char* command) { 1763 static IsolateMessageHandler FindIsolateMessageHandler(const char* command) {
1739 intptr_t num_message_handlers = sizeof(isolate_handlers) / 1764 intptr_t num_message_handlers = sizeof(isolate_handlers) /
1740 sizeof(isolate_handlers[0]); 1765 sizeof(isolate_handlers[0]);
1741 for (intptr_t i = 0; i < num_message_handlers; i++) { 1766 for (intptr_t i = 0; i < num_message_handlers; i++) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 while (current != NULL) { 2010 while (current != NULL) {
1986 if (strcmp(name, current->name()) == 0) { 2011 if (strcmp(name, current->name()) == 0) {
1987 return current; 2012 return current;
1988 } 2013 }
1989 current = current->next(); 2014 current = current->next();
1990 } 2015 }
1991 return NULL; 2016 return NULL;
1992 } 2017 }
1993 2018
1994 } // namespace dart 2019 } // namespace dart
OLDNEW
« runtime/vm/json_stream.h ('K') | « runtime/vm/message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698