| 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 script.GetTokenLocation(token_pos_, &line_number_, &ignore_column); | 559 script.GetTokenLocation(token_pos_, &line_number_, &ignore_column); |
| 560 } | 560 } |
| 561 return line_number_; | 561 return line_number_; |
| 562 } | 562 } |
| 563 | 563 |
| 564 | 564 |
| 565 void CodeBreakpoint::PatchCode() { | 565 void CodeBreakpoint::PatchCode() { |
| 566 ASSERT(!is_enabled_); | 566 ASSERT(!is_enabled_); |
| 567 switch (breakpoint_kind_) { | 567 switch (breakpoint_kind_) { |
| 568 case PcDescriptors::kIcCall: { | 568 case PcDescriptors::kIcCall: { |
| 569 int num_args, num_named_args; | 569 saved_bytes_.target_address_ = |
| 570 CodePatcher::GetInstanceCallAt(pc_, | 570 CodePatcher::GetInstanceCallAt(pc_, NULL, NULL); |
| 571 NULL, &num_args, &num_named_args, | 571 CodePatcher::PatchInstanceCallAt(pc_, |
| 572 &saved_bytes_.target_address_); | 572 StubCode::BreakpointDynamicEntryPoint()); |
| 573 CodePatcher::PatchInstanceCallAt( | |
| 574 pc_, StubCode::BreakpointDynamicEntryPoint()); | |
| 575 break; | 573 break; |
| 576 } | 574 } |
| 577 case PcDescriptors::kFuncCall: { | 575 case PcDescriptors::kFuncCall: { |
| 578 saved_bytes_.target_address_ = CodePatcher::GetStaticCallTargetAt(pc_); | 576 saved_bytes_.target_address_ = CodePatcher::GetStaticCallTargetAt(pc_); |
| 579 CodePatcher::PatchStaticCallAt(pc_, | 577 CodePatcher::PatchStaticCallAt(pc_, |
| 580 StubCode::BreakpointStaticEntryPoint()); | 578 StubCode::BreakpointStaticEntryPoint()); |
| 581 break; | 579 break; |
| 582 } | 580 } |
| 583 case PcDescriptors::kReturn: | 581 case PcDescriptors::kReturn: |
| 584 PatchFunctionReturn(); | 582 PatchFunctionReturn(); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 if (stack_trace->Length() > 1) { | 1376 if (stack_trace->Length() > 1) { |
| 1379 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); | 1377 ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1); |
| 1380 func_to_instrument = caller_frame->DartFunction().raw(); | 1378 func_to_instrument = caller_frame->DartFunction().raw(); |
| 1381 } | 1379 } |
| 1382 } | 1380 } |
| 1383 } else if (resume_action_ == kStepInto) { | 1381 } else if (resume_action_ == kStepInto) { |
| 1384 // If the call target is not debuggable, we treat StepInto like | 1382 // If the call target is not debuggable, we treat StepInto like |
| 1385 // a StepOver, that is we instrument the current function. | 1383 // a StepOver, that is we instrument the current function. |
| 1386 if (bpt->breakpoint_kind_ == PcDescriptors::kIcCall) { | 1384 if (bpt->breakpoint_kind_ == PcDescriptors::kIcCall) { |
| 1387 func_to_instrument = bpt->function(); | 1385 func_to_instrument = bpt->function(); |
| 1388 int num_args, num_named_args; | 1386 ICData& ic_data = ICData::Handle(); |
| 1389 uword target; | 1387 Array& descriptor = Array::Handle(); |
| 1390 CodePatcher::GetInstanceCallAt(bpt->pc_, NULL, | 1388 CodePatcher::GetInstanceCallAt(bpt->pc_, &ic_data, &descriptor); |
| 1391 &num_args, &num_named_args, &target); | 1389 ArgumentsDescriptor arg_descriptor(descriptor.raw()); |
| 1392 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); | 1390 ActivationFrame* top_frame = stack_trace->ActivationFrameAt(0); |
| 1393 Instance& receiver = Instance::Handle( | 1391 intptr_t num_args = arg_descriptor.Count(); |
| 1394 top_frame->GetInstanceCallReceiver(num_args)); | 1392 Instance& receiver = |
| 1395 Code& code = Code::Handle( | 1393 Instance::Handle(top_frame->GetInstanceCallReceiver(num_args)); |
| 1396 ResolveCompileInstanceCallTarget(isolate_, receiver)); | 1394 Code& code = |
| 1395 Code::Handle(ResolveCompileInstanceCallTarget(receiver, |
| 1396 ic_data, |
| 1397 arg_descriptor)); |
| 1397 if (!code.IsNull()) { | 1398 if (!code.IsNull()) { |
| 1398 Function& callee = Function::Handle(code.function()); | 1399 Function& callee = Function::Handle(code.function()); |
| 1399 if (IsDebuggable(callee)) { | 1400 if (IsDebuggable(callee)) { |
| 1400 func_to_instrument = callee.raw(); | 1401 func_to_instrument = callee.raw(); |
| 1401 } | 1402 } |
| 1402 } | 1403 } |
| 1403 } else if (bpt->breakpoint_kind_ == PcDescriptors::kFuncCall) { | 1404 } else if (bpt->breakpoint_kind_ == PcDescriptors::kFuncCall) { |
| 1404 func_to_instrument = bpt->function(); | 1405 func_to_instrument = bpt->function(); |
| 1405 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); | 1406 const Code& code = Code::Handle(func_to_instrument.CurrentCode()); |
| 1406 const Function& callee = | 1407 const Function& callee = |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 } | 1617 } |
| 1617 | 1618 |
| 1618 | 1619 |
| 1619 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1620 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1620 ASSERT(bpt->next() == NULL); | 1621 ASSERT(bpt->next() == NULL); |
| 1621 bpt->set_next(code_breakpoints_); | 1622 bpt->set_next(code_breakpoints_); |
| 1622 code_breakpoints_ = bpt; | 1623 code_breakpoints_ = bpt; |
| 1623 } | 1624 } |
| 1624 | 1625 |
| 1625 } // namespace dart | 1626 } // namespace dart |
| OLD | NEW |