1 //===-- RegisterContextPOSIX_x86.h ------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_RegisterContextPOSIX_x86_h_ 11 #define liblldb_RegisterContextPOSIX_x86_h_ 12 13 // C Includes 14 // C++ Includes 15 // Other libraries and framework includes 16 // Project includes 17 #include "RegisterContext_x86.h" 18 #include "RegisterInfoInterface.h" 19 #include "lldb-x86-register-enums.h" 20 #include "lldb/Core/Log.h" 21 #include "lldb/Target/RegisterContext.h" 22 23 class ProcessMonitor; 24 25 class RegisterContextPOSIX_x86 : public lldb_private::RegisterContext { 26 public: 27 RegisterContextPOSIX_x86(lldb_private::Thread &thread, 28 uint32_t concrete_frame_idx, 29 lldb_private::RegisterInfoInterface *register_info); 30 31 ~RegisterContextPOSIX_x86() override; 32 33 void Invalidate(); 34 35 void InvalidateAllRegisters() override; 36 37 size_t GetRegisterCount() override; 38 39 virtual size_t GetGPRSize(); 40 41 virtual size_t GetFXSAVEOffset(); 42 43 virtual unsigned GetRegisterSize(unsigned reg); 44 45 virtual unsigned GetRegisterOffset(unsigned reg); 46 47 const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; 48 49 size_t GetRegisterSetCount() override; 50 51 const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; 52 53 const char *GetRegisterName(unsigned reg); 54 55 uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, 56 uint32_t num) override; 57 58 //--------------------------------------------------------------------------- 59 // Note: prefer kernel definitions over user-land 60 //--------------------------------------------------------------------------- 61 enum FPRType { 62 eNotValid = 0, 63 eFSAVE, // TODO 64 eFXSAVE, 65 eSOFT, // TODO 66 eXSAVE 67 }; 68 69 static uint32_t g_contained_eax[]; 70 static uint32_t g_contained_ebx[]; 71 static uint32_t g_contained_ecx[]; 72 static uint32_t g_contained_edx[]; 73 static uint32_t g_contained_edi[]; 74 static uint32_t g_contained_esi[]; 75 static uint32_t g_contained_ebp[]; 76 static uint32_t g_contained_esp[]; 77 78 static uint32_t g_invalidate_eax[]; 79 static uint32_t g_invalidate_ebx[]; 80 static uint32_t g_invalidate_ecx[]; 81 static uint32_t g_invalidate_edx[]; 82 static uint32_t g_invalidate_edi[]; 83 static uint32_t g_invalidate_esi[]; 84 static uint32_t g_invalidate_ebp[]; 85 static uint32_t g_invalidate_esp[]; 86 87 static uint32_t g_contained_rax[]; 88 static uint32_t g_contained_rbx[]; 89 static uint32_t g_contained_rcx[]; 90 static uint32_t g_contained_rdx[]; 91 static uint32_t g_contained_rdi[]; 92 static uint32_t g_contained_rsi[]; 93 static uint32_t g_contained_rbp[]; 94 static uint32_t g_contained_rsp[]; 95 static uint32_t g_contained_r8[]; 96 static uint32_t g_contained_r9[]; 97 static uint32_t g_contained_r10[]; 98 static uint32_t g_contained_r11[]; 99 static uint32_t g_contained_r12[]; 100 static uint32_t g_contained_r13[]; 101 static uint32_t g_contained_r14[]; 102 static uint32_t g_contained_r15[]; 103 104 static uint32_t g_invalidate_rax[]; 105 static uint32_t g_invalidate_rbx[]; 106 static uint32_t g_invalidate_rcx[]; 107 static uint32_t g_invalidate_rdx[]; 108 static uint32_t g_invalidate_rdi[]; 109 static uint32_t g_invalidate_rsi[]; 110 static uint32_t g_invalidate_rbp[]; 111 static uint32_t g_invalidate_rsp[]; 112 static uint32_t g_invalidate_r8[]; 113 static uint32_t g_invalidate_r9[]; 114 static uint32_t g_invalidate_r10[]; 115 static uint32_t g_invalidate_r11[]; 116 static uint32_t g_invalidate_r12[]; 117 static uint32_t g_invalidate_r13[]; 118 static uint32_t g_invalidate_r14[]; 119 static uint32_t g_invalidate_r15[]; 120 121 protected: 122 struct RegInfo { 123 uint32_t num_registers; 124 uint32_t num_gpr_registers; 125 uint32_t num_fpr_registers; 126 uint32_t num_avx_registers; 127 128 uint32_t last_gpr; 129 uint32_t first_fpr; 130 uint32_t last_fpr; 131 132 uint32_t first_st; 133 uint32_t last_st; 134 uint32_t first_mm; 135 uint32_t last_mm; 136 uint32_t first_xmm; 137 uint32_t last_xmm; 138 uint32_t first_ymm; 139 uint32_t last_ymm; 140 141 uint32_t first_dr; 142 uint32_t gpr_flags; 143 }; 144 145 uint64_t m_gpr_x86_64[lldb_private::k_num_gpr_registers_x86_64]; // 64-bit 146 // general 147 // purpose 148 // registers. 149 RegInfo m_reg_info; 150 FPRType 151 m_fpr_type; // determines the type of data stored by union FPR, if any. 152 FPR m_fpr; // floating-point registers including extended register sets. 153 IOVEC m_iovec; // wrapper for xsave. 154 YMM m_ymm_set; // copy of ymmh and xmm register halves. 155 std::unique_ptr<lldb_private::RegisterInfoInterface> 156 m_register_info_ap; // Register Info Interface (FreeBSD or Linux) 157 158 // Determines if an extended register set is supported on the processor 159 // running the inferior process. 160 virtual bool IsRegisterSetAvailable(size_t set_index); 161 162 virtual const lldb_private::RegisterInfo *GetRegisterInfo(); 163 164 bool IsGPR(unsigned reg); 165 166 bool IsFPR(unsigned reg); 167 168 bool IsAVX(unsigned reg); 169 170 lldb::ByteOrder GetByteOrder(); 171 172 bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order); 173 bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); 174 bool IsFPR(unsigned reg, FPRType fpr_type); 175 FPRType GetFPRType(); 176 177 virtual bool ReadGPR() = 0; 178 virtual bool ReadFPR() = 0; 179 virtual bool WriteGPR() = 0; 180 virtual bool WriteFPR() = 0; 181 }; 182 183 #endif // liblldb_RegisterContextPOSIX_x86_h_ 184