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 uint32_t concrete_frame_idx); 35 36 uint32_t GetRegisterSetCount() const override; 37 38 uint32_t GetUserRegisterCount() const override; 39 40 const RegisterSet *GetRegisterSet(uint32_t set_index) const override; 41 42 Status ReadRegister(const RegisterInfo *reg_info, 43 RegisterValue ®_value) override; 44 45 Status WriteRegister(const RegisterInfo *reg_info, 46 const RegisterValue ®_value) override; 47 48 Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override; 49 50 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override; 51 52 //------------------------------------------------------------------ 53 // Hardware watchpoint mangement functions 54 //------------------------------------------------------------------ 55 56 uint32_t NumSupportedHardwareWatchpoints() override; 57 58 uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, 59 uint32_t watch_flags) override; 60 61 bool ClearHardwareWatchpoint(uint32_t hw_index) override; 62 63 Status GetWatchpointHitIndex(uint32_t &wp_index, 64 lldb::addr_t trap_addr) override; 65 66 lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override; 67 68 lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override; 69 70 uint32_t GetWatchpointSize(uint32_t wp_index); 71 72 bool WatchpointIsEnabled(uint32_t wp_index); 73 74 protected: 75 Status DoReadGPR(void *buf, size_t buf_size) override; 76 77 Status DoWriteGPR(void *buf, size_t buf_size) override; 78 79 void *GetGPRBuffer() override { return &m_gpr_ppc64le; } 80 81 private: 82 GPR m_gpr_ppc64le; // 64-bit general purpose registers. 83 84 bool IsGPR(unsigned reg) const; 85 86 Status ReadHardwareDebugInfo(); 87 88 Status WriteHardwareDebugRegs(); 89 90 // Debug register info for hardware watchpoints management. 91 struct DREG { 92 lldb::addr_t address; // Breakpoint/watchpoint address value. 93 lldb::addr_t hit_addr; // Address at which last watchpoint trigger 94 // exception occurred. 95 lldb::addr_t real_addr; // Address value that should cause target to stop. 96 uint32_t control; // Breakpoint/watchpoint control value. 97 uint32_t refcount; // Serves as enable/disable and reference counter. 98 long slot; // Saves the value returned from PTRACE_SETHWDEBUG. 99 int mode; // Defines if watchpoint is read/write/access. 100 }; 101 102 std::array<DREG, 4> m_hwp_regs; 103 104 // 16 is just a maximum value, query hardware for actual watchpoint count 105 uint32_t m_max_hwp_supported = 16; 106 uint32_t m_max_hbp_supported = 16; 107 bool m_refresh_hwdebug_info = true; 108 }; 109 110 } // namespace process_linux 111 } // namespace lldb_private 112 113 #endif // #ifndef lldb_NativeRegisterContextLinux_ppc64le_h 114 115 #endif // defined(__powerpc64__) 116