1 //===-- RegisterContextWindows_x86_64.cpp ---------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextWindows_x86_64.h"
10 #include "RegisterContext_x86.h"
11 #include "lldb-x86-register-enums.h"
15 using namespace lldb_private
;
46 #define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
47 #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
49 #reg, alt, sizeof(((GPR *)nullptr)->reg), GPR_OFFSET(reg), eEncodingUint, \
51 {kind1, kind2, kind3, kind4, lldb_##reg##_x86_64 }, nullptr, nullptr, \
55 typedef struct _FPReg
{
74 #define FPR_OFFSET(regname) \
75 (sizeof(GPR) + LLVM_EXTENSION offsetof(FPReg, regname))
77 #define DEFINE_XMM(reg) \
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, \
87 static RegisterInfo g_register_infos_x86_64
[] = {
88 // General purpose registers EH_Frame DWARF Generic Process Plugin
89 // =========================== ================== ================ ========================= ====================
90 DEFINE_GPR(rax
, nullptr, dwarf_rax_x86_64
, dwarf_rax_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
91 DEFINE_GPR(rbx
, nullptr, dwarf_rbx_x86_64
, dwarf_rbx_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
92 DEFINE_GPR(rcx
, nullptr, dwarf_rcx_x86_64
, dwarf_rcx_x86_64
, LLDB_REGNUM_GENERIC_ARG4
, LLDB_INVALID_REGNUM
),
93 DEFINE_GPR(rdx
, nullptr, dwarf_rdx_x86_64
, dwarf_rdx_x86_64
, LLDB_REGNUM_GENERIC_ARG3
, LLDB_INVALID_REGNUM
),
94 DEFINE_GPR(rdi
, nullptr, dwarf_rdi_x86_64
, dwarf_rdi_x86_64
, LLDB_REGNUM_GENERIC_ARG1
, LLDB_INVALID_REGNUM
),
95 DEFINE_GPR(rsi
, nullptr, dwarf_rsi_x86_64
, dwarf_rsi_x86_64
, LLDB_REGNUM_GENERIC_ARG2
, LLDB_INVALID_REGNUM
),
96 DEFINE_GPR(rbp
, nullptr, dwarf_rbp_x86_64
, dwarf_rbp_x86_64
, LLDB_REGNUM_GENERIC_FP
, LLDB_INVALID_REGNUM
),
97 DEFINE_GPR(rsp
, nullptr, dwarf_rsp_x86_64
, dwarf_rsp_x86_64
, LLDB_REGNUM_GENERIC_SP
, LLDB_INVALID_REGNUM
),
98 DEFINE_GPR(r8
, nullptr, dwarf_r8_x86_64
, dwarf_r8_x86_64
, LLDB_REGNUM_GENERIC_ARG5
, LLDB_INVALID_REGNUM
),
99 DEFINE_GPR(r9
, nullptr, dwarf_r9_x86_64
, dwarf_r9_x86_64
, LLDB_REGNUM_GENERIC_ARG6
, LLDB_INVALID_REGNUM
),
100 DEFINE_GPR(r10
, nullptr, dwarf_r10_x86_64
, dwarf_r10_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
101 DEFINE_GPR(r11
, nullptr, dwarf_r11_x86_64
, dwarf_r11_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
102 DEFINE_GPR(r12
, nullptr, dwarf_r12_x86_64
, dwarf_r12_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
103 DEFINE_GPR(r13
, nullptr, dwarf_r13_x86_64
, dwarf_r13_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
104 DEFINE_GPR(r14
, nullptr, dwarf_r14_x86_64
, dwarf_r14_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
105 DEFINE_GPR(r15
, nullptr, dwarf_r15_x86_64
, dwarf_r15_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
106 DEFINE_GPR(rip
, nullptr, dwarf_rip_x86_64
, dwarf_rip_x86_64
, LLDB_REGNUM_GENERIC_PC
, LLDB_INVALID_REGNUM
),
107 DEFINE_GPR(rflags
, nullptr, dwarf_rflags_x86_64
, dwarf_rflags_x86_64
, LLDB_REGNUM_GENERIC_FLAGS
, LLDB_INVALID_REGNUM
),
108 DEFINE_GPR(cs
, nullptr, dwarf_cs_x86_64
, dwarf_cs_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
109 DEFINE_GPR(fs
, nullptr, dwarf_fs_x86_64
, dwarf_fs_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
110 DEFINE_GPR(gs
, nullptr, dwarf_gs_x86_64
, dwarf_gs_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
111 DEFINE_GPR(ss
, nullptr, dwarf_ss_x86_64
, dwarf_ss_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
112 DEFINE_GPR(ds
, nullptr, dwarf_ds_x86_64
, dwarf_ds_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
113 DEFINE_GPR(es
, nullptr, dwarf_es_x86_64
, dwarf_es_x86_64
, LLDB_INVALID_REGNUM
, LLDB_INVALID_REGNUM
),
134 RegisterContextWindows_x86_64::RegisterContextWindows_x86_64(
135 const ArchSpec
&target_arch
)
136 : lldb_private::RegisterInfoInterface(target_arch
) {
137 assert(target_arch
.GetMachine() == llvm::Triple::x86_64
);
140 const RegisterInfo
*RegisterContextWindows_x86_64::GetRegisterInfo() const {
141 return g_register_infos_x86_64
;
144 uint32_t RegisterContextWindows_x86_64::GetRegisterCount() const {
145 return std::size(g_register_infos_x86_64
);
148 uint32_t RegisterContextWindows_x86_64::GetUserRegisterCount() const {
149 return std::size(g_register_infos_x86_64
);
152 size_t RegisterContextWindows_x86_64::GetGPRSize() const { return sizeof(GPR
); }