1 //===-- NativeRegisterContextLinux_x86_64.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 #if defined(__i386__) || defined(__x86_64__) 11 12 #ifndef lldb_NativeRegisterContextLinux_x86_64_h 13 #define lldb_NativeRegisterContextLinux_x86_64_h 14 15 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h" 16 #include "Plugins/Process/Utility/RegisterContext_x86.h" 17 #include "Plugins/Process/Utility/lldb-x86-register-enums.h" 18 #include <sys/uio.h> 19 20 namespace lldb_private { 21 namespace process_linux { 22 23 class NativeProcessLinux; 24 25 class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextLinux { 26 public: 27 NativeRegisterContextLinux_x86_64(const ArchSpec &target_arch, 28 NativeThreadProtocol &native_thread); 29 30 uint32_t GetRegisterSetCount() const override; 31 32 const RegisterSet *GetRegisterSet(uint32_t set_index) const override; 33 34 uint32_t GetUserRegisterCount() const override; 35 36 Status ReadRegister(const RegisterInfo *reg_info, 37 RegisterValue ®_value) override; 38 39 Status WriteRegister(const RegisterInfo *reg_info, 40 const RegisterValue ®_value) override; 41 42 Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; 43 44 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; 45 46 Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override; 47 48 Status GetWatchpointHitIndex(uint32_t &wp_index, 49 lldb::addr_t trap_addr) override; 50 51 Status IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override; 52 53 bool ClearHardwareWatchpoint(uint32_t wp_index) override; 54 55 Status ClearAllHardwareWatchpoints() override; 56 57 Status SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size, 58 uint32_t watch_flags, 59 uint32_t wp_index); 60 61 uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, 62 uint32_t watch_flags) override; 63 64 lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override; 65 66 uint32_t NumSupportedHardwareWatchpoints() override; 67 68 protected: 69 void *GetGPRBuffer() override { return &m_gpr_x86_64; } 70 71 void *GetFPRBuffer() override; 72 73 size_t GetFPRSize() override; 74 75 Status ReadFPR() override; 76 77 Status WriteFPR() override; 78 79 private: 80 // Private member types. 81 enum class XStateType { Invalid, FXSAVE, XSAVE }; 82 enum class RegSet { gpr, fpu, avx, mpx }; 83 84 // Info about register ranges. 85 struct RegInfo { 86 uint32_t num_registers; 87 uint32_t num_gpr_registers; 88 uint32_t num_fpr_registers; 89 uint32_t num_avx_registers; 90 uint32_t num_mpx_registers; 91 uint32_t last_gpr; 92 uint32_t first_fpr; 93 uint32_t last_fpr; 94 uint32_t first_st; 95 uint32_t last_st; 96 uint32_t first_mm; 97 uint32_t last_mm; 98 uint32_t first_xmm; 99 uint32_t last_xmm; 100 uint32_t first_ymm; 101 uint32_t last_ymm; 102 uint32_t first_mpxr; 103 uint32_t last_mpxr; 104 uint32_t first_mpxc; 105 uint32_t last_mpxc; 106 uint32_t first_dr; 107 uint32_t gpr_flags; 108 }; 109 110 // Private member variables. 111 mutable XStateType m_xstate_type; 112 FPR m_fpr; // Extended States Area, named FPR for historical reasons. 113 struct iovec m_iovec; 114 YMM m_ymm_set; 115 MPX m_mpx_set; 116 RegInfo m_reg_info; 117 uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64]; 118 uint32_t m_fctrl_offset_in_userarea; 119 120 // Private member methods. 121 bool IsCPUFeatureAvailable(RegSet feature_code) const; 122 123 bool IsRegisterSetAvailable(uint32_t set_index) const; 124 125 bool IsGPR(uint32_t reg_index) const; 126 127 bool IsFPR(uint32_t reg_index) const; 128 129 bool CopyXSTATEtoYMM(uint32_t reg_index, lldb::ByteOrder byte_order); 130 131 bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); 132 133 bool IsAVX(uint32_t reg_index) const; 134 135 bool CopyXSTATEtoMPX(uint32_t reg); 136 137 bool CopyMPXtoXSTATE(uint32_t reg); 138 139 bool IsMPX(uint32_t reg_index) const; 140 141 void UpdateXSTATEforWrite(uint32_t reg_index); 142 }; 143 144 } // namespace process_linux 145 } // namespace lldb_private 146 147 #endif // #ifndef lldb_NativeRegisterContextLinux_x86_64_h 148 149 #endif // defined(__i386__) || defined(__x86_64__) 150