Back out change to signals.exp (test_handle_all_print): Add setup_xfail for "alpha...
[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 /* Used by wait_for_inferior for stepping over signal handlers. */
53 bp_through_sigtramp,
54
55 /* The breakpoint at the end of a call dummy. */
56 /* FIXME: What if the function we are calling longjmp()s out of the
57 call, or the user gets out with the "return" command? We currently
58 have no way of cleaning up the breakpoint in these (obscure) situations.
59 (Probably can solve this by noticing longjmp, "return", etc., it's
60 similar to noticing when a watchpoint on a local variable goes out
61 of scope (with hardware support for watchpoints)). */
62 bp_call_dummy
63 };
64
65 /* States of enablement of breakpoint. */
66
67 enum enable { disabled, enabled};
68
69 /* Disposition of breakpoint. Ie: what to do after hitting it. */
70
71 enum bpdisp {
72 delete, /* Delete it */
73 disable, /* Disable it */
74 donttouch /* Leave it alone */
75 };
76
77 /* Note that the ->silent field is not currently used by any commands
78 (though the code is in there if it was to be, and set_raw_breakpoint
79 does set it to 0). I implemented it because I thought it would be
80 useful for a hack I had to put in; I'm going to leave it in because
81 I can see how there might be times when it would indeed be useful */
82
83 /* This is for a breakpoint or a watchpoint. */
84
85 struct breakpoint
86 {
87 struct breakpoint *next;
88 /* Type of breakpoint. */
89 enum bptype type;
90 /* Zero means disabled; remember the info but don't break here. */
91 enum enable enable;
92 /* What to do with this breakpoint after we hit it. */
93 enum bpdisp disposition;
94 /* Number assigned to distinguish breakpoints. */
95 int number;
96
97 /* Address to break at, or NULL if not a breakpoint. */
98 CORE_ADDR address;
99
100 /* Line number of this address. Only matters if address is
101 non-NULL. */
102
103 int line_number;
104
105 /* Source file name of this address. Only matters if address is
106 non-NULL. */
107
108 char *source_file;
109
110 /* Non-zero means a silent breakpoint (don't print frame info
111 if we stop here). */
112 unsigned char silent;
113 /* Number of stops at this breakpoint that should
114 be continued automatically before really stopping. */
115 int ignore_count;
116 /* "Real" contents of byte where breakpoint has been inserted.
117 Valid only when breakpoints are in the program. Under the complete
118 control of the target insert_breakpoint and remove_breakpoint routines.
119 No other code should assume anything about the value(s) here. */
120 char shadow_contents[BREAKPOINT_MAX];
121 /* Nonzero if this breakpoint is now inserted. Only matters if address
122 is non-NULL. */
123 char inserted;
124 /* Nonzero if this is not the first breakpoint in the list
125 for the given address. Only matters if address is non-NULL. */
126 char duplicate;
127 /* Chain of command lines to execute when this breakpoint is hit. */
128 struct command_line *commands;
129 /* Stack depth (address of frame). If nonzero, break only if fp
130 equals this. */
131 FRAME_ADDR frame;
132 /* Conditional. Break only if this expression's value is nonzero. */
133 struct expression *cond;
134
135 /* String we used to set the breakpoint (malloc'd). Only matters if
136 address is non-NULL. */
137 char *addr_string;
138 /* String form of the breakpoint condition (malloc'd), or NULL if there
139 is no condition. */
140 char *cond_string;
141 /* String form of exp (malloc'd), or NULL if none. */
142 char *exp_string;
143
144 /* The expression we are watching, or NULL if not a watchpoint. */
145 struct expression *exp;
146 /* The largest block within which it is valid, or NULL if it is
147 valid anywhere (e.g. consists just of global symbols). */
148 struct block *exp_valid_block;
149 /* Value of the watchpoint the last time we checked it. */
150 value val;
151 /* Thread number for thread-specific breakpoint, or -1 if don't care */
152 int thread;
153 };
154 \f
155 /* The following stuff is an abstract data type "bpstat" ("breakpoint status").
156 This provides the ability to determine whether we have stopped at a
157 breakpoint, and what we should do about it. */
158
159 typedef struct bpstat *bpstat;
160
161 /* Interface: */
162 /* Clear a bpstat so that it says we are not at any breakpoint.
163 Also free any storage that is part of a bpstat. */
164 extern void bpstat_clear PARAMS ((bpstat *));
165
166 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
167 is part of the bpstat is copied as well. */
168 extern bpstat bpstat_copy PARAMS ((bpstat));
169
170 /* FIXME: prototypes uses equivalence between FRAME_ADDR and CORE_ADDR */
171 extern bpstat bpstat_stop_status PARAMS ((CORE_ADDR *, CORE_ADDR, int));
172 \f
173 /* This bpstat_what stuff tells wait_for_inferior what to do with a
174 breakpoint (a challenging task). */
175
176 enum bpstat_what_main_action {
177 /* Perform various other tests; that is, this bpstat does not
178 say to perform any action (e.g. failed watchpoint and nothing
179 else). */
180 BPSTAT_WHAT_KEEP_CHECKING,
181
182 /* Rather than distinguish between noisy and silent stops here, it
183 might be cleaner to have bpstat_print make that decision (also
184 taking into account stop_print_frame and source_only). But the
185 implications are a bit scary (interaction with auto-displays, etc.),
186 so I won't try it. */
187
188 /* Stop silently. */
189 BPSTAT_WHAT_STOP_SILENT,
190
191 /* Stop and print. */
192 BPSTAT_WHAT_STOP_NOISY,
193
194 /* Remove breakpoints, single step once, then put them back in and
195 go back to what we were doing. It's possible that this should be
196 removed from the main_action and put into a separate field, to more
197 cleanly handle BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */
198 BPSTAT_WHAT_SINGLE,
199
200 /* Set longjmp_resume breakpoint, remove all other breakpoints,
201 and continue. The "remove all other breakpoints" part is required
202 if we are also stepping over another breakpoint as well as doing
203 the longjmp handling. */
204 BPSTAT_WHAT_SET_LONGJMP_RESUME,
205
206 /* Clear longjmp_resume breakpoint, then handle as
207 BPSTAT_WHAT_KEEP_CHECKING. */
208 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME,
209
210 /* Clear longjmp_resume breakpoint, then handle as BPSTAT_WHAT_SINGLE. */
211 BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE,
212
213 /* Clear step resume breakpoint, and keep checking. */
214 BPSTAT_WHAT_STEP_RESUME,
215
216 /* Clear through_sigtramp breakpoint, muck with trap_expected, and keep
217 checking. */
218 BPSTAT_WHAT_THROUGH_SIGTRAMP,
219
220 /* This is just used to keep track of how many enums there are. */
221 BPSTAT_WHAT_LAST
222 };
223
224 struct bpstat_what {
225 enum bpstat_what_main_action main_action;
226
227 /* Did we hit a call dummy breakpoint? This only goes with a main_action
228 of BPSTAT_WHAT_STOP_SILENT or BPSTAT_WHAT_STOP_NOISY (the concept of
229 continuing from a call dummy without popping the frame is not a
230 useful one). */
231 int call_dummy;
232 };
233
234 /* Tell what to do about this bpstat. */
235 struct bpstat_what bpstat_what PARAMS ((bpstat));
236 \f
237 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
238 bpstat bpstat_find_breakpoint PARAMS ((bpstat, struct breakpoint *));
239
240 /* Nonzero if a signal that we got in wait() was due to circumstances
241 explained by the BS. */
242 /* Currently that is true if we have hit a breakpoint, or if there is
243 a watchpoint enabled. */
244 #define bpstat_explains_signal(bs) ((bs) != NULL)
245
246 /* Nonzero if we should step constantly (e.g. watchpoints on machines
247 without hardware support). This isn't related to a specific bpstat,
248 just to things like whether watchpoints are set. */
249 extern int bpstat_should_step PARAMS ((void));
250
251 /* Print a message indicating what happened. Returns nonzero to
252 say that only the source line should be printed after this (zero
253 return means print the frame as well as the source line). */
254 extern int bpstat_print PARAMS ((bpstat));
255
256 /* Return the breakpoint number of the first breakpoint we are stopped
257 at. *BSP upon return is a bpstat which points to the remaining
258 breakpoints stopped at (but which is not guaranteed to be good for
259 anything but further calls to bpstat_num).
260 Return 0 if passed a bpstat which does not indicate any breakpoints. */
261 extern int bpstat_num PARAMS ((bpstat *));
262
263 /* Perform actions associated with having stopped at *BSP. Actually, we just
264 use this for breakpoint commands. Perhaps other actions will go here
265 later, but this is executed at a late time (from the command loop). */
266 extern void bpstat_do_actions PARAMS ((bpstat *));
267
268 /* Modify BS so that the actions will not be performed. */
269 extern void bpstat_clear_actions PARAMS ((bpstat));
270
271 /* Implementation: */
272 struct bpstat
273 {
274 /* Linked list because there can be two breakpoints at the
275 same place, and a bpstat reflects the fact that both have been hit. */
276 bpstat next;
277 /* Breakpoint that we are at. */
278 struct breakpoint *breakpoint_at;
279 /* Commands left to be done. */
280 struct command_line *commands;
281 /* Old value associated with a watchpoint. */
282 value old_val;
283
284 /* Nonzero if this breakpoint tells us to print the frame. */
285 char print;
286
287 /* Nonzero if this breakpoint tells us to stop. */
288 char stop;
289
290 /* Function called by bpstat_print to print stuff associated with
291 this element of the bpstat chain. Returns 0 or 1 just like
292 bpstat_print, or -1 if it can't deal with it. */
293 int (*print_it) PARAMS((bpstat bs));
294 };
295 \f
296 /* Prototypes for breakpoint-related functions. */
297
298 #ifdef __STDC__ /* Forward declarations for prototypes */
299 struct frame_info;
300 #endif
301
302 extern int breakpoint_here_p PARAMS ((CORE_ADDR));
303
304 extern int frame_in_dummy PARAMS ((struct frame_info *));
305
306 extern int breakpoint_thread_match PARAMS ((CORE_ADDR, int));
307
308 extern void
309 until_break_command PARAMS ((char *, int));
310
311 extern void
312 breakpoint_re_set PARAMS ((void));
313
314 extern void
315 clear_momentary_breakpoints PARAMS ((void));
316
317 /* FIXME: Prototype uses equivalence of "struct frame_info *" and FRAME */
318 extern struct breakpoint *
319 set_momentary_breakpoint PARAMS ((struct symtab_and_line,
320 struct frame_info *,
321 enum bptype));
322
323 extern void
324 set_ignore_count PARAMS ((int, int, int));
325
326 extern void
327 set_default_breakpoint PARAMS ((int, CORE_ADDR, struct symtab *, int));
328
329 extern void
330 mark_breakpoints_out PARAMS ((void));
331
332 extern void
333 breakpoint_init_inferior PARAMS ((void));
334
335 extern void
336 delete_breakpoint PARAMS ((struct breakpoint *));
337
338 extern void
339 breakpoint_auto_delete PARAMS ((bpstat));
340
341 extern void
342 breakpoint_clear_ignore_counts PARAMS ((void));
343
344 extern void
345 break_command PARAMS ((char *, int));
346
347 extern int
348 insert_breakpoints PARAMS ((void));
349
350 extern int
351 remove_breakpoints PARAMS ((void));
352
353 extern void
354 enable_longjmp_breakpoint PARAMS ((void));
355
356 extern void
357 disable_longjmp_breakpoint PARAMS ((void));
358
359 extern void
360 set_longjmp_resume_breakpoint PARAMS ((CORE_ADDR, FRAME));
361
362 /* The following are for displays, which aren't really breakpoints, but
363 here is as good a place as any for them. */
364
365 extern void
366 disable_current_display PARAMS ((void));
367
368 extern void
369 do_displays PARAMS ((void));
370
371 extern void
372 disable_display PARAMS ((int));
373
374 extern void
375 clear_displays PARAMS ((void));
376
377 #endif /* !defined (BREAKPOINT_H) */
This page took 0.036944 seconds and 4 git commands to generate.