LLDB  mainline
RegisterContextWindows_x86_64.cpp
Go to the documentation of this file.
1 //===-- RegisterContextWindows_x86_64.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 #include "RegisterContext_x86.h"
12 
13 #include <vector>
14 
15 using namespace lldb_private;
16 using namespace lldb;
17 
18 namespace {
19 typedef struct _GPR {
20  uint64_t rax;
21  uint64_t rcx;
22  uint64_t rdx;
23  uint64_t rbx;
24  uint64_t rsp;
25  uint64_t rbp;
26  uint64_t rsi;
27  uint64_t rdi;
28  uint64_t r8;
29  uint64_t r9;
30  uint64_t r10;
31  uint64_t r11;
32  uint64_t r12;
33  uint64_t r13;
34  uint64_t r14;
35  uint64_t r15;
36  uint64_t rip;
37  uint64_t rflags;
38  uint16_t cs;
39  uint16_t fs;
40  uint16_t gs;
41  uint16_t ss;
42  uint16_t ds;
43  uint16_t es;
44 } GPR;
45 
46 #define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
47 #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
48  { \
49 #reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \
50  eFormatHex, \
51  {kind1, kind2, kind3, kind4, lldb_##reg##_x86_64 }, nullptr, nullptr, \
52  nullptr, 0 \
53  }
54 
55 typedef struct _FPReg {
56  XMMReg xmm0;
57  XMMReg xmm1;
58  XMMReg xmm2;
59  XMMReg xmm3;
60  XMMReg xmm4;
61  XMMReg xmm5;
62  XMMReg xmm6;
63  XMMReg xmm7;
64  XMMReg xmm8;
65  XMMReg xmm9;
66  XMMReg xmm10;
67  XMMReg xmm11;
68  XMMReg xmm12;
69  XMMReg xmm13;
70  XMMReg xmm14;
71  XMMReg xmm15;
72 } FPReg;
73 
74 #define FPR_OFFSET(regname) \
75  (sizeof(GPR) + LLVM_EXTENSION offsetof(FPReg, regname))
76 
77 #define DEFINE_XMM(reg) \
78  { \
79 #reg, NULL, sizeof(((FPReg *)nullptr)->reg), FPR_OFFSET(reg), \
80  eEncodingUint, eFormatVectorOfUInt64, \
81  {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \
82  LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
83  nullptr, nullptr, nullptr, 0 \
84  }
85 
86 // clang-format off
87 static RegisterInfo g_register_infos_x86_64[] = {
88 // General purpose registers EH_Frame DWARF Generic Process Plugin
89 // =========================== ================== ================ ========================= ====================
114  DEFINE_XMM(xmm0),
115  DEFINE_XMM(xmm1),
116  DEFINE_XMM(xmm2),
117  DEFINE_XMM(xmm3),
118  DEFINE_XMM(xmm4),
119  DEFINE_XMM(xmm5),
120  DEFINE_XMM(xmm6),
121  DEFINE_XMM(xmm7),
122  DEFINE_XMM(xmm8),
123  DEFINE_XMM(xmm9),
124  DEFINE_XMM(xmm10),
125  DEFINE_XMM(xmm11),
126  DEFINE_XMM(xmm12),
127  DEFINE_XMM(xmm13),
128  DEFINE_XMM(xmm14),
129  DEFINE_XMM(xmm15)
130 };
131 // clang-format on
132 } // namespace
133 
135  const ArchSpec &target_arch)
136  : lldb_private::RegisterInfoInterface(target_arch) {
137  assert(target_arch.GetMachine() == llvm::Triple::x86_64);
138 }
139 
141  return g_register_infos_x86_64;
142 }
143 
145  return llvm::array_lengthof(g_register_infos_x86_64);
146 }
147 
149  return llvm::array_lengthof(g_register_infos_x86_64);
150 }
151 
152 size_t RegisterContextWindows_x86_64::GetGPRSize() const { return sizeof(GPR); }
LLDB_REGNUM_GENERIC_ARG2
#define LLDB_REGNUM_GENERIC_ARG2
Definition: lldb-defines.h:70
LLDB_REGNUM_GENERIC_ARG3
#define LLDB_REGNUM_GENERIC_ARG3
Definition: lldb-defines.h:72
r12
@ r12
Definition: CompactUnwindInfo.cpp:705
lldb_private::ArchSpec
Definition: ArchSpec.h:33
LLDB_REGNUM_GENERIC_ARG1
#define LLDB_REGNUM_GENERIC_ARG1
Definition: lldb-defines.h:68
rax
@ rax
Definition: CompactUnwindInfo.cpp:693
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::ArchSpec::GetMachine
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:667
lldb_private::dwarf_ss_x86_64
@ dwarf_ss_x86_64
Definition: RegisterContext_x86.h:200
lldb_private::dwarf_rcx_x86_64
@ dwarf_rcx_x86_64
Definition: RegisterContext_x86.h:143
LLDB_REGNUM_GENERIC_ARG5
#define LLDB_REGNUM_GENERIC_ARG5
Definition: lldb-defines.h:76
r10
@ r10
Definition: CompactUnwindInfo.cpp:703
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
lldb_private::dwarf_r13_x86_64
@ dwarf_r13_x86_64
Definition: RegisterContext_x86.h:155
rdi
@ rdi
Definition: CompactUnwindInfo.cpp:698
lldb_private::dwarf_r10_x86_64
@ dwarf_r10_x86_64
Definition: RegisterContext_x86.h:152
RegisterContextWindows_x86_64::GetRegisterInfo
const lldb_private::RegisterInfo * GetRegisterInfo() const override
Definition: RegisterContextWindows_x86_64.cpp:140
RegisterContextWindows_x86_64::RegisterContextWindows_x86_64
RegisterContextWindows_x86_64(const lldb_private::ArchSpec &target_arch)
Definition: RegisterContextWindows_x86_64.cpp:134
LLDB_REGNUM_GENERIC_ARG6
#define LLDB_REGNUM_GENERIC_ARG6
Definition: lldb-defines.h:78
lldb_private::dwarf_rsi_x86_64
@ dwarf_rsi_x86_64
Definition: RegisterContext_x86.h:145
LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_REGNUM_GENERIC_FLAGS
Definition: lldb-defines.h:67
lldb_private::dwarf_fs_x86_64
@ dwarf_fs_x86_64
Definition: RegisterContext_x86.h:202
r8
@ r8
Definition: CompactUnwindInfo.cpp:701
GPR
struct _GPR GPR
rcx
@ rcx
Definition: CompactUnwindInfo.cpp:695
lldb_private::dwarf_rbp_x86_64
@ dwarf_rbp_x86_64
Definition: RegisterContext_x86.h:147
lldb_private::dwarf_rdi_x86_64
@ dwarf_rdi_x86_64
Definition: RegisterContext_x86.h:146
rbx
@ rbx
Definition: CompactUnwindInfo.cpp:696
r11
@ r11
Definition: CompactUnwindInfo.cpp:704
r14
@ r14
Definition: CompactUnwindInfo.cpp:707
lldb_private::dwarf_r11_x86_64
@ dwarf_r11_x86_64
Definition: RegisterContext_x86.h:153
lldb_private::dwarf_r8_x86_64
@ dwarf_r8_x86_64
Definition: RegisterContext_x86.h:150
lldb_private::dwarf_rip_x86_64
@ dwarf_rip_x86_64
Definition: RegisterContext_x86.h:159
DEFINE_GPR
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4)
Definition: RegisterContextWindows_x86_64.cpp:47
lldb_private::dwarf_rflags_x86_64
@ dwarf_rflags_x86_64
Definition: RegisterContext_x86.h:196
lldb_private::dwarf_r12_x86_64
@ dwarf_r12_x86_64
Definition: RegisterContext_x86.h:154
lldb_private::dwarf_r14_x86_64
@ dwarf_r14_x86_64
Definition: RegisterContext_x86.h:156
rdx
@ rdx
Definition: CompactUnwindInfo.cpp:694
lldb_private::dwarf_rsp_x86_64
@ dwarf_rsp_x86_64
Definition: RegisterContext_x86.h:148
uint32_t
lldb_private::dwarf_es_x86_64
@ dwarf_es_x86_64
Definition: RegisterContext_x86.h:198
lldb_private::XMMReg
Definition: RegisterContext_x86.h:261
LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:64
lldb_private::dwarf_gs_x86_64
@ dwarf_gs_x86_64
Definition: RegisterContext_x86.h:203
DEFINE_XMM
#define DEFINE_XMM(reg)
Definition: RegisterContextWindows_x86_64.cpp:77
RegisterContextWindows_x86_64::GetUserRegisterCount
uint32_t GetUserRegisterCount() const override
Definition: RegisterContextWindows_x86_64.cpp:148
lldb_private::dwarf_r9_x86_64
@ dwarf_r9_x86_64
Definition: RegisterContext_x86.h:151
lldb_private::dwarf_r15_x86_64
@ dwarf_r15_x86_64
Definition: RegisterContext_x86.h:157
lldb-x86-register-enums.h
uint16_t
rip
@ rip
Definition: CompactUnwindInfo.cpp:709
LLDB_REGNUM_GENERIC_ARG4
#define LLDB_REGNUM_GENERIC_ARG4
Definition: lldb-defines.h:74
RegisterContext_x86.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::dwarf_rax_x86_64
@ dwarf_rax_x86_64
Definition: RegisterContext_x86.h:141
LLDB_REGNUM_GENERIC_FP
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:65
r15
@ r15
Definition: CompactUnwindInfo.cpp:708
LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:63
lldb_private::dwarf_cs_x86_64
@ dwarf_cs_x86_64
Definition: RegisterContext_x86.h:199
rsi
@ rsi
Definition: CompactUnwindInfo.cpp:697
r9
@ r9
Definition: CompactUnwindInfo.cpp:702
lldb_private::dwarf_rdx_x86_64
@ dwarf_rdx_x86_64
Definition: RegisterContext_x86.h:142
lldb
Definition: SBAddress.h:15
RegisterContextWindows_x86_64.h
RegisterContextWindows_x86_64::GetGPRSize
size_t GetGPRSize() const override
Definition: RegisterContextWindows_x86_64.cpp:152
rbp
@ rbp
Definition: CompactUnwindInfo.cpp:699
lldb_private::dwarf_rbx_x86_64
@ dwarf_rbx_x86_64
Definition: RegisterContext_x86.h:144
lldb_private::dwarf_ds_x86_64
@ dwarf_ds_x86_64
Definition: RegisterContext_x86.h:201
RegisterContextWindows_x86_64::GetRegisterCount
uint32_t GetRegisterCount() const override
Definition: RegisterContextWindows_x86_64.cpp:144
rsp
@ rsp
Definition: CompactUnwindInfo.cpp:700
r13
@ r13
Definition: CompactUnwindInfo.cpp:706