OLD | NEW |
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 for (intptr_t i = 0; i < var_desc_len; i++) { | 465 for (intptr_t i = 0; i < var_desc_len; i++) { |
466 RawLocalVarDescriptors::VarInfo var_info; | 466 RawLocalVarDescriptors::VarInfo var_info; |
467 var_descriptors_.GetInfo(i, &var_info); | 467 var_descriptors_.GetInfo(i, &var_info); |
468 const int8_t kind = var_info.kind(); | 468 const int8_t kind = var_info.kind(); |
469 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) { | 469 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) { |
470 if (FLAG_trace_debugger_stacktrace) { | 470 if (FLAG_trace_debugger_stacktrace) { |
471 OS::PrintErr("\tFound saved current ctx at index %d\n", | 471 OS::PrintErr("\tFound saved current ctx at index %d\n", |
472 var_info.index()); | 472 var_info.index()); |
473 } | 473 } |
474 ASSERT(Object::Handle(GetLocalVar(var_info.index())).IsContext()); | 474 ASSERT(Object::Handle(GetLocalVar(var_info.index())).IsContext()); |
475 return reinterpret_cast<RawContext*>(GetLocalVar(var_info.index())); | 475 return Context::RawCast(GetLocalVar(var_info.index())); |
476 } | 476 } |
477 } | 477 } |
478 UNREACHABLE(); | 478 UNREACHABLE(); |
479 return Context::null(); | 479 return Context::null(); |
480 } | 480 } |
481 | 481 |
482 | 482 |
483 const char* DebuggerEvent::EventTypeToCString(EventType type) { | 483 const char* DebuggerEvent::EventTypeToCString(EventType type) { |
484 switch (type) { | 484 switch (type) { |
485 case kBreakpointReached: | 485 case kBreakpointReached: |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 uword pc, | 1191 uword pc, |
1192 StackFrame* frame, | 1192 StackFrame* frame, |
1193 const Code& code, | 1193 const Code& code, |
1194 const Array& deopt_frame, | 1194 const Array& deopt_frame, |
1195 intptr_t deopt_frame_offset) { | 1195 intptr_t deopt_frame_offset) { |
1196 ASSERT(code.ContainsInstructionAt(pc)); | 1196 ASSERT(code.ContainsInstructionAt(pc)); |
1197 ActivationFrame* activation = | 1197 ActivationFrame* activation = |
1198 new ActivationFrame(pc, frame->fp(), frame->sp(), code, | 1198 new ActivationFrame(pc, frame->fp(), frame->sp(), code, |
1199 deopt_frame, deopt_frame_offset); | 1199 deopt_frame, deopt_frame_offset); |
1200 | 1200 |
1201 // Is there a closure call at the current PC? | |
1202 bool is_closure_call = false; | |
1203 const PcDescriptors& pc_desc = | |
1204 PcDescriptors::Handle(isolate, code.pc_descriptors()); | |
1205 PcDescriptors::Iterator iter(pc_desc, RawPcDescriptors::kClosureCall); | |
1206 while (iter.MoveNext()) { | |
1207 if (iter.Pc() == pc) { | |
1208 is_closure_call = true; | |
1209 break; | |
1210 } | |
1211 } | |
1212 | |
1213 // Recover the context for this frame. | 1201 // Recover the context for this frame. |
1214 if (is_closure_call) { | 1202 const Context& ctx = |
1215 // If the callee is a closure, we should have stored the context | 1203 Context::Handle(isolate, activation->GetSavedCurrentContext()); |
1216 // in the current frame before making the call. | 1204 ASSERT(!ctx.IsNull()); |
1217 const Context& closure_call_ctx = | 1205 activation->SetContext(ctx); |
1218 Context::Handle(isolate, activation->GetSavedCurrentContext()); | 1206 if (FLAG_trace_debugger_stacktrace) { |
1219 ASSERT(!closure_call_ctx.IsNull()); | 1207 OS::PrintErr("\tUsing saved context: %s\n", ctx.ToCString()); |
1220 activation->SetContext(closure_call_ctx); | |
1221 if (FLAG_trace_debugger_stacktrace) { | |
1222 OS::PrintErr("\tUsing closure call ctx: %s\n", | |
1223 closure_call_ctx.ToCString()); | |
1224 } | |
1225 } else { | |
1226 const Context& ctx = | |
1227 Context::Handle(isolate, activation->GetSavedCurrentContext()); | |
1228 ASSERT(!ctx.IsNull()); | |
1229 activation->SetContext(ctx); | |
1230 if (FLAG_trace_debugger_stacktrace) { | |
1231 OS::PrintErr("\tUsing entry ctx: %s\n", ctx.ToCString()); | |
1232 } | |
1233 } | 1208 } |
1234 if (FLAG_trace_debugger_stacktrace) { | 1209 if (FLAG_trace_debugger_stacktrace) { |
1235 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); | 1210 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); |
1236 } | 1211 } |
1237 return activation; | 1212 return activation; |
1238 } | 1213 } |
1239 | 1214 |
1240 | 1215 |
1241 RawArray* Debugger::DeoptimizeToArray(Isolate* isolate, | 1216 RawArray* Debugger::DeoptimizeToArray(Isolate* isolate, |
1242 StackFrame* frame, | 1217 StackFrame* frame, |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 } | 2485 } |
2511 | 2486 |
2512 | 2487 |
2513 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 2488 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
2514 ASSERT(bpt->next() == NULL); | 2489 ASSERT(bpt->next() == NULL); |
2515 bpt->set_next(code_breakpoints_); | 2490 bpt->set_next(code_breakpoints_); |
2516 code_breakpoints_ = bpt; | 2491 code_breakpoints_ = bpt; |
2517 } | 2492 } |
2518 | 2493 |
2519 } // namespace dart | 2494 } // namespace dart |
OLD | NEW |