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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 bool ActivationFrame::IsDebuggable() const { | 665 bool ActivationFrame::IsDebuggable() const { |
666 return Debugger::IsDebuggable(function()); | 666 return Debugger::IsDebuggable(function()); |
667 } | 667 } |
668 | 668 |
669 void ActivationFrame::PrintDescriptorsError(const char* message) { | 669 void ActivationFrame::PrintDescriptorsError(const char* message) { |
670 OS::PrintErr("Bad descriptors: %s\n", message); | 670 OS::PrintErr("Bad descriptors: %s\n", message); |
671 OS::PrintErr("function %s\n", function().ToQualifiedCString()); | 671 OS::PrintErr("function %s\n", function().ToQualifiedCString()); |
672 OS::PrintErr("pc_ %" Px "\n", pc_); | 672 OS::PrintErr("pc_ %" Px "\n", pc_); |
673 OS::PrintErr("deopt_id_ %" Px "\n", deopt_id_); | 673 OS::PrintErr("deopt_id_ %" Px "\n", deopt_id_); |
674 OS::PrintErr("context_level_ %" Px "\n", context_level_); | 674 OS::PrintErr("context_level_ %" Px "\n", context_level_); |
| 675 #if !defined(DART_PRECOMPILED_RUNTIME) |
675 DisassembleToStdout formatter; | 676 DisassembleToStdout formatter; |
676 code().Disassemble(&formatter); | 677 code().Disassemble(&formatter); |
| 678 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
677 PcDescriptors::Handle(code().pc_descriptors()).Print(); | 679 PcDescriptors::Handle(code().pc_descriptors()).Print(); |
678 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, | 680 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, |
679 Thread::Current(), | 681 Thread::Current(), |
680 StackFrameIterator::kNoCrossThreadIteration); | 682 StackFrameIterator::kNoCrossThreadIteration); |
681 StackFrame* frame = frames.NextFrame(); | 683 StackFrame* frame = frames.NextFrame(); |
682 while (frame != NULL) { | 684 while (frame != NULL) { |
683 OS::PrintErr("%s\n", frame->ToCString()); | 685 OS::PrintErr("%s\n", frame->ToCString()); |
684 frame = frames.NextFrame(); | 686 frame = frames.NextFrame(); |
685 } | 687 } |
686 OS::Abort(); | 688 OS::Abort(); |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 if (FLAG_trace_debugger_stacktrace) { | 1775 if (FLAG_trace_debugger_stacktrace) { |
1774 const Context& ctx = activation->GetSavedCurrentContext(); | 1776 const Context& ctx = activation->GetSavedCurrentContext(); |
1775 OS::PrintErr("\tUsing saved context: %s\n", ctx.ToCString()); | 1777 OS::PrintErr("\tUsing saved context: %s\n", ctx.ToCString()); |
1776 } | 1778 } |
1777 if (FLAG_trace_debugger_stacktrace) { | 1779 if (FLAG_trace_debugger_stacktrace) { |
1778 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); | 1780 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); |
1779 } | 1781 } |
1780 return activation; | 1782 return activation; |
1781 } | 1783 } |
1782 | 1784 |
| 1785 #if !defined(DART_PRECOMPILED_RUNTIME) |
1783 RawArray* Debugger::DeoptimizeToArray(Thread* thread, | 1786 RawArray* Debugger::DeoptimizeToArray(Thread* thread, |
1784 StackFrame* frame, | 1787 StackFrame* frame, |
1785 const Code& code) { | 1788 const Code& code) { |
1786 ASSERT(code.is_optimized()); | 1789 ASSERT(code.is_optimized()); |
1787 Isolate* isolate = thread->isolate(); | 1790 Isolate* isolate = thread->isolate(); |
1788 // Create the DeoptContext for this deoptimization. | 1791 // Create the DeoptContext for this deoptimization. |
1789 DeoptContext* deopt_context = | 1792 DeoptContext* deopt_context = |
1790 new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, NULL, NULL, | 1793 new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, NULL, NULL, |
1791 true, false /* deoptimizing_code */); | 1794 true, false /* deoptimizing_code */); |
1792 isolate->set_deopt_context(deopt_context); | 1795 isolate->set_deopt_context(deopt_context); |
1793 | 1796 |
1794 deopt_context->FillDestFrame(); | 1797 deopt_context->FillDestFrame(); |
1795 deopt_context->MaterializeDeferredObjects(); | 1798 deopt_context->MaterializeDeferredObjects(); |
1796 const Array& dest_frame = | 1799 const Array& dest_frame = |
1797 Array::Handle(thread->zone(), deopt_context->DestFrameAsArray()); | 1800 Array::Handle(thread->zone(), deopt_context->DestFrameAsArray()); |
1798 | 1801 |
1799 isolate->set_deopt_context(NULL); | 1802 isolate->set_deopt_context(NULL); |
1800 delete deopt_context; | 1803 delete deopt_context; |
1801 | 1804 |
1802 return dest_frame.raw(); | 1805 return dest_frame.raw(); |
1803 } | 1806 } |
| 1807 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1804 | 1808 |
1805 DebuggerStackTrace* Debugger::CollectStackTrace() { | 1809 DebuggerStackTrace* Debugger::CollectStackTrace() { |
1806 Thread* thread = Thread::Current(); | 1810 Thread* thread = Thread::Current(); |
1807 Zone* zone = thread->zone(); | 1811 Zone* zone = thread->zone(); |
1808 Isolate* isolate = thread->isolate(); | 1812 Isolate* isolate = thread->isolate(); |
1809 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1813 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1810 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 1814 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
1811 Thread::Current(), | 1815 Thread::Current(), |
1812 StackFrameIterator::kNoCrossThreadIteration); | 1816 StackFrameIterator::kNoCrossThreadIteration); |
1813 Code& code = Code::Handle(zone); | 1817 Code& code = Code::Handle(zone); |
(...skipping 17 matching lines...) Expand all Loading... |
1831 } | 1835 } |
1832 | 1836 |
1833 void Debugger::AppendCodeFrames(Thread* thread, | 1837 void Debugger::AppendCodeFrames(Thread* thread, |
1834 Isolate* isolate, | 1838 Isolate* isolate, |
1835 Zone* zone, | 1839 Zone* zone, |
1836 DebuggerStackTrace* stack_trace, | 1840 DebuggerStackTrace* stack_trace, |
1837 StackFrame* frame, | 1841 StackFrame* frame, |
1838 Code* code, | 1842 Code* code, |
1839 Code* inlined_code, | 1843 Code* inlined_code, |
1840 Array* deopt_frame) { | 1844 Array* deopt_frame) { |
1841 if (code->is_optimized() && !FLAG_precompiled_runtime) { | 1845 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1846 if (code->is_optimized()) { |
1842 // TODO(rmacnak): Use CodeSourceMap | 1847 // TODO(rmacnak): Use CodeSourceMap |
1843 *deopt_frame = DeoptimizeToArray(thread, frame, *code); | 1848 *deopt_frame = DeoptimizeToArray(thread, frame, *code); |
1844 for (InlinedFunctionsIterator it(*code, frame->pc()); !it.Done(); | 1849 for (InlinedFunctionsIterator it(*code, frame->pc()); !it.Done(); |
1845 it.Advance()) { | 1850 it.Advance()) { |
1846 *inlined_code = it.code(); | 1851 *inlined_code = it.code(); |
1847 if (FLAG_trace_debugger_stacktrace) { | 1852 if (FLAG_trace_debugger_stacktrace) { |
1848 const Function& function = Function::Handle(zone, it.function()); | 1853 const Function& function = Function::Handle(zone, it.function()); |
1849 ASSERT(!function.IsNull()); | 1854 ASSERT(!function.IsNull()); |
1850 OS::PrintErr("CollectStackTrace: visiting inlined function: %s\n", | 1855 OS::PrintErr("CollectStackTrace: visiting inlined function: %s\n", |
1851 function.ToFullyQualifiedCString()); | 1856 function.ToFullyQualifiedCString()); |
1852 } | 1857 } |
1853 intptr_t deopt_frame_offset = it.GetDeoptFpOffset(); | 1858 intptr_t deopt_frame_offset = it.GetDeoptFpOffset(); |
1854 stack_trace->AddActivation(CollectDartFrame(isolate, it.pc(), frame, | 1859 stack_trace->AddActivation(CollectDartFrame(isolate, it.pc(), frame, |
1855 *inlined_code, *deopt_frame, | 1860 *inlined_code, *deopt_frame, |
1856 deopt_frame_offset)); | 1861 deopt_frame_offset)); |
1857 } | 1862 } |
1858 } else { | 1863 return; |
1859 stack_trace->AddActivation(CollectDartFrame( | |
1860 isolate, frame->pc(), frame, *code, Object::null_array(), 0)); | |
1861 } | 1864 } |
| 1865 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1866 stack_trace->AddActivation(CollectDartFrame(isolate, frame->pc(), frame, |
| 1867 *code, Object::null_array(), 0)); |
1862 } | 1868 } |
1863 | 1869 |
1864 DebuggerStackTrace* Debugger::CollectAsyncCausalStackTrace() { | 1870 DebuggerStackTrace* Debugger::CollectAsyncCausalStackTrace() { |
1865 if (!FLAG_causal_async_stacks) { | 1871 if (!FLAG_causal_async_stacks) { |
1866 return NULL; | 1872 return NULL; |
1867 } | 1873 } |
1868 Thread* thread = Thread::Current(); | 1874 Thread* thread = Thread::Current(); |
1869 Zone* zone = thread->zone(); | 1875 Zone* zone = thread->zone(); |
1870 Isolate* isolate = thread->isolate(); | 1876 Isolate* isolate = thread->isolate(); |
1871 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1877 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 } | 1946 } |
1941 } | 1947 } |
1942 // Follow the link. | 1948 // Follow the link. |
1943 async_stack_trace = async_stack_trace.async_link(); | 1949 async_stack_trace = async_stack_trace.async_link(); |
1944 } | 1950 } |
1945 | 1951 |
1946 return stack_trace; | 1952 return stack_trace; |
1947 } | 1953 } |
1948 | 1954 |
1949 DebuggerStackTrace* Debugger::CollectAwaiterReturnStackTrace() { | 1955 DebuggerStackTrace* Debugger::CollectAwaiterReturnStackTrace() { |
| 1956 #if defined(DART_PRECOMPILED_RUNTIME) |
| 1957 // Causal async stacks are not supported in the AOT runtime. |
| 1958 ASSERT(!FLAG_async_debugger); |
| 1959 return NULL; |
| 1960 #else |
1950 if (!FLAG_async_debugger) { | 1961 if (!FLAG_async_debugger) { |
1951 return NULL; | 1962 return NULL; |
1952 } | 1963 } |
1953 // Causal async stacks are not supported in the AOT runtime. | |
1954 ASSERT(!FLAG_precompiled_runtime); | |
1955 | 1964 |
1956 Thread* thread = Thread::Current(); | 1965 Thread* thread = Thread::Current(); |
1957 Zone* zone = thread->zone(); | 1966 Zone* zone = thread->zone(); |
1958 Isolate* isolate = thread->isolate(); | 1967 Isolate* isolate = thread->isolate(); |
1959 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1968 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1960 | 1969 |
1961 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 1970 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
1962 Thread::Current(), | 1971 Thread::Current(), |
1963 StackFrameIterator::kNoCrossThreadIteration); | 1972 StackFrameIterator::kNoCrossThreadIteration); |
1964 | 1973 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 } else { | 2092 } else { |
2084 stack_trace->AddAsyncCausalFrame(pc, code); | 2093 stack_trace->AddAsyncCausalFrame(pc, code); |
2085 } | 2094 } |
2086 } | 2095 } |
2087 } | 2096 } |
2088 // Follow the link. | 2097 // Follow the link. |
2089 async_stack_trace = async_stack_trace.async_link(); | 2098 async_stack_trace = async_stack_trace.async_link(); |
2090 } | 2099 } |
2091 | 2100 |
2092 return stack_trace; | 2101 return stack_trace; |
| 2102 #endif // defined(DART_PRECOMPILED_RUNTIME) |
2093 } | 2103 } |
2094 | 2104 |
2095 ActivationFrame* Debugger::TopDartFrame() const { | 2105 ActivationFrame* Debugger::TopDartFrame() const { |
2096 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 2106 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
2097 Thread::Current(), | 2107 Thread::Current(), |
2098 StackFrameIterator::kNoCrossThreadIteration); | 2108 StackFrameIterator::kNoCrossThreadIteration); |
2099 StackFrame* frame = iterator.NextFrame(); | 2109 StackFrame* frame = iterator.NextFrame(); |
2100 while ((frame != NULL) && !frame->IsDartFrame()) { | 2110 while ((frame != NULL) && !frame->IsDartFrame()) { |
2101 frame = iterator.NextFrame(); | 2111 frame = iterator.NextFrame(); |
2102 } | 2112 } |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 | 4370 |
4361 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4371 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
4362 ASSERT(bpt->next() == NULL); | 4372 ASSERT(bpt->next() == NULL); |
4363 bpt->set_next(code_breakpoints_); | 4373 bpt->set_next(code_breakpoints_); |
4364 code_breakpoints_ = bpt; | 4374 code_breakpoints_ = bpt; |
4365 } | 4375 } |
4366 | 4376 |
4367 #endif // !PRODUCT | 4377 #endif // !PRODUCT |
4368 | 4378 |
4369 } // namespace dart | 4379 } // namespace dart |
OLD | NEW |