LLDB mainline
RegisterContextFreeBSDKernelCore_arm.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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
17#if defined(__FreeBSD__) && defined(__arm__)
18#include <machine/frame.h>
19#endif
20
21using namespace lldb;
22using namespace lldb_private;
23
25 Thread &thread, std::unique_ptr<RegisterInfoPOSIX_arm> register_info_up,
26 lldb::addr_t pcb_addr)
27 : RegisterContextPOSIX_arm(thread, std::move(register_info_up)),
28 m_pcb_addr(pcb_addr) {}
29
31
33
35 assert(0);
36 return false;
37}
38
40 assert(0);
41 return false;
42}
43
45 const RegisterInfo *reg_info, RegisterValue &value) {
47 return false;
48
49 // https://cgit.freebsd.org/src/tree/sys/arm/include/frame.h
50 // struct pcb's first field is struct switchframe which is the only field used
51 // by debugger and should be aligned by 8 bytes.
52 struct {
53 // Aka switchframe.sf_r4 to switchframe.sf_pc.
54 llvm::support::ulittle32_t r4;
55 llvm::support::ulittle32_t r5;
56 llvm::support::ulittle32_t r6;
57 llvm::support::ulittle32_t r7;
58 llvm::support::ulittle32_t r8;
59 llvm::support::ulittle32_t r9;
60 llvm::support::ulittle32_t r10;
61 llvm::support::ulittle32_t r11;
62 llvm::support::ulittle32_t r12;
63 llvm::support::ulittle32_t sp;
64 llvm::support::ulittle32_t lr;
65 llvm::support::ulittle32_t pc;
66 } pcb;
67
68#if defined(__FreeBSD__) && defined(__arm__)
69 static_assert(offsetof(struct switchframe, sf_r4) ==
70 offsetof(decltype(pcb), r4));
71 static_assert(offsetof(struct switchframe, sf_r5) ==
72 offsetof(decltype(pcb), r5));
73 static_assert(offsetof(struct switchframe, sf_r6) ==
74 offsetof(decltype(pcb), r6));
75 static_assert(offsetof(struct switchframe, sf_r7) ==
76 offsetof(decltype(pcb), r7));
77 static_assert(offsetof(struct switchframe, sf_r8) ==
78 offsetof(decltype(pcb), r8));
79 static_assert(offsetof(struct switchframe, sf_r9) ==
80 offsetof(decltype(pcb), r9));
81 static_assert(offsetof(struct switchframe, sf_r10) ==
82 offsetof(decltype(pcb), r10));
83 static_assert(offsetof(struct switchframe, sf_r11) ==
84 offsetof(decltype(pcb), r11));
85 static_assert(offsetof(struct switchframe, sf_r12) ==
86 offsetof(decltype(pcb), r12));
87 static_assert(offsetof(struct switchframe, sf_sp) ==
88 offsetof(decltype(pcb), sp));
89 static_assert(offsetof(struct switchframe, sf_lr) ==
90 offsetof(decltype(pcb), lr));
91 static_assert(offsetof(struct switchframe, sf_pc) ==
92 offsetof(decltype(pcb), pc));
93#endif
94
96 size_t rd =
97 m_thread.GetProcess()->ReadMemory(m_pcb_addr, &pcb, sizeof(pcb), error);
98 if (rd != sizeof(pcb))
99 return false;
100
101 uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
102 switch (reg) {
103
104#define REG(x) \
105 case gpr_##x##_arm: \
106 value = pcb.x; \
107 break;
108
109 REG(r4);
110 REG(r5);
111 REG(r6);
112 REG(r7);
113 REG(r8);
114 REG(r9);
115 REG(r10);
116 REG(r11);
117 REG(r12);
118 REG(sp);
119 REG(lr);
120 REG(pc);
121
122#undef REG
123
124 default:
125 return false;
126 }
127 return true;
128}
129
131 const RegisterInfo *reg_info, const RegisterValue &value) {
132 return false;
133}
static llvm::raw_ostream & error(Stream &strm)
#define REG(x)
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
RegisterContextFreeBSDKernelCore_arm(lldb_private::Thread &thread, std::unique_ptr< RegisterInfoPOSIX_arm > register_info_up, lldb::addr_t pcb_addr)
RegisterContextPOSIX_arm(lldb_private::Thread &thread, std::unique_ptr< RegisterInfoPOSIX_arm > register_info)
An error handling class.
Definition Status.h:118
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80
@ eRegisterKindLLDB
lldb's internal register numbers
Every register is described in detail including its name, alternate name (optional),...
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.