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