Automatic date update in version.in
[binutils-gdb.git] / gdb / aarch64-nat.h
blobfee6bda257779401188c71efb5f9a76ed8856ccf
1 /* Native-dependent code for AArch64.
3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef AARCH64_NAT_H
21 #define AARCH64_NAT_H
23 #include "breakpoint.h"
24 #include "nat/aarch64-hw-point.h"
25 #include "target.h"
27 /* Hardware-assisted breakpoints and watchpoints. */
29 /* Initialize platform-independent state for hardware-assisted
30 breakpoints and watchpoints. */
32 void aarch64_initialize_hw_point ();
34 /* Return the debug register state for process PID. If no existing
35 state is found for this process, return nullptr. */
37 struct aarch64_debug_reg_state *aarch64_lookup_debug_reg_state (pid_t pid);
39 /* Return the debug register state for process PID. If no existing
40 state is found for this process, create new state. */
42 struct aarch64_debug_reg_state *aarch64_get_debug_reg_state (pid_t pid);
44 /* Remove any existing per-process debug state for process PID. */
46 void aarch64_remove_debug_reg_state (pid_t pid);
48 /* Helper for the "stopped_data_address" target method. Returns TRUE
49 if a hardware watchpoint trap at ADDR_TRAP matches a set
50 watchpoint. The address of the matched watchpoint is returned in
51 *ADDR_P. */
53 bool aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
54 CORE_ADDR addr_trap, CORE_ADDR *addr_p);
56 /* Helper functions used by aarch64_nat_target below. See their
57 definitions. */
59 int aarch64_can_use_hw_breakpoint (enum bptype type, int cnt, int othertype);
60 int aarch64_insert_watchpoint (CORE_ADDR addr, int len,
61 enum target_hw_bp_type type,
62 struct expression *cond);
63 int aarch64_remove_watchpoint (CORE_ADDR addr, int len,
64 enum target_hw_bp_type type,
65 struct expression *cond);
66 int aarch64_insert_hw_breakpoint (struct gdbarch *gdbarch,
67 struct bp_target_info *bp_tgt);
68 int aarch64_remove_hw_breakpoint (struct gdbarch *gdbarch,
69 struct bp_target_info *bp_tgt);
70 int aarch64_stopped_by_hw_breakpoint ();
72 /* Convenience template mixin used to add aarch64 watchpoints support to a
73 target. */
75 template <typename BaseTarget>
76 struct aarch64_nat_target : public BaseTarget
78 /* Hook in common aarch64 hardware watchpoints/breakpoints support. */
80 int can_use_hw_breakpoint (enum bptype type, int cnt, int othertype) override
81 { return aarch64_can_use_hw_breakpoint (type, cnt, othertype); }
83 int region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) override
84 { return aarch64_region_ok_for_watchpoint (addr, len); }
86 int insert_watchpoint (CORE_ADDR addr, int len,
87 enum target_hw_bp_type type,
88 struct expression *cond) override
89 { return aarch64_insert_watchpoint (addr, len, type, cond); }
91 int remove_watchpoint (CORE_ADDR addr, int len,
92 enum target_hw_bp_type type,
93 struct expression *cond) override
94 { return aarch64_remove_watchpoint (addr, len, type, cond); }
96 int insert_hw_breakpoint (struct gdbarch *gdbarch,
97 struct bp_target_info *bp_tgt) override
98 { return aarch64_insert_hw_breakpoint (gdbarch, bp_tgt); }
100 int remove_hw_breakpoint (struct gdbarch *gdbarch,
101 struct bp_target_info *bp_tgt) override
102 { return aarch64_remove_hw_breakpoint (gdbarch, bp_tgt); }
104 bool watchpoint_addr_within_range (CORE_ADDR addr, CORE_ADDR start,
105 int length) override
106 { return start <= addr && start + length - 1 >= addr; }
109 #endif /* AARCH64_NAT_H */