1 //===-- NativeRegisterContextLinux_ppc64le.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 // This implementation is related to the OpenPOWER ABI for Power Architecture 11 // 64-bit ELF V2 ABI 12 13 #if defined(__powerpc64__) 14 15 #ifndef lldb_NativeRegisterContextLinux_ppc64le_h 16 #define lldb_NativeRegisterContextLinux_ppc64le_h 17 18 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h" 19 #include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h" 20 21 #define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT 22 #include "RegisterInfos_ppc64le.h" 23 #undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT 24 25 namespace lldb_private { 26 namespace process_linux { 27 28 class NativeProcessLinux; 29 30 class NativeRegisterContextLinux_ppc64le : public NativeRegisterContextLinux { 31 public: 32 NativeRegisterContextLinux_ppc64le(const ArchSpec &target_arch, 33 NativeThreadProtocol &native_thread); 34 35 uint32_t GetRegisterSetCount() const override; 36 37 uint32_t GetUserRegisterCount() const override; 38 39 const RegisterSet *GetRegisterSet(uint32_t set_index) const override; 40 41 Status ReadRegister(const RegisterInfo *reg_info, 42 RegisterValue ®_value) override; 43 44 Status WriteRegister(const RegisterInfo *reg_info, 45 const RegisterValue ®_value) override; 46 47 Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; 48 49 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; 50 51 //------------------------------------------------------------------ 52 // Hardware watchpoint mangement functions 53 //------------------------------------------------------------------ 54 55 uint32_t NumSupportedHardwareWatchpoints() override; 56 57 uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, 58 uint32_t watch_flags) override; 59 60 bool ClearHardwareWatchpoint(uint32_t hw_index) override; 61 62 Status GetWatchpointHitIndex(uint32_t &wp_index, 63 lldb::addr_t trap_addr) override; 64 65 lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override; 66 67 lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override; 68 69 uint32_t GetWatchpointSize(uint32_t wp_index); 70 71 bool WatchpointIsEnabled(uint32_t wp_index); 72 73 protected: 74 Status DoReadGPR(void *buf, size_t buf_size) override; 75 76 Status DoWriteGPR(void *buf, size_t buf_size) override; 77 78 Status DoReadFPR(void *buf, size_t buf_size) override; 79 80 Status DoWriteFPR(void *buf, size_t buf_size) override; 81 82 bool IsVMX(unsigned reg); 83 84 bool IsVSX(unsigned reg); 85 86 Status ReadVMX(); 87 88 Status WriteVMX(); 89 90 Status ReadVSX(); 91 92 Status WriteVSX(); 93 94 void *GetGPRBuffer() override { return &m_gpr_ppc64le; } 95 96 void *GetFPRBuffer() override { return &m_fpr_ppc64le; } 97 98 size_t GetFPRSize() override { return sizeof(m_fpr_ppc64le); } 99 100 private: 101 GPR m_gpr_ppc64le; // 64-bit general purpose registers. 102 FPR m_fpr_ppc64le; // floating-point registers including extended register. 103 VMX m_vmx_ppc64le; // VMX registers. 104 VSX m_vsx_ppc64le; // Last lower bytes from first VSX registers. 105 106 bool IsGPR(unsigned reg) const; 107 108 bool IsFPR(unsigned reg) const; 109 110 bool IsVMX(unsigned reg) const; 111 112 bool IsVSX(unsigned reg) const; 113 114 uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const; 115 116 uint32_t CalculateVmxOffset(const RegisterInfo *reg_info) const; 117 118 uint32_t CalculateVsxOffset(const RegisterInfo *reg_info) const; 119 120 Status ReadHardwareDebugInfo(); 121 122 Status WriteHardwareDebugRegs(); 123 124 // Debug register info for hardware watchpoints management. 125 struct DREG { 126 lldb::addr_t address; // Breakpoint/watchpoint address value. 127 lldb::addr_t hit_addr; // Address at which last watchpoint trigger 128 // exception occurred. 129 lldb::addr_t real_addr; // Address value that should cause target to stop. 130 uint32_t control; // Breakpoint/watchpoint control value. 131 uint32_t refcount; // Serves as enable/disable and reference counter. 132 long slot; // Saves the value returned from PTRACE_SETHWDEBUG. 133 int mode; // Defines if watchpoint is read/write/access. 134 }; 135 136 std::array<DREG, 4> m_hwp_regs; 137 138 // 16 is just a maximum value, query hardware for actual watchpoint count 139 uint32_t m_max_hwp_supported = 16; 140 uint32_t m_max_hbp_supported = 16; 141 bool m_refresh_hwdebug_info = true; 142 }; 143 144 } // namespace process_linux 145 } // namespace lldb_private 146 147 #endif // #ifndef lldb_NativeRegisterContextLinux_ppc64le_h 148 149 #endif // defined(__powerpc64__) 150