1 /* Copyright (C) 1992 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19 #if !defined (BREAKPOINT_H)
20 #define BREAKPOINT_H 1
25 /* This is the maximum number of bytes a breakpoint instruction can take.
26 Feel free to increase it. It's just used in a few places to size
27 arrays that should be independent of the target architecture. */
29 #define BREAKPOINT_MAX 10
31 typedef struct bpstat__struct *bpstat;
33 #ifdef __STDC__ /* Forward declarations for prototypes */
38 breakpoint_here_p PARAMS ((CORE_ADDR));
41 until_break_command PARAMS ((char *, int));
44 breakpoint_re_set PARAMS ((void));
47 clear_momentary_breakpoints PARAMS ((void));
49 /* FIXME: Prototype uses equivalence of "struct frame_info *" and FRAME */
50 extern struct breakpoint *
51 set_momentary_breakpoint PARAMS ((struct symtab_and_line,
56 set_ignore_count PARAMS ((int, int, int));
59 set_default_breakpoint PARAMS ((int, CORE_ADDR, struct symtab *, int));
62 mark_breakpoints_out PARAMS ((void));
65 delete_breakpoint PARAMS ((struct breakpoint *));
68 breakpoint_auto_delete PARAMS ((bpstat));
71 breakpoint_clear_ignore_counts PARAMS ((void));
74 break_command PARAMS ((char *, int));
77 insert_breakpoints PARAMS ((void));
80 remove_breakpoints PARAMS ((void));
82 /* The following are for displays, which aren't really breakpoints, but
83 here is as good a place as any for them. */
86 disable_current_display PARAMS ((void));
89 do_displays PARAMS ((void));
92 disable_display PARAMS ((int));
95 clear_displays PARAMS ((void));
98 /* The follow stuff is an abstract data type "bpstat" ("breakpoint status").
99 This provides the ability to determine whether we have stopped at a
100 breakpoint, and what we should do about it. */
103 /* Clear a bpstat so that it says we are not at any breakpoint.
104 Also free any storage that is part of a bpstat. */
105 extern void bpstat_clear PARAMS ((bpstat *));
107 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
108 is part of the bpstat is copied as well. */
109 extern bpstat bpstat_copy PARAMS ((bpstat));
111 /* Get a bpstat associated with having just stopped at address *PC
112 and frame address FRAME_ADDRESS. Update *PC to point at the
113 breakpoint (if we hit a breakpoint). */
114 /* FIXME: prototypes uses equivalence between FRAME_ADDR and CORE_ADDR */
115 extern bpstat bpstat_stop_status PARAMS ((CORE_ADDR *, CORE_ADDR));
117 /* Nonzero if we should print the frame. */
118 #define bpstat_should_print(bs) ((bs) != NULL && (bs)->print)
120 /* Nonzero if we should stop. */
121 #define bpstat_stop(bs) ((bs) != NULL && (bs)->stop)
123 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
124 bpstat bpstat_find_breakpoint(/* bpstat, breakpoint */);
126 /* Nonzero if we hit a momentary breakpoint. */
127 #define bpstat_momentary_breakpoint(bs) ((bs) != NULL && (bs)->momentary)
129 /* Nonzero if a signal that we got in wait() was due to circumstances
130 explained by the BS. */
131 /* Currently that is true iff we have hit a breakpoint. */
132 #define bpstat_explains_signal(bs) ((bs) != NULL)
134 /* Nonzero if we should step constantly (e.g. watchpoints on machines
135 without hardware support). This isn't related to a specific bpstat,
136 just to things like whether watchpoints are set. */
137 extern int bpstat_should_step PARAMS ((void));
139 /* Print a message indicating what happened. Returns nonzero to
140 say that only the source line should be printed after this (zero
141 return means print the frame as well as the source line). */
142 extern int bpstat_print PARAMS ((bpstat));
144 /* Return the breakpoint number of the first breakpoint we are stopped
145 at. *BSP upon return is a bpstat which points to the remaining
146 breakpoints stopped at (but which is not guaranteed to be good for
147 anything but further calls to bpstat_num).
148 Return 0 if passed a bpstat which does not indicate any breakpoints. */
149 extern int bpstat_num PARAMS ((bpstat *));
151 /* Perform actions associated with having stopped at *BSP. */
152 extern void bpstat_do_actions PARAMS ((bpstat *));
154 /* Modify BS so that the actions will not be performed. */
155 extern void bpstat_clear_actions PARAMS ((bpstat));
157 /* Implementation: */
158 struct bpstat__struct
160 /* Linked list because there can be two breakpoints at the
161 same place, and a bpstat reflects the fact that both have been hit. */
163 /* Breakpoint that we are at. */
164 struct breakpoint *breakpoint_at;
165 /* Commands left to be done. */
166 struct command_line *commands;
167 /* Old value associated with a watchpoint. */
169 /* Nonzero if we should print the frame. Only significant for the first
170 bpstat in the chain. */
172 /* Nonzero if we should stop. Only significant for the first bpstat in
175 /* Nonzero if we hit a momentary breakpoint. Only significant for the
176 first bpstat in the chain. */
180 /* Type of breakpoint. */
181 /* FIXME In the future, we should fold all other breakpoint-like things into
184 1) single-step (for machines where we have to simulate single stepping),
185 2) step-resume (for 'next'ing over subroutine calls),
186 3) call-dummy (the breakpoint at the end of a subroutine stub that gdb
187 uses to call functions in the target).
191 bp_breakpoint, /* Normal breakpoint */
192 bp_until, /* used by until command */
193 bp_finish, /* used by finish command */
194 bp_watchpoint, /* Watchpoint */
195 bp_longjmp, /* secret breakpoint to find longjmp() */
196 bp_longjmp_resume, /* secret breakpoint to escape longjmp() */
199 /* States of enablement of breakpoint. */
201 enum enable { disabled, enabled};
203 /* Disposition of breakpoint. Ie: what to do after hitting it. */
206 delete, /* Delete it */
207 disable, /* Disable it */
208 donttouch, /* Leave it alone */
211 /* Note that the ->silent field is not currently used by any commands
212 (though the code is in there if it was to be, and set_raw_breakpoint
213 does set it to 0). I implemented it because I thought it would be
214 useful for a hack I had to put in; I'm going to leave it in because
215 I can see how there might be times when it would indeed be useful */
217 /* This is for a breakpoint or a watchpoint. */
221 struct breakpoint *next;
222 /* Type of breakpoint. */
224 /* Zero means disabled; remember the info but don't break here. */
226 /* What to do with this breakpoint after we hit it. */
227 enum bpdisp disposition;
228 /* Number assigned to distinguish breakpoints. */
230 /* Address to break at, or NULL if not a breakpoint. */
232 /* Line number of this address. Redundant. Only matters if address
235 /* Symtab of file of this address. Redundant. Only matters if address
237 struct symtab *symtab;
238 /* Non-zero means a silent breakpoint (don't print frame info
240 unsigned char silent;
241 /* Number of stops at this breakpoint that should
242 be continued automatically before really stopping. */
244 /* "Real" contents of byte where breakpoint has been inserted.
245 Valid only when breakpoints are in the program. Under the complete
246 control of the target insert_breakpoint and remove_breakpoint routines.
247 No other code should assume anything about the value(s) here. */
248 char shadow_contents[BREAKPOINT_MAX];
249 /* Nonzero if this breakpoint is now inserted. Only matters if address
252 /* Nonzero if this is not the first breakpoint in the list
253 for the given address. Only matters if address is non-NULL. */
255 /* Chain of command lines to execute when this breakpoint is hit. */
256 struct command_line *commands;
257 /* Stack depth (address of frame). If nonzero, break only if fp
260 /* Conditional. Break only if this expression's value is nonzero. */
261 struct expression *cond;
263 /* String we used to set the breakpoint (malloc'd). Only matters if
264 address is non-NULL. */
266 /* String form of the breakpoint condition (malloc'd), or NULL if there
270 /* The expression we are watching, or NULL if not a watchpoint. */
271 struct expression *exp;
272 /* The largest block within which it is valid, or NULL if it is
273 valid anywhere (e.g. consists just of global symbols). */
274 struct block *exp_valid_block;
275 /* Value of the watchpoint the last time we checked it. */
279 #endif /* !defined (BREAKPOINT_H) */