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

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

Issue 14503003: Fix context-allocated variables in stack traces (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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') | runtime/vm/scopes.cc » ('j') | 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 context_level_ = var_info.index; 332 context_level_ = var_info.index;
333 } 333 }
334 } 334 }
335 } 335 }
336 ASSERT(context_level_ >= 0); 336 ASSERT(context_level_ >= 0);
337 } 337 }
338 return context_level_; 338 return context_level_;
339 } 339 }
340 340
341 341
342 RawContext* ActivationFrame::GetSavedContext() { 342 RawContext* ActivationFrame::GetSavedContext(const Context& ctx) {
343 GetVarDescriptors(); 343 GetVarDescriptors();
344 intptr_t var_desc_len = var_descriptors_.Length(); 344 intptr_t var_desc_len = var_descriptors_.Length();
345 for (int i = 0; i < var_desc_len; i++) { 345 for (int i = 0; i < var_desc_len; i++) {
346 RawLocalVarDescriptors::VarInfo var_info; 346 RawLocalVarDescriptors::VarInfo var_info;
347 var_descriptors_.GetInfo(i, &var_info); 347 var_descriptors_.GetInfo(i, &var_info);
348 if (var_info.kind == RawLocalVarDescriptors::kContextChain) { 348 if (var_info.kind == RawLocalVarDescriptors::kContextChain) {
349 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index)); 349 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index));
350 } 350 }
351 } 351 }
352 UNREACHABLE(); 352 return ctx.raw();
353 return Context::null();
354 } 353 }
355 354
356 355
357 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( 356 ActivationFrame* DebuggerStackTrace::GetHandlerFrame(
358 const Instance& exc_obj) const { 357 const Instance& exc_obj) const {
359 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); 358 ExceptionHandlers& handlers = ExceptionHandlers::Handle();
360 Array& handled_types = Array::Handle(); 359 Array& handled_types = Array::Handle();
361 AbstractType& type = Type::Handle(); 360 AbstractType& type = Type::Handle();
362 const TypeArguments& no_instantiator = TypeArguments::Handle(); 361 const TypeArguments& no_instantiator = TypeArguments::Handle();
363 for (int frame_index = 0; frame_index < Length(); frame_index++) { 362 for (int frame_index = 0; frame_index < Length(); frame_index++) {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } 875 }
877 876
878 877
879 DebuggerStackTrace* Debugger::CollectStackTrace() { 878 DebuggerStackTrace* Debugger::CollectStackTrace() {
880 Isolate* isolate = Isolate::Current(); 879 Isolate* isolate = Isolate::Current();
881 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); 880 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
882 Context& ctx = Context::Handle(isolate->top_context()); 881 Context& ctx = Context::Handle(isolate->top_context());
883 Code& code = Code::Handle(isolate); 882 Code& code = Code::Handle(isolate);
884 StackFrameIterator iterator(false); 883 StackFrameIterator iterator(false);
885 StackFrame* frame = iterator.NextFrame(); 884 StackFrame* frame = iterator.NextFrame();
886 bool get_saved_context = false;
887 bool optimized_frame_found = false; 885 bool optimized_frame_found = false;
888 while (frame != NULL) { 886 while (frame != NULL) {
889 ASSERT(frame->IsValid()); 887 ASSERT(frame->IsValid());
890 if (frame->IsDartFrame()) { 888 if (frame->IsDartFrame()) {
891 code = frame->LookupDartCode(); 889 code = frame->LookupDartCode();
892 ActivationFrame* activation = new ActivationFrame(frame->pc(), 890 ActivationFrame* activation = new ActivationFrame(frame->pc(),
893 frame->fp(), 891 frame->fp(),
894 frame->sp(), 892 frame->sp(),
895 code); 893 code);
896 if (optimized_frame_found || code.is_optimized()) { 894 if (optimized_frame_found || code.is_optimized()) {
897 // Set context to null, to avoid returning bad context variable values. 895 // Set context to null, to avoid returning bad context variable values.
898 activation->SetContext(Context::Handle()); 896 activation->SetContext(Context::Handle());
899 optimized_frame_found = true; 897 optimized_frame_found = true;
900 } else { 898 } else {
901 if (get_saved_context) {
902 ctx = activation->GetSavedContext();
903 }
904 activation->SetContext(ctx); 899 activation->SetContext(ctx);
900 ctx = activation->GetSavedContext(ctx);
905 } 901 }
906 stack_trace->AddActivation(activation); 902 stack_trace->AddActivation(activation);
907 get_saved_context = activation->function().IsClosureFunction();
908 } else if (frame->IsEntryFrame()) { 903 } else if (frame->IsEntryFrame()) {
909 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); 904 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext();
910 get_saved_context = false;
911 } 905 }
912 frame = iterator.NextFrame(); 906 frame = iterator.NextFrame();
913 } 907 }
914 return stack_trace; 908 return stack_trace;
915 } 909 }
916 910
917 911
918 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { 912 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
919 ASSERT((pause_info == kNoPauseOnExceptions) || 913 ASSERT((pause_info == kNoPauseOnExceptions) ||
920 (pause_info == kPauseOnUnhandledExceptions) || 914 (pause_info == kPauseOnUnhandledExceptions) ||
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 } 1739 }
1746 1740
1747 1741
1748 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1742 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1749 ASSERT(bpt->next() == NULL); 1743 ASSERT(bpt->next() == NULL);
1750 bpt->set_next(code_breakpoints_); 1744 bpt->set_next(code_breakpoints_);
1751 code_breakpoints_ = bpt; 1745 code_breakpoints_ = bpt;
1752 } 1746 }
1753 1747
1754 } // namespace dart 1748 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698