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, \
190 DEFINE_GPR_BIN(eflags,
"flags"),
197 DEFINE_GPR_PSEUDO_32(
eax),
198 DEFINE_GPR_PSEUDO_32(
ebx),
199 DEFINE_GPR_PSEUDO_32(
ecx),
200 DEFINE_GPR_PSEUDO_32(
edx),
201 DEFINE_GPR_PSEUDO_32(
edi),
202 DEFINE_GPR_PSEUDO_32(
esi),
203 DEFINE_GPR_PSEUDO_32(
ebp),
204 DEFINE_GPR_PSEUDO_32(
esp),
205 DEFINE_GPR_PSEUDO_32(r8d),
206 DEFINE_GPR_PSEUDO_32(r9d),
207 DEFINE_GPR_PSEUDO_32(r10d),
208 DEFINE_GPR_PSEUDO_32(r11d),
209 DEFINE_GPR_PSEUDO_32(r12d),
210 DEFINE_GPR_PSEUDO_32(r13d),
211 DEFINE_GPR_PSEUDO_32(r14d),
212 DEFINE_GPR_PSEUDO_32(r15d),
213 DEFINE_GPR_PSEUDO_16(ax),
214 DEFINE_GPR_PSEUDO_16(bx),
215 DEFINE_GPR_PSEUDO_16(cx),
216 DEFINE_GPR_PSEUDO_16(dx),
217 DEFINE_GPR_PSEUDO_16(di),
218 DEFINE_GPR_PSEUDO_16(si),
219 DEFINE_GPR_PSEUDO_16(bp),
220 DEFINE_GPR_PSEUDO_16(
sp),
221 DEFINE_GPR_PSEUDO_16(r8w),
222 DEFINE_GPR_PSEUDO_16(r9w),
223 DEFINE_GPR_PSEUDO_16(r10w),
224 DEFINE_GPR_PSEUDO_16(r11w),
225 DEFINE_GPR_PSEUDO_16(r12w),
226 DEFINE_GPR_PSEUDO_16(r13w),
227 DEFINE_GPR_PSEUDO_16(r14w),
228 DEFINE_GPR_PSEUDO_16(r15w),
229 DEFINE_GPR_PSEUDO_8(ah),
230 DEFINE_GPR_PSEUDO_8(bh),
231 DEFINE_GPR_PSEUDO_8(ch),
232 DEFINE_GPR_PSEUDO_8(dh),
233 DEFINE_GPR_PSEUDO_8(al),
234 DEFINE_GPR_PSEUDO_8(bl),
235 DEFINE_GPR_PSEUDO_8(cl),
236 DEFINE_GPR_PSEUDO_8(dl),
237 DEFINE_GPR_PSEUDO_8(dil),
238 DEFINE_GPR_PSEUDO_8(sil),
239 DEFINE_GPR_PSEUDO_8(bpl),
240 DEFINE_GPR_PSEUDO_8(spl),
241 DEFINE_GPR_PSEUDO_8(r8l),
242 DEFINE_GPR_PSEUDO_8(r9l),
243 DEFINE_GPR_PSEUDO_8(r10l),
244 DEFINE_GPR_PSEUDO_8(r11l),
245 DEFINE_GPR_PSEUDO_8(r12l),
246 DEFINE_GPR_PSEUDO_8(r13l),
247 DEFINE_GPR_PSEUDO_8(r14l),
248 DEFINE_GPR_PSEUDO_8(r15l),
249 {DEFINE_FPU_XMM(xmm0)},
250 {DEFINE_FPU_XMM(xmm1)},
251 {DEFINE_FPU_XMM(xmm2)},
252 {DEFINE_FPU_XMM(xmm3)},
253 {DEFINE_FPU_XMM(xmm4)},
254 {DEFINE_FPU_XMM(xmm5)},
255 {DEFINE_FPU_XMM(xmm6)},
256 {DEFINE_FPU_XMM(xmm7)},
257 {DEFINE_FPU_XMM(xmm8)},
258 {DEFINE_FPU_XMM(xmm9)},
259 {DEFINE_FPU_XMM(xmm10)},
260 {DEFINE_FPU_XMM(xmm11)},
261 {DEFINE_FPU_XMM(xmm12)},
262 {DEFINE_FPU_XMM(xmm13)},
263 {DEFINE_FPU_XMM(xmm14)},
264 {DEFINE_FPU_XMM(xmm15)}};
270uint32_t g_gpr_reg_indices[] = {
271 eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx,
272 eRegisterIndexRdx, eRegisterIndexRdi, eRegisterIndexRsi,
273 eRegisterIndexRbp, eRegisterIndexRsp, eRegisterIndexR8,
274 eRegisterIndexR9, eRegisterIndexR10, eRegisterIndexR11,
275 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
276 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags,
277 eRegisterIndexEax, eRegisterIndexEbx, eRegisterIndexEcx,
278 eRegisterIndexEdx, eRegisterIndexEdi, eRegisterIndexEsi,
279 eRegisterIndexEbp, eRegisterIndexEsp, eRegisterIndexR8d,
280 eRegisterIndexR9d, eRegisterIndexR10d, eRegisterIndexR11d,
281 eRegisterIndexR12d, eRegisterIndexR13d, eRegisterIndexR14d,
282 eRegisterIndexR15d, eRegisterIndexAx, eRegisterIndexBx,
283 eRegisterIndexCx, eRegisterIndexDx, eRegisterIndexDi,
284 eRegisterIndexSi, eRegisterIndexBp, eRegisterIndexSp,
285 eRegisterIndexR8w, eRegisterIndexR9w, eRegisterIndexR10w,
286 eRegisterIndexR11w, eRegisterIndexR12w, eRegisterIndexR13w,
287 eRegisterIndexR14w, eRegisterIndexR15w, eRegisterIndexAh,
288 eRegisterIndexBh, eRegisterIndexCh, eRegisterIndexDh,
289 eRegisterIndexAl, eRegisterIndexBl, eRegisterIndexCl,
290 eRegisterIndexDl, eRegisterIndexDil, eRegisterIndexSil,
291 eRegisterIndexBpl, eRegisterIndexSpl, eRegisterIndexR8l,
292 eRegisterIndexR9l, eRegisterIndexR10l, eRegisterIndexR11l,
293 eRegisterIndexR12l, eRegisterIndexR13l, eRegisterIndexR14l,
297uint32_t g_fpu_reg_indices[] = {
298 eRegisterIndexXmm0, eRegisterIndexXmm1, eRegisterIndexXmm2,
299 eRegisterIndexXmm3, eRegisterIndexXmm4, eRegisterIndexXmm5,
300 eRegisterIndexXmm6, eRegisterIndexXmm7, eRegisterIndexXmm8,
301 eRegisterIndexXmm9, eRegisterIndexXmm10, eRegisterIndexXmm11,
302 eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
307 {
"General Purpose Registers",
"gpr", std::size(g_gpr_reg_indices),
309 {
"Floating Point Registers",
"fpu", std::size(g_fpu_reg_indices),
314RegisterContextWindows_x64::RegisterContextWindows_x64(
315 Thread &thread, uint32_t concrete_frame_idx)
318RegisterContextWindows_x64::~RegisterContextWindows_x64() {}
320size_t RegisterContextWindows_x64::GetRegisterCount() {
325RegisterContextWindows_x64::GetRegisterInfoAtIndex(
size_t reg) {
331size_t RegisterContextWindows_x64::GetRegisterSetCount() {
332 return std::size(g_register_sets);
335const RegisterSet *RegisterContextWindows_x64::GetRegisterSet(
size_t reg_set) {
336 return &g_register_sets[reg_set];
339bool RegisterContextWindows_x64::ReadRegister(
const RegisterInfo *reg_info,
341 if (!CacheAllRegisterValues())
344 if (reg_info ==
nullptr)
350#define GPR_CASE(size, reg_case, reg_val) \
352 reg_value.SetUInt##size(reg_val); \
355 GPR_CASE(64, lldb_rax_x86_64, m_context.Rax);
356 GPR_CASE(64, lldb_rbx_x86_64, m_context.Rbx);
357 GPR_CASE(64, lldb_rcx_x86_64, m_context.Rcx);
358 GPR_CASE(64, lldb_rdx_x86_64, m_context.Rdx);
359 GPR_CASE(64, lldb_rdi_x86_64, m_context.Rdi);
360 GPR_CASE(64, lldb_rsi_x86_64, m_context.Rsi);
361 GPR_CASE(64, lldb_r8_x86_64, m_context.R8);
362 GPR_CASE(64, lldb_r9_x86_64, m_context.R9);
363 GPR_CASE(64, lldb_r10_x86_64, m_context.R10);
364 GPR_CASE(64, lldb_r11_x86_64, m_context.R11);
365 GPR_CASE(64, lldb_r12_x86_64, m_context.R12);
366 GPR_CASE(64, lldb_r13_x86_64, m_context.R13);
367 GPR_CASE(64, lldb_r14_x86_64, m_context.R14);
368 GPR_CASE(64, lldb_r15_x86_64, m_context.R15);
369 GPR_CASE(64, lldb_rbp_x86_64, m_context.Rbp);
370 GPR_CASE(64, lldb_rsp_x86_64, m_context.Rsp);
371 GPR_CASE(64, lldb_rip_x86_64, m_context.Rip);
372 GPR_CASE(64, lldb_rflags_x86_64, m_context.EFlags);
373 GPR_CASE(32, lldb_eax_x86_64,
static_cast<uint32_t
>(m_context.Rax));
374 GPR_CASE(32, lldb_ebx_x86_64,
static_cast<uint32_t
>(m_context.Rbx));
375 GPR_CASE(32, lldb_ecx_x86_64,
static_cast<uint32_t
>(m_context.Rcx));
376 GPR_CASE(32, lldb_edx_x86_64,
static_cast<uint32_t
>(m_context.Rdx));
377 GPR_CASE(32, lldb_edi_x86_64,
static_cast<uint32_t
>(m_context.Rdi));
378 GPR_CASE(32, lldb_esi_x86_64,
static_cast<uint32_t
>(m_context.Rsi));
379 GPR_CASE(32, lldb_ebp_x86_64,
static_cast<uint32_t
>(m_context.Rbp));
380 GPR_CASE(32, lldb_esp_x86_64,
static_cast<uint32_t
>(m_context.Rsp));
381 GPR_CASE(32, lldb_r8d_x86_64,
static_cast<uint32_t
>(m_context.R8));
382 GPR_CASE(32, lldb_r9d_x86_64,
static_cast<uint32_t
>(m_context.R9));
383 GPR_CASE(32, lldb_r10d_x86_64,
static_cast<uint32_t
>(m_context.R10));
384 GPR_CASE(32, lldb_r11d_x86_64,
static_cast<uint32_t
>(m_context.R11));
385 GPR_CASE(32, lldb_r12d_x86_64,
static_cast<uint32_t
>(m_context.R12));
386 GPR_CASE(32, lldb_r13d_x86_64,
static_cast<uint32_t
>(m_context.R13));
387 GPR_CASE(32, lldb_r14d_x86_64,
static_cast<uint32_t
>(m_context.R14));
388 GPR_CASE(32, lldb_r15d_x86_64,
static_cast<uint32_t
>(m_context.R15));
389 GPR_CASE(16, lldb_ax_x86_64,
static_cast<uint16_t
>(m_context.Rax));
390 GPR_CASE(16, lldb_bx_x86_64,
static_cast<uint16_t
>(m_context.Rbx));
391 GPR_CASE(16, lldb_cx_x86_64,
static_cast<uint16_t
>(m_context.Rcx));
392 GPR_CASE(16, lldb_dx_x86_64,
static_cast<uint16_t
>(m_context.Rdx));
393 GPR_CASE(16, lldb_di_x86_64,
static_cast<uint16_t
>(m_context.Rdi));
394 GPR_CASE(16, lldb_si_x86_64,
static_cast<uint16_t
>(m_context.Rsi));
395 GPR_CASE(16, lldb_bp_x86_64,
static_cast<uint16_t
>(m_context.Rbp));
396 GPR_CASE(16, lldb_sp_x86_64,
static_cast<uint16_t
>(m_context.Rsp));
397 GPR_CASE(16, lldb_r8w_x86_64,
static_cast<uint16_t
>(m_context.R8));
398 GPR_CASE(16, lldb_r9w_x86_64,
static_cast<uint16_t
>(m_context.R9));
399 GPR_CASE(16, lldb_r10w_x86_64,
static_cast<uint16_t
>(m_context.R10));
400 GPR_CASE(16, lldb_r11w_x86_64,
static_cast<uint16_t
>(m_context.R11));
401 GPR_CASE(16, lldb_r12w_x86_64,
static_cast<uint16_t
>(m_context.R12));
402 GPR_CASE(16, lldb_r13w_x86_64,
static_cast<uint16_t
>(m_context.R13));
403 GPR_CASE(16, lldb_r14w_x86_64,
static_cast<uint16_t
>(m_context.R14));
404 GPR_CASE(16, lldb_r15w_x86_64,
static_cast<uint16_t
>(m_context.R15));
405 GPR_CASE(8, lldb_ah_x86_64,
static_cast<uint16_t
>(m_context.Rax) >> 8);
406 GPR_CASE(8, lldb_bh_x86_64,
static_cast<uint16_t
>(m_context.Rbx) >> 8);
407 GPR_CASE(8, lldb_ch_x86_64,
static_cast<uint16_t
>(m_context.Rcx) >> 8);
408 GPR_CASE(8, lldb_dh_x86_64,
static_cast<uint16_t
>(m_context.Rdx) >> 8);
409 GPR_CASE(8, lldb_al_x86_64,
static_cast<uint8_t
>(m_context.Rax));
410 GPR_CASE(8, lldb_bl_x86_64,
static_cast<uint8_t
>(m_context.Rbx));
411 GPR_CASE(8, lldb_cl_x86_64,
static_cast<uint8_t
>(m_context.Rcx));
412 GPR_CASE(8, lldb_dl_x86_64,
static_cast<uint8_t
>(m_context.Rdx));
413 GPR_CASE(8, lldb_dil_x86_64,
static_cast<uint8_t
>(m_context.Rdi));
414 GPR_CASE(8, lldb_sil_x86_64,
static_cast<uint8_t
>(m_context.Rsi));
415 GPR_CASE(8, lldb_bpl_x86_64,
static_cast<uint8_t
>(m_context.Rbp));
416 GPR_CASE(8, lldb_spl_x86_64,
static_cast<uint8_t
>(m_context.Rsp));
417 GPR_CASE(8, lldb_r8l_x86_64,
static_cast<uint8_t
>(m_context.R8));
418 GPR_CASE(8, lldb_r9l_x86_64,
static_cast<uint8_t
>(m_context.R9));
419 GPR_CASE(8, lldb_r10l_x86_64,
static_cast<uint8_t
>(m_context.R10));
420 GPR_CASE(8, lldb_r11l_x86_64,
static_cast<uint8_t
>(m_context.R11));
421 GPR_CASE(8, lldb_r12l_x86_64,
static_cast<uint8_t
>(m_context.R12));
422 GPR_CASE(8, lldb_r13l_x86_64,
static_cast<uint8_t
>(m_context.R13));
423 GPR_CASE(8, lldb_r14l_x86_64,
static_cast<uint8_t
>(m_context.R14));
424 GPR_CASE(8, lldb_r15l_x86_64,
static_cast<uint8_t
>(m_context.R15));
428 reg_info->
byte_size, endian::InlHostByteOrder());
432 reg_info->
byte_size, endian::InlHostByteOrder());
436 reg_info->
byte_size, endian::InlHostByteOrder());
440 reg_info->
byte_size, endian::InlHostByteOrder());
444 reg_info->
byte_size, endian::InlHostByteOrder());
448 reg_info->
byte_size, endian::InlHostByteOrder());
452 reg_info->
byte_size, endian::InlHostByteOrder());
456 reg_info->
byte_size, endian::InlHostByteOrder());
460 reg_info->
byte_size, endian::InlHostByteOrder());
464 reg_info->
byte_size, endian::InlHostByteOrder());
467 reg_value.
SetBytes(&m_context.Xmm10,
468 reg_info->
byte_size, endian::InlHostByteOrder());
471 reg_value.
SetBytes(&m_context.Xmm11,
472 reg_info->
byte_size, endian::InlHostByteOrder());
475 reg_value.
SetBytes(&m_context.Xmm12,
476 reg_info->
byte_size, endian::InlHostByteOrder());
479 reg_value.
SetBytes(&m_context.Xmm13,
480 reg_info->
byte_size, endian::InlHostByteOrder());
483 reg_value.
SetBytes(&m_context.Xmm14,
484 reg_info->
byte_size, endian::InlHostByteOrder());
487 reg_value.
SetBytes(&m_context.Xmm15,
488 reg_info->
byte_size, endian::InlHostByteOrder());
494bool RegisterContextWindows_x64::WriteRegister(
const RegisterInfo *reg_info,
500 if (!CacheAllRegisterValues())
503 switch (reg_info->
kinds[eRegisterKindLLDB]) {
559 memcpy(&m_context.Xmm0, reg_value.
GetBytes(), 16);
562 memcpy(&m_context.Xmm1, reg_value.
GetBytes(), 16);
565 memcpy(&m_context.Xmm2, reg_value.
GetBytes(), 16);
568 memcpy(&m_context.Xmm3, reg_value.
GetBytes(), 16);
571 memcpy(&m_context.Xmm4, reg_value.
GetBytes(), 16);
574 memcpy(&m_context.Xmm5, reg_value.
GetBytes(), 16);
577 memcpy(&m_context.Xmm6, reg_value.
GetBytes(), 16);
580 memcpy(&m_context.Xmm7, reg_value.
GetBytes(), 16);
583 memcpy(&m_context.Xmm8, reg_value.
GetBytes(), 16);
586 memcpy(&m_context.Xmm9, reg_value.
GetBytes(), 16);
589 memcpy(&m_context.Xmm10, reg_value.
GetBytes(), 16);
592 memcpy(&m_context.Xmm11, reg_value.
GetBytes(), 16);
595 memcpy(&m_context.Xmm12, reg_value.
GetBytes(), 16);
598 memcpy(&m_context.Xmm13, reg_value.
GetBytes(), 16);
601 memcpy(&m_context.Xmm14, reg_value.
GetBytes(), 16);
604 memcpy(&m_context.Xmm15, reg_value.
GetBytes(), 16);
609 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.