| 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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 return NULL; | 723 return NULL; |
| 724 } | 724 } |
| 725 | 725 |
| 726 | 726 |
| 727 static const MethodParameter* get_isolate_params[] = { | 727 static const MethodParameter* get_isolate_params[] = { |
| 728 ISOLATE_PARAMETER, | 728 ISOLATE_PARAMETER, |
| 729 NULL, | 729 NULL, |
| 730 }; | 730 }; |
| 731 | 731 |
| 732 | 732 |
| 733 static bool HandleIsolate(Isolate* isolate, JSONStream* js) { | 733 static bool GetIsolate(Isolate* isolate, JSONStream* js) { |
| 734 isolate->PrintJSON(js, false); | 734 isolate->PrintJSON(js, false); |
| 735 return true; | 735 return true; |
| 736 } | 736 } |
| 737 | 737 |
| 738 | 738 |
| 739 static const MethodParameter* get_stack_params[] = { | 739 static const MethodParameter* get_stack_params[] = { |
| 740 ISOLATE_PARAMETER, | 740 ISOLATE_PARAMETER, |
| 741 NULL, | 741 NULL, |
| 742 }; | 742 }; |
| 743 | 743 |
| 744 | 744 |
| 745 static bool HandleIsolateGetStack(Isolate* isolate, JSONStream* js) { | 745 static bool GetStack(Isolate* isolate, JSONStream* js) { |
| 746 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 746 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
| 747 JSONObject jsobj(js); | 747 JSONObject jsobj(js); |
| 748 jsobj.AddProperty("type", "Stack"); | 748 jsobj.AddProperty("type", "Stack"); |
| 749 JSONArray jsarr(&jsobj, "frames"); | 749 JSONArray jsarr(&jsobj, "frames"); |
| 750 intptr_t num_frames = stack->Length(); | 750 intptr_t num_frames = stack->Length(); |
| 751 for (intptr_t i = 0; i < num_frames; i++) { | 751 for (intptr_t i = 0; i < num_frames; i++) { |
| 752 ActivationFrame* frame = stack->FrameAt(i); | 752 ActivationFrame* frame = stack->FrameAt(i); |
| 753 JSONObject jsobj(&jsarr); | 753 JSONObject jsobj(&jsarr); |
| 754 frame->PrintToJSONObject(&jsobj); | 754 frame->PrintToJSONObject(&jsobj); |
| 755 // TODO(turnidge): Implement depth differently -- differentiate | 755 // TODO(turnidge): Implement depth differently -- differentiate |
| (...skipping 24 matching lines...) Expand all Loading... |
| 780 jsobj.AddProperty("text", text); | 780 jsobj.AddProperty("text", text); |
| 781 } | 781 } |
| 782 } | 782 } |
| 783 const String& message = String::Handle(String::New(js.ToCString())); | 783 const String& message = String::Handle(String::New(js.ToCString())); |
| 784 uint8_t data[] = {0, 128, 255}; | 784 uint8_t data[] = {0, 128, 255}; |
| 785 // TODO(koda): Add 'testing' event family. | 785 // TODO(koda): Add 'testing' event family. |
| 786 SendEvent(kEventFamilyDebug, message, data, sizeof(data)); | 786 SendEvent(kEventFamilyDebug, message, data, sizeof(data)); |
| 787 } | 787 } |
| 788 | 788 |
| 789 | 789 |
| 790 static bool HandleIsolateTriggerEchoEvent(Isolate* isolate, JSONStream* js) { | 790 static bool _TriggerEchoEvent(Isolate* isolate, JSONStream* js) { |
| 791 Service::SendEchoEvent(isolate, js->LookupParam("text")); | 791 Service::SendEchoEvent(isolate, js->LookupParam("text")); |
| 792 JSONObject jsobj(js); | 792 JSONObject jsobj(js); |
| 793 return HandleCommonEcho(&jsobj, js); | 793 return HandleCommonEcho(&jsobj, js); |
| 794 } | 794 } |
| 795 | 795 |
| 796 | 796 |
| 797 static bool HandleIsolateEcho(Isolate* isolate, JSONStream* js) { | 797 static bool _Echo(Isolate* isolate, JSONStream* js) { |
| 798 JSONObject jsobj(js); | 798 JSONObject jsobj(js); |
| 799 return HandleCommonEcho(&jsobj, js); | 799 return HandleCommonEcho(&jsobj, js); |
| 800 } | 800 } |
| 801 | 801 |
| 802 | 802 |
| 803 static bool ContainsNonInstance(const Object& obj) { | 803 static bool ContainsNonInstance(const Object& obj) { |
| 804 if (obj.IsArray()) { | 804 if (obj.IsArray()) { |
| 805 const Array& array = Array::Cast(obj); | 805 const Array& array = Array::Cast(obj); |
| 806 Object& element = Object::Handle(); | 806 Object& element = Object::Handle(); |
| 807 for (intptr_t i = 0; i < array.Length(); ++i) { | 807 for (intptr_t i = 0; i < array.Length(); ++i) { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 return true; | 1241 return true; |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 | 1244 |
| 1245 static const MethodParameter* get_inbound_references_params[] = { | 1245 static const MethodParameter* get_inbound_references_params[] = { |
| 1246 ISOLATE_PARAMETER, | 1246 ISOLATE_PARAMETER, |
| 1247 NULL, | 1247 NULL, |
| 1248 }; | 1248 }; |
| 1249 | 1249 |
| 1250 | 1250 |
| 1251 static bool HandleIsolateGetInboundReferences(Isolate* isolate, | 1251 static bool GetInboundReferences(Isolate* isolate, JSONStream* js) { |
| 1252 JSONStream* js) { | |
| 1253 const char* target_id = js->LookupParam("targetId"); | 1252 const char* target_id = js->LookupParam("targetId"); |
| 1254 if (target_id == NULL) { | 1253 if (target_id == NULL) { |
| 1255 PrintMissingParamError(js, "targetId"); | 1254 PrintMissingParamError(js, "targetId"); |
| 1256 return true; | 1255 return true; |
| 1257 } | 1256 } |
| 1258 const char* limit_cstr = js->LookupParam("limit"); | 1257 const char* limit_cstr = js->LookupParam("limit"); |
| 1259 if (target_id == NULL) { | 1258 if (target_id == NULL) { |
| 1260 PrintMissingParamError(js, "limit"); | 1259 PrintMissingParamError(js, "limit"); |
| 1261 return true; | 1260 return true; |
| 1262 } | 1261 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 return true; | 1345 return true; |
| 1347 } | 1346 } |
| 1348 | 1347 |
| 1349 | 1348 |
| 1350 static const MethodParameter* get_retaining_path_params[] = { | 1349 static const MethodParameter* get_retaining_path_params[] = { |
| 1351 ISOLATE_PARAMETER, | 1350 ISOLATE_PARAMETER, |
| 1352 NULL, | 1351 NULL, |
| 1353 }; | 1352 }; |
| 1354 | 1353 |
| 1355 | 1354 |
| 1356 static bool HandleIsolateGetRetainingPath(Isolate* isolate, | 1355 static bool GetRetainingPath(Isolate* isolate, JSONStream* js) { |
| 1357 JSONStream* js) { | |
| 1358 const char* target_id = js->LookupParam("targetId"); | 1356 const char* target_id = js->LookupParam("targetId"); |
| 1359 if (target_id == NULL) { | 1357 if (target_id == NULL) { |
| 1360 PrintMissingParamError(js, "targetId"); | 1358 PrintMissingParamError(js, "targetId"); |
| 1361 return true; | 1359 return true; |
| 1362 } | 1360 } |
| 1363 const char* limit_cstr = js->LookupParam("limit"); | 1361 const char* limit_cstr = js->LookupParam("limit"); |
| 1364 if (target_id == NULL) { | 1362 if (target_id == NULL) { |
| 1365 PrintMissingParamError(js, "limit"); | 1363 PrintMissingParamError(js, "limit"); |
| 1366 return true; | 1364 return true; |
| 1367 } | 1365 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1395 return PrintRetainingPath(isolate, &obj, limit, js); | 1393 return PrintRetainingPath(isolate, &obj, limit, js); |
| 1396 } | 1394 } |
| 1397 | 1395 |
| 1398 | 1396 |
| 1399 static const MethodParameter* get_retained_size_params[] = { | 1397 static const MethodParameter* get_retained_size_params[] = { |
| 1400 ISOLATE_PARAMETER, | 1398 ISOLATE_PARAMETER, |
| 1401 NULL, | 1399 NULL, |
| 1402 }; | 1400 }; |
| 1403 | 1401 |
| 1404 | 1402 |
| 1405 static bool HandleIsolateGetRetainedSize(Isolate* isolate, JSONStream* js) { | 1403 static bool GetRetainedSize(Isolate* isolate, JSONStream* js) { |
| 1406 const char* target_id = js->LookupParam("targetId"); | 1404 const char* target_id = js->LookupParam("targetId"); |
| 1407 if (target_id == NULL) { | 1405 if (target_id == NULL) { |
| 1408 PrintMissingParamError(js, "targetId"); | 1406 PrintMissingParamError(js, "targetId"); |
| 1409 return true; | 1407 return true; |
| 1410 } | 1408 } |
| 1411 ObjectIdRing::LookupResult lookup_result; | 1409 ObjectIdRing::LookupResult lookup_result; |
| 1412 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, | 1410 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, |
| 1413 &lookup_result)); | 1411 &lookup_result)); |
| 1414 if (obj.raw() == Object::sentinel().raw()) { | 1412 if (obj.raw() == Object::sentinel().raw()) { |
| 1415 if (lookup_result == ObjectIdRing::kCollected) { | 1413 if (lookup_result == ObjectIdRing::kCollected) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 return true; | 1446 return true; |
| 1449 } | 1447 } |
| 1450 | 1448 |
| 1451 | 1449 |
| 1452 static const MethodParameter* eval_params[] = { | 1450 static const MethodParameter* eval_params[] = { |
| 1453 ISOLATE_PARAMETER, | 1451 ISOLATE_PARAMETER, |
| 1454 NULL, | 1452 NULL, |
| 1455 }; | 1453 }; |
| 1456 | 1454 |
| 1457 | 1455 |
| 1458 static bool HandleIsolateEval(Isolate* isolate, JSONStream* js) { | 1456 static bool Eval(Isolate* isolate, JSONStream* js) { |
| 1459 const char* target_id = js->LookupParam("targetId"); | 1457 const char* target_id = js->LookupParam("targetId"); |
| 1460 if (target_id == NULL) { | 1458 if (target_id == NULL) { |
| 1461 PrintMissingParamError(js, "targetId"); | 1459 PrintMissingParamError(js, "targetId"); |
| 1462 return true; | 1460 return true; |
| 1463 } | 1461 } |
| 1464 const char* expr = js->LookupParam("expression"); | 1462 const char* expr = js->LookupParam("expression"); |
| 1465 if (expr == NULL) { | 1463 if (expr == NULL) { |
| 1466 PrintMissingParamError(js, "expression"); | 1464 PrintMissingParamError(js, "expression"); |
| 1467 return true; | 1465 return true; |
| 1468 } | 1466 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 } | 1513 } |
| 1516 | 1514 |
| 1517 | 1515 |
| 1518 static const MethodParameter* get_call_site_data_params[] = { | 1516 static const MethodParameter* get_call_site_data_params[] = { |
| 1519 ISOLATE_PARAMETER, | 1517 ISOLATE_PARAMETER, |
| 1520 new IdParameter("targetId", true), | 1518 new IdParameter("targetId", true), |
| 1521 NULL, | 1519 NULL, |
| 1522 }; | 1520 }; |
| 1523 | 1521 |
| 1524 | 1522 |
| 1525 static bool HandleIsolateGetCallSiteData(Isolate* isolate, JSONStream* js) { | 1523 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { |
| 1526 const char* target_id = js->LookupParam("targetId"); | 1524 const char* target_id = js->LookupParam("targetId"); |
| 1527 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 1525 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); |
| 1528 if (obj.raw() == Object::sentinel().raw()) { | 1526 if (obj.raw() == Object::sentinel().raw()) { |
| 1529 PrintInvalidParamError(js, "targetId"); | 1527 PrintInvalidParamError(js, "targetId"); |
| 1530 return true; | 1528 return true; |
| 1531 } | 1529 } |
| 1532 if (obj.IsFunction()) { | 1530 if (obj.IsFunction()) { |
| 1533 const Function& func = Function::Cast(obj); | 1531 const Function& func = Function::Cast(obj); |
| 1534 const GrowableObjectArray& ics = | 1532 const GrowableObjectArray& ics = |
| 1535 GrowableObjectArray::Handle(func.CollectICsWithSourcePositions()); | 1533 GrowableObjectArray::Handle(func.CollectICsWithSourcePositions()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 intptr_t count_; | 1581 intptr_t count_; |
| 1584 }; | 1582 }; |
| 1585 | 1583 |
| 1586 | 1584 |
| 1587 static const MethodParameter* get_instances_params[] = { | 1585 static const MethodParameter* get_instances_params[] = { |
| 1588 ISOLATE_PARAMETER, | 1586 ISOLATE_PARAMETER, |
| 1589 NULL, | 1587 NULL, |
| 1590 }; | 1588 }; |
| 1591 | 1589 |
| 1592 | 1590 |
| 1593 static bool HandleIsolateGetInstances(Isolate* isolate, JSONStream* js) { | 1591 static bool GetInstances(Isolate* isolate, JSONStream* js) { |
| 1594 const char* target_id = js->LookupParam("classId"); | 1592 const char* target_id = js->LookupParam("classId"); |
| 1595 if (target_id == NULL) { | 1593 if (target_id == NULL) { |
| 1596 PrintMissingParamError(js, "classId"); | 1594 PrintMissingParamError(js, "classId"); |
| 1597 return true; | 1595 return true; |
| 1598 } | 1596 } |
| 1599 const char* limit_cstr = js->LookupParam("limit"); | 1597 const char* limit_cstr = js->LookupParam("limit"); |
| 1600 if (target_id == NULL) { | 1598 if (target_id == NULL) { |
| 1601 PrintMissingParamError(js, "limit"); | 1599 PrintMissingParamError(js, "limit"); |
| 1602 return true; | 1600 return true; |
| 1603 } | 1601 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 const Function& func_; | 1690 const Function& func_; |
| 1693 }; | 1691 }; |
| 1694 | 1692 |
| 1695 | 1693 |
| 1696 static const MethodParameter* get_coverage_params[] = { | 1694 static const MethodParameter* get_coverage_params[] = { |
| 1697 ISOLATE_PARAMETER, | 1695 ISOLATE_PARAMETER, |
| 1698 NULL, | 1696 NULL, |
| 1699 }; | 1697 }; |
| 1700 | 1698 |
| 1701 | 1699 |
| 1702 static bool HandleIsolateGetCoverage(Isolate* isolate, JSONStream* js) { | 1700 static bool GetCoverage(Isolate* isolate, JSONStream* js) { |
| 1703 if (!js->HasParam("targetId")) { | 1701 if (!js->HasParam("targetId")) { |
| 1704 CodeCoverage::PrintJSON(isolate, js, NULL); | 1702 CodeCoverage::PrintJSON(isolate, js, NULL); |
| 1705 return true; | 1703 return true; |
| 1706 } | 1704 } |
| 1707 const char* target_id = js->LookupParam("targetId"); | 1705 const char* target_id = js->LookupParam("targetId"); |
| 1708 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 1706 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); |
| 1709 if (obj.raw() == Object::sentinel().raw()) { | 1707 if (obj.raw() == Object::sentinel().raw()) { |
| 1710 PrintInvalidParamError(js, "targetId"); | 1708 PrintInvalidParamError(js, "targetId"); |
| 1711 return true; | 1709 return true; |
| 1712 } | 1710 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1738 | 1736 |
| 1739 | 1737 |
| 1740 static const MethodParameter* add_breakpoint_params[] = { | 1738 static const MethodParameter* add_breakpoint_params[] = { |
| 1741 ISOLATE_PARAMETER, | 1739 ISOLATE_PARAMETER, |
| 1742 new IdParameter("scriptId", true), | 1740 new IdParameter("scriptId", true), |
| 1743 new UIntParameter("line", true), | 1741 new UIntParameter("line", true), |
| 1744 NULL, | 1742 NULL, |
| 1745 }; | 1743 }; |
| 1746 | 1744 |
| 1747 | 1745 |
| 1748 static bool HandleIsolateAddBreakpoint(Isolate* isolate, JSONStream* js) { | 1746 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1749 const char* line_param = js->LookupParam("line"); | 1747 const char* line_param = js->LookupParam("line"); |
| 1750 intptr_t line = UIntParameter::Parse(line_param); | 1748 intptr_t line = UIntParameter::Parse(line_param); |
| 1751 const char* script_id = js->LookupParam("scriptId"); | 1749 const char* script_id = js->LookupParam("scriptId"); |
| 1752 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); | 1750 Object& obj = Object::Handle(LookupHeapObject(isolate, script_id, NULL)); |
| 1753 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 1751 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
| 1754 PrintInvalidParamError(js, "scriptId"); | 1752 PrintInvalidParamError(js, "scriptId"); |
| 1755 return true; | 1753 return true; |
| 1756 } | 1754 } |
| 1757 const Script& script = Script::Cast(obj); | 1755 const Script& script = Script::Cast(obj); |
| 1758 const String& script_url = String::Handle(script.url()); | 1756 const String& script_url = String::Handle(script.url()); |
| 1759 SourceBreakpoint* bpt = | 1757 SourceBreakpoint* bpt = |
| 1760 isolate->debugger()->SetBreakpointAtLine(script_url, line); | 1758 isolate->debugger()->SetBreakpointAtLine(script_url, line); |
| 1761 if (bpt == NULL) { | 1759 if (bpt == NULL) { |
| 1762 PrintError(js, "Unable to set breakpoint at line %s", line_param); | 1760 PrintError(js, "Unable to set breakpoint at line %s", line_param); |
| 1763 return true; | 1761 return true; |
| 1764 } | 1762 } |
| 1765 bpt->PrintJSON(js); | 1763 bpt->PrintJSON(js); |
| 1766 return true; | 1764 return true; |
| 1767 } | 1765 } |
| 1768 | 1766 |
| 1769 | 1767 |
| 1770 static const MethodParameter* add_breakpoint_at_entry_params[] = { | 1768 static const MethodParameter* add_breakpoint_at_entry_params[] = { |
| 1771 ISOLATE_PARAMETER, | 1769 ISOLATE_PARAMETER, |
| 1772 new IdParameter("functionId", true), | 1770 new IdParameter("functionId", true), |
| 1773 NULL, | 1771 NULL, |
| 1774 }; | 1772 }; |
| 1775 | 1773 |
| 1776 | 1774 |
| 1777 static bool HandleIsolateAddBreakpointAtEntry(Isolate* isolate, | 1775 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { |
| 1778 JSONStream* js) { | |
| 1779 const char* function_id = js->LookupParam("functionId"); | 1776 const char* function_id = js->LookupParam("functionId"); |
| 1780 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); | 1777 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); |
| 1781 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { | 1778 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { |
| 1782 PrintInvalidParamError(js, "functionId"); | 1779 PrintInvalidParamError(js, "functionId"); |
| 1783 return true; | 1780 return true; |
| 1784 } | 1781 } |
| 1785 const Function& function = Function::Cast(obj); | 1782 const Function& function = Function::Cast(obj); |
| 1786 SourceBreakpoint* bpt = | 1783 SourceBreakpoint* bpt = |
| 1787 isolate->debugger()->SetBreakpointAtEntry(function); | 1784 isolate->debugger()->SetBreakpointAtEntry(function); |
| 1788 if (bpt == NULL) { | 1785 if (bpt == NULL) { |
| 1789 const String& funcName = String::Handle(function.PrettyName()); | 1786 const String& funcName = String::Handle(function.PrettyName()); |
| 1790 PrintError(js, "Unable to set breakpoint at function '%s'", | 1787 PrintError(js, "Unable to set breakpoint at function '%s'", |
| 1791 funcName.ToCString()); | 1788 funcName.ToCString()); |
| 1792 return true; | 1789 return true; |
| 1793 } | 1790 } |
| 1794 bpt->PrintJSON(js); | 1791 bpt->PrintJSON(js); |
| 1795 return true; | 1792 return true; |
| 1796 } | 1793 } |
| 1797 | 1794 |
| 1798 | 1795 |
| 1799 static const MethodParameter* remove_breakpoint_params[] = { | 1796 static const MethodParameter* remove_breakpoint_params[] = { |
| 1800 ISOLATE_PARAMETER, | 1797 ISOLATE_PARAMETER, |
| 1801 NULL, | 1798 NULL, |
| 1802 }; | 1799 }; |
| 1803 | 1800 |
| 1804 | 1801 |
| 1805 static bool HandleIsolateRemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 1802 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1806 if (!js->HasParam("breakpointId")) { | 1803 if (!js->HasParam("breakpointId")) { |
| 1807 PrintMissingParamError(js, "breakpointId"); | 1804 PrintMissingParamError(js, "breakpointId"); |
| 1808 return true; | 1805 return true; |
| 1809 } | 1806 } |
| 1810 const char* bpt_id = js->LookupParam("breakpointId"); | 1807 const char* bpt_id = js->LookupParam("breakpointId"); |
| 1811 SourceBreakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 1808 SourceBreakpoint* bpt = LookupBreakpoint(isolate, bpt_id); |
| 1812 if (bpt == NULL) { | 1809 if (bpt == NULL) { |
| 1813 fprintf(stderr, "ERROR1"); | 1810 fprintf(stderr, "ERROR1"); |
| 1814 PrintInvalidParamError(js, "breakpointId"); | 1811 PrintInvalidParamError(js, "breakpointId"); |
| 1815 return true; | 1812 return true; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 ASSERT(result.IsString()); | 1909 ASSERT(result.IsString()); |
| 1913 TextBuffer* buffer = js->buffer(); | 1910 TextBuffer* buffer = js->buffer(); |
| 1914 buffer->AddString(String::Cast(result).ToCString()); | 1911 buffer->AddString(String::Cast(result).ToCString()); |
| 1915 return true; | 1912 return true; |
| 1916 } | 1913 } |
| 1917 PrintError(js, "Dart Metric %s not found\n", id); | 1914 PrintError(js, "Dart Metric %s not found\n", id); |
| 1918 return true; | 1915 return true; |
| 1919 } | 1916 } |
| 1920 | 1917 |
| 1921 | 1918 |
| 1922 static const MethodParameter* get_metric_list_params[] = { | 1919 static const MethodParameter* get_isolate_metric_list_params[] = { |
| 1923 ISOLATE_PARAMETER, | 1920 ISOLATE_PARAMETER, |
| 1924 NULL, | 1921 NULL, |
| 1925 }; | 1922 }; |
| 1926 | 1923 |
| 1927 | 1924 |
| 1928 static bool HandleIsolateGetMetricList(Isolate* isolate, JSONStream* js) { | 1925 static bool GetIsolateMetricList(Isolate* isolate, JSONStream* js) { |
| 1929 bool native_metrics = false; | 1926 bool native_metrics = false; |
| 1930 if (js->HasParam("type")) { | 1927 if (js->HasParam("type")) { |
| 1931 if (js->ParamIs("type", "Native")) { | 1928 if (js->ParamIs("type", "Native")) { |
| 1932 native_metrics = true; | 1929 native_metrics = true; |
| 1933 } else if (js->ParamIs("type", "Dart")) { | 1930 } else if (js->ParamIs("type", "Dart")) { |
| 1934 native_metrics = false; | 1931 native_metrics = false; |
| 1935 } else { | 1932 } else { |
| 1936 PrintInvalidParamError(js, "type"); | 1933 PrintInvalidParamError(js, "type"); |
| 1937 return true; | 1934 return true; |
| 1938 } | 1935 } |
| 1939 } else { | 1936 } else { |
| 1940 PrintMissingParamError(js, "type"); | 1937 PrintMissingParamError(js, "type"); |
| 1941 return true; | 1938 return true; |
| 1942 } | 1939 } |
| 1943 if (native_metrics) { | 1940 if (native_metrics) { |
| 1944 return HandleNativeMetricsList(isolate, js); | 1941 return HandleNativeMetricsList(isolate, js); |
| 1945 } | 1942 } |
| 1946 return HandleDartMetricsList(isolate, js); | 1943 return HandleDartMetricsList(isolate, js); |
| 1947 } | 1944 } |
| 1948 | 1945 |
| 1949 | 1946 |
| 1950 static const MethodParameter* get_metric_params[] = { | 1947 static const MethodParameter* get_isolate_metric_params[] = { |
| 1951 ISOLATE_PARAMETER, | 1948 ISOLATE_PARAMETER, |
| 1952 NULL, | 1949 NULL, |
| 1953 }; | 1950 }; |
| 1954 | 1951 |
| 1955 | 1952 |
| 1956 static bool HandleIsolateGetMetric(Isolate* isolate, JSONStream* js) { | 1953 static bool GetIsolateMetric(Isolate* isolate, JSONStream* js) { |
| 1957 const char* metric_id = js->LookupParam("metricId"); | 1954 const char* metric_id = js->LookupParam("metricId"); |
| 1958 if (metric_id == NULL) { | 1955 if (metric_id == NULL) { |
| 1959 PrintMissingParamError(js, "metricId"); | 1956 PrintMissingParamError(js, "metricId"); |
| 1960 return true; | 1957 return true; |
| 1961 } | 1958 } |
| 1962 // Verify id begins with "metrics/". | 1959 // Verify id begins with "metrics/". |
| 1963 static const char* kMetricIdPrefix = "metrics/"; | 1960 static const char* kMetricIdPrefix = "metrics/"; |
| 1964 static intptr_t kMetricIdPrefixLen = strlen(kMetricIdPrefix); | 1961 static intptr_t kMetricIdPrefixLen = strlen(kMetricIdPrefix); |
| 1965 if (strncmp(metric_id, kMetricIdPrefix, kMetricIdPrefixLen) != 0) { | 1962 if (strncmp(metric_id, kMetricIdPrefix, kMetricIdPrefixLen) != 0) { |
| 1966 PrintError(js, "Metric %s not found\n", metric_id); | 1963 PrintError(js, "Metric %s not found\n", metric_id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1978 return HandleDartMetric(isolate, js, id); | 1975 return HandleDartMetric(isolate, js, id); |
| 1979 } | 1976 } |
| 1980 | 1977 |
| 1981 | 1978 |
| 1982 static const MethodParameter* get_vm_metric_list_params[] = { | 1979 static const MethodParameter* get_vm_metric_list_params[] = { |
| 1983 NO_ISOLATE_PARAMETER, | 1980 NO_ISOLATE_PARAMETER, |
| 1984 NULL, | 1981 NULL, |
| 1985 }; | 1982 }; |
| 1986 | 1983 |
| 1987 | 1984 |
| 1988 static bool HandleVMGetMetricList(Isolate* isolate, JSONStream* js) { | 1985 static bool GetVMMetricList(Isolate* isolate, JSONStream* js) { |
| 1989 return false; | 1986 return false; |
| 1990 } | 1987 } |
| 1991 | 1988 |
| 1992 | 1989 |
| 1993 static const MethodParameter* get_vm_metric_params[] = { | 1990 static const MethodParameter* get_vm_metric_params[] = { |
| 1994 NO_ISOLATE_PARAMETER, | 1991 NO_ISOLATE_PARAMETER, |
| 1995 NULL, | 1992 NULL, |
| 1996 }; | 1993 }; |
| 1997 | 1994 |
| 1998 | 1995 |
| 1999 static bool HandleVMGetMetric(Isolate* isolate, JSONStream* js) { | 1996 static bool GetVMMetric(Isolate* isolate, JSONStream* js) { |
| 2000 const char* metric_id = js->LookupParam("metricId"); | 1997 const char* metric_id = js->LookupParam("metricId"); |
| 2001 if (metric_id == NULL) { | 1998 if (metric_id == NULL) { |
| 2002 PrintMissingParamError(js, "metricId"); | 1999 PrintMissingParamError(js, "metricId"); |
| 2003 } | 2000 } |
| 2004 return false; | 2001 return false; |
| 2005 } | 2002 } |
| 2006 | 2003 |
| 2007 | 2004 |
| 2008 static const MethodParameter* resume_params[] = { | 2005 static const MethodParameter* resume_params[] = { |
| 2009 ISOLATE_PARAMETER, | 2006 ISOLATE_PARAMETER, |
| 2010 NULL, | 2007 NULL, |
| 2011 }; | 2008 }; |
| 2012 | 2009 |
| 2013 | 2010 |
| 2014 static bool HandleIsolateResume(Isolate* isolate, JSONStream* js) { | 2011 static bool Resume(Isolate* isolate, JSONStream* js) { |
| 2015 const char* step_param = js->LookupParam("step"); | 2012 const char* step_param = js->LookupParam("step"); |
| 2016 if (isolate->message_handler()->paused_on_start()) { | 2013 if (isolate->message_handler()->paused_on_start()) { |
| 2017 isolate->message_handler()->set_pause_on_start(false); | 2014 isolate->message_handler()->set_pause_on_start(false); |
| 2018 JSONObject jsobj(js); | 2015 JSONObject jsobj(js); |
| 2019 jsobj.AddProperty("type", "Success"); | 2016 jsobj.AddProperty("type", "Success"); |
| 2020 jsobj.AddProperty("id", ""); | 2017 jsobj.AddProperty("id", ""); |
| 2021 { | 2018 { |
| 2022 DebuggerEvent resumeEvent(isolate, DebuggerEvent::kIsolateResumed); | 2019 DebuggerEvent resumeEvent(isolate, DebuggerEvent::kIsolateResumed); |
| 2023 Service::HandleDebuggerEvent(&resumeEvent); | 2020 Service::HandleDebuggerEvent(&resumeEvent); |
| 2024 } | 2021 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2056 return true; | 2053 return true; |
| 2057 } | 2054 } |
| 2058 | 2055 |
| 2059 | 2056 |
| 2060 static const MethodParameter* get_breakpoints_params[] = { | 2057 static const MethodParameter* get_breakpoints_params[] = { |
| 2061 ISOLATE_PARAMETER, | 2058 ISOLATE_PARAMETER, |
| 2062 NULL, | 2059 NULL, |
| 2063 }; | 2060 }; |
| 2064 | 2061 |
| 2065 | 2062 |
| 2066 static bool HandleIsolateGetBreakpoints(Isolate* isolate, JSONStream* js) { | 2063 static bool GetBreakpoints(Isolate* isolate, JSONStream* js) { |
| 2067 JSONObject jsobj(js); | 2064 JSONObject jsobj(js); |
| 2068 jsobj.AddProperty("type", "BreakpointList"); | 2065 jsobj.AddProperty("type", "BreakpointList"); |
| 2069 JSONArray jsarr(&jsobj, "breakpoints"); | 2066 JSONArray jsarr(&jsobj, "breakpoints"); |
| 2070 isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr); | 2067 isolate->debugger()->PrintBreakpointsToJSONArray(&jsarr); |
| 2071 return true; | 2068 return true; |
| 2072 } | 2069 } |
| 2073 | 2070 |
| 2074 | 2071 |
| 2075 static const MethodParameter* pause_params[] = { | 2072 static const MethodParameter* pause_params[] = { |
| 2076 ISOLATE_PARAMETER, | 2073 ISOLATE_PARAMETER, |
| 2077 NULL, | 2074 NULL, |
| 2078 }; | 2075 }; |
| 2079 | 2076 |
| 2080 | 2077 |
| 2081 static bool HandleIsolatePause(Isolate* isolate, JSONStream* js) { | 2078 static bool Pause(Isolate* isolate, JSONStream* js) { |
| 2082 // TODO(turnidge): Don't double-interrupt the isolate here. | 2079 // TODO(turnidge): Don't double-interrupt the isolate here. |
| 2083 isolate->ScheduleInterrupts(Isolate::kApiInterrupt); | 2080 isolate->ScheduleInterrupts(Isolate::kApiInterrupt); |
| 2084 JSONObject jsobj(js); | 2081 JSONObject jsobj(js); |
| 2085 jsobj.AddProperty("type", "Success"); | 2082 jsobj.AddProperty("type", "Success"); |
| 2086 jsobj.AddProperty("id", ""); | 2083 jsobj.AddProperty("id", ""); |
| 2087 return true; | 2084 return true; |
| 2088 } | 2085 } |
| 2089 | 2086 |
| 2090 | 2087 |
| 2091 static const MethodParameter* get_tag_profile_params[] = { | 2088 static const MethodParameter* get_tag_profile_params[] = { |
| 2092 ISOLATE_PARAMETER, | 2089 ISOLATE_PARAMETER, |
| 2093 NULL, | 2090 NULL, |
| 2094 }; | 2091 }; |
| 2095 | 2092 |
| 2096 | 2093 |
| 2097 static bool HandleIsolateGetTagProfile(Isolate* isolate, JSONStream* js) { | 2094 static bool GetTagProfile(Isolate* isolate, JSONStream* js) { |
| 2098 JSONObject miniProfile(js); | 2095 JSONObject miniProfile(js); |
| 2099 miniProfile.AddProperty("type", "TagProfile"); | 2096 miniProfile.AddProperty("type", "TagProfile"); |
| 2100 miniProfile.AddProperty("id", "profile/tag"); | 2097 miniProfile.AddProperty("id", "profile/tag"); |
| 2101 isolate->vm_tag_counters()->PrintToJSONObject(&miniProfile); | 2098 isolate->vm_tag_counters()->PrintToJSONObject(&miniProfile); |
| 2102 return true; | 2099 return true; |
| 2103 } | 2100 } |
| 2104 | 2101 |
| 2105 | 2102 |
| 2106 static const char* tags_enum_names[] = { | 2103 static const char* tags_enum_names[] = { |
| 2107 "None", | 2104 "None", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2123 }; | 2120 }; |
| 2124 | 2121 |
| 2125 | 2122 |
| 2126 static const MethodParameter* get_cpu_profile_params[] = { | 2123 static const MethodParameter* get_cpu_profile_params[] = { |
| 2127 ISOLATE_PARAMETER, | 2124 ISOLATE_PARAMETER, |
| 2128 new EnumParameter("tags", true, tags_enum_names), | 2125 new EnumParameter("tags", true, tags_enum_names), |
| 2129 NULL, | 2126 NULL, |
| 2130 }; | 2127 }; |
| 2131 | 2128 |
| 2132 | 2129 |
| 2133 static bool HandleIsolateGetCpuProfile(Isolate* isolate, JSONStream* js) { | 2130 static bool GetCpuProfile(Isolate* isolate, JSONStream* js) { |
| 2134 ProfilerService::TagOrder tag_order = | 2131 ProfilerService::TagOrder tag_order = |
| 2135 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); | 2132 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); |
| 2136 ProfilerService::PrintJSON(js, tag_order); | 2133 ProfilerService::PrintJSON(js, tag_order); |
| 2137 return true; | 2134 return true; |
| 2138 } | 2135 } |
| 2139 | 2136 |
| 2140 | 2137 |
| 2141 static const MethodParameter* get_allocation_profile_params[] = { | 2138 static const MethodParameter* get_allocation_profile_params[] = { |
| 2142 ISOLATE_PARAMETER, | 2139 ISOLATE_PARAMETER, |
| 2143 NULL, | 2140 NULL, |
| 2144 }; | 2141 }; |
| 2145 | 2142 |
| 2146 | 2143 |
| 2147 static bool HandleIsolateGetAllocationProfile(Isolate* isolate, | 2144 static bool GetAllocationProfile(Isolate* isolate, JSONStream* js) { |
| 2148 JSONStream* js) { | |
| 2149 bool should_reset_accumulator = false; | 2145 bool should_reset_accumulator = false; |
| 2150 bool should_collect = false; | 2146 bool should_collect = false; |
| 2151 if (js->HasParam("reset")) { | 2147 if (js->HasParam("reset")) { |
| 2152 if (js->ParamIs("reset", "true")) { | 2148 if (js->ParamIs("reset", "true")) { |
| 2153 should_reset_accumulator = true; | 2149 should_reset_accumulator = true; |
| 2154 } else { | 2150 } else { |
| 2155 PrintInvalidParamError(js, "reset"); | 2151 PrintInvalidParamError(js, "reset"); |
| 2156 return true; | 2152 return true; |
| 2157 } | 2153 } |
| 2158 } | 2154 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2176 return true; | 2172 return true; |
| 2177 } | 2173 } |
| 2178 | 2174 |
| 2179 | 2175 |
| 2180 static const MethodParameter* get_heap_map_params[] = { | 2176 static const MethodParameter* get_heap_map_params[] = { |
| 2181 ISOLATE_PARAMETER, | 2177 ISOLATE_PARAMETER, |
| 2182 NULL, | 2178 NULL, |
| 2183 }; | 2179 }; |
| 2184 | 2180 |
| 2185 | 2181 |
| 2186 static bool HandleIsolateGetHeapMap(Isolate* isolate, JSONStream* js) { | 2182 static bool GetHeapMap(Isolate* isolate, JSONStream* js) { |
| 2187 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); | 2183 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); |
| 2188 return true; | 2184 return true; |
| 2189 } | 2185 } |
| 2190 | 2186 |
| 2191 | 2187 |
| 2192 static const MethodParameter* request_heap_snapshot_params[] = { | 2188 static const MethodParameter* request_heap_snapshot_params[] = { |
| 2193 ISOLATE_PARAMETER, | 2189 ISOLATE_PARAMETER, |
| 2194 NULL, | 2190 NULL, |
| 2195 }; | 2191 }; |
| 2196 | 2192 |
| 2197 | 2193 |
| 2198 static bool HandleIsolateRequestHeapSnapshot(Isolate* isolate, JSONStream* js) { | 2194 static bool RequestHeapSnapshot(Isolate* isolate, JSONStream* js) { |
| 2199 Service::SendGraphEvent(isolate); | 2195 Service::SendGraphEvent(isolate); |
| 2200 // TODO(koda): Provide some id that ties this request to async response(s). | 2196 // TODO(koda): Provide some id that ties this request to async response(s). |
| 2201 JSONObject jsobj(js); | 2197 JSONObject jsobj(js); |
| 2202 jsobj.AddProperty("type", "OK"); | 2198 jsobj.AddProperty("type", "OK"); |
| 2203 jsobj.AddProperty("id", "ok"); | 2199 jsobj.AddProperty("id", "ok"); |
| 2204 return true; | 2200 return true; |
| 2205 } | 2201 } |
| 2206 | 2202 |
| 2207 | 2203 |
| 2208 void Service::SendGraphEvent(Isolate* isolate) { | 2204 void Service::SendGraphEvent(Isolate* isolate) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 uword addr_; | 2240 uword addr_; |
| 2245 }; | 2241 }; |
| 2246 | 2242 |
| 2247 | 2243 |
| 2248 static const MethodParameter* get_object_by_address_params[] = { | 2244 static const MethodParameter* get_object_by_address_params[] = { |
| 2249 ISOLATE_PARAMETER, | 2245 ISOLATE_PARAMETER, |
| 2250 NULL, | 2246 NULL, |
| 2251 }; | 2247 }; |
| 2252 | 2248 |
| 2253 | 2249 |
| 2254 static bool HandleIsolateGetObjectByAddress(Isolate* isolate, JSONStream* js) { | 2250 static bool GetObjectByAddress(Isolate* isolate, JSONStream* js) { |
| 2255 const char* addr_str = js->LookupParam("address"); | 2251 const char* addr_str = js->LookupParam("address"); |
| 2256 if (addr_str == NULL) { | 2252 if (addr_str == NULL) { |
| 2257 PrintMissingParamError(js, "address"); | 2253 PrintMissingParamError(js, "address"); |
| 2258 return true; | 2254 return true; |
| 2259 } | 2255 } |
| 2260 | 2256 |
| 2261 // Handle heap objects. | 2257 // Handle heap objects. |
| 2262 uword addr = 0; | 2258 uword addr = 0; |
| 2263 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { | 2259 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { |
| 2264 PrintInvalidParamError(js, "address"); | 2260 PrintInvalidParamError(js, "address"); |
| 2265 return true; | 2261 return true; |
| 2266 } | 2262 } |
| 2267 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); | 2263 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); |
| 2268 Object& object = Object::Handle(isolate); | 2264 Object& object = Object::Handle(isolate); |
| 2269 { | 2265 { |
| 2270 NoGCScope no_gc; | 2266 NoGCScope no_gc; |
| 2271 ContainsAddressVisitor visitor(isolate, addr); | 2267 ContainsAddressVisitor visitor(isolate, addr); |
| 2272 object = isolate->heap()->FindObject(&visitor); | 2268 object = isolate->heap()->FindObject(&visitor); |
| 2273 } | 2269 } |
| 2274 object.PrintJSON(js, ref); | 2270 object.PrintJSON(js, ref); |
| 2275 return true; | 2271 return true; |
| 2276 } | 2272 } |
| 2277 | 2273 |
| 2278 | 2274 |
| 2279 static bool HandleIsolateRespondWithMalformedJson(Isolate* isolate, | 2275 static bool _RespondWithMalformedJson(Isolate* isolate, |
| 2280 JSONStream* js) { | 2276 JSONStream* js) { |
| 2281 JSONObject jsobj(js); | 2277 JSONObject jsobj(js); |
| 2282 jsobj.AddProperty("a", "a"); | 2278 jsobj.AddProperty("a", "a"); |
| 2283 JSONObject jsobj1(js); | 2279 JSONObject jsobj1(js); |
| 2284 jsobj1.AddProperty("a", "a"); | 2280 jsobj1.AddProperty("a", "a"); |
| 2285 JSONObject jsobj2(js); | 2281 JSONObject jsobj2(js); |
| 2286 jsobj2.AddProperty("a", "a"); | 2282 jsobj2.AddProperty("a", "a"); |
| 2287 JSONObject jsobj3(js); | 2283 JSONObject jsobj3(js); |
| 2288 jsobj3.AddProperty("a", "a"); | 2284 jsobj3.AddProperty("a", "a"); |
| 2289 return true; | 2285 return true; |
| 2290 } | 2286 } |
| 2291 | 2287 |
| 2292 | 2288 |
| 2293 static bool HandleIsolateRespondWithMalformedObject(Isolate* isolate, | 2289 static bool _RespondWithMalformedObject(Isolate* isolate, |
| 2294 JSONStream* js) { | 2290 JSONStream* js) { |
| 2295 JSONObject jsobj(js); | 2291 JSONObject jsobj(js); |
| 2296 jsobj.AddProperty("bart", "simpson"); | 2292 jsobj.AddProperty("bart", "simpson"); |
| 2297 return true; | 2293 return true; |
| 2298 } | 2294 } |
| 2299 | 2295 |
| 2300 | 2296 |
| 2301 static const MethodParameter* get_object_params[] = { | 2297 static const MethodParameter* get_object_params[] = { |
| 2302 ISOLATE_PARAMETER, | 2298 ISOLATE_PARAMETER, |
| 2303 NULL, | 2299 NULL, |
| 2304 }; | 2300 }; |
| 2305 | 2301 |
| 2306 | 2302 |
| 2307 static bool HandleIsolateGetObject(Isolate* isolate, JSONStream* js) { | 2303 static bool GetObject(Isolate* isolate, JSONStream* js) { |
| 2308 const char* id = js->LookupParam("objectId"); | 2304 const char* id = js->LookupParam("objectId"); |
| 2309 if (id == NULL) { | 2305 if (id == NULL) { |
| 2310 PrintMissingParamError(js, "objectId"); | 2306 PrintMissingParamError(js, "objectId"); |
| 2311 return true; | 2307 return true; |
| 2312 } | 2308 } |
| 2313 | 2309 |
| 2314 // Handle heap objects. | 2310 // Handle heap objects. |
| 2315 ObjectIdRing::LookupResult lookup_result; | 2311 ObjectIdRing::LookupResult lookup_result; |
| 2316 const Object& obj = | 2312 const Object& obj = |
| 2317 Object::Handle(LookupHeapObject(isolate, id, &lookup_result)); | 2313 Object::Handle(LookupHeapObject(isolate, id, &lookup_result)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2338 return true; | 2334 return true; |
| 2339 } | 2335 } |
| 2340 | 2336 |
| 2341 | 2337 |
| 2342 static const MethodParameter* get_class_list_params[] = { | 2338 static const MethodParameter* get_class_list_params[] = { |
| 2343 ISOLATE_PARAMETER, | 2339 ISOLATE_PARAMETER, |
| 2344 NULL, | 2340 NULL, |
| 2345 }; | 2341 }; |
| 2346 | 2342 |
| 2347 | 2343 |
| 2348 static bool HandleIsolateGetClassList(Isolate* isolate, JSONStream* js) { | 2344 static bool GetClassList(Isolate* isolate, JSONStream* js) { |
| 2349 ClassTable* table = isolate->class_table(); | 2345 ClassTable* table = isolate->class_table(); |
| 2350 JSONObject jsobj(js); | 2346 JSONObject jsobj(js); |
| 2351 table->PrintToJSONObject(&jsobj); | 2347 table->PrintToJSONObject(&jsobj); |
| 2352 return true; | 2348 return true; |
| 2353 } | 2349 } |
| 2354 | 2350 |
| 2355 | 2351 |
| 2356 static const MethodParameter* get_type_arguments_list_params[] = { | 2352 static const MethodParameter* get_type_arguments_list_params[] = { |
| 2357 ISOLATE_PARAMETER, | 2353 ISOLATE_PARAMETER, |
| 2358 NULL, | 2354 NULL, |
| 2359 }; | 2355 }; |
| 2360 | 2356 |
| 2361 | 2357 |
| 2362 static bool HandleIsolateGetTypeArgumentsList(Isolate* isolate, | 2358 static bool GetTypeArgumentsList(Isolate* isolate, JSONStream* js) { |
| 2363 JSONStream* js) { | |
| 2364 bool only_with_instantiations = false; | 2359 bool only_with_instantiations = false; |
| 2365 if (js->ParamIs("onlyWithInstantiations", "true")) { | 2360 if (js->ParamIs("onlyWithInstantiations", "true")) { |
| 2366 only_with_instantiations = true; | 2361 only_with_instantiations = true; |
| 2367 } | 2362 } |
| 2368 ObjectStore* object_store = isolate->object_store(); | 2363 ObjectStore* object_store = isolate->object_store(); |
| 2369 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 2364 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
| 2370 ASSERT(table.Length() > 0); | 2365 ASSERT(table.Length() > 0); |
| 2371 TypeArguments& type_args = TypeArguments::Handle(); | 2366 TypeArguments& type_args = TypeArguments::Handle(); |
| 2372 const intptr_t table_size = table.Length() - 1; | 2367 const intptr_t table_size = table.Length() - 1; |
| 2373 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); | 2368 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 JSONArray* jsarr_; | 2402 JSONArray* jsarr_; |
| 2408 }; | 2403 }; |
| 2409 | 2404 |
| 2410 | 2405 |
| 2411 static const MethodParameter* get_vm_params[] = { | 2406 static const MethodParameter* get_vm_params[] = { |
| 2412 NO_ISOLATE_PARAMETER, | 2407 NO_ISOLATE_PARAMETER, |
| 2413 NULL, | 2408 NULL, |
| 2414 }; | 2409 }; |
| 2415 | 2410 |
| 2416 | 2411 |
| 2417 static bool HandleVM(Isolate* isolate, JSONStream* js) { | 2412 static bool GetVM(Isolate* isolate, JSONStream* js) { |
| 2418 JSONObject jsobj(js); | 2413 JSONObject jsobj(js); |
| 2419 jsobj.AddProperty("type", "VM"); | 2414 jsobj.AddProperty("type", "VM"); |
| 2420 jsobj.AddProperty("id", "vm"); | 2415 jsobj.AddProperty("id", "vm"); |
| 2421 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord)); | 2416 jsobj.AddProperty("architectureBits", static_cast<intptr_t>(kBitsPerWord)); |
| 2422 jsobj.AddProperty("targetCPU", CPU::Id()); | 2417 jsobj.AddProperty("targetCPU", CPU::Id()); |
| 2423 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); | 2418 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware()); |
| 2424 jsobj.AddPropertyF("date", "%" Pd64 "", OS::GetCurrentTimeMillis()); | 2419 jsobj.AddPropertyF("date", "%" Pd64 "", OS::GetCurrentTimeMillis()); |
| 2425 jsobj.AddProperty("version", Version::String()); | 2420 jsobj.AddProperty("version", Version::String()); |
| 2426 // Send pid as a string because it allows us to avoid any issues with | 2421 // Send pid as a string because it allows us to avoid any issues with |
| 2427 // pids > 53-bits (when consumed by JavaScript). | 2422 // pids > 53-bits (when consumed by JavaScript). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2444 return true; | 2439 return true; |
| 2445 } | 2440 } |
| 2446 | 2441 |
| 2447 | 2442 |
| 2448 static const MethodParameter* get_flag_list_params[] = { | 2443 static const MethodParameter* get_flag_list_params[] = { |
| 2449 NO_ISOLATE_PARAMETER, | 2444 NO_ISOLATE_PARAMETER, |
| 2450 NULL, | 2445 NULL, |
| 2451 }; | 2446 }; |
| 2452 | 2447 |
| 2453 | 2448 |
| 2454 static bool HandleVMFlagList(Isolate* isolate, JSONStream* js) { | 2449 static bool GetFlagList(Isolate* isolate, JSONStream* js) { |
| 2455 Flags::PrintJSON(js); | 2450 Flags::PrintJSON(js); |
| 2456 return true; | 2451 return true; |
| 2457 } | 2452 } |
| 2458 | 2453 |
| 2459 | 2454 |
| 2460 static const MethodParameter* set_flags_params[] = { | 2455 static const MethodParameter* set_flags_params[] = { |
| 2461 NO_ISOLATE_PARAMETER, | 2456 NO_ISOLATE_PARAMETER, |
| 2462 NULL, | 2457 NULL, |
| 2463 }; | 2458 }; |
| 2464 | 2459 |
| 2465 | 2460 |
| 2466 static bool HandleVMSetFlag(Isolate* isolate, JSONStream* js) { | 2461 static bool SetFlag(Isolate* isolate, JSONStream* js) { |
| 2467 const char* flag_name = js->LookupParam("name"); | 2462 const char* flag_name = js->LookupParam("name"); |
| 2468 if (flag_name == NULL) { | 2463 if (flag_name == NULL) { |
| 2469 PrintMissingParamError(js, "name"); | 2464 PrintMissingParamError(js, "name"); |
| 2470 return true; | 2465 return true; |
| 2471 } | 2466 } |
| 2472 const char* flag_value = js->LookupParam("value"); | 2467 const char* flag_value = js->LookupParam("value"); |
| 2473 if (flag_value == NULL) { | 2468 if (flag_value == NULL) { |
| 2474 PrintMissingParamError(js, "value"); | 2469 PrintMissingParamError(js, "value"); |
| 2475 return true; | 2470 return true; |
| 2476 } | 2471 } |
| 2477 JSONObject jsobj(js); | 2472 JSONObject jsobj(js); |
| 2478 const char* error = NULL; | 2473 const char* error = NULL; |
| 2479 if (Flags::SetFlag(flag_name, flag_value, &error)) { | 2474 if (Flags::SetFlag(flag_name, flag_value, &error)) { |
| 2480 jsobj.AddProperty("type", "Success"); | 2475 jsobj.AddProperty("type", "Success"); |
| 2481 jsobj.AddProperty("id", ""); | 2476 jsobj.AddProperty("id", ""); |
| 2482 return true; | 2477 return true; |
| 2483 } else { | 2478 } else { |
| 2484 jsobj.AddProperty("type", "Failure"); | 2479 jsobj.AddProperty("type", "Failure"); |
| 2485 jsobj.AddProperty("id", ""); | 2480 jsobj.AddProperty("id", ""); |
| 2486 jsobj.AddProperty("message", error); | 2481 jsobj.AddProperty("message", error); |
| 2487 return true; | 2482 return true; |
| 2488 } | 2483 } |
| 2489 } | 2484 } |
| 2490 | 2485 |
| 2491 | 2486 |
| 2492 static ServiceMethodDescriptor service_methods_[] = { | 2487 static ServiceMethodDescriptor service_methods_[] = { |
| 2493 { "_echo", HandleIsolateEcho, | 2488 { "_echo", _Echo, |
| 2494 NULL }, | 2489 NULL }, |
| 2495 { "_respondWithMalformedJson", HandleIsolateRespondWithMalformedJson, | 2490 { "_respondWithMalformedJson", _RespondWithMalformedJson, |
| 2496 NULL }, | 2491 NULL }, |
| 2497 { "_respondWithMalformedObject", HandleIsolateRespondWithMalformedObject, | 2492 { "_respondWithMalformedObject", _RespondWithMalformedObject, |
| 2498 NULL }, | 2493 NULL }, |
| 2499 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, | 2494 { "_triggerEchoEvent", _TriggerEchoEvent, |
| 2500 NULL }, | 2495 NULL }, |
| 2501 { "addBreakpoint", HandleIsolateAddBreakpoint, | 2496 { "addBreakpoint", AddBreakpoint, |
| 2502 add_breakpoint_params }, | 2497 add_breakpoint_params }, |
| 2503 { "addBreakpointAtEntry", HandleIsolateAddBreakpointAtEntry, | 2498 { "addBreakpointAtEntry", AddBreakpointAtEntry, |
| 2504 add_breakpoint_at_entry_params }, | 2499 add_breakpoint_at_entry_params }, |
| 2505 { "eval", HandleIsolateEval, | 2500 { "eval", Eval, |
| 2506 eval_params }, | 2501 eval_params }, |
| 2507 { "getAllocationProfile", HandleIsolateGetAllocationProfile, | 2502 { "getAllocationProfile", GetAllocationProfile, |
| 2508 get_allocation_profile_params }, | 2503 get_allocation_profile_params }, |
| 2509 { "getBreakpoints", HandleIsolateGetBreakpoints, | 2504 { "getBreakpoints", GetBreakpoints, |
| 2510 get_breakpoints_params }, | 2505 get_breakpoints_params }, |
| 2511 { "getCallSiteData", HandleIsolateGetCallSiteData, | 2506 { "getCallSiteData", GetCallSiteData, |
| 2512 get_call_site_data_params }, | 2507 get_call_site_data_params }, |
| 2513 { "getClassList", HandleIsolateGetClassList, | 2508 { "getClassList", GetClassList, |
| 2514 get_class_list_params }, | 2509 get_class_list_params }, |
| 2515 { "getCoverage", HandleIsolateGetCoverage, | 2510 { "getCoverage", GetCoverage, |
| 2516 get_coverage_params }, | 2511 get_coverage_params }, |
| 2517 { "getCpuProfile", HandleIsolateGetCpuProfile, | 2512 { "getCpuProfile", GetCpuProfile, |
| 2518 get_cpu_profile_params }, | 2513 get_cpu_profile_params }, |
| 2519 { "getFlagList", HandleVMFlagList , | 2514 { "getFlagList", GetFlagList , |
| 2520 get_flag_list_params }, | 2515 get_flag_list_params }, |
| 2521 { "getHeapMap", HandleIsolateGetHeapMap, | 2516 { "getHeapMap", GetHeapMap, |
| 2522 get_heap_map_params }, | 2517 get_heap_map_params }, |
| 2523 { "getInboundReferences", HandleIsolateGetInboundReferences, | 2518 { "getInboundReferences", GetInboundReferences, |
| 2524 get_inbound_references_params }, | 2519 get_inbound_references_params }, |
| 2525 { "getInstances", HandleIsolateGetInstances, | 2520 { "getInstances", GetInstances, |
| 2526 get_instances_params }, | 2521 get_instances_params }, |
| 2527 { "getIsolate", HandleIsolate, | 2522 { "getIsolate", GetIsolate, |
| 2528 get_isolate_params }, | 2523 get_isolate_params }, |
| 2529 { "getIsolateMetric", HandleIsolateGetMetric, | 2524 { "getIsolateMetric", GetIsolateMetric, |
| 2530 get_metric_params }, | 2525 get_isolate_metric_params }, |
| 2531 { "getIsolateMetricList", HandleIsolateGetMetricList, | 2526 { "getIsolateMetricList", GetIsolateMetricList, |
| 2532 get_metric_list_params }, | 2527 get_isolate_metric_list_params }, |
| 2533 { "getObject", HandleIsolateGetObject, | 2528 { "getObject", GetObject, |
| 2534 get_object_params }, | 2529 get_object_params }, |
| 2535 { "getObjectByAddress", HandleIsolateGetObjectByAddress, | 2530 { "getObjectByAddress", GetObjectByAddress, |
| 2536 get_object_by_address_params }, | 2531 get_object_by_address_params }, |
| 2537 { "getRetainedSize", HandleIsolateGetRetainedSize, | 2532 { "getRetainedSize", GetRetainedSize, |
| 2538 get_retained_size_params }, | 2533 get_retained_size_params }, |
| 2539 { "getRetainingPath", HandleIsolateGetRetainingPath, | 2534 { "getRetainingPath", GetRetainingPath, |
| 2540 get_retaining_path_params }, | 2535 get_retaining_path_params }, |
| 2541 { "getStack", HandleIsolateGetStack, | 2536 { "getStack", GetStack, |
| 2542 get_stack_params }, | 2537 get_stack_params }, |
| 2543 { "getTagProfile", HandleIsolateGetTagProfile, | 2538 { "getTagProfile", GetTagProfile, |
| 2544 get_tag_profile_params }, | 2539 get_tag_profile_params }, |
| 2545 { "getTypeArgumentsList", HandleIsolateGetTypeArgumentsList, | 2540 { "getTypeArgumentsList", GetTypeArgumentsList, |
| 2546 get_type_arguments_list_params }, | 2541 get_type_arguments_list_params }, |
| 2547 { "getVM", HandleVM , | 2542 { "getVM", GetVM, |
| 2548 get_vm_params }, | 2543 get_vm_params }, |
| 2549 { "getVMMetric", HandleVMGetMetric, | 2544 { "getVMMetric", GetVMMetric, |
| 2550 get_vm_metric_params }, | 2545 get_vm_metric_params }, |
| 2551 { "getVMMetricList", HandleVMGetMetricList, | 2546 { "getVMMetricList", GetVMMetricList, |
| 2552 get_vm_metric_list_params }, | 2547 get_vm_metric_list_params }, |
| 2553 { "pause", HandleIsolatePause, | 2548 { "pause", Pause, |
| 2554 pause_params }, | 2549 pause_params }, |
| 2555 { "removeBreakpoint", HandleIsolateRemoveBreakpoint, | 2550 { "removeBreakpoint", RemoveBreakpoint, |
| 2556 remove_breakpoint_params }, | 2551 remove_breakpoint_params }, |
| 2557 { "resume", HandleIsolateResume, | 2552 { "resume", Resume, |
| 2558 resume_params }, | 2553 resume_params }, |
| 2559 { "requestHeapSnapshot", HandleIsolateRequestHeapSnapshot, | 2554 { "requestHeapSnapshot", RequestHeapSnapshot, |
| 2560 request_heap_snapshot_params }, | 2555 request_heap_snapshot_params }, |
| 2561 { "setFlag", HandleVMSetFlag , | 2556 { "setFlag", SetFlag , |
| 2562 set_flags_params }, | 2557 set_flags_params }, |
| 2563 }; | 2558 }; |
| 2564 | 2559 |
| 2565 | 2560 |
| 2566 ServiceMethodDescriptor* FindMethod(const char* method_name) { | 2561 ServiceMethodDescriptor* FindMethod(const char* method_name) { |
| 2567 intptr_t num_methods = sizeof(service_methods_) / | 2562 intptr_t num_methods = sizeof(service_methods_) / |
| 2568 sizeof(service_methods_[0]); | 2563 sizeof(service_methods_[0]); |
| 2569 for (intptr_t i = 0; i < num_methods; i++) { | 2564 for (intptr_t i = 0; i < num_methods; i++) { |
| 2570 ServiceMethodDescriptor& method = service_methods_[i]; | 2565 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2571 if (strcmp(method_name, method.name) == 0) { | 2566 if (strcmp(method_name, method.name) == 0) { |
| 2572 return &method; | 2567 return &method; |
| 2573 } | 2568 } |
| 2574 } | 2569 } |
| 2575 return NULL; | 2570 return NULL; |
| 2576 } | 2571 } |
| 2577 | 2572 |
| 2578 | 2573 |
| 2579 } // namespace dart | 2574 } // namespace dart |
| OLD | NEW |