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(false, Thread::Current(), false); |
rmacnak
2017/05/01 15:51:33
Here and elsewhere
StackFrameIterator::kDontValid
kustermann
2017/05/02 07:11:18
Will make it an enum, same for the other boolean.
| |
1169 StackFrame* frame = iterator.NextFrame(); | 1169 StackFrame* frame = iterator.NextFrame(); |
1170 intptr_t num = 0; | 1170 intptr_t num = 0; |
1171 while ((frame != NULL)) { | 1171 while ((frame != NULL)) { |
1172 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 1172 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
1173 frame = iterator.NextFrame(); | 1173 frame = iterator.NextFrame(); |
1174 } | 1174 } |
1175 } | 1175 } |
1176 | 1176 |
1177 | 1177 |
1178 void ActivationFrame::VariableAt(intptr_t i, | 1178 void ActivationFrame::VariableAt(intptr_t i, |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1841 | 1841 |
1842 return dest_frame.raw(); | 1842 return dest_frame.raw(); |
1843 } | 1843 } |
1844 | 1844 |
1845 | 1845 |
1846 DebuggerStackTrace* Debugger::CollectStackTrace() { | 1846 DebuggerStackTrace* Debugger::CollectStackTrace() { |
1847 Thread* thread = Thread::Current(); | 1847 Thread* thread = Thread::Current(); |
1848 Zone* zone = thread->zone(); | 1848 Zone* zone = thread->zone(); |
1849 Isolate* isolate = thread->isolate(); | 1849 Isolate* isolate = thread->isolate(); |
1850 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1850 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1851 StackFrameIterator iterator(false); | 1851 StackFrameIterator iterator(false, Thread::Current(), false); |
1852 Code& code = Code::Handle(zone); | 1852 Code& code = Code::Handle(zone); |
1853 Code& inlined_code = Code::Handle(zone); | 1853 Code& inlined_code = Code::Handle(zone); |
1854 Array& deopt_frame = Array::Handle(zone); | 1854 Array& deopt_frame = Array::Handle(zone); |
1855 | 1855 |
1856 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 1856 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
1857 frame = iterator.NextFrame()) { | 1857 frame = iterator.NextFrame()) { |
1858 ASSERT(frame->IsValid()); | 1858 ASSERT(frame->IsValid()); |
1859 if (FLAG_trace_debugger_stacktrace) { | 1859 if (FLAG_trace_debugger_stacktrace) { |
1860 OS::PrintErr("CollectStackTrace: visiting frame:\n\t%s\n", | 1860 OS::PrintErr("CollectStackTrace: visiting frame:\n\t%s\n", |
1861 frame->ToCString()); | 1861 frame->ToCString()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1927 return NULL; | 1927 return NULL; |
1928 } | 1928 } |
1929 | 1929 |
1930 intptr_t synchronous_stack_trace_length = | 1930 intptr_t synchronous_stack_trace_length = |
1931 StackTraceUtils::CountFrames(thread, 0, async_function); | 1931 StackTraceUtils::CountFrames(thread, 0, async_function); |
1932 | 1932 |
1933 // Append the top frames from the synchronous stack trace, up until the active | 1933 // Append the top frames from the synchronous stack trace, up until the active |
1934 // asynchronous function. We truncate the remainder of the synchronous | 1934 // asynchronous function. We truncate the remainder of the synchronous |
1935 // stack trace because it contains activations that are part of the | 1935 // stack trace because it contains activations that are part of the |
1936 // asynchronous dispatch mechanisms. | 1936 // asynchronous dispatch mechanisms. |
1937 StackFrameIterator iterator(false); | 1937 StackFrameIterator iterator(false, Thread::Current(), false); |
1938 StackFrame* frame = iterator.NextFrame(); | 1938 StackFrame* frame = iterator.NextFrame(); |
1939 while (synchronous_stack_trace_length > 0) { | 1939 while (synchronous_stack_trace_length > 0) { |
1940 ASSERT(frame != NULL); | 1940 ASSERT(frame != NULL); |
1941 if (frame->IsDartFrame()) { | 1941 if (frame->IsDartFrame()) { |
1942 code = frame->LookupDartCode(); | 1942 code = frame->LookupDartCode(); |
1943 AppendCodeFrames(thread, isolate, zone, stack_trace, frame, &code, | 1943 AppendCodeFrames(thread, isolate, zone, stack_trace, frame, &code, |
1944 &inlined_code, &deopt_frame); | 1944 &inlined_code, &deopt_frame); |
1945 synchronous_stack_trace_length--; | 1945 synchronous_stack_trace_length--; |
1946 } | 1946 } |
1947 frame = iterator.NextFrame(); | 1947 frame = iterator.NextFrame(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1990 return NULL; | 1990 return NULL; |
1991 } | 1991 } |
1992 // Causal async stacks are not supported in the AOT runtime. | 1992 // Causal async stacks are not supported in the AOT runtime. |
1993 ASSERT(!FLAG_precompiled_runtime); | 1993 ASSERT(!FLAG_precompiled_runtime); |
1994 | 1994 |
1995 Thread* thread = Thread::Current(); | 1995 Thread* thread = Thread::Current(); |
1996 Zone* zone = thread->zone(); | 1996 Zone* zone = thread->zone(); |
1997 Isolate* isolate = thread->isolate(); | 1997 Isolate* isolate = thread->isolate(); |
1998 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1998 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1999 | 1999 |
2000 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); | 2000 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
2001 Thread::Current(), false); | |
2001 | 2002 |
2002 Code& code = Code::Handle(zone); | 2003 Code& code = Code::Handle(zone); |
2003 Smi& offset = Smi::Handle(zone); | 2004 Smi& offset = Smi::Handle(zone); |
2004 Function& function = Function::Handle(zone); | 2005 Function& function = Function::Handle(zone); |
2005 Code& inlined_code = Code::Handle(zone); | 2006 Code& inlined_code = Code::Handle(zone); |
2006 Closure& async_activation = Closure::Handle(zone); | 2007 Closure& async_activation = Closure::Handle(zone); |
2007 Object& next_async_activation = Object::Handle(zone); | 2008 Object& next_async_activation = Object::Handle(zone); |
2008 Array& deopt_frame = Array::Handle(zone); | 2009 Array& deopt_frame = Array::Handle(zone); |
2009 class StackTrace& async_stack_trace = StackTrace::Handle(zone); | 2010 class StackTrace& async_stack_trace = StackTrace::Handle(zone); |
2010 bool stack_has_async_function = false; | 2011 bool stack_has_async_function = false; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2124 } | 2125 } |
2125 // Follow the link. | 2126 // Follow the link. |
2126 async_stack_trace = async_stack_trace.async_link(); | 2127 async_stack_trace = async_stack_trace.async_link(); |
2127 } | 2128 } |
2128 | 2129 |
2129 return stack_trace; | 2130 return stack_trace; |
2130 } | 2131 } |
2131 | 2132 |
2132 | 2133 |
2133 ActivationFrame* Debugger::TopDartFrame() const { | 2134 ActivationFrame* Debugger::TopDartFrame() const { |
2134 StackFrameIterator iterator(false); | 2135 StackFrameIterator iterator(false, Thread::Current(), false); |
2135 StackFrame* frame = iterator.NextFrame(); | 2136 StackFrame* frame = iterator.NextFrame(); |
2136 while ((frame != NULL) && !frame->IsDartFrame()) { | 2137 while ((frame != NULL) && !frame->IsDartFrame()) { |
2137 frame = iterator.NextFrame(); | 2138 frame = iterator.NextFrame(); |
2138 } | 2139 } |
2139 Code& code = Code::Handle(frame->LookupDartCode()); | 2140 Code& code = Code::Handle(frame->LookupDartCode()); |
2140 ActivationFrame* activation = new ActivationFrame( | 2141 ActivationFrame* activation = new ActivationFrame( |
2141 frame->pc(), frame->fp(), frame->sp(), code, Object::null_array(), 0); | 2142 frame->pc(), frame->fp(), frame->sp(), code, Object::null_array(), 0); |
2142 return activation; | 2143 return activation; |
2143 } | 2144 } |
2144 | 2145 |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3337 } | 3338 } |
3338 if (FLAG_verbose_debug) { | 3339 if (FLAG_verbose_debug) { |
3339 OS::Print("HandleSteppingRequest- kStepOut %" Px "\n", stepping_fp_); | 3340 OS::Print("HandleSteppingRequest- kStepOut %" Px "\n", stepping_fp_); |
3340 } | 3341 } |
3341 } else if (resume_action_ == kStepRewind) { | 3342 } else if (resume_action_ == kStepRewind) { |
3342 if (FLAG_trace_rewind) { | 3343 if (FLAG_trace_rewind) { |
3343 OS::PrintErr("Rewinding to frame %" Pd "\n", resume_frame_index_); | 3344 OS::PrintErr("Rewinding to frame %" Pd "\n", resume_frame_index_); |
3344 OS::PrintErr( | 3345 OS::PrintErr( |
3345 "-------------------------\n" | 3346 "-------------------------\n" |
3346 "All frames...\n\n"); | 3347 "All frames...\n\n"); |
3347 StackFrameIterator iterator(false); | 3348 StackFrameIterator iterator(false, Thread::Current(), false); |
3348 StackFrame* frame = iterator.NextFrame(); | 3349 StackFrame* frame = iterator.NextFrame(); |
3349 intptr_t num = 0; | 3350 intptr_t num = 0; |
3350 while ((frame != NULL)) { | 3351 while ((frame != NULL)) { |
3351 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 3352 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
3352 frame = iterator.NextFrame(); | 3353 frame = iterator.NextFrame(); |
3353 } | 3354 } |
3354 } | 3355 } |
3355 RewindToFrame(resume_frame_index_); | 3356 RewindToFrame(resume_frame_index_); |
3356 UNREACHABLE(); | 3357 UNREACHABLE(); |
3357 } | 3358 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3459 } | 3460 } |
3460 | 3461 |
3461 | 3462 |
3462 void Debugger::RewindToFrame(intptr_t frame_index) { | 3463 void Debugger::RewindToFrame(intptr_t frame_index) { |
3463 Thread* thread = Thread::Current(); | 3464 Thread* thread = Thread::Current(); |
3464 Zone* zone = thread->zone(); | 3465 Zone* zone = thread->zone(); |
3465 Code& code = Code::Handle(zone); | 3466 Code& code = Code::Handle(zone); |
3466 Function& function = Function::Handle(zone); | 3467 Function& function = Function::Handle(zone); |
3467 | 3468 |
3468 // Find the requested frame. | 3469 // Find the requested frame. |
3469 StackFrameIterator iterator(false); | 3470 StackFrameIterator iterator(false, Thread::Current(), false); |
3470 intptr_t current_frame = 0; | 3471 intptr_t current_frame = 0; |
3471 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 3472 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
3472 frame = iterator.NextFrame()) { | 3473 frame = iterator.NextFrame()) { |
3473 ASSERT(frame->IsValid()); | 3474 ASSERT(frame->IsValid()); |
3474 if (frame->IsDartFrame()) { | 3475 if (frame->IsDartFrame()) { |
3475 code = frame->LookupDartCode(); | 3476 code = frame->LookupDartCode(); |
3476 function = code.function(); | 3477 function = code.function(); |
3477 if (!IsFunctionVisible(function)) { | 3478 if (!IsFunctionVisible(function)) { |
3478 continue; | 3479 continue; |
3479 } | 3480 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3561 | 3562 |
3562 | 3563 |
3563 void Debugger::RewindPostDeopt() { | 3564 void Debugger::RewindPostDeopt() { |
3564 intptr_t rewind_frame = post_deopt_frame_index_; | 3565 intptr_t rewind_frame = post_deopt_frame_index_; |
3565 post_deopt_frame_index_ = -1; | 3566 post_deopt_frame_index_ = -1; |
3566 if (FLAG_trace_rewind) { | 3567 if (FLAG_trace_rewind) { |
3567 OS::PrintErr("Post deopt, jumping to frame %" Pd "\n", rewind_frame); | 3568 OS::PrintErr("Post deopt, jumping to frame %" Pd "\n", rewind_frame); |
3568 OS::PrintErr( | 3569 OS::PrintErr( |
3569 "-------------------------\n" | 3570 "-------------------------\n" |
3570 "All frames...\n\n"); | 3571 "All frames...\n\n"); |
3571 StackFrameIterator iterator(false); | 3572 StackFrameIterator iterator(false, Thread::Current(), false); |
3572 StackFrame* frame = iterator.NextFrame(); | 3573 StackFrame* frame = iterator.NextFrame(); |
3573 intptr_t num = 0; | 3574 intptr_t num = 0; |
3574 while ((frame != NULL)) { | 3575 while ((frame != NULL)) { |
3575 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); | 3576 OS::PrintErr("#%04" Pd " %s\n", num++, frame->ToCString()); |
3576 frame = iterator.NextFrame(); | 3577 frame = iterator.NextFrame(); |
3577 } | 3578 } |
3578 } | 3579 } |
3579 | 3580 |
3580 Thread* thread = Thread::Current(); | 3581 Thread* thread = Thread::Current(); |
3581 Zone* zone = thread->zone(); | 3582 Zone* zone = thread->zone(); |
3582 Code& code = Code::Handle(zone); | 3583 Code& code = Code::Handle(zone); |
3583 | 3584 |
3584 StackFrameIterator iterator(false); | 3585 StackFrameIterator iterator(false, Thread::Current(), false); |
3585 intptr_t current_frame = 0; | 3586 intptr_t current_frame = 0; |
3586 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; | 3587 for (StackFrame* frame = iterator.NextFrame(); frame != NULL; |
3587 frame = iterator.NextFrame()) { | 3588 frame = iterator.NextFrame()) { |
3588 ASSERT(frame->IsValid()); | 3589 ASSERT(frame->IsValid()); |
3589 if (frame->IsDartFrame()) { | 3590 if (frame->IsDartFrame()) { |
3590 code = frame->LookupDartCode(); | 3591 code = frame->LookupDartCode(); |
3591 ASSERT(!code.is_optimized()); | 3592 ASSERT(!code.is_optimized()); |
3592 if (current_frame == rewind_frame) { | 3593 if (current_frame == rewind_frame) { |
3593 RewindToUnoptimizedFrame(frame, code); | 3594 RewindToUnoptimizedFrame(frame, code); |
3594 UNREACHABLE(); | 3595 UNREACHABLE(); |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4367 | 4368 |
4368 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4369 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
4369 ASSERT(bpt->next() == NULL); | 4370 ASSERT(bpt->next() == NULL); |
4370 bpt->set_next(code_breakpoints_); | 4371 bpt->set_next(code_breakpoints_); |
4371 code_breakpoints_ = bpt; | 4372 code_breakpoints_ = bpt; |
4372 } | 4373 } |
4373 | 4374 |
4374 #endif // !PRODUCT | 4375 #endif // !PRODUCT |
4375 | 4376 |
4376 } // namespace dart | 4377 } // namespace dart |
OLD | NEW |