1 //===-- RegisterContextPOSIX_x86.h ------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_RegisterContextPOSIX_x86_H_
11 #define liblldb_RegisterContextPOSIX_x86_H_
13 #include "lldb/Core/Log.h"
14 #include "RegisterContextPOSIX.h"
15 #include "RegisterContext_x86.h"
19 //---------------------------------------------------------------------------
20 // Internal codes for all i386 registers.
21 //---------------------------------------------------------------------------
25 gpr_eax_i386 = k_first_gpr_i386,
43 gpr_ax_i386 = k_first_alias_i386,
59 k_last_alias_i386 = gpr_dl_i386,
61 k_last_gpr_i386 = k_last_alias_i386,
64 fpu_fctrl_i386 = k_first_fpr_i386,
98 k_last_fpr_i386 = fpu_xmm7_i386,
101 fpu_ymm0_i386 = k_first_avx_i386,
109 k_last_avx_i386 = fpu_ymm7_i386,
120 k_num_registers_i386,
121 k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
122 k_num_fpr_registers_i386 = k_last_fpr_i386 - k_first_fpr_i386 + 1,
123 k_num_avx_registers_i386 = k_last_avx_i386 - k_first_avx_i386 + 1
126 //---------------------------------------------------------------------------
127 // Internal codes for all x86_64 registers.
128 //---------------------------------------------------------------------------
132 gpr_rax_x86_64 = k_first_gpr_x86_64,
157 k_first_alias_x86_64,
158 gpr_eax_x86_64 = k_first_alias_x86_64,
166 gpr_r8d_x86_64, // Low 32 bits of r8
167 gpr_r9d_x86_64, // Low 32 bits of r9
168 gpr_r10d_x86_64, // Low 32 bits of r10
169 gpr_r11d_x86_64, // Low 32 bits of r11
170 gpr_r12d_x86_64, // Low 32 bits of r12
171 gpr_r13d_x86_64, // Low 32 bits of r13
172 gpr_r14d_x86_64, // Low 32 bits of r14
173 gpr_r15d_x86_64, // Low 32 bits of r15
182 gpr_r8w_x86_64, // Low 16 bits of r8
183 gpr_r9w_x86_64, // Low 16 bits of r9
184 gpr_r10w_x86_64, // Low 16 bits of r10
185 gpr_r11w_x86_64, // Low 16 bits of r11
186 gpr_r12w_x86_64, // Low 16 bits of r12
187 gpr_r13w_x86_64, // Low 16 bits of r13
188 gpr_r14w_x86_64, // Low 16 bits of r14
189 gpr_r15w_x86_64, // Low 16 bits of r15
202 gpr_r8l_x86_64, // Low 8 bits of r8
203 gpr_r9l_x86_64, // Low 8 bits of r9
204 gpr_r10l_x86_64, // Low 8 bits of r10
205 gpr_r11l_x86_64, // Low 8 bits of r11
206 gpr_r12l_x86_64, // Low 8 bits of r12
207 gpr_r13l_x86_64, // Low 8 bits of r13
208 gpr_r14l_x86_64, // Low 8 bits of r14
209 gpr_r15l_x86_64, // Low 8 bits of r15
210 k_last_alias_x86_64 = gpr_r15l_x86_64,
212 k_last_gpr_x86_64 = k_last_alias_x86_64,
215 fpu_fctrl_x86_64 = k_first_fpr_x86_64,
224 fpu_mxcsrmask_x86_64,
257 k_last_fpr_x86_64 = fpu_xmm15_x86_64,
260 fpu_ymm0_x86_64 = k_first_avx_x86_64,
276 k_last_avx_x86_64 = fpu_ymm15_x86_64,
287 k_num_registers_x86_64,
288 k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
289 k_num_fpr_registers_x86_64 = k_last_fpr_x86_64 - k_first_fpr_x86_64 + 1,
290 k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1
293 class RegisterContextPOSIX_x86
294 : public lldb_private::RegisterContext
297 RegisterContextPOSIX_x86 (lldb_private::Thread &thread,
298 uint32_t concrete_frame_idx,
299 RegisterInfoInterface *register_info);
301 ~RegisterContextPOSIX_x86();
307 InvalidateAllRegisters();
316 GetRegisterSize(unsigned reg);
319 GetRegisterOffset(unsigned reg);
321 const lldb_private::RegisterInfo *
322 GetRegisterInfoAtIndex(size_t reg);
325 GetRegisterSetCount();
327 const lldb_private::RegisterSet *
328 GetRegisterSet(size_t set);
331 GetRegisterName(unsigned reg);
334 ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num);
336 //---------------------------------------------------------------------------
337 // Note: prefer kernel definitions over user-land
338 //---------------------------------------------------------------------------
348 static uint32_t g_contained_eax[];
349 static uint32_t g_contained_ebx[];
350 static uint32_t g_contained_ecx[];
351 static uint32_t g_contained_edx[];
352 static uint32_t g_contained_edi[];
353 static uint32_t g_contained_esi[];
354 static uint32_t g_contained_ebp[];
355 static uint32_t g_contained_esp[];
357 static uint32_t g_invalidate_eax[];
358 static uint32_t g_invalidate_ebx[];
359 static uint32_t g_invalidate_ecx[];
360 static uint32_t g_invalidate_edx[];
361 static uint32_t g_invalidate_edi[];
362 static uint32_t g_invalidate_esi[];
363 static uint32_t g_invalidate_ebp[];
364 static uint32_t g_invalidate_esp[];
366 static uint32_t g_contained_rax[];
367 static uint32_t g_contained_rbx[];
368 static uint32_t g_contained_rcx[];
369 static uint32_t g_contained_rdx[];
370 static uint32_t g_contained_rdi[];
371 static uint32_t g_contained_rsi[];
372 static uint32_t g_contained_rbp[];
373 static uint32_t g_contained_rsp[];
374 static uint32_t g_contained_r8[];
375 static uint32_t g_contained_r9[];
376 static uint32_t g_contained_r10[];
377 static uint32_t g_contained_r11[];
378 static uint32_t g_contained_r12[];
379 static uint32_t g_contained_r13[];
380 static uint32_t g_contained_r14[];
381 static uint32_t g_contained_r15[];
383 static uint32_t g_invalidate_rax[];
384 static uint32_t g_invalidate_rbx[];
385 static uint32_t g_invalidate_rcx[];
386 static uint32_t g_invalidate_rdx[];
387 static uint32_t g_invalidate_rdi[];
388 static uint32_t g_invalidate_rsi[];
389 static uint32_t g_invalidate_rbp[];
390 static uint32_t g_invalidate_rsp[];
391 static uint32_t g_invalidate_r8[];
392 static uint32_t g_invalidate_r9[];
393 static uint32_t g_invalidate_r10[];
394 static uint32_t g_invalidate_r11[];
395 static uint32_t g_invalidate_r12[];
396 static uint32_t g_invalidate_r13[];
397 static uint32_t g_invalidate_r14[];
398 static uint32_t g_invalidate_r15[];
403 uint32_t num_registers;
404 uint32_t num_gpr_registers;
405 uint32_t num_fpr_registers;
406 uint32_t num_avx_registers;
425 uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64]; // 64-bit general purpose registers.
427 FPRType m_fpr_type; // determines the type of data stored by union FPR, if any.
428 FPR m_fpr; // floating-point registers including extended register sets.
429 IOVEC m_iovec; // wrapper for xsave.
430 YMM m_ymm_set; // copy of ymmh and xmm register halves.
431 std::unique_ptr<RegisterInfoInterface> m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
433 // Determines if an extended register set is supported on the processor running the inferior process.
435 IsRegisterSetAvailable(size_t set_index);
437 virtual const lldb_private::RegisterInfo *
449 lldb::ByteOrder GetByteOrder();
451 bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order);
452 bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
453 bool IsFPR(unsigned reg, FPRType fpr_type);
454 FPRType GetFPRType();
456 virtual bool ReadGPR() = 0;
457 virtual bool ReadFPR() = 0;
458 virtual bool WriteGPR() = 0;
459 virtual bool WriteFPR() = 0;
462 #endif // #ifndef liblldb_RegisterContextPOSIX_x86_H_