* breakpoint.{c,h}: Add exp_string to struct breakpoint and use
[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 /* The follow stuff is an abstract data type "bpstat" ("breakpoint status").
33 This provides the ability to determine whether we have stopped at a
34 breakpoint, and what we should do about it. */
35
36 typedef struct bpstat *bpstat;
37
38 /* Interface: */
39 /* Clear a bpstat so that it says we are not at any breakpoint.
40 Also free any storage that is part of a bpstat. */
41 extern void bpstat_clear PARAMS ((bpstat *));
42
43 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
44 is part of the bpstat is copied as well. */
45 extern bpstat bpstat_copy PARAMS ((bpstat));
46
47 /* Get a bpstat associated with having just stopped at address *PC
48 and frame address FRAME_ADDRESS. Update *PC to point at the
49 breakpoint (if we hit a breakpoint). */
50 /* FIXME: prototypes uses equivalence between FRAME_ADDR and CORE_ADDR */
51 extern bpstat bpstat_stop_status PARAMS ((CORE_ADDR *, CORE_ADDR));
52
53 /* Nonzero if we should print the frame. */
54 #define bpstat_should_print(bs) ((bs) != NULL && (bs)->print)
55
56 /* Nonzero if we should stop. */
57 #define bpstat_stop(bs) ((bs) != NULL && (bs)->stop)
58
59 /* Find the bpstat associated with a breakpoint. NULL otherwise. */
60 bpstat bpstat_find_breakpoint(/* bpstat, breakpoint */);
61
62 /* Nonzero if we hit a momentary breakpoint. */
63 #define bpstat_momentary_breakpoint(bs) ((bs) != NULL && (bs)->momentary)
64
65 /* Nonzero if a signal that we got in wait() was due to circumstances
66 explained by the BS. */
67 /* Currently that is true iff we have hit a breakpoint. */
68 #define bpstat_explains_signal(bs) ((bs) != NULL)
69
70 /* Nonzero if we should step constantly (e.g. watchpoints on machines
71 without hardware support). This isn't related to a specific bpstat,
72 just to things like whether watchpoints are set. */
73 extern int bpstat_should_step PARAMS ((void));
74
75 /* Print a message indicating what happened. Returns nonzero to
76 say that only the source line should be printed after this (zero
77 return means print the frame as well as the source line). */
78 extern int bpstat_print PARAMS ((bpstat));
79
80 /* Return the breakpoint number of the first breakpoint we are stopped
81 at. *BSP upon return is a bpstat which points to the remaining
82 breakpoints stopped at (but which is not guaranteed to be good for
83 anything but further calls to bpstat_num).
84 Return 0 if passed a bpstat which does not indicate any breakpoints. */
85 extern int bpstat_num PARAMS ((bpstat *));
86
87 /* Perform actions associated with having stopped at *BSP. */
88 extern void bpstat_do_actions PARAMS ((bpstat *));
89
90 /* Modify BS so that the actions will not be performed. */
91 extern void bpstat_clear_actions PARAMS ((bpstat));
92
93 /* Implementation: */
94 struct bpstat
95 {
96 /* Linked list because there can be two breakpoints at the
97 same place, and a bpstat reflects the fact that both have been hit. */
98 bpstat next;
99 /* Breakpoint that we are at. */
100 struct breakpoint *breakpoint_at;
101 /* Commands left to be done. */
102 struct command_line *commands;
103 /* Old value associated with a watchpoint. */
104 value old_val;
105 /* Nonzero if we should print the frame. Only significant for the first
106 bpstat in the chain. */
107 char print;
108 /* Nonzero if we should stop. Only significant for the first bpstat in
109 the chain. */
110 char stop;
111 /* Nonzero if we hit a momentary breakpoint. Only significant for the
112 first bpstat in the chain. */
113 char momentary;
114 };
115 \f
116 /* Type of breakpoint. */
117 /* FIXME In the future, we should fold all other breakpoint-like things into
118 here. This includes:
119
120 1) single-step (for machines where we have to simulate single stepping),
121 2) step-resume (for 'next'ing over subroutine calls),
122 3) call-dummy (the breakpoint at the end of a subroutine stub that gdb
123 uses to call functions in the target).
124 */
125
126 enum bptype {
127 bp_breakpoint, /* Normal breakpoint */
128 bp_until, /* used by until command */
129 bp_finish, /* used by finish command */
130 bp_watchpoint, /* Watchpoint */
131 bp_longjmp, /* secret breakpoint to find longjmp() */
132 bp_longjmp_resume /* secret breakpoint to escape longjmp() */
133 };
134
135 /* States of enablement of breakpoint. */
136
137 enum enable { disabled, enabled};
138
139 /* Disposition of breakpoint. Ie: what to do after hitting it. */
140
141 enum bpdisp {
142 delete, /* Delete it */
143 disable, /* Disable it */
144 donttouch /* Leave it alone */
145 };
146
147 /* Note that the ->silent field is not currently used by any commands
148 (though the code is in there if it was to be, and set_raw_breakpoint
149 does set it to 0). I implemented it because I thought it would be
150 useful for a hack I had to put in; I'm going to leave it in because
151 I can see how there might be times when it would indeed be useful */
152
153 /* This is for a breakpoint or a watchpoint. */
154
155 struct breakpoint
156 {
157 struct breakpoint *next;
158 /* Type of breakpoint. */
159 enum bptype type;
160 /* Zero means disabled; remember the info but don't break here. */
161 enum enable enable;
162 /* What to do with this breakpoint after we hit it. */
163 enum bpdisp disposition;
164 /* Number assigned to distinguish breakpoints. */
165 int number;
166 /* Address to break at, or NULL if not a breakpoint. */
167 CORE_ADDR address;
168 /* Line number of this address. Redundant. Only matters if address
169 is non-NULL. */
170 int line_number;
171 /* Symtab of file of this address. Redundant. Only matters if address
172 is non-NULL. */
173 struct symtab *symtab;
174 /* Non-zero means a silent breakpoint (don't print frame info
175 if we stop here). */
176 unsigned char silent;
177 /* Number of stops at this breakpoint that should
178 be continued automatically before really stopping. */
179 int ignore_count;
180 /* "Real" contents of byte where breakpoint has been inserted.
181 Valid only when breakpoints are in the program. Under the complete
182 control of the target insert_breakpoint and remove_breakpoint routines.
183 No other code should assume anything about the value(s) here. */
184 char shadow_contents[BREAKPOINT_MAX];
185 /* Nonzero if this breakpoint is now inserted. Only matters if address
186 is non-NULL. */
187 char inserted;
188 /* Nonzero if this is not the first breakpoint in the list
189 for the given address. Only matters if address is non-NULL. */
190 char duplicate;
191 /* Chain of command lines to execute when this breakpoint is hit. */
192 struct command_line *commands;
193 /* Stack depth (address of frame). If nonzero, break only if fp
194 equals this. */
195 FRAME_ADDR frame;
196 /* Conditional. Break only if this expression's value is nonzero. */
197 struct expression *cond;
198
199 /* String we used to set the breakpoint (malloc'd). Only matters if
200 address is non-NULL. */
201 char *addr_string;
202 /* String form of the breakpoint condition (malloc'd), or NULL if there
203 is no condition. */
204 char *cond_string;
205 /* String form of exp (malloc'd), or NULL if none. */
206 char *exp_string;
207
208 /* The expression we are watching, or NULL if not a watchpoint. */
209 struct expression *exp;
210 /* The largest block within which it is valid, or NULL if it is
211 valid anywhere (e.g. consists just of global symbols). */
212 struct block *exp_valid_block;
213 /* Value of the watchpoint the last time we checked it. */
214 value val;
215 };
216 \f
217 /* Prototypes for breakpoint-related functions. */
218
219 #ifdef __STDC__ /* Forward declarations for prototypes */
220 struct frame_info;
221 #endif
222
223 extern int
224 breakpoint_here_p PARAMS ((CORE_ADDR));
225
226 extern void
227 until_break_command PARAMS ((char *, int));
228
229 extern void
230 breakpoint_re_set PARAMS ((void));
231
232 extern void
233 clear_momentary_breakpoints PARAMS ((void));
234
235 /* FIXME: Prototype uses equivalence of "struct frame_info *" and FRAME */
236 extern struct breakpoint *
237 set_momentary_breakpoint PARAMS ((struct symtab_and_line,
238 struct frame_info *,
239 enum bptype));
240
241 extern void
242 set_ignore_count PARAMS ((int, int, int));
243
244 extern void
245 set_default_breakpoint PARAMS ((int, CORE_ADDR, struct symtab *, int));
246
247 extern void
248 mark_breakpoints_out PARAMS ((void));
249
250 extern void
251 delete_breakpoint PARAMS ((struct breakpoint *));
252
253 extern void
254 breakpoint_auto_delete PARAMS ((bpstat));
255
256 extern void
257 breakpoint_clear_ignore_counts PARAMS ((void));
258
259 extern void
260 break_command PARAMS ((char *, int));
261
262 extern int
263 insert_breakpoints PARAMS ((void));
264
265 extern int
266 remove_breakpoints PARAMS ((void));
267
268 extern void
269 enable_longjmp_breakpoint PARAMS ((void));
270
271 extern void
272 disable_longjmp_breakpoint PARAMS ((void));
273
274 extern void
275 set_longjmp_resume_breakpoint PARAMS ((CORE_ADDR, FRAME));
276
277 /* The following are for displays, which aren't really breakpoints, but
278 here is as good a place as any for them. */
279
280 extern void
281 disable_current_display PARAMS ((void));
282
283 extern void
284 do_displays PARAMS ((void));
285
286 extern void
287 disable_display PARAMS ((int));
288
289 extern void
290 clear_displays PARAMS ((void));
291
292 #endif /* !defined (BREAKPOINT_H) */