LLDB mainline
RegisterContextFreeBSDKernel_arm64.cpp
Go to the documentation of this file.
1//===-- RegisterContextFreeBSDKernel_arm64.cpp ----------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
11
12#include "lldb/Target/Process.h"
13#include "lldb/Target/Thread.h"
15#include "llvm/Support/Endian.h"
16
17using namespace lldb;
18using namespace lldb_private;
19
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) {}
25
27
29
31 assert(0);
32 return false;
33}
34
36 assert(0);
37 return false;
38}
39
41 const RegisterInfo *reg_info, RegisterValue &value) {
43 return false;
44
45 struct {
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;
50 } pcb;
51
53 size_t rd =
54 m_thread.GetProcess()->ReadMemory(m_pcb_addr, &pcb, sizeof(pcb), error);
55 if (rd != sizeof(pcb))
56 return false;
57
58 uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
59 switch (reg) {
60 case gpr_x0_arm64:
61 case gpr_x1_arm64:
62 case gpr_x2_arm64:
63 case gpr_x3_arm64:
64 case gpr_x4_arm64:
65 case gpr_x5_arm64:
66 case gpr_x6_arm64:
67 case gpr_x7_arm64:
68 case gpr_x8_arm64:
69 case gpr_x9_arm64:
70 case gpr_x10_arm64:
71 case gpr_x11_arm64:
72 case gpr_x12_arm64:
73 case gpr_x13_arm64:
74 case gpr_x14_arm64:
75 case gpr_x15_arm64:
76 case gpr_x16_arm64:
77 case gpr_x17_arm64:
78 case gpr_x18_arm64:
79 case gpr_x19_arm64:
80 case gpr_x20_arm64:
81 case gpr_x21_arm64:
82 case gpr_x22_arm64:
83 case gpr_x23_arm64:
84 case gpr_x24_arm64:
85 case gpr_x25_arm64:
86 case gpr_x26_arm64:
87 case gpr_x27_arm64:
88 case gpr_x28_arm64:
89 case gpr_fp_arm64:
90 static_assert(gpr_fp_arm64 - gpr_x0_arm64 == 29,
91 "nonconsecutive arm64 register numbers");
92 value = pcb.x[reg - gpr_x0_arm64];
93 break;
94 case gpr_sp_arm64:
95 value = pcb.sp;
96 break;
97 case gpr_pc_arm64:
98 // The pc of crashing thread is stored in lr.
99 value = pcb.lr;
100 break;
101 default:
102 return false;
103 }
104 return true;
105}
106
108 const RegisterInfo *reg_info, const RegisterValue &value) {
109 return false;
110}
static llvm::raw_ostream & error(Stream &strm)
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
RegisterContextFreeBSDKernel_arm64(lldb_private::Thread &thread, std::unique_ptr< RegisterInfoPOSIX_arm64 > register_info_up, lldb::addr_t pcb_addr)
An error handling class.
Definition: Status.h:44
lldb::ProcessSP GetProcess() const
Definition: Thread.h:153
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
uint64_t addr_t
Definition: lldb-types.h:83
@ eRegisterKindLLDB
lldb's internal register numbers