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

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

Issue 12179020: Fix for issues 6080 - pass in the Isolate's top context into the stub for invoking dart code from n… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_)); 127 visitor->VisitPointer(reinterpret_cast<RawObject**>(&function_));
128 } 128 }
129 129
130 130
131 131
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, const Code& code)
138 const Code& code,
139 const Context& ctx)
140 : pc_(pc), fp_(fp), sp_(sp), 138 : pc_(pc), fp_(fp), sp_(sp),
141 ctx_(Context::ZoneHandle(ctx.raw())), 139 ctx_(Context::ZoneHandle()),
142 code_(Code::ZoneHandle(code.raw())), 140 code_(Code::ZoneHandle(code.raw())),
143 function_(Function::ZoneHandle(code.function())), 141 function_(Function::ZoneHandle(code.function())),
144 token_pos_(-1), 142 token_pos_(-1),
145 pc_desc_index_(-1), 143 pc_desc_index_(-1),
146 line_number_(-1), 144 line_number_(-1),
147 context_level_(-1), 145 context_level_(-1),
148 vars_initialized_(false), 146 vars_initialized_(false),
149 var_descriptors_(LocalVarDescriptors::ZoneHandle()), 147 var_descriptors_(LocalVarDescriptors::ZoneHandle()),
150 desc_indices_(8), 148 desc_indices_(8),
151 pc_desc_(PcDescriptors::ZoneHandle()) { 149 pc_desc_(PcDescriptors::ZoneHandle()) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 context_level_ = var_info.index; 331 context_level_ = var_info.index;
334 } 332 }
335 } 333 }
336 } 334 }
337 ASSERT(context_level_ >= 0); 335 ASSERT(context_level_ >= 0);
338 } 336 }
339 return context_level_; 337 return context_level_;
340 } 338 }
341 339
342 340
343 RawContext* ActivationFrame::CallerContext() { 341 RawContext* ActivationFrame::GetSavedContext() {
344 GetVarDescriptors(); 342 GetVarDescriptors();
345 intptr_t var_desc_len = var_descriptors_.Length(); 343 intptr_t var_desc_len = var_descriptors_.Length();
346 for (int i = 0; i < var_desc_len; i++) { 344 for (int i = 0; i < var_desc_len; i++) {
347 RawLocalVarDescriptors::VarInfo var_info; 345 RawLocalVarDescriptors::VarInfo var_info;
348 var_descriptors_.GetInfo(i, &var_info); 346 var_descriptors_.GetInfo(i, &var_info);
349 if (var_info.kind == RawLocalVarDescriptors::kContextChain) { 347 if (var_info.kind == RawLocalVarDescriptors::kContextChain) {
350 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index)); 348 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index));
351 } 349 }
352 } 350 }
353 // Caller uses same context chain. 351 UNREACHABLE();
354 return ctx_.raw(); 352 return Context::null();
355 } 353 }
356 354
357 355
358 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( 356 ActivationFrame* DebuggerStackTrace::GetHandlerFrame(
359 const Instance& exc_obj) const { 357 const Instance& exc_obj) const {
360 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); 358 ExceptionHandlers& handlers = ExceptionHandlers::Handle();
361 Array& handled_types = Array::Handle(); 359 Array& handled_types = Array::Handle();
362 AbstractType& type = Type::Handle(); 360 AbstractType& type = Type::Handle();
363 const TypeArguments& no_instantiator = TypeArguments::Handle(); 361 const TypeArguments& no_instantiator = TypeArguments::Handle();
364 for (int frame_index = 0; frame_index < Length(); frame_index++) { 362 for (int frame_index = 0; frame_index < Length(); frame_index++) {
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 (*event_handler_)(&event); 850 (*event_handler_)(&event);
853 } 851 }
854 } 852 }
855 853
856 854
857 DebuggerStackTrace* Debugger::CollectStackTrace() { 855 DebuggerStackTrace* Debugger::CollectStackTrace() {
858 Isolate* isolate = Isolate::Current(); 856 Isolate* isolate = Isolate::Current();
859 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); 857 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
860 Context& ctx = Context::Handle(isolate->top_context()); 858 Context& ctx = Context::Handle(isolate->top_context());
861 Code& code = Code::Handle(isolate); 859 Code& code = Code::Handle(isolate);
862 DartFrameIterator iterator; 860 StackFrameIterator iterator(false);
863 StackFrame* frame = iterator.NextFrame(); 861 StackFrame* frame = iterator.NextFrame();
862 bool get_saved_context = false;
864 while (frame != NULL) { 863 while (frame != NULL) {
865 ASSERT(frame->IsValid()); 864 ASSERT(frame->IsValid());
866 ASSERT(frame->IsDartFrame()); 865 if (frame->IsDartFrame()) {
867 code = frame->LookupDartCode(); 866 code = frame->LookupDartCode();
868 ActivationFrame* activation = 867 ActivationFrame* activation = new ActivationFrame(frame->pc(),
869 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, ctx); 868 frame->fp(),
870 ctx = activation->CallerContext(); 869 frame->sp(),
871 stack_trace->AddActivation(activation); 870 code);
871 if (get_saved_context) {
872 ctx = activation->GetSavedContext();
873 }
874 activation->SetContext(ctx);
875 stack_trace->AddActivation(activation);
876 get_saved_context = activation->function().IsClosureFunction();
877 } else if (frame->IsEntryFrame()) {
878 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext();
879 get_saved_context = false;
880 }
872 frame = iterator.NextFrame(); 881 frame = iterator.NextFrame();
873 } 882 }
874 return stack_trace; 883 return stack_trace;
875 } 884 }
876 885
877 886
878 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { 887 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
879 ASSERT((pause_info == kNoPauseOnExceptions) || 888 ASSERT((pause_info == kNoPauseOnExceptions) ||
880 (pause_info == kPauseOnUnhandledExceptions) || 889 (pause_info == kPauseOnUnhandledExceptions) ||
881 (pause_info == kPauseOnAllExceptions)); 890 (pause_info == kPauseOnAllExceptions));
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 } 1715 }
1707 1716
1708 1717
1709 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1718 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1710 ASSERT(bpt->next() == NULL); 1719 ASSERT(bpt->next() == NULL);
1711 bpt->set_next(code_breakpoints_); 1720 bpt->set_next(code_breakpoints_);
1712 code_breakpoints_ = bpt; 1721 code_breakpoints_ = bpt;
1713 } 1722 }
1714 1723
1715 } // namespace dart 1724 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698