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 
11 namespace lldb_private {
12 namespace 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 
23 static std::vector<DynamicRegisterInfo::Register> GetRegisters_aarch64() {
24  ConstString empty_alt_name;
25  ConstString reg_set{"general purpose registers"};
26 
27  std::vector<DynamicRegisterInfo::Register> registers{
28  R64(x0), R64(x1), R64(x2), R64(x3), R64(x4), R64(x5), R64(x6),
29  R64(x7), R64(x8), R64(x9), R64(x10), R64(x11), R64(x12), R64(x13),
30  R64(x14), R64(x15), R64(x16), R64(x17), R64(x18), R64(x19), R64(x20),
31  R64(x21), R64(x22), R64(x23), R64(x24), R64(x25), R64(x26), R64(x27),
32  R64(x28), R64(x29), R64(x30), R64(sp), R64(pc), R32(cpsr),
33  };
34 
35  return registers;
36 }
37 
38 static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86() {
39  ConstString empty_alt_name;
40  ConstString reg_set{"general purpose registers"};
41 
42  std::vector<DynamicRegisterInfo::Register> registers{
43  R32(eax), R32(ecx), R32(edx), R32(ebx), R32(esp), R32(ebp),
44  R32(esi), R32(edi), R32(eip), R32(eflags), R32(cs), R32(ss),
45  R32(ds), R32(es), R32(fs), R32(gs),
46  };
47 
48  return registers;
49 }
50 
51 static std::vector<DynamicRegisterInfo::Register> GetRegisters_x86_64() {
52  ConstString empty_alt_name;
53  ConstString reg_set{"general purpose registers"};
54 
55  std::vector<DynamicRegisterInfo::Register> registers{
56  R64(rax), R64(rbx), R64(rcx), R64(rdx), R64(rsi), R64(rdi),
57  R64(rbp), R64(rsp), R64(r8), R64(r9), R64(r10), R64(r11),
58  R64(r12), R64(r13), R64(r14), R64(r15), R64(rip), R32(eflags),
59  R32(cs), R32(ss), R32(ds), R32(es), R32(fs), R32(gs),
60  };
61 
62  return registers;
63 }
64 
65 #undef R32
66 #undef R64
67 #undef REG
68 
69 std::vector<DynamicRegisterInfo::Register>
70 GetFallbackRegisters(const ArchSpec &arch_to_use) {
71  switch (arch_to_use.GetMachine()) {
72  case llvm::Triple::aarch64:
73  return GetRegisters_aarch64();
74  case llvm::Triple::x86:
75  return GetRegisters_x86();
76  case llvm::Triple::x86_64:
77  return GetRegisters_x86_64();
78  default:
79  break;
80  }
81 
82  return {};
83 }
84 
85 } // namespace process_gdb_remote
86 } // namespace lldb_private
arm64_dwarf::x5
@ x5
Definition: ARM64_DWARF_Registers.h:22
arm64_dwarf::x4
@ x4
Definition: ARM64_DWARF_Registers.h:21
x27
@ x27
Definition: CompactUnwindInfo.cpp:1245
r12
@ r12
Definition: CompactUnwindInfo.cpp:706
arm64_dwarf::x6
@ x6
Definition: ARM64_DWARF_Registers.h:23
arm64_dwarf::x16
@ x16
Definition: ARM64_DWARF_Registers.h:33
lldb_private::ArchSpec
Definition: ArchSpec.h:33
rax
@ rax
Definition: CompactUnwindInfo.cpp:694
x20
@ x20
Definition: CompactUnwindInfo.cpp:1238
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:668
esp
@ esp
Definition: CompactUnwindInfo.cpp:979
arm64_dwarf::x18
@ x18
Definition: ARM64_DWARF_Registers.h:35
arm64_dwarf::x12
@ x12
Definition: ARM64_DWARF_Registers.h:29
x19
@ x19
Definition: CompactUnwindInfo.cpp:1237
r10
@ r10
Definition: CompactUnwindInfo.cpp:704
arm64_dwarf::cpsr
@ cpsr
Definition: ARM64_DWARF_Registers.h:53
arm64_dwarf::x0
@ x0
Definition: ARM64_DWARF_Registers.h:17
ebp
@ ebp
Definition: CompactUnwindInfo.cpp:978
ebx
@ ebx
Definition: CompactUnwindInfo.cpp:977
arm64_dwarf::x3
@ x3
Definition: ARM64_DWARF_Registers.h:20
rdi
@ rdi
Definition: CompactUnwindInfo.cpp:699
pc
@ pc
Definition: CompactUnwindInfo.cpp:1251
edx
@ edx
Definition: CompactUnwindInfo.cpp:976
r8
@ r8
Definition: CompactUnwindInfo.cpp:702
arm64_dwarf::x17
@ x17
Definition: ARM64_DWARF_Registers.h:34
x26
@ x26
Definition: CompactUnwindInfo.cpp:1244
rcx
@ rcx
Definition: CompactUnwindInfo.cpp:696
R32
#define R32(name)
Definition: GDBRemoteRegisterFallback.cpp:21
x24
@ x24
Definition: CompactUnwindInfo.cpp:1242
rbx
@ rbx
Definition: CompactUnwindInfo.cpp:697
r11
@ r11
Definition: CompactUnwindInfo.cpp:705
arm64_dwarf::x9
@ x9
Definition: ARM64_DWARF_Registers.h:26
r14
@ r14
Definition: CompactUnwindInfo.cpp:708
lldb_private::ConstString
Definition: ConstString.h:40
arm64_dwarf::x29
@ x29
Definition: ARM64_DWARF_Registers.h:46
sp
@ sp
Definition: CompactUnwindInfo.cpp:1250
R64
#define R64(name)
Definition: GDBRemoteRegisterFallback.cpp:20
arm64_dwarf::x15
@ x15
Definition: ARM64_DWARF_Registers.h:32
arm64_dwarf::x30
@ x30
Definition: ARM64_DWARF_Registers.h:48
x22
@ x22
Definition: CompactUnwindInfo.cpp:1240
arm64_dwarf::x8
@ x8
Definition: ARM64_DWARF_Registers.h:25
lldb_private::process_gdb_remote::GetRegisters_aarch64
static std::vector< DynamicRegisterInfo::Register > GetRegisters_aarch64()
Definition: GDBRemoteRegisterFallback.cpp:23
GDBRemoteRegisterFallback.h
x23
@ x23
Definition: CompactUnwindInfo.cpp:1241
ecx
@ ecx
Definition: CompactUnwindInfo.cpp:975
rdx
@ rdx
Definition: CompactUnwindInfo.cpp:695
arm64_dwarf::x7
@ x7
Definition: ARM64_DWARF_Registers.h:24
x28
@ x28
Definition: CompactUnwindInfo.cpp:1246
lldb_private::process_gdb_remote::GetRegisters_x86
static std::vector< DynamicRegisterInfo::Register > GetRegisters_x86()
Definition: GDBRemoteRegisterFallback.cpp:38
edi
@ edi
Definition: CompactUnwindInfo.cpp:981
eax
@ eax
Definition: CompactUnwindInfo.cpp:974
arm64_dwarf::x11
@ x11
Definition: ARM64_DWARF_Registers.h:28
rip
@ rip
Definition: CompactUnwindInfo.cpp:710
x25
@ x25
Definition: CompactUnwindInfo.cpp:1243
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
r15
@ r15
Definition: CompactUnwindInfo.cpp:709
arm64_dwarf::x2
@ x2
Definition: ARM64_DWARF_Registers.h:19
arm64_dwarf::x13
@ x13
Definition: ARM64_DWARF_Registers.h:30
esi
@ esi
Definition: CompactUnwindInfo.cpp:980
x21
@ x21
Definition: CompactUnwindInfo.cpp:1239
arm64_dwarf::x10
@ x10
Definition: ARM64_DWARF_Registers.h:27
rsi
@ rsi
Definition: CompactUnwindInfo.cpp:698
r9
@ r9
Definition: CompactUnwindInfo.cpp:703
arm64_dwarf::x1
@ x1
Definition: ARM64_DWARF_Registers.h:18
lldb_private::process_gdb_remote::GetFallbackRegisters
std::vector< DynamicRegisterInfo::Register > GetFallbackRegisters(const ArchSpec &arch_to_use)
Definition: GDBRemoteRegisterFallback.cpp:70
rbp
@ rbp
Definition: CompactUnwindInfo.cpp:700
lldb_private::process_gdb_remote::GetRegisters_x86_64
static std::vector< DynamicRegisterInfo::Register > GetRegisters_x86_64()
Definition: GDBRemoteRegisterFallback.cpp:51
rsp
@ rsp
Definition: CompactUnwindInfo.cpp:701
r13
@ r13
Definition: CompactUnwindInfo.cpp:707
arm64_dwarf::x14
@ x14
Definition: ARM64_DWARF_Registers.h:31
eip
@ eip
Definition: CompactUnwindInfo.cpp:982