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