Chromium Code Reviews| 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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 } | 893 } |
| 894 | 894 |
| 895 | 895 |
| 896 DebuggerStackTrace* Debugger::CollectStackTrace() { | 896 DebuggerStackTrace* Debugger::CollectStackTrace() { |
| 897 Isolate* isolate = Isolate::Current(); | 897 Isolate* isolate = Isolate::Current(); |
| 898 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 898 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
| 899 Context& ctx = Context::Handle(isolate->top_context()); | 899 Context& ctx = Context::Handle(isolate->top_context()); |
| 900 Code& code = Code::Handle(isolate); | 900 Code& code = Code::Handle(isolate); |
| 901 StackFrameIterator iterator(false); | 901 StackFrameIterator iterator(false); |
| 902 StackFrame* frame = iterator.NextFrame(); | 902 StackFrame* frame = iterator.NextFrame(); |
| 903 ActivationFrame* callee_activation = NULL; | |
| 903 bool optimized_frame_found = false; | 904 bool optimized_frame_found = false; |
| 904 while (frame != NULL) { | 905 while (frame != NULL) { |
| 905 ASSERT(frame->IsValid()); | 906 ASSERT(frame->IsValid()); |
| 906 if (frame->IsDartFrame()) { | 907 if (frame->IsDartFrame()) { |
| 907 code = frame->LookupDartCode(); | 908 code = frame->LookupDartCode(); |
| 908 ActivationFrame* activation = new ActivationFrame(frame->pc(), | 909 ActivationFrame* activation = new ActivationFrame(frame->pc(), |
| 909 frame->fp(), | 910 frame->fp(), |
| 910 frame->sp(), | 911 frame->sp(), |
| 911 code); | 912 code); |
| 912 // If this activation frame called a closure, the function has | 913 // If this activation frame called a closure, the function has |
| 913 // saved its context before the call. | 914 // saved its context before the call. |
| 914 if (stack_trace->Length() > 0) { | 915 if ((callee_activation != NULL) && |
| 915 ActivationFrame* callee_frame = | 916 (callee_activation->function().IsClosureFunction())) { |
| 916 stack_trace->ActivationFrameAt(stack_trace->Length() - 1); | 917 ctx = activation->GetSavedCurrentContext(); |
| 917 if (callee_frame->function().IsClosureFunction()) { | 918 if (FLAG_verbose_debug && ctx.IsNull()) { |
| 918 ctx = activation->GetSavedCurrentContext(); | 919 const Function& caller = activation->function(); |
| 919 if (FLAG_verbose_debug && ctx.IsNull()) { | 920 const Function& callee = callee_activation->function(); |
| 920 const Function& caller = activation->function(); | 921 const Script& script = |
| 921 const Function& callee = callee_frame->function(); | 922 Script::Handle(Class::Handle(caller.Owner()).script()); |
| 922 const Script& script = | 923 intptr_t line, col; |
| 923 Script::Handle(Class::Handle(caller.Owner()).script()); | 924 script.GetTokenLocation(activation->TokenPos(), &line, &col); |
| 924 intptr_t line, col; | 925 printf("CollectStackTrace error: no saved context in function " |
|
siva
2013/05/01 18:21:19
maybe use OS::Print here.
hausner
2013/05/01 18:32:53
Yes.
| |
| 925 script.GetTokenLocation(activation->TokenPos(), &line, &col); | 926 "'%s' which calls closure '%s' " |
| 926 printf("CollectStackTrace error: no saved context in function " | 927 " in line %"Pd" column %"Pd"\n", |
| 927 "'%s' which calls closure '%s' " | 928 caller.ToFullyQualifiedCString(), |
| 928 " in line %"Pd" column %"Pd"\n", | 929 callee.ToFullyQualifiedCString(), |
| 929 caller.ToFullyQualifiedCString(), | 930 line, col); |
| 930 callee.ToFullyQualifiedCString(), | |
| 931 line, col); | |
| 932 } | |
| 933 ASSERT(!ctx.IsNull()); | |
| 934 } | 931 } |
| 932 ASSERT(!ctx.IsNull()); | |
| 935 } | 933 } |
| 936 if (optimized_frame_found || code.is_optimized()) { | 934 if (optimized_frame_found || code.is_optimized()) { |
| 937 // Set context to null, to avoid returning bad context variable values. | 935 // Set context to null, to avoid returning bad context variable values. |
| 938 activation->SetContext(Context::Handle()); | 936 activation->SetContext(Context::Handle()); |
| 939 optimized_frame_found = true; | 937 optimized_frame_found = true; |
| 940 } else { | 938 } else { |
| 941 activation->SetContext(ctx); | 939 activation->SetContext(ctx); |
| 942 } | 940 } |
| 943 stack_trace->AddActivation(activation); | 941 stack_trace->AddActivation(activation); |
| 942 callee_activation = activation; | |
| 944 // Get caller's context if this function saved it on entry. | 943 // Get caller's context if this function saved it on entry. |
| 945 ctx = activation->GetSavedEntryContext(ctx); | 944 ctx = activation->GetSavedEntryContext(ctx); |
| 946 } else if (frame->IsEntryFrame()) { | 945 } else if (frame->IsEntryFrame()) { |
| 947 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); | 946 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); |
| 947 callee_activation = NULL; | |
| 948 } | 948 } |
| 949 frame = iterator.NextFrame(); | 949 frame = iterator.NextFrame(); |
| 950 } | 950 } |
| 951 return stack_trace; | 951 return stack_trace; |
| 952 } | 952 } |
| 953 | 953 |
| 954 | 954 |
| 955 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { | 955 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { |
| 956 ASSERT((pause_info == kNoPauseOnExceptions) || | 956 ASSERT((pause_info == kNoPauseOnExceptions) || |
| 957 (pause_info == kPauseOnUnhandledExceptions) || | 957 (pause_info == kPauseOnUnhandledExceptions) || |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1781 } | 1781 } |
| 1782 | 1782 |
| 1783 | 1783 |
| 1784 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1784 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1785 ASSERT(bpt->next() == NULL); | 1785 ASSERT(bpt->next() == NULL); |
| 1786 bpt->set_next(code_breakpoints_); | 1786 bpt->set_next(code_breakpoints_); |
| 1787 code_breakpoints_ = bpt; | 1787 code_breakpoints_ = bpt; |
| 1788 } | 1788 } |
| 1789 | 1789 |
| 1790 } // namespace dart | 1790 } // namespace dart |
| OLD | NEW |