| Index: runtime/vm/debugger_dbc.cc
|
| diff --git a/runtime/vm/debugger_ia32.cc b/runtime/vm/debugger_dbc.cc
|
| similarity index 60%
|
| copy from runtime/vm/debugger_ia32.cc
|
| copy to runtime/vm/debugger_dbc.cc
|
| index 9c4473ba32a2863208738b3f955e3d9c03bca13c..5f82cd5368a10a3456def0225c9684c30ca2cadf 100644
|
| --- a/runtime/vm/debugger_ia32.cc
|
| +++ b/runtime/vm/debugger_dbc.cc
|
| @@ -1,18 +1,14 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| #include "vm/globals.h"
|
| -#if defined(TARGET_ARCH_IA32)
|
| -
|
| -#include "vm/debugger.h"
|
| +#if defined(TARGET_ARCH_DBC)
|
|
|
| #include "vm/code_patcher.h"
|
| #include "vm/cpu.h"
|
| -#include "vm/disassembler.h"
|
| -#include "vm/object.h"
|
| -#include "vm/os.h"
|
| -#include "vm/stack_frame.h"
|
| +#include "vm/debugger.h"
|
| +#include "vm/instructions.h"
|
| #include "vm/stub_code.h"
|
|
|
| namespace dart {
|
| @@ -20,7 +16,12 @@ namespace dart {
|
| #ifndef PRODUCT
|
|
|
| RawCode* CodeBreakpoint::OrigStubAddress() const {
|
| - return saved_value_;
|
| + return reinterpret_cast<RawCode*>(static_cast<uintptr_t>(saved_value_));
|
| +}
|
| +
|
| +
|
| +static Instr* CallInstructionFromReturnAddress(uword pc) {
|
| + return reinterpret_cast<Instr*>(pc) - 1;
|
| }
|
|
|
|
|
| @@ -28,25 +29,31 @@ void CodeBreakpoint::PatchCode() {
|
| ASSERT(!is_enabled_);
|
| const Code& code = Code::Handle(code_);
|
| const Instructions& instrs = Instructions::Handle(code.instructions());
|
| - Code& stub_target = Code::Handle();
|
| {
|
| WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
|
| + saved_value_ = *CallInstructionFromReturnAddress(pc_);
|
| switch (breakpoint_kind_) {
|
| case RawPcDescriptors::kIcCall:
|
| case RawPcDescriptors::kUnoptStaticCall: {
|
| - stub_target = StubCode::ICCallBreakpoint_entry()->code();
|
| + // DebugBreak has an A operand matching the call it replaces.
|
| + // This ensures that Return instructions continue to work - as they
|
| + // look at calls to figure out how many arguments to drop.
|
| + *CallInstructionFromReturnAddress(pc_) =
|
| + Bytecode::Encode(Bytecode::kDebugBreak,
|
| + Bytecode::DecodeArgc(saved_value_),
|
| + 0,
|
| + 0);
|
| break;
|
| }
|
| +
|
| case RawPcDescriptors::kRuntimeCall: {
|
| - saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
| - stub_target = StubCode::RuntimeCallBreakpoint_entry()->code();
|
| + *CallInstructionFromReturnAddress(pc_) = Bytecode::kDebugBreak;
|
| break;
|
| }
|
| +
|
| default:
|
| UNREACHABLE();
|
| }
|
| - saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
| - CodePatcher::PatchStaticCallAt(pc_, code, stub_target);
|
| }
|
| is_enabled_ = true;
|
| }
|
| @@ -62,7 +69,7 @@ void CodeBreakpoint::RestoreCode() {
|
| case RawPcDescriptors::kIcCall:
|
| case RawPcDescriptors::kUnoptStaticCall:
|
| case RawPcDescriptors::kRuntimeCall: {
|
| - CodePatcher::PatchStaticCallAt(pc_, code, Code::Handle(saved_value_));
|
| + *CallInstructionFromReturnAddress(pc_) = saved_value_;
|
| break;
|
| }
|
| default:
|
| @@ -76,4 +83,4 @@ void CodeBreakpoint::RestoreCode() {
|
|
|
| } // namespace dart
|
|
|
| -#endif // defined TARGET_ARCH_IA32
|
| +#endif // defined TARGET_ARCH_DBC
|
|
|