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
|
|
|
|
|
2020-04-25 05:21:27 +00:00
|
|
|
CodePtr 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() {
|
2021-03-19 20:24:48 +00:00
|
|
|
ASSERT(!IsEnabled());
|
2019-06-12 21:56:53 +00:00
|
|
|
const Code& code = Code::Handle(code_);
|
2015-05-18 13:03:02 +00:00
|
|
|
switch (breakpoint_kind_) {
|
2021-01-15 23:32:02 +00:00
|
|
|
case UntaggedPcDescriptors::kIcCall: {
|
2019-06-12 21:56:53 +00:00
|
|
|
Object& data = Object::Handle();
|
|
|
|
saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, &data);
|
|
|
|
CodePatcher::PatchInstanceCallAt(pc_, code, data,
|
|
|
|
StubCode::ICCallBreakpoint());
|
2015-05-18 13:03:02 +00:00
|
|
|
break;
|
2019-06-12 21:56:53 +00:00
|
|
|
}
|
2021-01-15 23:32:02 +00:00
|
|
|
case UntaggedPcDescriptors::kUnoptStaticCall: {
|
2019-06-12 21:56:53 +00:00
|
|
|
saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
|
|
|
CodePatcher::PatchPoolPointerCallAt(
|
|
|
|
pc_, code, StubCode::UnoptStaticCallBreakpoint());
|
|
|
|
break;
|
|
|
|
}
|
2021-01-15 23:32:02 +00:00
|
|
|
case UntaggedPcDescriptors::kRuntimeCall: {
|
2019-06-12 21:56:53 +00:00
|
|
|
saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
|
|
|
|
CodePatcher::PatchPoolPointerCallAt(pc_, code,
|
|
|
|
StubCode::RuntimeCallBreakpoint());
|
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
|
|
|
}
|
2014-04-02 17:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CodeBreakpoint::RestoreCode() {
|
2021-03-19 20:24:48 +00:00
|
|
|
ASSERT(IsEnabled());
|
2014-05-09 23:20:14 +00:00
|
|
|
const Code& code = Code::Handle(code_);
|
2015-05-18 13:03:02 +00:00
|
|
|
switch (breakpoint_kind_) {
|
2021-01-15 23:32:02 +00:00
|
|
|
case UntaggedPcDescriptors::kIcCall: {
|
2019-06-12 21:56:53 +00:00
|
|
|
Object& data = Object::Handle();
|
|
|
|
CodePatcher::GetInstanceCallAt(pc_, code, &data);
|
|
|
|
CodePatcher::PatchInstanceCallAt(pc_, code, data,
|
|
|
|
Code::Handle(saved_value_));
|
|
|
|
break;
|
|
|
|
}
|
2021-01-15 23:32:02 +00:00
|
|
|
case UntaggedPcDescriptors::kUnoptStaticCall:
|
|
|
|
case UntaggedPcDescriptors::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
|
|
|
}
|
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
|