13#define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
16#define FPR_OFFSET(regname) \
17 (LLVM_EXTENSION offsetof(UserArea, fpr) + \
18 LLVM_EXTENSION offsetof(FPR, fxsave) + \
19 LLVM_EXTENSION offsetof(FXSAVE, regname))
23#define YMM_OFFSET(reg_index) \
24 (LLVM_EXTENSION offsetof(UserArea, fpr) + \
25 LLVM_EXTENSION offsetof(FPR, xsave) + \
26 LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
29#define GDB_REMOTE_OFFSET 128
31#define BNDR_OFFSET(reg_index) \
32 (LLVM_EXTENSION offsetof(UserArea, fpr) + \
33 LLVM_EXTENSION offsetof(FPR, xsave) + \
34 LLVM_EXTENSION offsetof(XSAVE, mpxr[reg_index]) + GDB_REMOTE_OFFSET)
36#define BNDC_OFFSET(reg_index) \
37 (LLVM_EXTENSION offsetof(UserArea, fpr) + \
38 LLVM_EXTENSION offsetof(FPR, xsave) + \
39 LLVM_EXTENSION offsetof(XSAVE, mpxc[reg_index]) + GDB_REMOTE_OFFSET)
41#ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT
44#define FPR_SIZE(reg) sizeof(((FXSAVE *)nullptr)->reg)
47#define FP_SIZE sizeof(((MMSReg *)nullptr)->bytes)
50#define XMM_SIZE sizeof(XMMReg)
53#define YMM_SIZE sizeof(YMMReg)
56#define BNDR_SIZE sizeof(MPXReg)
57#define BNDC_SIZE sizeof(MPXCsr)
59#define DR_SIZE sizeof(((DBG *)nullptr)->dr[0])
64#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
66 #reg, alt, sizeof(((GPR *)nullptr)->reg), \
67 GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
68 {kind1, kind2, kind3, kind4, \
69 lldb_##reg##_x86_64 }, \
70 nullptr, nullptr, nullptr, \
73#define DEFINE_FPR(name, reg, kind1, kind2, kind3, kind4) \
75 #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
76 {kind1, kind2, kind3, kind4, \
77 lldb_##name##_x86_64 }, \
78 nullptr, nullptr, nullptr, \
81#define DEFINE_FP_ST(reg, i) \
83 #reg #i, nullptr, FP_SIZE, \
84 LLVM_EXTENSION FPR_OFFSET( \
85 stmm[i]), eEncodingVector, eFormatVectorOfUInt8, \
86 {dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, \
87 LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \
88 nullptr, nullptr, nullptr, \
91#define DEFINE_FP_MM(reg, i, streg) \
93 #reg #i, nullptr, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
94 eEncodingUint, eFormatHex, \
95 {dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, \
96 LLDB_INVALID_REGNUM, lldb_mm##i##_x86_64 }, \
97 RegisterContextPOSIX_x86::g_contained_##streg##_64, \
98 RegisterContextPOSIX_x86::g_invalidate_##streg##_64, \
102#define DEFINE_XMM(reg, i) \
104 #reg #i, nullptr, XMM_SIZE, \
105 LLVM_EXTENSION FPR_OFFSET( \
106 reg[i]), eEncodingVector, eFormatVectorOfUInt8, \
107 {dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, \
108 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
109 lldb_##reg##i##_x86_64 }, \
110 nullptr, nullptr, nullptr, \
113#define DEFINE_YMM(reg, i) \
115 #reg #i, nullptr, YMM_SIZE, \
116 LLVM_EXTENSION YMM_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \
117 {dwarf_##reg##i##h_x86_64, \
118 dwarf_##reg##i##h_x86_64, \
119 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
120 lldb_##reg##i##_x86_64 }, \
121 nullptr, nullptr, nullptr, \
124#define DEFINE_BNDR(reg, i) \
126 #reg #i, nullptr, BNDR_SIZE, \
127 LLVM_EXTENSION BNDR_OFFSET(i), eEncodingVector, eFormatVectorOfUInt64, \
128 {dwarf_##reg##i##_x86_64, \
129 dwarf_##reg##i##_x86_64, \
130 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
131 lldb_##reg##i##_x86_64 }, \
132 nullptr, nullptr, nullptr, \
135#define DEFINE_BNDC(name, i) \
137 #name, nullptr, BNDC_SIZE, \
138 LLVM_EXTENSION BNDC_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \
139 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
140 LLDB_INVALID_REGNUM, lldb_##name##_x86_64 }, \
141 nullptr, nullptr, nullptr, \
144#define DEFINE_DR(reg, i) \
146 #reg #i, nullptr, DR_SIZE, \
147 DR_OFFSET(i), eEncodingUint, eFormatHex, \
148 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
149 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
150 lldb_##reg##i##_x86_64 }, \
151 nullptr, nullptr, nullptr, \
154#define DEFINE_GPR_PSEUDO_32(reg32, reg64) \
156 #reg32, nullptr, 4, \
157 GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
158 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
159 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
160 lldb_##reg32##_x86_64 }, \
161 RegisterContextPOSIX_x86::g_contained_##reg64, \
162 RegisterContextPOSIX_x86::g_invalidate_##reg64, \
166#define DEFINE_GPR_PSEUDO_16(reg16, reg64) \
168 #reg16, nullptr, 2, \
169 GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
170 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
171 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
172 lldb_##reg16##_x86_64 }, \
173 RegisterContextPOSIX_x86::g_contained_##reg64, \
174 RegisterContextPOSIX_x86::g_invalidate_##reg64, \
178#define DEFINE_GPR_PSEUDO_8H(reg8, reg64) \
181 GPR_OFFSET(reg64) + 1, eEncodingUint, eFormatHex, \
182 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
183 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
184 lldb_##reg8##_x86_64 }, \
185 RegisterContextPOSIX_x86::g_contained_##reg64, \
186 RegisterContextPOSIX_x86::g_invalidate_##reg64, \
190#define DEFINE_GPR_PSEUDO_8L(reg8, reg64) \
193 GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
194 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
195 LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
196 lldb_##reg8##_x86_64 }, \
197 RegisterContextPOSIX_x86::g_contained_##reg64, \
198 RegisterContextPOSIX_x86::g_invalidate_##reg64, \
202#define DEFINE_FPR_32(name, reg, kind1, kind2, kind3, kind4, reg64) \
204 #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
205 {kind1, kind2, kind3, kind4, lldb_##name##_x86_64 }, \
206 RegisterContextPOSIX_x86::g_contained_##reg64, \
207 RegisterContextPOSIX_x86::g_invalidate_##reg64, \
212static RegisterInfo g_register_infos_x86_64[] = {
240 DEFINE_GPR_PSEUDO_32(
eax,
rax), DEFINE_GPR_PSEUDO_32(
ebx,
rbx),
241 DEFINE_GPR_PSEUDO_32(
ecx,
rcx), DEFINE_GPR_PSEUDO_32(
edx,
rdx),
242 DEFINE_GPR_PSEUDO_32(
edi,
rdi), DEFINE_GPR_PSEUDO_32(
esi,
rsi),
243 DEFINE_GPR_PSEUDO_32(
ebp,
rbp), DEFINE_GPR_PSEUDO_32(
esp,
rsp),
244 DEFINE_GPR_PSEUDO_32(r8d,
r8), DEFINE_GPR_PSEUDO_32(r9d,
r9),
245 DEFINE_GPR_PSEUDO_32(r10d,
r10), DEFINE_GPR_PSEUDO_32(r11d,
r11),
246 DEFINE_GPR_PSEUDO_32(r12d,
r12), DEFINE_GPR_PSEUDO_32(r13d,
r13),
247 DEFINE_GPR_PSEUDO_32(r14d,
r14), DEFINE_GPR_PSEUDO_32(r15d,
r15),
248 DEFINE_GPR_PSEUDO_16(ax,
rax), DEFINE_GPR_PSEUDO_16(bx,
rbx),
249 DEFINE_GPR_PSEUDO_16(cx,
rcx), DEFINE_GPR_PSEUDO_16(dx,
rdx),
250 DEFINE_GPR_PSEUDO_16(di,
rdi), DEFINE_GPR_PSEUDO_16(si,
rsi),
251 DEFINE_GPR_PSEUDO_16(bp,
rbp), DEFINE_GPR_PSEUDO_16(
sp,
rsp),
252 DEFINE_GPR_PSEUDO_16(r8w,
r8), DEFINE_GPR_PSEUDO_16(r9w,
r9),
253 DEFINE_GPR_PSEUDO_16(r10w,
r10), DEFINE_GPR_PSEUDO_16(r11w,
r11),
254 DEFINE_GPR_PSEUDO_16(r12w,
r12), DEFINE_GPR_PSEUDO_16(r13w,
r13),
255 DEFINE_GPR_PSEUDO_16(r14w,
r14), DEFINE_GPR_PSEUDO_16(r15w,
r15),
256 DEFINE_GPR_PSEUDO_8H(ah,
rax), DEFINE_GPR_PSEUDO_8H(bh,
rbx),
257 DEFINE_GPR_PSEUDO_8H(ch,
rcx), DEFINE_GPR_PSEUDO_8H(dh,
rdx),
258 DEFINE_GPR_PSEUDO_8L(al,
rax), DEFINE_GPR_PSEUDO_8L(bl,
rbx),
259 DEFINE_GPR_PSEUDO_8L(cl,
rcx), DEFINE_GPR_PSEUDO_8L(dl,
rdx),
260 DEFINE_GPR_PSEUDO_8L(dil,
rdi), DEFINE_GPR_PSEUDO_8L(sil,
rsi),
261 DEFINE_GPR_PSEUDO_8L(bpl,
rbp), DEFINE_GPR_PSEUDO_8L(spl,
rsp),
262 DEFINE_GPR_PSEUDO_8L(r8l,
r8), DEFINE_GPR_PSEUDO_8L(r9l,
r9),
263 DEFINE_GPR_PSEUDO_8L(r10l,
r10), DEFINE_GPR_PSEUDO_8L(r11l,
r11),
264 DEFINE_GPR_PSEUDO_8L(r12l,
r12), DEFINE_GPR_PSEUDO_8L(r13l,
r13),
265 DEFINE_GPR_PSEUDO_8L(r14l,
r14), DEFINE_GPR_PSEUDO_8L(r15l,
r15),
283 DEFINE_FP_ST(st, 0), DEFINE_FP_ST(st, 1), DEFINE_FP_ST(st, 2),
284 DEFINE_FP_ST(st, 3), DEFINE_FP_ST(st, 4), DEFINE_FP_ST(st, 5),
285 DEFINE_FP_ST(st, 6), DEFINE_FP_ST(st, 7),
287 DEFINE_FP_MM(mm, 0, st0), DEFINE_FP_MM(mm, 1, st1),
288 DEFINE_FP_MM(mm, 2, st2), DEFINE_FP_MM(mm, 3, st3),
289 DEFINE_FP_MM(mm, 4, st4), DEFINE_FP_MM(mm, 5, st5),
290 DEFINE_FP_MM(mm, 6, st6), DEFINE_FP_MM(mm, 7, st7),
301 DEFINE_YMM(ymm, 0), DEFINE_YMM(ymm, 1), DEFINE_YMM(ymm, 2),
302 DEFINE_YMM(ymm, 3), DEFINE_YMM(ymm, 4), DEFINE_YMM(ymm, 5),
303 DEFINE_YMM(ymm, 6), DEFINE_YMM(ymm, 7), DEFINE_YMM(ymm, 8),
304 DEFINE_YMM(ymm, 9), DEFINE_YMM(ymm, 10), DEFINE_YMM(ymm, 11),
305 DEFINE_YMM(ymm, 12), DEFINE_YMM(ymm, 13), DEFINE_YMM(ymm, 14),
314 DEFINE_BNDC(bndcfgu, 0),
315 DEFINE_BNDC(bndstatus, 1),
318 DEFINE_DR(dr, 0), DEFINE_DR(dr, 1), DEFINE_DR(dr, 2), DEFINE_DR(dr, 3),
319 DEFINE_DR(dr, 4), DEFINE_DR(dr, 5), DEFINE_DR(dr, 6), DEFINE_DR(dr, 7)};
323static_assert((
sizeof(g_register_infos_x86_64) /
324 sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64,
325 "g_register_infos_x86_64 has wrong number of register infos");
339#undef DEFINE_GPR_PSEUDO_32
340#undef DEFINE_GPR_PSEUDO_16
341#undef DEFINE_GPR_PSEUDO_8H
342#undef DEFINE_GPR_PSEUDO_8L
346#ifdef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
348#define UPDATE_GPR_INFO(reg, reg64) \
350 g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64); \
353#define UPDATE_GPR_INFO_8H(reg, reg64) \
355 g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64) + 1; \
358#define UPDATE_FPR_INFO(reg, reg64) \
360 g_register_infos[lldb_##reg##_i386].byte_offset = FPR_OFFSET(reg64); \
363#define UPDATE_FP_INFO(reg, i) \
365 g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(stmm[i]); \
368#define UPDATE_XMM_INFO(reg, i) \
370 g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(reg[i]); \
373#define UPDATE_YMM_INFO(reg, i) \
375 g_register_infos[lldb_##reg##i##_i386].byte_offset = YMM_OFFSET(i); \
378#define UPDATE_DR_INFO(reg_index) \
380 g_register_infos[lldb_dr##reg_index##_i386].byte_offset = \
381 DR_OFFSET(reg_index); \
394UPDATE_GPR_INFO(eflags, rflags);
395UPDATE_GPR_INFO(cs, cs);
396UPDATE_GPR_INFO(fs, fs);
397UPDATE_GPR_INFO(gs, gs);
398UPDATE_GPR_INFO(ss, ss);
399UPDATE_GPR_INFO(ds, ds);
400UPDATE_GPR_INFO(es, es);
402UPDATE_GPR_INFO(ax,
rax);
403UPDATE_GPR_INFO(bx,
rbx);
404UPDATE_GPR_INFO(cx,
rcx);
405UPDATE_GPR_INFO(dx,
rdx);
406UPDATE_GPR_INFO(di,
rdi);
407UPDATE_GPR_INFO(si,
rsi);
408UPDATE_GPR_INFO(bp,
rbp);
409UPDATE_GPR_INFO(
sp,
rsp);
410UPDATE_GPR_INFO_8H(ah,
rax);
411UPDATE_GPR_INFO_8H(bh,
rbx);
412UPDATE_GPR_INFO_8H(ch,
rcx);
413UPDATE_GPR_INFO_8H(dh,
rdx);
414UPDATE_GPR_INFO(al,
rax);
415UPDATE_GPR_INFO(bl,
rbx);
416UPDATE_GPR_INFO(cl,
rcx);
417UPDATE_GPR_INFO(dl,
rdx);
419UPDATE_FPR_INFO(fctrl, fctrl);
420UPDATE_FPR_INFO(fstat, fstat);
421UPDATE_FPR_INFO(ftag, ftag);
422UPDATE_FPR_INFO(fop, fop);
423UPDATE_FPR_INFO(fiseg, ptr.i386_.fiseg);
424UPDATE_FPR_INFO(fioff, ptr.i386_.fioff);
425UPDATE_FPR_INFO(fooff, ptr.i386_.fooff);
426UPDATE_FPR_INFO(foseg, ptr.i386_.foseg);
427UPDATE_FPR_INFO(mxcsr, mxcsr);
428UPDATE_FPR_INFO(mxcsrmask, mxcsrmask);
430UPDATE_FP_INFO(st, 0);
431UPDATE_FP_INFO(st, 1);
432UPDATE_FP_INFO(st, 2);
433UPDATE_FP_INFO(st, 3);
434UPDATE_FP_INFO(st, 4);
435UPDATE_FP_INFO(st, 5);
436UPDATE_FP_INFO(st, 6);
437UPDATE_FP_INFO(st, 7);
438UPDATE_FP_INFO(mm, 0);
439UPDATE_FP_INFO(mm, 1);
440UPDATE_FP_INFO(mm, 2);
441UPDATE_FP_INFO(mm, 3);
442UPDATE_FP_INFO(mm, 4);
443UPDATE_FP_INFO(mm, 5);
444UPDATE_FP_INFO(mm, 6);
445UPDATE_FP_INFO(mm, 7);
447UPDATE_XMM_INFO(xmm, 0);
448UPDATE_XMM_INFO(xmm, 1);
449UPDATE_XMM_INFO(xmm, 2);
450UPDATE_XMM_INFO(xmm, 3);
451UPDATE_XMM_INFO(xmm, 4);
452UPDATE_XMM_INFO(xmm, 5);
453UPDATE_XMM_INFO(xmm, 6);
454UPDATE_XMM_INFO(xmm, 7);
456UPDATE_YMM_INFO(ymm, 0);
457UPDATE_YMM_INFO(ymm, 1);
458UPDATE_YMM_INFO(ymm, 2);
459UPDATE_YMM_INFO(ymm, 3);
460UPDATE_YMM_INFO(ymm, 4);
461UPDATE_YMM_INFO(ymm, 5);
462UPDATE_YMM_INFO(ymm, 6);
463UPDATE_YMM_INFO(ymm, 7);
474#undef UPDATE_GPR_INFO
475#undef UPDATE_GPR_INFO_8H
476#undef UPDATE_FPR_INFO
478#undef UPDATE_XMM_INFO
479#undef UPDATE_YMM_INFO
#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4)
#define LLDB_REGNUM_GENERIC_ARG6
#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
#define LLDB_REGNUM_GENERIC_ARG5