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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 } | 1140 } |
1141 | 1141 |
1142 | 1142 |
1143 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, | 1143 SourceBreakpoint* Debugger::SetBreakpointAtLine(const String& script_url, |
1144 intptr_t line_number) { | 1144 intptr_t line_number) { |
1145 Library& lib = Library::Handle(); | 1145 Library& lib = Library::Handle(); |
1146 Script& script = Script::Handle(); | 1146 Script& script = Script::Handle(); |
1147 const GrowableObjectArray& libs = | 1147 const GrowableObjectArray& libs = |
1148 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); | 1148 GrowableObjectArray::Handle(isolate_->object_store()->libraries()); |
1149 for (int i = 0; i < libs.Length(); i++) { | 1149 for (int i = 0; i < libs.Length(); i++) { |
1150 lib |= libs.At(i); | 1150 lib ^= libs.At(i); |
1151 script = lib.LookupScript(script_url); | 1151 script = lib.LookupScript(script_url); |
1152 if (!script.IsNull()) { | 1152 if (!script.IsNull()) { |
1153 break; | 1153 break; |
1154 } | 1154 } |
1155 } | 1155 } |
1156 if (script.IsNull()) { | 1156 if (script.IsNull()) { |
1157 if (FLAG_verbose_debug) { | 1157 if (FLAG_verbose_debug) { |
1158 OS::Print("Failed to find script with url '%s'\n", | 1158 OS::Print("Failed to find script with url '%s'\n", |
1159 script_url.ToCString()); | 1159 script_url.ToCString()); |
1160 } | 1160 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 Array& fields = Array::Handle(); | 1275 Array& fields = Array::Handle(); |
1276 Field& field = Field::Handle(); | 1276 Field& field = Field::Handle(); |
1277 const GrowableObjectArray& field_list = | 1277 const GrowableObjectArray& field_list = |
1278 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1278 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
1279 String& field_name = String::Handle(); | 1279 String& field_name = String::Handle(); |
1280 Object& field_value = Object::Handle(); | 1280 Object& field_value = Object::Handle(); |
1281 // Iterate over fields in class hierarchy to count all instance fields. | 1281 // Iterate over fields in class hierarchy to count all instance fields. |
1282 while (!cls.IsNull()) { | 1282 while (!cls.IsNull()) { |
1283 fields = cls.fields(); | 1283 fields = cls.fields(); |
1284 for (int i = 0; i < fields.Length(); i++) { | 1284 for (int i = 0; i < fields.Length(); i++) { |
1285 field |= fields.At(i); | 1285 field ^= fields.At(i); |
1286 if (!field.is_static()) { | 1286 if (!field.is_static()) { |
1287 field_name = field.name(); | 1287 field_name = field.name(); |
1288 field_list.Add(field_name); | 1288 field_list.Add(field_name); |
1289 field_value = GetInstanceField(cls, field_name, obj); | 1289 field_value = GetInstanceField(cls, field_name, obj); |
1290 field_list.Add(field_value); | 1290 field_list.Add(field_value); |
1291 } | 1291 } |
1292 } | 1292 } |
1293 cls = cls.SuperClass(); | 1293 cls = cls.SuperClass(); |
1294 } | 1294 } |
1295 return Array::MakeArray(field_list); | 1295 return Array::MakeArray(field_list); |
1296 } | 1296 } |
1297 | 1297 |
1298 | 1298 |
1299 RawArray* Debugger::GetStaticFields(const Class& cls) { | 1299 RawArray* Debugger::GetStaticFields(const Class& cls) { |
1300 const GrowableObjectArray& field_list = | 1300 const GrowableObjectArray& field_list = |
1301 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 1301 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
1302 Array& fields = Array::Handle(cls.fields()); | 1302 Array& fields = Array::Handle(cls.fields()); |
1303 Field& field = Field::Handle(); | 1303 Field& field = Field::Handle(); |
1304 String& field_name = String::Handle(); | 1304 String& field_name = String::Handle(); |
1305 Object& field_value = Object::Handle(); | 1305 Object& field_value = Object::Handle(); |
1306 for (int i = 0; i < fields.Length(); i++) { | 1306 for (int i = 0; i < fields.Length(); i++) { |
1307 field |= fields.At(i); | 1307 field ^= fields.At(i); |
1308 if (field.is_static()) { | 1308 if (field.is_static()) { |
1309 field_name = field.name(); | 1309 field_name = field.name(); |
1310 field_value = GetStaticField(cls, field_name); | 1310 field_value = GetStaticField(cls, field_name); |
1311 field_list.Add(field_name); | 1311 field_list.Add(field_name); |
1312 field_list.Add(field_value); | 1312 field_list.Add(field_value); |
1313 } | 1313 } |
1314 } | 1314 } |
1315 return Array::MakeArray(field_list); | 1315 return Array::MakeArray(field_list); |
1316 } | 1316 } |
1317 | 1317 |
1318 | 1318 |
1319 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, | 1319 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, |
1320 const Library& lib, | 1320 const Library& lib, |
1321 const String& prefix, | 1321 const String& prefix, |
1322 bool include_private_fields) { | 1322 bool include_private_fields) { |
1323 DictionaryIterator it(lib); | 1323 DictionaryIterator it(lib); |
1324 Object& entry = Object::Handle(isolate_); | 1324 Object& entry = Object::Handle(isolate_); |
1325 Field& field = Field::Handle(isolate_); | 1325 Field& field = Field::Handle(isolate_); |
1326 Class& cls = Class::Handle(isolate_); | 1326 Class& cls = Class::Handle(isolate_); |
1327 String& field_name = String::Handle(isolate_); | 1327 String& field_name = String::Handle(isolate_); |
1328 Object& field_value = Object::Handle(isolate_); | 1328 Object& field_value = Object::Handle(isolate_); |
1329 while (it.HasNext()) { | 1329 while (it.HasNext()) { |
1330 entry = it.GetNext(); | 1330 entry = it.GetNext(); |
1331 if (entry.IsField()) { | 1331 if (entry.IsField()) { |
1332 field |= entry.raw(); | 1332 field ^= entry.raw(); |
1333 cls = field.owner(); | 1333 cls = field.owner(); |
1334 ASSERT(field.is_static()); | 1334 ASSERT(field.is_static()); |
1335 field_name = field.name(); | 1335 field_name = field.name(); |
1336 if ((field_name.CharAt(0) == '_') && !include_private_fields) { | 1336 if ((field_name.CharAt(0) == '_') && !include_private_fields) { |
1337 // Skip library-private field. | 1337 // Skip library-private field. |
1338 continue; | 1338 continue; |
1339 } | 1339 } |
1340 field_value = GetStaticField(cls, field_name); | 1340 field_value = GetStaticField(cls, field_name); |
1341 if (!prefix.IsNull()) { | 1341 if (!prefix.IsNull()) { |
1342 field_name = String::Concat(prefix, field_name); | 1342 field_name = String::Concat(prefix, field_name); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 } | 1728 } |
1729 | 1729 |
1730 | 1730 |
1731 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1731 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
1732 ASSERT(bpt->next() == NULL); | 1732 ASSERT(bpt->next() == NULL); |
1733 bpt->set_next(code_breakpoints_); | 1733 bpt->set_next(code_breakpoints_); |
1734 code_breakpoints_ = bpt; | 1734 code_breakpoints_ = bpt; |
1735 } | 1735 } |
1736 | 1736 |
1737 } // namespace dart | 1737 } // namespace dart |
OLD | NEW |