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 19 namespace lldb_private { 20 namespace process_linux { 21 22 class NativeProcessLinux; 23 24 class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextLinux 25 { 26 public: 27 NativeRegisterContextLinux_x86_64 (const ArchSpec& target_arch, 28 NativeThreadProtocol &native_thread, 29 uint32_t concrete_frame_idx); 30 31 uint32_t 32 GetRegisterSetCount () const override; 33 34 const RegisterSet * 35 GetRegisterSet (uint32_t set_index) const override; 36 37 uint32_t 38 GetUserRegisterCount() const override; 39 40 Error 41 ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) override; 42 43 Error 44 WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) override; 45 46 Error 47 ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override; 48 49 Error 50 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override; 51 52 Error 53 IsWatchpointHit(uint32_t wp_index, bool &is_hit) override; 54 55 Error 56 GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override; 57 58 Error 59 IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override; 60 61 bool 62 ClearHardwareWatchpoint(uint32_t wp_index) override; 63 64 Error 65 ClearAllHardwareWatchpoints () override; 66 67 Error 68 SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size, 69 uint32_t watch_flags, uint32_t wp_index); 70 71 uint32_t 72 SetHardwareWatchpoint(lldb::addr_t addr, size_t size, 73 uint32_t watch_flags) override; 74 75 lldb::addr_t 76 GetWatchpointAddress(uint32_t wp_index) override; 77 78 uint32_t 79 NumSupportedHardwareWatchpoints() override; 80 81 protected: 82 void* 83 GetGPRBuffer() override { return &m_gpr_x86_64; } 84 85 void* 86 GetFPRBuffer() override; 87 88 size_t 89 GetFPRSize() override; 90 91 Error 92 ReadFPR() override; 93 94 Error 95 WriteFPR() override; 96 97 private: 98 99 // Private member types. 100 enum FPRType 101 { 102 eFPRTypeNotValid = 0, 103 eFPRTypeFXSAVE, 104 eFPRTypeXSAVE 105 }; 106 107 // Info about register ranges. 108 struct RegInfo 109 { 110 uint32_t num_registers; 111 uint32_t num_gpr_registers; 112 uint32_t num_fpr_registers; 113 uint32_t num_avx_registers; 114 115 uint32_t last_gpr; 116 uint32_t first_fpr; 117 uint32_t last_fpr; 118 119 uint32_t first_st; 120 uint32_t last_st; 121 uint32_t first_mm; 122 uint32_t last_mm; 123 uint32_t first_xmm; 124 uint32_t last_xmm; 125 uint32_t first_ymm; 126 uint32_t last_ymm; 127 128 uint32_t first_dr; 129 uint32_t gpr_flags; 130 }; 131 132 // Private member variables. 133 mutable FPRType m_fpr_type; 134 FPR m_fpr; 135 IOVEC m_iovec; 136 YMM m_ymm_set; 137 RegInfo m_reg_info; 138 uint64_t m_gpr_x86_64[k_num_gpr_registers_x86_64]; 139 uint32_t m_fctrl_offset_in_userarea; 140 141 // Private member methods. 142 bool IsRegisterSetAvailable (uint32_t set_index) const; 143 144 bool 145 IsGPR(uint32_t reg_index) const; 146 147 FPRType 148 GetFPRType () const; 149 150 bool 151 IsFPR(uint32_t reg_index) const; 152 153 bool 154 IsFPR(uint32_t reg_index, FPRType fpr_type) const; 155 156 bool 157 CopyXSTATEtoYMM (uint32_t reg_index, lldb::ByteOrder byte_order); 158 159 bool 160 CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order); 161 162 bool 163 IsAVX (uint32_t reg_index) const; 164 }; 165 166 } // namespace process_linux 167 } // namespace lldb_private 168 169 #endif // #ifndef lldb_NativeRegisterContextLinux_x86_64_h 170 171 #endif // defined(__i386__) || defined(__x86_64__) 172