LLDB mainline
GDBRemoteRegisterFallback.cpp
Go to the documentation of this file.
1//===-- GDBRemoteRegisterFallback.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
10
11namespace lldb_private {
12namespace process_gdb_remote {
13
14#define REG(name, size) \
15 DynamicRegisterInfo::Register { \
16 ConstString(#name), empty_alt_name, reg_set, size, LLDB_INVALID_INDEX32, \
17 lldb::eEncodingUint, lldb::eFormatHex, LLDB_INVALID_REGNUM, \
18 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, {}, {} \
19 }
20#define R64(name) REG(name, 8)
21#define R32(name) REG(name, 4)
22#define R16(name) REG(name, 2)
23
24static std::vector<DynamicRegisterInfo::Register> GetRegisters_aarch64() {
25 ConstString empty_alt_name;
26 ConstString reg_set{"general purpose registers"};
27
28 std::vector<DynamicRegisterInfo::Register> registers{
29 R64(x0), R64(x1), R64(x2), R64(x3), R64(x4), R64(x5), R64(x6),
30 R64(x7), R64(x8), R64(x9), R64(x10), R64(x11), R64(x12), R64(x13),
31 R64(x14), R64(x15), R64(x16), R64(x17), R64(x18), R64(x19), R64(x20),
32 R64(x21), R64(x22), R64(x23), R64(x24), R64(x25), R64(x26), R64(x27),
33 R64(x28), R64(x29), R64(x30), R64(sp), R64(pc), R32(cpsr),
34 };
35
36 return registers;
37}
38
39static std::vector<DynamicRegisterInfo::Register> GetRegisters_msp430() {
40 ConstString empty_alt_name;
41 ConstString reg_set{"general purpose registers"};
42
43 std::vector<DynamicRegisterInfo::Register> registers{
44 R16(pc), R16(sp), R16(r2), R16(r3), R16(fp), R16(r5),
45 R16(r6), R16(r7), R16(r8), R16(r9), R16(r10), R16(r11),
46 R16(r12), R16(r13), R16(r14), R16(r15)};
47
48 return registers;
49}
50
51static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86() {
52 ConstString empty_alt_name;
53 ConstString reg_set{"general purpose registers"};
54
55 std::vector<DynamicRegisterInfo::Register> registers{
56 R32(eax), R32(ecx), R32(edx), R32(ebx), R32(esp), R32(ebp),
57 R32(esi), R32(edi), R32(eip), R32(eflags), R32(cs), R32(ss),
58 R32(ds), R32(es), R32(fs), R32(gs),
59 };
60
61 return registers;
62}
63
64static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86_64() {
65 ConstString empty_alt_name;
66 ConstString reg_set{"general purpose registers"};
67
68 std::vector<DynamicRegisterInfo::Register> registers{
69 R64(rax), R64(rbx), R64(rcx), R64(rdx), R64(rsi), R64(rdi),
70 R64(rbp), R64(rsp), R64(r8), R64(r9), R64(r10), R64(r11),
71 R64(r12), R64(r13), R64(r14), R64(r15), R64(rip), R32(eflags),
72 R32(cs), R32(ss), R32(ds), R32(es), R32(fs), R32(gs),
73 };
74
75 return registers;
76}
77
78#undef R32
79#undef R64
80#undef REG
81
82std::vector<DynamicRegisterInfo::Register>
83GetFallbackRegisters(const ArchSpec &arch_to_use) {
84 switch (arch_to_use.GetMachine()) {
85 case llvm::Triple::aarch64:
86 return GetRegisters_aarch64();
87 case llvm::Triple::msp430:
88 return GetRegisters_msp430();
89 case llvm::Triple::x86:
90 return GetRegisters_x86();
91 case llvm::Triple::x86_64:
92 return GetRegisters_x86_64();
93 default:
94 break;
95 }
96
97 return {};
98}
99
100} // namespace process_gdb_remote
101} // namespace lldb_private
#define R32(name)
#define R16(name)
#define R64(name)
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:683
A uniqued constant string class.
Definition: ConstString.h:40
static std::vector< DynamicRegisterInfo::Register > GetRegisters_x86()
static std::vector< DynamicRegisterInfo::Register > GetRegisters_x86_64()
std::vector< DynamicRegisterInfo::Register > GetFallbackRegisters(const ArchSpec &arch_to_use)
static std::vector< DynamicRegisterInfo::Register > GetRegisters_aarch64()
static std::vector< DynamicRegisterInfo::Register > GetRegisters_msp430()
A class that represents a running process on the host machine.