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 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 | 1964 |
1965 // TODO(hausner): Merge some of this functionality with the code in | 1965 // TODO(hausner): Merge some of this functionality with the code in |
1966 // dart_api_impl.cc. | 1966 // dart_api_impl.cc. |
1967 RawObject* Debugger::GetInstanceField(const Class& cls, | 1967 RawObject* Debugger::GetInstanceField(const Class& cls, |
1968 const String& field_name, | 1968 const String& field_name, |
1969 const Instance& object) { | 1969 const Instance& object) { |
1970 const Function& getter_func = | 1970 const Function& getter_func = |
1971 Function::Handle(cls.LookupGetterFunction(field_name)); | 1971 Function::Handle(cls.LookupGetterFunction(field_name)); |
1972 ASSERT(!getter_func.IsNull()); | 1972 ASSERT(!getter_func.IsNull()); |
1973 | 1973 |
1974 Object& result = Object::Handle(); | 1974 PassiveObject& result = PassiveObject::Handle(); |
1975 bool saved_ignore_flag = ignore_breakpoints_; | 1975 bool saved_ignore_flag = ignore_breakpoints_; |
1976 ignore_breakpoints_ = true; | 1976 ignore_breakpoints_ = true; |
1977 | 1977 |
1978 LongJumpScope jump; | 1978 LongJumpScope jump; |
1979 if (setjmp(*jump.Set()) == 0) { | 1979 if (setjmp(*jump.Set()) == 0) { |
1980 const Array& args = Array::Handle(Array::New(1)); | 1980 const Array& args = Array::Handle(Array::New(1)); |
1981 args.SetAt(0, object); | 1981 args.SetAt(0, object); |
1982 result = DartEntry::InvokeFunction(getter_func, args); | 1982 result = DartEntry::InvokeFunction(getter_func, args); |
1983 } else { | 1983 } else { |
1984 result = isolate_->object_store()->sticky_error(); | 1984 result = isolate_->object_store()->sticky_error(); |
(...skipping 16 matching lines...) Expand all Loading... |
2001 } | 2001 } |
2002 // There is no field or the field has not been initialized yet. | 2002 // There is no field or the field has not been initialized yet. |
2003 // We must have a getter. Run the getter. | 2003 // We must have a getter. Run the getter. |
2004 const Function& getter_func = | 2004 const Function& getter_func = |
2005 Function::Handle(cls.LookupGetterFunction(field_name)); | 2005 Function::Handle(cls.LookupGetterFunction(field_name)); |
2006 ASSERT(!getter_func.IsNull()); | 2006 ASSERT(!getter_func.IsNull()); |
2007 if (getter_func.IsNull()) { | 2007 if (getter_func.IsNull()) { |
2008 return Object::null(); | 2008 return Object::null(); |
2009 } | 2009 } |
2010 | 2010 |
2011 Object& result = Object::Handle(); | 2011 PassiveObject& result = PassiveObject::Handle(); |
2012 bool saved_ignore_flag = ignore_breakpoints_; | 2012 bool saved_ignore_flag = ignore_breakpoints_; |
2013 ignore_breakpoints_ = true; | 2013 ignore_breakpoints_ = true; |
2014 LongJumpScope jump; | 2014 LongJumpScope jump; |
2015 if (setjmp(*jump.Set()) == 0) { | 2015 if (setjmp(*jump.Set()) == 0) { |
2016 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); | 2016 result = DartEntry::InvokeFunction(getter_func, Object::empty_array()); |
2017 } else { | 2017 } else { |
2018 result = isolate_->object_store()->sticky_error(); | 2018 result = isolate_->object_store()->sticky_error(); |
2019 } | 2019 } |
2020 ignore_breakpoints_ = saved_ignore_flag; | 2020 ignore_breakpoints_ = saved_ignore_flag; |
2021 return result.raw(); | 2021 return result.raw(); |
2022 } | 2022 } |
2023 | 2023 |
2024 | 2024 |
2025 RawArray* Debugger::GetInstanceFields(const Instance& obj) { | 2025 RawArray* Debugger::GetInstanceFields(const Instance& obj) { |
2026 Class& cls = Class::Handle(obj.clazz()); | 2026 Class& cls = Class::Handle(obj.clazz()); |
2027 Array& fields = Array::Handle(); | 2027 Array& fields = Array::Handle(); |
2028 Field& field = Field::Handle(); | 2028 Field& field = Field::Handle(); |
2029 const GrowableObjectArray& field_list = | 2029 const GrowableObjectArray& field_list = |
2030 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 2030 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
2031 String& field_name = String::Handle(); | 2031 String& field_name = String::Handle(); |
2032 Object& field_value = Object::Handle(); | 2032 PassiveObject& field_value = PassiveObject::Handle(); |
2033 // Iterate over fields in class hierarchy to count all instance fields. | 2033 // Iterate over fields in class hierarchy to count all instance fields. |
2034 while (!cls.IsNull()) { | 2034 while (!cls.IsNull()) { |
2035 fields = cls.fields(); | 2035 fields = cls.fields(); |
2036 for (intptr_t i = 0; i < fields.Length(); i++) { | 2036 for (intptr_t i = 0; i < fields.Length(); i++) { |
2037 field ^= fields.At(i); | 2037 field ^= fields.At(i); |
2038 if (!field.is_static()) { | 2038 if (!field.is_static()) { |
2039 field_name = field.name(); | 2039 field_name = field.name(); |
2040 field_list.Add(field_name); | 2040 field_list.Add(field_name); |
2041 field_value = GetInstanceField(cls, field_name, obj); | 2041 field_value = GetInstanceField(cls, field_name, obj); |
2042 field_list.Add(field_value); | 2042 field_list.Add(field_value); |
2043 } | 2043 } |
2044 } | 2044 } |
2045 cls = cls.SuperClass(); | 2045 cls = cls.SuperClass(); |
2046 } | 2046 } |
2047 return Array::MakeArray(field_list); | 2047 return Array::MakeArray(field_list); |
2048 } | 2048 } |
2049 | 2049 |
2050 | 2050 |
2051 RawArray* Debugger::GetStaticFields(const Class& cls) { | 2051 RawArray* Debugger::GetStaticFields(const Class& cls) { |
2052 const GrowableObjectArray& field_list = | 2052 const GrowableObjectArray& field_list = |
2053 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 2053 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
2054 Array& fields = Array::Handle(cls.fields()); | 2054 Array& fields = Array::Handle(cls.fields()); |
2055 Field& field = Field::Handle(); | 2055 Field& field = Field::Handle(); |
2056 String& field_name = String::Handle(); | 2056 String& field_name = String::Handle(); |
2057 Object& field_value = Object::Handle(); | 2057 PassiveObject& field_value = PassiveObject::Handle(); |
2058 for (intptr_t i = 0; i < fields.Length(); i++) { | 2058 for (intptr_t i = 0; i < fields.Length(); i++) { |
2059 field ^= fields.At(i); | 2059 field ^= fields.At(i); |
2060 if (field.is_static()) { | 2060 if (field.is_static()) { |
2061 field_name = field.name(); | 2061 field_name = field.name(); |
2062 field_value = GetStaticField(cls, field_name); | 2062 field_value = GetStaticField(cls, field_name); |
2063 field_list.Add(field_name); | 2063 field_list.Add(field_name); |
2064 field_list.Add(field_value); | 2064 field_list.Add(field_value); |
2065 } | 2065 } |
2066 } | 2066 } |
2067 return Array::MakeArray(field_list); | 2067 return Array::MakeArray(field_list); |
2068 } | 2068 } |
2069 | 2069 |
2070 | 2070 |
2071 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, | 2071 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, |
2072 const Library& lib, | 2072 const Library& lib, |
2073 const String& prefix, | 2073 const String& prefix, |
2074 bool include_private_fields) { | 2074 bool include_private_fields) { |
2075 DictionaryIterator it(lib); | 2075 DictionaryIterator it(lib); |
2076 Object& entry = Object::Handle(isolate_); | 2076 Object& entry = Object::Handle(isolate_); |
2077 Field& field = Field::Handle(isolate_); | 2077 Field& field = Field::Handle(isolate_); |
2078 String& field_name = String::Handle(isolate_); | 2078 String& field_name = String::Handle(isolate_); |
2079 Object& field_value = Object::Handle(isolate_); | 2079 PassiveObject& field_value = PassiveObject::Handle(isolate_); |
2080 while (it.HasNext()) { | 2080 while (it.HasNext()) { |
2081 entry = it.GetNext(); | 2081 entry = it.GetNext(); |
2082 if (entry.IsField()) { | 2082 if (entry.IsField()) { |
2083 field ^= entry.raw(); | 2083 field ^= entry.raw(); |
2084 ASSERT(field.is_static()); | 2084 ASSERT(field.is_static()); |
2085 field_name = field.name(); | 2085 field_name = field.name(); |
2086 if ((field_name.CharAt(0) == '_') && !include_private_fields) { | 2086 if ((field_name.CharAt(0) == '_') && !include_private_fields) { |
2087 // Skip library-private field. | 2087 // Skip library-private field. |
2088 continue; | 2088 continue; |
2089 } | 2089 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2579 } | 2579 } |
2580 | 2580 |
2581 | 2581 |
2582 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2582 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2583 ASSERT(bpt->next() == NULL); | 2583 ASSERT(bpt->next() == NULL); |
2584 bpt->set_next(code_breakpoints_); | 2584 bpt->set_next(code_breakpoints_); |
2585 code_breakpoints_ = bpt; | 2585 code_breakpoints_ = bpt; |
2586 } | 2586 } |
2587 | 2587 |
2588 } // namespace dart | 2588 } // namespace dart |
OLD | NEW |