2011-12-22 00:17:15 +00:00
|
|
|
// Copyright (c) 2011, 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_X64)
|
|
|
|
|
|
|
|
#include "vm/debugger.h"
|
|
|
|
|
2013-09-09 15:39:26 +00:00
|
|
|
#include "vm/assembler.h"
|
2014-01-14 23:27:13 +00:00
|
|
|
#include "vm/code_patcher.h"
|
2012-02-27 22:00:28 +00:00
|
|
|
#include "vm/cpu.h"
|
2014-01-14 23:27:13 +00:00
|
|
|
#include "vm/instructions.h"
|
2012-02-27 22:00:28 +00:00
|
|
|
#include "vm/stub_code.h"
|
|
|
|
|
2011-12-22 00:17:15 +00:00
|
|
|
namespace dart {
|
|
|
|
|
2015-09-19 11:21:09 +00:00
|
|
|
RawCode* CodeBreakpoint::OrigStubAddress() const {
|
2015-05-18 13:03:02 +00:00
|
|
|
return saved_value_;
|
2014-01-14 23:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CodeBreakpoint::PatchCode() {
|
|
|
|
ASSERT(!is_enabled_);
|
2015-09-19 11:21:09 +00:00
|
|
|
Code& stub_target = Code::Handle();
|
2015-05-18 13:03:02 +00:00
|
|
|
switch (breakpoint_kind_) {
|
|
|
|
case RawPcDescriptors::kIcCall:
|
|
|
|
case RawPcDescriptors::kUnoptStaticCall:
|
2015-09-19 11:21:09 +00:00
|
|
|
stub_target = StubCode::ICCallBreakpoint_entry()->code();
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
|
|
|
case RawPcDescriptors::kRuntimeCall:
|
2015-09-19 11:21:09 +00:00
|
|
|
stub_target = StubCode::RuntimeCallBreakpoint_entry()->code();
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
2014-01-14 23:27:13 +00:00
|
|
|
}
|
2015-05-18 13:03:02 +00:00
|
|
|
const Code& code = Code::Handle(code_);
|
|
|
|
saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
|
|
|
CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target);
|
2014-01-14 23:27:13 +00:00
|
|
|
is_enabled_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CodeBreakpoint::RestoreCode() {
|
|
|
|
ASSERT(is_enabled_);
|
2014-02-10 12:18:06 +00:00
|
|
|
const Code& code = Code::Handle(code_);
|
2015-05-18 13:03:02 +00:00
|
|
|
switch (breakpoint_kind_) {
|
|
|
|
case RawPcDescriptors::kIcCall:
|
|
|
|
case RawPcDescriptors::kUnoptStaticCall:
|
|
|
|
case RawPcDescriptors::kRuntimeCall: {
|
2015-09-19 11:21:09 +00:00
|
|
|
CodePatcher::PatchPoolPointerCallAt(
|
|
|
|
pc_, code, Code::Handle(saved_value_));
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
2014-01-14 23:27:13 +00:00
|
|
|
}
|
2015-05-18 13:03:02 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
2014-01-14 23:27:13 +00:00
|
|
|
}
|
|
|
|
is_enabled_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 00:17:15 +00:00
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // defined TARGET_ARCH_X64
|