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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return Debugger::IsDebuggable(function()); | 713 return Debugger::IsDebuggable(function()); |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 void ActivationFrame::PrintDescriptorsError(const char* message) { | 717 void ActivationFrame::PrintDescriptorsError(const char* message) { |
718 OS::PrintErr("Bad descriptors: %s\n", message); | 718 OS::PrintErr("Bad descriptors: %s\n", message); |
719 OS::PrintErr("function %s\n", function().ToQualifiedCString()); | 719 OS::PrintErr("function %s\n", function().ToQualifiedCString()); |
720 OS::PrintErr("pc_ %" Px "\n", pc_); | 720 OS::PrintErr("pc_ %" Px "\n", pc_); |
721 OS::PrintErr("deopt_id_ %" Px "\n", deopt_id_); | 721 OS::PrintErr("deopt_id_ %" Px "\n", deopt_id_); |
722 OS::PrintErr("context_level_ %" Px "\n", context_level_); | 722 OS::PrintErr("context_level_ %" Px "\n", context_level_); |
| 723 #if !defined(DART_PRECOMPILED_RUNTIME) |
723 DisassembleToStdout formatter; | 724 DisassembleToStdout formatter; |
724 code().Disassemble(&formatter); | 725 code().Disassemble(&formatter); |
| 726 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
725 PcDescriptors::Handle(code().pc_descriptors()).Print(); | 727 PcDescriptors::Handle(code().pc_descriptors()).Print(); |
726 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, | 728 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames, |
727 Thread::Current(), | 729 Thread::Current(), |
728 StackFrameIterator::kNoCrossThreadIteration); | 730 StackFrameIterator::kNoCrossThreadIteration); |
729 StackFrame* frame = frames.NextFrame(); | 731 StackFrame* frame = frames.NextFrame(); |
730 while (frame != NULL) { | 732 while (frame != NULL) { |
731 OS::PrintErr("%s\n", frame->ToCString()); | 733 OS::PrintErr("%s\n", frame->ToCString()); |
732 frame = frames.NextFrame(); | 734 frame = frames.NextFrame(); |
733 } | 735 } |
734 OS::Abort(); | 736 OS::Abort(); |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 const Context& ctx = activation->GetSavedCurrentContext(); | 1885 const Context& ctx = activation->GetSavedCurrentContext(); |
1884 OS::PrintErr("\tUsing saved context: %s\n", ctx.ToCString()); | 1886 OS::PrintErr("\tUsing saved context: %s\n", ctx.ToCString()); |
1885 } | 1887 } |
1886 if (FLAG_trace_debugger_stacktrace) { | 1888 if (FLAG_trace_debugger_stacktrace) { |
1887 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); | 1889 OS::PrintErr("\tLine number: %" Pd "\n", activation->LineNumber()); |
1888 } | 1890 } |
1889 return activation; | 1891 return activation; |
1890 } | 1892 } |
1891 | 1893 |
1892 | 1894 |
| 1895 #if !defined(DART_PRECOMPILED_RUNTIME) |
1893 RawArray* Debugger::DeoptimizeToArray(Thread* thread, | 1896 RawArray* Debugger::DeoptimizeToArray(Thread* thread, |
1894 StackFrame* frame, | 1897 StackFrame* frame, |
1895 const Code& code) { | 1898 const Code& code) { |
1896 ASSERT(code.is_optimized()); | 1899 ASSERT(code.is_optimized()); |
1897 Isolate* isolate = thread->isolate(); | 1900 Isolate* isolate = thread->isolate(); |
1898 // Create the DeoptContext for this deoptimization. | 1901 // Create the DeoptContext for this deoptimization. |
1899 DeoptContext* deopt_context = | 1902 DeoptContext* deopt_context = |
1900 new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, NULL, NULL, | 1903 new DeoptContext(frame, code, DeoptContext::kDestIsAllocated, NULL, NULL, |
1901 true, false /* deoptimizing_code */); | 1904 true, false /* deoptimizing_code */); |
1902 isolate->set_deopt_context(deopt_context); | 1905 isolate->set_deopt_context(deopt_context); |
1903 | 1906 |
1904 deopt_context->FillDestFrame(); | 1907 deopt_context->FillDestFrame(); |
1905 deopt_context->MaterializeDeferredObjects(); | 1908 deopt_context->MaterializeDeferredObjects(); |
1906 const Array& dest_frame = | 1909 const Array& dest_frame = |
1907 Array::Handle(thread->zone(), deopt_context->DestFrameAsArray()); | 1910 Array::Handle(thread->zone(), deopt_context->DestFrameAsArray()); |
1908 | 1911 |
1909 isolate->set_deopt_context(NULL); | 1912 isolate->set_deopt_context(NULL); |
1910 delete deopt_context; | 1913 delete deopt_context; |
1911 | 1914 |
1912 return dest_frame.raw(); | 1915 return dest_frame.raw(); |
1913 } | 1916 } |
| 1917 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1914 | 1918 |
1915 | 1919 |
1916 DebuggerStackTrace* Debugger::CollectStackTrace() { | 1920 DebuggerStackTrace* Debugger::CollectStackTrace() { |
1917 Thread* thread = Thread::Current(); | 1921 Thread* thread = Thread::Current(); |
1918 Zone* zone = thread->zone(); | 1922 Zone* zone = thread->zone(); |
1919 Isolate* isolate = thread->isolate(); | 1923 Isolate* isolate = thread->isolate(); |
1920 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 1924 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
1921 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 1925 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
1922 Thread::Current(), | 1926 Thread::Current(), |
1923 StackFrameIterator::kNoCrossThreadIteration); | 1927 StackFrameIterator::kNoCrossThreadIteration); |
(...skipping 18 matching lines...) Expand all Loading... |
1942 } | 1946 } |
1943 | 1947 |
1944 void Debugger::AppendCodeFrames(Thread* thread, | 1948 void Debugger::AppendCodeFrames(Thread* thread, |
1945 Isolate* isolate, | 1949 Isolate* isolate, |
1946 Zone* zone, | 1950 Zone* zone, |
1947 DebuggerStackTrace* stack_trace, | 1951 DebuggerStackTrace* stack_trace, |
1948 StackFrame* frame, | 1952 StackFrame* frame, |
1949 Code* code, | 1953 Code* code, |
1950 Code* inlined_code, | 1954 Code* inlined_code, |
1951 Array* deopt_frame) { | 1955 Array* deopt_frame) { |
1952 if (code->is_optimized() && !FLAG_precompiled_runtime) { | 1956 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1957 if (code->is_optimized()) { |
1953 // TODO(rmacnak): Use CodeSourceMap | 1958 // TODO(rmacnak): Use CodeSourceMap |
1954 *deopt_frame = DeoptimizeToArray(thread, frame, *code); | 1959 *deopt_frame = DeoptimizeToArray(thread, frame, *code); |
1955 for (InlinedFunctionsIterator it(*code, frame->pc()); !it.Done(); | 1960 for (InlinedFunctionsIterator it(*code, frame->pc()); !it.Done(); |
1956 it.Advance()) { | 1961 it.Advance()) { |
1957 *inlined_code = it.code(); | 1962 *inlined_code = it.code(); |
1958 if (FLAG_trace_debugger_stacktrace) { | 1963 if (FLAG_trace_debugger_stacktrace) { |
1959 const Function& function = Function::Handle(zone, it.function()); | 1964 const Function& function = Function::Handle(zone, it.function()); |
1960 ASSERT(!function.IsNull()); | 1965 ASSERT(!function.IsNull()); |
1961 OS::PrintErr("CollectStackTrace: visiting inlined function: %s\n", | 1966 OS::PrintErr("CollectStackTrace: visiting inlined function: %s\n", |
1962 function.ToFullyQualifiedCString()); | 1967 function.ToFullyQualifiedCString()); |
1963 } | 1968 } |
1964 intptr_t deopt_frame_offset = it.GetDeoptFpOffset(); | 1969 intptr_t deopt_frame_offset = it.GetDeoptFpOffset(); |
1965 stack_trace->AddActivation(CollectDartFrame(isolate, it.pc(), frame, | 1970 stack_trace->AddActivation(CollectDartFrame(isolate, it.pc(), frame, |
1966 *inlined_code, *deopt_frame, | 1971 *inlined_code, *deopt_frame, |
1967 deopt_frame_offset)); | 1972 deopt_frame_offset)); |
1968 } | 1973 } |
1969 } else { | 1974 return; |
1970 stack_trace->AddActivation(CollectDartFrame( | |
1971 isolate, frame->pc(), frame, *code, Object::null_array(), 0)); | |
1972 } | 1975 } |
| 1976 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1977 stack_trace->AddActivation(CollectDartFrame(isolate, frame->pc(), frame, |
| 1978 *code, Object::null_array(), 0)); |
1973 } | 1979 } |
1974 | 1980 |
1975 | 1981 |
1976 DebuggerStackTrace* Debugger::CollectAsyncCausalStackTrace() { | 1982 DebuggerStackTrace* Debugger::CollectAsyncCausalStackTrace() { |
1977 if (!FLAG_causal_async_stacks) { | 1983 if (!FLAG_causal_async_stacks) { |
1978 return NULL; | 1984 return NULL; |
1979 } | 1985 } |
1980 Thread* thread = Thread::Current(); | 1986 Thread* thread = Thread::Current(); |
1981 Zone* zone = thread->zone(); | 1987 Zone* zone = thread->zone(); |
1982 Isolate* isolate = thread->isolate(); | 1988 Isolate* isolate = thread->isolate(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 } | 2059 } |
2054 // Follow the link. | 2060 // Follow the link. |
2055 async_stack_trace = async_stack_trace.async_link(); | 2061 async_stack_trace = async_stack_trace.async_link(); |
2056 } | 2062 } |
2057 | 2063 |
2058 return stack_trace; | 2064 return stack_trace; |
2059 } | 2065 } |
2060 | 2066 |
2061 | 2067 |
2062 DebuggerStackTrace* Debugger::CollectAwaiterReturnStackTrace() { | 2068 DebuggerStackTrace* Debugger::CollectAwaiterReturnStackTrace() { |
| 2069 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2070 // Causal async stacks are not supported in the AOT runtime. |
| 2071 ASSERT(!FLAG_async_debugger); |
| 2072 return NULL; |
| 2073 #else |
2063 if (!FLAG_async_debugger) { | 2074 if (!FLAG_async_debugger) { |
2064 return NULL; | 2075 return NULL; |
2065 } | 2076 } |
2066 // Causal async stacks are not supported in the AOT runtime. | |
2067 ASSERT(!FLAG_precompiled_runtime); | |
2068 | 2077 |
2069 Thread* thread = Thread::Current(); | 2078 Thread* thread = Thread::Current(); |
2070 Zone* zone = thread->zone(); | 2079 Zone* zone = thread->zone(); |
2071 Isolate* isolate = thread->isolate(); | 2080 Isolate* isolate = thread->isolate(); |
2072 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 2081 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
2073 | 2082 |
2074 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 2083 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
2075 Thread::Current(), | 2084 Thread::Current(), |
2076 StackFrameIterator::kNoCrossThreadIteration); | 2085 StackFrameIterator::kNoCrossThreadIteration); |
2077 | 2086 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 } else { | 2205 } else { |
2197 stack_trace->AddAsyncCausalFrame(pc, code); | 2206 stack_trace->AddAsyncCausalFrame(pc, code); |
2198 } | 2207 } |
2199 } | 2208 } |
2200 } | 2209 } |
2201 // Follow the link. | 2210 // Follow the link. |
2202 async_stack_trace = async_stack_trace.async_link(); | 2211 async_stack_trace = async_stack_trace.async_link(); |
2203 } | 2212 } |
2204 | 2213 |
2205 return stack_trace; | 2214 return stack_trace; |
| 2215 #endif // defined(DART_PRECOMPILED_RUNTIME) |
2206 } | 2216 } |
2207 | 2217 |
2208 | 2218 |
2209 ActivationFrame* Debugger::TopDartFrame() const { | 2219 ActivationFrame* Debugger::TopDartFrame() const { |
2210 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, | 2220 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames, |
2211 Thread::Current(), | 2221 Thread::Current(), |
2212 StackFrameIterator::kNoCrossThreadIteration); | 2222 StackFrameIterator::kNoCrossThreadIteration); |
2213 StackFrame* frame = iterator.NextFrame(); | 2223 StackFrame* frame = iterator.NextFrame(); |
2214 while ((frame != NULL) && !frame->IsDartFrame()) { | 2224 while ((frame != NULL) && !frame->IsDartFrame()) { |
2215 frame = iterator.NextFrame(); | 2225 frame = iterator.NextFrame(); |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4538 | 4548 |
4539 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4549 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
4540 ASSERT(bpt->next() == NULL); | 4550 ASSERT(bpt->next() == NULL); |
4541 bpt->set_next(code_breakpoints_); | 4551 bpt->set_next(code_breakpoints_); |
4542 code_breakpoints_ = bpt; | 4552 code_breakpoints_ = bpt; |
4543 } | 4553 } |
4544 | 4554 |
4545 #endif // !PRODUCT | 4555 #endif // !PRODUCT |
4546 | 4556 |
4547 } // namespace dart | 4557 } // namespace dart |
OLD | NEW |