1//===-- NativeRegisterContextDBReg_arm64.h ----------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef lldb_NativeRegisterContextDBReg_arm64_h
10#define lldb_NativeRegisterContextDBReg_arm64_h
11
12#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
13
14#include <array>
15
16namespace lldb_private {
17
18class NativeRegisterContextDBReg_arm64
19 : public virtual NativeRegisterContextRegisterInfo {
20public:
21 uint32_t NumSupportedHardwareBreakpoints() override;
22
23 uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
24
25 bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
26
27 Status ClearAllHardwareBreakpoints() override;
28
29 Status GetHardwareBreakHitIndex(uint32_t &bp_index,
30 lldb::addr_t trap_addr) override;
31
32 bool BreakpointIsEnabled(uint32_t bp_index);
33
34 uint32_t NumSupportedHardwareWatchpoints() override;
35
36 uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
37 uint32_t watch_flags) override;
38
39 bool ClearHardwareWatchpoint(uint32_t hw_index) override;
40
41 Status ClearAllHardwareWatchpoints() override;
42
43 Status GetWatchpointHitIndex(uint32_t &wp_index,
44 lldb::addr_t trap_addr) override;
45
46 lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
47
48 lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
49
50 uint32_t GetWatchpointSize(uint32_t wp_index);
51
52 bool WatchpointIsEnabled(uint32_t wp_index);
53
54 // Debug register type select
55 enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
56
57protected:
58 /// Debug register info for hardware breakpoints and watchpoints management.
59 /// Watchpoints: For a user requested size 4 at addr 0x1004, where BAS
60 /// watchpoints are at doubleword (8-byte) alignment.
61 /// \a real_addr is 0x1004
62 /// \a address is 0x1000
63 /// size is 8
64 /// If a one-byte write to 0x1006 is the most recent watchpoint trap,
65 /// \a hit_addr is 0x1006
66 struct DREG {
67 lldb::addr_t address; // Breakpoint/watchpoint address value.
68 lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception
69 // occurred.
70 lldb::addr_t real_addr; // Address value that should cause target to stop.
71 uint32_t control; // Breakpoint/watchpoint control value.
72 };
73
74 std::array<struct DREG, 16> m_hbp_regs; // hardware breakpoints
75 std::array<struct DREG, 16> m_hwp_regs; // hardware watchpoints
76
77 uint32_t m_max_hbp_supported;
78 uint32_t m_max_hwp_supported;
79
80 virtual llvm::Error ReadHardwareDebugInfo() = 0;
81 virtual llvm::Error WriteHardwareDebugRegs(DREGType hwbType) = 0;
82 virtual lldb::addr_t FixWatchpointHitAddress(lldb::addr_t hit_addr) {
83 return hit_addr;
84 }
85};
86
87} // namespace lldb_private
88
89#endif // #ifndef lldb_NativeRegisterContextDBReg_arm64_h
90

source code of lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.h