1 /* Memory breakpoint interfaces for the remote server for GDB.
2 Copyright (C) 2002-2014 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 fast_tracepoint_jump
;
29 struct raw_breakpoint
;
32 #define Z_PACKET_SW_BP '0'
33 #define Z_PACKET_HW_BP '1'
34 #define Z_PACKET_WRITE_WP '2'
35 #define Z_PACKET_READ_WP '3'
36 #define Z_PACKET_ACCESS_WP '4'
38 /* The low level breakpoint types. */
42 /* Software/memory breakpoint. */
45 /* Hardware-assisted breakpoint. */
48 /* Hardware-assisted write watchpoint. */
49 raw_bkpt_type_write_wp
,
51 /* Hardware-assisted read watchpoint. */
52 raw_bkpt_type_read_wp
,
54 /* Hardware-assisted access watchpoint. */
55 raw_bkpt_type_access_wp
58 /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
59 raw breakpoint type. */
61 enum raw_bkpt_type
Z_packet_to_raw_bkpt_type (char z_type
);
63 /* Map a raw breakpoint type to an enum target_hw_bp_type. */
65 enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
66 (enum raw_bkpt_type raw_type
);
68 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with size SIZE.
69 Returns a pointer to the newly created breakpoint on success. On
70 failure returns NULL and sets *ERR to either -1 for error, or 1 if
71 Z_TYPE breakpoints are not supported on this target. */
73 struct breakpoint
*set_gdb_breakpoint (char z_type
, CORE_ADDR addr
, int size
,
76 /* Delete a GDB breakpoint of type Z_TYPE and size SIZE previously
77 inserted at ADDR with set_gdb_breakpoint_at. Returns 0 on success,
78 -1 on error, and 1 if Z_TYPE breakpoints are not supported on this
81 int delete_gdb_breakpoint (char z_type
, CORE_ADDR addr
, int size
);
83 /* Returns TRUE if there's a software or hardware (code) breakpoint at
84 ADDR in our tables, inserted, or not. */
86 int breakpoint_here (CORE_ADDR addr
);
88 /* Returns TRUE if there's any inserted software or hardware (code)
89 breakpoint set at ADDR. */
91 int breakpoint_inserted_here (CORE_ADDR addr
);
93 /* Clear all breakpoint conditions associated with this address. */
95 void clear_breakpoint_conditions (struct breakpoint
*bp
);
97 /* Set target-side condition CONDITION to the breakpoint at ADDR.
98 Returns false on failure. On success, advances CONDITION pointer
99 past the condition and returns true. */
101 int add_breakpoint_condition (struct breakpoint
*bp
, char **condition
);
103 /* Set target-side commands COMMANDS to the breakpoint at ADDR.
104 Returns false on failure. On success, advances COMMANDS past the
105 commands and returns true. If PERSIST, the commands should run
106 even while GDB is disconnected. */
108 int add_breakpoint_commands (struct breakpoint
*bp
, char **commands
,
111 int any_persistent_commands (void);
113 /* Evaluation condition (if any) at breakpoint BP. Return 1 if
114 true and 0 otherwise. */
116 int gdb_condition_true_at_breakpoint (CORE_ADDR where
);
118 int gdb_no_commands_at_breakpoint (CORE_ADDR where
);
120 void run_breakpoint_commands (CORE_ADDR where
);
122 /* Returns TRUE if there's a GDB breakpoint (Z0 or Z1) set at
125 int gdb_breakpoint_here (CORE_ADDR where
);
127 /* Create a new breakpoint at WHERE, and call HANDLER when
128 it is hit. HANDLER should return 1 if the breakpoint
129 should be deleted, 0 otherwise. */
131 struct breakpoint
*set_breakpoint_at (CORE_ADDR where
,
132 int (*handler
) (CORE_ADDR
));
134 /* Delete a breakpoint. */
136 int delete_breakpoint (struct breakpoint
*bkpt
);
138 /* Set a reinsert breakpoint at STOP_AT. */
140 void set_reinsert_breakpoint (CORE_ADDR stop_at
);
142 /* Delete all reinsert breakpoints. */
144 void delete_reinsert_breakpoints (void);
146 /* Reinsert breakpoints at WHERE (and change their status to
149 void reinsert_breakpoints_at (CORE_ADDR where
);
151 /* Uninsert breakpoints at WHERE (and change their status to
152 uninserted). This still leaves the breakpoints in the table. */
154 void uninsert_breakpoints_at (CORE_ADDR where
);
156 /* Reinsert all breakpoints of the current process (and change their
157 status to inserted). */
159 void reinsert_all_breakpoints (void);
161 /* Uninsert all breakpoints of the current process (and change their
162 status to uninserted). This still leaves the breakpoints in the
165 void uninsert_all_breakpoints (void);
167 /* See if any breakpoint claims ownership of STOP_PC. Call the handler for
168 the breakpoint, if found. */
170 void check_breakpoints (CORE_ADDR stop_pc
);
172 /* See if any breakpoints shadow the target memory area from MEM_ADDR
173 to MEM_ADDR + MEM_LEN. Update the data already read from the target
174 (in BUF) if necessary. */
176 void check_mem_read (CORE_ADDR mem_addr
, unsigned char *buf
, int mem_len
);
178 /* See if any breakpoints shadow the target memory area from MEM_ADDR
179 to MEM_ADDR + MEM_LEN. Update the data to be written to the target
180 (in BUF, a copy of MYADDR on entry) if necessary, as well as the
181 original data for any breakpoints. */
183 void check_mem_write (CORE_ADDR mem_addr
,
184 unsigned char *buf
, const unsigned char *myaddr
, int mem_len
);
186 /* Set the byte pattern to insert for memory breakpoints. This function
187 must be called before any breakpoints are set. */
189 void set_breakpoint_data (const unsigned char *bp_data
, int bp_len
);
191 /* Delete all breakpoints. */
193 void delete_all_breakpoints (void);
195 /* Clear the "inserted" flag in all breakpoints of PROC. */
197 void mark_breakpoints_out (struct process_info
*proc
);
199 /* Delete all breakpoints, but do not try to un-insert them from the
202 void free_all_breakpoints (struct process_info
*proc
);
204 /* Check if breakpoints still seem to be inserted in the inferior. */
206 void validate_breakpoints (void);
208 /* Insert a fast tracepoint jump at WHERE, using instruction INSN, of
211 struct fast_tracepoint_jump
*set_fast_tracepoint_jump (CORE_ADDR where
,
215 /* Increment reference counter of JP. */
216 void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump
*jp
);
218 /* Delete fast tracepoint jump TODEL from our tables, and uninsert if
221 int delete_fast_tracepoint_jump (struct fast_tracepoint_jump
*todel
);
223 /* Returns true if there's fast tracepoint jump set at WHERE. */
225 int fast_tracepoint_jump_here (CORE_ADDR
);
227 /* Uninsert fast tracepoint jumps at WHERE (and change their status to
228 uninserted). This still leaves the tracepoints in the table. */
230 void uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc
);
232 /* Reinsert fast tracepoint jumps at WHERE (and change their status to
235 void reinsert_fast_tracepoint_jumps_at (CORE_ADDR where
);
237 /* Insert a memory breakpoint. */
239 int insert_memory_breakpoint (struct raw_breakpoint
*bp
);
241 /* Remove a previously inserted memory breakpoint. */
243 int remove_memory_breakpoint (struct raw_breakpoint
*bp
);
245 #endif /* MEM_BREAK_H */