| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 | 579 |
| 580 | 580 |
| 581 void DebuggerStackTrace::AddActivation(ActivationFrame* frame) { | 581 void DebuggerStackTrace::AddActivation(ActivationFrame* frame) { |
| 582 trace_.Add(frame); | 582 trace_.Add(frame); |
| 583 } | 583 } |
| 584 | 584 |
| 585 | 585 |
| 586 static bool IsSafePoint(PcDescriptors::Kind kind) { | 586 static bool IsSafePoint(PcDescriptors::Kind kind) { |
| 587 return ((kind == PcDescriptors::kIcCall) || | 587 return ((kind == PcDescriptors::kIcCall) || |
| 588 (kind == PcDescriptors::kFuncCall) || | 588 (kind == PcDescriptors::kOptStaticCall) || |
| 589 (kind == PcDescriptors::kUnoptStaticCall) || |
| 589 (kind == PcDescriptors::kClosureCall) || | 590 (kind == PcDescriptors::kClosureCall) || |
| 590 (kind == PcDescriptors::kReturn) || | 591 (kind == PcDescriptors::kReturn) || |
| 591 (kind == PcDescriptors::kRuntimeCall)); | 592 (kind == PcDescriptors::kRuntimeCall)); |
| 592 } | 593 } |
| 593 | 594 |
| 594 | 595 |
| 595 CodeBreakpoint::CodeBreakpoint(const Function& func, intptr_t pc_desc_index) | 596 CodeBreakpoint::CodeBreakpoint(const Function& func, intptr_t pc_desc_index) |
| 596 : function_(func.raw()), | 597 : function_(func.raw()), |
| 597 pc_desc_index_(pc_desc_index), | 598 pc_desc_index_(pc_desc_index), |
| 598 pc_(0), | 599 pc_(0), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 switch (breakpoint_kind_) { | 657 switch (breakpoint_kind_) { |
| 657 case PcDescriptors::kIcCall: { | 658 case PcDescriptors::kIcCall: { |
| 658 const Code& code = | 659 const Code& code = |
| 659 Code::Handle(Function::Handle(function_).unoptimized_code()); | 660 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 660 saved_bytes_.target_address_ = | 661 saved_bytes_.target_address_ = |
| 661 CodePatcher::GetInstanceCallAt(pc_, code, NULL); | 662 CodePatcher::GetInstanceCallAt(pc_, code, NULL); |
| 662 CodePatcher::PatchInstanceCallAt(pc_, code, | 663 CodePatcher::PatchInstanceCallAt(pc_, code, |
| 663 StubCode::BreakpointDynamicEntryPoint()); | 664 StubCode::BreakpointDynamicEntryPoint()); |
| 664 break; | 665 break; |
| 665 } | 666 } |
| 666 case PcDescriptors::kFuncCall: { | 667 case PcDescriptors::kUnoptStaticCall: { |
| 667 const Code& code = | 668 const Code& code = |
| 668 Code::Handle(Function::Handle(function_).unoptimized_code()); | 669 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 669 saved_bytes_.target_address_ = | 670 saved_bytes_.target_address_ = |
| 670 CodePatcher::GetStaticCallTargetAt(pc_, code); | 671 CodePatcher::GetStaticCallTargetAt(pc_, code); |
| 671 CodePatcher::PatchStaticCallAt(pc_, code, | 672 CodePatcher::PatchStaticCallAt(pc_, code, |
| 672 StubCode::BreakpointStaticEntryPoint()); | 673 StubCode::BreakpointStaticEntryPoint()); |
| 673 break; | 674 break; |
| 674 } | 675 } |
| 675 case PcDescriptors::kRuntimeCall: | 676 case PcDescriptors::kRuntimeCall: |
| 676 case PcDescriptors::kClosureCall: { | 677 case PcDescriptors::kClosureCall: { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 695 void CodeBreakpoint::RestoreCode() { | 696 void CodeBreakpoint::RestoreCode() { |
| 696 ASSERT(is_enabled_); | 697 ASSERT(is_enabled_); |
| 697 switch (breakpoint_kind_) { | 698 switch (breakpoint_kind_) { |
| 698 case PcDescriptors::kIcCall: { | 699 case PcDescriptors::kIcCall: { |
| 699 const Code& code = | 700 const Code& code = |
| 700 Code::Handle(Function::Handle(function_).unoptimized_code()); | 701 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 701 CodePatcher::PatchInstanceCallAt(pc_, code, | 702 CodePatcher::PatchInstanceCallAt(pc_, code, |
| 702 saved_bytes_.target_address_); | 703 saved_bytes_.target_address_); |
| 703 break; | 704 break; |
| 704 } | 705 } |
| 705 case PcDescriptors::kFuncCall: | 706 case PcDescriptors::kUnoptStaticCall: |
| 706 case PcDescriptors::kClosureCall: | 707 case PcDescriptors::kClosureCall: |
| 707 case PcDescriptors::kRuntimeCall: { | 708 case PcDescriptors::kRuntimeCall: { |
| 708 const Code& code = | 709 const Code& code = |
| 709 Code::Handle(Function::Handle(function_).unoptimized_code()); | 710 Code::Handle(Function::Handle(function_).unoptimized_code()); |
| 710 CodePatcher::PatchStaticCallAt(pc_, code, | 711 CodePatcher::PatchStaticCallAt(pc_, code, |
| 711 saved_bytes_.target_address_); | 712 saved_bytes_.target_address_); |
| 712 break; | 713 break; |
| 713 } | 714 } |
| 714 case PcDescriptors::kReturn: | 715 case PcDescriptors::kReturn: |
| 715 RestoreFunctionReturn(); | 716 RestoreFunctionReturn(); |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 Instance& receiver = | 1577 Instance& receiver = |
| 1577 Instance::Handle(top_frame->GetInstanceCallReceiver(num_args)); | 1578 Instance::Handle(top_frame->GetInstanceCallReceiver(num_args)); |
| 1578 Code& target_code = | 1579 Code& target_code = |
| 1579 Code::Handle(ResolveCompileInstanceCallTarget(receiver, ic_data)); | 1580 Code::Handle(ResolveCompileInstanceCallTarget(receiver, ic_data)); |
| 1580 if (!target_code.IsNull()) { | 1581 if (!target_code.IsNull()) { |
| 1581 Function& callee = Function::Handle(target_code.function()); | 1582 Function& callee = Function::Handle(target_code.function()); |
| 1582 if (IsDebuggable(callee)) { | 1583 if (IsDebuggable(callee)) { |
| 1583 func_to_instrument = callee.raw(); | 1584 func_to_instrument = callee.raw(); |
| 1584 } | 1585 } |
| 1585 } | 1586 } |
| 1586 } else if (bpt->breakpoint_kind_ == PcDescriptors::kFuncCall) { | 1587 } else if (bpt->breakpoint_kind_ == PcDescriptors::kUnoptStaticCall) { |
| 1587 func_to_instrument = bpt->function(); | 1588 func_to_instrument = bpt->function(); |
| 1588 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); | 1589 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); |
| 1589 ASSERT(!code.is_optimized()); | 1590 ASSERT(!code.is_optimized()); |
| 1590 const Function& callee = Function::Handle( | 1591 const Function& callee = Function::Handle( |
| 1591 CodePatcher::GetUnoptimizedStaticCallTargetAt(bpt->pc_, code)); | 1592 CodePatcher::GetUnoptimizedStaticCallAt(bpt->pc_, code, NULL)); |
| 1592 ASSERT(!callee.IsNull()); | 1593 ASSERT(!callee.IsNull()); |
| 1593 if (IsDebuggable(callee)) { | 1594 if (IsDebuggable(callee)) { |
| 1594 func_to_instrument = callee.raw(); | 1595 func_to_instrument = callee.raw(); |
| 1595 } | 1596 } |
| 1596 } else if (bpt->breakpoint_kind_ == PcDescriptors::kClosureCall) { | 1597 } else if (bpt->breakpoint_kind_ == PcDescriptors::kClosureCall) { |
| 1597 func_to_instrument = bpt->function(); | 1598 func_to_instrument = bpt->function(); |
| 1598 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); | 1599 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); |
| 1599 ArgumentsDescriptor args_desc(Array::Handle( | 1600 ArgumentsDescriptor args_desc(Array::Handle( |
| 1600 CodePatcher::GetClosureArgDescAt(bpt->pc_, code))); | 1601 CodePatcher::GetClosureArgDescAt(bpt->pc_, code))); |
| 1601 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); | 1602 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 } | 1837 } |
| 1837 | 1838 |
| 1838 | 1839 |
| 1839 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1840 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1840 ASSERT(bpt->next() == NULL); | 1841 ASSERT(bpt->next() == NULL); |
| 1841 bpt->set_next(code_breakpoints_); | 1842 bpt->set_next(code_breakpoints_); |
| 1842 code_breakpoints_ = bpt; | 1843 code_breakpoints_ = bpt; |
| 1843 } | 1844 } |
| 1844 | 1845 |
| 1845 } // namespace dart | 1846 } // namespace dart |
| OLD | NEW |