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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 501 |
502 void ActivationFrame::VariableAt(intptr_t i, | 502 void ActivationFrame::VariableAt(intptr_t i, |
503 String* name, | 503 String* name, |
504 intptr_t* token_pos, | 504 intptr_t* token_pos, |
505 intptr_t* end_pos, | 505 intptr_t* end_pos, |
506 Instance* value) { | 506 Instance* value) { |
507 GetDescIndices(); | 507 GetDescIndices(); |
508 ASSERT(i < desc_indices_.length()); | 508 ASSERT(i < desc_indices_.length()); |
509 intptr_t desc_index = desc_indices_[i]; | 509 intptr_t desc_index = desc_indices_[i]; |
510 ASSERT(name != NULL); | 510 ASSERT(name != NULL); |
511 *name ^= var_descriptors_.GetName(desc_index); | 511 *name |= var_descriptors_.GetName(desc_index); |
512 RawLocalVarDescriptors::VarInfo var_info; | 512 RawLocalVarDescriptors::VarInfo var_info; |
513 var_descriptors_.GetInfo(desc_index, &var_info); | 513 var_descriptors_.GetInfo(desc_index, &var_info); |
514 ASSERT(token_pos != NULL); | 514 ASSERT(token_pos != NULL); |
515 *token_pos = var_info.begin_pos; | 515 *token_pos = var_info.begin_pos; |
516 ASSERT(end_pos != NULL); | 516 ASSERT(end_pos != NULL); |
517 *end_pos = var_info.end_pos; | 517 *end_pos = var_info.end_pos; |
518 ASSERT(value != NULL); | 518 ASSERT(value != NULL); |
519 if (var_info.kind == RawLocalVarDescriptors::kStackVar) { | 519 if (var_info.kind == RawLocalVarDescriptors::kStackVar) { |
520 *value = GetLocalVarValue(var_info.index); | 520 *value = GetLocalVarValue(var_info.index); |
521 } else { | 521 } else { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 Class& cls = Class::Handle(); | 817 Class& cls = Class::Handle(); |
818 Array& functions = Array::Handle(); | 818 Array& functions = Array::Handle(); |
819 Function& function = Function::Handle(); | 819 Function& function = Function::Handle(); |
820 intptr_t num_classes = class_table.NumCids(); | 820 intptr_t num_classes = class_table.NumCids(); |
821 for (intptr_t i = 1; i < num_classes; i++) { | 821 for (intptr_t i = 1; i < num_classes; i++) { |
822 if (class_table.HasValidClassAt(i)) { | 822 if (class_table.HasValidClassAt(i)) { |
823 cls = class_table.At(i); | 823 cls = class_table.At(i); |
824 functions = cls.functions(); | 824 functions = cls.functions(); |
825 intptr_t num_functions = functions.IsNull() ? 0 : functions.Length(); | 825 intptr_t num_functions = functions.IsNull() ? 0 : functions.Length(); |
826 for (intptr_t f = 0; f < num_functions; f++) { | 826 for (intptr_t f = 0; f < num_functions; f++) { |
827 function ^= functions.At(f); | 827 function |= functions.At(f); |
828 ASSERT(!function.IsNull()); | 828 ASSERT(!function.IsNull()); |
829 if (function.HasOptimizedCode()) { | 829 if (function.HasOptimizedCode()) { |
830 function.SwitchToUnoptimizedCode(); | 830 function.SwitchToUnoptimizedCode(); |
831 } | 831 } |
832 } | 832 } |
833 } | 833 } |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 | 837 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 } | 1135 } |
1136 | 1136 |
1137 | 1137 |
1138 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, | 1138 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, |
1139 intptr_t line_number) { | 1139 intptr_t line_number) { |
1140 Library& lib = Library::Handle(); | 1140 Library& lib = Library::Handle(); |
1141 Script& script = Script::Handle(); | 1141 Script& script = Script::Handle(); |
1142 const GrowableObjectArray& libs = | 1142 const GrowableObjectArray& libs = |
1143 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); | 1143 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); |
1144 for (int i = 0; i < libs.Length(); i++) { | 1144 for (int i = 0; i < libs.Length(); i++) { |
1145 lib ^= libs.At(i); | 1145 lib |= libs.At(i); |
1146 script = lib.LookupScript(script_url); | 1146 script = lib.LookupScript(script_url); |
1147 if (!script.IsNull()) { | 1147 if (!script.IsNull()) { |
1148 break; | 1148 break; |
1149 } | 1149 } |
1150 } | 1150 } |
1151 if (script.IsNull()) { | 1151 if (script.IsNull()) { |
1152 if (FLAG_verbose_debug) { | 1152 if (FLAG_verbose_debug) { |
1153 OS::Print("Failed to find script with url '%s'\n", | 1153 OS::Print("Failed to find script with url '%s'\n", |
1154 script_url.ToCString()); | 1154 script_url.ToCString()); |
1155 } | 1155 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 Array& fields = Array::Handle(); | 1270 Array& fields = Array::Handle(); |
1271 Field& field = Field::Handle(); | 1271 Field& field = Field::Handle(); |
1272 const GrowableObjectArray& field_list = | 1272 const GrowableObjectArray& field_list = |
1273 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1273 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
1274 String& field_name = String::Handle(); | 1274 String& field_name = String::Handle(); |
1275 Object& field_value = Object::Handle(); | 1275 Object& field_value = Object::Handle(); |
1276 // Iterate over fields in class hierarchy to count all instance fields. | 1276 // Iterate over fields in class hierarchy to count all instance fields. |
1277 while (!cls.IsNull()) { | 1277 while (!cls.IsNull()) { |
1278 fields = cls.fields(); | 1278 fields = cls.fields(); |
1279 for (int i = 0; i < fields.Length(); i++) { | 1279 for (int i = 0; i < fields.Length(); i++) { |
1280 field ^= fields.At(i); | 1280 field |= fields.At(i); |
1281 if (!field.is_static()) { | 1281 if (!field.is_static()) { |
1282 field_name = field.name(); | 1282 field_name = field.name(); |
1283 field_list.Add(field_name); | 1283 field_list.Add(field_name); |
1284 field_value = GetInstanceField(cls, field_name, obj); | 1284 field_value = GetInstanceField(cls, field_name, obj); |
1285 field_list.Add(field_value); | 1285 field_list.Add(field_value); |
1286 } | 1286 } |
1287 } | 1287 } |
1288 cls = cls.SuperClass(); | 1288 cls = cls.SuperClass(); |
1289 } | 1289 } |
1290 return Array::MakeArray(field_list); | 1290 return Array::MakeArray(field_list); |
1291 } | 1291 } |
1292 | 1292 |
1293 | 1293 |
1294 RawArray* Debugger::GetStaticFields(const Class& cls) { | 1294 RawArray* Debugger::GetStaticFields(const Class& cls) { |
1295 const GrowableObjectArray& field_list = | 1295 const GrowableObjectArray& field_list = |
1296 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1296 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
1297 Array& fields = Array::Handle(cls.fields()); | 1297 Array& fields = Array::Handle(cls.fields()); |
1298 Field& field = Field::Handle(); | 1298 Field& field = Field::Handle(); |
1299 String& field_name = String::Handle(); | 1299 String& field_name = String::Handle(); |
1300 Object& field_value = Object::Handle(); | 1300 Object& field_value = Object::Handle(); |
1301 for (int i = 0; i < fields.Length(); i++) { | 1301 for (int i = 0; i < fields.Length(); i++) { |
1302 field ^= fields.At(i); | 1302 field |= fields.At(i); |
1303 if (field.is_static()) { | 1303 if (field.is_static()) { |
1304 field_name = field.name(); | 1304 field_name = field.name(); |
1305 field_value = GetStaticField(cls, field_name); | 1305 field_value = GetStaticField(cls, field_name); |
1306 field_list.Add(field_name); | 1306 field_list.Add(field_name); |
1307 field_list.Add(field_value); | 1307 field_list.Add(field_value); |
1308 } | 1308 } |
1309 } | 1309 } |
1310 return Array::MakeArray(field_list); | 1310 return Array::MakeArray(field_list); |
1311 } | 1311 } |
1312 | 1312 |
1313 | 1313 |
1314 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, | 1314 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, |
1315 const Library& lib, | 1315 const Library& lib, |
1316 const String& prefix, | 1316 const String& prefix, |
1317 bool include_private_fields) { | 1317 bool include_private_fields) { |
1318 DictionaryIterator it(lib); | 1318 DictionaryIterator it(lib); |
1319 Object& entry = Object::Handle(isolate_); | 1319 Object& entry = Object::Handle(isolate_); |
1320 Field& field = Field::Handle(isolate_); | 1320 Field& field = Field::Handle(isolate_); |
1321 Class& cls = Class::Handle(isolate_); | 1321 Class& cls = Class::Handle(isolate_); |
1322 String& field_name = String::Handle(isolate_); | 1322 String& field_name = String::Handle(isolate_); |
1323 Object& field_value = Object::Handle(isolate_); | 1323 Object& field_value = Object::Handle(isolate_); |
1324 while (it.HasNext()) { | 1324 while (it.HasNext()) { |
1325 entry = it.GetNext(); | 1325 entry = it.GetNext(); |
1326 if (entry.IsField()) { | 1326 if (entry.IsField()) { |
1327 field ^= entry.raw(); | 1327 field |= entry.raw(); |
1328 cls = field.owner(); | 1328 cls = field.owner(); |
1329 ASSERT(field.is_static()); | 1329 ASSERT(field.is_static()); |
1330 field_name = field.name(); | 1330 field_name = field.name(); |
1331 if ((field_name.CharAt(0) == '_') && !include_private_fields) { | 1331 if ((field_name.CharAt(0) == '_') && !include_private_fields) { |
1332 // Skip library-private field. | 1332 // Skip library-private field. |
1333 continue; | 1333 continue; |
1334 } | 1334 } |
1335 field_value = GetStaticField(cls, field_name); | 1335 field_value = GetStaticField(cls, field_name); |
1336 if (!prefix.IsNull()) { | 1336 if (!prefix.IsNull()) { |
1337 field_name = String::Concat(prefix, field_name); | 1337 field_name = String::Concat(prefix, field_name); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 } | 1723 } |
1724 | 1724 |
1725 | 1725 |
1726 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1726 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
1727 ASSERT(bpt->next() == NULL); | 1727 ASSERT(bpt->next() == NULL); |
1728 bpt->set_next(code_breakpoints_); | 1728 bpt->set_next(code_breakpoints_); |
1729 code_breakpoints_ = bpt; | 1729 code_breakpoints_ = bpt; |
1730 } | 1730 } |
1731 | 1731 |
1732 } // namespace dart | 1732 } // namespace dart |
OLD | NEW |