Flutter Engine
The Flutter Engine
debugger_riscv.cc
Go to the documentation of this file.
1// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
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.
4
5#include "vm/globals.h"
6#if defined(TARGET_ARCH_RISCV32) || defined(TARGET_ARCH_RISCV64)
7
8#include "vm/code_patcher.h"
9#include "vm/cpu.h"
10#include "vm/debugger.h"
11#include "vm/instructions.h"
12#include "vm/stub_code.h"
13
14namespace dart {
15
16#ifndef PRODUCT
17
18CodePtr CodeBreakpoint::OrigStubAddress() const {
19 return saved_value_;
20}
21
22void CodeBreakpoint::PatchCode() {
23 ASSERT(!IsEnabled());
24 const Code& code = Code::Handle(code_);
25 switch (breakpoint_kind_) {
26 case UntaggedPcDescriptors::kIcCall: {
27 Object& data = Object::Handle();
28 saved_value_ = CodePatcher::GetInstanceCallAt(pc_, code, &data);
30 StubCode::ICCallBreakpoint());
31 break;
32 }
33 case UntaggedPcDescriptors::kUnoptStaticCall: {
34 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
36 pc_, code, StubCode::UnoptStaticCallBreakpoint());
37 break;
38 }
39 case UntaggedPcDescriptors::kRuntimeCall: {
40 saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code);
42 StubCode::RuntimeCallBreakpoint());
43 break;
44 }
45 default:
47 }
48}
49
50void CodeBreakpoint::RestoreCode() {
52 const Code& code = Code::Handle(code_);
53 switch (breakpoint_kind_) {
54 case UntaggedPcDescriptors::kIcCall: {
55 Object& data = Object::Handle();
58 Code::Handle(saved_value_));
59 break;
60 }
61 case UntaggedPcDescriptors::kUnoptStaticCall:
62 case UntaggedPcDescriptors::kRuntimeCall: {
64 Code::Handle(saved_value_));
65 break;
66 }
67 default:
69 }
70}
71
72#endif // !PRODUCT
73
74} // namespace dart
75
76#endif // defined TARGET_ARCH_RISCV
#define UNREACHABLE()
Definition: assert.h:248
bool IsEnabled() const
Definition: debugger.h:235
CodePtr OrigStubAddress() const
static void PatchInstanceCallAt(uword return_address, const Code &caller_code, const Object &data, const Code &target)
static void PatchPoolPointerCallAt(uword return_address, const Code &code, const Code &new_target)
static CodePtr GetStaticCallTargetAt(uword return_address, const Code &code)
static CodePtr GetInstanceCallAt(uword return_address, const Code &caller_code, Object *data)
static Object & Handle()
Definition: object.h:407
#define ASSERT(E)
Definition: dart_vm.cc:33
static int8_t data[kExtLength]