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;
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 }
53
54typedef struct _FPReg {
55 XMMReg xmm0;
56 XMMReg xmm1;
57 XMMReg xmm2;
58 XMMReg xmm3;
59 XMMReg xmm4;
60 XMMReg xmm5;
61 XMMReg xmm6;
62 XMMReg xmm7;
63 XMMReg xmm8;
64 XMMReg xmm9;
65 XMMReg xmm10;
66 XMMReg xmm11;
67 XMMReg xmm12;
68 XMMReg xmm13;
69 XMMReg xmm14;
70 XMMReg xmm15;
71} FPReg;
72
73#define FPR_OFFSET(regname) \
74 (sizeof(GPR) + LLVM_EXTENSION offsetof(FPReg, regname))
75
76#define DEFINE_XMM(reg) \
77 { \
78#reg, NULL, sizeof(((FPReg *)nullptr)->reg), FPR_OFFSET(reg), \
79 eEncodingUint, eFormatVectorOfUInt64, \
80 {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \
81 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
82 nullptr, nullptr, \
83 }
84
85// clang-format off
86static RegisterInfo g_register_infos_x86_64[] = {
87// General purpose registers EH_Frame DWARF Generic Process Plugin
88// =========================== ================== ================ ========================= ====================
113 DEFINE_XMM(xmm0),
114 DEFINE_XMM(xmm1),
115 DEFINE_XMM(xmm2),
116 DEFINE_XMM(xmm3),
117 DEFINE_XMM(xmm4),
118 DEFINE_XMM(xmm5),
119 DEFINE_XMM(xmm6),
120 DEFINE_XMM(xmm7),
121 DEFINE_XMM(xmm8),
122 DEFINE_XMM(xmm9),
123 DEFINE_XMM(xmm10),
124 DEFINE_XMM(xmm11),
125 DEFINE_XMM(xmm12),
126 DEFINE_XMM(xmm13),
127 DEFINE_XMM(xmm14),
128 DEFINE_XMM(xmm15)
129};
130// clang-format on
131} // namespace
132
134 const ArchSpec &target_arch)
135 : lldb_private::RegisterInfoInterface(target_arch) {
136 assert(target_arch.GetMachine() == llvm::Triple::x86_64);
137}
138
140 return g_register_infos_x86_64;
141}
142
144 return std::size(g_register_infos_x86_64);
145}
146
148 return std::size(g_register_infos_x86_64);
149}
150
151size_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:32
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
Definition: ArchSpec.cpp:678
RegisterInfo interface to patch RegisterInfo structure for archs.
#define LLDB_REGNUM_GENERIC_ARG6
Definition: lldb-defines.h:66
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:52
#define LLDB_REGNUM_GENERIC_ARG4
Definition: lldb-defines.h:62
#define LLDB_REGNUM_GENERIC_ARG3
Definition: lldb-defines.h:60
#define LLDB_REGNUM_GENERIC_ARG1
Definition: lldb-defines.h:56
#define LLDB_REGNUM_GENERIC_FLAGS
Definition: lldb-defines.h:55
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
#define LLDB_REGNUM_GENERIC_ARG2
Definition: lldb-defines.h:58
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:51
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:53
#define LLDB_REGNUM_GENERIC_ARG5
Definition: lldb-defines.h:64
A class that represents a running process on the host machine.
Definition: SBAddress.h:15