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

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: Replaced redundant test with assertion 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 ASSERT(!code_.is_optimized());
308 context_level_ = 0; 309 context_level_ = 0;
309 intptr_t pc_desc_idx = PcDescIndex(); 310 intptr_t pc_desc_idx = PcDescIndex();
310 ASSERT(!pc_desc_.IsNull()); 311 ASSERT(!pc_desc_.IsNull());
311 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) { 312 if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) {
312 // Special case: the context chain has already been deallocated. 313 // Special case: the context chain has already been deallocated.
313 // The context level is 0. 314 // The context level is 0.
314 return context_level_; 315 return context_level_;
315 } 316 }
316 intptr_t innermost_begin_pos = 0; 317 intptr_t innermost_begin_pos = 0;
317 intptr_t activation_token_pos = TokenPos(); 318 intptr_t activation_token_pos = TokenPos();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 RawLocalVarDescriptors::VarInfo var_info; 487 RawLocalVarDescriptors::VarInfo var_info;
487 var_descriptors_.GetInfo(desc_index, &var_info); 488 var_descriptors_.GetInfo(desc_index, &var_info);
488 ASSERT(token_pos != NULL); 489 ASSERT(token_pos != NULL);
489 *token_pos = var_info.begin_pos; 490 *token_pos = var_info.begin_pos;
490 ASSERT(end_pos != NULL); 491 ASSERT(end_pos != NULL);
491 *end_pos = var_info.end_pos; 492 *end_pos = var_info.end_pos;
492 ASSERT(value != NULL); 493 ASSERT(value != NULL);
493 if (var_info.kind == RawLocalVarDescriptors::kStackVar) { 494 if (var_info.kind == RawLocalVarDescriptors::kStackVar) {
494 *value = GetLocalVarValue(var_info.index); 495 *value = GetLocalVarValue(var_info.index);
495 } else { 496 } 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); 497 ASSERT(var_info.kind == RawLocalVarDescriptors::kContextVar);
500 ASSERT(!ctx_.IsNull());
501 // The context level at the PC/token index of this activation frame. 498 // The context level at the PC/token index of this activation frame.
502 intptr_t frame_ctx_level = ContextLevel(); 499 intptr_t frame_ctx_level = ContextLevel();
500 if (ctx_.IsNull()) {
501 *value = Symbols::New("<unknown>");
502 return;
503 }
503 // The context level of the variable. 504 // The context level of the variable.
504 intptr_t var_ctx_level = var_info.scope_id; 505 intptr_t var_ctx_level = var_info.scope_id;
505 intptr_t level_diff = frame_ctx_level - var_ctx_level; 506 intptr_t level_diff = frame_ctx_level - var_ctx_level;
506 intptr_t ctx_slot = var_info.index; 507 intptr_t ctx_slot = var_info.index;
507 if (level_diff == 0) { 508 if (level_diff == 0) {
508 *value = ctx_.At(ctx_slot); 509 *value = ctx_.At(ctx_slot);
509 } else { 510 } else {
510 ASSERT(level_diff > 0); 511 ASSERT(level_diff > 0);
511 Context& ctx = Context::Handle(ctx_.raw()); 512 Context& ctx = Context::Handle(ctx_.raw());
512 while (level_diff > 0) { 513 while (level_diff > 0) {
513 ASSERT(!ctx.IsNull()); 514 ASSERT(!ctx.IsNull());
514 level_diff--; 515 level_diff--;
515 ctx = ctx.parent(); 516 ctx = ctx.parent();
516 } 517 }
517 ASSERT(!ctx.IsNull()); 518 ASSERT(!ctx.IsNull());
518 *value = ctx.At(ctx_slot); 519 *value = ctx.At(ctx_slot);
519 } */ 520 }
520 *value = Symbols::New("<unknown>");
521 } 521 }
522 } 522 }
523 523
524 524
525 RawArray* ActivationFrame::GetLocalVariables() { 525 RawArray* ActivationFrame::GetLocalVariables() {
526 GetDescIndices(); 526 GetDescIndices();
527 intptr_t num_variables = desc_indices_.length(); 527 intptr_t num_variables = desc_indices_.length();
528 String& var_name = String::Handle(); 528 String& var_name = String::Handle();
529 Instance& value = Instance::Handle(); 529 Instance& value = Instance::Handle();
530 const Array& list = Array::Handle(Array::New(2 * num_variables)); 530 const Array& list = Array::Handle(Array::New(2 * num_variables));
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 870
871 871
872 DebuggerStackTrace* Debugger::CollectStackTrace() { 872 DebuggerStackTrace* Debugger::CollectStackTrace() {
873 Isolate* isolate = Isolate::Current(); 873 Isolate* isolate = Isolate::Current();
874 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); 874 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
875 Context& ctx = Context::Handle(isolate->top_context()); 875 Context& ctx = Context::Handle(isolate->top_context());
876 Code& code = Code::Handle(isolate); 876 Code& code = Code::Handle(isolate);
877 StackFrameIterator iterator(false); 877 StackFrameIterator iterator(false);
878 StackFrame* frame = iterator.NextFrame(); 878 StackFrame* frame = iterator.NextFrame();
879 bool get_saved_context = false; 879 bool get_saved_context = false;
880 bool optimized_frame_found = false;
880 while (frame != NULL) { 881 while (frame != NULL) {
881 ASSERT(frame->IsValid()); 882 ASSERT(frame->IsValid());
882 if (frame->IsDartFrame()) { 883 if (frame->IsDartFrame()) {
883 code = frame->LookupDartCode(); 884 code = frame->LookupDartCode();
884 ActivationFrame* activation = new ActivationFrame(frame->pc(), 885 ActivationFrame* activation = new ActivationFrame(frame->pc(),
885 frame->fp(), 886 frame->fp(),
886 frame->sp(), 887 frame->sp(),
887 code); 888 code);
888 if (get_saved_context && !activation->code().is_optimized()) { 889 if (optimized_frame_found || code.is_optimized()) {
889 ctx = activation->GetSavedContext(); 890 // Set context to null, to avoid returning bad context variable values.
891 activation->SetContext(Context::Handle());
892 optimized_frame_found = true;
893 } else {
894 if (get_saved_context) {
895 ctx = activation->GetSavedContext();
896 }
897 activation->SetContext(ctx);
890 } 898 }
891 activation->SetContext(ctx);
892 stack_trace->AddActivation(activation); 899 stack_trace->AddActivation(activation);
893 get_saved_context = activation->function().IsClosureFunction(); 900 get_saved_context = activation->function().IsClosureFunction();
894 } else if (frame->IsEntryFrame()) { 901 } else if (frame->IsEntryFrame()) {
895 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); 902 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext();
896 get_saved_context = false; 903 get_saved_context = false;
897 } 904 }
898 frame = iterator.NextFrame(); 905 frame = iterator.NextFrame();
899 } 906 }
900 return stack_trace; 907 return stack_trace;
901 } 908 }
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 } 1741 }
1735 1742
1736 1743
1737 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1744 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1738 ASSERT(bpt->next() == NULL); 1745 ASSERT(bpt->next() == NULL);
1739 bpt->set_next(code_breakpoints_); 1746 bpt->set_next(code_breakpoints_);
1740 code_breakpoints_ = bpt; 1747 code_breakpoints_ = bpt;
1741 } 1748 }
1742 1749
1743 } // namespace dart 1750 } // 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