LLDB mainline
RegisterContextWindows_x64.cpp
Go to the documentation of this file.
1//===-- RegisterContextWindows_x64.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
9#if defined(__x86_64__) || defined(_M_X64)
10
14#include "lldb/Utility/Status.h"
16
19#include "TargetThreadWindows.h"
21
22#include "llvm/ADT/STLExtras.h"
23
24using namespace lldb;
25using namespace lldb_private;
26
27#define DEFINE_GPR(reg, alt, generic) \
28{ \
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, \
33}
34
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,
41
42#define DEFINE_GPR_PSEUDO_32(reg) \
43{ \
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, \
48}
49
50#define DEFINE_GPR_PSEUDO_16(reg) \
51{ \
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, \
56}
57
58#define DEFINE_GPR_PSEUDO_8(reg) \
59{ \
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, \
64}
65
66namespace {
67
68// This enum defines the layout of the global RegisterInfo array. This is
69// necessary because lldb register sets are defined in terms of indices into
70// the register array. As such, the order of RegisterInfos defined in global
71// registers array must match the order defined here. When defining the
72// register set layouts, these values can appear in an arbitrary order, and
73// that determines the order that register values are displayed in a dump.
74enum RegisterIndex {
75 eRegisterIndexRax,
76 eRegisterIndexRbx,
77 eRegisterIndexRcx,
78 eRegisterIndexRdx,
79 eRegisterIndexRdi,
80 eRegisterIndexRsi,
81 eRegisterIndexRbp,
82 eRegisterIndexRsp,
83 eRegisterIndexR8,
84 eRegisterIndexR9,
85 eRegisterIndexR10,
86 eRegisterIndexR11,
87 eRegisterIndexR12,
88 eRegisterIndexR13,
89 eRegisterIndexR14,
90 eRegisterIndexR15,
91 eRegisterIndexRip,
92 eRegisterIndexRflags,
93 eRegisterIndexEax,
94 eRegisterIndexEbx,
95 eRegisterIndexEcx,
96 eRegisterIndexEdx,
97 eRegisterIndexEdi,
98 eRegisterIndexEsi,
99 eRegisterIndexEbp,
100 eRegisterIndexEsp,
101 eRegisterIndexR8d,
102 eRegisterIndexR9d,
103 eRegisterIndexR10d,
104 eRegisterIndexR11d,
105 eRegisterIndexR12d,
106 eRegisterIndexR13d,
107 eRegisterIndexR14d,
108 eRegisterIndexR15d,
109 eRegisterIndexAx,
110 eRegisterIndexBx,
111 eRegisterIndexCx,
112 eRegisterIndexDx,
113 eRegisterIndexDi,
114 eRegisterIndexSi,
115 eRegisterIndexBp,
116 eRegisterIndexSp,
117 eRegisterIndexR8w,
118 eRegisterIndexR9w,
119 eRegisterIndexR10w,
120 eRegisterIndexR11w,
121 eRegisterIndexR12w,
122 eRegisterIndexR13w,
123 eRegisterIndexR14w,
124 eRegisterIndexR15w,
125 eRegisterIndexAh,
126 eRegisterIndexBh,
127 eRegisterIndexCh,
128 eRegisterIndexDh,
129 eRegisterIndexAl,
130 eRegisterIndexBl,
131 eRegisterIndexCl,
132 eRegisterIndexDl,
133 eRegisterIndexDil,
134 eRegisterIndexSil,
135 eRegisterIndexBpl,
136 eRegisterIndexSpl,
137 eRegisterIndexR8l,
138 eRegisterIndexR9l,
139 eRegisterIndexR10l,
140 eRegisterIndexR11l,
141 eRegisterIndexR12l,
142 eRegisterIndexR13l,
143 eRegisterIndexR14l,
144 eRegisterIndexR15l,
145
146 eRegisterIndexXmm0,
147 eRegisterIndexXmm1,
148 eRegisterIndexXmm2,
149 eRegisterIndexXmm3,
150 eRegisterIndexXmm4,
151 eRegisterIndexXmm5,
152 eRegisterIndexXmm6,
153 eRegisterIndexXmm7,
154 eRegisterIndexXmm8,
155 eRegisterIndexXmm9,
156 eRegisterIndexXmm10,
157 eRegisterIndexXmm11,
158 eRegisterIndexXmm12,
159 eRegisterIndexXmm13,
160 eRegisterIndexXmm14,
161 eRegisterIndexXmm15
162};
163
164// Array of all register information supported by Windows x86
166 // Macro auto defines most stuff eh_frame DWARF
167 // GENERIC
168 // GDB LLDB VALUE REGS INVALIDATE REGS
169 // ================================ =========================
170 // ====================== =========================
171 // =================== ================= ========== ===============
189 {
190 DEFINE_GPR_BIN(eflags, "flags"),
193 nullptr,
194 nullptr,
195 nullptr,
196 },
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)}};
265
266static size_t k_num_register_infos = std::size(g_register_infos);
267
268// Array of lldb register numbers used to define the set of all General Purpose
269// Registers
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,
294 eRegisterIndexR15l
295};
296
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,
303 eRegisterIndexXmm15
304};
305
306RegisterSet g_register_sets[] = {
307 {"General Purpose Registers", "gpr", std::size(g_gpr_reg_indices),
308 g_gpr_reg_indices},
309 {"Floating Point Registers", "fpu", std::size(g_fpu_reg_indices),
310 g_fpu_reg_indices}};
311}
312
313// Constructors and Destructors
314RegisterContextWindows_x64::RegisterContextWindows_x64(
315 Thread &thread, uint32_t concrete_frame_idx)
316 : RegisterContextWindows(thread, concrete_frame_idx) {}
317
318RegisterContextWindows_x64::~RegisterContextWindows_x64() {}
319
320size_t RegisterContextWindows_x64::GetRegisterCount() {
321 return std::size(g_register_infos);
322}
323
324const RegisterInfo *
325RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg) {
326 if (reg < k_num_register_infos)
327 return &g_register_infos[reg];
328 return NULL;
329}
330
331size_t RegisterContextWindows_x64::GetRegisterSetCount() {
332 return std::size(g_register_sets);
333}
334
335const RegisterSet *RegisterContextWindows_x64::GetRegisterSet(size_t reg_set) {
336 return &g_register_sets[reg_set];
337}
338
339bool RegisterContextWindows_x64::ReadRegister(const RegisterInfo *reg_info,
340 RegisterValue &reg_value) {
341 if (!CacheAllRegisterValues())
342 return false;
343
344 if (reg_info == nullptr)
345 return false;
346
347 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
348
349 switch (reg) {
350#define GPR_CASE(size, reg_case, reg_val) \
351 case reg_case: \
352 reg_value.SetUInt##size(reg_val); \
353 break;
354
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));
425
426 case lldb_xmm0_x86_64:
427 reg_value.SetBytes(&m_context.Xmm0,
428 reg_info->byte_size, endian::InlHostByteOrder());
429 break;
430 case lldb_xmm1_x86_64:
431 reg_value.SetBytes(&m_context.Xmm1,
432 reg_info->byte_size, endian::InlHostByteOrder());
433 break;
434 case lldb_xmm2_x86_64:
435 reg_value.SetBytes(&m_context.Xmm2,
436 reg_info->byte_size, endian::InlHostByteOrder());
437 break;
438 case lldb_xmm3_x86_64:
439 reg_value.SetBytes(&m_context.Xmm3,
440 reg_info->byte_size, endian::InlHostByteOrder());
441 break;
442 case lldb_xmm4_x86_64:
443 reg_value.SetBytes(&m_context.Xmm4,
444 reg_info->byte_size, endian::InlHostByteOrder());
445 break;
446 case lldb_xmm5_x86_64:
447 reg_value.SetBytes(&m_context.Xmm5,
448 reg_info->byte_size, endian::InlHostByteOrder());
449 break;
450 case lldb_xmm6_x86_64:
451 reg_value.SetBytes(&m_context.Xmm6,
452 reg_info->byte_size, endian::InlHostByteOrder());
453 break;
454 case lldb_xmm7_x86_64:
455 reg_value.SetBytes(&m_context.Xmm7,
456 reg_info->byte_size, endian::InlHostByteOrder());
457 break;
458 case lldb_xmm8_x86_64:
459 reg_value.SetBytes(&m_context.Xmm8,
460 reg_info->byte_size, endian::InlHostByteOrder());
461 break;
462 case lldb_xmm9_x86_64:
463 reg_value.SetBytes(&m_context.Xmm9,
464 reg_info->byte_size, endian::InlHostByteOrder());
465 break;
467 reg_value.SetBytes(&m_context.Xmm10,
468 reg_info->byte_size, endian::InlHostByteOrder());
469 break;
471 reg_value.SetBytes(&m_context.Xmm11,
472 reg_info->byte_size, endian::InlHostByteOrder());
473 break;
475 reg_value.SetBytes(&m_context.Xmm12,
476 reg_info->byte_size, endian::InlHostByteOrder());
477 break;
479 reg_value.SetBytes(&m_context.Xmm13,
480 reg_info->byte_size, endian::InlHostByteOrder());
481 break;
483 reg_value.SetBytes(&m_context.Xmm14,
484 reg_info->byte_size, endian::InlHostByteOrder());
485 break;
487 reg_value.SetBytes(&m_context.Xmm15,
488 reg_info->byte_size, endian::InlHostByteOrder());
489 break;
490 }
491 return true;
492}
493
494bool RegisterContextWindows_x64::WriteRegister(const RegisterInfo *reg_info,
495 const RegisterValue &reg_value) {
496 // Since we cannot only write a single register value to the inferior, we
497 // need to make sure our cached copy of the register values are fresh.
498 // Otherwise when writing EAX, for example, we may also overwrite some other
499 // register with a stale value.
500 if (!CacheAllRegisterValues())
501 return false;
502
503 switch (reg_info->kinds[eRegisterKindLLDB]) {
504 case lldb_rax_x86_64:
505 m_context.Rax = reg_value.GetAsUInt64();
506 break;
507 case lldb_rbx_x86_64:
508 m_context.Rbx = reg_value.GetAsUInt64();
509 break;
510 case lldb_rcx_x86_64:
511 m_context.Rcx = reg_value.GetAsUInt64();
512 break;
513 case lldb_rdx_x86_64:
514 m_context.Rdx = reg_value.GetAsUInt64();
515 break;
516 case lldb_rdi_x86_64:
517 m_context.Rdi = reg_value.GetAsUInt64();
518 break;
519 case lldb_rsi_x86_64:
520 m_context.Rsi = reg_value.GetAsUInt64();
521 break;
522 case lldb_r8_x86_64:
523 m_context.R8 = reg_value.GetAsUInt64();
524 break;
525 case lldb_r9_x86_64:
526 m_context.R9 = reg_value.GetAsUInt64();
527 break;
528 case lldb_r10_x86_64:
529 m_context.R10 = reg_value.GetAsUInt64();
530 break;
531 case lldb_r11_x86_64:
532 m_context.R11 = reg_value.GetAsUInt64();
533 break;
534 case lldb_r12_x86_64:
535 m_context.R12 = reg_value.GetAsUInt64();
536 break;
537 case lldb_r13_x86_64:
538 m_context.R13 = reg_value.GetAsUInt64();
539 break;
540 case lldb_r14_x86_64:
541 m_context.R14 = reg_value.GetAsUInt64();
542 break;
543 case lldb_r15_x86_64:
544 m_context.R15 = reg_value.GetAsUInt64();
545 break;
546 case lldb_rbp_x86_64:
547 m_context.Rbp = reg_value.GetAsUInt64();
548 break;
549 case lldb_rsp_x86_64:
550 m_context.Rsp = reg_value.GetAsUInt64();
551 break;
552 case lldb_rip_x86_64:
553 m_context.Rip = reg_value.GetAsUInt64();
554 break;
556 m_context.EFlags = reg_value.GetAsUInt64();
557 break;
558 case lldb_xmm0_x86_64:
559 memcpy(&m_context.Xmm0, reg_value.GetBytes(), 16);
560 break;
561 case lldb_xmm1_x86_64:
562 memcpy(&m_context.Xmm1, reg_value.GetBytes(), 16);
563 break;
564 case lldb_xmm2_x86_64:
565 memcpy(&m_context.Xmm2, reg_value.GetBytes(), 16);
566 break;
567 case lldb_xmm3_x86_64:
568 memcpy(&m_context.Xmm3, reg_value.GetBytes(), 16);
569 break;
570 case lldb_xmm4_x86_64:
571 memcpy(&m_context.Xmm4, reg_value.GetBytes(), 16);
572 break;
573 case lldb_xmm5_x86_64:
574 memcpy(&m_context.Xmm5, reg_value.GetBytes(), 16);
575 break;
576 case lldb_xmm6_x86_64:
577 memcpy(&m_context.Xmm6, reg_value.GetBytes(), 16);
578 break;
579 case lldb_xmm7_x86_64:
580 memcpy(&m_context.Xmm7, reg_value.GetBytes(), 16);
581 break;
582 case lldb_xmm8_x86_64:
583 memcpy(&m_context.Xmm8, reg_value.GetBytes(), 16);
584 break;
585 case lldb_xmm9_x86_64:
586 memcpy(&m_context.Xmm9, reg_value.GetBytes(), 16);
587 break;
589 memcpy(&m_context.Xmm10, reg_value.GetBytes(), 16);
590 break;
592 memcpy(&m_context.Xmm11, reg_value.GetBytes(), 16);
593 break;
595 memcpy(&m_context.Xmm12, reg_value.GetBytes(), 16);
596 break;
598 memcpy(&m_context.Xmm13, reg_value.GetBytes(), 16);
599 break;
601 memcpy(&m_context.Xmm14, reg_value.GetBytes(), 16);
602 break;
604 memcpy(&m_context.Xmm15, reg_value.GetBytes(), 16);
605 break;
606 }
607
608 // Physically update the registers in the target process.
609 return ApplyAllRegisterValues();
610}
611
612#endif // defined(__x86_64__) || defined(_M_X64)
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
Definition: lldb-defines.h:57
#define LLDB_REGNUM_GENERIC_ARG4
Definition: lldb-defines.h:67
#define LLDB_REGNUM_GENERIC_ARG3
Definition: lldb-defines.h:65
#define LLDB_REGNUM_GENERIC_ARG1
Definition: lldb-defines.h:61
#define LLDB_REGNUM_GENERIC_FLAGS
Definition: lldb-defines.h:60
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:87
#define LLDB_REGNUM_GENERIC_ARG2
Definition: lldb-defines.h:63
#define LLDB_REGNUM_GENERIC_PC
Definition: lldb-defines.h:56
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:58
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
@ 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.