| 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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } | 928 } |
| 929 } | 929 } |
| 930 | 930 |
| 931 | 931 |
| 932 DebuggerStackTrace* Debugger::CollectStackTrace() { | 932 DebuggerStackTrace* Debugger::CollectStackTrace() { |
| 933 Isolate* isolate = Isolate::Current(); | 933 Isolate* isolate = Isolate::Current(); |
| 934 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); | 934 DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8); |
| 935 Context& ctx = Context::Handle(isolate->top_context()); | 935 Context& ctx = Context::Handle(isolate->top_context()); |
| 936 Code& code = Code::Handle(isolate); | 936 Code& code = Code::Handle(isolate); |
| 937 StackFrameIterator iterator(false); | 937 StackFrameIterator iterator(false); |
| 938 StackFrame* frame = iterator.NextFrame(); | |
| 939 ActivationFrame* callee_activation = NULL; | 938 ActivationFrame* callee_activation = NULL; |
| 940 bool optimized_frame_found = false; | 939 bool optimized_frame_found = false; |
| 941 while (frame != NULL) { | 940 for (StackFrame* frame = iterator.NextFrame(); |
| 941 frame != NULL; |
| 942 frame = iterator.NextFrame()) { |
| 942 ASSERT(frame->IsValid()); | 943 ASSERT(frame->IsValid()); |
| 943 if (frame->IsDartFrame()) { | 944 if (frame->IsDartFrame()) { |
| 944 code = frame->LookupDartCode(); | 945 code = frame->LookupDartCode(); |
| 945 ActivationFrame* activation = | 946 ActivationFrame* activation = |
| 946 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code); | 947 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code); |
| 948 // Check if frame is a debuggable function. |
| 949 if (!IsDebuggable(activation->function())) { |
| 950 continue; |
| 951 } |
| 947 // If this activation frame called a closure, the function has | 952 // If this activation frame called a closure, the function has |
| 948 // saved its context before the call. | 953 // saved its context before the call. |
| 949 if ((callee_activation != NULL) && | 954 if ((callee_activation != NULL) && |
| 950 (callee_activation->function().IsClosureFunction())) { | 955 (callee_activation->function().IsClosureFunction())) { |
| 951 ctx = activation->GetSavedCurrentContext(); | 956 ctx = activation->GetSavedCurrentContext(); |
| 952 if (FLAG_verbose_debug && ctx.IsNull()) { | 957 if (FLAG_verbose_debug && ctx.IsNull()) { |
| 953 const Function& caller = activation->function(); | 958 const Function& caller = activation->function(); |
| 954 const Function& callee = callee_activation->function(); | 959 const Function& callee = callee_activation->function(); |
| 955 const Script& script = | 960 const Script& script = |
| 956 Script::Handle(Class::Handle(caller.Owner()).script()); | 961 Script::Handle(Class::Handle(caller.Owner()).script()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 973 activation->SetContext(ctx); | 978 activation->SetContext(ctx); |
| 974 } | 979 } |
| 975 stack_trace->AddActivation(activation); | 980 stack_trace->AddActivation(activation); |
| 976 callee_activation = activation; | 981 callee_activation = activation; |
| 977 // Get caller's context if this function saved it on entry. | 982 // Get caller's context if this function saved it on entry. |
| 978 ctx = activation->GetSavedEntryContext(ctx); | 983 ctx = activation->GetSavedEntryContext(ctx); |
| 979 } else if (frame->IsEntryFrame()) { | 984 } else if (frame->IsEntryFrame()) { |
| 980 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); | 985 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); |
| 981 callee_activation = NULL; | 986 callee_activation = NULL; |
| 982 } | 987 } |
| 983 frame = iterator.NextFrame(); | |
| 984 } | 988 } |
| 985 return stack_trace; | 989 return stack_trace; |
| 986 } | 990 } |
| 987 | 991 |
| 988 | 992 |
| 989 ActivationFrame* Debugger::TopDartFrame() const { | 993 ActivationFrame* Debugger::TopDartFrame() const { |
| 990 StackFrameIterator iterator(false); | 994 StackFrameIterator iterator(false); |
| 991 StackFrame* frame = iterator.NextFrame(); | 995 StackFrame* frame = iterator.NextFrame(); |
| 992 while ((frame != NULL) && !frame->IsDartFrame()) { | 996 while ((frame != NULL) && !frame->IsDartFrame()) { |
| 993 frame = iterator.NextFrame(); | 997 frame = iterator.NextFrame(); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 event_handler_ = handler; | 1531 event_handler_ = handler; |
| 1528 } | 1532 } |
| 1529 | 1533 |
| 1530 | 1534 |
| 1531 bool Debugger::IsDebuggable(const Function& func) { | 1535 bool Debugger::IsDebuggable(const Function& func) { |
| 1532 RawFunction::Kind fkind = func.kind(); | 1536 RawFunction::Kind fkind = func.kind(); |
| 1533 if ((fkind == RawFunction::kImplicitGetter) || | 1537 if ((fkind == RawFunction::kImplicitGetter) || |
| 1534 (fkind == RawFunction::kImplicitSetter) || | 1538 (fkind == RawFunction::kImplicitSetter) || |
| 1535 (fkind == RawFunction::kConstImplicitGetter) || | 1539 (fkind == RawFunction::kConstImplicitGetter) || |
| 1536 (fkind == RawFunction::kMethodExtractor) || | 1540 (fkind == RawFunction::kMethodExtractor) || |
| 1537 (fkind == RawFunction::kNoSuchMethodDispatcher)) { | 1541 (fkind == RawFunction::kNoSuchMethodDispatcher) || |
| 1542 (fkind == RawFunction::kInvokeFieldDispatcher)) { |
| 1538 return false; | 1543 return false; |
| 1539 } | 1544 } |
| 1540 const Class& cls = Class::Handle(func.Owner()); | 1545 const Class& cls = Class::Handle(func.Owner()); |
| 1541 const Library& lib = Library::Handle(cls.library()); | 1546 const Library& lib = Library::Handle(cls.library()); |
| 1542 return lib.IsDebuggable(); | 1547 return lib.IsDebuggable(); |
| 1543 } | 1548 } |
| 1544 | 1549 |
| 1545 | 1550 |
| 1546 void Debugger::SignalPausedEvent(ActivationFrame* top_frame) { | 1551 void Debugger::SignalPausedEvent(ActivationFrame* top_frame) { |
| 1547 resume_action_ = kContinue; | 1552 resume_action_ = kContinue; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 } | 1860 } |
| 1856 | 1861 |
| 1857 | 1862 |
| 1858 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1863 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1859 ASSERT(bpt->next() == NULL); | 1864 ASSERT(bpt->next() == NULL); |
| 1860 bpt->set_next(code_breakpoints_); | 1865 bpt->set_next(code_breakpoints_); |
| 1861 code_breakpoints_ = bpt; | 1866 code_breakpoints_ = bpt; |
| 1862 } | 1867 } |
| 1863 | 1868 |
| 1864 } // namespace dart | 1869 } // namespace dart |
| OLD | NEW |