Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Side by Side Diff: runtime/vm/debugger.cc

Issue 10657048: Debugger support to display global variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 168
169 RawScript* ActivationFrame::SourceScript() { 169 RawScript* ActivationFrame::SourceScript() {
170 const Function& func = DartFunction(); 170 const Function& func = DartFunction();
171 const Class& cls = Class::Handle(func.owner()); 171 const Class& cls = Class::Handle(func.owner());
172 return cls.script(); 172 return cls.script();
173 } 173 }
174 174
175 175
176 RawLibrary* ActivationFrame::Library() {
177 const Function& func = DartFunction();
178 const Class& cls = Class::Handle(func.owner());
179 return cls.library();
180 }
181
182
176 void ActivationFrame::GetPcDescriptors() { 183 void ActivationFrame::GetPcDescriptors() {
177 if (pc_desc_.IsNull()) { 184 if (pc_desc_.IsNull()) {
178 const Function& func = DartFunction(); 185 const Function& func = DartFunction();
179 ASSERT(!func.HasOptimizedCode()); 186 ASSERT(!func.HasOptimizedCode());
180 Code& code = Code::Handle(func.unoptimized_code()); 187 Code& code = Code::Handle(func.unoptimized_code());
181 ASSERT(!code.IsNull()); 188 ASSERT(!code.IsNull());
182 pc_desc_ = code.pc_descriptors(); 189 pc_desc_ = code.pc_descriptors();
183 ASSERT(!pc_desc_.IsNull()); 190 ASSERT(!pc_desc_.IsNull());
184 } 191 }
185 } 192 }
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 field_name = field.name(); 1101 field_name = field.name();
1095 field_value = GetStaticField(cls, field_name); 1102 field_value = GetStaticField(cls, field_name);
1096 field_list.Add(field_name); 1103 field_list.Add(field_name);
1097 field_list.Add(field_value); 1104 field_list.Add(field_value);
1098 } 1105 }
1099 } 1106 }
1100 return Array::MakeArray(field_list); 1107 return Array::MakeArray(field_list);
1101 } 1108 }
1102 1109
1103 1110
1104 RawArray* Debugger::GetLibraryFields(const Library& lib) { 1111 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list,
1105 const GrowableObjectArray& field_list = 1112 const Library& lib,
1106 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); 1113 const String& prefix) {
1107 DictionaryIterator it(lib); 1114 DictionaryIterator it(lib);
1108 Object& entry = Object::Handle(); 1115 Object& entry = Object::Handle(isolate_);
srdjan 2012/06/26 17:08:26 Why all this isolates_ passing? Is there a perform
hausner 2012/06/26 17:32:12 As discussed offline, it has a tiny impact on perf
1109 Field& field = Field::Handle(); 1116 Field& field = Field::Handle(isolate_);
1110 Class& cls = Class::Handle(); 1117 Class& cls = Class::Handle(isolate_);
1111 String& field_name = String::Handle(); 1118 String& field_name = String::Handle(isolate_);
1112 Object& field_value = Object::Handle(); 1119 Object& field_value = Object::Handle(isolate_);
1113 while (it.HasNext()) { 1120 while (it.HasNext()) {
1114 entry = it.GetNext(); 1121 entry = it.GetNext();
1115 if (entry.IsField()) { 1122 if (entry.IsField()) {
1116 field ^= entry.raw(); 1123 field ^= entry.raw();
1117 cls = field.owner(); 1124 cls = field.owner();
1118 ASSERT(field.is_static()); 1125 ASSERT(field.is_static());
1119 field_name = field.name(); 1126 field_name = field.name();
1120 field_value = GetStaticField(cls, field_name); 1127 field_value = GetStaticField(cls, field_name);
1128 if (!prefix.IsNull()) {
1129 field_name = String::Concat(prefix, field_name);
1130 }
1121 field_list.Add(field_name); 1131 field_list.Add(field_name);
1122 field_list.Add(field_value); 1132 field_list.Add(field_value);
1123 } 1133 }
1124 } 1134 }
1135 }
1136
1137
1138 RawArray* Debugger::GetLibraryFields(const Library& lib) {
1139 const GrowableObjectArray& field_list =
1140 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
1141 CollectLibraryFields(field_list, lib, String::Handle(isolate_));
1142 return Array::MakeArray(field_list);
1143 }
1144
1145
1146 RawArray* Debugger::GetGlobalFields(const Library& lib) {
1147 const GrowableObjectArray& field_list =
1148 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
srdjan 2012/06/26 17:08:26 Why 8? Maybe better to not pass the length if you
hausner 2012/06/26 17:32:12 No particular reason. It just eliminates the first
1149 String& prefix_name = String::Handle(isolate_);
1150 CollectLibraryFields(field_list, lib, prefix_name);
1151 Library& imported = Library::Handle(isolate_);
1152 intptr_t num_imports = lib.num_imports();
1153 for (int i = 0; i < num_imports; i++) {
1154 imported = lib.ImportAt(i);
1155 ASSERT(!imported.IsNull());
1156 CollectLibraryFields(field_list, imported, prefix_name);
1157 }
1158 LibraryPrefix& prefix = LibraryPrefix::Handle(isolate_);
1159 LibraryPrefixIterator it(lib);
1160 while (it.HasNext()) {
1161 prefix = it.GetNext();
1162 prefix_name = prefix.name();
1163 ASSERT(!prefix_name.IsNull());
1164 prefix_name = String::Concat(prefix_name,
1165 String::Handle(isolate_, String::New(".")));
1166 for (int i = 0; i < prefix.num_libs(); i++) {
1167 imported = prefix.GetLibrary(i);
1168 CollectLibraryFields(field_list, imported, prefix_name);
1169 }
1170 }
1125 return Array::MakeArray(field_list); 1171 return Array::MakeArray(field_list);
1126 } 1172 }
1127 1173
1128 1174
1129 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { 1175 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) {
1130 ASSERT(visitor != NULL); 1176 ASSERT(visitor != NULL);
1131 SourceBreakpoint* bpt = src_breakpoints_; 1177 SourceBreakpoint* bpt = src_breakpoints_;
1132 while (bpt != NULL) { 1178 while (bpt != NULL) {
1133 bpt->VisitObjectPointers(visitor); 1179 bpt->VisitObjectPointers(visitor);
1134 bpt = bpt->next(); 1180 bpt = bpt->next();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 } 1517 }
1472 1518
1473 1519
1474 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1520 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1475 ASSERT(bpt->next() == NULL); 1521 ASSERT(bpt->next() == NULL);
1476 bpt->set_next(code_breakpoints_); 1522 bpt->set_next(code_breakpoints_);
1477 code_breakpoints_ = bpt; 1523 code_breakpoints_ = bpt;
1478 } 1524 }
1479 1525
1480 } // namespace dart 1526 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698