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