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

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

Issue 12408015: Disable stack context when its frame is for optimized code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « no previous file | 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void ActivationFrame::GetVarDescriptors() { 297 void ActivationFrame::GetVarDescriptors() {
298 if (var_descriptors_.IsNull()) { 298 if (var_descriptors_.IsNull()) {
299 var_descriptors_ = code().var_descriptors(); 299 var_descriptors_ = code().var_descriptors();
300 ASSERT(!var_descriptors_.IsNull()); 300 ASSERT(!var_descriptors_.IsNull());
301 } 301 }
302 } 302 }
303 303
304 304
305 // Calculate the context level at the current token index of the frame. 305 // Calculate the context level at the current token index of the frame.
306 intptr_t ActivationFrame::ContextLevel() { 306 intptr_t ActivationFrame::ContextLevel() {
307 if (context_level_ < 0) { 307 if (context_level_ < 0 && !ctx_.IsNull()) {
308 if (code_.is_optimized()) {
309 // Set context to null, since this and all subsequent frames are
310 // invalid.
311 SetContext(Context::Handle());
312 return context_level_;
313 }
308 context_level_ = 0; 314 context_level_ = 0;
309 intptr_t pc_desc_idx = PcDescIndex(); 315 intptr_t pc_desc_idx = PcDescIndex();
310 ASSERT(!pc_desc_.IsNull()); 316 ASSERT(!pc_desc_.IsNull());
311 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) { 317 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) {
312 // Special case: the context chain has already been deallocated. 318 // Special case: the context chain has already been deallocated.
313 // The context level is 0. 319 // The context level is 0.
314 return context_level_; 320 return context_level_;
315 } 321 }
316 intptr_t innermost_begin_pos = 0; 322 intptr_t innermost_begin_pos = 0;
317 intptr_t activation_token_pos = TokenPos(); 323 intptr_t activation_token_pos = TokenPos();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 RawLocalVarDescriptors::VarInfo var_info; 492 RawLocalVarDescriptors::VarInfo var_info;
487 var_descriptors_.GetInfo(desc_index, &var_info); 493 var_descriptors_.GetInfo(desc_index, &var_info);
488 ASSERT(token_pos != NULL); 494 ASSERT(token_pos != NULL);
489 *token_pos = var_info.begin_pos; 495 *token_pos = var_info.begin_pos;
490 ASSERT(end_pos != NULL); 496 ASSERT(end_pos != NULL);
491 *end_pos = var_info.end_pos; 497 *end_pos = var_info.end_pos;
492 ASSERT(value != NULL); 498 ASSERT(value != NULL);
493 if (var_info.kind == RawLocalVarDescriptors::kStackVar) { 499 if (var_info.kind == RawLocalVarDescriptors::kStackVar) {
494 *value = GetLocalVarValue(var_info.index); 500 *value = GetLocalVarValue(var_info.index);
495 } else { 501 } else {
496 // TODO(tball): enable context variables once problem with VariableAt() is
497 // fixed, where frame_ctx_level is sometimes off by 1 (issues 8593 and 8594)
498 /*
499 ASSERT(var_info.kind == RawLocalVarDescriptors::kContextVar); 502 ASSERT(var_info.kind == RawLocalVarDescriptors::kContextVar);
500 ASSERT(!ctx_.IsNull());
501 // The context level at the PC/token index of this activation frame. 503 // The context level at the PC/token index of this activation frame.
502 intptr_t frame_ctx_level = ContextLevel(); 504 intptr_t frame_ctx_level = ContextLevel();
505 if (ctx_.IsNull()) {
506 *value = Symbols::New("<unknown>");
507 return;
508 }
503 // The context level of the variable. 509 // The context level of the variable.
504 intptr_t var_ctx_level = var_info.scope_id; 510 intptr_t var_ctx_level = var_info.scope_id;
505 intptr_t level_diff = frame_ctx_level - var_ctx_level; 511 intptr_t level_diff = frame_ctx_level - var_ctx_level;
506 intptr_t ctx_slot = var_info.index; 512 intptr_t ctx_slot = var_info.index;
507 if (level_diff == 0) { 513 if (level_diff == 0) {
508 *value = ctx_.At(ctx_slot); 514 *value = ctx_.At(ctx_slot);
509 } else { 515 } else {
510 ASSERT(level_diff > 0); 516 ASSERT(level_diff > 0);
511 Context& ctx = Context::Handle(ctx_.raw()); 517 Context& ctx = Context::Handle(ctx_.raw());
512 while (level_diff > 0) { 518 while (level_diff > 0) {
513 ASSERT(!ctx.IsNull()); 519 ASSERT(!ctx.IsNull());
514 level_diff--; 520 level_diff--;
515 ctx = ctx.parent(); 521 ctx = ctx.parent();
516 } 522 }
517 ASSERT(!ctx.IsNull()); 523 ASSERT(!ctx.IsNull());
518 *value = ctx.At(ctx_slot); 524 *value = ctx.At(ctx_slot);
519 } */ 525 }
520 *value = Symbols::New("<unknown>");
521 } 526 }
522 } 527 }
523 528
524 529
525 RawArray* ActivationFrame::GetLocalVariables() { 530 RawArray* ActivationFrame::GetLocalVariables() {
526 GetDescIndices(); 531 GetDescIndices();
527 intptr_t num_variables = desc_indices_.length(); 532 intptr_t num_variables = desc_indices_.length();
528 String& var_name = String::Handle(); 533 String& var_name = String::Handle();
529 Instance& value = Instance::Handle(); 534 Instance& value = Instance::Handle();
530 const Array& list = Array::Handle(Array::New(2 * num_variables)); 535 const Array& list = Array::Handle(Array::New(2 * num_variables));
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 while (frame != NULL) { 885 while (frame != NULL) {
881 ASSERT(frame->IsValid()); 886 ASSERT(frame->IsValid());
882 if (frame->IsDartFrame()) { 887 if (frame->IsDartFrame()) {
883 code = frame->LookupDartCode(); 888 code = frame->LookupDartCode();
884 ActivationFrame* activation = new ActivationFrame(frame->pc(), 889 ActivationFrame* activation = new ActivationFrame(frame->pc(),
885 frame->fp(), 890 frame->fp(),
886 frame->sp(), 891 frame->sp(),
887 code); 892 code);
888 if (get_saved_context && !activation->code().is_optimized()) { 893 if (get_saved_context && !activation->code().is_optimized()) {
889 ctx = activation->GetSavedContext(); 894 ctx = activation->GetSavedContext();
890 } 895 }
Ivan Posva 2013/03/12 16:31:25 What I am concerned about is this scenario: Trave
891 activation->SetContext(ctx); 896 activation->SetContext(ctx);
892 stack_trace->AddActivation(activation); 897 stack_trace->AddActivation(activation);
893 get_saved_context = activation->function().IsClosureFunction(); 898 get_saved_context = activation->function().IsClosureFunction();
894 } else if (frame->IsEntryFrame()) { 899 } else if (frame->IsEntryFrame()) {
895 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); 900 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext();
896 get_saved_context = false; 901 get_saved_context = false;
897 } 902 }
898 frame = iterator.NextFrame(); 903 frame = iterator.NextFrame();
899 } 904 }
900 return stack_trace; 905 return stack_trace;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 } 1739 }
1735 1740
1736 1741
1737 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1742 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1738 ASSERT(bpt->next() == NULL); 1743 ASSERT(bpt->next() == NULL);
1739 bpt->set_next(code_breakpoints_); 1744 bpt->set_next(code_breakpoints_);
1740 code_breakpoints_ = bpt; 1745 code_breakpoints_ = bpt;
1741 } 1746 }
1742 1747
1743 } // namespace dart 1748 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698