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 "ProcessWindowsLog.h"
21#include "TargetThreadWindows.h"
22
23#include "llvm/ADT/STLExtras.h"
24
25using namespace lldb;
26using namespace lldb_private;
27
28#define DEFINE_GPR(reg, alt, generic) \
29{ \
30 #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase, \
31 {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, generic, \
32 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
33 nullptr, nullptr, nullptr, \
34}
35
36#define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
37#define DEFINE_FPU_XMM(reg) \
38 #reg, nullptr, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
39 {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \
40 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64}, \
41 nullptr, nullptr, nullptr,
42
43#define DEFINE_GPR_PSEUDO_32(reg) \
44{ \
45 #reg, nullptr, 4, 0, eEncodingUint, eFormatHexUppercase, \
46 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
47 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
48 nullptr, nullptr, nullptr, \
49}
50
51#define DEFINE_GPR_PSEUDO_16(reg) \
52{ \
53 #reg, nullptr, 2, 0, eEncodingUint, eFormatHexUppercase, \
54 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
55 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
56 nullptr, nullptr, nullptr, \
57}
58
59#define DEFINE_GPR_PSEUDO_8(reg) \
60{ \
61 #reg, nullptr, 1, 0, eEncodingUint, eFormatHexUppercase, \
62 {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
63 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
64 nullptr, nullptr, nullptr, \
65}
66
67namespace {
68
69// This enum defines the layout of the global RegisterInfo array. This is
70// necessary because lldb register sets are defined in terms of indices into
71// the register array. As such, the order of RegisterInfos defined in global
72// registers array must match the order defined here. When defining the
73// register set layouts, these values can appear in an arbitrary order, and
74// that determines the order that register values are displayed in a dump.
75enum RegisterIndex {
76 eRegisterIndexRax,
77 eRegisterIndexRbx,
78 eRegisterIndexRcx,
79 eRegisterIndexRdx,
80 eRegisterIndexRdi,
81 eRegisterIndexRsi,
82 eRegisterIndexRbp,
83 eRegisterIndexRsp,
84 eRegisterIndexR8,
85 eRegisterIndexR9,
86 eRegisterIndexR10,
87 eRegisterIndexR11,
88 eRegisterIndexR12,
89 eRegisterIndexR13,
90 eRegisterIndexR14,
91 eRegisterIndexR15,
92 eRegisterIndexRip,
93 eRegisterIndexRflags,
94 eRegisterIndexEax,
95 eRegisterIndexEbx,
96 eRegisterIndexEcx,
97 eRegisterIndexEdx,
98 eRegisterIndexEdi,
99 eRegisterIndexEsi,
100 eRegisterIndexEbp,
101 eRegisterIndexEsp,
102 eRegisterIndexR8d,
103 eRegisterIndexR9d,
104 eRegisterIndexR10d,
105 eRegisterIndexR11d,
106 eRegisterIndexR12d,
107 eRegisterIndexR13d,
108 eRegisterIndexR14d,
109 eRegisterIndexR15d,
110 eRegisterIndexAx,
111 eRegisterIndexBx,
112 eRegisterIndexCx,
113 eRegisterIndexDx,
114 eRegisterIndexDi,
115 eRegisterIndexSi,
116 eRegisterIndexBp,
117 eRegisterIndexSp,
118 eRegisterIndexR8w,
119 eRegisterIndexR9w,
120 eRegisterIndexR10w,
121 eRegisterIndexR11w,
122 eRegisterIndexR12w,
123 eRegisterIndexR13w,
124 eRegisterIndexR14w,
125 eRegisterIndexR15w,
126 eRegisterIndexAh,
127 eRegisterIndexBh,
128 eRegisterIndexCh,
129 eRegisterIndexDh,
130 eRegisterIndexAl,
131 eRegisterIndexBl,
132 eRegisterIndexCl,
133 eRegisterIndexDl,
134 eRegisterIndexDil,
135 eRegisterIndexSil,
136 eRegisterIndexBpl,
137 eRegisterIndexSpl,
138 eRegisterIndexR8l,
139 eRegisterIndexR9l,
140 eRegisterIndexR10l,
141 eRegisterIndexR11l,
142 eRegisterIndexR12l,
143 eRegisterIndexR13l,
144 eRegisterIndexR14l,
145 eRegisterIndexR15l,
146
147 eRegisterIndexXmm0,
148 eRegisterIndexXmm1,
149 eRegisterIndexXmm2,
150 eRegisterIndexXmm3,
151 eRegisterIndexXmm4,
152 eRegisterIndexXmm5,
153 eRegisterIndexXmm6,
154 eRegisterIndexXmm7,
155 eRegisterIndexXmm8,
156 eRegisterIndexXmm9,
157 eRegisterIndexXmm10,
158 eRegisterIndexXmm11,
159 eRegisterIndexXmm12,
160 eRegisterIndexXmm13,
161 eRegisterIndexXmm14,
162 eRegisterIndexXmm15
163};
164
165// Array of all register information supported by Windows x86
184 {
185 DEFINE_GPR_BIN(eflags, "flags"),
188 nullptr,
189 nullptr,
190 nullptr,
191 },
192 DEFINE_GPR_PSEUDO_32(eax),
193 DEFINE_GPR_PSEUDO_32(ebx),
194 DEFINE_GPR_PSEUDO_32(ecx),
195 DEFINE_GPR_PSEUDO_32(edx),
196 DEFINE_GPR_PSEUDO_32(edi),
197 DEFINE_GPR_PSEUDO_32(esi),
198 DEFINE_GPR_PSEUDO_32(ebp),
199 DEFINE_GPR_PSEUDO_32(esp),
200 DEFINE_GPR_PSEUDO_32(r8d),
201 DEFINE_GPR_PSEUDO_32(r9d),
202 DEFINE_GPR_PSEUDO_32(r10d),
203 DEFINE_GPR_PSEUDO_32(r11d),
204 DEFINE_GPR_PSEUDO_32(r12d),
205 DEFINE_GPR_PSEUDO_32(r13d),
206 DEFINE_GPR_PSEUDO_32(r14d),
207 DEFINE_GPR_PSEUDO_32(r15d),
208 DEFINE_GPR_PSEUDO_16(ax),
209 DEFINE_GPR_PSEUDO_16(bx),
210 DEFINE_GPR_PSEUDO_16(cx),
211 DEFINE_GPR_PSEUDO_16(dx),
212 DEFINE_GPR_PSEUDO_16(di),
213 DEFINE_GPR_PSEUDO_16(si),
214 DEFINE_GPR_PSEUDO_16(bp),
215 DEFINE_GPR_PSEUDO_16(sp),
216 DEFINE_GPR_PSEUDO_16(r8w),
217 DEFINE_GPR_PSEUDO_16(r9w),
218 DEFINE_GPR_PSEUDO_16(r10w),
219 DEFINE_GPR_PSEUDO_16(r11w),
220 DEFINE_GPR_PSEUDO_16(r12w),
221 DEFINE_GPR_PSEUDO_16(r13w),
222 DEFINE_GPR_PSEUDO_16(r14w),
223 DEFINE_GPR_PSEUDO_16(r15w),
224 DEFINE_GPR_PSEUDO_8(ah),
225 DEFINE_GPR_PSEUDO_8(bh),
226 DEFINE_GPR_PSEUDO_8(ch),
227 DEFINE_GPR_PSEUDO_8(dh),
228 DEFINE_GPR_PSEUDO_8(al),
229 DEFINE_GPR_PSEUDO_8(bl),
230 DEFINE_GPR_PSEUDO_8(cl),
231 DEFINE_GPR_PSEUDO_8(dl),
232 DEFINE_GPR_PSEUDO_8(dil),
233 DEFINE_GPR_PSEUDO_8(sil),
234 DEFINE_GPR_PSEUDO_8(bpl),
235 DEFINE_GPR_PSEUDO_8(spl),
236 DEFINE_GPR_PSEUDO_8(r8l),
237 DEFINE_GPR_PSEUDO_8(r9l),
238 DEFINE_GPR_PSEUDO_8(r10l),
239 DEFINE_GPR_PSEUDO_8(r11l),
240 DEFINE_GPR_PSEUDO_8(r12l),
241 DEFINE_GPR_PSEUDO_8(r13l),
242 DEFINE_GPR_PSEUDO_8(r14l),
243 DEFINE_GPR_PSEUDO_8(r15l),
244 {DEFINE_FPU_XMM(xmm0)},
245 {DEFINE_FPU_XMM(xmm1)},
246 {DEFINE_FPU_XMM(xmm2)},
247 {DEFINE_FPU_XMM(xmm3)},
248 {DEFINE_FPU_XMM(xmm4)},
249 {DEFINE_FPU_XMM(xmm5)},
250 {DEFINE_FPU_XMM(xmm6)},
251 {DEFINE_FPU_XMM(xmm7)},
252 {DEFINE_FPU_XMM(xmm8)},
253 {DEFINE_FPU_XMM(xmm9)},
254 {DEFINE_FPU_XMM(xmm10)},
255 {DEFINE_FPU_XMM(xmm11)},
256 {DEFINE_FPU_XMM(xmm12)},
257 {DEFINE_FPU_XMM(xmm13)},
258 {DEFINE_FPU_XMM(xmm14)},
259 {DEFINE_FPU_XMM(xmm15)}};
260
261static size_t k_num_register_infos = std::size(g_register_infos);
262
263// Array of lldb register numbers used to define the set of all General Purpose
264// Registers
265uint32_t g_gpr_reg_indices[] = {
266 eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx,
267 eRegisterIndexRdx, eRegisterIndexRdi, eRegisterIndexRsi,
268 eRegisterIndexRbp, eRegisterIndexRsp, eRegisterIndexR8,
269 eRegisterIndexR9, eRegisterIndexR10, eRegisterIndexR11,
270 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
271 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags,
272 eRegisterIndexEax, eRegisterIndexEbx, eRegisterIndexEcx,
273 eRegisterIndexEdx, eRegisterIndexEdi, eRegisterIndexEsi,
274 eRegisterIndexEbp, eRegisterIndexEsp, eRegisterIndexR8d,
275 eRegisterIndexR9d, eRegisterIndexR10d, eRegisterIndexR11d,
276 eRegisterIndexR12d, eRegisterIndexR13d, eRegisterIndexR14d,
277 eRegisterIndexR15d, eRegisterIndexAx, eRegisterIndexBx,
278 eRegisterIndexCx, eRegisterIndexDx, eRegisterIndexDi,
279 eRegisterIndexSi, eRegisterIndexBp, eRegisterIndexSp,
280 eRegisterIndexR8w, eRegisterIndexR9w, eRegisterIndexR10w,
281 eRegisterIndexR11w, eRegisterIndexR12w, eRegisterIndexR13w,
282 eRegisterIndexR14w, eRegisterIndexR15w, eRegisterIndexAh,
283 eRegisterIndexBh, eRegisterIndexCh, eRegisterIndexDh,
284 eRegisterIndexAl, eRegisterIndexBl, eRegisterIndexCl,
285 eRegisterIndexDl, eRegisterIndexDil, eRegisterIndexSil,
286 eRegisterIndexBpl, eRegisterIndexSpl, eRegisterIndexR8l,
287 eRegisterIndexR9l, eRegisterIndexR10l, eRegisterIndexR11l,
288 eRegisterIndexR12l, eRegisterIndexR13l, eRegisterIndexR14l,
289 eRegisterIndexR15l
290};
291
292uint32_t g_fpu_reg_indices[] = {
293 eRegisterIndexXmm0, eRegisterIndexXmm1, eRegisterIndexXmm2,
294 eRegisterIndexXmm3, eRegisterIndexXmm4, eRegisterIndexXmm5,
295 eRegisterIndexXmm6, eRegisterIndexXmm7, eRegisterIndexXmm8,
296 eRegisterIndexXmm9, eRegisterIndexXmm10, eRegisterIndexXmm11,
297 eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
298 eRegisterIndexXmm15
299};
300
301RegisterSet g_register_sets[] = {
302 {"General Purpose Registers", "gpr", std::size(g_gpr_reg_indices),
303 g_gpr_reg_indices},
304 {"Floating Point Registers", "fpu", std::size(g_fpu_reg_indices),
305 g_fpu_reg_indices}};
306}
307
308// Constructors and Destructors
309RegisterContextWindows_x64::RegisterContextWindows_x64(
310 Thread &thread, uint32_t concrete_frame_idx)
311 : RegisterContextWindows(thread, concrete_frame_idx) {}
312
313RegisterContextWindows_x64::~RegisterContextWindows_x64() {}
314
315size_t RegisterContextWindows_x64::GetRegisterCount() {
316 return std::size(g_register_infos);
317}
318
319const RegisterInfo *
320RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg) {
321 if (reg < k_num_register_infos)
322 return &g_register_infos[reg];
323 return nullptr;
324}
325
326size_t RegisterContextWindows_x64::GetRegisterSetCount() {
327 return std::size(g_register_sets);
328}
329
330const RegisterSet *RegisterContextWindows_x64::GetRegisterSet(size_t reg_set) {
331 return &g_register_sets[reg_set];
332}
333
334bool RegisterContextWindows_x64::ReadRegister(const RegisterInfo *reg_info,
335 RegisterValue &reg_value) {
336 if (!CacheAllRegisterValues())
337 return false;
338
339 if (reg_info == nullptr)
340 return false;
341
342 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
343
344 switch (reg) {
345#define GPR_CASE(size, reg_case, reg_val) \
346 case reg_case: \
347 reg_value.SetUInt##size(reg_val); \
348 break;
349
350 GPR_CASE(64, lldb_rax_x86_64, m_context.Rax);
351 GPR_CASE(64, lldb_rbx_x86_64, m_context.Rbx);
352 GPR_CASE(64, lldb_rcx_x86_64, m_context.Rcx);
353 GPR_CASE(64, lldb_rdx_x86_64, m_context.Rdx);
354 GPR_CASE(64, lldb_rdi_x86_64, m_context.Rdi);
355 GPR_CASE(64, lldb_rsi_x86_64, m_context.Rsi);
356 GPR_CASE(64, lldb_r8_x86_64, m_context.R8);
357 GPR_CASE(64, lldb_r9_x86_64, m_context.R9);
358 GPR_CASE(64, lldb_r10_x86_64, m_context.R10);
359 GPR_CASE(64, lldb_r11_x86_64, m_context.R11);
360 GPR_CASE(64, lldb_r12_x86_64, m_context.R12);
361 GPR_CASE(64, lldb_r13_x86_64, m_context.R13);
362 GPR_CASE(64, lldb_r14_x86_64, m_context.R14);
363 GPR_CASE(64, lldb_r15_x86_64, m_context.R15);
364 GPR_CASE(64, lldb_rbp_x86_64, m_context.Rbp);
365 GPR_CASE(64, lldb_rsp_x86_64, m_context.Rsp);
366 GPR_CASE(64, lldb_rip_x86_64, m_context.Rip);
367 GPR_CASE(64, lldb_rflags_x86_64, m_context.EFlags);
368 GPR_CASE(32, lldb_eax_x86_64, static_cast<uint32_t>(m_context.Rax));
369 GPR_CASE(32, lldb_ebx_x86_64, static_cast<uint32_t>(m_context.Rbx));
370 GPR_CASE(32, lldb_ecx_x86_64, static_cast<uint32_t>(m_context.Rcx));
371 GPR_CASE(32, lldb_edx_x86_64, static_cast<uint32_t>(m_context.Rdx));
372 GPR_CASE(32, lldb_edi_x86_64, static_cast<uint32_t>(m_context.Rdi));
373 GPR_CASE(32, lldb_esi_x86_64, static_cast<uint32_t>(m_context.Rsi));
374 GPR_CASE(32, lldb_ebp_x86_64, static_cast<uint32_t>(m_context.Rbp));
375 GPR_CASE(32, lldb_esp_x86_64, static_cast<uint32_t>(m_context.Rsp));
376 GPR_CASE(32, lldb_r8d_x86_64, static_cast<uint32_t>(m_context.R8));
377 GPR_CASE(32, lldb_r9d_x86_64, static_cast<uint32_t>(m_context.R9));
378 GPR_CASE(32, lldb_r10d_x86_64, static_cast<uint32_t>(m_context.R10));
379 GPR_CASE(32, lldb_r11d_x86_64, static_cast<uint32_t>(m_context.R11));
380 GPR_CASE(32, lldb_r12d_x86_64, static_cast<uint32_t>(m_context.R12));
381 GPR_CASE(32, lldb_r13d_x86_64, static_cast<uint32_t>(m_context.R13));
382 GPR_CASE(32, lldb_r14d_x86_64, static_cast<uint32_t>(m_context.R14));
383 GPR_CASE(32, lldb_r15d_x86_64, static_cast<uint32_t>(m_context.R15));
384 GPR_CASE(16, lldb_ax_x86_64, static_cast<uint16_t>(m_context.Rax));
385 GPR_CASE(16, lldb_bx_x86_64, static_cast<uint16_t>(m_context.Rbx));
386 GPR_CASE(16, lldb_cx_x86_64, static_cast<uint16_t>(m_context.Rcx));
387 GPR_CASE(16, lldb_dx_x86_64, static_cast<uint16_t>(m_context.Rdx));
388 GPR_CASE(16, lldb_di_x86_64, static_cast<uint16_t>(m_context.Rdi));
389 GPR_CASE(16, lldb_si_x86_64, static_cast<uint16_t>(m_context.Rsi));
390 GPR_CASE(16, lldb_bp_x86_64, static_cast<uint16_t>(m_context.Rbp));
391 GPR_CASE(16, lldb_sp_x86_64, static_cast<uint16_t>(m_context.Rsp));
392 GPR_CASE(16, lldb_r8w_x86_64, static_cast<uint16_t>(m_context.R8));
393 GPR_CASE(16, lldb_r9w_x86_64, static_cast<uint16_t>(m_context.R9));
394 GPR_CASE(16, lldb_r10w_x86_64, static_cast<uint16_t>(m_context.R10));
395 GPR_CASE(16, lldb_r11w_x86_64, static_cast<uint16_t>(m_context.R11));
396 GPR_CASE(16, lldb_r12w_x86_64, static_cast<uint16_t>(m_context.R12));
397 GPR_CASE(16, lldb_r13w_x86_64, static_cast<uint16_t>(m_context.R13));
398 GPR_CASE(16, lldb_r14w_x86_64, static_cast<uint16_t>(m_context.R14));
399 GPR_CASE(16, lldb_r15w_x86_64, static_cast<uint16_t>(m_context.R15));
400 GPR_CASE(8, lldb_ah_x86_64, static_cast<uint16_t>(m_context.Rax) >> 8);
401 GPR_CASE(8, lldb_bh_x86_64, static_cast<uint16_t>(m_context.Rbx) >> 8);
402 GPR_CASE(8, lldb_ch_x86_64, static_cast<uint16_t>(m_context.Rcx) >> 8);
403 GPR_CASE(8, lldb_dh_x86_64, static_cast<uint16_t>(m_context.Rdx) >> 8);
404 GPR_CASE(8, lldb_al_x86_64, static_cast<uint8_t>(m_context.Rax));
405 GPR_CASE(8, lldb_bl_x86_64, static_cast<uint8_t>(m_context.Rbx));
406 GPR_CASE(8, lldb_cl_x86_64, static_cast<uint8_t>(m_context.Rcx));
407 GPR_CASE(8, lldb_dl_x86_64, static_cast<uint8_t>(m_context.Rdx));
408 GPR_CASE(8, lldb_dil_x86_64, static_cast<uint8_t>(m_context.Rdi));
409 GPR_CASE(8, lldb_sil_x86_64, static_cast<uint8_t>(m_context.Rsi));
410 GPR_CASE(8, lldb_bpl_x86_64, static_cast<uint8_t>(m_context.Rbp));
411 GPR_CASE(8, lldb_spl_x86_64, static_cast<uint8_t>(m_context.Rsp));
412 GPR_CASE(8, lldb_r8l_x86_64, static_cast<uint8_t>(m_context.R8));
413 GPR_CASE(8, lldb_r9l_x86_64, static_cast<uint8_t>(m_context.R9));
414 GPR_CASE(8, lldb_r10l_x86_64, static_cast<uint8_t>(m_context.R10));
415 GPR_CASE(8, lldb_r11l_x86_64, static_cast<uint8_t>(m_context.R11));
416 GPR_CASE(8, lldb_r12l_x86_64, static_cast<uint8_t>(m_context.R12));
417 GPR_CASE(8, lldb_r13l_x86_64, static_cast<uint8_t>(m_context.R13));
418 GPR_CASE(8, lldb_r14l_x86_64, static_cast<uint8_t>(m_context.R14));
419 GPR_CASE(8, lldb_r15l_x86_64, static_cast<uint8_t>(m_context.R15));
420
421 case lldb_xmm0_x86_64:
422 reg_value.SetBytes(&m_context.Xmm0,
424 break;
425 case lldb_xmm1_x86_64:
426 reg_value.SetBytes(&m_context.Xmm1,
428 break;
429 case lldb_xmm2_x86_64:
430 reg_value.SetBytes(&m_context.Xmm2,
432 break;
433 case lldb_xmm3_x86_64:
434 reg_value.SetBytes(&m_context.Xmm3,
436 break;
437 case lldb_xmm4_x86_64:
438 reg_value.SetBytes(&m_context.Xmm4,
440 break;
441 case lldb_xmm5_x86_64:
442 reg_value.SetBytes(&m_context.Xmm5,
444 break;
445 case lldb_xmm6_x86_64:
446 reg_value.SetBytes(&m_context.Xmm6,
448 break;
449 case lldb_xmm7_x86_64:
450 reg_value.SetBytes(&m_context.Xmm7,
452 break;
453 case lldb_xmm8_x86_64:
454 reg_value.SetBytes(&m_context.Xmm8,
456 break;
457 case lldb_xmm9_x86_64:
458 reg_value.SetBytes(&m_context.Xmm9,
460 break;
462 reg_value.SetBytes(&m_context.Xmm10,
464 break;
466 reg_value.SetBytes(&m_context.Xmm11,
468 break;
470 reg_value.SetBytes(&m_context.Xmm12,
472 break;
474 reg_value.SetBytes(&m_context.Xmm13,
476 break;
478 reg_value.SetBytes(&m_context.Xmm14,
480 break;
482 reg_value.SetBytes(&m_context.Xmm15,
484 break;
485 }
486 return true;
487}
488
489bool RegisterContextWindows_x64::WriteRegister(const RegisterInfo *reg_info,
490 const RegisterValue &reg_value) {
491 // Since we cannot only write a single register value to the inferior, we
492 // need to make sure our cached copy of the register values are fresh.
493 // Otherwise when writing EAX, for example, we may also overwrite some other
494 // register with a stale value.
495 if (!CacheAllRegisterValues())
496 return false;
497
498 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
499
501 switch (reg) {
502 case lldb_rax_x86_64:
503 m_context.Rax = reg_value.GetAsUInt64();
504 break;
505 case lldb_rbx_x86_64:
506 m_context.Rbx = reg_value.GetAsUInt64();
507 break;
508 case lldb_rcx_x86_64:
509 m_context.Rcx = reg_value.GetAsUInt64();
510 break;
511 case lldb_rdx_x86_64:
512 m_context.Rdx = reg_value.GetAsUInt64();
513 break;
514 case lldb_rdi_x86_64:
515 m_context.Rdi = reg_value.GetAsUInt64();
516 break;
517 case lldb_rsi_x86_64:
518 m_context.Rsi = reg_value.GetAsUInt64();
519 break;
520 case lldb_r8_x86_64:
521 m_context.R8 = reg_value.GetAsUInt64();
522 break;
523 case lldb_r9_x86_64:
524 m_context.R9 = reg_value.GetAsUInt64();
525 break;
526 case lldb_r10_x86_64:
527 m_context.R10 = reg_value.GetAsUInt64();
528 break;
529 case lldb_r11_x86_64:
530 m_context.R11 = reg_value.GetAsUInt64();
531 break;
532 case lldb_r12_x86_64:
533 m_context.R12 = reg_value.GetAsUInt64();
534 break;
535 case lldb_r13_x86_64:
536 m_context.R13 = reg_value.GetAsUInt64();
537 break;
538 case lldb_r14_x86_64:
539 m_context.R14 = reg_value.GetAsUInt64();
540 break;
541 case lldb_r15_x86_64:
542 m_context.R15 = reg_value.GetAsUInt64();
543 break;
544 case lldb_rbp_x86_64:
545 m_context.Rbp = reg_value.GetAsUInt64();
546 break;
547 case lldb_rsp_x86_64:
548 m_context.Rsp = reg_value.GetAsUInt64();
549 break;
550 case lldb_rip_x86_64:
551 m_context.Rip = reg_value.GetAsUInt64();
552 break;
554 m_context.EFlags = reg_value.GetAsUInt64();
555 break;
556 case lldb_xmm0_x86_64:
557 memcpy(&m_context.Xmm0, reg_value.GetBytes(), 16);
558 break;
559 case lldb_xmm1_x86_64:
560 memcpy(&m_context.Xmm1, reg_value.GetBytes(), 16);
561 break;
562 case lldb_xmm2_x86_64:
563 memcpy(&m_context.Xmm2, reg_value.GetBytes(), 16);
564 break;
565 case lldb_xmm3_x86_64:
566 memcpy(&m_context.Xmm3, reg_value.GetBytes(), 16);
567 break;
568 case lldb_xmm4_x86_64:
569 memcpy(&m_context.Xmm4, reg_value.GetBytes(), 16);
570 break;
571 case lldb_xmm5_x86_64:
572 memcpy(&m_context.Xmm5, reg_value.GetBytes(), 16);
573 break;
574 case lldb_xmm6_x86_64:
575 memcpy(&m_context.Xmm6, reg_value.GetBytes(), 16);
576 break;
577 case lldb_xmm7_x86_64:
578 memcpy(&m_context.Xmm7, reg_value.GetBytes(), 16);
579 break;
580 case lldb_xmm8_x86_64:
581 memcpy(&m_context.Xmm8, reg_value.GetBytes(), 16);
582 break;
583 case lldb_xmm9_x86_64:
584 memcpy(&m_context.Xmm9, reg_value.GetBytes(), 16);
585 break;
587 memcpy(&m_context.Xmm10, reg_value.GetBytes(), 16);
588 break;
590 memcpy(&m_context.Xmm11, reg_value.GetBytes(), 16);
591 break;
593 memcpy(&m_context.Xmm12, reg_value.GetBytes(), 16);
594 break;
596 memcpy(&m_context.Xmm13, reg_value.GetBytes(), 16);
597 break;
599 memcpy(&m_context.Xmm14, reg_value.GetBytes(), 16);
600 break;
602 memcpy(&m_context.Xmm15, reg_value.GetBytes(), 16);
603 break;
604 default:
605 LLDB_LOG(log, "Write value {0:x} to unknown register {1}",
606 reg_value.GetAsUInt32(), reg);
607 return false;
608 }
609
610 // Physically update the registers in the target process.
611 return ApplyAllRegisterValues();
612}
613
614#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)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:364
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
uint32_t GetAsUInt32(uint32_t fail_value=UINT32_MAX, bool *success_ptr=nullptr) 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
lldb::ByteOrder InlHostByteOrder()
Definition Endian.h:25
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:327
@ 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.