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

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

Issue 14449009: Another fix for debugging stack traces and captured variables. (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/raw_object.h » ('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(const Context& ctx) { 342 // Get the caller's context, or return ctx if the function does not
343 // save the caller's context on entry.
344 RawContext* ActivationFrame::GetSavedEntryContext(const Context& ctx) {
343 GetVarDescriptors(); 345 GetVarDescriptors();
344 intptr_t var_desc_len = var_descriptors_.Length(); 346 intptr_t var_desc_len = var_descriptors_.Length();
345 for (int i = 0; i < var_desc_len; i++) { 347 for (int i = 0; i < var_desc_len; i++) {
346 RawLocalVarDescriptors::VarInfo var_info; 348 RawLocalVarDescriptors::VarInfo var_info;
347 var_descriptors_.GetInfo(i, &var_info); 349 var_descriptors_.GetInfo(i, &var_info);
348 if (var_info.kind == RawLocalVarDescriptors::kContextChain) { 350 if (var_info.kind == RawLocalVarDescriptors::kSavedEntryContext) {
349 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index)); 351 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index));
350 } 352 }
351 } 353 }
352 return ctx.raw(); 354 return ctx.raw();
353 } 355 }
354 356
355 357
358 // Get the saved context if the callee of this activation frame is a
359 // closure function.
360 RawContext* ActivationFrame::GetSavedCurrentContext() {
361 GetVarDescriptors();
362 intptr_t var_desc_len = var_descriptors_.Length();
363 for (int i = 0; i < var_desc_len; i++) {
364 RawLocalVarDescriptors::VarInfo var_info;
365 var_descriptors_.GetInfo(i, &var_info);
366 if (var_info.kind == RawLocalVarDescriptors::kSavedCurrentContext) {
367 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index));
368 }
369 }
370 UNREACHABLE();
371 return Context::null();
372 }
373
374
356 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( 375 ActivationFrame* DebuggerStackTrace::GetHandlerFrame(
357 const Instance& exc_obj) const { 376 const Instance& exc_obj) const {
358 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); 377 ExceptionHandlers& handlers = ExceptionHandlers::Handle();
359 Array& handled_types = Array::Handle(); 378 Array& handled_types = Array::Handle();
360 AbstractType& type = Type::Handle(); 379 AbstractType& type = Type::Handle();
361 const TypeArguments& no_instantiator = TypeArguments::Handle(); 380 const TypeArguments& no_instantiator = TypeArguments::Handle();
362 for (int frame_index = 0; frame_index < Length(); frame_index++) { 381 for (int frame_index = 0; frame_index < Length(); frame_index++) {
363 ActivationFrame* frame = trace_[frame_index]; 382 ActivationFrame* frame = trace_[frame_index];
364 intptr_t try_index = frame->TryIndex(); 383 intptr_t try_index = frame->TryIndex();
365 if (try_index < 0) continue; 384 if (try_index < 0) continue;
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 StackFrame* frame = iterator.NextFrame(); 903 StackFrame* frame = iterator.NextFrame();
885 bool optimized_frame_found = false; 904 bool optimized_frame_found = false;
886 while (frame != NULL) { 905 while (frame != NULL) {
887 ASSERT(frame->IsValid()); 906 ASSERT(frame->IsValid());
888 if (frame->IsDartFrame()) { 907 if (frame->IsDartFrame()) {
889 code = frame->LookupDartCode(); 908 code = frame->LookupDartCode();
890 ActivationFrame* activation = new ActivationFrame(frame->pc(), 909 ActivationFrame* activation = new ActivationFrame(frame->pc(),
891 frame->fp(), 910 frame->fp(),
892 frame->sp(), 911 frame->sp(),
893 code); 912 code);
913 // If this activation frame called a closure, the function has
914 // saved its context before the call.
915 if (stack_trace->Length() > 0) {
916 ActivationFrame* callee_frame =
917 stack_trace->ActivationFrameAt(stack_trace->Length() - 1);
918 if (callee_frame->function().IsClosureFunction()) {
919 ctx = activation->GetSavedCurrentContext();
920 }
921 }
894 if (optimized_frame_found || code.is_optimized()) { 922 if (optimized_frame_found || code.is_optimized()) {
895 // Set context to null, to avoid returning bad context variable values. 923 // Set context to null, to avoid returning bad context variable values.
896 activation->SetContext(Context::Handle()); 924 activation->SetContext(Context::Handle());
897 optimized_frame_found = true; 925 optimized_frame_found = true;
898 } else { 926 } else {
899 activation->SetContext(ctx); 927 activation->SetContext(ctx);
900 ctx = activation->GetSavedContext(ctx);
901 } 928 }
902 stack_trace->AddActivation(activation); 929 stack_trace->AddActivation(activation);
930 // Get caller's context if this function saved it on entry.
931 ctx = activation->GetSavedEntryContext(ctx);
903 } else if (frame->IsEntryFrame()) { 932 } else if (frame->IsEntryFrame()) {
904 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); 933 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext();
905 } 934 }
906 frame = iterator.NextFrame(); 935 frame = iterator.NextFrame();
907 } 936 }
908 return stack_trace; 937 return stack_trace;
909 } 938 }
910 939
911 940
912 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { 941 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 } 1768 }
1740 1769
1741 1770
1742 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1771 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1743 ASSERT(bpt->next() == NULL); 1772 ASSERT(bpt->next() == NULL);
1744 bpt->set_next(code_breakpoints_); 1773 bpt->set_next(code_breakpoints_);
1745 code_breakpoints_ = bpt; 1774 code_breakpoints_ = bpt;
1746 } 1775 }
1747 1776
1748 } // namespace dart 1777 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698