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 "platform/address_sanitizer.h" | 9 #include "platform/address_sanitizer.h" |
10 | 10 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 DebuggerStackTrace* stack = Isolate::Current()->debugger()->StackTrace(); | 1158 DebuggerStackTrace* stack = Isolate::Current()->debugger()->StackTrace(); |
1159 intptr_t num_frames = stack->Length(); | 1159 intptr_t num_frames = stack->Length(); |
1160 for (intptr_t i = 0; i < num_frames; i++) { | 1160 for (intptr_t i = 0; i < num_frames; i++) { |
1161 ActivationFrame* frame = stack->FrameAt(i); | 1161 ActivationFrame* frame = stack->FrameAt(i); |
1162 OS::PrintErr("#%04" Pd " %s", i, frame->ToCString()); | 1162 OS::PrintErr("#%04" Pd " %s", i, frame->ToCString()); |
1163 } | 1163 } |
1164 | 1164 |
1165 OS::PrintErr( | 1165 OS::PrintErr( |
1166 "-------------------------\n" | 1166 "-------------------------\n" |
1167 "All frames...\n\n"); | 1167 "All frames...\n\n"); |
1168 StackFrameIterator iterator(false); | 1168 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 1169 Thread::Current(), |
| 1170 StackFrameIterator::kNoCrossThreadIteration); |
1169 StackFrame* frame = iterator.NextFrame(); | 1171 StackFrame* frame = iterator.NextFrame(); |
1170 intptr_t num = 0; | 1172 intptr_t num = 0; |
1171 while ((frame != NULL)) { | 1173 while ((frame != NULL)) { |
1172 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 1174 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
1173 frame = iterator.NextFrame(); | 1175 frame = iterator.NextFrame(); |
1174 } | 1176 } |
1175 } | 1177 } |
1176 | 1178 |
1177 | 1179 |
1178 void ActivationFrame::VariableAt(intptr_t i, | 1180 void ActivationFrame::VariableAt(intptr_t i, |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1843 |
1842 return dest_frame.raw(); | 1844 return dest_frame.raw(); |
1843 } | 1845 } |
1844 | 1846 |
1845 | 1847 |
1846 DebuggerStackTrace* Debugger::CollectStackTrace() { | 1848 DebuggerStackTrace* Debugger::CollectStackTrace() { |
1847 Thread* thread = Thread::Current(); | 1849 Thread* thread = Thread::Current(); |
1848 Zone* zone = thread->zone(); | 1850 Zone* zone = thread->zone(); |
1849 Isolate* isolate = thread->isolate(); | 1851 Isolate* isolate = thread->isolate(); |
1850 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1852 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1851 StackFrameIterator iterator(false); | 1853 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 1854 Thread::Current(), |
| 1855 StackFrameIterator::kNoCrossThreadIteration); |
1852 Code& code = Code::Handle(zone); | 1856 Code& code = Code::Handle(zone); |
1853 Code& inlined_code = Code::Handle(zone); | 1857 Code& inlined_code = Code::Handle(zone); |
1854 Array& deopt_frame = Array::Handle(zone); | 1858 Array& deopt_frame = Array::Handle(zone); |
1855 | 1859 |
1856 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 1860 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
1857 frame = iterator.NextFrame()) { | 1861 frame = iterator.NextFrame()) { |
1858 ASSERT(frame->IsValid()); | 1862 ASSERT(frame->IsValid()); |
1859 if (FLAG_trace_debugger_stacktrace) { | 1863 if (FLAG_trace_debugger_stacktrace) { |
1860 OS::PrintErr("CollectStackTrace: visiting frame:\n\t%s\n", | 1864 OS::PrintErr("CollectStackTrace: visiting frame:\n\t%s\n", |
1861 frame->ToCString()); | 1865 frame->ToCString()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 return NULL; | 1931 return NULL; |
1928 } | 1932 } |
1929 | 1933 |
1930 intptr_t synchronous_stack_trace_length = | 1934 intptr_t synchronous_stack_trace_length = |
1931 StackTraceUtils::CountFrames(thread, 0, async_function); | 1935 StackTraceUtils::CountFrames(thread, 0, async_function); |
1932 | 1936 |
1933 // Append the top frames from the synchronous stack trace, up until the active | 1937 // Append the top frames from the synchronous stack trace, up until the active |
1934 // asynchronous function. We truncate the remainder of the synchronous | 1938 // asynchronous function. We truncate the remainder of the synchronous |
1935 // stack trace because it contains activations that are part of the | 1939 // stack trace because it contains activations that are part of the |
1936 // asynchronous dispatch mechanisms. | 1940 // asynchronous dispatch mechanisms. |
1937 StackFrameIterator iterator(false); | 1941 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 1942 Thread::Current(), |
| 1943 StackFrameIterator::kNoCrossThreadIteration); |
1938 StackFrame* frame = iterator.NextFrame(); | 1944 StackFrame* frame = iterator.NextFrame(); |
1939 while (synchronous_stack_trace_length > 0) { | 1945 while (synchronous_stack_trace_length > 0) { |
1940 ASSERT(frame != NULL); | 1946 ASSERT(frame != NULL); |
1941 if (frame->IsDartFrame()) { | 1947 if (frame->IsDartFrame()) { |
1942 code = frame->LookupDartCode(); | 1948 code = frame->LookupDartCode(); |
1943 AppendCodeFrames(thread, isolate, zone, stack_trace, frame, &code, | 1949 AppendCodeFrames(thread, isolate, zone, stack_trace, frame, &code, |
1944 &inlined_code, &deopt_frame); | 1950 &inlined_code, &deopt_frame); |
1945 synchronous_stack_trace_length--; | 1951 synchronous_stack_trace_length--; |
1946 } | 1952 } |
1947 frame = iterator.NextFrame(); | 1953 frame = iterator.NextFrame(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 return NULL; | 1996 return NULL; |
1991 } | 1997 } |
1992 // Causal async stacks are not supported in the AOT runtime. | 1998 // Causal async stacks are not supported in the AOT runtime. |
1993 ASSERT(!FLAG_precompiled_runtime); | 1999 ASSERT(!FLAG_precompiled_runtime); |
1994 | 2000 |
1995 Thread* thread = Thread::Current(); | 2001 Thread* thread = Thread::Current(); |
1996 Zone* zone = thread->zone(); | 2002 Zone* zone = thread->zone(); |
1997 Isolate* isolate = thread->isolate(); | 2003 Isolate* isolate = thread->isolate(); |
1998 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 2004 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1999 | 2005 |
2000 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); | 2006 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 2007 Thread::Current(), |
| 2008 StackFrameIterator::kNoCrossThreadIteration); |
2001 | 2009 |
2002 Code& code = Code::Handle(zone); | 2010 Code& code = Code::Handle(zone); |
2003 Smi& offset = Smi::Handle(zone); | 2011 Smi& offset = Smi::Handle(zone); |
2004 Function& function = Function::Handle(zone); | 2012 Function& function = Function::Handle(zone); |
2005 Code& inlined_code = Code::Handle(zone); | 2013 Code& inlined_code = Code::Handle(zone); |
2006 Closure& async_activation = Closure::Handle(zone); | 2014 Closure& async_activation = Closure::Handle(zone); |
2007 Object& next_async_activation = Object::Handle(zone); | 2015 Object& next_async_activation = Object::Handle(zone); |
2008 Array& deopt_frame = Array::Handle(zone); | 2016 Array& deopt_frame = Array::Handle(zone); |
2009 class StackTrace& async_stack_trace = StackTrace::Handle(zone); | 2017 class StackTrace& async_stack_trace = StackTrace::Handle(zone); |
2010 bool stack_has_async_function = false; | 2018 bool stack_has_async_function = false; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 } | 2132 } |
2125 // Follow the link. | 2133 // Follow the link. |
2126 async_stack_trace = async_stack_trace.async_link(); | 2134 async_stack_trace = async_stack_trace.async_link(); |
2127 } | 2135 } |
2128 | 2136 |
2129 return stack_trace; | 2137 return stack_trace; |
2130 } | 2138 } |
2131 | 2139 |
2132 | 2140 |
2133 ActivationFrame* Debugger::TopDartFrame() const { | 2141 ActivationFrame* Debugger::TopDartFrame() const { |
2134 StackFrameIterator iterator(false); | 2142 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 2143 Thread::Current(), |
| 2144 StackFrameIterator::kNoCrossThreadIteration); |
2135 StackFrame* frame = iterator.NextFrame(); | 2145 StackFrame* frame = iterator.NextFrame(); |
2136 while ((frame != NULL) && !frame->IsDartFrame()) { | 2146 while ((frame != NULL) && !frame->IsDartFrame()) { |
2137 frame = iterator.NextFrame(); | 2147 frame = iterator.NextFrame(); |
2138 } | 2148 } |
2139 Code& code = Code::Handle(frame->LookupDartCode()); | 2149 Code& code = Code::Handle(frame->LookupDartCode()); |
2140 ActivationFrame* activation = new ActivationFrame( | 2150 ActivationFrame* activation = new ActivationFrame( |
2141 frame->pc(), frame->fp(), frame->sp(), code, Object::null_array(), 0); | 2151 frame->pc(), frame->fp(), frame->sp(), code, Object::null_array(), 0); |
2142 return activation; | 2152 return activation; |
2143 } | 2153 } |
2144 | 2154 |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 } | 3347 } |
3338 if (FLAG_verbose_debug) { | 3348 if (FLAG_verbose_debug) { |
3339 OS::Print("HandleSteppingRequest- kStepOut %" Px "\n", stepping_fp_); | 3349 OS::Print("HandleSteppingRequest- kStepOut %" Px "\n", stepping_fp_); |
3340 } | 3350 } |
3341 } else if (resume_action_ == kStepRewind) { | 3351 } else if (resume_action_ == kStepRewind) { |
3342 if (FLAG_trace_rewind) { | 3352 if (FLAG_trace_rewind) { |
3343 OS::PrintErr("Rewinding to frame %" Pd "\n", resume_frame_index_); | 3353 OS::PrintErr("Rewinding to frame %" Pd "\n", resume_frame_index_); |
3344 OS::PrintErr( | 3354 OS::PrintErr( |
3345 "-------------------------\n" | 3355 "-------------------------\n" |
3346 "All frames...\n\n"); | 3356 "All frames...\n\n"); |
3347 StackFrameIterator iterator(false); | 3357 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 3358 Thread::Current(), |
| 3359 StackFrameIterator::kNoCrossThreadIteration); |
3348 StackFrame* frame = iterator.NextFrame(); | 3360 StackFrame* frame = iterator.NextFrame(); |
3349 intptr_t num = 0; | 3361 intptr_t num = 0; |
3350 while ((frame != NULL)) { | 3362 while ((frame != NULL)) { |
3351 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 3363 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
3352 frame = iterator.NextFrame(); | 3364 frame = iterator.NextFrame(); |
3353 } | 3365 } |
3354 } | 3366 } |
3355 RewindToFrame(resume_frame_index_); | 3367 RewindToFrame(resume_frame_index_); |
3356 UNREACHABLE(); | 3368 UNREACHABLE(); |
3357 } | 3369 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3459 } | 3471 } |
3460 | 3472 |
3461 | 3473 |
3462 void Debugger::RewindToFrame(intptr_t frame_index) { | 3474 void Debugger::RewindToFrame(intptr_t frame_index) { |
3463 Thread* thread = Thread::Current(); | 3475 Thread* thread = Thread::Current(); |
3464 Zone* zone = thread->zone(); | 3476 Zone* zone = thread->zone(); |
3465 Code& code = Code::Handle(zone); | 3477 Code& code = Code::Handle(zone); |
3466 Function& function = Function::Handle(zone); | 3478 Function& function = Function::Handle(zone); |
3467 | 3479 |
3468 // Find the requested frame. | 3480 // Find the requested frame. |
3469 StackFrameIterator iterator(false); | 3481 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 3482 Thread::Current(), |
| 3483 StackFrameIterator::kNoCrossThreadIteration); |
3470 intptr_t current_frame = 0; | 3484 intptr_t current_frame = 0; |
3471 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 3485 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
3472 frame = iterator.NextFrame()) { | 3486 frame = iterator.NextFrame()) { |
3473 ASSERT(frame->IsValid()); | 3487 ASSERT(frame->IsValid()); |
3474 if (frame->IsDartFrame()) { | 3488 if (frame->IsDartFrame()) { |
3475 code = frame->LookupDartCode(); | 3489 code = frame->LookupDartCode(); |
3476 function = code.function(); | 3490 function = code.function(); |
3477 if (!IsFunctionVisible(function)) { | 3491 if (!IsFunctionVisible(function)) { |
3478 continue; | 3492 continue; |
3479 } | 3493 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3561 | 3575 |
3562 | 3576 |
3563 void Debugger::RewindPostDeopt() { | 3577 void Debugger::RewindPostDeopt() { |
3564 intptr_t rewind_frame = post_deopt_frame_index_; | 3578 intptr_t rewind_frame = post_deopt_frame_index_; |
3565 post_deopt_frame_index_ = -1; | 3579 post_deopt_frame_index_ = -1; |
3566 if (FLAG_trace_rewind) { | 3580 if (FLAG_trace_rewind) { |
3567 OS::PrintErr("Post deopt, jumping to frame %" Pd "\n", rewind_frame); | 3581 OS::PrintErr("Post deopt, jumping to frame %" Pd "\n", rewind_frame); |
3568 OS::PrintErr( | 3582 OS::PrintErr( |
3569 "-------------------------\n" | 3583 "-------------------------\n" |
3570 "All frames...\n\n"); | 3584 "All frames...\n\n"); |
3571 StackFrameIterator iterator(false); | 3585 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 3586 Thread::Current(), |
| 3587 StackFrameIterator::kNoCrossThreadIteration); |
3572 StackFrame* frame = iterator.NextFrame(); | 3588 StackFrame* frame = iterator.NextFrame(); |
3573 intptr_t num = 0; | 3589 intptr_t num = 0; |
3574 while ((frame != NULL)) { | 3590 while ((frame != NULL)) { |
3575 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 3591 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
3576 frame = iterator.NextFrame(); | 3592 frame = iterator.NextFrame(); |
3577 } | 3593 } |
3578 } | 3594 } |
3579 | 3595 |
3580 Thread* thread = Thread::Current(); | 3596 Thread* thread = Thread::Current(); |
3581 Zone* zone = thread->zone(); | 3597 Zone* zone = thread->zone(); |
3582 Code& code = Code::Handle(zone); | 3598 Code& code = Code::Handle(zone); |
3583 | 3599 |
3584 StackFrameIterator iterator(false); | 3600 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
| 3601 Thread::Current(), |
| 3602 StackFrameIterator::kNoCrossThreadIteration); |
3585 intptr_t current_frame = 0; | 3603 intptr_t current_frame = 0; |
3586 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 3604 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
3587 frame = iterator.NextFrame()) { | 3605 frame = iterator.NextFrame()) { |
3588 ASSERT(frame->IsValid()); | 3606 ASSERT(frame->IsValid()); |
3589 if (frame->IsDartFrame()) { | 3607 if (frame->IsDartFrame()) { |
3590 code = frame->LookupDartCode(); | 3608 code = frame->LookupDartCode(); |
3591 ASSERT(!code.is_optimized()); | 3609 ASSERT(!code.is_optimized()); |
3592 if (current_frame == rewind_frame) { | 3610 if (current_frame == rewind_frame) { |
3593 RewindToUnoptimizedFrame(frame, code); | 3611 RewindToUnoptimizedFrame(frame, code); |
3594 UNREACHABLE(); | 3612 UNREACHABLE(); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4367 | 4385 |
4368 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4386 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
4369 ASSERT(bpt->next() == NULL); | 4387 ASSERT(bpt->next() == NULL); |
4370 bpt->set_next(code_breakpoints_); | 4388 bpt->set_next(code_breakpoints_); |
4371 code_breakpoints_ = bpt; | 4389 code_breakpoints_ = bpt; |
4372 } | 4390 } |
4373 | 4391 |
4374 #endif // !PRODUCT | 4392 #endif // !PRODUCT |
4375 | 4393 |
4376 } // namespace dart | 4394 } // namespace dart |
OLD | NEW |