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

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

Issue 11776007: Handle optimized code blocks in debugger stack trace (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « runtime/vm/debugger.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { 132 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) {
133 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); 133 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_));
134 } 134 }
135 135
136 136
137 ActivationFrame::ActivationFrame(uword pc, uword fp, uword sp, 137 ActivationFrame::ActivationFrame(uword pc, uword fp, uword sp,
138 const Context& ctx) 138 const Context& ctx)
139 : pc_(pc), fp_(fp), sp_(sp), 139 : pc_(pc), fp_(fp), sp_(sp),
140 ctx_(Context::ZoneHandle(ctx.raw())), 140 ctx_(Context::ZoneHandle(ctx.raw())),
141 function_(Function::ZoneHandle()), 141 function_(Function::ZoneHandle()),
142 code_(Code::ZoneHandle()),
142 token_pos_(-1), 143 token_pos_(-1),
143 pc_desc_index_(-1), 144 pc_desc_index_(-1),
144 line_number_(-1), 145 line_number_(-1),
145 context_level_(-1), 146 context_level_(-1),
146 vars_initialized_(false), 147 vars_initialized_(false),
147 var_descriptors_(LocalVarDescriptors::ZoneHandle()), 148 var_descriptors_(LocalVarDescriptors::ZoneHandle()),
148 desc_indices_(8), 149 desc_indices_(8),
149 pc_desc_(PcDescriptors::ZoneHandle()) { 150 pc_desc_(PcDescriptors::ZoneHandle()) {
150 } 151 }
151 152
152 153
154 const Code& ActivationFrame::DartCode() {
155 if (code_.IsNull()) {
156 Isolate* isolate = Isolate::Current();
157 ASSERT(isolate != NULL);
158 code_ = Code::LookupCode(pc_);
159 }
160 return code_;
161 }
162
163
153 const Function& ActivationFrame::DartFunction() { 164 const Function& ActivationFrame::DartFunction() {
154 if (function_.IsNull()) { 165 if (function_.IsNull()) {
155 Isolate* isolate = Isolate::Current(); 166 function_ = DartCode().function();
srdjan 2013/01/04 22:50:15 Why cache the function at all?
hausner 2013/01/05 00:46:06 It is used in a few locations. May save a few hand
156 ASSERT(isolate != NULL);
157 const Code& code = Code::Handle(Code::LookupCode(pc_));
158 function_ = code.function();
159 } 167 }
160 return function_; 168 return function_;
161 } 169 }
162 170
163 171
164 void Debugger::SignalIsolateEvent(EventType type) { 172 void Debugger::SignalIsolateEvent(EventType type) {
165 if (event_handler_ != NULL) { 173 if (event_handler_ != NULL) {
166 Debugger* debugger = Isolate::Current()->debugger(); 174 Debugger* debugger = Isolate::Current()->debugger();
167 ASSERT(debugger != NULL); 175 ASSERT(debugger != NULL);
168 DebuggerEvent event; 176 DebuggerEvent event;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 236
229 RawLibrary* ActivationFrame::Library() { 237 RawLibrary* ActivationFrame::Library() {
230 const Function& func = DartFunction(); 238 const Function& func = DartFunction();
231 const Class& cls = Class::Handle(func.Owner()); 239 const Class& cls = Class::Handle(func.Owner());
232 return cls.library(); 240 return cls.library();
233 } 241 }
234 242
235 243
236 void ActivationFrame::GetPcDescriptors() { 244 void ActivationFrame::GetPcDescriptors() {
237 if (pc_desc_.IsNull()) { 245 if (pc_desc_.IsNull()) {
238 const Function& func = DartFunction(); 246 const Code& code = DartCode();
239 ASSERT(!func.HasOptimizedCode());
240 Code& code = Code::Handle(func.unoptimized_code());
241 ASSERT(!code.IsNull()); 247 ASSERT(!code.IsNull());
242 pc_desc_ = code.pc_descriptors(); 248 pc_desc_ = code.pc_descriptors();
243 ASSERT(!pc_desc_.IsNull()); 249 ASSERT(!pc_desc_.IsNull());
244 } 250 }
245 } 251 }
246 252
247 253
248 // Compute token_pos_ and pc_desc_index_. 254 // Compute token_pos_ and pc_desc_index_.
249 intptr_t ActivationFrame::TokenPos() { 255 intptr_t ActivationFrame::TokenPos() {
250 if (token_pos_ < 0) { 256 if (token_pos_ < 0) {
(...skipping 25 matching lines...) Expand all
276 if (line_number_ < 0) { 282 if (line_number_ < 0) {
277 const Script& script = Script::Handle(SourceScript()); 283 const Script& script = Script::Handle(SourceScript());
278 intptr_t ignore_column; 284 intptr_t ignore_column;
279 script.GetTokenLocation(TokenPos(), &line_number_, &ignore_column); 285 script.GetTokenLocation(TokenPos(), &line_number_, &ignore_column);
280 } 286 }
281 return line_number_; 287 return line_number_;
282 } 288 }
283 289
284 290
285 void ActivationFrame::GetVarDescriptors() { 291 void ActivationFrame::GetVarDescriptors() {
286 if (!var_descriptors_.IsNull()) { 292 if (var_descriptors_.IsNull()) {
287 return; 293 const Code& code = DartCode();
294 var_descriptors_ = code.var_descriptors();
295 ASSERT(!var_descriptors_.IsNull());
288 } 296 }
289 ASSERT(!DartFunction().HasOptimizedCode());
290 const Code& code = Code::Handle(DartFunction().unoptimized_code());
291 var_descriptors_ = code.var_descriptors();
292 ASSERT(!var_descriptors_.IsNull());
293 } 297 }
294 298
295 299
296 // Calculate the context level at the current token index of the frame. 300 // Calculate the context level at the current token index of the frame.
297 intptr_t ActivationFrame::ContextLevel() { 301 intptr_t ActivationFrame::ContextLevel() {
298 if (context_level_ < 0) { 302 if (context_level_ < 0) {
299 context_level_ = 0; 303 context_level_ = 0;
300 intptr_t pc_desc_idx = PcDescIndex(); 304 intptr_t pc_desc_idx = PcDescIndex();
301 ASSERT(!pc_desc_.IsNull()); 305 ASSERT(!pc_desc_.IsNull());
302 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) { 306 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) {
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 } 1644 }
1641 1645
1642 1646
1643 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1647 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1644 ASSERT(bpt->next() == NULL); 1648 ASSERT(bpt->next() == NULL);
1645 bpt->set_next(code_breakpoints_); 1649 bpt->set_next(code_breakpoints_);
1646 code_breakpoints_ = bpt; 1650 code_breakpoints_ = bpt;
1647 } 1651 }
1648 1652
1649 } // namespace dart 1653 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698