1 //===-- NativeRegisterContextLinux_arm64.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 (__arm64__) || defined (__aarch64__) 11 12 #ifndef lldb_NativeRegisterContextLinux_arm64_h 13 #define lldb_NativeRegisterContextLinux_arm64_h 14 15 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h" 16 #include "Plugins/Process/Utility/lldb-arm64-register-enums.h" 17 18 namespace lldb_private { 19 namespace process_linux { 20 21 class NativeProcessLinux; 22 23 class NativeRegisterContextLinux_arm64 : public NativeRegisterContextLinux 24 { 25 public: 26 NativeRegisterContextLinux_arm64 (const ArchSpec& target_arch, 27 NativeThreadProtocol &native_thread, 28 uint32_t concrete_frame_idx); 29 30 uint32_t 31 GetRegisterSetCount () const override; 32 33 uint32_t 34 GetUserRegisterCount() const override; 35 36 const RegisterSet * 37 GetRegisterSet (uint32_t set_index) const override; 38 39 Error 40 ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) override; 41 42 Error 43 WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) override; 44 45 Error 46 ReadAllRegisterValues (lldb::DataBufferSP &data_sp) override; 47 48 Error 49 WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) override; 50 51 //------------------------------------------------------------------ 52 // Hardware breakpoints/watchpoint mangement functions 53 //------------------------------------------------------------------ 54 55 uint32_t 56 SetHardwareBreakpoint (lldb::addr_t addr, size_t size) override; 57 58 bool 59 ClearHardwareBreakpoint (uint32_t hw_idx) override; 60 61 uint32_t 62 NumSupportedHardwareWatchpoints () override; 63 64 uint32_t 65 SetHardwareWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags) override; 66 67 bool 68 ClearHardwareWatchpoint (uint32_t hw_index) override; 69 70 Error 71 ClearAllHardwareWatchpoints () override; 72 73 Error 74 GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override; 75 76 lldb::addr_t 77 GetWatchpointAddress (uint32_t wp_index) override; 78 79 uint32_t 80 GetWatchpointSize(uint32_t wp_index); 81 82 bool 83 WatchpointIsEnabled(uint32_t wp_index); 84 85 protected: 86 Error 87 DoReadRegisterValue(uint32_t offset, 88 const char* reg_name, 89 uint32_t size, 90 RegisterValue &value) override; 91 92 Error 93 DoWriteRegisterValue(uint32_t offset, 94 const char* reg_name, 95 const RegisterValue &value) override; 96 97 Error 98 DoReadGPR(void *buf, size_t buf_size) override; 99 100 Error 101 DoWriteGPR(void *buf, size_t buf_size) override; 102 103 Error 104 DoReadFPR(void *buf, size_t buf_size) override; 105 106 Error 107 DoWriteFPR(void *buf, size_t buf_size) override; 108 109 void* 110 GetGPRBuffer() override { return &m_gpr_arm64; } 111 112 void* 113 GetFPRBuffer() override { return &m_fpr; } 114 115 size_t 116 GetFPRSize() override { return sizeof(m_fpr); } 117 118 private: 119 struct RegInfo 120 { 121 uint32_t num_registers; 122 uint32_t num_gpr_registers; 123 uint32_t num_fpr_registers; 124 125 uint32_t last_gpr; 126 uint32_t first_fpr; 127 uint32_t last_fpr; 128 129 uint32_t first_fpr_v; 130 uint32_t last_fpr_v; 131 132 uint32_t gpr_flags; 133 }; 134 135 // based on RegisterContextDarwin_arm64.h 136 struct VReg 137 { 138 uint8_t bytes[16]; 139 }; 140 141 // based on RegisterContextDarwin_arm64.h 142 struct FPU 143 { 144 VReg v[32]; 145 uint32_t fpsr; 146 uint32_t fpcr; 147 }; 148 149 uint64_t m_gpr_arm64[k_num_gpr_registers_arm64]; // 64-bit general purpose registers. 150 RegInfo m_reg_info; 151 FPU m_fpr; // floating-point registers including extended register sets. 152 153 // Debug register info for hardware breakpoints and watchpoints management. 154 struct DREG 155 { 156 lldb::addr_t address; // Breakpoint/watchpoint address value. 157 uint32_t control; // Breakpoint/watchpoint control value. 158 uint32_t refcount; // Serves as enable/disable and refernce counter. 159 }; 160 161 struct DREG m_hbr_regs[16]; // Arm native linux hardware breakpoints 162 struct DREG m_hwp_regs[16]; // Arm native linux hardware watchpoints 163 164 uint32_t m_max_hwp_supported; 165 uint32_t m_max_hbp_supported; 166 bool m_refresh_hwdebug_info; 167 168 bool 169 IsGPR(unsigned reg) const; 170 171 bool 172 IsFPR(unsigned reg) const; 173 174 Error 175 ReadHardwareDebugInfo(unsigned int &watch_count , unsigned int &break_count); 176 177 Error 178 WriteHardwareDebugRegs(lldb::addr_t *addr_buf, uint32_t *cntrl_buf, int type, int count); 179 }; 180 181 } // namespace process_linux 182 } // namespace lldb_private 183 184 #endif // #ifndef lldb_NativeRegisterContextLinux_arm64_h 185 186 #endif // defined (__arm64__) || defined (__aarch64__) 187