2014-04-02 17:39:32 +00:00
|
|
|
// Copyright (c) 2014, 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_ARM64)
|
|
|
|
|
|
|
|
#include "vm/code_patcher.h"
|
|
|
|
#include "vm/cpu.h"
|
|
|
|
#include "vm/debugger.h"
|
|
|
|
#include "vm/instructions.h"
|
|
|
|
#include "vm/stub_code.h"
|
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
2016-02-09 16:45:32 +00:00
|
|
|
#ifndef PRODUCT
|
|
|
|
|
2015-09-19 11:21:09 +00:00
|
|
|
RawCode* CodeBreakpoint::OrigStubAddress() const {
|
2015-05-18 13:03:02 +00:00
|
|
|
return saved_value_;
|
2014-04-02 17:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CodeBreakpoint::PatchCode() {
|
2014-05-09 23:20:14 +00:00
|
|
|
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:
|
2018-11-21 17:45:11 +00:00
|
|
|
stub_target = StubCode::ICCallBreakpoint().raw();
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
|
|
|
case RawPcDescriptors::kRuntimeCall: {
|
2018-11-21 17:45:11 +00:00
|
|
|
stub_target = StubCode::RuntimeCallBreakpoint().raw();
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
2014-05-09 23:20:14 +00:00
|
|
|
}
|
2015-05-18 13:03:02 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
2014-05-09 23:20:14 +00:00
|
|
|
}
|
2015-05-18 13:03:02 +00:00
|
|
|
const Code& code = Code::Handle(code_);
|
2016-11-08 21:54:47 +00:00
|
|
|
saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
2015-05-18 13:03:02 +00:00
|
|
|
CodePatcher::PatchPoolPointerCallAt(pc_, code, stub_target);
|
2014-05-09 23:20:14 +00:00
|
|
|
is_enabled_ = true;
|
2014-04-02 17:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CodeBreakpoint::RestoreCode() {
|
2014-05-09 23:20:14 +00:00
|
|
|
ASSERT(is_enabled_);
|
|
|
|
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: {
|
2016-11-08 21:54:47 +00:00
|
|
|
CodePatcher::PatchPoolPointerCallAt(pc_, code,
|
|
|
|
Code::Handle(saved_value_));
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
2014-05-09 23:20:14 +00:00
|
|
|
}
|
2015-05-18 13:03:02 +00:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
2014-05-09 23:20:14 +00:00
|
|
|
}
|
|
|
|
is_enabled_ = false;
|
2014-04-02 17:39:32 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 16:45:32 +00:00
|
|
|
#endif // !PRODUCT
|
|
|
|
|
2014-04-02 17:39:32 +00:00
|
|
|
} // namespace dart
|
|
|
|
|
|
|
|
#endif // defined TARGET_ARCH_ARM64
|