1 /* Native-dependent code for AArch64.
3 Copyright (C) 2011-2024 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/>. */
23 #include "breakpoint.h"
24 #include "nat/aarch64-hw-point.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 functions used by aarch64_nat_target below. See their
51 int aarch64_can_use_hw_breakpoint (enum bptype type
, int cnt
, int othertype
);
52 int aarch64_insert_watchpoint (CORE_ADDR addr
, int len
,
53 enum target_hw_bp_type type
,
54 struct expression
*cond
);
55 int aarch64_remove_watchpoint (CORE_ADDR addr
, int len
,
56 enum target_hw_bp_type type
,
57 struct expression
*cond
);
58 int aarch64_insert_hw_breakpoint (struct gdbarch
*gdbarch
,
59 struct bp_target_info
*bp_tgt
);
60 int aarch64_remove_hw_breakpoint (struct gdbarch
*gdbarch
,
61 struct bp_target_info
*bp_tgt
);
62 int aarch64_stopped_by_hw_breakpoint ();
64 /* Convenience template mixin used to add aarch64 watchpoints support to a
67 template <typename BaseTarget
>
68 struct aarch64_nat_target
: public BaseTarget
70 /* Hook in common aarch64 hardware watchpoints/breakpoints support. */
72 int can_use_hw_breakpoint (enum bptype type
, int cnt
, int othertype
) override
73 { return aarch64_can_use_hw_breakpoint (type
, cnt
, othertype
); }
75 int region_ok_for_hw_watchpoint (CORE_ADDR addr
, int len
) override
76 { return aarch64_region_ok_for_watchpoint (addr
, len
); }
78 int insert_watchpoint (CORE_ADDR addr
, int len
,
79 enum target_hw_bp_type type
,
80 struct expression
*cond
) override
81 { return aarch64_insert_watchpoint (addr
, len
, type
, cond
); }
83 int remove_watchpoint (CORE_ADDR addr
, int len
,
84 enum target_hw_bp_type type
,
85 struct expression
*cond
) override
86 { return aarch64_remove_watchpoint (addr
, len
, type
, cond
); }
88 int insert_hw_breakpoint (struct gdbarch
*gdbarch
,
89 struct bp_target_info
*bp_tgt
) override
90 { return aarch64_insert_hw_breakpoint (gdbarch
, bp_tgt
); }
92 int remove_hw_breakpoint (struct gdbarch
*gdbarch
,
93 struct bp_target_info
*bp_tgt
) override
94 { return aarch64_remove_hw_breakpoint (gdbarch
, bp_tgt
); }
96 bool watchpoint_addr_within_range (CORE_ADDR addr
, CORE_ADDR start
,
98 { return start
<= addr
&& start
+ length
- 1 >= addr
; }
101 #endif /* AARCH64_NAT_H */