1 /* Memory breakpoint interfaces for the remote server for GDB.
2 Copyright (C) 2002-2016 Free Software Foundation, Inc.
4 Contributed by MontaVista Software.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "break-common.h"
26 /* Breakpoints are opaque. */
28 struct gdb_breakpoint
;
29 struct fast_tracepoint_jump
;
30 struct raw_breakpoint
;
33 #define Z_PACKET_SW_BP '0'
34 #define Z_PACKET_HW_BP '1'
35 #define Z_PACKET_WRITE_WP '2'
36 #define Z_PACKET_READ_WP '3'
37 #define Z_PACKET_ACCESS_WP '4'
39 /* The low level breakpoint types. */
43 /* Software/memory breakpoint. */
46 /* Hardware-assisted breakpoint. */
49 /* Hardware-assisted write watchpoint. */
50 raw_bkpt_type_write_wp
,
52 /* Hardware-assisted read watchpoint. */
53 raw_bkpt_type_read_wp
,
55 /* Hardware-assisted access watchpoint. */
56 raw_bkpt_type_access_wp
59 /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
60 raw breakpoint type. */
62 enum raw_bkpt_type
Z_packet_to_raw_bkpt_type (char z_type
);
64 /* Map a raw breakpoint type to an enum target_hw_bp_type. */
66 enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
67 (enum raw_bkpt_type raw_type
);
69 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
70 Returns a pointer to the newly created breakpoint on success. On
71 failure returns NULL and sets *ERR to either -1 for error, or 1 if
72 Z_TYPE breakpoints are not supported on this target. */
74 struct gdb_breakpoint
*set_gdb_breakpoint (char z_type
, CORE_ADDR addr
,
77 /* Delete a GDB breakpoint of type Z_TYPE and kind KIND previously
78 inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
79 -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
82 int delete_gdb_breakpoint (char z_type
, CORE_ADDR addr
, int kind
);
84 /* Returns TRUE if there's a software or hardware (code) breakpoint at
85 ADDR in our tables, inserted, or not. */
87 int breakpoint_here (CORE_ADDR addr
);
89 /* Returns TRUE if there's any inserted software or hardware (code)
90 breakpoint set at ADDR. */
92 int breakpoint_inserted_here (CORE_ADDR addr
);
94 /* Returns TRUE if there's any inserted software breakpoint at
97 int software_breakpoint_inserted_here (CORE_ADDR addr
);
99 /* Returns TRUE if there's any inserted hardware (code) breakpoint at
102 int hardware_breakpoint_inserted_here (CORE_ADDR addr
);
104 /* Returns TRUE if there's any reinsert breakpoint at ADDR. */
106 int reinsert_breakpoint_inserted_here (CORE_ADDR addr
);
108 /* Clear all breakpoint conditions and commands associated with a
111 void clear_breakpoint_conditions_and_commands (struct gdb_breakpoint
*bp
);
113 /* Set target-side condition CONDITION to the breakpoint at ADDR.
114 Returns false on failure. On success, advances CONDITION pointer
115 past the condition and returns true. */
117 int add_breakpoint_condition (struct gdb_breakpoint
*bp
, char **condition
);
119 /* Set target-side commands COMMANDS to the breakpoint at ADDR.
120 Returns false on failure. On success, advances COMMANDS past the
121 commands and returns true. If PERSIST, the commands should run
122 even while GDB is disconnected. */
124 int add_breakpoint_commands (struct gdb_breakpoint
*bp
, char **commands
,
127 int any_persistent_commands (void);
129 /* Evaluation condition (if any) at breakpoint BP. Return 1 if
130 true and 0 otherwise. */
132 int gdb_condition_true_at_breakpoint (CORE_ADDR where
);
134 int gdb_no_commands_at_breakpoint (CORE_ADDR where
);
136 void run_breakpoint_commands (CORE_ADDR where
);
138 /* Returns TRUE if there's a GDB breakpoint (Z0 or Z1) set at
141 int gdb_breakpoint_here (CORE_ADDR where
);
143 /* Create a new breakpoint at WHERE, and call HANDLER when
144 it is hit. HANDLER should return 1 if the breakpoint
145 should be deleted, 0 otherwise. The type of the created
146 breakpoint is other_breakpoint. */
148 struct breakpoint
*set_breakpoint_at (CORE_ADDR where
,
149 int (*handler
) (CORE_ADDR
));
151 /* Delete a breakpoint. */
153 int delete_breakpoint (struct breakpoint
*bkpt
);
155 /* Set a reinsert breakpoint at STOP_AT. */
157 void set_reinsert_breakpoint (CORE_ADDR stop_at
);
159 /* Delete all reinsert breakpoints. */
161 void delete_reinsert_breakpoints (void);
163 /* Reinsert all reinsert breakpoints of the current process. */
165 void reinsert_reinsert_breakpoints (void);
167 /* Uninsert all reinsert breakpoints of the current process. This
168 still leaves the reinsert breakpoints in the table. */
170 void uninsert_reinsert_breakpoints (void);
172 /* Reinsert breakpoints at WHERE (and change their status to
175 void reinsert_breakpoints_at (CORE_ADDR where
);
177 /* Process PROC has reinsert breakpoints or not. */
179 int has_reinsert_breakpoints (struct process_info
*proc
);
181 /* Uninsert breakpoints at WHERE (and change their status to
182 uninserted). This still leaves the breakpoints in the table. */
184 void uninsert_breakpoints_at (CORE_ADDR where
);
186 /* Reinsert all breakpoints of the current process (and change their
187 status to inserted). */
189 void reinsert_all_breakpoints (void);
191 /* Uninsert all breakpoints of the current process (and change their
192 status to uninserted). This still leaves the breakpoints in the
195 void uninsert_all_breakpoints (void);
197 /* See if any breakpoint claims ownership of STOP_PC. Call the handler for
198 the breakpoint, if found. */
200 void check_breakpoints (CORE_ADDR stop_pc
);
202 /* See if any breakpoints shadow the target memory area from MEM_ADDR
203 to MEM_ADDR + MEM_LEN. Update the data already read from the target
204 (in BUF) if necessary. */
206 void check_mem_read (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
);
208 /* See if any breakpoints shadow the target memory area from MEM_ADDR
209 to MEM_ADDR + MEM_LEN. Update the data to be written to the target
210 (in BUF, a copy of MYADDR on entry) if necessary, as well as the
211 original data for any breakpoints. */
213 void check_mem_write (CORE_ADDR mem_addr
,
214 unsigned char *buf
, const unsigned char *myaddr
, int mem_len
);
216 /* Delete all breakpoints. */
218 void delete_all_breakpoints (void);
220 /* Clear the "inserted" flag in all breakpoints of PROC. */
222 void mark_breakpoints_out (struct process_info
*proc
);
224 /* Delete all breakpoints, but do not try to un-insert them from the
227 void free_all_breakpoints (struct process_info
*proc
);
229 /* Check if breakpoints still seem to be inserted in the inferior. */
231 void validate_breakpoints (void);
233 /* Insert a fast tracepoint jump at WHERE, using instruction INSN, of
236 struct fast_tracepoint_jump
*set_fast_tracepoint_jump (CORE_ADDR where
,
240 /* Increment reference counter of JP. */
241 void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump
*jp
);
243 /* Delete fast tracepoint jump TODEL from our tables, and uninsert if
246 int delete_fast_tracepoint_jump (struct fast_tracepoint_jump
*todel
);
248 /* Returns true if there's fast tracepoint jump set at WHERE. */
250 int fast_tracepoint_jump_here (CORE_ADDR
);
252 /* Uninsert fast tracepoint jumps at WHERE (and change their status to
253 uninserted). This still leaves the tracepoints in the table. */
255 void uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc
);
257 /* Reinsert fast tracepoint jumps at WHERE (and change their status to
260 void reinsert_fast_tracepoint_jumps_at (CORE_ADDR where
);
262 /* Insert a memory breakpoint. */
264 int insert_memory_breakpoint (struct raw_breakpoint
*bp
);
266 /* Remove a previously inserted memory breakpoint. */
268 int remove_memory_breakpoint (struct raw_breakpoint
*bp
);
270 /* Create a new breakpoint list NEW_BKPT_LIST that is a copy of SRC. */
272 void clone_all_breakpoints (struct breakpoint
**new_bkpt_list
,
273 struct raw_breakpoint
**new_raw_bkpt_list
,
274 const struct breakpoint
*src
);
276 #endif /* MEM_BREAK_H */