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