9#if defined(__x86_64__) || defined(_M_X64)
22#include "llvm/ADT/STLExtras.h"
27#define DEFINE_GPR(reg, alt, generic) \
29 #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase, \
30 {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, generic, \
31 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
32 nullptr, nullptr, nullptr, \
35#define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
36#define DEFINE_FPU_XMM(reg) \
37 #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
38 {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \
39 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64}, \
40 nullptr, nullptr, nullptr,
42#define DEFINE_GPR_PSEUDO_32(reg) \
44 #reg, nullptr, 4, 0, eEncodingUint, eFormatHexUppercase, \
45 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
46 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
47 nullptr, nullptr, nullptr, \
50#define DEFINE_GPR_PSEUDO_16(reg) \
52 #reg, nullptr, 2, 0, eEncodingUint, eFormatHexUppercase, \
53 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
54 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
55 nullptr, nullptr, nullptr, \
58#define DEFINE_GPR_PSEUDO_8(reg) \
60 #reg, nullptr, 1, 0, eEncodingUint, eFormatHexUppercase, \
61 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
62 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
63 nullptr, nullptr, nullptr, \
184 DEFINE_GPR_BIN(eflags,
"flags"),
191 DEFINE_GPR_PSEUDO_32(
eax),
192 DEFINE_GPR_PSEUDO_32(
ebx),
193 DEFINE_GPR_PSEUDO_32(
ecx),
194 DEFINE_GPR_PSEUDO_32(
edx),
195 DEFINE_GPR_PSEUDO_32(
edi),
196 DEFINE_GPR_PSEUDO_32(
esi),
197 DEFINE_GPR_PSEUDO_32(
ebp),
198 DEFINE_GPR_PSEUDO_32(
esp),
199 DEFINE_GPR_PSEUDO_32(r8d),
200 DEFINE_GPR_PSEUDO_32(r9d),
201 DEFINE_GPR_PSEUDO_32(r10d),
202 DEFINE_GPR_PSEUDO_32(r11d),
203 DEFINE_GPR_PSEUDO_32(r12d),
204 DEFINE_GPR_PSEUDO_32(r13d),
205 DEFINE_GPR_PSEUDO_32(r14d),
206 DEFINE_GPR_PSEUDO_32(r15d),
207 DEFINE_GPR_PSEUDO_16(ax),
208 DEFINE_GPR_PSEUDO_16(bx),
209 DEFINE_GPR_PSEUDO_16(cx),
210 DEFINE_GPR_PSEUDO_16(dx),
211 DEFINE_GPR_PSEUDO_16(di),
212 DEFINE_GPR_PSEUDO_16(si),
213 DEFINE_GPR_PSEUDO_16(bp),
214 DEFINE_GPR_PSEUDO_16(
sp),
215 DEFINE_GPR_PSEUDO_16(r8w),
216 DEFINE_GPR_PSEUDO_16(r9w),
217 DEFINE_GPR_PSEUDO_16(r10w),
218 DEFINE_GPR_PSEUDO_16(r11w),
219 DEFINE_GPR_PSEUDO_16(r12w),
220 DEFINE_GPR_PSEUDO_16(r13w),
221 DEFINE_GPR_PSEUDO_16(r14w),
222 DEFINE_GPR_PSEUDO_16(r15w),
223 DEFINE_GPR_PSEUDO_8(ah),
224 DEFINE_GPR_PSEUDO_8(bh),
225 DEFINE_GPR_PSEUDO_8(ch),
226 DEFINE_GPR_PSEUDO_8(dh),
227 DEFINE_GPR_PSEUDO_8(al),
228 DEFINE_GPR_PSEUDO_8(bl),
229 DEFINE_GPR_PSEUDO_8(cl),
230 DEFINE_GPR_PSEUDO_8(dl),
231 DEFINE_GPR_PSEUDO_8(dil),
232 DEFINE_GPR_PSEUDO_8(sil),
233 DEFINE_GPR_PSEUDO_8(bpl),
234 DEFINE_GPR_PSEUDO_8(spl),
235 DEFINE_GPR_PSEUDO_8(r8l),
236 DEFINE_GPR_PSEUDO_8(r9l),
237 DEFINE_GPR_PSEUDO_8(r10l),
238 DEFINE_GPR_PSEUDO_8(r11l),
239 DEFINE_GPR_PSEUDO_8(r12l),
240 DEFINE_GPR_PSEUDO_8(r13l),
241 DEFINE_GPR_PSEUDO_8(r14l),
242 DEFINE_GPR_PSEUDO_8(r15l),
243 {DEFINE_FPU_XMM(xmm0)},
244 {DEFINE_FPU_XMM(xmm1)},
245 {DEFINE_FPU_XMM(xmm2)},
246 {DEFINE_FPU_XMM(xmm3)},
247 {DEFINE_FPU_XMM(xmm4)},
248 {DEFINE_FPU_XMM(xmm5)},
249 {DEFINE_FPU_XMM(xmm6)},
250 {DEFINE_FPU_XMM(xmm7)},
251 {DEFINE_FPU_XMM(xmm8)},
252 {DEFINE_FPU_XMM(xmm9)},
253 {DEFINE_FPU_XMM(xmm10)},
254 {DEFINE_FPU_XMM(xmm11)},
255 {DEFINE_FPU_XMM(xmm12)},
256 {DEFINE_FPU_XMM(xmm13)},
257 {DEFINE_FPU_XMM(xmm14)},
258 {DEFINE_FPU_XMM(xmm15)}};
264uint32_t g_gpr_reg_indices[] = {
265 eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx,
266 eRegisterIndexRdx, eRegisterIndexRdi, eRegisterIndexRsi,
267 eRegisterIndexRbp, eRegisterIndexRsp, eRegisterIndexR8,
268 eRegisterIndexR9, eRegisterIndexR10, eRegisterIndexR11,
269 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
270 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags,
271 eRegisterIndexEax, eRegisterIndexEbx, eRegisterIndexEcx,
272 eRegisterIndexEdx, eRegisterIndexEdi, eRegisterIndexEsi,
273 eRegisterIndexEbp, eRegisterIndexEsp, eRegisterIndexR8d,
274 eRegisterIndexR9d, eRegisterIndexR10d, eRegisterIndexR11d,
275 eRegisterIndexR12d, eRegisterIndexR13d, eRegisterIndexR14d,
276 eRegisterIndexR15d, eRegisterIndexAx, eRegisterIndexBx,
277 eRegisterIndexCx, eRegisterIndexDx, eRegisterIndexDi,
278 eRegisterIndexSi, eRegisterIndexBp, eRegisterIndexSp,
279 eRegisterIndexR8w, eRegisterIndexR9w, eRegisterIndexR10w,
280 eRegisterIndexR11w, eRegisterIndexR12w, eRegisterIndexR13w,
281 eRegisterIndexR14w, eRegisterIndexR15w, eRegisterIndexAh,
282 eRegisterIndexBh, eRegisterIndexCh, eRegisterIndexDh,
283 eRegisterIndexAl, eRegisterIndexBl, eRegisterIndexCl,
284 eRegisterIndexDl, eRegisterIndexDil, eRegisterIndexSil,
285 eRegisterIndexBpl, eRegisterIndexSpl, eRegisterIndexR8l,
286 eRegisterIndexR9l, eRegisterIndexR10l, eRegisterIndexR11l,
287 eRegisterIndexR12l, eRegisterIndexR13l, eRegisterIndexR14l,
291uint32_t g_fpu_reg_indices[] = {
292 eRegisterIndexXmm0, eRegisterIndexXmm1, eRegisterIndexXmm2,
293 eRegisterIndexXmm3, eRegisterIndexXmm4, eRegisterIndexXmm5,
294 eRegisterIndexXmm6, eRegisterIndexXmm7, eRegisterIndexXmm8,
295 eRegisterIndexXmm9, eRegisterIndexXmm10, eRegisterIndexXmm11,
296 eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
301 {
"General Purpose Registers",
"gpr", std::size(g_gpr_reg_indices),
303 {
"Floating Point Registers",
"fpu", std::size(g_fpu_reg_indices),
308RegisterContextWindows_x64::RegisterContextWindows_x64(
309 Thread &thread, uint32_t concrete_frame_idx)
312RegisterContextWindows_x64::~RegisterContextWindows_x64() {}
314size_t RegisterContextWindows_x64::GetRegisterCount() {
319RegisterContextWindows_x64::GetRegisterInfoAtIndex(
size_t reg) {
325size_t RegisterContextWindows_x64::GetRegisterSetCount() {
326 return std::size(g_register_sets);
329const RegisterSet *RegisterContextWindows_x64::GetRegisterSet(
size_t reg_set) {
330 return &g_register_sets[reg_set];
333bool RegisterContextWindows_x64::ReadRegister(
const RegisterInfo *reg_info,
335 if (!CacheAllRegisterValues())
338 if (reg_info ==
nullptr)
344#define GPR_CASE(size, reg_case, reg_val) \
346 reg_value.SetUInt##size(reg_val); \
349 GPR_CASE(64, lldb_rax_x86_64, m_context.Rax);
350 GPR_CASE(64, lldb_rbx_x86_64, m_context.Rbx);
351 GPR_CASE(64, lldb_rcx_x86_64, m_context.Rcx);
352 GPR_CASE(64, lldb_rdx_x86_64, m_context.Rdx);
353 GPR_CASE(64, lldb_rdi_x86_64, m_context.Rdi);
354 GPR_CASE(64, lldb_rsi_x86_64, m_context.Rsi);
355 GPR_CASE(64, lldb_r8_x86_64, m_context.R8);
356 GPR_CASE(64, lldb_r9_x86_64, m_context.R9);
357 GPR_CASE(64, lldb_r10_x86_64, m_context.R10);
358 GPR_CASE(64, lldb_r11_x86_64, m_context.R11);
359 GPR_CASE(64, lldb_r12_x86_64, m_context.R12);
360 GPR_CASE(64, lldb_r13_x86_64, m_context.R13);
361 GPR_CASE(64, lldb_r14_x86_64, m_context.R14);
362 GPR_CASE(64, lldb_r15_x86_64, m_context.R15);
363 GPR_CASE(64, lldb_rbp_x86_64, m_context.Rbp);
364 GPR_CASE(64, lldb_rsp_x86_64, m_context.Rsp);
365 GPR_CASE(64, lldb_rip_x86_64, m_context.Rip);
366 GPR_CASE(64, lldb_rflags_x86_64, m_context.EFlags);
367 GPR_CASE(32, lldb_eax_x86_64,
static_cast<uint32_t
>(m_context.Rax));
368 GPR_CASE(32, lldb_ebx_x86_64,
static_cast<uint32_t
>(m_context.Rbx));
369 GPR_CASE(32, lldb_ecx_x86_64,
static_cast<uint32_t
>(m_context.Rcx));
370 GPR_CASE(32, lldb_edx_x86_64,
static_cast<uint32_t
>(m_context.Rdx));
371 GPR_CASE(32, lldb_edi_x86_64,
static_cast<uint32_t
>(m_context.Rdi));
372 GPR_CASE(32, lldb_esi_x86_64,
static_cast<uint32_t
>(m_context.Rsi));
373 GPR_CASE(32, lldb_ebp_x86_64,
static_cast<uint32_t
>(m_context.Rbp));
374 GPR_CASE(32, lldb_esp_x86_64,
static_cast<uint32_t
>(m_context.Rsp));
375 GPR_CASE(32, lldb_r8d_x86_64,
static_cast<uint32_t
>(m_context.R8));
376 GPR_CASE(32, lldb_r9d_x86_64,
static_cast<uint32_t
>(m_context.R9));
377 GPR_CASE(32, lldb_r10d_x86_64,
static_cast<uint32_t
>(m_context.R10));
378 GPR_CASE(32, lldb_r11d_x86_64,
static_cast<uint32_t
>(m_context.R11));
379 GPR_CASE(32, lldb_r12d_x86_64,
static_cast<uint32_t
>(m_context.R12));
380 GPR_CASE(32, lldb_r13d_x86_64,
static_cast<uint32_t
>(m_context.R13));
381 GPR_CASE(32, lldb_r14d_x86_64,
static_cast<uint32_t
>(m_context.R14));
382 GPR_CASE(32, lldb_r15d_x86_64,
static_cast<uint32_t
>(m_context.R15));
383 GPR_CASE(16, lldb_ax_x86_64,
static_cast<uint16_t
>(m_context.Rax));
384 GPR_CASE(16, lldb_bx_x86_64,
static_cast<uint16_t
>(m_context.Rbx));
385 GPR_CASE(16, lldb_cx_x86_64,
static_cast<uint16_t
>(m_context.Rcx));
386 GPR_CASE(16, lldb_dx_x86_64,
static_cast<uint16_t
>(m_context.Rdx));
387 GPR_CASE(16, lldb_di_x86_64,
static_cast<uint16_t
>(m_context.Rdi));
388 GPR_CASE(16, lldb_si_x86_64,
static_cast<uint16_t
>(m_context.Rsi));
389 GPR_CASE(16, lldb_bp_x86_64,
static_cast<uint16_t
>(m_context.Rbp));
390 GPR_CASE(16, lldb_sp_x86_64,
static_cast<uint16_t
>(m_context.Rsp));
391 GPR_CASE(16, lldb_r8w_x86_64,
static_cast<uint16_t
>(m_context.R8));
392 GPR_CASE(16, lldb_r9w_x86_64,
static_cast<uint16_t
>(m_context.R9));
393 GPR_CASE(16, lldb_r10w_x86_64,
static_cast<uint16_t
>(m_context.R10));
394 GPR_CASE(16, lldb_r11w_x86_64,
static_cast<uint16_t
>(m_context.R11));
395 GPR_CASE(16, lldb_r12w_x86_64,
static_cast<uint16_t
>(m_context.R12));
396 GPR_CASE(16, lldb_r13w_x86_64,
static_cast<uint16_t
>(m_context.R13));
397 GPR_CASE(16, lldb_r14w_x86_64,
static_cast<uint16_t
>(m_context.R14));
398 GPR_CASE(16, lldb_r15w_x86_64,
static_cast<uint16_t
>(m_context.R15));
399 GPR_CASE(8, lldb_ah_x86_64,
static_cast<uint16_t
>(m_context.Rax) >> 8);
400 GPR_CASE(8, lldb_bh_x86_64,
static_cast<uint16_t
>(m_context.Rbx) >> 8);
401 GPR_CASE(8, lldb_ch_x86_64,
static_cast<uint16_t
>(m_context.Rcx) >> 8);
402 GPR_CASE(8, lldb_dh_x86_64,
static_cast<uint16_t
>(m_context.Rdx) >> 8);
403 GPR_CASE(8, lldb_al_x86_64,
static_cast<uint8_t
>(m_context.Rax));
404 GPR_CASE(8, lldb_bl_x86_64,
static_cast<uint8_t
>(m_context.Rbx));
405 GPR_CASE(8, lldb_cl_x86_64,
static_cast<uint8_t
>(m_context.Rcx));
406 GPR_CASE(8, lldb_dl_x86_64,
static_cast<uint8_t
>(m_context.Rdx));
407 GPR_CASE(8, lldb_dil_x86_64,
static_cast<uint8_t
>(m_context.Rdi));
408 GPR_CASE(8, lldb_sil_x86_64,
static_cast<uint8_t
>(m_context.Rsi));
409 GPR_CASE(8, lldb_bpl_x86_64,
static_cast<uint8_t
>(m_context.Rbp));
410 GPR_CASE(8, lldb_spl_x86_64,
static_cast<uint8_t
>(m_context.Rsp));
411 GPR_CASE(8, lldb_r8l_x86_64,
static_cast<uint8_t
>(m_context.R8));
412 GPR_CASE(8, lldb_r9l_x86_64,
static_cast<uint8_t
>(m_context.R9));
413 GPR_CASE(8, lldb_r10l_x86_64,
static_cast<uint8_t
>(m_context.R10));
414 GPR_CASE(8, lldb_r11l_x86_64,
static_cast<uint8_t
>(m_context.R11));
415 GPR_CASE(8, lldb_r12l_x86_64,
static_cast<uint8_t
>(m_context.R12));
416 GPR_CASE(8, lldb_r13l_x86_64,
static_cast<uint8_t
>(m_context.R13));
417 GPR_CASE(8, lldb_r14l_x86_64,
static_cast<uint8_t
>(m_context.R14));
418 GPR_CASE(8, lldb_r15l_x86_64,
static_cast<uint8_t
>(m_context.R15));
422 reg_info->
byte_size, endian::InlHostByteOrder());
426 reg_info->
byte_size, endian::InlHostByteOrder());
430 reg_info->
byte_size, endian::InlHostByteOrder());
434 reg_info->
byte_size, endian::InlHostByteOrder());
438 reg_info->
byte_size, endian::InlHostByteOrder());
442 reg_info->
byte_size, endian::InlHostByteOrder());
446 reg_info->
byte_size, endian::InlHostByteOrder());
450 reg_info->
byte_size, endian::InlHostByteOrder());
454 reg_info->
byte_size, endian::InlHostByteOrder());
458 reg_info->
byte_size, endian::InlHostByteOrder());
461 reg_value.
SetBytes(&m_context.Xmm10,
462 reg_info->
byte_size, endian::InlHostByteOrder());
465 reg_value.
SetBytes(&m_context.Xmm11,
466 reg_info->
byte_size, endian::InlHostByteOrder());
469 reg_value.
SetBytes(&m_context.Xmm12,
470 reg_info->
byte_size, endian::InlHostByteOrder());
473 reg_value.
SetBytes(&m_context.Xmm13,
474 reg_info->
byte_size, endian::InlHostByteOrder());
477 reg_value.
SetBytes(&m_context.Xmm14,
478 reg_info->
byte_size, endian::InlHostByteOrder());
481 reg_value.
SetBytes(&m_context.Xmm15,
482 reg_info->
byte_size, endian::InlHostByteOrder());
488bool RegisterContextWindows_x64::WriteRegister(
const RegisterInfo *reg_info,
494 if (!CacheAllRegisterValues())
497 switch (reg_info->
kinds[eRegisterKindLLDB]) {
553 memcpy(&m_context.Xmm0, reg_value.
GetBytes(), 16);
556 memcpy(&m_context.Xmm1, reg_value.
GetBytes(), 16);
559 memcpy(&m_context.Xmm2, reg_value.
GetBytes(), 16);
562 memcpy(&m_context.Xmm3, reg_value.
GetBytes(), 16);
565 memcpy(&m_context.Xmm4, reg_value.
GetBytes(), 16);
568 memcpy(&m_context.Xmm5, reg_value.
GetBytes(), 16);
571 memcpy(&m_context.Xmm6, reg_value.
GetBytes(), 16);
574 memcpy(&m_context.Xmm7, reg_value.
GetBytes(), 16);
577 memcpy(&m_context.Xmm8, reg_value.
GetBytes(), 16);
580 memcpy(&m_context.Xmm9, reg_value.
GetBytes(), 16);
583 memcpy(&m_context.Xmm10, reg_value.
GetBytes(), 16);
586 memcpy(&m_context.Xmm11, reg_value.
GetBytes(), 16);
589 memcpy(&m_context.Xmm12, reg_value.
GetBytes(), 16);
592 memcpy(&m_context.Xmm13, reg_value.
GetBytes(), 16);
595 memcpy(&m_context.Xmm14, reg_value.
GetBytes(), 16);
598 memcpy(&m_context.Xmm15, reg_value.
GetBytes(), 16);
603 return ApplyAllRegisterValues();
static const uint32_t k_num_register_infos
static const RegisterInfo g_register_infos[]
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4)
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
const void * GetBytes() const
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_ARG4
#define LLDB_REGNUM_GENERIC_ARG3
#define LLDB_REGNUM_GENERIC_ARG1
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_ARG2
#define LLDB_REGNUM_GENERIC_PC
#define LLDB_REGNUM_GENERIC_FP
A class that represents a running process on the host machine.
@ eRegisterKindLLDB
lldb's internal register numbers
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_size
Size in bytes of the register.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.
Registers are grouped into register sets.