Chromium Code Reviews| 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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 | 1548 |
| 1549 const char* expr = js->LookupParam("expression"); | 1549 const char* expr = js->LookupParam("expression"); |
| 1550 const String& expr_str = String::Handle(isolate, String::New(expr)); | 1550 const String& expr_str = String::Handle(isolate, String::New(expr)); |
| 1551 | 1551 |
| 1552 const Object& result = Object::Handle(frame->Evaluate(expr_str)); | 1552 const Object& result = Object::Handle(frame->Evaluate(expr_str)); |
| 1553 result.PrintJSON(js, true); | 1553 result.PrintJSON(js, true); |
| 1554 return true; | 1554 return true; |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 | 1557 |
| 1558 static const MethodParameter* get_call_site_data_params[] = { | |
| 1559 ISOLATE_PARAMETER, | |
| 1560 new IdParameter("targetId", true), | |
| 1561 NULL, | |
| 1562 }; | |
| 1563 | |
| 1564 | |
| 1565 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { | |
| 1566 const char* target_id = js->LookupParam("targetId"); | |
| 1567 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | |
| 1568 if (obj.raw() == Object::sentinel().raw()) { | |
| 1569 PrintInvalidParamError(js, "targetId"); | |
| 1570 return true; | |
| 1571 } | |
| 1572 if (obj.IsFunction()) { | |
| 1573 const Function& func = Function::Cast(obj); | |
| 1574 const GrowableObjectArray& ics = | |
| 1575 GrowableObjectArray::Handle(func.CollectICsWithSourcePositions()); | |
| 1576 JSONObject jsobj(js); | |
| 1577 jsobj.AddProperty("type", "_CallSiteData"); | |
| 1578 jsobj.AddProperty("function", func); | |
| 1579 JSONArray elements(&jsobj, "callSites"); | |
| 1580 ICData& ic_data = ICData::Handle(); | |
| 1581 Smi& token_pos = Smi::Handle(); | |
| 1582 for (intptr_t i = 0; i < ics.Length();) { | |
| 1583 ic_data ^= ics.At(i++); | |
| 1584 token_pos ^= ics.At(i++); | |
| 1585 ic_data.PrintToJSONArray(&elements, token_pos.Value()); | |
| 1586 } | |
| 1587 return true; | |
| 1588 } | |
| 1589 return false; | |
| 1590 } | |
| 1591 | |
| 1592 | |
| 1593 class GetInstancesVisitor : public ObjectGraph::Visitor { | 1558 class GetInstancesVisitor : public ObjectGraph::Visitor { |
| 1594 public: | 1559 public: |
| 1595 GetInstancesVisitor(const Class& cls, const Array& storage) | 1560 GetInstancesVisitor(const Class& cls, const Array& storage) |
| 1596 : cls_(cls), storage_(storage), count_(0) {} | 1561 : cls_(cls), storage_(storage), count_(0) {} |
| 1597 | 1562 |
| 1598 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { | 1563 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { |
| 1599 RawObject* raw_obj = it->Get(); | 1564 RawObject* raw_obj = it->Get(); |
| 1600 if (raw_obj->IsFreeListElement()) { | 1565 if (raw_obj->IsFreeListElement()) { |
| 1601 return kProceed; | 1566 return kProceed; |
| 1602 } | 1567 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1724 const Script& script, | 1689 const Script& script, |
| 1725 const Class& cls, | 1690 const Class& cls, |
| 1726 const Function& func) const { | 1691 const Function& func) const { |
| 1727 return func.raw() == func_.raw(); | 1692 return func.raw() == func_.raw(); |
| 1728 } | 1693 } |
| 1729 private: | 1694 private: |
| 1730 const Function& func_; | 1695 const Function& func_; |
| 1731 }; | 1696 }; |
| 1732 | 1697 |
| 1733 | 1698 |
| 1734 static const MethodParameter* get_coverage_params[] = { | 1699 static bool GetHitsOrSites(Isolate* isolate, JSONStream* js, bool as_sites) { |
| 1735 ISOLATE_PARAMETER, | |
| 1736 NULL, | |
| 1737 }; | |
| 1738 | |
| 1739 | |
| 1740 static bool GetCoverage(Isolate* isolate, JSONStream* js) { | |
| 1741 if (!js->HasParam("targetId")) { | 1700 if (!js->HasParam("targetId")) { |
| 1742 CodeCoverage::PrintJSON(isolate, js, NULL); | 1701 CodeCoverage::PrintJSON(isolate, js, NULL, as_sites); |
| 1743 return true; | 1702 return true; |
| 1744 } | 1703 } |
| 1745 const char* target_id = js->LookupParam("targetId"); | 1704 const char* target_id = js->LookupParam("targetId"); |
| 1746 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 1705 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); |
| 1747 if (obj.raw() == Object::sentinel().raw()) { | 1706 if (obj.raw() == Object::sentinel().raw()) { |
| 1748 PrintInvalidParamError(js, "targetId"); | 1707 PrintInvalidParamError(js, "targetId"); |
| 1749 return true; | 1708 return true; |
| 1750 } | 1709 } |
| 1751 if (obj.IsScript()) { | 1710 if (obj.IsScript()) { |
| 1752 ScriptCoverageFilter sf(Script::Cast(obj)); | 1711 ScriptCoverageFilter sf(Script::Cast(obj)); |
| 1753 CodeCoverage::PrintJSON(isolate, js, &sf); | 1712 CodeCoverage::PrintJSON(isolate, js, &sf, as_sites); |
| 1754 return true; | 1713 return true; |
| 1755 } | 1714 } |
| 1756 if (obj.IsLibrary()) { | 1715 if (obj.IsLibrary()) { |
| 1757 LibraryCoverageFilter lf(Library::Cast(obj)); | 1716 LibraryCoverageFilter lf(Library::Cast(obj)); |
| 1758 CodeCoverage::PrintJSON(isolate, js, &lf); | 1717 CodeCoverage::PrintJSON(isolate, js, &lf, as_sites); |
| 1759 return true; | 1718 return true; |
| 1760 } | 1719 } |
| 1761 if (obj.IsClass()) { | 1720 if (obj.IsClass()) { |
| 1762 ClassCoverageFilter cf(Class::Cast(obj)); | 1721 ClassCoverageFilter cf(Class::Cast(obj)); |
| 1763 CodeCoverage::PrintJSON(isolate, js, &cf); | 1722 CodeCoverage::PrintJSON(isolate, js, &cf, as_sites); |
| 1764 return true; | 1723 return true; |
| 1765 } | 1724 } |
| 1766 if (obj.IsFunction()) { | 1725 if (obj.IsFunction()) { |
| 1767 FunctionCoverageFilter ff(Function::Cast(obj)); | 1726 FunctionCoverageFilter ff(Function::Cast(obj)); |
| 1768 CodeCoverage::PrintJSON(isolate, js, &ff); | 1727 CodeCoverage::PrintJSON(isolate, js, &ff, as_sites); |
| 1769 return true; | 1728 return true; |
| 1770 } | 1729 } |
| 1771 PrintError(js, "%s: Invalid 'targetId' parameter value: " | 1730 PrintError(js, "%s: Invalid 'targetId' parameter value: " |
| 1772 "id '%s' does not correspond to a " | 1731 "id '%s' does not correspond to a " |
| 1773 "script, library, class, or function", js->method(), target_id); | 1732 "script, library, class, or function", js->method(), target_id); |
| 1774 return true; | 1733 return true; |
| 1775 } | 1734 } |
| 1776 | 1735 |
| 1777 | 1736 |
| 1737 static const MethodParameter* get_coverage_params[] = { | |
| 1738 ISOLATE_PARAMETER, | |
| 1739 NULL, | |
| 1740 }; | |
| 1741 | |
| 1742 | |
| 1743 static bool GetCoverage(Isolate* isolate, JSONStream* js) { | |
|
Cutch
2015/03/18 19:53:52
Add a TODO here to remove this.
rmacnak
2015/03/18 20:06:47
Done.
| |
| 1744 return GetHitsOrSites(isolate, js, false); | |
| 1745 } | |
| 1746 | |
| 1747 | |
| 1748 static const MethodParameter* get_call_site_data_params[] = { | |
| 1749 ISOLATE_PARAMETER, | |
| 1750 new IdParameter("targetId", true), | |
| 1751 NULL, | |
| 1752 }; | |
| 1753 | |
| 1754 | |
| 1755 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { | |
| 1756 return GetHitsOrSites(isolate, js, true); | |
| 1757 } | |
| 1758 | |
| 1759 | |
| 1778 static const MethodParameter* add_breakpoint_params[] = { | 1760 static const MethodParameter* add_breakpoint_params[] = { |
| 1779 ISOLATE_PARAMETER, | 1761 ISOLATE_PARAMETER, |
| 1780 new IdParameter("scriptId", true), | 1762 new IdParameter("scriptId", true), |
| 1781 new UIntParameter("line", true), | 1763 new UIntParameter("line", true), |
| 1782 NULL, | 1764 NULL, |
| 1783 }; | 1765 }; |
| 1784 | 1766 |
| 1785 | 1767 |
| 1786 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { | 1768 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { |
| 1787 const char* line_param = js->LookupParam("line"); | 1769 const char* line_param = js->LookupParam("line"); |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2606 ServiceMethodDescriptor& method = service_methods_[i]; | 2588 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2607 if (strcmp(method_name, method.name) == 0) { | 2589 if (strcmp(method_name, method.name) == 0) { |
| 2608 return &method; | 2590 return &method; |
| 2609 } | 2591 } |
| 2610 } | 2592 } |
| 2611 return NULL; | 2593 return NULL; |
| 2612 } | 2594 } |
| 2613 | 2595 |
| 2614 | 2596 |
| 2615 } // namespace dart | 2597 } // namespace dart |
| OLD | NEW |