1 //===-- NativeRegisterContextLinux_ppc64le.h --------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This implementation is related to the OpenPOWER ABI for Power Architecture
12 #if defined(__powerpc64__)
14 #ifndef lldb_NativeRegisterContextLinux_ppc64le_h
15 #define lldb_NativeRegisterContextLinux_ppc64le_h
17 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
18 #include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h"
20 #define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
21 #include "Plugins/Process/Utility/RegisterInfos_ppc64le.h"
22 #undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
24 namespace lldb_private
{
25 namespace process_linux
{
27 class NativeProcessLinux
;
29 class NativeRegisterContextLinux_ppc64le
: public NativeRegisterContextLinux
{
31 NativeRegisterContextLinux_ppc64le(const ArchSpec
&target_arch
,
32 NativeThreadProtocol
&native_thread
);
34 uint32_t GetRegisterSetCount() const override
;
36 uint32_t GetUserRegisterCount() const override
;
38 const RegisterSet
*GetRegisterSet(uint32_t set_index
) const override
;
40 Status
ReadRegister(const RegisterInfo
*reg_info
,
41 RegisterValue
®_value
) override
;
43 Status
WriteRegister(const RegisterInfo
*reg_info
,
44 const RegisterValue
®_value
) override
;
46 Status
ReadAllRegisterValues(lldb::WritableDataBufferSP
&data_sp
) override
;
48 Status
WriteAllRegisterValues(const lldb::DataBufferSP
&data_sp
) override
;
50 // Hardware watchpoint management functions
52 uint32_t NumSupportedHardwareWatchpoints() override
;
54 uint32_t SetHardwareWatchpoint(lldb::addr_t addr
, size_t size
,
55 uint32_t watch_flags
) override
;
57 bool ClearHardwareWatchpoint(uint32_t hw_index
) override
;
59 Status
GetWatchpointHitIndex(uint32_t &wp_index
,
60 lldb::addr_t trap_addr
) override
;
62 lldb::addr_t
GetWatchpointHitAddress(uint32_t wp_index
) override
;
64 lldb::addr_t
GetWatchpointAddress(uint32_t wp_index
) override
;
66 uint32_t GetWatchpointSize(uint32_t wp_index
);
68 bool WatchpointIsEnabled(uint32_t wp_index
);
71 bool IsVMX(unsigned reg
);
73 bool IsVSX(unsigned reg
);
83 void *GetGPRBuffer() override
{ return &m_gpr_ppc64le
; }
85 void *GetFPRBuffer() override
{ return &m_fpr_ppc64le
; }
87 size_t GetFPRSize() override
{ return sizeof(m_fpr_ppc64le
); }
90 GPR m_gpr_ppc64le
; // 64-bit general purpose registers.
91 FPR m_fpr_ppc64le
; // floating-point registers including extended register.
92 VMX m_vmx_ppc64le
; // VMX registers.
93 VSX m_vsx_ppc64le
; // Last lower bytes from first VSX registers.
95 bool IsGPR(unsigned reg
) const;
97 bool IsFPR(unsigned reg
) const;
99 bool IsVMX(unsigned reg
) const;
101 bool IsVSX(unsigned reg
) const;
103 uint32_t CalculateFprOffset(const RegisterInfo
*reg_info
) const;
105 uint32_t CalculateVmxOffset(const RegisterInfo
*reg_info
) const;
107 uint32_t CalculateVsxOffset(const RegisterInfo
*reg_info
) const;
109 Status
ReadHardwareDebugInfo();
111 Status
WriteHardwareDebugRegs();
113 // Debug register info for hardware watchpoints management.
115 lldb::addr_t address
; // Breakpoint/watchpoint address value.
116 lldb::addr_t hit_addr
; // Address at which last watchpoint trigger
117 // exception occurred.
118 lldb::addr_t real_addr
; // Address value that should cause target to stop.
119 uint32_t control
; // Breakpoint/watchpoint control value.
120 uint32_t refcount
; // Serves as enable/disable and reference counter.
121 long slot
; // Saves the value returned from PTRACE_SETHWDEBUG.
122 int mode
; // Defines if watchpoint is read/write/access.
125 std::array
<DREG
, 16> m_hwp_regs
;
127 // 16 is just a maximum value, query hardware for actual watchpoint count
128 uint32_t m_max_hwp_supported
= 16;
129 uint32_t m_max_hbp_supported
= 16;
130 bool m_refresh_hwdebug_info
= true;
133 } // namespace process_linux
134 } // namespace lldb_private
136 #endif // #ifndef lldb_NativeRegisterContextLinux_ppc64le_h
138 #endif // defined(__powerpc64__)