8317dd3886b2a9b42c7895667b713337275700c1
[deliverable/binutils-gdb.git] / gdb / breakpoint.h
1 /* Data structures associated with breakpoints in GDB.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #if !defined (BREAKPOINT_H)
21 #define BREAKPOINT_H 1
22
23 #include "frame.h"
24 #include "value.h"
25
26 /* This is the maximum number of bytes a breakpoint instruction can take.
27 Feel free to increase it. It's just used in a few places to size
28 arrays that should be independent of the target architecture. */
29
30 #define BREAKPOINT_MAX 16
31 \f
32 /* Type of breakpoint. */
33 /* FIXME In the future, we should fold all other breakpoint-like things into
34 here. This includes:
35
36 * single-step (for machines where we have to simulate single stepping)
37 (probably, though perhaps it is better for it to look as much as
38 possible like a single-step to wait_for_inferior). */
39
40 enum bptype {
41 bp_breakpoint, /* Normal breakpoint */
42 bp_until, /* used by until command */
43 bp_finish, /* used by finish command */
44 bp_watchpoint, /* Watchpoint */
45 bp_longjmp, /* secret breakpoint to find longjmp() */
46 bp_longjmp_resume, /* secret breakpoint to escape longjmp() */
47
48 /* Used by wait_for_inferior for stepping over subroutine calls, for
49 stepping over signal handlers, and for skipping prologues. */
50 bp_step_resume,
51
52 /* The breakpoint at the end of a call dummy. */
53 bp_call_dummy
54 };
55
56 /* States of enablement of breakpoint. */
57
58 enum enable { disabled, enabled};
59
60 /* Disposition of breakpoint. Ie: what to do after hitting it. */
61
62 enum bpdisp {
63 delete, /* Delete it */
64 disable, /* Disable it */
65 donttouch /* Leave it alone */
66 };
67
68 /* Note that the ->silent field is not currently used by any commands
69 (though the code is in there if it was to be, and set_raw_breakpoint
70 does set it to 0). I implemented it because I thought it would be
71 useful for a hack I had to put in; I'm going to leave it in because
72 I can see how there might be times when it would indeed be useful */
73
74 /* This is for a breakpoint or a watchpoint. */
75
76 struct breakpoint
77 {
78 struct breakpoint *next;
79 /* Type of breakpoint. */
80 enum bptype type;
81 /* Zero means disabled; remember the info but don't break here. */
82 enum enable enable;
83 /* What to do with this breakpoint after we hit it. */
84 enum bpdisp disposition;
85 /* Number assigned to distinguish breakpoints. */
86 int number;
87
88 /* Address to break at, or NULL if not a breakpoint. */
89 CORE_ADDR address;
90
91 /* Line number of this address. Only matters if address is
92 non-NULL. */
93
94 int line_number;
95
96 /* Source file name of this address. Only matters if address is
97 non-NULL. */
98
99 char *source_file;
100
101 /* Non-zero means a silent breakpoint (don't print frame info
102 if we stop here). */
103 unsigned char silent;
104 /* Number of stops at this breakpoint that should
105 be continued automatically before really stopping. */
106 int ignore_count;
107 /* "Real" contents of byte where breakpoint has been inserted.
108 Valid only when breakpoints are in the program. Under the complete
109 control of the target insert_breakpoint and remove_breakpoint routines.
110 No other code should assume anything about the value(s) here. */
111 char shadow_contents[BREAKPOINT_MAX];
112 /* Nonzero if this breakpoint is now inserted. Only matters if address
113 is non-NULL. */
114 char inserted;
115 /* Nonzero if this is not the first breakpoint in the list
116 for the given address. Only matters if address is non-NULL. */
117 char duplicate;
118 /* Chain of command lines to execute when this breakpoint is hit. */
119 struct command_line *commands;
120 /* Stack depth (address of frame). If nonzero, break only if fp
121 equals this. */
122 FRAME_ADDR frame;
123 /* Conditional. Break only if this expression's value is nonzero. */
124 struct expression *cond;
125
126 /* String we used to set the breakpoint (malloc'd). Only matters if
127 address is non-NULL. */
128 char *addr_string;
129 /* String form of the breakpoint condition (malloc'd), or NULL if there
130 is no condition. */
131 char *cond_string;
132 /* String form of exp (malloc'd), or NULL if none. */
133 char *exp_string;
134
135 /* The expression we are watching, or NULL if not a watchpoint. */
136 struct expression *exp;
137 /* The largest block within which it is valid, or NULL if it is
138 valid anywhere (e.g. consists just of global symbols). */
139 struct block *exp_valid_block;
140 /* Value of the watchpoint the last time we checked it. */
141 value val;
142 };
143 \f
144 /* The following stuff is an abstract data type "bpstat" ("breakpoint status").
145 This provides the ability to determine whether we have stopped at a
146 breakpoint, and what we should do about it. */
147
148 typedef struct bpstat *bpstat;
149
150 /* Interface: */
151 /* Clear a bpstat so that it says we are not at any breakpoint.
152 Also free any storage that is part of a bpstat. */
153 extern void bpstat_clear PARAMS ((bpstat *));
154
155 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
156 is part of the bpstat is copied as well. */
157 extern bpstat bpstat_copy PARAMS ((bpstat));
158
159 /* Get a bpstat associated with having just stopped at address *PC
160 and frame address FRAME_ADDRESS. Update *PC to point at the
161 breakpoint (if we hit a breakpoint). */
162 /* FIXME: prototypes uses equivalence between FRAME_ADDR and CORE_ADDR */
163 extern bpstat bpstat_stop_status PARAMS ((CORE_ADDR *, CORE_ADDR));
164 \f
165 /* This bpstat_what stuff tells wait_for_inferior what to do with a
166 breakpoint (a challenging task). */
167
168 enum bpstat_what_main_action {
169 /* Perform various other tests; that is, this bpstat does not
170 say to perform any action (e.g. failed watchpoint and nothing
171 else). */
172 BPSTAT_WHAT_KEEP_CHECKING,
173
174 /* Rather than distinguish between noisy and silent stops here, it
175 might be cleaner to have bpstat_print make that decision (also
176 taking into account stop_print_frame and source_only). But the
177 implications are a bit scary (interaction with auto-displays, etc.),
178 so I won't try it. */
179
180 /* Stop silently. */
181 BPSTAT_WHAT_STOP_SILENT,
182
183 /* Stop and print. */
184 BPSTAT_WHAT_STOP_NOISY,
185
186 /* Remove breakpoints, single step once, then put them back in and
187 go back to what we were doing. It's possible that this should be
188 removed from the main_action and put into a separate field, to more
189 cleanly handle BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */
190 BPSTAT_WHAT_SINGLE,
191
192 /* Set longjmp_resume breakpoint, remove all other breakpoints,
193 and continue. The "remove all other breakpoints" part is required
194 if we are also stepping over another breakpoint as well as doing
195 the longjmp handling. */
196 BPSTAT_WHAT_SET_LONGJMP_RESUME,
197
198 /* Clear longjmp_resume breakpoint, then handle as
199 BPSTAT_WHAT_KEEP_CHECKING. */
200 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
201
202 /* Clear longjmp_resume breakpoint, then handle as BPSTAT_WHAT_SINGLE. */
203 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE,
204
205 /* This is just used to keep track of how many enums there are. */
206 BPSTAT_WHAT_LAST
207 };
208
209 struct bpstat_what {
210 enum bpstat_what_main_action main_action : 4;
211
212 /* Did we hit the step resume breakpoint? This is separate from the
213 main_action to allow for it to be combined with any of the main
214 actions. */
215 unsigned int step_resume : 1;
216
217 /* Did we hit a call dummy breakpoint? This only goes with a main_action
218 of BPSTAT_WHAT_STOP_SILENT or BPSTAT_WHAT_STOP_NOISY (the concept of
219 continuing from a call dummy without popping the frame is not a
220 useful one). */
221 unsigned int call_dummy : 1;
222 };
223
224 /* Tell what to do about this bpstat. */
225 struct bpstat_what bpstat_what PARAMS ((bpstat));
226 \f
227 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
228 bpstat bpstat_find_breakpoint PARAMS ((bpstat, struct breakpoint *));
229
230 /* Nonzero if a signal that we got in wait() was due to circumstances
231 explained by the BS. */
232 /* Currently that is true if we have hit a breakpoint, or if there is
233 a watchpoint enabled. */
234 #define bpstat_explains_signal(bs) ((bs) != NULL)
235
236 /* Nonzero if we should step constantly (e.g. watchpoints on machines
237 without hardware support). This isn't related to a specific bpstat,
238 just to things like whether watchpoints are set. */
239 extern int bpstat_should_step PARAMS ((void));
240
241 /* Print a message indicating what happened. Returns nonzero to
242 say that only the source line should be printed after this (zero
243 return means print the frame as well as the source line). */
244 extern int bpstat_print PARAMS ((bpstat));
245
246 /* Return the breakpoint number of the first breakpoint we are stopped
247 at. *BSP upon return is a bpstat which points to the remaining
248 breakpoints stopped at (but which is not guaranteed to be good for
249 anything but further calls to bpstat_num).
250 Return 0 if passed a bpstat which does not indicate any breakpoints. */
251 extern int bpstat_num PARAMS ((bpstat *));
252
253 /* Perform actions associated with having stopped at *BSP. Actually, we just
254 use this for breakpoint commands. Perhaps other actions will go here
255 later, but this is executed at a late time (from the command loop). */
256 extern void bpstat_do_actions PARAMS ((bpstat *));
257
258 /* Modify BS so that the actions will not be performed. */
259 extern void bpstat_clear_actions PARAMS ((bpstat));
260
261 /* Implementation: */
262 struct bpstat
263 {
264 /* Linked list because there can be two breakpoints at the
265 same place, and a bpstat reflects the fact that both have been hit. */
266 bpstat next;
267 /* Breakpoint that we are at. */
268 struct breakpoint *breakpoint_at;
269 /* Commands left to be done. */
270 struct command_line *commands;
271 /* Old value associated with a watchpoint. */
272 value old_val;
273
274 /* Nonzero if this breakpoint tells us to print the frame. */
275 char print;
276
277 /* Nonzero if this breakpoint tells us to stop. */
278 char stop;
279
280 /* Function called by bpstat_print to print stuff associated with
281 this element of the bpstat chain. Returns 0 or 1 just like
282 bpstat_print, or -1 if it can't deal with it. */
283 int (*print_it) PARAMS((bpstat bs));
284 };
285 \f
286 /* Prototypes for breakpoint-related functions. */
287
288 #ifdef __STDC__ /* Forward declarations for prototypes */
289 struct frame_info;
290 #endif
291
292 extern int
293 breakpoint_here_p PARAMS ((CORE_ADDR));
294
295 extern void
296 until_break_command PARAMS ((char *, int));
297
298 extern void
299 breakpoint_re_set PARAMS ((void));
300
301 extern void
302 clear_momentary_breakpoints PARAMS ((void));
303
304 /* FIXME: Prototype uses equivalence of "struct frame_info *" and FRAME */
305 extern struct breakpoint *
306 set_momentary_breakpoint PARAMS ((struct symtab_and_line,
307 struct frame_info *,
308 enum bptype));
309
310 extern void
311 set_ignore_count PARAMS ((int, int, int));
312
313 extern void
314 set_default_breakpoint PARAMS ((int, CORE_ADDR, struct symtab *, int));
315
316 extern void
317 mark_breakpoints_out PARAMS ((void));
318
319 extern void
320 delete_breakpoint PARAMS ((struct breakpoint *));
321
322 extern void
323 breakpoint_auto_delete PARAMS ((bpstat));
324
325 extern void
326 breakpoint_clear_ignore_counts PARAMS ((void));
327
328 extern void
329 break_command PARAMS ((char *, int));
330
331 extern int
332 insert_breakpoints PARAMS ((void));
333
334 extern int
335 remove_breakpoints PARAMS ((void));
336
337 extern void
338 enable_longjmp_breakpoint PARAMS ((void));
339
340 extern void
341 disable_longjmp_breakpoint PARAMS ((void));
342
343 extern void
344 set_longjmp_resume_breakpoint PARAMS ((CORE_ADDR, FRAME));
345
346 /* The following are for displays, which aren't really breakpoints, but
347 here is as good a place as any for them. */
348
349 extern void
350 disable_current_display PARAMS ((void));
351
352 extern void
353 do_displays PARAMS ((void));
354
355 extern void
356 disable_display PARAMS ((int));
357
358 extern void
359 clear_displays PARAMS ((void));
360
361 #endif /* !defined (BREAKPOINT_H) */
This page took 0.036145 seconds and 3 git commands to generate.