| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 651 } |
| 652 | 652 |
| 653 | 653 |
| 654 void CodeBreakpoint::PatchCode() { | 654 void CodeBreakpoint::PatchCode() { |
| 655 ASSERT(!is_enabled_); | 655 ASSERT(!is_enabled_); |
| 656 switch (breakpoint_kind_) { | 656 switch (breakpoint_kind_) { |
| 657 case PcDescriptors::kIcCall: { | 657 case PcDescriptors::kIcCall: { |
| 658 const Code& code = | 658 const Code& code = |
| 659 Code::Handle(Function::Handle(function_).unoptimized_code()); | 659 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 660 saved_bytes_.target_address_ = | 660 saved_bytes_.target_address_ = |
| 661 CodePatcher::GetInstanceCallAt(pc_, code, NULL, NULL); | 661 CodePatcher::GetInstanceCallAt(pc_, code, NULL); |
| 662 CodePatcher::PatchInstanceCallAt(pc_, code, | 662 CodePatcher::PatchInstanceCallAt(pc_, code, |
| 663 StubCode::BreakpointDynamicEntryPoint()); | 663 StubCode::BreakpointDynamicEntryPoint()); |
| 664 break; | 664 break; |
| 665 } | 665 } |
| 666 case PcDescriptors::kFuncCall: { | 666 case PcDescriptors::kFuncCall: { |
| 667 const Code& code = | 667 const Code& code = |
| 668 Code::Handle(Function::Handle(function_).unoptimized_code()); | 668 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 669 saved_bytes_.target_address_ = | 669 saved_bytes_.target_address_ = |
| 670 CodePatcher::GetStaticCallTargetAt(pc_, code); | 670 CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 671 CodePatcher::PatchStaticCallAt(pc_, code, | 671 CodePatcher::PatchStaticCallAt(pc_, code, |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); | 1558 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); |
| 1559 func_to_instrument = caller_frame->function().raw(); | 1559 func_to_instrument = caller_frame->function().raw(); |
| 1560 } | 1560 } |
| 1561 } | 1561 } |
| 1562 } else if (resume_action_ == kStepInto) { | 1562 } else if (resume_action_ == kStepInto) { |
| 1563 // If the call target is not debuggable, we treat StepInto like | 1563 // If the call target is not debuggable, we treat StepInto like |
| 1564 // a StepOver, that is we instrument the current function. | 1564 // a StepOver, that is we instrument the current function. |
| 1565 if (bpt->breakpoint_kind_ == PcDescriptors::kIcCall) { | 1565 if (bpt->breakpoint_kind_ == PcDescriptors::kIcCall) { |
| 1566 func_to_instrument = bpt->function(); | 1566 func_to_instrument = bpt->function(); |
| 1567 ICData& ic_data = ICData::Handle(); | 1567 ICData& ic_data = ICData::Handle(); |
| 1568 Array& descriptor = Array::Handle(); | |
| 1569 const Code& code = | 1568 const Code& code = |
| 1570 Code::Handle(Function::Handle(bpt->function_).unoptimized_code()); | 1569 Code::Handle(Function::Handle(bpt->function_).unoptimized_code()); |
| 1571 CodePatcher::GetInstanceCallAt(bpt->pc_, code, &ic_data, &descriptor); | 1570 CodePatcher::GetInstanceCallAt(bpt->pc_, code, &ic_data); |
| 1572 ArgumentsDescriptor args_descriptor(descriptor); | 1571 ArgumentsDescriptor |
| 1572 args_descriptor(Array::Handle(ic_data.arguments_descriptor())); |
| 1573 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); | 1573 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); |
| 1574 intptr_t num_args = args_descriptor.Count(); | 1574 intptr_t num_args = args_descriptor.Count(); |
| 1575 Instance& receiver = | 1575 Instance& receiver = |
| 1576 Instance::Handle(top_frame->GetInstanceCallReceiver(num_args)); | 1576 Instance::Handle(top_frame->GetInstanceCallReceiver(num_args)); |
| 1577 Code& target_code = | 1577 Code& target_code = |
| 1578 Code::Handle(ResolveCompileInstanceCallTarget(receiver, | 1578 Code::Handle(ResolveCompileInstanceCallTarget(receiver, ic_data)); |
| 1579 ic_data, | |
| 1580 descriptor)); | |
| 1581 if (!target_code.IsNull()) { | 1579 if (!target_code.IsNull()) { |
| 1582 Function& callee = Function::Handle(target_code.function()); | 1580 Function& callee = Function::Handle(target_code.function()); |
| 1583 if (IsDebuggable(callee)) { | 1581 if (IsDebuggable(callee)) { |
| 1584 func_to_instrument = callee.raw(); | 1582 func_to_instrument = callee.raw(); |
| 1585 } | 1583 } |
| 1586 } | 1584 } |
| 1587 } else if (bpt->breakpoint_kind_ == PcDescriptors::kFuncCall) { | 1585 } else if (bpt->breakpoint_kind_ == PcDescriptors::kFuncCall) { |
| 1588 func_to_instrument = bpt->function(); | 1586 func_to_instrument = bpt->function(); |
| 1589 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); | 1587 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); |
| 1590 const Function& callee = | 1588 const Function& callee = |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 } | 1834 } |
| 1837 | 1835 |
| 1838 | 1836 |
| 1839 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1837 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1840 ASSERT(bpt->next() == NULL); | 1838 ASSERT(bpt->next() == NULL); |
| 1841 bpt->set_next(code_breakpoints_); | 1839 bpt->set_next(code_breakpoints_); |
| 1842 code_breakpoints_ = bpt; | 1840 code_breakpoints_ = bpt; |
| 1843 } | 1841 } |
| 1844 | 1842 |
| 1845 } // namespace dart | 1843 } // namespace dart |
| OLD | NEW |