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
15using namespace lldb_private;
16using namespace lldb;
17
18namespace {
19typedef 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, \
53 }
54
55typedef 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, \
84 }
85
86// clang-format off
87static 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 std::size(g_register_infos_x86_64);
146}
147
149 return std::size(g_register_infos_x86_64);
150}
151
152size_t RegisterContextWindows_x86_64::GetGPRSize() const { return sizeof(GPR); }
#define DEFINE_XMM(reg)
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4)
const lldb_private::RegisterInfo * GetRegisterInfo() const override
RegisterContextWindows_x86_64(const lldb_private::ArchSpec &target_arch)
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:701
RegisterInfo interface to patch RegisterInfo structure for archs.
#define LLDB_REGNUM_GENERIC_ARG6
Definition: lldb-defines.h:71
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:57
#define LLDB_REGNUM_GENERIC_ARG4
Definition: lldb-defines.h:67
#define LLDB_REGNUM_GENERIC_ARG3
Definition: lldb-defines.h:65
#define LLDB_REGNUM_GENERIC_ARG1
Definition: lldb-defines.h:61
#define LLDB_REGNUM_GENERIC_FLAGS
Definition: lldb-defines.h:60
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
#define LLDB_REGNUM_GENERIC_ARG2
Definition: lldb-defines.h:63
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:56
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:58
#define LLDB_REGNUM_GENERIC_ARG5
Definition: lldb-defines.h:69
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
Every register is described in detail including its name, alternate name (optional),...