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 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 // TODO(hausner): Merge some of this functionality with the code in | 1690 // TODO(hausner): Merge some of this functionality with the code in |
1691 // dart_api_impl.cc. | 1691 // dart_api_impl.cc. |
1692 RawObject* Debugger::GetInstanceField(const Class& cls, | 1692 RawObject* Debugger::GetInstanceField(const Class& cls, |
1693 const String& field_name, | 1693 const String& field_name, |
1694 const Instance& object) { | 1694 const Instance& object) { |
1695 const Function& getter_func = | 1695 const Function& getter_func = |
1696 Function::Handle(cls.LookupGetterFunction(field_name)); | 1696 Function::Handle(cls.LookupGetterFunction(field_name)); |
1697 ASSERT(!getter_func.IsNull()); | 1697 ASSERT(!getter_func.IsNull()); |
1698 | 1698 |
1699 Object& result = Object::Handle(); | 1699 Object& result = Object::Handle(); |
1700 LongJump* base = isolate_->long_jump_base(); | |
1701 LongJump jump; | |
1702 isolate_->set_long_jump_base(&jump); | |
1703 bool saved_ignore_flag = ignore_breakpoints_; | 1700 bool saved_ignore_flag = ignore_breakpoints_; |
1704 ignore_breakpoints_ = true; | 1701 ignore_breakpoints_ = true; |
| 1702 |
| 1703 LongJumpScope jump; |
1705 if (setjmp(*jump.Set()) == 0) { | 1704 if (setjmp(*jump.Set()) == 0) { |
1706 const Array& args = Array::Handle(Array::New(1)); | 1705 const Array& args = Array::Handle(Array::New(1)); |
1707 args.SetAt(0, object); | 1706 args.SetAt(0, object); |
1708 result = DartEntry::InvokeFunction(getter_func, args); | 1707 result = DartEntry::InvokeFunction(getter_func, args); |
1709 } else { | 1708 } else { |
1710 result = isolate_->object_store()->sticky_error(); | 1709 result = isolate_->object_store()->sticky_error(); |
1711 } | 1710 } |
1712 ignore_breakpoints_ = saved_ignore_flag; | 1711 ignore_breakpoints_ = saved_ignore_flag; |
1713 isolate_->set_long_jump_base(base); | |
1714 return result.raw(); | 1712 return result.raw(); |
1715 } | 1713 } |
1716 | 1714 |
1717 | 1715 |
1718 RawObject* Debugger::GetStaticField(const Class& cls, | 1716 RawObject* Debugger::GetStaticField(const Class& cls, |
1719 const String& field_name) { | 1717 const String& field_name) { |
1720 const Field& fld = Field::Handle(cls.LookupStaticField(field_name)); | 1718 const Field& fld = Field::Handle(cls.LookupStaticField(field_name)); |
1721 if (!fld.IsNull()) { | 1719 if (!fld.IsNull()) { |
1722 // Return the value in the field if it has been initialized already. | 1720 // Return the value in the field if it has been initialized already. |
1723 const Instance& value = Instance::Handle(fld.value()); | 1721 const Instance& value = Instance::Handle(fld.value()); |
1724 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 1722 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
1725 if (value.raw() != Object::sentinel().raw()) { | 1723 if (value.raw() != Object::sentinel().raw()) { |
1726 return value.raw(); | 1724 return value.raw(); |
1727 } | 1725 } |
1728 } | 1726 } |
1729 // There is no field or the field has not been initialized yet. | 1727 // There is no field or the field has not been initialized yet. |
1730 // We must have a getter. Run the getter. | 1728 // We must have a getter. Run the getter. |
1731 const Function& getter_func = | 1729 const Function& getter_func = |
1732 Function::Handle(cls.LookupGetterFunction(field_name)); | 1730 Function::Handle(cls.LookupGetterFunction(field_name)); |
1733 ASSERT(!getter_func.IsNull()); | 1731 ASSERT(!getter_func.IsNull()); |
1734 if (getter_func.IsNull()) { | 1732 if (getter_func.IsNull()) { |
1735 return Object::null(); | 1733 return Object::null(); |
1736 } | 1734 } |
1737 | 1735 |
1738 Object& result = Object::Handle(); | 1736 Object& result = Object::Handle(); |
1739 LongJump* base = isolate_->long_jump_base(); | |
1740 LongJump jump; | |
1741 isolate_->set_long_jump_base(&jump); | |
1742 bool saved_ignore_flag = ignore_breakpoints_; | 1737 bool saved_ignore_flag = ignore_breakpoints_; |
1743 ignore_breakpoints_ = true; | 1738 ignore_breakpoints_ = true; |
| 1739 LongJumpScope jump; |
1744 if (setjmp(*jump.Set()) == 0) { | 1740 if (setjmp(*jump.Set()) == 0) { |
1745 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); | 1741 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); |
1746 } else { | 1742 } else { |
1747 result = isolate_->object_store()->sticky_error(); | 1743 result = isolate_->object_store()->sticky_error(); |
1748 } | 1744 } |
1749 ignore_breakpoints_ = saved_ignore_flag; | 1745 ignore_breakpoints_ = saved_ignore_flag; |
1750 isolate_->set_long_jump_base(base); | |
1751 return result.raw(); | 1746 return result.raw(); |
1752 } | 1747 } |
1753 | 1748 |
1754 | 1749 |
1755 RawArray* Debugger::GetInstanceFields(const Instance& obj) { | 1750 RawArray* Debugger::GetInstanceFields(const Instance& obj) { |
1756 Class& cls = Class::Handle(obj.clazz()); | 1751 Class& cls = Class::Handle(obj.clazz()); |
1757 Array& fields = Array::Handle(); | 1752 Array& fields = Array::Handle(); |
1758 Field& field = Field::Handle(); | 1753 Field& field = Field::Handle(); |
1759 const GrowableObjectArray& field_list = | 1754 const GrowableObjectArray& field_list = |
1760 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1755 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 } | 2276 } |
2282 | 2277 |
2283 | 2278 |
2284 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2279 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2285 ASSERT(bpt->next() == NULL); | 2280 ASSERT(bpt->next() == NULL); |
2286 bpt->set_next(code_breakpoints_); | 2281 bpt->set_next(code_breakpoints_); |
2287 code_breakpoints_ = bpt; | 2282 code_breakpoints_ = bpt; |
2288 } | 2283 } |
2289 | 2284 |
2290 } // namespace dart | 2285 } // namespace dart |
OLD | NEW |