| 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 ASSERT(context_level_ >= 0); | 709 ASSERT(context_level_ >= 0); |
| 710 } | 710 } |
| 711 return context_level_; | 711 return context_level_; |
| 712 } | 712 } |
| 713 | 713 |
| 714 | 714 |
| 715 RawObject* ActivationFrame::GetAsyncContextVariable(const String& name) { | 715 RawObject* ActivationFrame::GetAsyncContextVariable(const String& name) { |
| 716 if (!function_.IsAsyncClosure()) { | 716 if (!function_.IsAsyncClosure() && !function_.IsAsyncGenClosure()) { |
| 717 return Object::null(); | 717 return Object::null(); |
| 718 } | 718 } |
| 719 GetVarDescriptors(); | 719 GetVarDescriptors(); |
| 720 intptr_t var_desc_len = var_descriptors_.Length(); | 720 intptr_t var_desc_len = var_descriptors_.Length(); |
| 721 for (intptr_t i = 0; i < var_desc_len; i++) { | 721 for (intptr_t i = 0; i < var_desc_len; i++) { |
| 722 RawLocalVarDescriptors::VarInfo var_info; | 722 RawLocalVarDescriptors::VarInfo var_info; |
| 723 var_descriptors_.GetInfo(i, &var_info); | 723 var_descriptors_.GetInfo(i, &var_info); |
| 724 if (var_descriptors_.GetName(i) == name.raw()) { | 724 if (var_descriptors_.GetName(i) == name.raw()) { |
| 725 const int8_t kind = var_info.kind(); | 725 const int8_t kind = var_info.kind(); |
| 726 if (!live_frame_) { | 726 if (!live_frame_) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 ASSERT(!stream_cls.IsNull()); | 778 ASSERT(!stream_cls.IsNull()); |
| 779 const Class& stream_impl_cls = Class::Handle(stream_cls.SuperClass()); | 779 const Class& stream_impl_cls = Class::Handle(stream_cls.SuperClass()); |
| 780 const Field& awaiter_field = Field::Handle( | 780 const Field& awaiter_field = Field::Handle( |
| 781 stream_impl_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); | 781 stream_impl_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); |
| 782 ASSERT(!awaiter_field.IsNull()); | 782 ASSERT(!awaiter_field.IsNull()); |
| 783 return Instance::Cast(stream).GetField(awaiter_field); | 783 return Instance::Cast(stream).GetField(awaiter_field); |
| 784 } | 784 } |
| 785 | 785 |
| 786 | 786 |
| 787 RawObject* ActivationFrame::GetAsyncAwaiter() { | 787 RawObject* ActivationFrame::GetAsyncAwaiter() { |
| 788 const Object& completer = Object::Handle(GetAsyncCompleter()); | |
| 789 if (!completer.IsNull()) { | |
| 790 return GetAsyncCompleterAwaiter(completer); | |
| 791 } | |
| 792 const Object& async_stream_controller_stream = | 788 const Object& async_stream_controller_stream = |
| 793 Object::Handle(GetAsyncStreamControllerStream()); | 789 Object::Handle(GetAsyncStreamControllerStream()); |
| 794 if (!async_stream_controller_stream.IsNull()) { | 790 if (!async_stream_controller_stream.IsNull()) { |
| 795 return GetAsyncStreamControllerStreamAwaiter( | 791 return GetAsyncStreamControllerStreamAwaiter( |
| 796 async_stream_controller_stream); | 792 async_stream_controller_stream); |
| 797 } | 793 } |
| 794 const Object& completer = Object::Handle(GetAsyncCompleter()); |
| 795 if (!completer.IsNull()) { |
| 796 return GetAsyncCompleterAwaiter(completer); |
| 797 } |
| 798 return Object::null(); | 798 return Object::null(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| 802 bool ActivationFrame::HandlesException(const Instance& exc_obj) { | 802 bool ActivationFrame::HandlesException(const Instance& exc_obj) { |
| 803 intptr_t try_index = TryIndex(); | 803 intptr_t try_index = TryIndex(); |
| 804 if (try_index < 0) { | 804 if (try_index < 0) { |
| 805 return false; | 805 return false; |
| 806 } | 806 } |
| 807 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); | 807 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3134 } else if (resume_action_ == kStepOver) { | 3134 } else if (resume_action_ == kStepOver) { |
| 3135 DeoptimizeWorld(); | 3135 DeoptimizeWorld(); |
| 3136 isolate_->set_single_step(true); | 3136 isolate_->set_single_step(true); |
| 3137 skip_next_step_ = skip_next_step; | 3137 skip_next_step_ = skip_next_step; |
| 3138 ASSERT(stack_trace->Length() > 0); | 3138 ASSERT(stack_trace->Length() > 0); |
| 3139 stepping_fp_ = stack_trace->FrameAt(0)->fp(); | 3139 stepping_fp_ = stack_trace->FrameAt(0)->fp(); |
| 3140 if (FLAG_verbose_debug) { | 3140 if (FLAG_verbose_debug) { |
| 3141 OS::Print("HandleSteppingRequest- kStepOver %" Px "\n", stepping_fp_); | 3141 OS::Print("HandleSteppingRequest- kStepOver %" Px "\n", stepping_fp_); |
| 3142 } | 3142 } |
| 3143 } else if (resume_action_ == kStepOut) { | 3143 } else if (resume_action_ == kStepOut) { |
| 3144 if (FLAG_async_debugger_stepping) { |
| 3145 if (stack_trace->FrameAt(0)->function().IsAsyncClosure() || |
| 3146 stack_trace->FrameAt(0)->function().IsAsyncGenClosure()) { |
| 3147 // Request to step out of an async/async* closure. |
| 3148 const Object& async_op = |
| 3149 Object::Handle(stack_trace->FrameAt(0)->GetAsyncAwaiter()); |
| 3150 if (!async_op.IsNull()) { |
| 3151 // Step out to the awaiter. |
| 3152 ASSERT(async_op.IsClosure()); |
| 3153 AsyncStepInto(Closure::Cast(async_op)); |
| 3154 return; |
| 3155 } |
| 3156 } |
| 3157 } |
| 3158 // Fall through to synchronous stepping. |
| 3144 DeoptimizeWorld(); | 3159 DeoptimizeWorld(); |
| 3145 isolate_->set_single_step(true); | 3160 isolate_->set_single_step(true); |
| 3146 // Find topmost caller that is debuggable. | 3161 // Find topmost caller that is debuggable. |
| 3147 for (intptr_t i = 1; i < stack_trace->Length(); i++) { | 3162 for (intptr_t i = 1; i < stack_trace->Length(); i++) { |
| 3148 ActivationFrame* frame = stack_trace->FrameAt(i); | 3163 ActivationFrame* frame = stack_trace->FrameAt(i); |
| 3149 if (frame->IsDebuggable()) { | 3164 if (frame->IsDebuggable()) { |
| 3150 stepping_fp_ = frame->fp(); | 3165 stepping_fp_ = frame->fp(); |
| 3151 break; | 3166 break; |
| 3152 } | 3167 } |
| 3153 } | 3168 } |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4103 loc = loc->next(); | 4118 loc = loc->next(); |
| 4104 } | 4119 } |
| 4105 return NULL; | 4120 return NULL; |
| 4106 } | 4121 } |
| 4107 | 4122 |
| 4108 | 4123 |
| 4109 void Debugger::MaybeAsyncStepInto(const Closure& async_op) { | 4124 void Debugger::MaybeAsyncStepInto(const Closure& async_op) { |
| 4110 if (FLAG_async_debugger_stepping && IsSingleStepping()) { | 4125 if (FLAG_async_debugger_stepping && IsSingleStepping()) { |
| 4111 // We are single stepping, set a breakpoint on the closure activation | 4126 // We are single stepping, set a breakpoint on the closure activation |
| 4112 // and resume execution so we can hit the breakpoint. | 4127 // and resume execution so we can hit the breakpoint. |
| 4113 SetBreakpointAtActivation(async_op, true); | 4128 AsyncStepInto(async_op); |
| 4114 Continue(); | |
| 4115 } | 4129 } |
| 4116 } | 4130 } |
| 4117 | 4131 |
| 4118 | 4132 |
| 4133 void Debugger::AsyncStepInto(const Closure& async_op) { |
| 4134 SetBreakpointAtActivation(async_op, true); |
| 4135 Continue(); |
| 4136 } |
| 4137 |
| 4138 |
| 4119 void Debugger::Continue() { | 4139 void Debugger::Continue() { |
| 4120 SetResumeAction(kContinue); | 4140 SetResumeAction(kContinue); |
| 4121 stepping_fp_ = 0; | 4141 stepping_fp_ = 0; |
| 4122 isolate_->set_single_step(false); | 4142 isolate_->set_single_step(false); |
| 4123 } | 4143 } |
| 4124 | 4144 |
| 4125 | 4145 |
| 4126 BreakpointLocation* Debugger::GetLatentBreakpoint(const String& url, | 4146 BreakpointLocation* Debugger::GetLatentBreakpoint(const String& url, |
| 4127 intptr_t line, | 4147 intptr_t line, |
| 4128 intptr_t column) { | 4148 intptr_t column) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4153 | 4173 |
| 4154 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4174 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 4155 ASSERT(bpt->next() == NULL); | 4175 ASSERT(bpt->next() == NULL); |
| 4156 bpt->set_next(code_breakpoints_); | 4176 bpt->set_next(code_breakpoints_); |
| 4157 code_breakpoints_ = bpt; | 4177 code_breakpoints_ = bpt; |
| 4158 } | 4178 } |
| 4159 | 4179 |
| 4160 #endif // !PRODUCT | 4180 #endif // !PRODUCT |
| 4161 | 4181 |
| 4162 } // namespace dart | 4182 } // namespace dart |
| OLD | NEW |