1 //===-- RegisterContext_x86_64.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_RegisterContext_x86_64_H_
11 #define liblldb_RegisterContext_x86_64_H_
13 #include "lldb/Core/Log.h"
14 #include "RegisterContextPOSIX.h"
18 // Internal codes for all x86_64 registers.
22 gpr_rax = k_first_gpr,
47 gpr_eax = k_first_i386,
56 gpr_eflags, // eRegisterKindLLDB == 33
57 k_last_i386 = gpr_eflags,
58 k_last_gpr = gpr_eflags,
61 fpu_fcw = k_first_fpr,
95 k_last_fpr = fpu_xmm15,
97 fpu_ymm0 = k_first_avx,
113 k_last_avx = fpu_ymm15,
125 k_num_gpr_registers = k_last_gpr - k_first_gpr + 1,
126 k_num_fpr_registers = k_last_fpr - k_first_fpr + 1,
127 k_num_avx_registers = k_last_avx - k_first_avx + 1
130 class RegisterContext_x86_64
131 : public RegisterContextPOSIX
134 RegisterContext_x86_64 (lldb_private::Thread &thread,
135 uint32_t concrete_frame_idx);
137 ~RegisterContext_x86_64();
143 InvalidateAllRegisters();
152 GetRegisterSize(unsigned reg);
155 GetRegisterOffset(unsigned reg);
157 const lldb_private::RegisterInfo *
158 GetRegisterInfoAtIndex(size_t reg);
161 GetRegisterSetCount();
163 const lldb_private::RegisterSet *
164 GetRegisterSet(size_t set);
167 GetRegisterIndexFromOffset(unsigned offset);
170 GetRegisterName(unsigned reg);
173 ReadRegister(const lldb_private::RegisterInfo *reg_info,
174 lldb_private::RegisterValue &value);
177 ReadAllRegisterValues(lldb::DataBufferSP &data_sp);
180 WriteRegister(const lldb_private::RegisterInfo *reg_info,
181 const lldb_private::RegisterValue &value);
184 WriteAllRegisterValues(const lldb::DataBufferSP &data_sp);
187 ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num);
190 NumSupportedHardwareWatchpoints();
193 SetHardwareWatchpoint(lldb::addr_t, size_t size, bool read, bool write);
196 SetHardwareWatchpointWithIndex(lldb::addr_t, size_t size, bool read,
197 bool write, uint32_t hw_index);
200 ClearHardwareWatchpoint(uint32_t hw_index);
203 HardwareSingleStep(bool enable);
206 UpdateAfterBreakpoint();
209 IsWatchpointVacant(uint32_t hw_index);
212 IsWatchpointHit (uint32_t hw_index);
215 GetWatchpointAddress (uint32_t hw_index);
218 ClearWatchpointHits();
220 //---------------------------------------------------------------------------
221 // Generic floating-point registers
222 //---------------------------------------------------------------------------
232 uint8_t bytes[16]; // 128-bits for each XMM register
247 uint32_t padding[24];
250 //---------------------------------------------------------------------------
251 // Extended floating-point registers
252 //---------------------------------------------------------------------------
255 uint8_t bytes[16]; // 16 * 8 bits for the high bytes of each YMM register
260 uint8_t bytes[32]; // 16 * 16 bits for each YMM register
265 YMMReg ymm[16]; // assembled from ymmh and xmm registers
270 uint64_t xstate_bv; // OS enabled xstate mask to determine the extended states supported by the processor
271 uint64_t reserved1[2];
272 uint64_t reserved2[5];
273 } __attribute__((packed));
275 // x86 extensions to FXSAVE (i.e. for AVX processors)
278 FXSAVE i387; // floating point registers typical in i387_fxsave_struct
279 XSAVE_HDR header; // The xsave_hdr_struct can be used to determine if the following extensions are usable
280 YMMHReg ymmh[16]; // High 16 bytes of each of 16 YMM registers (the low bytes are in FXSAVE.xmm for compatibility with SSE)
281 // Slot any extensions to the register file here
282 } __attribute__((packed, aligned (64)));
286 void *iov_base; // pointer to XSAVE
287 size_t iov_len; // sizeof(XSAVE)
290 //---------------------------------------------------------------------------
291 // Note: prefer kernel definitions over user-land
292 //---------------------------------------------------------------------------
302 // Floating-point registers
305 // Thread state for the floating-point unit of the processor read by ptrace.
307 FXSAVE fxsave; // Generic floating-point registers.
308 XSAVE xsave; // x86 extended processor state.
313 // Determines if an extended register set is supported on the processor running the inferior process.
315 IsRegisterSetAvailable(size_t set_index);
317 virtual const lldb_private::RegisterInfo *
321 ReadRegister(const unsigned reg, lldb_private::RegisterValue &value);
324 WriteRegister(const unsigned reg, const lldb_private::RegisterValue &value);
327 uint64_t m_gpr[k_num_gpr_registers]; // general purpose registers.
328 FPRType m_fpr_type; // determines the type of data stored by union FPR, if any.
329 FPR m_fpr; // floating-point registers including extended register sets.
330 IOVEC m_iovec; // wrapper for xsave.
331 YMM m_ymm_set; // copy of ymmh and xmm register halves.
333 ProcessMonitor &GetMonitor();
334 lldb::ByteOrder GetByteOrder();
336 bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order);
337 bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
338 bool IsFPR(unsigned reg, FPRType fpr_type);
347 #endif // #ifndef liblldb_RegisterContext_x86_64_H_