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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 if (bpt_location_->IsResolved()) { | 224 if (bpt_location_->IsResolved()) { |
225 jsobj.AddLocation(bpt_location_); | 225 jsobj.AddLocation(bpt_location_); |
226 } else { | 226 } else { |
227 jsobj.AddUnresolvedLocation(bpt_location_); | 227 jsobj.AddUnresolvedLocation(bpt_location_); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 232 void CodeBreakpoint::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
233 visitor->VisitPointer(reinterpret_cast<RawObject**>(&code_)); | 233 visitor->VisitPointer(reinterpret_cast<RawObject**>(&code_)); |
| 234 #if !defined(TARGET_ARCH_DBC) |
234 visitor->VisitPointer(reinterpret_cast<RawObject**>(&saved_value_)); | 235 visitor->VisitPointer(reinterpret_cast<RawObject**>(&saved_value_)); |
| 236 #endif |
235 } | 237 } |
236 | 238 |
237 | 239 |
238 ActivationFrame::ActivationFrame( | 240 ActivationFrame::ActivationFrame( |
239 uword pc, | 241 uword pc, |
240 uword fp, | 242 uword fp, |
241 uword sp, | 243 uword sp, |
242 const Code& code, | 244 const Code& code, |
243 const Array& deopt_frame, | 245 const Array& deopt_frame, |
244 intptr_t deopt_frame_offset) | 246 intptr_t deopt_frame_offset) |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 vars_initialized_ = true; | 854 vars_initialized_ = true; |
853 } | 855 } |
854 | 856 |
855 | 857 |
856 intptr_t ActivationFrame::NumLocalVariables() { | 858 intptr_t ActivationFrame::NumLocalVariables() { |
857 GetDescIndices(); | 859 GetDescIndices(); |
858 return desc_indices_.length(); | 860 return desc_indices_.length(); |
859 } | 861 } |
860 | 862 |
861 | 863 |
| 864 DART_FORCE_INLINE static RawObject* GetVariableValue(uword addr) { |
| 865 return *reinterpret_cast<RawObject**>(addr); |
| 866 } |
| 867 |
| 868 |
862 RawObject* ActivationFrame::GetParameter(intptr_t index) { | 869 RawObject* ActivationFrame::GetParameter(intptr_t index) { |
863 intptr_t num_parameters = function().num_fixed_parameters(); | 870 intptr_t num_parameters = function().num_fixed_parameters(); |
864 ASSERT(0 <= index && index < num_parameters); | 871 ASSERT(0 <= index && index < num_parameters); |
865 intptr_t reverse_index = num_parameters - index; | |
866 | 872 |
867 if (function().NumOptionalParameters() > 0) { | 873 if (function().NumOptionalParameters() > 0) { |
868 // If the function has optional parameters, the first positional parameter | 874 // If the function has optional parameters, the first positional parameter |
869 // can be in a number of places in the caller's frame depending on how many | 875 // can be in a number of places in the caller's frame depending on how many |
870 // were actually supplied at the call site, but they are copied to a fixed | 876 // were actually supplied at the call site, but they are copied to a fixed |
871 // place in the callee's frame. | 877 // place in the callee's frame. |
872 uword var_address = fp() + ((kFirstLocalSlotFromFp - index) * kWordSize); | 878 return GetVariableValue(LocalVarAddress(fp(), |
873 return reinterpret_cast<RawObject*>( | 879 (kFirstLocalSlotFromFp - index))); |
874 *reinterpret_cast<uword*>(var_address)); | |
875 } else { | 880 } else { |
876 uword var_address = fp() + (kParamEndSlotFromFp * kWordSize) | 881 intptr_t reverse_index = num_parameters - index; |
877 + (reverse_index * kWordSize); | 882 return GetVariableValue(ParamAddress(fp(), reverse_index)); |
878 return reinterpret_cast<RawObject*>( | |
879 *reinterpret_cast<uword*>(var_address)); | |
880 } | 883 } |
881 } | 884 } |
882 | 885 |
883 | 886 |
884 RawObject* ActivationFrame::GetClosure() { | 887 RawObject* ActivationFrame::GetClosure() { |
885 ASSERT(function().IsClosureFunction()); | 888 ASSERT(function().IsClosureFunction()); |
886 return GetParameter(0); | 889 return GetParameter(0); |
887 } | 890 } |
888 | 891 |
889 | 892 |
890 RawObject* ActivationFrame::GetStackVar(intptr_t slot_index) { | 893 RawObject* ActivationFrame::GetStackVar(intptr_t slot_index) { |
891 if (deopt_frame_.IsNull()) { | 894 if (deopt_frame_.IsNull()) { |
892 uword var_address = fp() + slot_index * kWordSize; | 895 return GetVariableValue(LocalVarAddress(fp(), slot_index)); |
893 return reinterpret_cast<RawObject*>( | |
894 *reinterpret_cast<uword*>(var_address)); | |
895 } else { | 896 } else { |
896 return deopt_frame_.At(deopt_frame_offset_ + slot_index); | 897 return deopt_frame_.At(deopt_frame_offset_ + slot_index); |
897 } | 898 } |
898 } | 899 } |
899 | 900 |
900 | 901 |
901 void ActivationFrame::PrintContextMismatchError( | 902 void ActivationFrame::PrintContextMismatchError( |
902 intptr_t ctx_slot, | 903 intptr_t ctx_slot, |
903 intptr_t frame_ctx_level, | 904 intptr_t frame_ctx_level, |
904 intptr_t var_ctx_level) { | 905 intptr_t var_ctx_level) { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 uword pc, | 1165 uword pc, |
1165 RawPcDescriptors::Kind kind) | 1166 RawPcDescriptors::Kind kind) |
1166 : code_(code.raw()), | 1167 : code_(code.raw()), |
1167 token_pos_(token_pos), | 1168 token_pos_(token_pos), |
1168 pc_(pc), | 1169 pc_(pc), |
1169 line_number_(-1), | 1170 line_number_(-1), |
1170 is_enabled_(false), | 1171 is_enabled_(false), |
1171 bpt_location_(NULL), | 1172 bpt_location_(NULL), |
1172 next_(NULL), | 1173 next_(NULL), |
1173 breakpoint_kind_(kind), | 1174 breakpoint_kind_(kind), |
1174 saved_value_(Code::null()) { | 1175 #if !defined(TARGET_ARCH_DBC) |
| 1176 saved_value_(Code::null()) |
| 1177 #else |
| 1178 saved_value_(Bytecode::kTrap) |
| 1179 #endif |
| 1180 { |
1175 ASSERT(!code.IsNull()); | 1181 ASSERT(!code.IsNull()); |
1176 ASSERT(token_pos_.IsReal()); | 1182 ASSERT(token_pos_.IsReal()); |
1177 ASSERT(pc_ != 0); | 1183 ASSERT(pc_ != 0); |
1178 ASSERT((breakpoint_kind_ & kSafepointKind) != 0); | 1184 ASSERT((breakpoint_kind_ & kSafepointKind) != 0); |
1179 } | 1185 } |
1180 | 1186 |
1181 | 1187 |
1182 CodeBreakpoint::~CodeBreakpoint() { | 1188 CodeBreakpoint::~CodeBreakpoint() { |
1183 // Make sure we don't leave patched code behind. | 1189 // Make sure we don't leave patched code behind. |
1184 ASSERT(!IsEnabled()); | 1190 ASSERT(!IsEnabled()); |
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2686 // interested in. If we saved the frame pointer of a stack frame | 2692 // interested in. If we saved the frame pointer of a stack frame |
2687 // the user is interested in, we ignore the single step if we are | 2693 // the user is interested in, we ignore the single step if we are |
2688 // in a callee of that frame. Note that we assume that the stack | 2694 // in a callee of that frame. Note that we assume that the stack |
2689 // grows towards lower addresses. | 2695 // grows towards lower addresses. |
2690 ActivationFrame* frame = TopDartFrame(); | 2696 ActivationFrame* frame = TopDartFrame(); |
2691 ASSERT(frame != NULL); | 2697 ASSERT(frame != NULL); |
2692 | 2698 |
2693 if (stepping_fp_ != 0) { | 2699 if (stepping_fp_ != 0) { |
2694 // There is an "interesting frame" set. Only pause at appropriate | 2700 // There is an "interesting frame" set. Only pause at appropriate |
2695 // locations in this frame. | 2701 // locations in this frame. |
2696 if (stepping_fp_ > frame->fp()) { | 2702 if (IsCalleeFrameOf(stepping_fp_, frame->fp())) { |
2697 // We are i n a callee of the frame we're interested in. | 2703 // We are i n a callee of the frame we're interested in. |
2698 // Ignore this stepping break. | 2704 // Ignore this stepping break. |
2699 return Error::null(); | 2705 return Error::null(); |
2700 } else if (frame->fp() > stepping_fp_) { | 2706 } else if (IsCalleeFrameOf(frame->fp(), stepping_fp_)) { |
2701 // We returned from the "interesting frame", there can be no more | 2707 // We returned from the "interesting frame", there can be no more |
2702 // stepping breaks for it. Pause at the next appropriate location | 2708 // stepping breaks for it. Pause at the next appropriate location |
2703 // and let the user set the "interesting" frame again. | 2709 // and let the user set the "interesting" frame again. |
2704 stepping_fp_ = 0; | 2710 stepping_fp_ = 0; |
2705 } | 2711 } |
2706 } | 2712 } |
2707 | 2713 |
2708 if (!frame->IsDebuggable()) { | 2714 if (!frame->IsDebuggable()) { |
2709 return Error::null(); | 2715 return Error::null(); |
2710 } | 2716 } |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 | 3353 |
3348 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 3354 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
3349 ASSERT(bpt->next() == NULL); | 3355 ASSERT(bpt->next() == NULL); |
3350 bpt->set_next(code_breakpoints_); | 3356 bpt->set_next(code_breakpoints_); |
3351 code_breakpoints_ = bpt; | 3357 code_breakpoints_ = bpt; |
3352 } | 3358 } |
3353 | 3359 |
3354 #endif // !PRODUCT | 3360 #endif // !PRODUCT |
3355 | 3361 |
3356 } // namespace dart | 3362 } // namespace dart |
OLD | NEW |