Pass breakpoint type in set_breakpoint_at
[deliverable/binutils-gdb.git] / gdb / gdbserver / mem-break.h
1 /* Memory breakpoint interfaces for the remote server for GDB.
2 Copyright (C) 2002-2016 Free Software Foundation, Inc.
3
4 Contributed by MontaVista Software.
5
6 This file is part of GDB.
7
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.
12
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.
17
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/>. */
20
21 #ifndef MEM_BREAK_H
22 #define MEM_BREAK_H
23
24 #include "break-common.h"
25
26 /* Breakpoints are opaque. */
27 struct breakpoint;
28 struct fast_tracepoint_jump;
29 struct raw_breakpoint;
30 struct process_info;
31
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'
37
38 /* The low level breakpoint types. */
39
40 enum raw_bkpt_type
41 {
42 /* Software/memory breakpoint. */
43 raw_bkpt_type_sw,
44
45 /* Hardware-assisted breakpoint. */
46 raw_bkpt_type_hw,
47
48 /* Hardware-assisted write watchpoint. */
49 raw_bkpt_type_write_wp,
50
51 /* Hardware-assisted read watchpoint. */
52 raw_bkpt_type_read_wp,
53
54 /* Hardware-assisted access watchpoint. */
55 raw_bkpt_type_access_wp
56 };
57
58 /* Map the protocol breakpoint/watchpoint type Z_TYPE to the internal
59 raw breakpoint type. */
60
61 enum raw_bkpt_type Z_packet_to_raw_bkpt_type (char z_type);
62
63 /* Map a raw breakpoint type to an enum target_hw_bp_type. */
64
65 enum target_hw_bp_type raw_bkpt_type_to_target_hw_bp_type
66 (enum raw_bkpt_type raw_type);
67
68 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
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. */
72
73 struct breakpoint *set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind,
74 int *err);
75
76 /* Delete a GDB breakpoint of type Z_TYPE and kind KIND 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
79 target. */
80
81 int delete_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind);
82
83 /* Returns TRUE if there's a software or hardware (code) breakpoint at
84 ADDR in our tables, inserted, or not. */
85
86 int breakpoint_here (CORE_ADDR addr);
87
88 /* Returns TRUE if there's any inserted software or hardware (code)
89 breakpoint set at ADDR. */
90
91 int breakpoint_inserted_here (CORE_ADDR addr);
92
93 /* Returns TRUE if there's any inserted software breakpoint at
94 ADDR. */
95
96 int software_breakpoint_inserted_here (CORE_ADDR addr);
97
98 /* Returns TRUE if there's any inserted hardware (code) breakpoint at
99 ADDR. */
100
101 int hardware_breakpoint_inserted_here (CORE_ADDR addr);
102
103 /* Returns TRUE if there's any reinsert breakpoint at ADDR. */
104
105 int reinsert_breakpoint_inserted_here (CORE_ADDR addr);
106
107 /* Clear all breakpoint conditions and commands associated with a
108 breakpoint. */
109
110 void clear_breakpoint_conditions_and_commands (struct breakpoint *bp);
111
112 /* Set target-side condition CONDITION to the breakpoint at ADDR.
113 Returns false on failure. On success, advances CONDITION pointer
114 past the condition and returns true. */
115
116 int add_breakpoint_condition (struct breakpoint *bp, char **condition);
117
118 /* Set target-side commands COMMANDS to the breakpoint at ADDR.
119 Returns false on failure. On success, advances COMMANDS past the
120 commands and returns true. If PERSIST, the commands should run
121 even while GDB is disconnected. */
122
123 int add_breakpoint_commands (struct breakpoint *bp, char **commands,
124 int persist);
125
126 int any_persistent_commands (void);
127
128 /* Evaluation condition (if any) at breakpoint BP. Return 1 if
129 true and 0 otherwise. */
130
131 int gdb_condition_true_at_breakpoint (CORE_ADDR where);
132
133 int gdb_no_commands_at_breakpoint (CORE_ADDR where);
134
135 void run_breakpoint_commands (CORE_ADDR where);
136
137 /* Returns TRUE if there's a GDB breakpoint (Z0 or Z1) set at
138 WHERE. */
139
140 int gdb_breakpoint_here (CORE_ADDR where);
141
142 /* Create a new breakpoint at WHERE, and call HANDLER when
143 it is hit. HANDLER should return 1 if the breakpoint
144 should be deleted, 0 otherwise. The type of the created
145 breakpoint is other_breakpoint. */
146
147 struct breakpoint *set_breakpoint_at (CORE_ADDR where,
148 int (*handler) (CORE_ADDR));
149
150 /* Delete a breakpoint. */
151
152 int delete_breakpoint (struct breakpoint *bkpt);
153
154 /* Set a reinsert breakpoint at STOP_AT. */
155
156 void set_reinsert_breakpoint (CORE_ADDR stop_at);
157
158 /* Delete all reinsert breakpoints. */
159
160 void delete_reinsert_breakpoints (void);
161
162 /* Reinsert all reinsert breakpoints of the current process. */
163
164 void reinsert_reinsert_breakpoints (void);
165
166 /* Uninsert all reinsert breakpoints of the current process. This
167 still leaves the reinsert breakpoints in the table. */
168
169 void uninsert_reinsert_breakpoints (void);
170
171 /* Reinsert breakpoints at WHERE (and change their status to
172 inserted). */
173
174 void reinsert_breakpoints_at (CORE_ADDR where);
175
176 /* Process PROC has reinsert breakpoints or not. */
177
178 int has_reinsert_breakpoints (struct process_info *proc);
179
180 /* Uninsert breakpoints at WHERE (and change their status to
181 uninserted). This still leaves the breakpoints in the table. */
182
183 void uninsert_breakpoints_at (CORE_ADDR where);
184
185 /* Reinsert all breakpoints of the current process (and change their
186 status to inserted). */
187
188 void reinsert_all_breakpoints (void);
189
190 /* Uninsert all breakpoints of the current process (and change their
191 status to uninserted). This still leaves the breakpoints in the
192 table. */
193
194 void uninsert_all_breakpoints (void);
195
196 /* See if any breakpoint claims ownership of STOP_PC. Call the handler for
197 the breakpoint, if found. */
198
199 void check_breakpoints (CORE_ADDR stop_pc);
200
201 /* See if any breakpoints shadow the target memory area from MEM_ADDR
202 to MEM_ADDR + MEM_LEN. Update the data already read from the target
203 (in BUF) if necessary. */
204
205 void check_mem_read (CORE_ADDR mem_addr, unsigned char *buf, int mem_len);
206
207 /* See if any breakpoints shadow the target memory area from MEM_ADDR
208 to MEM_ADDR + MEM_LEN. Update the data to be written to the target
209 (in BUF, a copy of MYADDR on entry) if necessary, as well as the
210 original data for any breakpoints. */
211
212 void check_mem_write (CORE_ADDR mem_addr,
213 unsigned char *buf, const unsigned char *myaddr, int mem_len);
214
215 /* Delete all breakpoints. */
216
217 void delete_all_breakpoints (void);
218
219 /* Clear the "inserted" flag in all breakpoints of PROC. */
220
221 void mark_breakpoints_out (struct process_info *proc);
222
223 /* Delete all breakpoints, but do not try to un-insert them from the
224 inferior. */
225
226 void free_all_breakpoints (struct process_info *proc);
227
228 /* Check if breakpoints still seem to be inserted in the inferior. */
229
230 void validate_breakpoints (void);
231
232 /* Insert a fast tracepoint jump at WHERE, using instruction INSN, of
233 LENGTH bytes. */
234
235 struct fast_tracepoint_jump *set_fast_tracepoint_jump (CORE_ADDR where,
236 unsigned char *insn,
237 ULONGEST length);
238
239 /* Increment reference counter of JP. */
240 void inc_ref_fast_tracepoint_jump (struct fast_tracepoint_jump *jp);
241
242 /* Delete fast tracepoint jump TODEL from our tables, and uninsert if
243 from memory. */
244
245 int delete_fast_tracepoint_jump (struct fast_tracepoint_jump *todel);
246
247 /* Returns true if there's fast tracepoint jump set at WHERE. */
248
249 int fast_tracepoint_jump_here (CORE_ADDR);
250
251 /* Uninsert fast tracepoint jumps at WHERE (and change their status to
252 uninserted). This still leaves the tracepoints in the table. */
253
254 void uninsert_fast_tracepoint_jumps_at (CORE_ADDR pc);
255
256 /* Reinsert fast tracepoint jumps at WHERE (and change their status to
257 inserted). */
258
259 void reinsert_fast_tracepoint_jumps_at (CORE_ADDR where);
260
261 /* Insert a memory breakpoint. */
262
263 int insert_memory_breakpoint (struct raw_breakpoint *bp);
264
265 /* Remove a previously inserted memory breakpoint. */
266
267 int remove_memory_breakpoint (struct raw_breakpoint *bp);
268
269 /* Create a new breakpoint list NEW_BKPT_LIST that is a copy of SRC. */
270
271 void clone_all_breakpoints (struct breakpoint **new_bkpt_list,
272 struct raw_breakpoint **new_raw_bkpt_list,
273 const struct breakpoint *src);
274
275 #endif /* MEM_BREAK_H */
This page took 0.043396 seconds and 5 git commands to generate.