1 //===-- RegisterContextFreeBSDKernel_arm64.cpp ----------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextFreeBSDKernel_arm64.h"
10 #include "Plugins/Process/Utility/lldb-arm64-register-enums.h"
12 #include "lldb/Target/Process.h"
13 #include "lldb/Target/Thread.h"
14 #include "lldb/Utility/RegisterValue.h"
15 #include "llvm/Support/Endian.h"
18 using namespace lldb_private
;
20 RegisterContextFreeBSDKernel_arm64::RegisterContextFreeBSDKernel_arm64(
21 Thread
&thread
, std::unique_ptr
<RegisterInfoPOSIX_arm64
> register_info_up
,
22 lldb::addr_t pcb_addr
)
23 : RegisterContextPOSIX_arm64(thread
, std::move(register_info_up
)),
24 m_pcb_addr(pcb_addr
) {}
26 bool RegisterContextFreeBSDKernel_arm64::ReadGPR() { return true; }
28 bool RegisterContextFreeBSDKernel_arm64::ReadFPR() { return true; }
30 bool RegisterContextFreeBSDKernel_arm64::WriteGPR() {
35 bool RegisterContextFreeBSDKernel_arm64::WriteFPR() {
40 bool RegisterContextFreeBSDKernel_arm64::ReadRegister(
41 const RegisterInfo
*reg_info
, RegisterValue
&value
) {
42 if (m_pcb_addr
== LLDB_INVALID_ADDRESS
)
46 llvm::support::ulittle64_t x
[30];
47 llvm::support::ulittle64_t lr
;
48 llvm::support::ulittle64_t _reserved
;
49 llvm::support::ulittle64_t sp
;
54 m_thread
.GetProcess()->ReadMemory(m_pcb_addr
, &pcb
, sizeof(pcb
), error
);
55 if (rd
!= sizeof(pcb
))
58 uint32_t reg
= reg_info
->kinds
[lldb::eRegisterKindLLDB
];
90 static_assert(gpr_fp_arm64
- gpr_x0_arm64
== 29,
91 "nonconsecutive arm64 register numbers");
92 value
= pcb
.x
[reg
- gpr_x0_arm64
];
98 // The pc of crashing thread is stored in lr.
107 bool RegisterContextFreeBSDKernel_arm64::WriteRegister(
108 const RegisterInfo
*reg_info
, const RegisterValue
&value
) {