| 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 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 ActivationFrame* callee_activation = NULL; | 942 ActivationFrame* callee_activation = NULL; |
| 943 bool optimized_frame_found = false; | 943 bool optimized_frame_found = false; |
| 944 for (StackFrame* frame = iterator.NextFrame(); | 944 for (StackFrame* frame = iterator.NextFrame(); |
| 945 frame != NULL; | 945 frame != NULL; |
| 946 frame = iterator.NextFrame()) { | 946 frame = iterator.NextFrame()) { |
| 947 ASSERT(frame->IsValid()); | 947 ASSERT(frame->IsValid()); |
| 948 if (frame->IsDartFrame()) { | 948 if (frame->IsDartFrame()) { |
| 949 code = frame->LookupDartCode(); | 949 code = frame->LookupDartCode(); |
| 950 ActivationFrame* activation = | 950 ActivationFrame* activation = |
| 951 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code); | 951 new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code); |
| 952 // Check if frame is a debuggable function. | |
| 953 if (!IsDebuggable(activation->function())) { | |
| 954 continue; | |
| 955 } | |
| 956 // If this activation frame called a closure, the function has | 952 // If this activation frame called a closure, the function has |
| 957 // saved its context before the call. | 953 // saved its context before the call. |
| 958 if ((callee_activation != NULL) && | 954 if ((callee_activation != NULL) && |
| 959 (callee_activation->function().IsClosureFunction())) { | 955 (callee_activation->function().IsClosureFunction())) { |
| 960 ctx = activation->GetSavedCurrentContext(); | 956 ctx = activation->GetSavedCurrentContext(); |
| 961 if (FLAG_verbose_debug && ctx.IsNull()) { | 957 if (FLAG_verbose_debug && ctx.IsNull()) { |
| 962 const Function& caller = activation->function(); | 958 const Function& caller = activation->function(); |
| 963 const Function& callee = callee_activation->function(); | 959 const Function& callee = callee_activation->function(); |
| 964 const Script& script = | 960 const Script& script = |
| 965 Script::Handle(Class::Handle(caller.Owner()).script()); | 961 Script::Handle(Class::Handle(caller.Owner()).script()); |
| 966 intptr_t line, col; | 962 intptr_t line, col; |
| 967 script.GetTokenLocation(activation->TokenPos(), &line, &col); | 963 script.GetTokenLocation(activation->TokenPos(), &line, &col); |
| 968 OS::Print("CollectStackTrace error: no saved context in function " | 964 OS::Print("CollectStackTrace error: no saved context in function " |
| 969 "'%s' which calls closure '%s' " | 965 "'%s' which calls closure '%s' " |
| 970 " in line %"Pd" column %"Pd"\n", | 966 " in line %"Pd" column %"Pd"\n", |
| 971 caller.ToFullyQualifiedCString(), | 967 caller.ToFullyQualifiedCString(), |
| 972 callee.ToFullyQualifiedCString(), | 968 callee.ToFullyQualifiedCString(), |
| 973 line, col); | 969 line, col); |
| 974 } | 970 } |
| 975 ASSERT(!ctx.IsNull()); | |
| 976 } | 971 } |
| 977 if (optimized_frame_found || code.is_optimized()) { | 972 if (optimized_frame_found || code.is_optimized()) { |
| 978 // Set context to null, to avoid returning bad context variable values. | 973 // Set context to null, to avoid returning bad context variable values. |
| 979 activation->SetContext(Context::Handle()); | 974 activation->SetContext(Context::Handle()); |
| 980 optimized_frame_found = true; | 975 optimized_frame_found = true; |
| 981 } else { | 976 } else { |
| 977 ASSERT(!ctx.IsNull()); |
| 982 activation->SetContext(ctx); | 978 activation->SetContext(ctx); |
| 983 } | 979 } |
| 984 stack_trace->AddActivation(activation); | 980 // Check if frame is a debuggable function. |
| 981 if (IsDebuggable(activation->function())) { |
| 982 stack_trace->AddActivation(activation); |
| 983 } |
| 985 callee_activation = activation; | 984 callee_activation = activation; |
| 986 // Get caller's context if this function saved it on entry. | 985 // Get caller's context if this function saved it on entry. |
| 987 ctx = activation->GetSavedEntryContext(ctx); | 986 ctx = activation->GetSavedEntryContext(ctx); |
| 988 } else if (frame->IsEntryFrame()) { | 987 } else if (frame->IsEntryFrame()) { |
| 989 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); | 988 ctx = reinterpret_cast<EntryFrame*>(frame)->SavedContext(); |
| 990 callee_activation = NULL; | 989 callee_activation = NULL; |
| 991 } | 990 } |
| 992 } | 991 } |
| 993 return stack_trace; | 992 return stack_trace; |
| 994 } | 993 } |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 } | 1863 } |
| 1865 | 1864 |
| 1866 | 1865 |
| 1867 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1866 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1868 ASSERT(bpt->next() == NULL); | 1867 ASSERT(bpt->next() == NULL); |
| 1869 bpt->set_next(code_breakpoints_); | 1868 bpt->set_next(code_breakpoints_); |
| 1870 code_breakpoints_ = bpt; | 1869 code_breakpoints_ = bpt; |
| 1871 } | 1870 } |
| 1872 | 1871 |
| 1873 } // namespace dart | 1872 } // namespace dart |
| OLD | NEW |