| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/debugger.h" | 5 #include "vm/debugger.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 // TODO(hausner): Merge some of this functionality with the code in | 1681 // TODO(hausner): Merge some of this functionality with the code in |
| 1682 // dart_api_impl.cc. | 1682 // dart_api_impl.cc. |
| 1683 RawObject* Debugger::GetInstanceField(const Class& cls, | 1683 RawObject* Debugger::GetInstanceField(const Class& cls, |
| 1684 const String& field_name, | 1684 const String& field_name, |
| 1685 const Instance& object) { | 1685 const Instance& object) { |
| 1686 const Function& getter_func = | 1686 const Function& getter_func = |
| 1687 Function::Handle(cls.LookupGetterFunction(field_name)); | 1687 Function::Handle(cls.LookupGetterFunction(field_name)); |
| 1688 ASSERT(!getter_func.IsNull()); | 1688 ASSERT(!getter_func.IsNull()); |
| 1689 | 1689 |
| 1690 Object& result = Object::Handle(); | 1690 Object& result = Object::Handle(); |
| 1691 LongJump* base = isolate_->long_jump_base(); | |
| 1692 LongJump jump; | |
| 1693 isolate_->set_long_jump_base(&jump); | |
| 1694 bool saved_ignore_flag = ignore_breakpoints_; | 1691 bool saved_ignore_flag = ignore_breakpoints_; |
| 1695 ignore_breakpoints_ = true; | 1692 ignore_breakpoints_ = true; |
| 1693 |
| 1694 LongJumpScope jump; |
| 1696 if (setjmp(*jump.Set()) == 0) { | 1695 if (setjmp(*jump.Set()) == 0) { |
| 1697 const Array& args = Array::Handle(Array::New(1)); | 1696 const Array& args = Array::Handle(Array::New(1)); |
| 1698 args.SetAt(0, object); | 1697 args.SetAt(0, object); |
| 1699 result = DartEntry::InvokeFunction(getter_func, args); | 1698 result = DartEntry::InvokeFunction(getter_func, args); |
| 1700 } else { | 1699 } else { |
| 1701 result = isolate_->object_store()->sticky_error(); | 1700 result = isolate_->object_store()->sticky_error(); |
| 1702 } | 1701 } |
| 1703 ignore_breakpoints_ = saved_ignore_flag; | 1702 ignore_breakpoints_ = saved_ignore_flag; |
| 1704 isolate_->set_long_jump_base(base); | |
| 1705 return result.raw(); | 1703 return result.raw(); |
| 1706 } | 1704 } |
| 1707 | 1705 |
| 1708 | 1706 |
| 1709 RawObject* Debugger::GetStaticField(const Class& cls, | 1707 RawObject* Debugger::GetStaticField(const Class& cls, |
| 1710 const String& field_name) { | 1708 const String& field_name) { |
| 1711 const Field& fld = Field::Handle(cls.LookupStaticField(field_name)); | 1709 const Field& fld = Field::Handle(cls.LookupStaticField(field_name)); |
| 1712 if (!fld.IsNull()) { | 1710 if (!fld.IsNull()) { |
| 1713 // Return the value in the field if it has been initialized already. | 1711 // Return the value in the field if it has been initialized already. |
| 1714 const Instance& value = Instance::Handle(fld.value()); | 1712 const Instance& value = Instance::Handle(fld.value()); |
| 1715 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 1713 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
| 1716 if (value.raw() != Object::sentinel().raw()) { | 1714 if (value.raw() != Object::sentinel().raw()) { |
| 1717 return value.raw(); | 1715 return value.raw(); |
| 1718 } | 1716 } |
| 1719 } | 1717 } |
| 1720 // There is no field or the field has not been initialized yet. | 1718 // There is no field or the field has not been initialized yet. |
| 1721 // We must have a getter. Run the getter. | 1719 // We must have a getter. Run the getter. |
| 1722 const Function& getter_func = | 1720 const Function& getter_func = |
| 1723 Function::Handle(cls.LookupGetterFunction(field_name)); | 1721 Function::Handle(cls.LookupGetterFunction(field_name)); |
| 1724 ASSERT(!getter_func.IsNull()); | 1722 ASSERT(!getter_func.IsNull()); |
| 1725 if (getter_func.IsNull()) { | 1723 if (getter_func.IsNull()) { |
| 1726 return Object::null(); | 1724 return Object::null(); |
| 1727 } | 1725 } |
| 1728 | 1726 |
| 1729 Object& result = Object::Handle(); | 1727 Object& result = Object::Handle(); |
| 1730 LongJump* base = isolate_->long_jump_base(); | |
| 1731 LongJump jump; | |
| 1732 isolate_->set_long_jump_base(&jump); | |
| 1733 bool saved_ignore_flag = ignore_breakpoints_; | 1728 bool saved_ignore_flag = ignore_breakpoints_; |
| 1734 ignore_breakpoints_ = true; | 1729 ignore_breakpoints_ = true; |
| 1730 LongJumpScope jump; |
| 1735 if (setjmp(*jump.Set()) == 0) { | 1731 if (setjmp(*jump.Set()) == 0) { |
| 1736 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); | 1732 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); |
| 1737 } else { | 1733 } else { |
| 1738 result = isolate_->object_store()->sticky_error(); | 1734 result = isolate_->object_store()->sticky_error(); |
| 1739 } | 1735 } |
| 1740 ignore_breakpoints_ = saved_ignore_flag; | 1736 ignore_breakpoints_ = saved_ignore_flag; |
| 1741 isolate_->set_long_jump_base(base); | |
| 1742 return result.raw(); | 1737 return result.raw(); |
| 1743 } | 1738 } |
| 1744 | 1739 |
| 1745 | 1740 |
| 1746 RawArray* Debugger::GetInstanceFields(const Instance& obj) { | 1741 RawArray* Debugger::GetInstanceFields(const Instance& obj) { |
| 1747 Class& cls = Class::Handle(obj.clazz()); | 1742 Class& cls = Class::Handle(obj.clazz()); |
| 1748 Array& fields = Array::Handle(); | 1743 Array& fields = Array::Handle(); |
| 1749 Field& field = Field::Handle(); | 1744 Field& field = Field::Handle(); |
| 1750 const GrowableObjectArray& field_list = | 1745 const GrowableObjectArray& field_list = |
| 1751 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1746 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 } | 2266 } |
| 2272 | 2267 |
| 2273 | 2268 |
| 2274 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2269 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 2275 ASSERT(bpt->next() == NULL); | 2270 ASSERT(bpt->next() == NULL); |
| 2276 bpt->set_next(code_breakpoints_); | 2271 bpt->set_next(code_breakpoints_); |
| 2277 code_breakpoints_ = bpt; | 2272 code_breakpoints_ = bpt; |
| 2278 } | 2273 } |
| 2279 | 2274 |
| 2280 } // namespace dart | 2275 } // namespace dart |
| OLD | NEW |