1 |
24 |
jeremybenn |
/* Everything about breakpoints, for GDB.
|
2 |
|
|
|
3 |
|
|
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
4 |
|
|
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
5 |
|
|
2008 Free Software Foundation, Inc.
|
6 |
|
|
|
7 |
|
|
This file is part of GDB.
|
8 |
|
|
|
9 |
|
|
This program is free software; you can redistribute it and/or modify
|
10 |
|
|
it under the terms of the GNU General Public License as published by
|
11 |
|
|
the Free Software Foundation; either version 3 of the License, or
|
12 |
|
|
(at your option) any later version.
|
13 |
|
|
|
14 |
|
|
This program is distributed in the hope that it will be useful,
|
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
GNU General Public License for more details.
|
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU General Public License
|
20 |
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
21 |
|
|
|
22 |
|
|
#include "defs.h"
|
23 |
|
|
#include <ctype.h>
|
24 |
|
|
#include "hashtab.h"
|
25 |
|
|
#include "symtab.h"
|
26 |
|
|
#include "frame.h"
|
27 |
|
|
#include "breakpoint.h"
|
28 |
|
|
#include "gdbtypes.h"
|
29 |
|
|
#include "expression.h"
|
30 |
|
|
#include "gdbcore.h"
|
31 |
|
|
#include "gdbcmd.h"
|
32 |
|
|
#include "value.h"
|
33 |
|
|
#include "command.h"
|
34 |
|
|
#include "inferior.h"
|
35 |
|
|
#include "gdbthread.h"
|
36 |
|
|
#include "target.h"
|
37 |
|
|
#include "language.h"
|
38 |
|
|
#include "gdb_string.h"
|
39 |
|
|
#include "demangle.h"
|
40 |
|
|
#include "annotate.h"
|
41 |
|
|
#include "symfile.h"
|
42 |
|
|
#include "objfiles.h"
|
43 |
|
|
#include "source.h"
|
44 |
|
|
#include "linespec.h"
|
45 |
|
|
#include "completer.h"
|
46 |
|
|
#include "gdb.h"
|
47 |
|
|
#include "ui-out.h"
|
48 |
|
|
#include "cli/cli-script.h"
|
49 |
|
|
#include "gdb_assert.h"
|
50 |
|
|
#include "block.h"
|
51 |
|
|
#include "solib.h"
|
52 |
|
|
#include "solist.h"
|
53 |
|
|
#include "observer.h"
|
54 |
|
|
#include "exceptions.h"
|
55 |
|
|
#include "memattr.h"
|
56 |
|
|
#include "ada-lang.h"
|
57 |
|
|
#include "top.h"
|
58 |
|
|
|
59 |
|
|
#include "gdb-events.h"
|
60 |
|
|
#include "mi/mi-common.h"
|
61 |
|
|
|
62 |
|
|
/* Prototypes for local functions. */
|
63 |
|
|
|
64 |
|
|
static void until_break_command_continuation (struct continuation_arg *arg);
|
65 |
|
|
|
66 |
|
|
static void catch_command_1 (char *, int, int);
|
67 |
|
|
|
68 |
|
|
static void enable_delete_command (char *, int);
|
69 |
|
|
|
70 |
|
|
static void enable_delete_breakpoint (struct breakpoint *);
|
71 |
|
|
|
72 |
|
|
static void enable_once_command (char *, int);
|
73 |
|
|
|
74 |
|
|
static void enable_once_breakpoint (struct breakpoint *);
|
75 |
|
|
|
76 |
|
|
static void disable_command (char *, int);
|
77 |
|
|
|
78 |
|
|
static void enable_command (char *, int);
|
79 |
|
|
|
80 |
|
|
static void map_breakpoint_numbers (char *, void (*)(struct breakpoint *));
|
81 |
|
|
|
82 |
|
|
static void ignore_command (char *, int);
|
83 |
|
|
|
84 |
|
|
static int breakpoint_re_set_one (void *);
|
85 |
|
|
|
86 |
|
|
static void clear_command (char *, int);
|
87 |
|
|
|
88 |
|
|
static void catch_command (char *, int);
|
89 |
|
|
|
90 |
|
|
static void watch_command (char *, int);
|
91 |
|
|
|
92 |
|
|
static int can_use_hardware_watchpoint (struct value *);
|
93 |
|
|
|
94 |
|
|
static void break_command_1 (char *, int, int);
|
95 |
|
|
|
96 |
|
|
static void mention (struct breakpoint *);
|
97 |
|
|
|
98 |
|
|
struct breakpoint *set_raw_breakpoint (struct symtab_and_line, enum bptype);
|
99 |
|
|
|
100 |
|
|
static void check_duplicates (struct breakpoint *);
|
101 |
|
|
|
102 |
|
|
static void breakpoint_adjustment_warning (CORE_ADDR, CORE_ADDR, int, int);
|
103 |
|
|
|
104 |
|
|
static CORE_ADDR adjust_breakpoint_address (CORE_ADDR bpaddr,
|
105 |
|
|
enum bptype bptype);
|
106 |
|
|
|
107 |
|
|
static void describe_other_breakpoints (CORE_ADDR, asection *, int);
|
108 |
|
|
|
109 |
|
|
static void breakpoints_info (char *, int);
|
110 |
|
|
|
111 |
|
|
static void breakpoint_1 (int, int);
|
112 |
|
|
|
113 |
|
|
static bpstat bpstat_alloc (const struct bp_location *, bpstat);
|
114 |
|
|
|
115 |
|
|
static int breakpoint_cond_eval (void *);
|
116 |
|
|
|
117 |
|
|
static void cleanup_executing_breakpoints (void *);
|
118 |
|
|
|
119 |
|
|
static void commands_command (char *, int);
|
120 |
|
|
|
121 |
|
|
static void condition_command (char *, int);
|
122 |
|
|
|
123 |
|
|
static int get_number_trailer (char **, int);
|
124 |
|
|
|
125 |
|
|
void set_breakpoint_count (int);
|
126 |
|
|
|
127 |
|
|
typedef enum
|
128 |
|
|
{
|
129 |
|
|
mark_inserted,
|
130 |
|
|
mark_uninserted
|
131 |
|
|
}
|
132 |
|
|
insertion_state_t;
|
133 |
|
|
|
134 |
|
|
static int remove_breakpoint (struct bp_location *, insertion_state_t);
|
135 |
|
|
|
136 |
|
|
static enum print_stop_action print_it_typical (bpstat);
|
137 |
|
|
|
138 |
|
|
static enum print_stop_action print_bp_stop_message (bpstat bs);
|
139 |
|
|
|
140 |
|
|
typedef struct
|
141 |
|
|
{
|
142 |
|
|
enum exception_event_kind kind;
|
143 |
|
|
int enable_p;
|
144 |
|
|
}
|
145 |
|
|
args_for_catchpoint_enable;
|
146 |
|
|
|
147 |
|
|
static int watchpoint_check (void *);
|
148 |
|
|
|
149 |
|
|
static void maintenance_info_breakpoints (char *, int);
|
150 |
|
|
|
151 |
|
|
static void create_longjmp_breakpoint (char *);
|
152 |
|
|
|
153 |
|
|
static void create_overlay_event_breakpoint (char *);
|
154 |
|
|
|
155 |
|
|
static int hw_breakpoint_used_count (void);
|
156 |
|
|
|
157 |
|
|
static int hw_watchpoint_used_count (enum bptype, int *);
|
158 |
|
|
|
159 |
|
|
static void hbreak_command (char *, int);
|
160 |
|
|
|
161 |
|
|
static void thbreak_command (char *, int);
|
162 |
|
|
|
163 |
|
|
static void watch_command_1 (char *, int, int);
|
164 |
|
|
|
165 |
|
|
static void rwatch_command (char *, int);
|
166 |
|
|
|
167 |
|
|
static void awatch_command (char *, int);
|
168 |
|
|
|
169 |
|
|
static void do_enable_breakpoint (struct breakpoint *, enum bpdisp);
|
170 |
|
|
|
171 |
|
|
static void create_fork_vfork_event_catchpoint (int tempflag,
|
172 |
|
|
char *cond_string,
|
173 |
|
|
enum bptype bp_kind);
|
174 |
|
|
|
175 |
|
|
static void stop_command (char *arg, int from_tty);
|
176 |
|
|
|
177 |
|
|
static void stopin_command (char *arg, int from_tty);
|
178 |
|
|
|
179 |
|
|
static void stopat_command (char *arg, int from_tty);
|
180 |
|
|
|
181 |
|
|
static char *ep_find_event_name_end (char *arg);
|
182 |
|
|
|
183 |
|
|
static char *ep_parse_optional_if_clause (char **arg);
|
184 |
|
|
|
185 |
|
|
static char *ep_parse_optional_filename (char **arg);
|
186 |
|
|
|
187 |
|
|
static void create_exception_catchpoint (int tempflag, char *cond_string,
|
188 |
|
|
enum exception_event_kind ex_event,
|
189 |
|
|
struct symtab_and_line *sal);
|
190 |
|
|
|
191 |
|
|
static void catch_exception_command_1 (enum exception_event_kind ex_event,
|
192 |
|
|
char *arg, int tempflag, int from_tty);
|
193 |
|
|
|
194 |
|
|
static void tcatch_command (char *arg, int from_tty);
|
195 |
|
|
|
196 |
|
|
static void ep_skip_leading_whitespace (char **s);
|
197 |
|
|
|
198 |
|
|
static int single_step_breakpoint_inserted_here_p (CORE_ADDR pc);
|
199 |
|
|
|
200 |
|
|
static void free_bp_location (struct bp_location *loc);
|
201 |
|
|
|
202 |
|
|
static void mark_breakpoints_out (void);
|
203 |
|
|
|
204 |
|
|
static struct bp_location *
|
205 |
|
|
allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type);
|
206 |
|
|
|
207 |
|
|
static void
|
208 |
|
|
unlink_locations_from_global_list (struct breakpoint *bpt);
|
209 |
|
|
|
210 |
|
|
static int
|
211 |
|
|
is_hardware_watchpoint (struct breakpoint *bpt);
|
212 |
|
|
|
213 |
|
|
/* Prototypes for exported functions. */
|
214 |
|
|
|
215 |
|
|
/* If FALSE, gdb will not use hardware support for watchpoints, even
|
216 |
|
|
if such is available. */
|
217 |
|
|
static int can_use_hw_watchpoints;
|
218 |
|
|
|
219 |
|
|
static void
|
220 |
|
|
show_can_use_hw_watchpoints (struct ui_file *file, int from_tty,
|
221 |
|
|
struct cmd_list_element *c,
|
222 |
|
|
const char *value)
|
223 |
|
|
{
|
224 |
|
|
fprintf_filtered (file, _("\
|
225 |
|
|
Debugger's willingness to use watchpoint hardware is %s.\n"),
|
226 |
|
|
value);
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
/* If AUTO_BOOLEAN_FALSE, gdb will not attempt to create pending breakpoints.
|
230 |
|
|
If AUTO_BOOLEAN_TRUE, gdb will automatically create pending breakpoints
|
231 |
|
|
for unrecognized breakpoint locations.
|
232 |
|
|
If AUTO_BOOLEAN_AUTO, gdb will query when breakpoints are unrecognized. */
|
233 |
|
|
static enum auto_boolean pending_break_support;
|
234 |
|
|
static void
|
235 |
|
|
show_pending_break_support (struct ui_file *file, int from_tty,
|
236 |
|
|
struct cmd_list_element *c,
|
237 |
|
|
const char *value)
|
238 |
|
|
{
|
239 |
|
|
fprintf_filtered (file, _("\
|
240 |
|
|
Debugger's behavior regarding pending breakpoints is %s.\n"),
|
241 |
|
|
value);
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
/* If 1, gdb will automatically use hardware breakpoints for breakpoints
|
245 |
|
|
set with "break" but falling in read-only memory.
|
246 |
|
|
If 0, gdb will warn about such breakpoints, but won't automatically
|
247 |
|
|
use hardware breakpoints. */
|
248 |
|
|
static int automatic_hardware_breakpoints;
|
249 |
|
|
static void
|
250 |
|
|
show_automatic_hardware_breakpoints (struct ui_file *file, int from_tty,
|
251 |
|
|
struct cmd_list_element *c,
|
252 |
|
|
const char *value)
|
253 |
|
|
{
|
254 |
|
|
fprintf_filtered (file, _("\
|
255 |
|
|
Automatic usage of hardware breakpoints is %s.\n"),
|
256 |
|
|
value);
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
void _initialize_breakpoint (void);
|
261 |
|
|
|
262 |
|
|
extern int addressprint; /* Print machine addresses? */
|
263 |
|
|
|
264 |
|
|
/* Are we executing breakpoint commands? */
|
265 |
|
|
static int executing_breakpoint_commands;
|
266 |
|
|
|
267 |
|
|
/* Are overlay event breakpoints enabled? */
|
268 |
|
|
static int overlay_events_enabled;
|
269 |
|
|
|
270 |
|
|
/* Walk the following statement or block through all breakpoints.
|
271 |
|
|
ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
|
272 |
|
|
breakpoint. */
|
273 |
|
|
|
274 |
|
|
#define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
|
275 |
|
|
|
276 |
|
|
#define ALL_BREAKPOINTS_SAFE(B,TMP) \
|
277 |
|
|
for (B = breakpoint_chain; \
|
278 |
|
|
B ? (TMP=B->next, 1): 0; \
|
279 |
|
|
B = TMP)
|
280 |
|
|
|
281 |
|
|
/* Similar iterators for the low-level breakpoints. */
|
282 |
|
|
|
283 |
|
|
#define ALL_BP_LOCATIONS(B) for (B = bp_location_chain; B; B = B->global_next)
|
284 |
|
|
|
285 |
|
|
#define ALL_BP_LOCATIONS_SAFE(B,TMP) \
|
286 |
|
|
for (B = bp_location_chain; \
|
287 |
|
|
B ? (TMP=B->global_next, 1): 0; \
|
288 |
|
|
B = TMP)
|
289 |
|
|
|
290 |
|
|
/* True if breakpoint hit counts should be displayed in breakpoint info. */
|
291 |
|
|
|
292 |
|
|
int show_breakpoint_hit_counts = 1;
|
293 |
|
|
|
294 |
|
|
/* Chains of all breakpoints defined. */
|
295 |
|
|
|
296 |
|
|
struct breakpoint *breakpoint_chain;
|
297 |
|
|
|
298 |
|
|
struct bp_location *bp_location_chain;
|
299 |
|
|
|
300 |
|
|
/* Number of last breakpoint made. */
|
301 |
|
|
|
302 |
|
|
int breakpoint_count;
|
303 |
|
|
|
304 |
|
|
/* Pointer to current exception event record */
|
305 |
|
|
static struct exception_event_record *current_exception_event;
|
306 |
|
|
|
307 |
|
|
/* This function returns a pointer to the string representation of the
|
308 |
|
|
pathname of the dynamically-linked library that has just been
|
309 |
|
|
loaded.
|
310 |
|
|
|
311 |
|
|
This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
|
312 |
|
|
or undefined results are guaranteed.
|
313 |
|
|
|
314 |
|
|
This string's contents are only valid immediately after the
|
315 |
|
|
inferior has stopped in the dynamic linker hook, and becomes
|
316 |
|
|
invalid as soon as the inferior is continued. Clients should make
|
317 |
|
|
a copy of this string if they wish to continue the inferior and
|
318 |
|
|
then access the string. */
|
319 |
|
|
|
320 |
|
|
#ifndef SOLIB_LOADED_LIBRARY_PATHNAME
|
321 |
|
|
#define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
|
322 |
|
|
#endif
|
323 |
|
|
|
324 |
|
|
/* This function returns a pointer to the string representation of the
|
325 |
|
|
pathname of the dynamically-linked library that has just been
|
326 |
|
|
unloaded.
|
327 |
|
|
|
328 |
|
|
This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
|
329 |
|
|
TRUE, or undefined results are guaranteed.
|
330 |
|
|
|
331 |
|
|
This string's contents are only valid immediately after the
|
332 |
|
|
inferior has stopped in the dynamic linker hook, and becomes
|
333 |
|
|
invalid as soon as the inferior is continued. Clients should make
|
334 |
|
|
a copy of this string if they wish to continue the inferior and
|
335 |
|
|
then access the string. */
|
336 |
|
|
|
337 |
|
|
#ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
|
338 |
|
|
#define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
|
339 |
|
|
#endif
|
340 |
|
|
|
341 |
|
|
/* This function is called by the "catch load" command. It allows the
|
342 |
|
|
debugger to be notified by the dynamic linker when a specified
|
343 |
|
|
library file (or any library file, if filename is NULL) is loaded. */
|
344 |
|
|
|
345 |
|
|
#ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
|
346 |
|
|
#define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
|
347 |
|
|
error (_("catch of library loads not yet implemented on this platform"))
|
348 |
|
|
#endif
|
349 |
|
|
|
350 |
|
|
/* This function is called by the "catch unload" command. It allows
|
351 |
|
|
the debugger to be notified by the dynamic linker when a specified
|
352 |
|
|
library file (or any library file, if filename is NULL) is
|
353 |
|
|
unloaded. */
|
354 |
|
|
|
355 |
|
|
#ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
|
356 |
|
|
#define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid, tempflag, filename, cond_string) \
|
357 |
|
|
error (_("catch of library unloads not yet implemented on this platform"))
|
358 |
|
|
#endif
|
359 |
|
|
|
360 |
|
|
/* Return whether a breakpoint is an active enabled breakpoint. */
|
361 |
|
|
static int
|
362 |
|
|
breakpoint_enabled (struct breakpoint *b)
|
363 |
|
|
{
|
364 |
|
|
return (b->enable_state == bp_enabled);
|
365 |
|
|
}
|
366 |
|
|
|
367 |
|
|
/* Set breakpoint count to NUM. */
|
368 |
|
|
|
369 |
|
|
void
|
370 |
|
|
set_breakpoint_count (int num)
|
371 |
|
|
{
|
372 |
|
|
breakpoint_count = num;
|
373 |
|
|
set_internalvar (lookup_internalvar ("bpnum"),
|
374 |
|
|
value_from_longest (builtin_type_int, (LONGEST) num));
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
/* Used in run_command to zero the hit count when a new run starts. */
|
378 |
|
|
|
379 |
|
|
void
|
380 |
|
|
clear_breakpoint_hit_counts (void)
|
381 |
|
|
{
|
382 |
|
|
struct breakpoint *b;
|
383 |
|
|
|
384 |
|
|
ALL_BREAKPOINTS (b)
|
385 |
|
|
b->hit_count = 0;
|
386 |
|
|
}
|
387 |
|
|
|
388 |
|
|
/* Default address, symtab and line to put a breakpoint at
|
389 |
|
|
for "break" command with no arg.
|
390 |
|
|
if default_breakpoint_valid is zero, the other three are
|
391 |
|
|
not valid, and "break" with no arg is an error.
|
392 |
|
|
|
393 |
|
|
This set by print_stack_frame, which calls set_default_breakpoint. */
|
394 |
|
|
|
395 |
|
|
int default_breakpoint_valid;
|
396 |
|
|
CORE_ADDR default_breakpoint_address;
|
397 |
|
|
struct symtab *default_breakpoint_symtab;
|
398 |
|
|
int default_breakpoint_line;
|
399 |
|
|
|
400 |
|
|
/* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
|
401 |
|
|
Advance *PP after the string and any trailing whitespace.
|
402 |
|
|
|
403 |
|
|
Currently the string can either be a number or "$" followed by the name
|
404 |
|
|
of a convenience variable. Making it an expression wouldn't work well
|
405 |
|
|
for map_breakpoint_numbers (e.g. "4 + 5 + 6").
|
406 |
|
|
|
407 |
|
|
If the string is a NULL pointer, that denotes the last breakpoint.
|
408 |
|
|
|
409 |
|
|
TRAILER is a character which can be found after the number; most
|
410 |
|
|
commonly this is `-'. If you don't want a trailer, use \0. */
|
411 |
|
|
static int
|
412 |
|
|
get_number_trailer (char **pp, int trailer)
|
413 |
|
|
{
|
414 |
|
|
int retval = 0; /* default */
|
415 |
|
|
char *p = *pp;
|
416 |
|
|
|
417 |
|
|
if (p == NULL)
|
418 |
|
|
/* Empty line means refer to the last breakpoint. */
|
419 |
|
|
return breakpoint_count;
|
420 |
|
|
else if (*p == '$')
|
421 |
|
|
{
|
422 |
|
|
/* Make a copy of the name, so we can null-terminate it
|
423 |
|
|
to pass to lookup_internalvar(). */
|
424 |
|
|
char *varname;
|
425 |
|
|
char *start = ++p;
|
426 |
|
|
struct value *val;
|
427 |
|
|
|
428 |
|
|
while (isalnum (*p) || *p == '_')
|
429 |
|
|
p++;
|
430 |
|
|
varname = (char *) alloca (p - start + 1);
|
431 |
|
|
strncpy (varname, start, p - start);
|
432 |
|
|
varname[p - start] = '\0';
|
433 |
|
|
val = value_of_internalvar (lookup_internalvar (varname));
|
434 |
|
|
if (TYPE_CODE (value_type (val)) == TYPE_CODE_INT)
|
435 |
|
|
retval = (int) value_as_long (val);
|
436 |
|
|
else
|
437 |
|
|
{
|
438 |
|
|
printf_filtered (_("Convenience variable must have integer value.\n"));
|
439 |
|
|
retval = 0;
|
440 |
|
|
}
|
441 |
|
|
}
|
442 |
|
|
else
|
443 |
|
|
{
|
444 |
|
|
if (*p == '-')
|
445 |
|
|
++p;
|
446 |
|
|
while (*p >= '0' && *p <= '9')
|
447 |
|
|
++p;
|
448 |
|
|
if (p == *pp)
|
449 |
|
|
/* There is no number here. (e.g. "cond a == b"). */
|
450 |
|
|
{
|
451 |
|
|
/* Skip non-numeric token */
|
452 |
|
|
while (*p && !isspace((int) *p))
|
453 |
|
|
++p;
|
454 |
|
|
/* Return zero, which caller must interpret as error. */
|
455 |
|
|
retval = 0;
|
456 |
|
|
}
|
457 |
|
|
else
|
458 |
|
|
retval = atoi (*pp);
|
459 |
|
|
}
|
460 |
|
|
if (!(isspace (*p) || *p == '\0' || *p == trailer))
|
461 |
|
|
{
|
462 |
|
|
/* Trailing junk: return 0 and let caller print error msg. */
|
463 |
|
|
while (!(isspace (*p) || *p == '\0' || *p == trailer))
|
464 |
|
|
++p;
|
465 |
|
|
retval = 0;
|
466 |
|
|
}
|
467 |
|
|
while (isspace (*p))
|
468 |
|
|
p++;
|
469 |
|
|
*pp = p;
|
470 |
|
|
return retval;
|
471 |
|
|
}
|
472 |
|
|
|
473 |
|
|
|
474 |
|
|
/* Like get_number_trailer, but don't allow a trailer. */
|
475 |
|
|
int
|
476 |
|
|
get_number (char **pp)
|
477 |
|
|
{
|
478 |
|
|
return get_number_trailer (pp, '\0');
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
/* Parse a number or a range.
|
482 |
|
|
* A number will be of the form handled by get_number.
|
483 |
|
|
* A range will be of the form <number1> - <number2>, and
|
484 |
|
|
* will represent all the integers between number1 and number2,
|
485 |
|
|
* inclusive.
|
486 |
|
|
*
|
487 |
|
|
* While processing a range, this fuction is called iteratively;
|
488 |
|
|
* At each call it will return the next value in the range.
|
489 |
|
|
*
|
490 |
|
|
* At the beginning of parsing a range, the char pointer PP will
|
491 |
|
|
* be advanced past <number1> and left pointing at the '-' token.
|
492 |
|
|
* Subsequent calls will not advance the pointer until the range
|
493 |
|
|
* is completed. The call that completes the range will advance
|
494 |
|
|
* pointer PP past <number2>.
|
495 |
|
|
*/
|
496 |
|
|
|
497 |
|
|
int
|
498 |
|
|
get_number_or_range (char **pp)
|
499 |
|
|
{
|
500 |
|
|
static int last_retval, end_value;
|
501 |
|
|
static char *end_ptr;
|
502 |
|
|
static int in_range = 0;
|
503 |
|
|
|
504 |
|
|
if (**pp != '-')
|
505 |
|
|
{
|
506 |
|
|
/* Default case: pp is pointing either to a solo number,
|
507 |
|
|
or to the first number of a range. */
|
508 |
|
|
last_retval = get_number_trailer (pp, '-');
|
509 |
|
|
if (**pp == '-')
|
510 |
|
|
{
|
511 |
|
|
char **temp;
|
512 |
|
|
|
513 |
|
|
/* This is the start of a range (<number1> - <number2>).
|
514 |
|
|
Skip the '-', parse and remember the second number,
|
515 |
|
|
and also remember the end of the final token. */
|
516 |
|
|
|
517 |
|
|
temp = &end_ptr;
|
518 |
|
|
end_ptr = *pp + 1;
|
519 |
|
|
while (isspace ((int) *end_ptr))
|
520 |
|
|
end_ptr++; /* skip white space */
|
521 |
|
|
end_value = get_number (temp);
|
522 |
|
|
if (end_value < last_retval)
|
523 |
|
|
{
|
524 |
|
|
error (_("inverted range"));
|
525 |
|
|
}
|
526 |
|
|
else if (end_value == last_retval)
|
527 |
|
|
{
|
528 |
|
|
/* degenerate range (number1 == number2). Advance the
|
529 |
|
|
token pointer so that the range will be treated as a
|
530 |
|
|
single number. */
|
531 |
|
|
*pp = end_ptr;
|
532 |
|
|
}
|
533 |
|
|
else
|
534 |
|
|
in_range = 1;
|
535 |
|
|
}
|
536 |
|
|
}
|
537 |
|
|
else if (! in_range)
|
538 |
|
|
error (_("negative value"));
|
539 |
|
|
else
|
540 |
|
|
{
|
541 |
|
|
/* pp points to the '-' that betokens a range. All
|
542 |
|
|
number-parsing has already been done. Return the next
|
543 |
|
|
integer value (one greater than the saved previous value).
|
544 |
|
|
Do not advance the token pointer 'pp' until the end of range
|
545 |
|
|
is reached. */
|
546 |
|
|
|
547 |
|
|
if (++last_retval == end_value)
|
548 |
|
|
{
|
549 |
|
|
/* End of range reached; advance token pointer. */
|
550 |
|
|
*pp = end_ptr;
|
551 |
|
|
in_range = 0;
|
552 |
|
|
}
|
553 |
|
|
}
|
554 |
|
|
return last_retval;
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
/* condition N EXP -- set break condition of breakpoint N to EXP. */
|
560 |
|
|
|
561 |
|
|
static void
|
562 |
|
|
condition_command (char *arg, int from_tty)
|
563 |
|
|
{
|
564 |
|
|
struct breakpoint *b;
|
565 |
|
|
char *p;
|
566 |
|
|
int bnum;
|
567 |
|
|
|
568 |
|
|
if (arg == 0)
|
569 |
|
|
error_no_arg (_("breakpoint number"));
|
570 |
|
|
|
571 |
|
|
p = arg;
|
572 |
|
|
bnum = get_number (&p);
|
573 |
|
|
if (bnum == 0)
|
574 |
|
|
error (_("Bad breakpoint argument: '%s'"), arg);
|
575 |
|
|
|
576 |
|
|
ALL_BREAKPOINTS (b)
|
577 |
|
|
if (b->number == bnum)
|
578 |
|
|
{
|
579 |
|
|
struct bp_location *loc = b->loc;
|
580 |
|
|
for (; loc; loc = loc->next)
|
581 |
|
|
{
|
582 |
|
|
if (loc->cond)
|
583 |
|
|
{
|
584 |
|
|
xfree (loc->cond);
|
585 |
|
|
loc->cond = 0;
|
586 |
|
|
}
|
587 |
|
|
}
|
588 |
|
|
if (b->cond_string != NULL)
|
589 |
|
|
xfree (b->cond_string);
|
590 |
|
|
|
591 |
|
|
if (*p == 0)
|
592 |
|
|
{
|
593 |
|
|
b->cond_string = NULL;
|
594 |
|
|
if (from_tty)
|
595 |
|
|
printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum);
|
596 |
|
|
}
|
597 |
|
|
else
|
598 |
|
|
{
|
599 |
|
|
arg = p;
|
600 |
|
|
/* I don't know if it matters whether this is the string the user
|
601 |
|
|
typed in or the decompiled expression. */
|
602 |
|
|
b->cond_string = savestring (arg, strlen (arg));
|
603 |
|
|
b->condition_not_parsed = 0;
|
604 |
|
|
for (loc = b->loc; loc; loc = loc->next)
|
605 |
|
|
{
|
606 |
|
|
arg = p;
|
607 |
|
|
loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0);
|
608 |
|
|
if (*arg)
|
609 |
|
|
error (_("Junk at end of expression"));
|
610 |
|
|
}
|
611 |
|
|
}
|
612 |
|
|
breakpoints_changed ();
|
613 |
|
|
breakpoint_modify_event (b->number);
|
614 |
|
|
return;
|
615 |
|
|
}
|
616 |
|
|
|
617 |
|
|
error (_("No breakpoint number %d."), bnum);
|
618 |
|
|
}
|
619 |
|
|
|
620 |
|
|
static void
|
621 |
|
|
commands_command (char *arg, int from_tty)
|
622 |
|
|
{
|
623 |
|
|
struct breakpoint *b;
|
624 |
|
|
char *p;
|
625 |
|
|
int bnum;
|
626 |
|
|
struct command_line *l;
|
627 |
|
|
|
628 |
|
|
/* If we allowed this, we would have problems with when to
|
629 |
|
|
free the storage, if we change the commands currently
|
630 |
|
|
being read from. */
|
631 |
|
|
|
632 |
|
|
if (executing_breakpoint_commands)
|
633 |
|
|
error (_("Can't use the \"commands\" command among a breakpoint's commands."));
|
634 |
|
|
|
635 |
|
|
p = arg;
|
636 |
|
|
bnum = get_number (&p);
|
637 |
|
|
|
638 |
|
|
if (p && *p)
|
639 |
|
|
error (_("Unexpected extra arguments following breakpoint number."));
|
640 |
|
|
|
641 |
|
|
ALL_BREAKPOINTS (b)
|
642 |
|
|
if (b->number == bnum)
|
643 |
|
|
{
|
644 |
|
|
char *tmpbuf = xstrprintf ("Type commands for when breakpoint %d is hit, one per line.",
|
645 |
|
|
bnum);
|
646 |
|
|
struct cleanup *cleanups = make_cleanup (xfree, tmpbuf);
|
647 |
|
|
l = read_command_lines (tmpbuf, from_tty);
|
648 |
|
|
do_cleanups (cleanups);
|
649 |
|
|
free_command_lines (&b->commands);
|
650 |
|
|
b->commands = l;
|
651 |
|
|
breakpoints_changed ();
|
652 |
|
|
breakpoint_modify_event (b->number);
|
653 |
|
|
return;
|
654 |
|
|
}
|
655 |
|
|
error (_("No breakpoint number %d."), bnum);
|
656 |
|
|
}
|
657 |
|
|
|
658 |
|
|
/* Like commands_command, but instead of reading the commands from
|
659 |
|
|
input stream, takes them from an already parsed command structure.
|
660 |
|
|
|
661 |
|
|
This is used by cli-script.c to DTRT with breakpoint commands
|
662 |
|
|
that are part of if and while bodies. */
|
663 |
|
|
enum command_control_type
|
664 |
|
|
commands_from_control_command (char *arg, struct command_line *cmd)
|
665 |
|
|
{
|
666 |
|
|
struct breakpoint *b;
|
667 |
|
|
char *p;
|
668 |
|
|
int bnum;
|
669 |
|
|
|
670 |
|
|
/* If we allowed this, we would have problems with when to
|
671 |
|
|
free the storage, if we change the commands currently
|
672 |
|
|
being read from. */
|
673 |
|
|
|
674 |
|
|
if (executing_breakpoint_commands)
|
675 |
|
|
error (_("Can't use the \"commands\" command among a breakpoint's commands."));
|
676 |
|
|
|
677 |
|
|
/* An empty string for the breakpoint number means the last
|
678 |
|
|
breakpoint, but get_number expects a NULL pointer. */
|
679 |
|
|
if (arg && !*arg)
|
680 |
|
|
p = NULL;
|
681 |
|
|
else
|
682 |
|
|
p = arg;
|
683 |
|
|
bnum = get_number (&p);
|
684 |
|
|
|
685 |
|
|
if (p && *p)
|
686 |
|
|
error (_("Unexpected extra arguments following breakpoint number."));
|
687 |
|
|
|
688 |
|
|
ALL_BREAKPOINTS (b)
|
689 |
|
|
if (b->number == bnum)
|
690 |
|
|
{
|
691 |
|
|
free_command_lines (&b->commands);
|
692 |
|
|
if (cmd->body_count != 1)
|
693 |
|
|
error (_("Invalid \"commands\" block structure."));
|
694 |
|
|
/* We need to copy the commands because if/while will free the
|
695 |
|
|
list after it finishes execution. */
|
696 |
|
|
b->commands = copy_command_lines (cmd->body_list[0]);
|
697 |
|
|
breakpoints_changed ();
|
698 |
|
|
breakpoint_modify_event (b->number);
|
699 |
|
|
return simple_control;
|
700 |
|
|
}
|
701 |
|
|
error (_("No breakpoint number %d."), bnum);
|
702 |
|
|
}
|
703 |
|
|
|
704 |
|
|
/* Like target_read_memory() but if breakpoints are inserted, return
|
705 |
|
|
the shadow contents instead of the breakpoints themselves.
|
706 |
|
|
|
707 |
|
|
Read "memory data" from whatever target or inferior we have.
|
708 |
|
|
Returns zero if successful, errno value if not. EIO is used
|
709 |
|
|
for address out of bounds. If breakpoints are inserted, returns
|
710 |
|
|
shadow contents, not the breakpoints themselves. From breakpoint.c. */
|
711 |
|
|
|
712 |
|
|
int
|
713 |
|
|
read_memory_nobpt (CORE_ADDR memaddr, gdb_byte *myaddr, unsigned len)
|
714 |
|
|
{
|
715 |
|
|
int status;
|
716 |
|
|
const struct bp_location *b;
|
717 |
|
|
CORE_ADDR bp_addr = 0;
|
718 |
|
|
int bp_size = 0;
|
719 |
|
|
|
720 |
|
|
if (gdbarch_breakpoint_from_pc (current_gdbarch, &bp_addr, &bp_size) == NULL)
|
721 |
|
|
/* No breakpoints on this machine. */
|
722 |
|
|
return target_read_memory (memaddr, myaddr, len);
|
723 |
|
|
|
724 |
|
|
ALL_BP_LOCATIONS (b)
|
725 |
|
|
{
|
726 |
|
|
if (b->owner->type == bp_none)
|
727 |
|
|
warning (_("reading through apparently deleted breakpoint #%d?"),
|
728 |
|
|
b->owner->number);
|
729 |
|
|
|
730 |
|
|
if (b->loc_type != bp_loc_software_breakpoint)
|
731 |
|
|
continue;
|
732 |
|
|
if (!b->inserted)
|
733 |
|
|
continue;
|
734 |
|
|
/* Addresses and length of the part of the breakpoint that
|
735 |
|
|
we need to copy. */
|
736 |
|
|
bp_addr = b->target_info.placed_address;
|
737 |
|
|
bp_size = b->target_info.shadow_len;
|
738 |
|
|
if (bp_size == 0)
|
739 |
|
|
/* bp isn't valid, or doesn't shadow memory. */
|
740 |
|
|
continue;
|
741 |
|
|
if (bp_addr + bp_size <= memaddr)
|
742 |
|
|
/* The breakpoint is entirely before the chunk of memory we
|
743 |
|
|
are reading. */
|
744 |
|
|
continue;
|
745 |
|
|
if (bp_addr >= memaddr + len)
|
746 |
|
|
/* The breakpoint is entirely after the chunk of memory we are
|
747 |
|
|
reading. */
|
748 |
|
|
continue;
|
749 |
|
|
/* Copy the breakpoint from the shadow contents, and recurse for
|
750 |
|
|
the things before and after. */
|
751 |
|
|
{
|
752 |
|
|
/* Offset within shadow_contents. */
|
753 |
|
|
int bptoffset = 0;
|
754 |
|
|
|
755 |
|
|
if (bp_addr < memaddr)
|
756 |
|
|
{
|
757 |
|
|
/* Only copy the second part of the breakpoint. */
|
758 |
|
|
bp_size -= memaddr - bp_addr;
|
759 |
|
|
bptoffset = memaddr - bp_addr;
|
760 |
|
|
bp_addr = memaddr;
|
761 |
|
|
}
|
762 |
|
|
|
763 |
|
|
if (bp_addr + bp_size > memaddr + len)
|
764 |
|
|
{
|
765 |
|
|
/* Only copy the first part of the breakpoint. */
|
766 |
|
|
bp_size -= (bp_addr + bp_size) - (memaddr + len);
|
767 |
|
|
}
|
768 |
|
|
|
769 |
|
|
memcpy (myaddr + bp_addr - memaddr,
|
770 |
|
|
b->target_info.shadow_contents + bptoffset, bp_size);
|
771 |
|
|
|
772 |
|
|
if (bp_addr > memaddr)
|
773 |
|
|
{
|
774 |
|
|
/* Copy the section of memory before the breakpoint. */
|
775 |
|
|
status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr);
|
776 |
|
|
if (status != 0)
|
777 |
|
|
return status;
|
778 |
|
|
}
|
779 |
|
|
|
780 |
|
|
if (bp_addr + bp_size < memaddr + len)
|
781 |
|
|
{
|
782 |
|
|
/* Copy the section of memory after the breakpoint. */
|
783 |
|
|
status = read_memory_nobpt (bp_addr + bp_size,
|
784 |
|
|
myaddr + bp_addr + bp_size - memaddr,
|
785 |
|
|
memaddr + len - (bp_addr + bp_size));
|
786 |
|
|
if (status != 0)
|
787 |
|
|
return status;
|
788 |
|
|
}
|
789 |
|
|
return 0;
|
790 |
|
|
}
|
791 |
|
|
}
|
792 |
|
|
/* Nothing overlaps. Just call read_memory_noerr. */
|
793 |
|
|
return target_read_memory (memaddr, myaddr, len);
|
794 |
|
|
}
|
795 |
|
|
|
796 |
|
|
|
797 |
|
|
/* A wrapper function for inserting catchpoints. */
|
798 |
|
|
static void
|
799 |
|
|
insert_catchpoint (struct ui_out *uo, void *args)
|
800 |
|
|
{
|
801 |
|
|
struct breakpoint *b = (struct breakpoint *) args;
|
802 |
|
|
int val = -1;
|
803 |
|
|
|
804 |
|
|
switch (b->type)
|
805 |
|
|
{
|
806 |
|
|
case bp_catch_fork:
|
807 |
|
|
target_insert_fork_catchpoint (PIDGET (inferior_ptid));
|
808 |
|
|
break;
|
809 |
|
|
case bp_catch_vfork:
|
810 |
|
|
target_insert_vfork_catchpoint (PIDGET (inferior_ptid));
|
811 |
|
|
break;
|
812 |
|
|
case bp_catch_exec:
|
813 |
|
|
target_insert_exec_catchpoint (PIDGET (inferior_ptid));
|
814 |
|
|
break;
|
815 |
|
|
default:
|
816 |
|
|
internal_error (__FILE__, __LINE__, _("unknown breakpoint type"));
|
817 |
|
|
break;
|
818 |
|
|
}
|
819 |
|
|
}
|
820 |
|
|
|
821 |
|
|
static int
|
822 |
|
|
is_hardware_watchpoint (struct breakpoint *bpt)
|
823 |
|
|
{
|
824 |
|
|
return (bpt->type == bp_hardware_watchpoint
|
825 |
|
|
|| bpt->type == bp_read_watchpoint
|
826 |
|
|
|| bpt->type == bp_access_watchpoint);
|
827 |
|
|
}
|
828 |
|
|
|
829 |
|
|
/* Assuming that B is a hardware breakpoint:
|
830 |
|
|
- Reparse watchpoint expression, is REPARSE is non-zero
|
831 |
|
|
- Evaluate expression and store the result in B->val
|
832 |
|
|
- Update the list of values that must be watched in B->loc.
|
833 |
|
|
|
834 |
|
|
If the watchpoint is disabled, do nothing. If this is
|
835 |
|
|
local watchpoint that is out of scope, delete it. */
|
836 |
|
|
static void
|
837 |
|
|
update_watchpoint (struct breakpoint *b, int reparse)
|
838 |
|
|
{
|
839 |
|
|
int within_current_scope;
|
840 |
|
|
struct value *mark = value_mark ();
|
841 |
|
|
struct frame_id saved_frame_id;
|
842 |
|
|
struct bp_location *loc;
|
843 |
|
|
bpstat bs;
|
844 |
|
|
|
845 |
|
|
unlink_locations_from_global_list (b);
|
846 |
|
|
for (loc = b->loc; loc;)
|
847 |
|
|
{
|
848 |
|
|
struct bp_location *loc_next = loc->next;
|
849 |
|
|
remove_breakpoint (loc, mark_uninserted);
|
850 |
|
|
xfree (loc);
|
851 |
|
|
loc = loc_next;
|
852 |
|
|
}
|
853 |
|
|
b->loc = NULL;
|
854 |
|
|
|
855 |
|
|
if (b->disposition == disp_del_at_next_stop)
|
856 |
|
|
return;
|
857 |
|
|
|
858 |
|
|
/* Save the current frame's ID so we can restore it after
|
859 |
|
|
evaluating the watchpoint expression on its own frame. */
|
860 |
|
|
/* FIXME drow/2003-09-09: It would be nice if evaluate_expression
|
861 |
|
|
took a frame parameter, so that we didn't have to change the
|
862 |
|
|
selected frame. */
|
863 |
|
|
saved_frame_id = get_frame_id (get_selected_frame (NULL));
|
864 |
|
|
|
865 |
|
|
/* Determine if the watchpoint is within scope. */
|
866 |
|
|
if (b->exp_valid_block == NULL)
|
867 |
|
|
within_current_scope = 1;
|
868 |
|
|
else
|
869 |
|
|
{
|
870 |
|
|
struct frame_info *fi;
|
871 |
|
|
fi = frame_find_by_id (b->watchpoint_frame);
|
872 |
|
|
within_current_scope = (fi != NULL);
|
873 |
|
|
if (within_current_scope)
|
874 |
|
|
select_frame (fi);
|
875 |
|
|
}
|
876 |
|
|
|
877 |
|
|
if (within_current_scope && reparse)
|
878 |
|
|
{
|
879 |
|
|
char *s;
|
880 |
|
|
if (b->exp)
|
881 |
|
|
{
|
882 |
|
|
xfree (b->exp);
|
883 |
|
|
b->exp = NULL;
|
884 |
|
|
}
|
885 |
|
|
s = b->exp_string;
|
886 |
|
|
b->exp = parse_exp_1 (&s, b->exp_valid_block, 0);
|
887 |
|
|
/* If the meaning of expression itself changed, the old value is
|
888 |
|
|
no longer relevant. We don't want to report a watchpoint hit
|
889 |
|
|
to the user when the old value and the new value may actually
|
890 |
|
|
be completely different objects. */
|
891 |
|
|
value_free (b->val);
|
892 |
|
|
b->val = NULL;
|
893 |
|
|
}
|
894 |
|
|
|
895 |
|
|
|
896 |
|
|
/* If we failed to parse the expression, for example because
|
897 |
|
|
it refers to a global variable in a not-yet-loaded shared library,
|
898 |
|
|
don't try to insert watchpoint. We don't automatically delete
|
899 |
|
|
such watchpoint, though, since failure to parse expression
|
900 |
|
|
is different from out-of-scope watchpoint. */
|
901 |
|
|
if (within_current_scope && b->exp)
|
902 |
|
|
{
|
903 |
|
|
struct value *v, *next;
|
904 |
|
|
|
905 |
|
|
/* Evaluate the expression and make sure it's not lazy, so that
|
906 |
|
|
after target stops again, we have a non-lazy previous value
|
907 |
|
|
to compare with. Also, making the value non-lazy will fetch
|
908 |
|
|
intermediate values as needed, which we use to decide which
|
909 |
|
|
addresses to watch.
|
910 |
|
|
|
911 |
|
|
The value returned by evaluate_expression is stored in b->val.
|
912 |
|
|
In addition, we look at all values which were created
|
913 |
|
|
during evaluation, and set watchoints at addresses as needed.
|
914 |
|
|
Those values are explicitly deleted here. */
|
915 |
|
|
v = evaluate_expression (b->exp);
|
916 |
|
|
/* Avoid setting b->val if it's already set. The meaning of
|
917 |
|
|
b->val is 'the last value' user saw, and we should update
|
918 |
|
|
it only if we reported that last value to user. As it
|
919 |
|
|
happens, the code that reports it updates b->val directly. */
|
920 |
|
|
if (b->val == NULL)
|
921 |
|
|
b->val = v;
|
922 |
|
|
value_contents (v);
|
923 |
|
|
value_release_to_mark (mark);
|
924 |
|
|
|
925 |
|
|
/* Look at each value on the value chain. */
|
926 |
|
|
for (; v; v = next)
|
927 |
|
|
{
|
928 |
|
|
/* If it's a memory location, and GDB actually needed
|
929 |
|
|
its contents to evaluate the expression, then we
|
930 |
|
|
must watch it. */
|
931 |
|
|
if (VALUE_LVAL (v) == lval_memory
|
932 |
|
|
&& ! value_lazy (v))
|
933 |
|
|
{
|
934 |
|
|
struct type *vtype = check_typedef (value_type (v));
|
935 |
|
|
|
936 |
|
|
/* We only watch structs and arrays if user asked
|
937 |
|
|
for it explicitly, never if they just happen to
|
938 |
|
|
appear in the middle of some value chain. */
|
939 |
|
|
if (v == b->val
|
940 |
|
|
|| (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
|
941 |
|
|
&& TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
|
942 |
|
|
{
|
943 |
|
|
CORE_ADDR addr;
|
944 |
|
|
int len, type;
|
945 |
|
|
struct bp_location *loc, **tmp;
|
946 |
|
|
|
947 |
|
|
addr = VALUE_ADDRESS (v) + value_offset (v);
|
948 |
|
|
len = TYPE_LENGTH (value_type (v));
|
949 |
|
|
type = hw_write;
|
950 |
|
|
if (b->type == bp_read_watchpoint)
|
951 |
|
|
type = hw_read;
|
952 |
|
|
else if (b->type == bp_access_watchpoint)
|
953 |
|
|
type = hw_access;
|
954 |
|
|
|
955 |
|
|
loc = allocate_bp_location (b, bp_hardware_watchpoint);
|
956 |
|
|
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
|
957 |
|
|
;
|
958 |
|
|
*tmp = loc;
|
959 |
|
|
loc->address = addr;
|
960 |
|
|
loc->length = len;
|
961 |
|
|
loc->watchpoint_type = type;
|
962 |
|
|
}
|
963 |
|
|
}
|
964 |
|
|
|
965 |
|
|
next = value_next (v);
|
966 |
|
|
if (v != b->val)
|
967 |
|
|
value_free (v);
|
968 |
|
|
}
|
969 |
|
|
|
970 |
|
|
if (reparse && b->cond_string != NULL)
|
971 |
|
|
{
|
972 |
|
|
char *s = b->cond_string;
|
973 |
|
|
if (b->loc->cond)
|
974 |
|
|
{
|
975 |
|
|
xfree (b->loc->cond);
|
976 |
|
|
b->loc->cond = NULL;
|
977 |
|
|
}
|
978 |
|
|
b->loc->cond = parse_exp_1 (&s, b->exp_valid_block, 0);
|
979 |
|
|
}
|
980 |
|
|
}
|
981 |
|
|
else if (!within_current_scope)
|
982 |
|
|
{
|
983 |
|
|
printf_filtered (_("\
|
984 |
|
|
Hardware watchpoint %d deleted because the program has left the block \n\
|
985 |
|
|
in which its expression is valid.\n"),
|
986 |
|
|
b->number);
|
987 |
|
|
if (b->related_breakpoint)
|
988 |
|
|
b->related_breakpoint->disposition = disp_del_at_next_stop;
|
989 |
|
|
b->disposition = disp_del_at_next_stop;
|
990 |
|
|
}
|
991 |
|
|
|
992 |
|
|
/* Restore the selected frame. */
|
993 |
|
|
select_frame (frame_find_by_id (saved_frame_id));
|
994 |
|
|
}
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
/* Insert a low-level "breakpoint" of some type. BPT is the breakpoint.
|
998 |
|
|
Any error messages are printed to TMP_ERROR_STREAM; and DISABLED_BREAKS,
|
999 |
|
|
PROCESS_WARNING, and HW_BREAKPOINT_ERROR are used to report problems.
|
1000 |
|
|
|
1001 |
|
|
NOTE drow/2003-09-09: This routine could be broken down to an object-style
|
1002 |
|
|
method for each breakpoint or catchpoint type. */
|
1003 |
|
|
static int
|
1004 |
|
|
insert_bp_location (struct bp_location *bpt,
|
1005 |
|
|
struct ui_file *tmp_error_stream,
|
1006 |
|
|
int *disabled_breaks, int *process_warning,
|
1007 |
|
|
int *hw_breakpoint_error)
|
1008 |
|
|
{
|
1009 |
|
|
int val = 0;
|
1010 |
|
|
|
1011 |
|
|
if (!breakpoint_enabled (bpt->owner))
|
1012 |
|
|
return 0;
|
1013 |
|
|
|
1014 |
|
|
if (!bpt->enabled || bpt->shlib_disabled || bpt->inserted || bpt->duplicate)
|
1015 |
|
|
return 0;
|
1016 |
|
|
|
1017 |
|
|
/* Initialize the target-specific information. */
|
1018 |
|
|
memset (&bpt->target_info, 0, sizeof (bpt->target_info));
|
1019 |
|
|
bpt->target_info.placed_address = bpt->address;
|
1020 |
|
|
|
1021 |
|
|
if (bpt->loc_type == bp_loc_software_breakpoint
|
1022 |
|
|
|| bpt->loc_type == bp_loc_hardware_breakpoint)
|
1023 |
|
|
{
|
1024 |
|
|
if (bpt->owner->type != bp_hardware_breakpoint)
|
1025 |
|
|
{
|
1026 |
|
|
/* If the explicitly specified breakpoint type
|
1027 |
|
|
is not hardware breakpoint, check the memory map to see
|
1028 |
|
|
if the breakpoint address is in read only memory or not.
|
1029 |
|
|
Two important cases are:
|
1030 |
|
|
- location type is not hardware breakpoint, memory
|
1031 |
|
|
is readonly. We change the type of the location to
|
1032 |
|
|
hardware breakpoint.
|
1033 |
|
|
- location type is hardware breakpoint, memory is read-write.
|
1034 |
|
|
This means we've previously made the location hardware one, but
|
1035 |
|
|
then the memory map changed, so we undo.
|
1036 |
|
|
|
1037 |
|
|
When breakpoints are removed, remove_breakpoints will
|
1038 |
|
|
use location types we've just set here, the only possible
|
1039 |
|
|
problem is that memory map has changed during running program,
|
1040 |
|
|
but it's not going to work anyway with current gdb. */
|
1041 |
|
|
struct mem_region *mr
|
1042 |
|
|
= lookup_mem_region (bpt->target_info.placed_address);
|
1043 |
|
|
|
1044 |
|
|
if (mr)
|
1045 |
|
|
{
|
1046 |
|
|
if (automatic_hardware_breakpoints)
|
1047 |
|
|
{
|
1048 |
|
|
int changed = 0;
|
1049 |
|
|
enum bp_loc_type new_type;
|
1050 |
|
|
|
1051 |
|
|
if (mr->attrib.mode != MEM_RW)
|
1052 |
|
|
new_type = bp_loc_hardware_breakpoint;
|
1053 |
|
|
else
|
1054 |
|
|
new_type = bp_loc_software_breakpoint;
|
1055 |
|
|
|
1056 |
|
|
if (new_type != bpt->loc_type)
|
1057 |
|
|
{
|
1058 |
|
|
static int said = 0;
|
1059 |
|
|
bpt->loc_type = new_type;
|
1060 |
|
|
if (!said)
|
1061 |
|
|
{
|
1062 |
|
|
fprintf_filtered (gdb_stdout, _("\
|
1063 |
|
|
Note: automatically using hardware breakpoints for read-only addresses.\n"));
|
1064 |
|
|
said = 1;
|
1065 |
|
|
}
|
1066 |
|
|
}
|
1067 |
|
|
}
|
1068 |
|
|
else if (bpt->loc_type == bp_loc_software_breakpoint
|
1069 |
|
|
&& mr->attrib.mode != MEM_RW)
|
1070 |
|
|
warning (_("cannot set software breakpoint at readonly address %s"),
|
1071 |
|
|
paddr (bpt->address));
|
1072 |
|
|
}
|
1073 |
|
|
}
|
1074 |
|
|
|
1075 |
|
|
/* First check to see if we have to handle an overlay. */
|
1076 |
|
|
if (overlay_debugging == ovly_off
|
1077 |
|
|
|| bpt->section == NULL
|
1078 |
|
|
|| !(section_is_overlay (bpt->section)))
|
1079 |
|
|
{
|
1080 |
|
|
/* No overlay handling: just set the breakpoint. */
|
1081 |
|
|
|
1082 |
|
|
if (bpt->loc_type == bp_loc_hardware_breakpoint)
|
1083 |
|
|
val = target_insert_hw_breakpoint (&bpt->target_info);
|
1084 |
|
|
else
|
1085 |
|
|
val = target_insert_breakpoint (&bpt->target_info);
|
1086 |
|
|
}
|
1087 |
|
|
else
|
1088 |
|
|
{
|
1089 |
|
|
/* This breakpoint is in an overlay section.
|
1090 |
|
|
Shall we set a breakpoint at the LMA? */
|
1091 |
|
|
if (!overlay_events_enabled)
|
1092 |
|
|
{
|
1093 |
|
|
/* Yes -- overlay event support is not active,
|
1094 |
|
|
so we must try to set a breakpoint at the LMA.
|
1095 |
|
|
This will not work for a hardware breakpoint. */
|
1096 |
|
|
if (bpt->loc_type == bp_loc_hardware_breakpoint)
|
1097 |
|
|
warning (_("hardware breakpoint %d not supported in overlay!"),
|
1098 |
|
|
bpt->owner->number);
|
1099 |
|
|
else
|
1100 |
|
|
{
|
1101 |
|
|
CORE_ADDR addr = overlay_unmapped_address (bpt->address,
|
1102 |
|
|
bpt->section);
|
1103 |
|
|
/* Set a software (trap) breakpoint at the LMA. */
|
1104 |
|
|
bpt->overlay_target_info = bpt->target_info;
|
1105 |
|
|
bpt->overlay_target_info.placed_address = addr;
|
1106 |
|
|
val = target_insert_breakpoint (&bpt->overlay_target_info);
|
1107 |
|
|
if (val != 0)
|
1108 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1109 |
|
|
"Overlay breakpoint %d failed: in ROM?",
|
1110 |
|
|
bpt->owner->number);
|
1111 |
|
|
}
|
1112 |
|
|
}
|
1113 |
|
|
/* Shall we set a breakpoint at the VMA? */
|
1114 |
|
|
if (section_is_mapped (bpt->section))
|
1115 |
|
|
{
|
1116 |
|
|
/* Yes. This overlay section is mapped into memory. */
|
1117 |
|
|
if (bpt->loc_type == bp_loc_hardware_breakpoint)
|
1118 |
|
|
val = target_insert_hw_breakpoint (&bpt->target_info);
|
1119 |
|
|
else
|
1120 |
|
|
val = target_insert_breakpoint (&bpt->target_info);
|
1121 |
|
|
}
|
1122 |
|
|
else
|
1123 |
|
|
{
|
1124 |
|
|
/* No. This breakpoint will not be inserted.
|
1125 |
|
|
No error, but do not mark the bp as 'inserted'. */
|
1126 |
|
|
return 0;
|
1127 |
|
|
}
|
1128 |
|
|
}
|
1129 |
|
|
|
1130 |
|
|
if (val)
|
1131 |
|
|
{
|
1132 |
|
|
/* Can't set the breakpoint. */
|
1133 |
|
|
if (solib_address (bpt->address))
|
1134 |
|
|
{
|
1135 |
|
|
/* See also: disable_breakpoints_in_shlibs. */
|
1136 |
|
|
val = 0;
|
1137 |
|
|
bpt->shlib_disabled = 1;
|
1138 |
|
|
if (!*disabled_breaks)
|
1139 |
|
|
{
|
1140 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1141 |
|
|
"Cannot insert breakpoint %d.\n",
|
1142 |
|
|
bpt->owner->number);
|
1143 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1144 |
|
|
"Temporarily disabling shared library breakpoints:\n");
|
1145 |
|
|
}
|
1146 |
|
|
*disabled_breaks = 1;
|
1147 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1148 |
|
|
"breakpoint #%d\n", bpt->owner->number);
|
1149 |
|
|
}
|
1150 |
|
|
else
|
1151 |
|
|
{
|
1152 |
|
|
#ifdef ONE_PROCESS_WRITETEXT
|
1153 |
|
|
*process_warning = 1;
|
1154 |
|
|
#endif
|
1155 |
|
|
if (bpt->loc_type == bp_loc_hardware_breakpoint)
|
1156 |
|
|
{
|
1157 |
|
|
*hw_breakpoint_error = 1;
|
1158 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1159 |
|
|
"Cannot insert hardware breakpoint %d.\n",
|
1160 |
|
|
bpt->owner->number);
|
1161 |
|
|
}
|
1162 |
|
|
else
|
1163 |
|
|
{
|
1164 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1165 |
|
|
"Cannot insert breakpoint %d.\n",
|
1166 |
|
|
bpt->owner->number);
|
1167 |
|
|
fprintf_filtered (tmp_error_stream,
|
1168 |
|
|
"Error accessing memory address ");
|
1169 |
|
|
fputs_filtered (paddress (bpt->address), tmp_error_stream);
|
1170 |
|
|
fprintf_filtered (tmp_error_stream, ": %s.\n",
|
1171 |
|
|
safe_strerror (val));
|
1172 |
|
|
}
|
1173 |
|
|
|
1174 |
|
|
}
|
1175 |
|
|
}
|
1176 |
|
|
else
|
1177 |
|
|
bpt->inserted = 1;
|
1178 |
|
|
|
1179 |
|
|
return val;
|
1180 |
|
|
}
|
1181 |
|
|
|
1182 |
|
|
else if (bpt->loc_type == bp_loc_hardware_watchpoint
|
1183 |
|
|
/* NOTE drow/2003-09-08: This state only exists for removing
|
1184 |
|
|
watchpoints. It's not clear that it's necessary... */
|
1185 |
|
|
&& bpt->owner->disposition != disp_del_at_next_stop)
|
1186 |
|
|
{
|
1187 |
|
|
val = target_insert_watchpoint (bpt->address,
|
1188 |
|
|
bpt->length,
|
1189 |
|
|
bpt->watchpoint_type);
|
1190 |
|
|
bpt->inserted = (val != -1);
|
1191 |
|
|
}
|
1192 |
|
|
|
1193 |
|
|
else if (bpt->owner->type == bp_catch_fork
|
1194 |
|
|
|| bpt->owner->type == bp_catch_vfork
|
1195 |
|
|
|| bpt->owner->type == bp_catch_exec)
|
1196 |
|
|
{
|
1197 |
|
|
struct gdb_exception e = catch_exception (uiout, insert_catchpoint,
|
1198 |
|
|
bpt->owner, RETURN_MASK_ERROR);
|
1199 |
|
|
exception_fprintf (gdb_stderr, e, "warning: inserting catchpoint %d: ",
|
1200 |
|
|
bpt->owner->number);
|
1201 |
|
|
if (e.reason < 0)
|
1202 |
|
|
bpt->owner->enable_state = bp_disabled;
|
1203 |
|
|
else
|
1204 |
|
|
bpt->inserted = 1;
|
1205 |
|
|
|
1206 |
|
|
/* We've already printed an error message if there was a problem
|
1207 |
|
|
inserting this catchpoint, and we've disabled the catchpoint,
|
1208 |
|
|
so just return success. */
|
1209 |
|
|
return 0;
|
1210 |
|
|
}
|
1211 |
|
|
|
1212 |
|
|
return 0;
|
1213 |
|
|
}
|
1214 |
|
|
|
1215 |
|
|
/* insert_breakpoints is used when starting or continuing the program.
|
1216 |
|
|
remove_breakpoints is used when the program stops.
|
1217 |
|
|
Both return zero if successful,
|
1218 |
|
|
or an `errno' value if could not write the inferior. */
|
1219 |
|
|
|
1220 |
|
|
void
|
1221 |
|
|
insert_breakpoints (void)
|
1222 |
|
|
{
|
1223 |
|
|
struct breakpoint *bpt;
|
1224 |
|
|
struct bp_location *b, *temp;
|
1225 |
|
|
int error = 0;
|
1226 |
|
|
int val = 0;
|
1227 |
|
|
int disabled_breaks = 0;
|
1228 |
|
|
int hw_breakpoint_error = 0;
|
1229 |
|
|
int process_warning = 0;
|
1230 |
|
|
|
1231 |
|
|
struct ui_file *tmp_error_stream = mem_fileopen ();
|
1232 |
|
|
make_cleanup_ui_file_delete (tmp_error_stream);
|
1233 |
|
|
|
1234 |
|
|
/* Explicitly mark the warning -- this will only be printed if
|
1235 |
|
|
there was an error. */
|
1236 |
|
|
fprintf_unfiltered (tmp_error_stream, "Warning:\n");
|
1237 |
|
|
|
1238 |
|
|
ALL_BREAKPOINTS (bpt)
|
1239 |
|
|
if (is_hardware_watchpoint (bpt))
|
1240 |
|
|
update_watchpoint (bpt, 0 /* don't reparse */);
|
1241 |
|
|
|
1242 |
|
|
ALL_BP_LOCATIONS_SAFE (b, temp)
|
1243 |
|
|
{
|
1244 |
|
|
if (!breakpoint_enabled (b->owner))
|
1245 |
|
|
continue;
|
1246 |
|
|
|
1247 |
|
|
/* There is no point inserting thread-specific breakpoints if the
|
1248 |
|
|
thread no longer exists. */
|
1249 |
|
|
if (b->owner->thread != -1
|
1250 |
|
|
&& !valid_thread_id (b->owner->thread))
|
1251 |
|
|
continue;
|
1252 |
|
|
|
1253 |
|
|
val = insert_bp_location (b, tmp_error_stream,
|
1254 |
|
|
&disabled_breaks, &process_warning,
|
1255 |
|
|
&hw_breakpoint_error);
|
1256 |
|
|
if (val)
|
1257 |
|
|
error = val;
|
1258 |
|
|
}
|
1259 |
|
|
|
1260 |
|
|
/* If we failed to insert all locations of a watchpoint,
|
1261 |
|
|
remove them, as half-inserted watchpoint is of limited use. */
|
1262 |
|
|
ALL_BREAKPOINTS (bpt)
|
1263 |
|
|
{
|
1264 |
|
|
int some_failed = 0;
|
1265 |
|
|
struct bp_location *loc;
|
1266 |
|
|
|
1267 |
|
|
if (!is_hardware_watchpoint (bpt))
|
1268 |
|
|
continue;
|
1269 |
|
|
|
1270 |
|
|
if (bpt->enable_state != bp_enabled)
|
1271 |
|
|
continue;
|
1272 |
|
|
|
1273 |
|
|
for (loc = bpt->loc; loc; loc = loc->next)
|
1274 |
|
|
if (!loc->inserted)
|
1275 |
|
|
{
|
1276 |
|
|
some_failed = 1;
|
1277 |
|
|
break;
|
1278 |
|
|
}
|
1279 |
|
|
if (some_failed)
|
1280 |
|
|
{
|
1281 |
|
|
for (loc = bpt->loc; loc; loc = loc->next)
|
1282 |
|
|
if (loc->inserted)
|
1283 |
|
|
remove_breakpoint (loc, mark_uninserted);
|
1284 |
|
|
|
1285 |
|
|
hw_breakpoint_error = 1;
|
1286 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1287 |
|
|
"Could not insert hardware watchpoint %d.\n",
|
1288 |
|
|
bpt->number);
|
1289 |
|
|
error = -1;
|
1290 |
|
|
}
|
1291 |
|
|
}
|
1292 |
|
|
|
1293 |
|
|
if (error)
|
1294 |
|
|
{
|
1295 |
|
|
/* If a hardware breakpoint or watchpoint was inserted, add a
|
1296 |
|
|
message about possibly exhausted resources. */
|
1297 |
|
|
if (hw_breakpoint_error)
|
1298 |
|
|
{
|
1299 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1300 |
|
|
"Could not insert hardware breakpoints:\n\
|
1301 |
|
|
You may have requested too many hardware breakpoints/watchpoints.\n");
|
1302 |
|
|
}
|
1303 |
|
|
#ifdef ONE_PROCESS_WRITETEXT
|
1304 |
|
|
if (process_warning)
|
1305 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
1306 |
|
|
"The same program may be running in another process.");
|
1307 |
|
|
#endif
|
1308 |
|
|
target_terminal_ours_for_output ();
|
1309 |
|
|
error_stream (tmp_error_stream);
|
1310 |
|
|
}
|
1311 |
|
|
}
|
1312 |
|
|
|
1313 |
|
|
int
|
1314 |
|
|
remove_breakpoints (void)
|
1315 |
|
|
{
|
1316 |
|
|
struct bp_location *b;
|
1317 |
|
|
int val;
|
1318 |
|
|
|
1319 |
|
|
ALL_BP_LOCATIONS (b)
|
1320 |
|
|
{
|
1321 |
|
|
if (b->inserted)
|
1322 |
|
|
{
|
1323 |
|
|
val = remove_breakpoint (b, mark_uninserted);
|
1324 |
|
|
if (val != 0)
|
1325 |
|
|
return val;
|
1326 |
|
|
}
|
1327 |
|
|
}
|
1328 |
|
|
return 0;
|
1329 |
|
|
}
|
1330 |
|
|
|
1331 |
|
|
int
|
1332 |
|
|
remove_hw_watchpoints (void)
|
1333 |
|
|
{
|
1334 |
|
|
struct bp_location *b;
|
1335 |
|
|
int val;
|
1336 |
|
|
|
1337 |
|
|
ALL_BP_LOCATIONS (b)
|
1338 |
|
|
{
|
1339 |
|
|
if (b->inserted && b->loc_type == bp_loc_hardware_watchpoint)
|
1340 |
|
|
{
|
1341 |
|
|
val = remove_breakpoint (b, mark_uninserted);
|
1342 |
|
|
if (val != 0)
|
1343 |
|
|
return val;
|
1344 |
|
|
}
|
1345 |
|
|
}
|
1346 |
|
|
return 0;
|
1347 |
|
|
}
|
1348 |
|
|
|
1349 |
|
|
int
|
1350 |
|
|
reattach_breakpoints (int pid)
|
1351 |
|
|
{
|
1352 |
|
|
struct bp_location *b;
|
1353 |
|
|
int val;
|
1354 |
|
|
struct cleanup *old_chain = save_inferior_ptid ();
|
1355 |
|
|
struct ui_file *tmp_error_stream = mem_fileopen ();
|
1356 |
|
|
int dummy1 = 0, dummy2 = 0, dummy3 = 0;
|
1357 |
|
|
|
1358 |
|
|
make_cleanup_ui_file_delete (tmp_error_stream);
|
1359 |
|
|
|
1360 |
|
|
inferior_ptid = pid_to_ptid (pid);
|
1361 |
|
|
ALL_BP_LOCATIONS (b)
|
1362 |
|
|
{
|
1363 |
|
|
if (b->inserted)
|
1364 |
|
|
{
|
1365 |
|
|
b->inserted = 0;
|
1366 |
|
|
val = insert_bp_location (b, tmp_error_stream,
|
1367 |
|
|
&dummy1, &dummy2, &dummy3);
|
1368 |
|
|
if (val != 0)
|
1369 |
|
|
{
|
1370 |
|
|
do_cleanups (old_chain);
|
1371 |
|
|
return val;
|
1372 |
|
|
}
|
1373 |
|
|
}
|
1374 |
|
|
}
|
1375 |
|
|
do_cleanups (old_chain);
|
1376 |
|
|
return 0;
|
1377 |
|
|
}
|
1378 |
|
|
|
1379 |
|
|
void
|
1380 |
|
|
update_breakpoints_after_exec (void)
|
1381 |
|
|
{
|
1382 |
|
|
struct breakpoint *b;
|
1383 |
|
|
struct breakpoint *temp;
|
1384 |
|
|
|
1385 |
|
|
/* Doing this first prevents the badness of having delete_breakpoint()
|
1386 |
|
|
write a breakpoint's current "shadow contents" to lift the bp. That
|
1387 |
|
|
shadow is NOT valid after an exec()! */
|
1388 |
|
|
mark_breakpoints_out ();
|
1389 |
|
|
|
1390 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
1391 |
|
|
{
|
1392 |
|
|
/* Solib breakpoints must be explicitly reset after an exec(). */
|
1393 |
|
|
if (b->type == bp_shlib_event)
|
1394 |
|
|
{
|
1395 |
|
|
delete_breakpoint (b);
|
1396 |
|
|
continue;
|
1397 |
|
|
}
|
1398 |
|
|
|
1399 |
|
|
/* Thread event breakpoints must be set anew after an exec(),
|
1400 |
|
|
as must overlay event breakpoints. */
|
1401 |
|
|
if (b->type == bp_thread_event || b->type == bp_overlay_event)
|
1402 |
|
|
{
|
1403 |
|
|
delete_breakpoint (b);
|
1404 |
|
|
continue;
|
1405 |
|
|
}
|
1406 |
|
|
|
1407 |
|
|
/* Step-resume breakpoints are meaningless after an exec(). */
|
1408 |
|
|
if (b->type == bp_step_resume)
|
1409 |
|
|
{
|
1410 |
|
|
delete_breakpoint (b);
|
1411 |
|
|
continue;
|
1412 |
|
|
}
|
1413 |
|
|
|
1414 |
|
|
/* Don't delete an exec catchpoint, because else the inferior
|
1415 |
|
|
won't stop when it ought!
|
1416 |
|
|
|
1417 |
|
|
Similarly, we probably ought to keep vfork catchpoints, 'cause
|
1418 |
|
|
on this target, we may not be able to stop when the vfork is
|
1419 |
|
|
seen, but only when the subsequent exec is seen. (And because
|
1420 |
|
|
deleting fork catchpoints here but not vfork catchpoints will
|
1421 |
|
|
seem mysterious to users, keep those too.) */
|
1422 |
|
|
if ((b->type == bp_catch_exec) ||
|
1423 |
|
|
(b->type == bp_catch_vfork) ||
|
1424 |
|
|
(b->type == bp_catch_fork))
|
1425 |
|
|
{
|
1426 |
|
|
continue;
|
1427 |
|
|
}
|
1428 |
|
|
|
1429 |
|
|
/* bp_finish is a special case. The only way we ought to be able
|
1430 |
|
|
to see one of these when an exec() has happened, is if the user
|
1431 |
|
|
caught a vfork, and then said "finish". Ordinarily a finish just
|
1432 |
|
|
carries them to the call-site of the current callee, by setting
|
1433 |
|
|
a temporary bp there and resuming. But in this case, the finish
|
1434 |
|
|
will carry them entirely through the vfork & exec.
|
1435 |
|
|
|
1436 |
|
|
We don't want to allow a bp_finish to remain inserted now. But
|
1437 |
|
|
we can't safely delete it, 'cause finish_command has a handle to
|
1438 |
|
|
the bp on a bpstat, and will later want to delete it. There's a
|
1439 |
|
|
chance (and I've seen it happen) that if we delete the bp_finish
|
1440 |
|
|
here, that its storage will get reused by the time finish_command
|
1441 |
|
|
gets 'round to deleting the "use to be a bp_finish" breakpoint.
|
1442 |
|
|
We really must allow finish_command to delete a bp_finish.
|
1443 |
|
|
|
1444 |
|
|
In the absense of a general solution for the "how do we know
|
1445 |
|
|
it's safe to delete something others may have handles to?"
|
1446 |
|
|
problem, what we'll do here is just uninsert the bp_finish, and
|
1447 |
|
|
let finish_command delete it.
|
1448 |
|
|
|
1449 |
|
|
(We know the bp_finish is "doomed" in the sense that it's
|
1450 |
|
|
momentary, and will be deleted as soon as finish_command sees
|
1451 |
|
|
the inferior stopped. So it doesn't matter that the bp's
|
1452 |
|
|
address is probably bogus in the new a.out, unlike e.g., the
|
1453 |
|
|
solib breakpoints.) */
|
1454 |
|
|
|
1455 |
|
|
if (b->type == bp_finish)
|
1456 |
|
|
{
|
1457 |
|
|
continue;
|
1458 |
|
|
}
|
1459 |
|
|
|
1460 |
|
|
/* Without a symbolic address, we have little hope of the
|
1461 |
|
|
pre-exec() address meaning the same thing in the post-exec()
|
1462 |
|
|
a.out. */
|
1463 |
|
|
if (b->addr_string == NULL)
|
1464 |
|
|
{
|
1465 |
|
|
delete_breakpoint (b);
|
1466 |
|
|
continue;
|
1467 |
|
|
}
|
1468 |
|
|
}
|
1469 |
|
|
/* FIXME what about longjmp breakpoints? Re-create them here? */
|
1470 |
|
|
create_overlay_event_breakpoint ("_ovly_debug_event");
|
1471 |
|
|
}
|
1472 |
|
|
|
1473 |
|
|
int
|
1474 |
|
|
detach_breakpoints (int pid)
|
1475 |
|
|
{
|
1476 |
|
|
struct bp_location *b;
|
1477 |
|
|
int val;
|
1478 |
|
|
struct cleanup *old_chain = save_inferior_ptid ();
|
1479 |
|
|
|
1480 |
|
|
if (pid == PIDGET (inferior_ptid))
|
1481 |
|
|
error (_("Cannot detach breakpoints of inferior_ptid"));
|
1482 |
|
|
|
1483 |
|
|
/* Set inferior_ptid; remove_breakpoint uses this global. */
|
1484 |
|
|
inferior_ptid = pid_to_ptid (pid);
|
1485 |
|
|
ALL_BP_LOCATIONS (b)
|
1486 |
|
|
{
|
1487 |
|
|
if (b->inserted)
|
1488 |
|
|
{
|
1489 |
|
|
val = remove_breakpoint (b, mark_inserted);
|
1490 |
|
|
if (val != 0)
|
1491 |
|
|
{
|
1492 |
|
|
do_cleanups (old_chain);
|
1493 |
|
|
return val;
|
1494 |
|
|
}
|
1495 |
|
|
}
|
1496 |
|
|
}
|
1497 |
|
|
do_cleanups (old_chain);
|
1498 |
|
|
return 0;
|
1499 |
|
|
}
|
1500 |
|
|
|
1501 |
|
|
static int
|
1502 |
|
|
remove_breakpoint (struct bp_location *b, insertion_state_t is)
|
1503 |
|
|
{
|
1504 |
|
|
int val;
|
1505 |
|
|
|
1506 |
|
|
if (b->owner->enable_state == bp_permanent)
|
1507 |
|
|
/* Permanent breakpoints cannot be inserted or removed. */
|
1508 |
|
|
return 0;
|
1509 |
|
|
|
1510 |
|
|
if (b->owner->type == bp_none)
|
1511 |
|
|
warning (_("attempted to remove apparently deleted breakpoint #%d?"),
|
1512 |
|
|
b->owner->number);
|
1513 |
|
|
|
1514 |
|
|
if (b->loc_type == bp_loc_software_breakpoint
|
1515 |
|
|
|| b->loc_type == bp_loc_hardware_breakpoint)
|
1516 |
|
|
{
|
1517 |
|
|
/* "Normal" instruction breakpoint: either the standard
|
1518 |
|
|
trap-instruction bp (bp_breakpoint), or a
|
1519 |
|
|
bp_hardware_breakpoint. */
|
1520 |
|
|
|
1521 |
|
|
/* First check to see if we have to handle an overlay. */
|
1522 |
|
|
if (overlay_debugging == ovly_off
|
1523 |
|
|
|| b->section == NULL
|
1524 |
|
|
|| !(section_is_overlay (b->section)))
|
1525 |
|
|
{
|
1526 |
|
|
/* No overlay handling: just remove the breakpoint. */
|
1527 |
|
|
|
1528 |
|
|
if (b->loc_type == bp_loc_hardware_breakpoint)
|
1529 |
|
|
val = target_remove_hw_breakpoint (&b->target_info);
|
1530 |
|
|
else
|
1531 |
|
|
val = target_remove_breakpoint (&b->target_info);
|
1532 |
|
|
}
|
1533 |
|
|
else
|
1534 |
|
|
{
|
1535 |
|
|
/* This breakpoint is in an overlay section.
|
1536 |
|
|
Did we set a breakpoint at the LMA? */
|
1537 |
|
|
if (!overlay_events_enabled)
|
1538 |
|
|
{
|
1539 |
|
|
/* Yes -- overlay event support is not active, so we
|
1540 |
|
|
should have set a breakpoint at the LMA. Remove it.
|
1541 |
|
|
*/
|
1542 |
|
|
/* Ignore any failures: if the LMA is in ROM, we will
|
1543 |
|
|
have already warned when we failed to insert it. */
|
1544 |
|
|
if (b->loc_type == bp_loc_hardware_breakpoint)
|
1545 |
|
|
target_remove_hw_breakpoint (&b->overlay_target_info);
|
1546 |
|
|
else
|
1547 |
|
|
target_remove_breakpoint (&b->overlay_target_info);
|
1548 |
|
|
}
|
1549 |
|
|
/* Did we set a breakpoint at the VMA?
|
1550 |
|
|
If so, we will have marked the breakpoint 'inserted'. */
|
1551 |
|
|
if (b->inserted)
|
1552 |
|
|
{
|
1553 |
|
|
/* Yes -- remove it. Previously we did not bother to
|
1554 |
|
|
remove the breakpoint if the section had been
|
1555 |
|
|
unmapped, but let's not rely on that being safe. We
|
1556 |
|
|
don't know what the overlay manager might do. */
|
1557 |
|
|
if (b->loc_type == bp_loc_hardware_breakpoint)
|
1558 |
|
|
val = target_remove_hw_breakpoint (&b->target_info);
|
1559 |
|
|
|
1560 |
|
|
/* However, we should remove *software* breakpoints only
|
1561 |
|
|
if the section is still mapped, or else we overwrite
|
1562 |
|
|
wrong code with the saved shadow contents. */
|
1563 |
|
|
else if (section_is_mapped (b->section))
|
1564 |
|
|
val = target_remove_breakpoint (&b->target_info);
|
1565 |
|
|
else
|
1566 |
|
|
val = 0;
|
1567 |
|
|
}
|
1568 |
|
|
else
|
1569 |
|
|
{
|
1570 |
|
|
/* No -- not inserted, so no need to remove. No error. */
|
1571 |
|
|
val = 0;
|
1572 |
|
|
}
|
1573 |
|
|
}
|
1574 |
|
|
if (val)
|
1575 |
|
|
return val;
|
1576 |
|
|
b->inserted = (is == mark_inserted);
|
1577 |
|
|
}
|
1578 |
|
|
else if (b->loc_type == bp_loc_hardware_watchpoint)
|
1579 |
|
|
{
|
1580 |
|
|
struct value *v;
|
1581 |
|
|
struct value *n;
|
1582 |
|
|
|
1583 |
|
|
b->inserted = (is == mark_inserted);
|
1584 |
|
|
val = target_remove_watchpoint (b->address, b->length,
|
1585 |
|
|
b->watchpoint_type);
|
1586 |
|
|
|
1587 |
|
|
/* Failure to remove any of the hardware watchpoints comes here. */
|
1588 |
|
|
if ((is == mark_uninserted) && (b->inserted))
|
1589 |
|
|
warning (_("Could not remove hardware watchpoint %d."),
|
1590 |
|
|
b->owner->number);
|
1591 |
|
|
}
|
1592 |
|
|
else if ((b->owner->type == bp_catch_fork ||
|
1593 |
|
|
b->owner->type == bp_catch_vfork ||
|
1594 |
|
|
b->owner->type == bp_catch_exec)
|
1595 |
|
|
&& breakpoint_enabled (b->owner)
|
1596 |
|
|
&& !b->duplicate)
|
1597 |
|
|
{
|
1598 |
|
|
val = -1;
|
1599 |
|
|
switch (b->owner->type)
|
1600 |
|
|
{
|
1601 |
|
|
case bp_catch_fork:
|
1602 |
|
|
val = target_remove_fork_catchpoint (PIDGET (inferior_ptid));
|
1603 |
|
|
break;
|
1604 |
|
|
case bp_catch_vfork:
|
1605 |
|
|
val = target_remove_vfork_catchpoint (PIDGET (inferior_ptid));
|
1606 |
|
|
break;
|
1607 |
|
|
case bp_catch_exec:
|
1608 |
|
|
val = target_remove_exec_catchpoint (PIDGET (inferior_ptid));
|
1609 |
|
|
break;
|
1610 |
|
|
default:
|
1611 |
|
|
warning (_("Internal error, %s line %d."), __FILE__, __LINE__);
|
1612 |
|
|
break;
|
1613 |
|
|
}
|
1614 |
|
|
if (val)
|
1615 |
|
|
return val;
|
1616 |
|
|
b->inserted = (is == mark_inserted);
|
1617 |
|
|
}
|
1618 |
|
|
|
1619 |
|
|
return 0;
|
1620 |
|
|
}
|
1621 |
|
|
|
1622 |
|
|
/* Clear the "inserted" flag in all breakpoints. */
|
1623 |
|
|
|
1624 |
|
|
static void
|
1625 |
|
|
mark_breakpoints_out (void)
|
1626 |
|
|
{
|
1627 |
|
|
struct bp_location *bpt;
|
1628 |
|
|
|
1629 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1630 |
|
|
bpt->inserted = 0;
|
1631 |
|
|
}
|
1632 |
|
|
|
1633 |
|
|
/* Clear the "inserted" flag in all breakpoints and delete any
|
1634 |
|
|
breakpoints which should go away between runs of the program.
|
1635 |
|
|
|
1636 |
|
|
Plus other such housekeeping that has to be done for breakpoints
|
1637 |
|
|
between runs.
|
1638 |
|
|
|
1639 |
|
|
Note: this function gets called at the end of a run (by
|
1640 |
|
|
generic_mourn_inferior) and when a run begins (by
|
1641 |
|
|
init_wait_for_inferior). */
|
1642 |
|
|
|
1643 |
|
|
|
1644 |
|
|
|
1645 |
|
|
void
|
1646 |
|
|
breakpoint_init_inferior (enum inf_context context)
|
1647 |
|
|
{
|
1648 |
|
|
struct breakpoint *b, *temp;
|
1649 |
|
|
struct bp_location *bpt;
|
1650 |
|
|
|
1651 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1652 |
|
|
bpt->inserted = 0;
|
1653 |
|
|
|
1654 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
1655 |
|
|
{
|
1656 |
|
|
switch (b->type)
|
1657 |
|
|
{
|
1658 |
|
|
case bp_call_dummy:
|
1659 |
|
|
case bp_watchpoint_scope:
|
1660 |
|
|
|
1661 |
|
|
/* If the call dummy breakpoint is at the entry point it will
|
1662 |
|
|
cause problems when the inferior is rerun, so we better
|
1663 |
|
|
get rid of it.
|
1664 |
|
|
|
1665 |
|
|
Also get rid of scope breakpoints. */
|
1666 |
|
|
delete_breakpoint (b);
|
1667 |
|
|
break;
|
1668 |
|
|
|
1669 |
|
|
case bp_watchpoint:
|
1670 |
|
|
case bp_hardware_watchpoint:
|
1671 |
|
|
case bp_read_watchpoint:
|
1672 |
|
|
case bp_access_watchpoint:
|
1673 |
|
|
|
1674 |
|
|
/* Likewise for watchpoints on local expressions. */
|
1675 |
|
|
if (b->exp_valid_block != NULL)
|
1676 |
|
|
delete_breakpoint (b);
|
1677 |
|
|
else if (context == inf_starting)
|
1678 |
|
|
{
|
1679 |
|
|
/* Reset val field to force reread of starting value
|
1680 |
|
|
in insert_breakpoints. */
|
1681 |
|
|
if (b->val)
|
1682 |
|
|
value_free (b->val);
|
1683 |
|
|
b->val = NULL;
|
1684 |
|
|
}
|
1685 |
|
|
break;
|
1686 |
|
|
default:
|
1687 |
|
|
break;
|
1688 |
|
|
}
|
1689 |
|
|
}
|
1690 |
|
|
}
|
1691 |
|
|
|
1692 |
|
|
/* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
|
1693 |
|
|
exists at PC. It returns ordinary_breakpoint_here if it's an
|
1694 |
|
|
ordinary breakpoint, or permanent_breakpoint_here if it's a
|
1695 |
|
|
permanent breakpoint.
|
1696 |
|
|
- When continuing from a location with an ordinary breakpoint, we
|
1697 |
|
|
actually single step once before calling insert_breakpoints.
|
1698 |
|
|
- When continuing from a localion with a permanent breakpoint, we
|
1699 |
|
|
need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
|
1700 |
|
|
the target, to advance the PC past the breakpoint. */
|
1701 |
|
|
|
1702 |
|
|
enum breakpoint_here
|
1703 |
|
|
breakpoint_here_p (CORE_ADDR pc)
|
1704 |
|
|
{
|
1705 |
|
|
const struct bp_location *bpt;
|
1706 |
|
|
int any_breakpoint_here = 0;
|
1707 |
|
|
|
1708 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1709 |
|
|
{
|
1710 |
|
|
if (bpt->loc_type != bp_loc_software_breakpoint
|
1711 |
|
|
&& bpt->loc_type != bp_loc_hardware_breakpoint)
|
1712 |
|
|
continue;
|
1713 |
|
|
|
1714 |
|
|
if ((breakpoint_enabled (bpt->owner)
|
1715 |
|
|
|| bpt->owner->enable_state == bp_permanent)
|
1716 |
|
|
&& bpt->address == pc) /* bp is enabled and matches pc */
|
1717 |
|
|
{
|
1718 |
|
|
if (overlay_debugging
|
1719 |
|
|
&& section_is_overlay (bpt->section)
|
1720 |
|
|
&& !section_is_mapped (bpt->section))
|
1721 |
|
|
continue; /* unmapped overlay -- can't be a match */
|
1722 |
|
|
else if (bpt->owner->enable_state == bp_permanent)
|
1723 |
|
|
return permanent_breakpoint_here;
|
1724 |
|
|
else
|
1725 |
|
|
any_breakpoint_here = 1;
|
1726 |
|
|
}
|
1727 |
|
|
}
|
1728 |
|
|
|
1729 |
|
|
return any_breakpoint_here ? ordinary_breakpoint_here : 0;
|
1730 |
|
|
}
|
1731 |
|
|
|
1732 |
|
|
|
1733 |
|
|
/* Returns non-zero if there's a breakpoint inserted at PC, which is
|
1734 |
|
|
inserted using regular breakpoint_chain/bp_location_chain mechanism.
|
1735 |
|
|
This does not check for single-step breakpoints, which are
|
1736 |
|
|
inserted and removed using direct target manipulation. */
|
1737 |
|
|
|
1738 |
|
|
int
|
1739 |
|
|
regular_breakpoint_inserted_here_p (CORE_ADDR pc)
|
1740 |
|
|
{
|
1741 |
|
|
const struct bp_location *bpt;
|
1742 |
|
|
|
1743 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1744 |
|
|
{
|
1745 |
|
|
if (bpt->loc_type != bp_loc_software_breakpoint
|
1746 |
|
|
&& bpt->loc_type != bp_loc_hardware_breakpoint)
|
1747 |
|
|
continue;
|
1748 |
|
|
|
1749 |
|
|
if (bpt->inserted
|
1750 |
|
|
&& bpt->address == pc) /* bp is inserted and matches pc */
|
1751 |
|
|
{
|
1752 |
|
|
if (overlay_debugging
|
1753 |
|
|
&& section_is_overlay (bpt->section)
|
1754 |
|
|
&& !section_is_mapped (bpt->section))
|
1755 |
|
|
continue; /* unmapped overlay -- can't be a match */
|
1756 |
|
|
else
|
1757 |
|
|
return 1;
|
1758 |
|
|
}
|
1759 |
|
|
}
|
1760 |
|
|
return 0;
|
1761 |
|
|
}
|
1762 |
|
|
|
1763 |
|
|
/* Returns non-zero iff there's either regular breakpoint
|
1764 |
|
|
or a single step breakpoint inserted at PC. */
|
1765 |
|
|
|
1766 |
|
|
int
|
1767 |
|
|
breakpoint_inserted_here_p (CORE_ADDR pc)
|
1768 |
|
|
{
|
1769 |
|
|
if (regular_breakpoint_inserted_here_p (pc))
|
1770 |
|
|
return 1;
|
1771 |
|
|
|
1772 |
|
|
if (single_step_breakpoint_inserted_here_p (pc))
|
1773 |
|
|
return 1;
|
1774 |
|
|
|
1775 |
|
|
return 0;
|
1776 |
|
|
}
|
1777 |
|
|
|
1778 |
|
|
/* This function returns non-zero iff there is a software breakpoint
|
1779 |
|
|
inserted at PC. */
|
1780 |
|
|
|
1781 |
|
|
int
|
1782 |
|
|
software_breakpoint_inserted_here_p (CORE_ADDR pc)
|
1783 |
|
|
{
|
1784 |
|
|
const struct bp_location *bpt;
|
1785 |
|
|
int any_breakpoint_here = 0;
|
1786 |
|
|
|
1787 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1788 |
|
|
{
|
1789 |
|
|
if (bpt->loc_type != bp_loc_software_breakpoint)
|
1790 |
|
|
continue;
|
1791 |
|
|
|
1792 |
|
|
if (bpt->inserted
|
1793 |
|
|
&& bpt->address == pc) /* bp is enabled and matches pc */
|
1794 |
|
|
{
|
1795 |
|
|
if (overlay_debugging
|
1796 |
|
|
&& section_is_overlay (bpt->section)
|
1797 |
|
|
&& !section_is_mapped (bpt->section))
|
1798 |
|
|
continue; /* unmapped overlay -- can't be a match */
|
1799 |
|
|
else
|
1800 |
|
|
return 1;
|
1801 |
|
|
}
|
1802 |
|
|
}
|
1803 |
|
|
|
1804 |
|
|
/* Also check for software single-step breakpoints. */
|
1805 |
|
|
if (single_step_breakpoint_inserted_here_p (pc))
|
1806 |
|
|
return 1;
|
1807 |
|
|
|
1808 |
|
|
return 0;
|
1809 |
|
|
}
|
1810 |
|
|
|
1811 |
|
|
/* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
|
1812 |
|
|
PC is valid for process/thread PTID. */
|
1813 |
|
|
|
1814 |
|
|
int
|
1815 |
|
|
breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
|
1816 |
|
|
{
|
1817 |
|
|
const struct bp_location *bpt;
|
1818 |
|
|
int thread;
|
1819 |
|
|
|
1820 |
|
|
thread = pid_to_thread_id (ptid);
|
1821 |
|
|
|
1822 |
|
|
ALL_BP_LOCATIONS (bpt)
|
1823 |
|
|
{
|
1824 |
|
|
if (bpt->loc_type != bp_loc_software_breakpoint
|
1825 |
|
|
&& bpt->loc_type != bp_loc_hardware_breakpoint)
|
1826 |
|
|
continue;
|
1827 |
|
|
|
1828 |
|
|
if ((breakpoint_enabled (bpt->owner)
|
1829 |
|
|
|| bpt->owner->enable_state == bp_permanent)
|
1830 |
|
|
&& bpt->address == pc
|
1831 |
|
|
&& (bpt->owner->thread == -1 || bpt->owner->thread == thread))
|
1832 |
|
|
{
|
1833 |
|
|
if (overlay_debugging
|
1834 |
|
|
&& section_is_overlay (bpt->section)
|
1835 |
|
|
&& !section_is_mapped (bpt->section))
|
1836 |
|
|
continue; /* unmapped overlay -- can't be a match */
|
1837 |
|
|
else
|
1838 |
|
|
return 1;
|
1839 |
|
|
}
|
1840 |
|
|
}
|
1841 |
|
|
|
1842 |
|
|
return 0;
|
1843 |
|
|
}
|
1844 |
|
|
|
1845 |
|
|
|
1846 |
|
|
/* bpstat stuff. External routines' interfaces are documented
|
1847 |
|
|
in breakpoint.h. */
|
1848 |
|
|
|
1849 |
|
|
int
|
1850 |
|
|
ep_is_catchpoint (struct breakpoint *ep)
|
1851 |
|
|
{
|
1852 |
|
|
return
|
1853 |
|
|
(ep->type == bp_catch_load)
|
1854 |
|
|
|| (ep->type == bp_catch_unload)
|
1855 |
|
|
|| (ep->type == bp_catch_fork)
|
1856 |
|
|
|| (ep->type == bp_catch_vfork)
|
1857 |
|
|
|| (ep->type == bp_catch_exec);
|
1858 |
|
|
|
1859 |
|
|
/* ??rehrauer: Add more kinds here, as are implemented... */
|
1860 |
|
|
}
|
1861 |
|
|
|
1862 |
|
|
int
|
1863 |
|
|
ep_is_shlib_catchpoint (struct breakpoint *ep)
|
1864 |
|
|
{
|
1865 |
|
|
return
|
1866 |
|
|
(ep->type == bp_catch_load)
|
1867 |
|
|
|| (ep->type == bp_catch_unload);
|
1868 |
|
|
}
|
1869 |
|
|
|
1870 |
|
|
void
|
1871 |
|
|
bpstat_free (bpstat bs)
|
1872 |
|
|
{
|
1873 |
|
|
if (bs->old_val != NULL)
|
1874 |
|
|
value_free (bs->old_val);
|
1875 |
|
|
free_command_lines (&bs->commands);
|
1876 |
|
|
xfree (bs);
|
1877 |
|
|
}
|
1878 |
|
|
|
1879 |
|
|
/* Clear a bpstat so that it says we are not at any breakpoint.
|
1880 |
|
|
Also free any storage that is part of a bpstat. */
|
1881 |
|
|
|
1882 |
|
|
void
|
1883 |
|
|
bpstat_clear (bpstat *bsp)
|
1884 |
|
|
{
|
1885 |
|
|
bpstat p;
|
1886 |
|
|
bpstat q;
|
1887 |
|
|
|
1888 |
|
|
if (bsp == 0)
|
1889 |
|
|
return;
|
1890 |
|
|
p = *bsp;
|
1891 |
|
|
while (p != NULL)
|
1892 |
|
|
{
|
1893 |
|
|
q = p->next;
|
1894 |
|
|
bpstat_free (p);
|
1895 |
|
|
p = q;
|
1896 |
|
|
}
|
1897 |
|
|
*bsp = NULL;
|
1898 |
|
|
}
|
1899 |
|
|
|
1900 |
|
|
/* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
|
1901 |
|
|
is part of the bpstat is copied as well. */
|
1902 |
|
|
|
1903 |
|
|
bpstat
|
1904 |
|
|
bpstat_copy (bpstat bs)
|
1905 |
|
|
{
|
1906 |
|
|
bpstat p = NULL;
|
1907 |
|
|
bpstat tmp;
|
1908 |
|
|
bpstat retval = NULL;
|
1909 |
|
|
|
1910 |
|
|
if (bs == NULL)
|
1911 |
|
|
return bs;
|
1912 |
|
|
|
1913 |
|
|
for (; bs != NULL; bs = bs->next)
|
1914 |
|
|
{
|
1915 |
|
|
tmp = (bpstat) xmalloc (sizeof (*tmp));
|
1916 |
|
|
memcpy (tmp, bs, sizeof (*tmp));
|
1917 |
|
|
if (bs->commands != NULL)
|
1918 |
|
|
tmp->commands = copy_command_lines (bs->commands);
|
1919 |
|
|
if (bs->old_val != NULL)
|
1920 |
|
|
tmp->old_val = value_copy (bs->old_val);
|
1921 |
|
|
|
1922 |
|
|
if (p == NULL)
|
1923 |
|
|
/* This is the first thing in the chain. */
|
1924 |
|
|
retval = tmp;
|
1925 |
|
|
else
|
1926 |
|
|
p->next = tmp;
|
1927 |
|
|
p = tmp;
|
1928 |
|
|
}
|
1929 |
|
|
p->next = NULL;
|
1930 |
|
|
return retval;
|
1931 |
|
|
}
|
1932 |
|
|
|
1933 |
|
|
/* Find the bpstat associated with this breakpoint */
|
1934 |
|
|
|
1935 |
|
|
bpstat
|
1936 |
|
|
bpstat_find_breakpoint (bpstat bsp, struct breakpoint *breakpoint)
|
1937 |
|
|
{
|
1938 |
|
|
if (bsp == NULL)
|
1939 |
|
|
return NULL;
|
1940 |
|
|
|
1941 |
|
|
for (; bsp != NULL; bsp = bsp->next)
|
1942 |
|
|
{
|
1943 |
|
|
if (bsp->breakpoint_at && bsp->breakpoint_at->owner == breakpoint)
|
1944 |
|
|
return bsp;
|
1945 |
|
|
}
|
1946 |
|
|
return NULL;
|
1947 |
|
|
}
|
1948 |
|
|
|
1949 |
|
|
/* Find a step_resume breakpoint associated with this bpstat.
|
1950 |
|
|
(If there are multiple step_resume bp's on the list, this function
|
1951 |
|
|
will arbitrarily pick one.)
|
1952 |
|
|
|
1953 |
|
|
It is an error to use this function if BPSTAT doesn't contain a
|
1954 |
|
|
step_resume breakpoint.
|
1955 |
|
|
|
1956 |
|
|
See wait_for_inferior's use of this function. */
|
1957 |
|
|
struct breakpoint *
|
1958 |
|
|
bpstat_find_step_resume_breakpoint (bpstat bsp)
|
1959 |
|
|
{
|
1960 |
|
|
int current_thread;
|
1961 |
|
|
|
1962 |
|
|
gdb_assert (bsp != NULL);
|
1963 |
|
|
|
1964 |
|
|
current_thread = pid_to_thread_id (inferior_ptid);
|
1965 |
|
|
|
1966 |
|
|
for (; bsp != NULL; bsp = bsp->next)
|
1967 |
|
|
{
|
1968 |
|
|
if ((bsp->breakpoint_at != NULL) &&
|
1969 |
|
|
(bsp->breakpoint_at->owner->type == bp_step_resume) &&
|
1970 |
|
|
(bsp->breakpoint_at->owner->thread == current_thread ||
|
1971 |
|
|
bsp->breakpoint_at->owner->thread == -1))
|
1972 |
|
|
return bsp->breakpoint_at->owner;
|
1973 |
|
|
}
|
1974 |
|
|
|
1975 |
|
|
internal_error (__FILE__, __LINE__, _("No step_resume breakpoint found."));
|
1976 |
|
|
}
|
1977 |
|
|
|
1978 |
|
|
|
1979 |
|
|
/* Put in *NUM the breakpoint number of the first breakpoint we are stopped
|
1980 |
|
|
at. *BSP upon return is a bpstat which points to the remaining
|
1981 |
|
|
breakpoints stopped at (but which is not guaranteed to be good for
|
1982 |
|
|
anything but further calls to bpstat_num).
|
1983 |
|
|
Return 0 if passed a bpstat which does not indicate any breakpoints.
|
1984 |
|
|
Return -1 if stopped at a breakpoint that has been deleted since
|
1985 |
|
|
we set it.
|
1986 |
|
|
Return 1 otherwise. */
|
1987 |
|
|
|
1988 |
|
|
int
|
1989 |
|
|
bpstat_num (bpstat *bsp, int *num)
|
1990 |
|
|
{
|
1991 |
|
|
struct breakpoint *b;
|
1992 |
|
|
|
1993 |
|
|
if ((*bsp) == NULL)
|
1994 |
|
|
return 0; /* No more breakpoint values */
|
1995 |
|
|
|
1996 |
|
|
/* We assume we'll never have several bpstats that
|
1997 |
|
|
correspond to a single breakpoint -- otherwise,
|
1998 |
|
|
this function might return the same number more
|
1999 |
|
|
than once and this will look ugly. */
|
2000 |
|
|
b = (*bsp)->breakpoint_at ? (*bsp)->breakpoint_at->owner : NULL;
|
2001 |
|
|
*bsp = (*bsp)->next;
|
2002 |
|
|
if (b == NULL)
|
2003 |
|
|
return -1; /* breakpoint that's been deleted since */
|
2004 |
|
|
|
2005 |
|
|
*num = b->number; /* We have its number */
|
2006 |
|
|
return 1;
|
2007 |
|
|
}
|
2008 |
|
|
|
2009 |
|
|
/* Modify BS so that the actions will not be performed. */
|
2010 |
|
|
|
2011 |
|
|
void
|
2012 |
|
|
bpstat_clear_actions (bpstat bs)
|
2013 |
|
|
{
|
2014 |
|
|
for (; bs != NULL; bs = bs->next)
|
2015 |
|
|
{
|
2016 |
|
|
free_command_lines (&bs->commands);
|
2017 |
|
|
if (bs->old_val != NULL)
|
2018 |
|
|
{
|
2019 |
|
|
value_free (bs->old_val);
|
2020 |
|
|
bs->old_val = NULL;
|
2021 |
|
|
}
|
2022 |
|
|
}
|
2023 |
|
|
}
|
2024 |
|
|
|
2025 |
|
|
/* Stub for cleaning up our state if we error-out of a breakpoint command */
|
2026 |
|
|
static void
|
2027 |
|
|
cleanup_executing_breakpoints (void *ignore)
|
2028 |
|
|
{
|
2029 |
|
|
executing_breakpoint_commands = 0;
|
2030 |
|
|
}
|
2031 |
|
|
|
2032 |
|
|
/* Execute all the commands associated with all the breakpoints at this
|
2033 |
|
|
location. Any of these commands could cause the process to proceed
|
2034 |
|
|
beyond this point, etc. We look out for such changes by checking
|
2035 |
|
|
the global "breakpoint_proceeded" after each command. */
|
2036 |
|
|
|
2037 |
|
|
void
|
2038 |
|
|
bpstat_do_actions (bpstat *bsp)
|
2039 |
|
|
{
|
2040 |
|
|
bpstat bs;
|
2041 |
|
|
struct cleanup *old_chain;
|
2042 |
|
|
|
2043 |
|
|
/* Avoid endless recursion if a `source' command is contained
|
2044 |
|
|
in bs->commands. */
|
2045 |
|
|
if (executing_breakpoint_commands)
|
2046 |
|
|
return;
|
2047 |
|
|
|
2048 |
|
|
executing_breakpoint_commands = 1;
|
2049 |
|
|
old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
|
2050 |
|
|
|
2051 |
|
|
top:
|
2052 |
|
|
/* Note that (as of this writing), our callers all appear to
|
2053 |
|
|
be passing us the address of global stop_bpstat. And, if
|
2054 |
|
|
our calls to execute_control_command cause the inferior to
|
2055 |
|
|
proceed, that global (and hence, *bsp) will change.
|
2056 |
|
|
|
2057 |
|
|
We must be careful to not touch *bsp unless the inferior
|
2058 |
|
|
has not proceeded. */
|
2059 |
|
|
|
2060 |
|
|
/* This pointer will iterate over the list of bpstat's. */
|
2061 |
|
|
bs = *bsp;
|
2062 |
|
|
|
2063 |
|
|
breakpoint_proceeded = 0;
|
2064 |
|
|
for (; bs != NULL; bs = bs->next)
|
2065 |
|
|
{
|
2066 |
|
|
struct command_line *cmd;
|
2067 |
|
|
struct cleanup *this_cmd_tree_chain;
|
2068 |
|
|
|
2069 |
|
|
/* Take ownership of the BSP's command tree, if it has one.
|
2070 |
|
|
|
2071 |
|
|
The command tree could legitimately contain commands like
|
2072 |
|
|
'step' and 'next', which call clear_proceed_status, which
|
2073 |
|
|
frees stop_bpstat's command tree. To make sure this doesn't
|
2074 |
|
|
free the tree we're executing out from under us, we need to
|
2075 |
|
|
take ownership of the tree ourselves. Since a given bpstat's
|
2076 |
|
|
commands are only executed once, we don't need to copy it; we
|
2077 |
|
|
can clear the pointer in the bpstat, and make sure we free
|
2078 |
|
|
the tree when we're done. */
|
2079 |
|
|
cmd = bs->commands;
|
2080 |
|
|
bs->commands = 0;
|
2081 |
|
|
this_cmd_tree_chain = make_cleanup_free_command_lines (&cmd);
|
2082 |
|
|
|
2083 |
|
|
while (cmd != NULL)
|
2084 |
|
|
{
|
2085 |
|
|
execute_control_command (cmd);
|
2086 |
|
|
|
2087 |
|
|
if (breakpoint_proceeded)
|
2088 |
|
|
break;
|
2089 |
|
|
else
|
2090 |
|
|
cmd = cmd->next;
|
2091 |
|
|
}
|
2092 |
|
|
|
2093 |
|
|
/* We can free this command tree now. */
|
2094 |
|
|
do_cleanups (this_cmd_tree_chain);
|
2095 |
|
|
|
2096 |
|
|
if (breakpoint_proceeded)
|
2097 |
|
|
/* The inferior is proceeded by the command; bomb out now.
|
2098 |
|
|
The bpstat chain has been blown away by wait_for_inferior.
|
2099 |
|
|
But since execution has stopped again, there is a new bpstat
|
2100 |
|
|
to look at, so start over. */
|
2101 |
|
|
goto top;
|
2102 |
|
|
}
|
2103 |
|
|
do_cleanups (old_chain);
|
2104 |
|
|
}
|
2105 |
|
|
|
2106 |
|
|
/* This is the normal print function for a bpstat. In the future,
|
2107 |
|
|
much of this logic could (should?) be moved to bpstat_stop_status,
|
2108 |
|
|
by having it set different print_it values.
|
2109 |
|
|
|
2110 |
|
|
Current scheme: When we stop, bpstat_print() is called. It loops
|
2111 |
|
|
through the bpstat list of things causing this stop, calling the
|
2112 |
|
|
print_bp_stop_message function on each one. The behavior of the
|
2113 |
|
|
print_bp_stop_message function depends on the print_it field of
|
2114 |
|
|
bpstat. If such field so indicates, call this function here.
|
2115 |
|
|
|
2116 |
|
|
Return values from this routine (ultimately used by bpstat_print()
|
2117 |
|
|
and normal_stop() to decide what to do):
|
2118 |
|
|
PRINT_NOTHING: Means we already printed all we needed to print,
|
2119 |
|
|
don't print anything else.
|
2120 |
|
|
PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
|
2121 |
|
|
that something to be followed by a location.
|
2122 |
|
|
PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
|
2123 |
|
|
that something to be followed by a location.
|
2124 |
|
|
PRINT_UNKNOWN: Means we printed nothing or we need to do some more
|
2125 |
|
|
analysis. */
|
2126 |
|
|
|
2127 |
|
|
static enum print_stop_action
|
2128 |
|
|
print_it_typical (bpstat bs)
|
2129 |
|
|
{
|
2130 |
|
|
struct cleanup *old_chain, *ui_out_chain;
|
2131 |
|
|
struct breakpoint *b;
|
2132 |
|
|
const struct bp_location *bl;
|
2133 |
|
|
struct ui_stream *stb;
|
2134 |
|
|
stb = ui_out_stream_new (uiout);
|
2135 |
|
|
old_chain = make_cleanup_ui_out_stream_delete (stb);
|
2136 |
|
|
/* bs->breakpoint_at can be NULL if it was a momentary breakpoint
|
2137 |
|
|
which has since been deleted. */
|
2138 |
|
|
if (bs->breakpoint_at == NULL)
|
2139 |
|
|
return PRINT_UNKNOWN;
|
2140 |
|
|
bl = bs->breakpoint_at;
|
2141 |
|
|
b = bl->owner;
|
2142 |
|
|
|
2143 |
|
|
switch (b->type)
|
2144 |
|
|
{
|
2145 |
|
|
case bp_breakpoint:
|
2146 |
|
|
case bp_hardware_breakpoint:
|
2147 |
|
|
if (bl->address != bl->requested_address)
|
2148 |
|
|
breakpoint_adjustment_warning (bl->requested_address,
|
2149 |
|
|
bl->address,
|
2150 |
|
|
b->number, 1);
|
2151 |
|
|
annotate_breakpoint (b->number);
|
2152 |
|
|
ui_out_text (uiout, "\nBreakpoint ");
|
2153 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2154 |
|
|
ui_out_field_string (uiout, "reason",
|
2155 |
|
|
async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
|
2156 |
|
|
ui_out_field_int (uiout, "bkptno", b->number);
|
2157 |
|
|
ui_out_text (uiout, ", ");
|
2158 |
|
|
return PRINT_SRC_AND_LOC;
|
2159 |
|
|
break;
|
2160 |
|
|
|
2161 |
|
|
case bp_shlib_event:
|
2162 |
|
|
/* Did we stop because the user set the stop_on_solib_events
|
2163 |
|
|
variable? (If so, we report this as a generic, "Stopped due
|
2164 |
|
|
to shlib event" message.) */
|
2165 |
|
|
printf_filtered (_("Stopped due to shared library event\n"));
|
2166 |
|
|
return PRINT_NOTHING;
|
2167 |
|
|
break;
|
2168 |
|
|
|
2169 |
|
|
case bp_thread_event:
|
2170 |
|
|
/* Not sure how we will get here.
|
2171 |
|
|
GDB should not stop for these breakpoints. */
|
2172 |
|
|
printf_filtered (_("Thread Event Breakpoint: gdb should not stop!\n"));
|
2173 |
|
|
return PRINT_NOTHING;
|
2174 |
|
|
break;
|
2175 |
|
|
|
2176 |
|
|
case bp_overlay_event:
|
2177 |
|
|
/* By analogy with the thread event, GDB should not stop for these. */
|
2178 |
|
|
printf_filtered (_("Overlay Event Breakpoint: gdb should not stop!\n"));
|
2179 |
|
|
return PRINT_NOTHING;
|
2180 |
|
|
break;
|
2181 |
|
|
|
2182 |
|
|
case bp_catch_load:
|
2183 |
|
|
annotate_catchpoint (b->number);
|
2184 |
|
|
printf_filtered (_("\nCatchpoint %d (loaded %s), "),
|
2185 |
|
|
b->number,
|
2186 |
|
|
b->triggered_dll_pathname);
|
2187 |
|
|
return PRINT_SRC_AND_LOC;
|
2188 |
|
|
break;
|
2189 |
|
|
|
2190 |
|
|
case bp_catch_unload:
|
2191 |
|
|
annotate_catchpoint (b->number);
|
2192 |
|
|
printf_filtered (_("\nCatchpoint %d (unloaded %s), "),
|
2193 |
|
|
b->number,
|
2194 |
|
|
b->triggered_dll_pathname);
|
2195 |
|
|
return PRINT_SRC_AND_LOC;
|
2196 |
|
|
break;
|
2197 |
|
|
|
2198 |
|
|
case bp_catch_fork:
|
2199 |
|
|
annotate_catchpoint (b->number);
|
2200 |
|
|
printf_filtered (_("\nCatchpoint %d (forked process %d), "),
|
2201 |
|
|
b->number,
|
2202 |
|
|
b->forked_inferior_pid);
|
2203 |
|
|
return PRINT_SRC_AND_LOC;
|
2204 |
|
|
break;
|
2205 |
|
|
|
2206 |
|
|
case bp_catch_vfork:
|
2207 |
|
|
annotate_catchpoint (b->number);
|
2208 |
|
|
printf_filtered (_("\nCatchpoint %d (vforked process %d), "),
|
2209 |
|
|
b->number,
|
2210 |
|
|
b->forked_inferior_pid);
|
2211 |
|
|
return PRINT_SRC_AND_LOC;
|
2212 |
|
|
break;
|
2213 |
|
|
|
2214 |
|
|
case bp_catch_exec:
|
2215 |
|
|
annotate_catchpoint (b->number);
|
2216 |
|
|
printf_filtered (_("\nCatchpoint %d (exec'd %s), "),
|
2217 |
|
|
b->number,
|
2218 |
|
|
b->exec_pathname);
|
2219 |
|
|
return PRINT_SRC_AND_LOC;
|
2220 |
|
|
break;
|
2221 |
|
|
|
2222 |
|
|
case bp_watchpoint:
|
2223 |
|
|
case bp_hardware_watchpoint:
|
2224 |
|
|
if (bs->old_val != NULL)
|
2225 |
|
|
{
|
2226 |
|
|
annotate_watchpoint (b->number);
|
2227 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2228 |
|
|
ui_out_field_string
|
2229 |
|
|
(uiout, "reason",
|
2230 |
|
|
async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
|
2231 |
|
|
mention (b);
|
2232 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
|
2233 |
|
|
ui_out_text (uiout, "\nOld value = ");
|
2234 |
|
|
value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
|
2235 |
|
|
ui_out_field_stream (uiout, "old", stb);
|
2236 |
|
|
ui_out_text (uiout, "\nNew value = ");
|
2237 |
|
|
value_print (b->val, stb->stream, 0, Val_pretty_default);
|
2238 |
|
|
ui_out_field_stream (uiout, "new", stb);
|
2239 |
|
|
do_cleanups (ui_out_chain);
|
2240 |
|
|
ui_out_text (uiout, "\n");
|
2241 |
|
|
value_free (bs->old_val);
|
2242 |
|
|
bs->old_val = NULL;
|
2243 |
|
|
}
|
2244 |
|
|
/* More than one watchpoint may have been triggered. */
|
2245 |
|
|
return PRINT_UNKNOWN;
|
2246 |
|
|
break;
|
2247 |
|
|
|
2248 |
|
|
case bp_read_watchpoint:
|
2249 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2250 |
|
|
ui_out_field_string
|
2251 |
|
|
(uiout, "reason",
|
2252 |
|
|
async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
|
2253 |
|
|
mention (b);
|
2254 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
|
2255 |
|
|
ui_out_text (uiout, "\nValue = ");
|
2256 |
|
|
value_print (b->val, stb->stream, 0, Val_pretty_default);
|
2257 |
|
|
ui_out_field_stream (uiout, "value", stb);
|
2258 |
|
|
do_cleanups (ui_out_chain);
|
2259 |
|
|
ui_out_text (uiout, "\n");
|
2260 |
|
|
return PRINT_UNKNOWN;
|
2261 |
|
|
break;
|
2262 |
|
|
|
2263 |
|
|
case bp_access_watchpoint:
|
2264 |
|
|
if (bs->old_val != NULL)
|
2265 |
|
|
{
|
2266 |
|
|
annotate_watchpoint (b->number);
|
2267 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2268 |
|
|
ui_out_field_string
|
2269 |
|
|
(uiout, "reason",
|
2270 |
|
|
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
|
2271 |
|
|
mention (b);
|
2272 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
|
2273 |
|
|
ui_out_text (uiout, "\nOld value = ");
|
2274 |
|
|
value_print (bs->old_val, stb->stream, 0, Val_pretty_default);
|
2275 |
|
|
ui_out_field_stream (uiout, "old", stb);
|
2276 |
|
|
value_free (bs->old_val);
|
2277 |
|
|
bs->old_val = NULL;
|
2278 |
|
|
ui_out_text (uiout, "\nNew value = ");
|
2279 |
|
|
}
|
2280 |
|
|
else
|
2281 |
|
|
{
|
2282 |
|
|
mention (b);
|
2283 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2284 |
|
|
ui_out_field_string
|
2285 |
|
|
(uiout, "reason",
|
2286 |
|
|
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
|
2287 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
|
2288 |
|
|
ui_out_text (uiout, "\nValue = ");
|
2289 |
|
|
}
|
2290 |
|
|
value_print (b->val, stb->stream, 0,Val_pretty_default);
|
2291 |
|
|
ui_out_field_stream (uiout, "new", stb);
|
2292 |
|
|
do_cleanups (ui_out_chain);
|
2293 |
|
|
ui_out_text (uiout, "\n");
|
2294 |
|
|
return PRINT_UNKNOWN;
|
2295 |
|
|
break;
|
2296 |
|
|
|
2297 |
|
|
/* Fall through, we don't deal with these types of breakpoints
|
2298 |
|
|
here. */
|
2299 |
|
|
|
2300 |
|
|
case bp_finish:
|
2301 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2302 |
|
|
ui_out_field_string
|
2303 |
|
|
(uiout, "reason",
|
2304 |
|
|
async_reason_lookup (EXEC_ASYNC_FUNCTION_FINISHED));
|
2305 |
|
|
return PRINT_UNKNOWN;
|
2306 |
|
|
break;
|
2307 |
|
|
|
2308 |
|
|
case bp_until:
|
2309 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2310 |
|
|
ui_out_field_string
|
2311 |
|
|
(uiout, "reason",
|
2312 |
|
|
async_reason_lookup (EXEC_ASYNC_LOCATION_REACHED));
|
2313 |
|
|
return PRINT_UNKNOWN;
|
2314 |
|
|
break;
|
2315 |
|
|
|
2316 |
|
|
case bp_none:
|
2317 |
|
|
case bp_longjmp:
|
2318 |
|
|
case bp_longjmp_resume:
|
2319 |
|
|
case bp_step_resume:
|
2320 |
|
|
case bp_watchpoint_scope:
|
2321 |
|
|
case bp_call_dummy:
|
2322 |
|
|
default:
|
2323 |
|
|
return PRINT_UNKNOWN;
|
2324 |
|
|
}
|
2325 |
|
|
}
|
2326 |
|
|
|
2327 |
|
|
/* Generic routine for printing messages indicating why we
|
2328 |
|
|
stopped. The behavior of this function depends on the value
|
2329 |
|
|
'print_it' in the bpstat structure. Under some circumstances we
|
2330 |
|
|
may decide not to print anything here and delegate the task to
|
2331 |
|
|
normal_stop(). */
|
2332 |
|
|
|
2333 |
|
|
static enum print_stop_action
|
2334 |
|
|
print_bp_stop_message (bpstat bs)
|
2335 |
|
|
{
|
2336 |
|
|
switch (bs->print_it)
|
2337 |
|
|
{
|
2338 |
|
|
case print_it_noop:
|
2339 |
|
|
/* Nothing should be printed for this bpstat entry. */
|
2340 |
|
|
return PRINT_UNKNOWN;
|
2341 |
|
|
break;
|
2342 |
|
|
|
2343 |
|
|
case print_it_done:
|
2344 |
|
|
/* We still want to print the frame, but we already printed the
|
2345 |
|
|
relevant messages. */
|
2346 |
|
|
return PRINT_SRC_AND_LOC;
|
2347 |
|
|
break;
|
2348 |
|
|
|
2349 |
|
|
case print_it_normal:
|
2350 |
|
|
{
|
2351 |
|
|
const struct bp_location *bl = bs->breakpoint_at;
|
2352 |
|
|
struct breakpoint *b = bl ? bl->owner : NULL;
|
2353 |
|
|
|
2354 |
|
|
/* Normal case. Call the breakpoint's print_it method, or
|
2355 |
|
|
print_it_typical. */
|
2356 |
|
|
/* FIXME: how breakpoint can ever be NULL here? */
|
2357 |
|
|
if (b != NULL && b->ops != NULL && b->ops->print_it != NULL)
|
2358 |
|
|
return b->ops->print_it (b);
|
2359 |
|
|
else
|
2360 |
|
|
return print_it_typical (bs);
|
2361 |
|
|
}
|
2362 |
|
|
break;
|
2363 |
|
|
|
2364 |
|
|
default:
|
2365 |
|
|
internal_error (__FILE__, __LINE__,
|
2366 |
|
|
_("print_bp_stop_message: unrecognized enum value"));
|
2367 |
|
|
break;
|
2368 |
|
|
}
|
2369 |
|
|
}
|
2370 |
|
|
|
2371 |
|
|
/* Print a message indicating what happened. This is called from
|
2372 |
|
|
normal_stop(). The input to this routine is the head of the bpstat
|
2373 |
|
|
list - a list of the eventpoints that caused this stop. This
|
2374 |
|
|
routine calls the generic print routine for printing a message
|
2375 |
|
|
about reasons for stopping. This will print (for example) the
|
2376 |
|
|
"Breakpoint n," part of the output. The return value of this
|
2377 |
|
|
routine is one of:
|
2378 |
|
|
|
2379 |
|
|
PRINT_UNKNOWN: Means we printed nothing
|
2380 |
|
|
PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
|
2381 |
|
|
code to print the location. An example is
|
2382 |
|
|
"Breakpoint 1, " which should be followed by
|
2383 |
|
|
the location.
|
2384 |
|
|
PRINT_SRC_ONLY: Means we printed something, but there is no need
|
2385 |
|
|
to also print the location part of the message.
|
2386 |
|
|
An example is the catch/throw messages, which
|
2387 |
|
|
don't require a location appended to the end.
|
2388 |
|
|
PRINT_NOTHING: We have done some printing and we don't need any
|
2389 |
|
|
further info to be printed.*/
|
2390 |
|
|
|
2391 |
|
|
enum print_stop_action
|
2392 |
|
|
bpstat_print (bpstat bs)
|
2393 |
|
|
{
|
2394 |
|
|
int val;
|
2395 |
|
|
|
2396 |
|
|
/* Maybe another breakpoint in the chain caused us to stop.
|
2397 |
|
|
(Currently all watchpoints go on the bpstat whether hit or not.
|
2398 |
|
|
That probably could (should) be changed, provided care is taken
|
2399 |
|
|
with respect to bpstat_explains_signal). */
|
2400 |
|
|
for (; bs; bs = bs->next)
|
2401 |
|
|
{
|
2402 |
|
|
val = print_bp_stop_message (bs);
|
2403 |
|
|
if (val == PRINT_SRC_ONLY
|
2404 |
|
|
|| val == PRINT_SRC_AND_LOC
|
2405 |
|
|
|| val == PRINT_NOTHING)
|
2406 |
|
|
return val;
|
2407 |
|
|
}
|
2408 |
|
|
|
2409 |
|
|
/* We reached the end of the chain, or we got a null BS to start
|
2410 |
|
|
with and nothing was printed. */
|
2411 |
|
|
return PRINT_UNKNOWN;
|
2412 |
|
|
}
|
2413 |
|
|
|
2414 |
|
|
/* Evaluate the expression EXP and return 1 if value is zero.
|
2415 |
|
|
This is used inside a catch_errors to evaluate the breakpoint condition.
|
2416 |
|
|
The argument is a "struct expression *" that has been cast to char * to
|
2417 |
|
|
make it pass through catch_errors. */
|
2418 |
|
|
|
2419 |
|
|
static int
|
2420 |
|
|
breakpoint_cond_eval (void *exp)
|
2421 |
|
|
{
|
2422 |
|
|
struct value *mark = value_mark ();
|
2423 |
|
|
int i = !value_true (evaluate_expression ((struct expression *) exp));
|
2424 |
|
|
value_free_to_mark (mark);
|
2425 |
|
|
return i;
|
2426 |
|
|
}
|
2427 |
|
|
|
2428 |
|
|
/* Allocate a new bpstat and chain it to the current one. */
|
2429 |
|
|
|
2430 |
|
|
static bpstat
|
2431 |
|
|
bpstat_alloc (const struct bp_location *bl, bpstat cbs /* Current "bs" value */ )
|
2432 |
|
|
{
|
2433 |
|
|
bpstat bs;
|
2434 |
|
|
|
2435 |
|
|
bs = (bpstat) xmalloc (sizeof (*bs));
|
2436 |
|
|
cbs->next = bs;
|
2437 |
|
|
bs->breakpoint_at = bl;
|
2438 |
|
|
/* If the condition is false, etc., don't do the commands. */
|
2439 |
|
|
bs->commands = NULL;
|
2440 |
|
|
bs->old_val = NULL;
|
2441 |
|
|
bs->print_it = print_it_normal;
|
2442 |
|
|
return bs;
|
2443 |
|
|
}
|
2444 |
|
|
|
2445 |
|
|
/* The target has stopped with waitstatus WS. Check if any hardware
|
2446 |
|
|
watchpoints have triggered, according to the target. */
|
2447 |
|
|
|
2448 |
|
|
int
|
2449 |
|
|
watchpoints_triggered (struct target_waitstatus *ws)
|
2450 |
|
|
{
|
2451 |
|
|
int stopped_by_watchpoint = STOPPED_BY_WATCHPOINT (*ws);
|
2452 |
|
|
CORE_ADDR addr;
|
2453 |
|
|
struct breakpoint *b;
|
2454 |
|
|
|
2455 |
|
|
if (!stopped_by_watchpoint)
|
2456 |
|
|
{
|
2457 |
|
|
/* We were not stopped by a watchpoint. Mark all watchpoints
|
2458 |
|
|
as not triggered. */
|
2459 |
|
|
ALL_BREAKPOINTS (b)
|
2460 |
|
|
if (b->type == bp_hardware_watchpoint
|
2461 |
|
|
|| b->type == bp_read_watchpoint
|
2462 |
|
|
|| b->type == bp_access_watchpoint)
|
2463 |
|
|
b->watchpoint_triggered = watch_triggered_no;
|
2464 |
|
|
|
2465 |
|
|
return 0;
|
2466 |
|
|
}
|
2467 |
|
|
|
2468 |
|
|
if (!target_stopped_data_address (¤t_target, &addr))
|
2469 |
|
|
{
|
2470 |
|
|
/* We were stopped by a watchpoint, but we don't know where.
|
2471 |
|
|
Mark all watchpoints as unknown. */
|
2472 |
|
|
ALL_BREAKPOINTS (b)
|
2473 |
|
|
if (b->type == bp_hardware_watchpoint
|
2474 |
|
|
|| b->type == bp_read_watchpoint
|
2475 |
|
|
|| b->type == bp_access_watchpoint)
|
2476 |
|
|
b->watchpoint_triggered = watch_triggered_unknown;
|
2477 |
|
|
|
2478 |
|
|
return stopped_by_watchpoint;
|
2479 |
|
|
}
|
2480 |
|
|
|
2481 |
|
|
/* The target could report the data address. Mark watchpoints
|
2482 |
|
|
affected by this data address as triggered, and all others as not
|
2483 |
|
|
triggered. */
|
2484 |
|
|
|
2485 |
|
|
ALL_BREAKPOINTS (b)
|
2486 |
|
|
if (b->type == bp_hardware_watchpoint
|
2487 |
|
|
|| b->type == bp_read_watchpoint
|
2488 |
|
|
|| b->type == bp_access_watchpoint)
|
2489 |
|
|
{
|
2490 |
|
|
struct bp_location *loc;
|
2491 |
|
|
struct value *v;
|
2492 |
|
|
|
2493 |
|
|
b->watchpoint_triggered = watch_triggered_no;
|
2494 |
|
|
for (loc = b->loc; loc; loc = loc->next)
|
2495 |
|
|
/* Exact match not required. Within range is
|
2496 |
|
|
sufficient. */
|
2497 |
|
|
if (addr >= loc->address
|
2498 |
|
|
&& addr < loc->address + loc->length)
|
2499 |
|
|
{
|
2500 |
|
|
b->watchpoint_triggered = watch_triggered_yes;
|
2501 |
|
|
break;
|
2502 |
|
|
}
|
2503 |
|
|
}
|
2504 |
|
|
|
2505 |
|
|
return 1;
|
2506 |
|
|
}
|
2507 |
|
|
|
2508 |
|
|
/* Possible return values for watchpoint_check (this can't be an enum
|
2509 |
|
|
because of check_errors). */
|
2510 |
|
|
/* The watchpoint has been deleted. */
|
2511 |
|
|
#define WP_DELETED 1
|
2512 |
|
|
/* The value has changed. */
|
2513 |
|
|
#define WP_VALUE_CHANGED 2
|
2514 |
|
|
/* The value has not changed. */
|
2515 |
|
|
#define WP_VALUE_NOT_CHANGED 3
|
2516 |
|
|
|
2517 |
|
|
#define BP_TEMPFLAG 1
|
2518 |
|
|
#define BP_HARDWAREFLAG 2
|
2519 |
|
|
|
2520 |
|
|
/* Check watchpoint condition. */
|
2521 |
|
|
|
2522 |
|
|
static int
|
2523 |
|
|
watchpoint_check (void *p)
|
2524 |
|
|
{
|
2525 |
|
|
bpstat bs = (bpstat) p;
|
2526 |
|
|
struct breakpoint *b;
|
2527 |
|
|
struct frame_info *fr;
|
2528 |
|
|
int within_current_scope;
|
2529 |
|
|
|
2530 |
|
|
b = bs->breakpoint_at->owner;
|
2531 |
|
|
|
2532 |
|
|
if (b->exp_valid_block == NULL)
|
2533 |
|
|
within_current_scope = 1;
|
2534 |
|
|
else
|
2535 |
|
|
{
|
2536 |
|
|
/* There is no current frame at this moment. If we're going to have
|
2537 |
|
|
any chance of handling watchpoints on local variables, we'll need
|
2538 |
|
|
the frame chain (so we can determine if we're in scope). */
|
2539 |
|
|
reinit_frame_cache ();
|
2540 |
|
|
fr = frame_find_by_id (b->watchpoint_frame);
|
2541 |
|
|
within_current_scope = (fr != NULL);
|
2542 |
|
|
|
2543 |
|
|
/* If we've gotten confused in the unwinder, we might have
|
2544 |
|
|
returned a frame that can't describe this variable. */
|
2545 |
|
|
if (within_current_scope
|
2546 |
|
|
&& block_function (b->exp_valid_block) != get_frame_function (fr))
|
2547 |
|
|
within_current_scope = 0;
|
2548 |
|
|
|
2549 |
|
|
/* in_function_epilogue_p() returns a non-zero value if we're still
|
2550 |
|
|
in the function but the stack frame has already been invalidated.
|
2551 |
|
|
Since we can't rely on the values of local variables after the
|
2552 |
|
|
stack has been destroyed, we are treating the watchpoint in that
|
2553 |
|
|
state as `not changed' without further checking.
|
2554 |
|
|
|
2555 |
|
|
vinschen/2003-09-04: The former implementation left out the case
|
2556 |
|
|
that the watchpoint frame couldn't be found by frame_find_by_id()
|
2557 |
|
|
because the current PC is currently in an epilogue. Calling
|
2558 |
|
|
gdbarch_in_function_epilogue_p() also when fr == NULL fixes that. */
|
2559 |
|
|
if ((!within_current_scope || fr == get_current_frame ())
|
2560 |
|
|
&& gdbarch_in_function_epilogue_p (current_gdbarch, read_pc ()))
|
2561 |
|
|
return WP_VALUE_NOT_CHANGED;
|
2562 |
|
|
if (fr && within_current_scope)
|
2563 |
|
|
/* If we end up stopping, the current frame will get selected
|
2564 |
|
|
in normal_stop. So this call to select_frame won't affect
|
2565 |
|
|
the user. */
|
2566 |
|
|
select_frame (fr);
|
2567 |
|
|
}
|
2568 |
|
|
|
2569 |
|
|
if (within_current_scope)
|
2570 |
|
|
{
|
2571 |
|
|
/* We use value_{,free_to_}mark because it could be a
|
2572 |
|
|
*long* time before we return to the command level and
|
2573 |
|
|
call free_all_values. We can't call free_all_values because
|
2574 |
|
|
we might be in the middle of evaluating a function call. */
|
2575 |
|
|
|
2576 |
|
|
struct value *mark = value_mark ();
|
2577 |
|
|
struct value *new_val = evaluate_expression (b->exp);
|
2578 |
|
|
if (!value_equal (b->val, new_val))
|
2579 |
|
|
{
|
2580 |
|
|
release_value (new_val);
|
2581 |
|
|
value_free_to_mark (mark);
|
2582 |
|
|
bs->old_val = b->val;
|
2583 |
|
|
b->val = new_val;
|
2584 |
|
|
/* We will stop here */
|
2585 |
|
|
return WP_VALUE_CHANGED;
|
2586 |
|
|
}
|
2587 |
|
|
else
|
2588 |
|
|
{
|
2589 |
|
|
/* Nothing changed, don't do anything. */
|
2590 |
|
|
value_free_to_mark (mark);
|
2591 |
|
|
/* We won't stop here */
|
2592 |
|
|
return WP_VALUE_NOT_CHANGED;
|
2593 |
|
|
}
|
2594 |
|
|
}
|
2595 |
|
|
else
|
2596 |
|
|
{
|
2597 |
|
|
/* This seems like the only logical thing to do because
|
2598 |
|
|
if we temporarily ignored the watchpoint, then when
|
2599 |
|
|
we reenter the block in which it is valid it contains
|
2600 |
|
|
garbage (in the case of a function, it may have two
|
2601 |
|
|
garbage values, one before and one after the prologue).
|
2602 |
|
|
So we can't even detect the first assignment to it and
|
2603 |
|
|
watch after that (since the garbage may or may not equal
|
2604 |
|
|
the first value assigned). */
|
2605 |
|
|
/* We print all the stop information in print_it_typical(), but
|
2606 |
|
|
in this case, by the time we call print_it_typical() this bp
|
2607 |
|
|
will be deleted already. So we have no choice but print the
|
2608 |
|
|
information here. */
|
2609 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
2610 |
|
|
ui_out_field_string
|
2611 |
|
|
(uiout, "reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE));
|
2612 |
|
|
ui_out_text (uiout, "\nWatchpoint ");
|
2613 |
|
|
ui_out_field_int (uiout, "wpnum", b->number);
|
2614 |
|
|
ui_out_text (uiout, " deleted because the program has left the block in\n\
|
2615 |
|
|
which its expression is valid.\n");
|
2616 |
|
|
|
2617 |
|
|
if (b->related_breakpoint)
|
2618 |
|
|
b->related_breakpoint->disposition = disp_del_at_next_stop;
|
2619 |
|
|
b->disposition = disp_del_at_next_stop;
|
2620 |
|
|
|
2621 |
|
|
return WP_DELETED;
|
2622 |
|
|
}
|
2623 |
|
|
}
|
2624 |
|
|
|
2625 |
|
|
/* Get a bpstat associated with having just stopped at address
|
2626 |
|
|
BP_ADDR in thread PTID.
|
2627 |
|
|
|
2628 |
|
|
Determine whether we stopped at a breakpoint, etc, or whether we
|
2629 |
|
|
don't understand this stop. Result is a chain of bpstat's such that:
|
2630 |
|
|
|
2631 |
|
|
if we don't understand the stop, the result is a null pointer.
|
2632 |
|
|
|
2633 |
|
|
if we understand why we stopped, the result is not null.
|
2634 |
|
|
|
2635 |
|
|
Each element of the chain refers to a particular breakpoint or
|
2636 |
|
|
watchpoint at which we have stopped. (We may have stopped for
|
2637 |
|
|
several reasons concurrently.)
|
2638 |
|
|
|
2639 |
|
|
Each element of the chain has valid next, breakpoint_at,
|
2640 |
|
|
commands, FIXME??? fields. */
|
2641 |
|
|
|
2642 |
|
|
bpstat
|
2643 |
|
|
bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid)
|
2644 |
|
|
{
|
2645 |
|
|
struct breakpoint *b = NULL;
|
2646 |
|
|
const struct bp_location *bl;
|
2647 |
|
|
/* Root of the chain of bpstat's */
|
2648 |
|
|
struct bpstats root_bs[1];
|
2649 |
|
|
/* Pointer to the last thing in the chain currently. */
|
2650 |
|
|
bpstat bs = root_bs;
|
2651 |
|
|
int thread_id = pid_to_thread_id (ptid);
|
2652 |
|
|
|
2653 |
|
|
ALL_BP_LOCATIONS (bl)
|
2654 |
|
|
{
|
2655 |
|
|
b = bl->owner;
|
2656 |
|
|
gdb_assert (b);
|
2657 |
|
|
if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)
|
2658 |
|
|
continue;
|
2659 |
|
|
|
2660 |
|
|
if (b->type != bp_watchpoint
|
2661 |
|
|
&& b->type != bp_hardware_watchpoint
|
2662 |
|
|
&& b->type != bp_read_watchpoint
|
2663 |
|
|
&& b->type != bp_access_watchpoint
|
2664 |
|
|
&& b->type != bp_hardware_breakpoint
|
2665 |
|
|
&& b->type != bp_catch_fork
|
2666 |
|
|
&& b->type != bp_catch_vfork
|
2667 |
|
|
&& b->type != bp_catch_exec) /* a non-watchpoint bp */
|
2668 |
|
|
{
|
2669 |
|
|
if (bl->address != bp_addr) /* address doesn't match */
|
2670 |
|
|
continue;
|
2671 |
|
|
if (overlay_debugging /* unmapped overlay section */
|
2672 |
|
|
&& section_is_overlay (bl->section)
|
2673 |
|
|
&& !section_is_mapped (bl->section))
|
2674 |
|
|
continue;
|
2675 |
|
|
}
|
2676 |
|
|
|
2677 |
|
|
/* Continuable hardware watchpoints are treated as non-existent if the
|
2678 |
|
|
reason we stopped wasn't a hardware watchpoint (we didn't stop on
|
2679 |
|
|
some data address). Otherwise gdb won't stop on a break instruction
|
2680 |
|
|
in the code (not from a breakpoint) when a hardware watchpoint has
|
2681 |
|
|
been defined. Also skip watchpoints which we know did not trigger
|
2682 |
|
|
(did not match the data address). */
|
2683 |
|
|
|
2684 |
|
|
if ((b->type == bp_hardware_watchpoint
|
2685 |
|
|
|| b->type == bp_read_watchpoint
|
2686 |
|
|
|| b->type == bp_access_watchpoint)
|
2687 |
|
|
&& b->watchpoint_triggered == watch_triggered_no)
|
2688 |
|
|
continue;
|
2689 |
|
|
|
2690 |
|
|
if (b->type == bp_hardware_breakpoint)
|
2691 |
|
|
{
|
2692 |
|
|
if (bl->address != bp_addr)
|
2693 |
|
|
continue;
|
2694 |
|
|
if (overlay_debugging /* unmapped overlay section */
|
2695 |
|
|
&& section_is_overlay (bl->section)
|
2696 |
|
|
&& !section_is_mapped (bl->section))
|
2697 |
|
|
continue;
|
2698 |
|
|
}
|
2699 |
|
|
|
2700 |
|
|
/* Is this a catchpoint of a load or unload? If so, did we
|
2701 |
|
|
get a load or unload of the specified library? If not,
|
2702 |
|
|
ignore it. */
|
2703 |
|
|
if ((b->type == bp_catch_load)
|
2704 |
|
|
#if defined(SOLIB_HAVE_LOAD_EVENT)
|
2705 |
|
|
&& (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))
|
2706 |
|
|
|| ((b->dll_pathname != NULL)
|
2707 |
|
|
&& (strcmp (b->dll_pathname,
|
2708 |
|
|
SOLIB_LOADED_LIBRARY_PATHNAME (
|
2709 |
|
|
PIDGET (inferior_ptid)))
|
2710 |
|
|
!= 0)))
|
2711 |
|
|
#endif
|
2712 |
|
|
)
|
2713 |
|
|
continue;
|
2714 |
|
|
|
2715 |
|
|
if ((b->type == bp_catch_unload)
|
2716 |
|
|
#if defined(SOLIB_HAVE_UNLOAD_EVENT)
|
2717 |
|
|
&& (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))
|
2718 |
|
|
|| ((b->dll_pathname != NULL)
|
2719 |
|
|
&& (strcmp (b->dll_pathname,
|
2720 |
|
|
SOLIB_UNLOADED_LIBRARY_PATHNAME (
|
2721 |
|
|
PIDGET (inferior_ptid)))
|
2722 |
|
|
!= 0)))
|
2723 |
|
|
#endif
|
2724 |
|
|
)
|
2725 |
|
|
continue;
|
2726 |
|
|
|
2727 |
|
|
if ((b->type == bp_catch_fork)
|
2728 |
|
|
&& !inferior_has_forked (PIDGET (inferior_ptid),
|
2729 |
|
|
&b->forked_inferior_pid))
|
2730 |
|
|
continue;
|
2731 |
|
|
|
2732 |
|
|
if ((b->type == bp_catch_vfork)
|
2733 |
|
|
&& !inferior_has_vforked (PIDGET (inferior_ptid),
|
2734 |
|
|
&b->forked_inferior_pid))
|
2735 |
|
|
continue;
|
2736 |
|
|
|
2737 |
|
|
if ((b->type == bp_catch_exec)
|
2738 |
|
|
&& !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
|
2739 |
|
|
continue;
|
2740 |
|
|
|
2741 |
|
|
/* For hardware watchpoints, we look only at the first location.
|
2742 |
|
|
The watchpoint_check function will work on entire expression,
|
2743 |
|
|
not the individual locations. For read watchopints, the
|
2744 |
|
|
watchpoints_triggered function have checked all locations
|
2745 |
|
|
alrea
|
2746 |
|
|
*/
|
2747 |
|
|
if (b->type == bp_hardware_watchpoint && bl != b->loc)
|
2748 |
|
|
continue;
|
2749 |
|
|
|
2750 |
|
|
/* Come here if it's a watchpoint, or if the break address matches */
|
2751 |
|
|
|
2752 |
|
|
bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */
|
2753 |
|
|
|
2754 |
|
|
/* Watchpoints may change this, if not found to have triggered. */
|
2755 |
|
|
bs->stop = 1;
|
2756 |
|
|
bs->print = 1;
|
2757 |
|
|
|
2758 |
|
|
if (b->type == bp_watchpoint
|
2759 |
|
|
|| b->type == bp_read_watchpoint
|
2760 |
|
|
|| b->type == bp_access_watchpoint
|
2761 |
|
|
|| b->type == bp_hardware_watchpoint)
|
2762 |
|
|
{
|
2763 |
|
|
CORE_ADDR addr;
|
2764 |
|
|
struct value *v;
|
2765 |
|
|
int must_check_value = 0;
|
2766 |
|
|
|
2767 |
|
|
if (b->type == bp_watchpoint)
|
2768 |
|
|
/* For a software watchpoint, we must always check the
|
2769 |
|
|
watched value. */
|
2770 |
|
|
must_check_value = 1;
|
2771 |
|
|
else if (b->watchpoint_triggered == watch_triggered_yes)
|
2772 |
|
|
/* We have a hardware watchpoint (read, write, or access)
|
2773 |
|
|
and the target earlier reported an address watched by
|
2774 |
|
|
this watchpoint. */
|
2775 |
|
|
must_check_value = 1;
|
2776 |
|
|
else if (b->watchpoint_triggered == watch_triggered_unknown
|
2777 |
|
|
&& b->type == bp_hardware_watchpoint)
|
2778 |
|
|
/* We were stopped by a hardware watchpoint, but the target could
|
2779 |
|
|
not report the data address. We must check the watchpoint's
|
2780 |
|
|
value. Access and read watchpoints are out of luck; without
|
2781 |
|
|
a data address, we can't figure it out. */
|
2782 |
|
|
must_check_value = 1;
|
2783 |
|
|
|
2784 |
|
|
if (must_check_value)
|
2785 |
|
|
{
|
2786 |
|
|
char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",
|
2787 |
|
|
b->number);
|
2788 |
|
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
2789 |
|
|
int e = catch_errors (watchpoint_check, bs, message,
|
2790 |
|
|
RETURN_MASK_ALL);
|
2791 |
|
|
do_cleanups (cleanups);
|
2792 |
|
|
switch (e)
|
2793 |
|
|
{
|
2794 |
|
|
case WP_DELETED:
|
2795 |
|
|
/* We've already printed what needs to be printed. */
|
2796 |
|
|
bs->print_it = print_it_done;
|
2797 |
|
|
/* Stop. */
|
2798 |
|
|
break;
|
2799 |
|
|
case WP_VALUE_CHANGED:
|
2800 |
|
|
/* NOTE: Jeremy Bennett, 13-Aug-08: Code used to check if the
|
2801 |
|
|
value had changed, and if so disallow the watchpoint. The
|
2802 |
|
|
test was not reliable - trust the HW on this one */
|
2803 |
|
|
++(b->hit_count);
|
2804 |
|
|
break;
|
2805 |
|
|
case WP_VALUE_NOT_CHANGED:
|
2806 |
|
|
if (b->type == bp_hardware_watchpoint
|
2807 |
|
|
|| b->type == bp_watchpoint)
|
2808 |
|
|
{
|
2809 |
|
|
/* Don't stop: write watchpoints shouldn't fire if
|
2810 |
|
|
the value hasn't changed. */
|
2811 |
|
|
bs->print_it = print_it_noop;
|
2812 |
|
|
bs->stop = 0;
|
2813 |
|
|
continue;
|
2814 |
|
|
}
|
2815 |
|
|
/* Stop. */
|
2816 |
|
|
++(b->hit_count);
|
2817 |
|
|
break;
|
2818 |
|
|
default:
|
2819 |
|
|
/* Can't happen. */
|
2820 |
|
|
case 0:
|
2821 |
|
|
/* Error from catch_errors. */
|
2822 |
|
|
printf_filtered (_("Watchpoint %d deleted.\n"), b->number);
|
2823 |
|
|
if (b->related_breakpoint)
|
2824 |
|
|
b->related_breakpoint->disposition = disp_del_at_next_stop;
|
2825 |
|
|
b->disposition = disp_del_at_next_stop;
|
2826 |
|
|
/* We've already printed what needs to be printed. */
|
2827 |
|
|
bs->print_it = print_it_done;
|
2828 |
|
|
break;
|
2829 |
|
|
}
|
2830 |
|
|
}
|
2831 |
|
|
else /* must_check_value == 0 */
|
2832 |
|
|
{
|
2833 |
|
|
/* This is a case where some watchpoint(s) triggered, but
|
2834 |
|
|
not at the address of this watchpoint, or else no
|
2835 |
|
|
watchpoint triggered after all. So don't print
|
2836 |
|
|
anything for this watchpoint. */
|
2837 |
|
|
bs->print_it = print_it_noop;
|
2838 |
|
|
bs->stop = 0;
|
2839 |
|
|
continue;
|
2840 |
|
|
}
|
2841 |
|
|
}
|
2842 |
|
|
else
|
2843 |
|
|
{
|
2844 |
|
|
/* By definition, an encountered breakpoint is a triggered
|
2845 |
|
|
breakpoint. */
|
2846 |
|
|
++(b->hit_count);
|
2847 |
|
|
}
|
2848 |
|
|
|
2849 |
|
|
if (frame_id_p (b->frame_id)
|
2850 |
|
|
&& !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
|
2851 |
|
|
bs->stop = 0;
|
2852 |
|
|
else
|
2853 |
|
|
{
|
2854 |
|
|
int value_is_zero = 0;
|
2855 |
|
|
|
2856 |
|
|
/* If this is a scope breakpoint, mark the associated
|
2857 |
|
|
watchpoint as triggered so that we will handle the
|
2858 |
|
|
out-of-scope event. We'll get to the watchpoint next
|
2859 |
|
|
iteration. */
|
2860 |
|
|
if (b->type == bp_watchpoint_scope)
|
2861 |
|
|
b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
|
2862 |
|
|
|
2863 |
|
|
if (bl->cond && bl->owner->disposition != disp_del_at_next_stop)
|
2864 |
|
|
{
|
2865 |
|
|
/* Need to select the frame, with all that implies
|
2866 |
|
|
so that the conditions will have the right context. */
|
2867 |
|
|
select_frame (get_current_frame ());
|
2868 |
|
|
value_is_zero
|
2869 |
|
|
= catch_errors (breakpoint_cond_eval, (bl->cond),
|
2870 |
|
|
"Error in testing breakpoint condition:\n",
|
2871 |
|
|
RETURN_MASK_ALL);
|
2872 |
|
|
/* FIXME-someday, should give breakpoint # */
|
2873 |
|
|
free_all_values ();
|
2874 |
|
|
}
|
2875 |
|
|
if (bl->cond && value_is_zero)
|
2876 |
|
|
{
|
2877 |
|
|
bs->stop = 0;
|
2878 |
|
|
/* Don't consider this a hit. */
|
2879 |
|
|
--(b->hit_count);
|
2880 |
|
|
}
|
2881 |
|
|
else if (b->thread != -1 && b->thread != thread_id)
|
2882 |
|
|
{
|
2883 |
|
|
bs->stop = 0;
|
2884 |
|
|
/* Don't consider this a hit. */
|
2885 |
|
|
--(b->hit_count);
|
2886 |
|
|
}
|
2887 |
|
|
else if (b->ignore_count > 0)
|
2888 |
|
|
{
|
2889 |
|
|
b->ignore_count--;
|
2890 |
|
|
annotate_ignore_count_change ();
|
2891 |
|
|
bs->stop = 0;
|
2892 |
|
|
}
|
2893 |
|
|
else if (b->type == bp_thread_event || b->type == bp_overlay_event)
|
2894 |
|
|
/* We do not stop for these. */
|
2895 |
|
|
bs->stop = 0;
|
2896 |
|
|
else
|
2897 |
|
|
{
|
2898 |
|
|
/* We will stop here */
|
2899 |
|
|
if (b->disposition == disp_disable)
|
2900 |
|
|
b->enable_state = bp_disabled;
|
2901 |
|
|
if (b->silent)
|
2902 |
|
|
bs->print = 0;
|
2903 |
|
|
bs->commands = b->commands;
|
2904 |
|
|
if (bs->commands &&
|
2905 |
|
|
(strcmp ("silent", bs->commands->line) == 0
|
2906 |
|
|
|| (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
|
2907 |
|
|
{
|
2908 |
|
|
bs->commands = bs->commands->next;
|
2909 |
|
|
bs->print = 0;
|
2910 |
|
|
}
|
2911 |
|
|
bs->commands = copy_command_lines (bs->commands);
|
2912 |
|
|
}
|
2913 |
|
|
}
|
2914 |
|
|
/* Print nothing for this entry if we dont stop or if we dont print. */
|
2915 |
|
|
if (bs->stop == 0 || bs->print == 0)
|
2916 |
|
|
bs->print_it = print_it_noop;
|
2917 |
|
|
}
|
2918 |
|
|
|
2919 |
|
|
bs->next = NULL; /* Terminate the chain */
|
2920 |
|
|
bs = root_bs->next; /* Re-grab the head of the chain */
|
2921 |
|
|
|
2922 |
|
|
/* If we aren't stopping, the value of some hardware watchpoint may
|
2923 |
|
|
not have changed, but the intermediate memory locations we are
|
2924 |
|
|
watching may have. Don't bother if we're stopping; this will get
|
2925 |
|
|
done later. */
|
2926 |
|
|
for (bs = root_bs->next; bs != NULL; bs = bs->next)
|
2927 |
|
|
if (bs->stop)
|
2928 |
|
|
break;
|
2929 |
|
|
|
2930 |
|
|
if (bs == NULL)
|
2931 |
|
|
for (bs = root_bs->next; bs != NULL; bs = bs->next)
|
2932 |
|
|
if (!bs->stop
|
2933 |
|
|
&& (bs->breakpoint_at->owner->type == bp_hardware_watchpoint
|
2934 |
|
|
|| bs->breakpoint_at->owner->type == bp_read_watchpoint
|
2935 |
|
|
|| bs->breakpoint_at->owner->type == bp_access_watchpoint))
|
2936 |
|
|
{
|
2937 |
|
|
/* remove/insert can invalidate bs->breakpoint_at, if this
|
2938 |
|
|
location is no longer used by the watchpoint. Prevent
|
2939 |
|
|
further code from trying to use it. */
|
2940 |
|
|
bs->breakpoint_at = NULL;
|
2941 |
|
|
remove_breakpoints ();
|
2942 |
|
|
insert_breakpoints ();
|
2943 |
|
|
break;
|
2944 |
|
|
}
|
2945 |
|
|
|
2946 |
|
|
return root_bs->next;
|
2947 |
|
|
}
|
2948 |
|
|
|
2949 |
|
|
/* Tell what to do about this bpstat. */
|
2950 |
|
|
struct bpstat_what
|
2951 |
|
|
bpstat_what (bpstat bs)
|
2952 |
|
|
{
|
2953 |
|
|
/* Classify each bpstat as one of the following. */
|
2954 |
|
|
enum class
|
2955 |
|
|
{
|
2956 |
|
|
/* This bpstat element has no effect on the main_action. */
|
2957 |
|
|
no_effect = 0,
|
2958 |
|
|
|
2959 |
|
|
/* There was a watchpoint, stop but don't print. */
|
2960 |
|
|
wp_silent,
|
2961 |
|
|
|
2962 |
|
|
/* There was a watchpoint, stop and print. */
|
2963 |
|
|
wp_noisy,
|
2964 |
|
|
|
2965 |
|
|
/* There was a breakpoint but we're not stopping. */
|
2966 |
|
|
bp_nostop,
|
2967 |
|
|
|
2968 |
|
|
/* There was a breakpoint, stop but don't print. */
|
2969 |
|
|
bp_silent,
|
2970 |
|
|
|
2971 |
|
|
/* There was a breakpoint, stop and print. */
|
2972 |
|
|
bp_noisy,
|
2973 |
|
|
|
2974 |
|
|
/* We hit the longjmp breakpoint. */
|
2975 |
|
|
long_jump,
|
2976 |
|
|
|
2977 |
|
|
/* We hit the longjmp_resume breakpoint. */
|
2978 |
|
|
long_resume,
|
2979 |
|
|
|
2980 |
|
|
/* We hit the step_resume breakpoint. */
|
2981 |
|
|
step_resume,
|
2982 |
|
|
|
2983 |
|
|
/* We hit the shared library event breakpoint. */
|
2984 |
|
|
shlib_event,
|
2985 |
|
|
|
2986 |
|
|
/* We caught a shared library event. */
|
2987 |
|
|
catch_shlib_event,
|
2988 |
|
|
|
2989 |
|
|
/* This is just used to count how many enums there are. */
|
2990 |
|
|
class_last
|
2991 |
|
|
};
|
2992 |
|
|
|
2993 |
|
|
/* Here is the table which drives this routine. So that we can
|
2994 |
|
|
format it pretty, we define some abbreviations for the
|
2995 |
|
|
enum bpstat_what codes. */
|
2996 |
|
|
#define kc BPSTAT_WHAT_KEEP_CHECKING
|
2997 |
|
|
#define ss BPSTAT_WHAT_STOP_SILENT
|
2998 |
|
|
#define sn BPSTAT_WHAT_STOP_NOISY
|
2999 |
|
|
#define sgl BPSTAT_WHAT_SINGLE
|
3000 |
|
|
#define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
|
3001 |
|
|
#define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
|
3002 |
|
|
#define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
|
3003 |
|
|
#define sr BPSTAT_WHAT_STEP_RESUME
|
3004 |
|
|
#define shl BPSTAT_WHAT_CHECK_SHLIBS
|
3005 |
|
|
#define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
|
3006 |
|
|
|
3007 |
|
|
/* "Can't happen." Might want to print an error message.
|
3008 |
|
|
abort() is not out of the question, but chances are GDB is just
|
3009 |
|
|
a bit confused, not unusable. */
|
3010 |
|
|
#define err BPSTAT_WHAT_STOP_NOISY
|
3011 |
|
|
|
3012 |
|
|
/* Given an old action and a class, come up with a new action. */
|
3013 |
|
|
/* One interesting property of this table is that wp_silent is the same
|
3014 |
|
|
as bp_silent and wp_noisy is the same as bp_noisy. That is because
|
3015 |
|
|
after stopping, the check for whether to step over a breakpoint
|
3016 |
|
|
(BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
|
3017 |
|
|
reference to how we stopped. We retain separate wp_silent and
|
3018 |
|
|
bp_silent codes in case we want to change that someday.
|
3019 |
|
|
|
3020 |
|
|
Another possibly interesting property of this table is that
|
3021 |
|
|
there's a partial ordering, priority-like, of the actions. Once
|
3022 |
|
|
you've decided that some action is appropriate, you'll never go
|
3023 |
|
|
back and decide something of a lower priority is better. The
|
3024 |
|
|
ordering is:
|
3025 |
|
|
|
3026 |
|
|
kc < clr sgl shl shlr slr sn sr ss
|
3027 |
|
|
sgl < clrs shl shlr slr sn sr ss
|
3028 |
|
|
slr < err shl shlr sn sr ss
|
3029 |
|
|
clr < clrs err shl shlr sn sr ss
|
3030 |
|
|
clrs < err shl shlr sn sr ss
|
3031 |
|
|
ss < shl shlr sn sr
|
3032 |
|
|
sn < shl shlr sr
|
3033 |
|
|
shl < shlr sr
|
3034 |
|
|
shlr < sr
|
3035 |
|
|
sr <
|
3036 |
|
|
|
3037 |
|
|
What I think this means is that we don't need a damned table
|
3038 |
|
|
here. If you just put the rows and columns in the right order,
|
3039 |
|
|
it'd look awfully regular. We could simply walk the bpstat list
|
3040 |
|
|
and choose the highest priority action we find, with a little
|
3041 |
|
|
logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
|
3042 |
|
|
CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
|
3043 |
|
|
is messy anyway). */
|
3044 |
|
|
|
3045 |
|
|
/* step_resume entries: a step resume breakpoint overrides another
|
3046 |
|
|
breakpoint of signal handling (see comment in wait_for_inferior
|
3047 |
|
|
at where we set the step_resume breakpoint). */
|
3048 |
|
|
|
3049 |
|
|
static const enum bpstat_what_main_action
|
3050 |
|
|
table[(int) class_last][(int) BPSTAT_WHAT_LAST] =
|
3051 |
|
|
{
|
3052 |
|
|
/* old action */
|
3053 |
|
|
/* kc ss sn sgl slr clr clrs sr shl shlr
|
3054 |
|
|
*/
|
3055 |
|
|
/*no_effect */
|
3056 |
|
|
{kc, ss, sn, sgl, slr, clr, clrs, sr, shl, shlr},
|
3057 |
|
|
/*wp_silent */
|
3058 |
|
|
{ss, ss, sn, ss, ss, ss, ss, sr, shl, shlr},
|
3059 |
|
|
/*wp_noisy */
|
3060 |
|
|
{sn, sn, sn, sn, sn, sn, sn, sr, shl, shlr},
|
3061 |
|
|
/*bp_nostop */
|
3062 |
|
|
{sgl, ss, sn, sgl, slr, clrs, clrs, sr, shl, shlr},
|
3063 |
|
|
/*bp_silent */
|
3064 |
|
|
{ss, ss, sn, ss, ss, ss, ss, sr, shl, shlr},
|
3065 |
|
|
/*bp_noisy */
|
3066 |
|
|
{sn, sn, sn, sn, sn, sn, sn, sr, shl, shlr},
|
3067 |
|
|
/*long_jump */
|
3068 |
|
|
{slr, ss, sn, slr, slr, err, err, sr, shl, shlr},
|
3069 |
|
|
/*long_resume */
|
3070 |
|
|
{clr, ss, sn, clrs, err, err, err, sr, shl, shlr},
|
3071 |
|
|
/*step_resume */
|
3072 |
|
|
{sr, sr, sr, sr, sr, sr, sr, sr, sr, sr},
|
3073 |
|
|
/*shlib */
|
3074 |
|
|
{shl, shl, shl, shl, shl, shl, shl, sr, shl, shlr},
|
3075 |
|
|
/*catch_shlib */
|
3076 |
|
|
{shlr, shlr, shlr, shlr, shlr, shlr, shlr, sr, shlr, shlr}
|
3077 |
|
|
};
|
3078 |
|
|
|
3079 |
|
|
#undef kc
|
3080 |
|
|
#undef ss
|
3081 |
|
|
#undef sn
|
3082 |
|
|
#undef sgl
|
3083 |
|
|
#undef slr
|
3084 |
|
|
#undef clr
|
3085 |
|
|
#undef clrs
|
3086 |
|
|
#undef err
|
3087 |
|
|
#undef sr
|
3088 |
|
|
#undef ts
|
3089 |
|
|
#undef shl
|
3090 |
|
|
#undef shlr
|
3091 |
|
|
enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
|
3092 |
|
|
struct bpstat_what retval;
|
3093 |
|
|
|
3094 |
|
|
retval.call_dummy = 0;
|
3095 |
|
|
for (; bs != NULL; bs = bs->next)
|
3096 |
|
|
{
|
3097 |
|
|
enum class bs_class = no_effect;
|
3098 |
|
|
if (bs->breakpoint_at == NULL)
|
3099 |
|
|
/* I suspect this can happen if it was a momentary breakpoint
|
3100 |
|
|
which has since been deleted. */
|
3101 |
|
|
continue;
|
3102 |
|
|
switch (bs->breakpoint_at->owner->type)
|
3103 |
|
|
{
|
3104 |
|
|
case bp_none:
|
3105 |
|
|
continue;
|
3106 |
|
|
|
3107 |
|
|
case bp_breakpoint:
|
3108 |
|
|
case bp_hardware_breakpoint:
|
3109 |
|
|
case bp_until:
|
3110 |
|
|
case bp_finish:
|
3111 |
|
|
if (bs->stop)
|
3112 |
|
|
{
|
3113 |
|
|
if (bs->print)
|
3114 |
|
|
bs_class = bp_noisy;
|
3115 |
|
|
else
|
3116 |
|
|
bs_class = bp_silent;
|
3117 |
|
|
}
|
3118 |
|
|
else
|
3119 |
|
|
bs_class = bp_nostop;
|
3120 |
|
|
break;
|
3121 |
|
|
case bp_watchpoint:
|
3122 |
|
|
case bp_hardware_watchpoint:
|
3123 |
|
|
case bp_read_watchpoint:
|
3124 |
|
|
case bp_access_watchpoint:
|
3125 |
|
|
if (bs->stop)
|
3126 |
|
|
{
|
3127 |
|
|
if (bs->print)
|
3128 |
|
|
bs_class = wp_noisy;
|
3129 |
|
|
else
|
3130 |
|
|
bs_class = wp_silent;
|
3131 |
|
|
}
|
3132 |
|
|
else
|
3133 |
|
|
/* There was a watchpoint, but we're not stopping.
|
3134 |
|
|
This requires no further action. */
|
3135 |
|
|
bs_class = no_effect;
|
3136 |
|
|
break;
|
3137 |
|
|
case bp_longjmp:
|
3138 |
|
|
bs_class = long_jump;
|
3139 |
|
|
break;
|
3140 |
|
|
case bp_longjmp_resume:
|
3141 |
|
|
bs_class = long_resume;
|
3142 |
|
|
break;
|
3143 |
|
|
case bp_step_resume:
|
3144 |
|
|
if (bs->stop)
|
3145 |
|
|
{
|
3146 |
|
|
bs_class = step_resume;
|
3147 |
|
|
}
|
3148 |
|
|
else
|
3149 |
|
|
/* It is for the wrong frame. */
|
3150 |
|
|
bs_class = bp_nostop;
|
3151 |
|
|
break;
|
3152 |
|
|
case bp_watchpoint_scope:
|
3153 |
|
|
bs_class = bp_nostop;
|
3154 |
|
|
break;
|
3155 |
|
|
case bp_shlib_event:
|
3156 |
|
|
bs_class = shlib_event;
|
3157 |
|
|
break;
|
3158 |
|
|
case bp_thread_event:
|
3159 |
|
|
case bp_overlay_event:
|
3160 |
|
|
bs_class = bp_nostop;
|
3161 |
|
|
break;
|
3162 |
|
|
case bp_catch_load:
|
3163 |
|
|
case bp_catch_unload:
|
3164 |
|
|
/* Only if this catchpoint triggered should we cause the
|
3165 |
|
|
step-out-of-dld behaviour. Otherwise, we ignore this
|
3166 |
|
|
catchpoint. */
|
3167 |
|
|
if (bs->stop)
|
3168 |
|
|
bs_class = catch_shlib_event;
|
3169 |
|
|
else
|
3170 |
|
|
bs_class = no_effect;
|
3171 |
|
|
break;
|
3172 |
|
|
case bp_catch_fork:
|
3173 |
|
|
case bp_catch_vfork:
|
3174 |
|
|
case bp_catch_exec:
|
3175 |
|
|
if (bs->stop)
|
3176 |
|
|
{
|
3177 |
|
|
if (bs->print)
|
3178 |
|
|
bs_class = bp_noisy;
|
3179 |
|
|
else
|
3180 |
|
|
bs_class = bp_silent;
|
3181 |
|
|
}
|
3182 |
|
|
else
|
3183 |
|
|
/* There was a catchpoint, but we're not stopping.
|
3184 |
|
|
This requires no further action. */
|
3185 |
|
|
bs_class = no_effect;
|
3186 |
|
|
break;
|
3187 |
|
|
case bp_call_dummy:
|
3188 |
|
|
/* Make sure the action is stop (silent or noisy),
|
3189 |
|
|
so infrun.c pops the dummy frame. */
|
3190 |
|
|
bs_class = bp_silent;
|
3191 |
|
|
retval.call_dummy = 1;
|
3192 |
|
|
break;
|
3193 |
|
|
}
|
3194 |
|
|
current_action = table[(int) bs_class][(int) current_action];
|
3195 |
|
|
}
|
3196 |
|
|
retval.main_action = current_action;
|
3197 |
|
|
return retval;
|
3198 |
|
|
}
|
3199 |
|
|
|
3200 |
|
|
/* Nonzero if we should step constantly (e.g. watchpoints on machines
|
3201 |
|
|
without hardware support). This isn't related to a specific bpstat,
|
3202 |
|
|
just to things like whether watchpoints are set. */
|
3203 |
|
|
|
3204 |
|
|
int
|
3205 |
|
|
bpstat_should_step (void)
|
3206 |
|
|
{
|
3207 |
|
|
struct breakpoint *b;
|
3208 |
|
|
ALL_BREAKPOINTS (b)
|
3209 |
|
|
if (breakpoint_enabled (b) && b->type == bp_watchpoint)
|
3210 |
|
|
return 1;
|
3211 |
|
|
return 0;
|
3212 |
|
|
}
|
3213 |
|
|
|
3214 |
|
|
|
3215 |
|
|
|
3216 |
|
|
/* Given a bpstat that records zero or more triggered eventpoints, this
|
3217 |
|
|
function returns another bpstat which contains only the catchpoints
|
3218 |
|
|
on that first list, if any. */
|
3219 |
|
|
void
|
3220 |
|
|
bpstat_get_triggered_catchpoints (bpstat ep_list, bpstat *cp_list)
|
3221 |
|
|
{
|
3222 |
|
|
struct bpstats root_bs[1];
|
3223 |
|
|
bpstat bs = root_bs;
|
3224 |
|
|
struct breakpoint *ep;
|
3225 |
|
|
char *dll_pathname;
|
3226 |
|
|
|
3227 |
|
|
bpstat_clear (cp_list);
|
3228 |
|
|
root_bs->next = NULL;
|
3229 |
|
|
|
3230 |
|
|
for (; ep_list != NULL; ep_list = ep_list->next)
|
3231 |
|
|
{
|
3232 |
|
|
/* Is this eventpoint a catchpoint? If not, ignore it. */
|
3233 |
|
|
ep = ep_list->breakpoint_at->owner;
|
3234 |
|
|
if (ep == NULL)
|
3235 |
|
|
break;
|
3236 |
|
|
if ((ep->type != bp_catch_load) &&
|
3237 |
|
|
(ep->type != bp_catch_unload))
|
3238 |
|
|
/* pai: (temp) ADD fork/vfork here!! */
|
3239 |
|
|
continue;
|
3240 |
|
|
|
3241 |
|
|
/* Yes; add it to the list. */
|
3242 |
|
|
bs = bpstat_alloc (ep_list->breakpoint_at, bs);
|
3243 |
|
|
*bs = *ep_list;
|
3244 |
|
|
bs->next = NULL;
|
3245 |
|
|
bs = root_bs->next;
|
3246 |
|
|
|
3247 |
|
|
#if defined(SOLIB_ADD)
|
3248 |
|
|
/* Also, for each triggered catchpoint, tag it with the name of
|
3249 |
|
|
the library that caused this trigger. (We copy the name now,
|
3250 |
|
|
because it's only guaranteed to be available NOW, when the
|
3251 |
|
|
catchpoint triggers. Clients who may wish to know the name
|
3252 |
|
|
later must get it from the catchpoint itself.) */
|
3253 |
|
|
if (ep->triggered_dll_pathname != NULL)
|
3254 |
|
|
xfree (ep->triggered_dll_pathname);
|
3255 |
|
|
if (ep->type == bp_catch_load)
|
3256 |
|
|
dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (
|
3257 |
|
|
PIDGET (inferior_ptid));
|
3258 |
|
|
else
|
3259 |
|
|
dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (
|
3260 |
|
|
PIDGET (inferior_ptid));
|
3261 |
|
|
#else
|
3262 |
|
|
dll_pathname = NULL;
|
3263 |
|
|
#endif
|
3264 |
|
|
if (dll_pathname)
|
3265 |
|
|
{
|
3266 |
|
|
ep->triggered_dll_pathname = (char *)
|
3267 |
|
|
xmalloc (strlen (dll_pathname) + 1);
|
3268 |
|
|
strcpy (ep->triggered_dll_pathname, dll_pathname);
|
3269 |
|
|
}
|
3270 |
|
|
else
|
3271 |
|
|
ep->triggered_dll_pathname = NULL;
|
3272 |
|
|
}
|
3273 |
|
|
|
3274 |
|
|
*cp_list = bs;
|
3275 |
|
|
}
|
3276 |
|
|
|
3277 |
|
|
static void print_breakpoint_location (struct breakpoint *b,
|
3278 |
|
|
struct bp_location *loc,
|
3279 |
|
|
char *wrap_indent,
|
3280 |
|
|
struct ui_stream *stb)
|
3281 |
|
|
{
|
3282 |
|
|
if (b->source_file)
|
3283 |
|
|
{
|
3284 |
|
|
struct symbol *sym
|
3285 |
|
|
= find_pc_sect_function (loc->address, loc->section);
|
3286 |
|
|
if (sym)
|
3287 |
|
|
{
|
3288 |
|
|
ui_out_text (uiout, "in ");
|
3289 |
|
|
ui_out_field_string (uiout, "func",
|
3290 |
|
|
SYMBOL_PRINT_NAME (sym));
|
3291 |
|
|
ui_out_wrap_hint (uiout, wrap_indent);
|
3292 |
|
|
ui_out_text (uiout, " at ");
|
3293 |
|
|
}
|
3294 |
|
|
ui_out_field_string (uiout, "file", b->source_file);
|
3295 |
|
|
ui_out_text (uiout, ":");
|
3296 |
|
|
|
3297 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
3298 |
|
|
{
|
3299 |
|
|
struct symtab_and_line sal = find_pc_line (loc->address, 0);
|
3300 |
|
|
char *fullname = symtab_to_fullname (sal.symtab);
|
3301 |
|
|
|
3302 |
|
|
if (fullname)
|
3303 |
|
|
ui_out_field_string (uiout, "fullname", fullname);
|
3304 |
|
|
}
|
3305 |
|
|
|
3306 |
|
|
ui_out_field_int (uiout, "line", b->line_number);
|
3307 |
|
|
}
|
3308 |
|
|
else if (!b->loc)
|
3309 |
|
|
{
|
3310 |
|
|
ui_out_field_string (uiout, "pending", b->addr_string);
|
3311 |
|
|
}
|
3312 |
|
|
else
|
3313 |
|
|
{
|
3314 |
|
|
print_address_symbolic (loc->address, stb->stream, demangle, "");
|
3315 |
|
|
ui_out_field_stream (uiout, "at", stb);
|
3316 |
|
|
}
|
3317 |
|
|
}
|
3318 |
|
|
|
3319 |
|
|
/* Print B to gdb_stdout. */
|
3320 |
|
|
static void
|
3321 |
|
|
print_one_breakpoint_location (struct breakpoint *b,
|
3322 |
|
|
struct bp_location *loc,
|
3323 |
|
|
int loc_number,
|
3324 |
|
|
CORE_ADDR *last_addr)
|
3325 |
|
|
{
|
3326 |
|
|
struct command_line *l;
|
3327 |
|
|
struct symbol *sym;
|
3328 |
|
|
struct ep_type_description
|
3329 |
|
|
{
|
3330 |
|
|
enum bptype type;
|
3331 |
|
|
char *description;
|
3332 |
|
|
};
|
3333 |
|
|
static struct ep_type_description bptypes[] =
|
3334 |
|
|
{
|
3335 |
|
|
{bp_none, "?deleted?"},
|
3336 |
|
|
{bp_breakpoint, "breakpoint"},
|
3337 |
|
|
{bp_hardware_breakpoint, "hw breakpoint"},
|
3338 |
|
|
{bp_until, "until"},
|
3339 |
|
|
{bp_finish, "finish"},
|
3340 |
|
|
{bp_watchpoint, "watchpoint"},
|
3341 |
|
|
{bp_hardware_watchpoint, "hw watchpoint"},
|
3342 |
|
|
{bp_read_watchpoint, "read watchpoint"},
|
3343 |
|
|
{bp_access_watchpoint, "acc watchpoint"},
|
3344 |
|
|
{bp_longjmp, "longjmp"},
|
3345 |
|
|
{bp_longjmp_resume, "longjmp resume"},
|
3346 |
|
|
{bp_step_resume, "step resume"},
|
3347 |
|
|
{bp_watchpoint_scope, "watchpoint scope"},
|
3348 |
|
|
{bp_call_dummy, "call dummy"},
|
3349 |
|
|
{bp_shlib_event, "shlib events"},
|
3350 |
|
|
{bp_thread_event, "thread events"},
|
3351 |
|
|
{bp_overlay_event, "overlay events"},
|
3352 |
|
|
{bp_catch_load, "catch load"},
|
3353 |
|
|
{bp_catch_unload, "catch unload"},
|
3354 |
|
|
{bp_catch_fork, "catch fork"},
|
3355 |
|
|
{bp_catch_vfork, "catch vfork"},
|
3356 |
|
|
{bp_catch_exec, "catch exec"}
|
3357 |
|
|
};
|
3358 |
|
|
|
3359 |
|
|
static char *bpdisps[] =
|
3360 |
|
|
{"del", "dstp", "dis", "keep"};
|
3361 |
|
|
static char bpenables[] = "nynny";
|
3362 |
|
|
char wrap_indent[80];
|
3363 |
|
|
struct ui_stream *stb = ui_out_stream_new (uiout);
|
3364 |
|
|
struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
|
3365 |
|
|
struct cleanup *bkpt_chain;
|
3366 |
|
|
|
3367 |
|
|
int header_of_multiple = 0;
|
3368 |
|
|
int part_of_multiple = (loc != NULL);
|
3369 |
|
|
|
3370 |
|
|
gdb_assert (!loc || loc_number != 0);
|
3371 |
|
|
/* See comment in print_one_breakpoint concerning
|
3372 |
|
|
treatment of breakpoints with single disabled
|
3373 |
|
|
location. */
|
3374 |
|
|
if (loc == NULL
|
3375 |
|
|
&& (b->loc != NULL
|
3376 |
|
|
&& (b->loc->next != NULL || !b->loc->enabled)))
|
3377 |
|
|
header_of_multiple = 1;
|
3378 |
|
|
if (loc == NULL)
|
3379 |
|
|
loc = b->loc;
|
3380 |
|
|
|
3381 |
|
|
annotate_record ();
|
3382 |
|
|
bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
|
3383 |
|
|
|
3384 |
|
|
/* 1 */
|
3385 |
|
|
annotate_field (0);
|
3386 |
|
|
if (part_of_multiple)
|
3387 |
|
|
{
|
3388 |
|
|
char *formatted;
|
3389 |
|
|
formatted = xstrprintf ("%d.%d", b->number, loc_number);
|
3390 |
|
|
ui_out_field_string (uiout, "number", formatted);
|
3391 |
|
|
xfree (formatted);
|
3392 |
|
|
}
|
3393 |
|
|
else
|
3394 |
|
|
{
|
3395 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
3396 |
|
|
}
|
3397 |
|
|
|
3398 |
|
|
/* 2 */
|
3399 |
|
|
annotate_field (1);
|
3400 |
|
|
if (part_of_multiple)
|
3401 |
|
|
ui_out_field_skip (uiout, "type");
|
3402 |
|
|
else
|
3403 |
|
|
{
|
3404 |
|
|
if (((int) b->type >= (sizeof (bptypes) / sizeof (bptypes[0])))
|
3405 |
|
|
|| ((int) b->type != bptypes[(int) b->type].type))
|
3406 |
|
|
internal_error (__FILE__, __LINE__,
|
3407 |
|
|
_("bptypes table does not describe type #%d."),
|
3408 |
|
|
(int) b->type);
|
3409 |
|
|
ui_out_field_string (uiout, "type", bptypes[(int) b->type].description);
|
3410 |
|
|
}
|
3411 |
|
|
|
3412 |
|
|
/* 3 */
|
3413 |
|
|
annotate_field (2);
|
3414 |
|
|
if (part_of_multiple)
|
3415 |
|
|
ui_out_field_skip (uiout, "disp");
|
3416 |
|
|
else
|
3417 |
|
|
ui_out_field_string (uiout, "disp", bpdisps[(int) b->disposition]);
|
3418 |
|
|
|
3419 |
|
|
|
3420 |
|
|
/* 4 */
|
3421 |
|
|
annotate_field (3);
|
3422 |
|
|
if (part_of_multiple)
|
3423 |
|
|
ui_out_field_string (uiout, "enabled", loc->enabled ? "y" : "n");
|
3424 |
|
|
else
|
3425 |
|
|
ui_out_field_fmt (uiout, "enabled", "%c",
|
3426 |
|
|
bpenables[(int) b->enable_state]);
|
3427 |
|
|
ui_out_spaces (uiout, 2);
|
3428 |
|
|
|
3429 |
|
|
|
3430 |
|
|
/* 5 and 6 */
|
3431 |
|
|
strcpy (wrap_indent, " ");
|
3432 |
|
|
if (addressprint)
|
3433 |
|
|
{
|
3434 |
|
|
if (gdbarch_addr_bit (current_gdbarch) <= 32)
|
3435 |
|
|
strcat (wrap_indent, " ");
|
3436 |
|
|
else
|
3437 |
|
|
strcat (wrap_indent, " ");
|
3438 |
|
|
}
|
3439 |
|
|
|
3440 |
|
|
if (b->ops != NULL && b->ops->print_one != NULL)
|
3441 |
|
|
{
|
3442 |
|
|
/* Although the print_one can possibly print
|
3443 |
|
|
all locations, calling it here is not likely
|
3444 |
|
|
to get any nice result. So, make sure there's
|
3445 |
|
|
just one location. */
|
3446 |
|
|
gdb_assert (b->loc == NULL || b->loc->next == NULL);
|
3447 |
|
|
b->ops->print_one (b, last_addr);
|
3448 |
|
|
}
|
3449 |
|
|
else
|
3450 |
|
|
switch (b->type)
|
3451 |
|
|
{
|
3452 |
|
|
case bp_none:
|
3453 |
|
|
internal_error (__FILE__, __LINE__,
|
3454 |
|
|
_("print_one_breakpoint: bp_none encountered\n"));
|
3455 |
|
|
break;
|
3456 |
|
|
|
3457 |
|
|
case bp_watchpoint:
|
3458 |
|
|
case bp_hardware_watchpoint:
|
3459 |
|
|
case bp_read_watchpoint:
|
3460 |
|
|
case bp_access_watchpoint:
|
3461 |
|
|
/* Field 4, the address, is omitted (which makes the columns
|
3462 |
|
|
not line up too nicely with the headers, but the effect
|
3463 |
|
|
is relatively readable). */
|
3464 |
|
|
if (addressprint)
|
3465 |
|
|
ui_out_field_skip (uiout, "addr");
|
3466 |
|
|
annotate_field (5);
|
3467 |
|
|
print_expression (b->exp, stb->stream);
|
3468 |
|
|
ui_out_field_stream (uiout, "what", stb);
|
3469 |
|
|
break;
|
3470 |
|
|
|
3471 |
|
|
case bp_catch_load:
|
3472 |
|
|
case bp_catch_unload:
|
3473 |
|
|
/* Field 4, the address, is omitted (which makes the columns
|
3474 |
|
|
not line up too nicely with the headers, but the effect
|
3475 |
|
|
is relatively readable). */
|
3476 |
|
|
if (addressprint)
|
3477 |
|
|
ui_out_field_skip (uiout, "addr");
|
3478 |
|
|
annotate_field (5);
|
3479 |
|
|
if (b->dll_pathname == NULL)
|
3480 |
|
|
{
|
3481 |
|
|
ui_out_field_string (uiout, "what", "<any library>");
|
3482 |
|
|
ui_out_spaces (uiout, 1);
|
3483 |
|
|
}
|
3484 |
|
|
else
|
3485 |
|
|
{
|
3486 |
|
|
ui_out_text (uiout, "library \"");
|
3487 |
|
|
ui_out_field_string (uiout, "what", b->dll_pathname);
|
3488 |
|
|
ui_out_text (uiout, "\" ");
|
3489 |
|
|
}
|
3490 |
|
|
break;
|
3491 |
|
|
|
3492 |
|
|
case bp_catch_fork:
|
3493 |
|
|
case bp_catch_vfork:
|
3494 |
|
|
/* Field 4, the address, is omitted (which makes the columns
|
3495 |
|
|
not line up too nicely with the headers, but the effect
|
3496 |
|
|
is relatively readable). */
|
3497 |
|
|
if (addressprint)
|
3498 |
|
|
ui_out_field_skip (uiout, "addr");
|
3499 |
|
|
annotate_field (5);
|
3500 |
|
|
if (b->forked_inferior_pid != 0)
|
3501 |
|
|
{
|
3502 |
|
|
ui_out_text (uiout, "process ");
|
3503 |
|
|
ui_out_field_int (uiout, "what", b->forked_inferior_pid);
|
3504 |
|
|
ui_out_spaces (uiout, 1);
|
3505 |
|
|
}
|
3506 |
|
|
break;
|
3507 |
|
|
|
3508 |
|
|
case bp_catch_exec:
|
3509 |
|
|
/* Field 4, the address, is omitted (which makes the columns
|
3510 |
|
|
not line up too nicely with the headers, but the effect
|
3511 |
|
|
is relatively readable). */
|
3512 |
|
|
if (addressprint)
|
3513 |
|
|
ui_out_field_skip (uiout, "addr");
|
3514 |
|
|
annotate_field (5);
|
3515 |
|
|
if (b->exec_pathname != NULL)
|
3516 |
|
|
{
|
3517 |
|
|
ui_out_text (uiout, "program \"");
|
3518 |
|
|
ui_out_field_string (uiout, "what", b->exec_pathname);
|
3519 |
|
|
ui_out_text (uiout, "\" ");
|
3520 |
|
|
}
|
3521 |
|
|
break;
|
3522 |
|
|
|
3523 |
|
|
case bp_breakpoint:
|
3524 |
|
|
case bp_hardware_breakpoint:
|
3525 |
|
|
case bp_until:
|
3526 |
|
|
case bp_finish:
|
3527 |
|
|
case bp_longjmp:
|
3528 |
|
|
case bp_longjmp_resume:
|
3529 |
|
|
case bp_step_resume:
|
3530 |
|
|
case bp_watchpoint_scope:
|
3531 |
|
|
case bp_call_dummy:
|
3532 |
|
|
case bp_shlib_event:
|
3533 |
|
|
case bp_thread_event:
|
3534 |
|
|
case bp_overlay_event:
|
3535 |
|
|
if (addressprint)
|
3536 |
|
|
{
|
3537 |
|
|
annotate_field (4);
|
3538 |
|
|
if (header_of_multiple)
|
3539 |
|
|
ui_out_field_string (uiout, "addr", "<MULTIPLE>");
|
3540 |
|
|
if (b->loc == NULL || loc->shlib_disabled)
|
3541 |
|
|
ui_out_field_string (uiout, "addr", "<PENDING>");
|
3542 |
|
|
else
|
3543 |
|
|
ui_out_field_core_addr (uiout, "addr", loc->address);
|
3544 |
|
|
}
|
3545 |
|
|
annotate_field (5);
|
3546 |
|
|
if (!header_of_multiple)
|
3547 |
|
|
print_breakpoint_location (b, loc, wrap_indent, stb);
|
3548 |
|
|
if (b->loc)
|
3549 |
|
|
*last_addr = b->loc->address;
|
3550 |
|
|
break;
|
3551 |
|
|
}
|
3552 |
|
|
|
3553 |
|
|
if (!part_of_multiple && b->thread != -1)
|
3554 |
|
|
{
|
3555 |
|
|
/* FIXME: This seems to be redundant and lost here; see the
|
3556 |
|
|
"stop only in" line a little further down. */
|
3557 |
|
|
ui_out_text (uiout, " thread ");
|
3558 |
|
|
ui_out_field_int (uiout, "thread", b->thread);
|
3559 |
|
|
}
|
3560 |
|
|
|
3561 |
|
|
ui_out_text (uiout, "\n");
|
3562 |
|
|
|
3563 |
|
|
if (part_of_multiple && frame_id_p (b->frame_id))
|
3564 |
|
|
{
|
3565 |
|
|
annotate_field (6);
|
3566 |
|
|
ui_out_text (uiout, "\tstop only in stack frame at ");
|
3567 |
|
|
/* FIXME: cagney/2002-12-01: Shouldn't be poeking around inside
|
3568 |
|
|
the frame ID. */
|
3569 |
|
|
ui_out_field_core_addr (uiout, "frame", b->frame_id.stack_addr);
|
3570 |
|
|
ui_out_text (uiout, "\n");
|
3571 |
|
|
}
|
3572 |
|
|
|
3573 |
|
|
if (!part_of_multiple && b->cond_string && !ada_exception_catchpoint_p (b))
|
3574 |
|
|
{
|
3575 |
|
|
/* We do not print the condition for Ada exception catchpoints
|
3576 |
|
|
because the condition is an internal implementation detail
|
3577 |
|
|
that we do not want to expose to the user. */
|
3578 |
|
|
annotate_field (7);
|
3579 |
|
|
ui_out_text (uiout, "\tstop only if ");
|
3580 |
|
|
ui_out_field_string (uiout, "cond", b->cond_string);
|
3581 |
|
|
ui_out_text (uiout, "\n");
|
3582 |
|
|
}
|
3583 |
|
|
|
3584 |
|
|
if (!part_of_multiple && b->thread != -1)
|
3585 |
|
|
{
|
3586 |
|
|
/* FIXME should make an annotation for this */
|
3587 |
|
|
ui_out_text (uiout, "\tstop only in thread ");
|
3588 |
|
|
ui_out_field_int (uiout, "thread", b->thread);
|
3589 |
|
|
ui_out_text (uiout, "\n");
|
3590 |
|
|
}
|
3591 |
|
|
|
3592 |
|
|
if (!part_of_multiple && show_breakpoint_hit_counts && b->hit_count)
|
3593 |
|
|
{
|
3594 |
|
|
/* FIXME should make an annotation for this */
|
3595 |
|
|
if (ep_is_catchpoint (b))
|
3596 |
|
|
ui_out_text (uiout, "\tcatchpoint");
|
3597 |
|
|
else
|
3598 |
|
|
ui_out_text (uiout, "\tbreakpoint");
|
3599 |
|
|
ui_out_text (uiout, " already hit ");
|
3600 |
|
|
ui_out_field_int (uiout, "times", b->hit_count);
|
3601 |
|
|
if (b->hit_count == 1)
|
3602 |
|
|
ui_out_text (uiout, " time\n");
|
3603 |
|
|
else
|
3604 |
|
|
ui_out_text (uiout, " times\n");
|
3605 |
|
|
}
|
3606 |
|
|
|
3607 |
|
|
/* Output the count also if it is zero, but only if this is
|
3608 |
|
|
mi. FIXME: Should have a better test for this. */
|
3609 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
3610 |
|
|
if (!part_of_multiple && show_breakpoint_hit_counts && b->hit_count == 0)
|
3611 |
|
|
ui_out_field_int (uiout, "times", b->hit_count);
|
3612 |
|
|
|
3613 |
|
|
if (!part_of_multiple && b->ignore_count)
|
3614 |
|
|
{
|
3615 |
|
|
annotate_field (8);
|
3616 |
|
|
ui_out_text (uiout, "\tignore next ");
|
3617 |
|
|
ui_out_field_int (uiout, "ignore", b->ignore_count);
|
3618 |
|
|
ui_out_text (uiout, " hits\n");
|
3619 |
|
|
}
|
3620 |
|
|
|
3621 |
|
|
if (!part_of_multiple && (l = b->commands))
|
3622 |
|
|
{
|
3623 |
|
|
struct cleanup *script_chain;
|
3624 |
|
|
|
3625 |
|
|
annotate_field (9);
|
3626 |
|
|
script_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "script");
|
3627 |
|
|
print_command_lines (uiout, l, 4);
|
3628 |
|
|
do_cleanups (script_chain);
|
3629 |
|
|
}
|
3630 |
|
|
do_cleanups (bkpt_chain);
|
3631 |
|
|
do_cleanups (old_chain);
|
3632 |
|
|
}
|
3633 |
|
|
|
3634 |
|
|
static void
|
3635 |
|
|
print_one_breakpoint (struct breakpoint *b,
|
3636 |
|
|
CORE_ADDR *last_addr)
|
3637 |
|
|
{
|
3638 |
|
|
print_one_breakpoint_location (b, NULL, 0, last_addr);
|
3639 |
|
|
|
3640 |
|
|
/* If this breakpoint has custom print function,
|
3641 |
|
|
it's already printed. Otherwise, print individual
|
3642 |
|
|
locations, if any. */
|
3643 |
|
|
if (b->ops == NULL || b->ops->print_one == NULL)
|
3644 |
|
|
{
|
3645 |
|
|
/* If breakpoint has a single location that is
|
3646 |
|
|
disabled, we print it as if it had
|
3647 |
|
|
several locations, since otherwise it's hard to
|
3648 |
|
|
represent "breakpoint enabled, location disabled"
|
3649 |
|
|
situation.
|
3650 |
|
|
Note that while hardware watchpoints have
|
3651 |
|
|
several locations internally, that's no a property
|
3652 |
|
|
exposed to user. */
|
3653 |
|
|
if (b->loc
|
3654 |
|
|
&& !is_hardware_watchpoint (b)
|
3655 |
|
|
&& (b->loc->next || !b->loc->enabled)
|
3656 |
|
|
&& !ui_out_is_mi_like_p (uiout))
|
3657 |
|
|
{
|
3658 |
|
|
struct bp_location *loc;
|
3659 |
|
|
int n = 1;
|
3660 |
|
|
for (loc = b->loc; loc; loc = loc->next, ++n)
|
3661 |
|
|
print_one_breakpoint_location (b, loc, n, last_addr);
|
3662 |
|
|
}
|
3663 |
|
|
}
|
3664 |
|
|
}
|
3665 |
|
|
|
3666 |
|
|
|
3667 |
|
|
struct captured_breakpoint_query_args
|
3668 |
|
|
{
|
3669 |
|
|
int bnum;
|
3670 |
|
|
};
|
3671 |
|
|
|
3672 |
|
|
static int
|
3673 |
|
|
do_captured_breakpoint_query (struct ui_out *uiout, void *data)
|
3674 |
|
|
{
|
3675 |
|
|
struct captured_breakpoint_query_args *args = data;
|
3676 |
|
|
struct breakpoint *b;
|
3677 |
|
|
CORE_ADDR dummy_addr = 0;
|
3678 |
|
|
ALL_BREAKPOINTS (b)
|
3679 |
|
|
{
|
3680 |
|
|
if (args->bnum == b->number)
|
3681 |
|
|
{
|
3682 |
|
|
print_one_breakpoint (b, &dummy_addr);
|
3683 |
|
|
return GDB_RC_OK;
|
3684 |
|
|
}
|
3685 |
|
|
}
|
3686 |
|
|
return GDB_RC_NONE;
|
3687 |
|
|
}
|
3688 |
|
|
|
3689 |
|
|
enum gdb_rc
|
3690 |
|
|
gdb_breakpoint_query (struct ui_out *uiout, int bnum, char **error_message)
|
3691 |
|
|
{
|
3692 |
|
|
struct captured_breakpoint_query_args args;
|
3693 |
|
|
args.bnum = bnum;
|
3694 |
|
|
/* For the moment we don't trust print_one_breakpoint() to not throw
|
3695 |
|
|
an error. */
|
3696 |
|
|
if (catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args,
|
3697 |
|
|
error_message, RETURN_MASK_ALL) < 0)
|
3698 |
|
|
return GDB_RC_FAIL;
|
3699 |
|
|
else
|
3700 |
|
|
return GDB_RC_OK;
|
3701 |
|
|
}
|
3702 |
|
|
|
3703 |
|
|
/* Return non-zero if B is user settable (breakpoints, watchpoints,
|
3704 |
|
|
catchpoints, et.al.). */
|
3705 |
|
|
|
3706 |
|
|
static int
|
3707 |
|
|
user_settable_breakpoint (const struct breakpoint *b)
|
3708 |
|
|
{
|
3709 |
|
|
return (b->type == bp_breakpoint
|
3710 |
|
|
|| b->type == bp_catch_load
|
3711 |
|
|
|| b->type == bp_catch_unload
|
3712 |
|
|
|| b->type == bp_catch_fork
|
3713 |
|
|
|| b->type == bp_catch_vfork
|
3714 |
|
|
|| b->type == bp_catch_exec
|
3715 |
|
|
|| b->type == bp_hardware_breakpoint
|
3716 |
|
|
|| b->type == bp_watchpoint
|
3717 |
|
|
|| b->type == bp_read_watchpoint
|
3718 |
|
|
|| b->type == bp_access_watchpoint
|
3719 |
|
|
|| b->type == bp_hardware_watchpoint);
|
3720 |
|
|
}
|
3721 |
|
|
|
3722 |
|
|
/* Print information on user settable breakpoint (watchpoint, etc)
|
3723 |
|
|
number BNUM. If BNUM is -1 print all user settable breakpoints.
|
3724 |
|
|
If ALLFLAG is non-zero, include non- user settable breakpoints. */
|
3725 |
|
|
|
3726 |
|
|
static void
|
3727 |
|
|
breakpoint_1 (int bnum, int allflag)
|
3728 |
|
|
{
|
3729 |
|
|
struct breakpoint *b;
|
3730 |
|
|
CORE_ADDR last_addr = (CORE_ADDR) -1;
|
3731 |
|
|
int nr_printable_breakpoints;
|
3732 |
|
|
struct cleanup *bkpttbl_chain;
|
3733 |
|
|
|
3734 |
|
|
/* Compute the number of rows in the table. */
|
3735 |
|
|
nr_printable_breakpoints = 0;
|
3736 |
|
|
ALL_BREAKPOINTS (b)
|
3737 |
|
|
if (bnum == -1
|
3738 |
|
|
|| bnum == b->number)
|
3739 |
|
|
{
|
3740 |
|
|
if (allflag || user_settable_breakpoint (b))
|
3741 |
|
|
nr_printable_breakpoints++;
|
3742 |
|
|
}
|
3743 |
|
|
|
3744 |
|
|
if (addressprint)
|
3745 |
|
|
bkpttbl_chain
|
3746 |
|
|
= make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
|
3747 |
|
|
"BreakpointTable");
|
3748 |
|
|
else
|
3749 |
|
|
bkpttbl_chain
|
3750 |
|
|
= make_cleanup_ui_out_table_begin_end (uiout, 5, nr_printable_breakpoints,
|
3751 |
|
|
"BreakpointTable");
|
3752 |
|
|
|
3753 |
|
|
if (nr_printable_breakpoints > 0)
|
3754 |
|
|
annotate_breakpoints_headers ();
|
3755 |
|
|
if (nr_printable_breakpoints > 0)
|
3756 |
|
|
annotate_field (0);
|
3757 |
|
|
ui_out_table_header (uiout, 7, ui_left, "number", "Num"); /* 1 */
|
3758 |
|
|
if (nr_printable_breakpoints > 0)
|
3759 |
|
|
annotate_field (1);
|
3760 |
|
|
ui_out_table_header (uiout, 14, ui_left, "type", "Type"); /* 2 */
|
3761 |
|
|
if (nr_printable_breakpoints > 0)
|
3762 |
|
|
annotate_field (2);
|
3763 |
|
|
ui_out_table_header (uiout, 4, ui_left, "disp", "Disp"); /* 3 */
|
3764 |
|
|
if (nr_printable_breakpoints > 0)
|
3765 |
|
|
annotate_field (3);
|
3766 |
|
|
ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb"); /* 4 */
|
3767 |
|
|
if (addressprint)
|
3768 |
|
|
{
|
3769 |
|
|
if (nr_printable_breakpoints > 0)
|
3770 |
|
|
annotate_field (4);
|
3771 |
|
|
if (gdbarch_addr_bit (current_gdbarch) <= 32)
|
3772 |
|
|
ui_out_table_header (uiout, 10, ui_left, "addr", "Address");/* 5 */
|
3773 |
|
|
else
|
3774 |
|
|
ui_out_table_header (uiout, 18, ui_left, "addr", "Address");/* 5 */
|
3775 |
|
|
}
|
3776 |
|
|
if (nr_printable_breakpoints > 0)
|
3777 |
|
|
annotate_field (5);
|
3778 |
|
|
ui_out_table_header (uiout, 40, ui_noalign, "what", "What"); /* 6 */
|
3779 |
|
|
ui_out_table_body (uiout);
|
3780 |
|
|
if (nr_printable_breakpoints > 0)
|
3781 |
|
|
annotate_breakpoints_table ();
|
3782 |
|
|
|
3783 |
|
|
ALL_BREAKPOINTS (b)
|
3784 |
|
|
if (bnum == -1
|
3785 |
|
|
|| bnum == b->number)
|
3786 |
|
|
{
|
3787 |
|
|
/* We only print out user settable breakpoints unless the
|
3788 |
|
|
allflag is set. */
|
3789 |
|
|
if (allflag || user_settable_breakpoint (b))
|
3790 |
|
|
print_one_breakpoint (b, &last_addr);
|
3791 |
|
|
}
|
3792 |
|
|
|
3793 |
|
|
do_cleanups (bkpttbl_chain);
|
3794 |
|
|
|
3795 |
|
|
if (nr_printable_breakpoints == 0)
|
3796 |
|
|
{
|
3797 |
|
|
if (bnum == -1)
|
3798 |
|
|
ui_out_message (uiout, 0, "No breakpoints or watchpoints.\n");
|
3799 |
|
|
else
|
3800 |
|
|
ui_out_message (uiout, 0, "No breakpoint or watchpoint number %d.\n",
|
3801 |
|
|
bnum);
|
3802 |
|
|
}
|
3803 |
|
|
else
|
3804 |
|
|
{
|
3805 |
|
|
/* Compare against (CORE_ADDR)-1 in case some compiler decides
|
3806 |
|
|
that a comparison of an unsigned with -1 is always false. */
|
3807 |
|
|
if (last_addr != (CORE_ADDR) -1 && !server_command)
|
3808 |
|
|
set_next_address (last_addr);
|
3809 |
|
|
}
|
3810 |
|
|
|
3811 |
|
|
/* FIXME? Should this be moved up so that it is only called when
|
3812 |
|
|
there have been breakpoints? */
|
3813 |
|
|
annotate_breakpoints_table_end ();
|
3814 |
|
|
}
|
3815 |
|
|
|
3816 |
|
|
static void
|
3817 |
|
|
breakpoints_info (char *bnum_exp, int from_tty)
|
3818 |
|
|
{
|
3819 |
|
|
int bnum = -1;
|
3820 |
|
|
|
3821 |
|
|
if (bnum_exp)
|
3822 |
|
|
bnum = parse_and_eval_long (bnum_exp);
|
3823 |
|
|
|
3824 |
|
|
breakpoint_1 (bnum, 0);
|
3825 |
|
|
}
|
3826 |
|
|
|
3827 |
|
|
static void
|
3828 |
|
|
maintenance_info_breakpoints (char *bnum_exp, int from_tty)
|
3829 |
|
|
{
|
3830 |
|
|
int bnum = -1;
|
3831 |
|
|
|
3832 |
|
|
if (bnum_exp)
|
3833 |
|
|
bnum = parse_and_eval_long (bnum_exp);
|
3834 |
|
|
|
3835 |
|
|
breakpoint_1 (bnum, 1);
|
3836 |
|
|
}
|
3837 |
|
|
|
3838 |
|
|
static int
|
3839 |
|
|
breakpoint_has_pc (struct breakpoint *b, CORE_ADDR pc, asection *section)
|
3840 |
|
|
{
|
3841 |
|
|
struct bp_location *bl = b->loc;
|
3842 |
|
|
for (; bl; bl = bl->next)
|
3843 |
|
|
{
|
3844 |
|
|
if (bl->address == pc
|
3845 |
|
|
&& (!overlay_debugging || bl->section == section))
|
3846 |
|
|
return 1;
|
3847 |
|
|
}
|
3848 |
|
|
return 0;
|
3849 |
|
|
}
|
3850 |
|
|
|
3851 |
|
|
/* Print a message describing any breakpoints set at PC. */
|
3852 |
|
|
|
3853 |
|
|
static void
|
3854 |
|
|
describe_other_breakpoints (CORE_ADDR pc, asection *section, int thread)
|
3855 |
|
|
{
|
3856 |
|
|
int others = 0;
|
3857 |
|
|
struct breakpoint *b;
|
3858 |
|
|
|
3859 |
|
|
ALL_BREAKPOINTS (b)
|
3860 |
|
|
others += breakpoint_has_pc (b, pc, section);
|
3861 |
|
|
if (others > 0)
|
3862 |
|
|
{
|
3863 |
|
|
if (others == 1)
|
3864 |
|
|
printf_filtered (_("Note: breakpoint "));
|
3865 |
|
|
else /* if (others == ???) */
|
3866 |
|
|
printf_filtered (_("Note: breakpoints "));
|
3867 |
|
|
ALL_BREAKPOINTS (b)
|
3868 |
|
|
if (breakpoint_has_pc (b, pc, section))
|
3869 |
|
|
{
|
3870 |
|
|
others--;
|
3871 |
|
|
printf_filtered ("%d", b->number);
|
3872 |
|
|
if (b->thread == -1 && thread != -1)
|
3873 |
|
|
printf_filtered (" (all threads)");
|
3874 |
|
|
else if (b->thread != -1)
|
3875 |
|
|
printf_filtered (" (thread %d)", b->thread);
|
3876 |
|
|
printf_filtered ("%s%s ",
|
3877 |
|
|
((b->enable_state == bp_disabled ||
|
3878 |
|
|
b->enable_state == bp_call_disabled)
|
3879 |
|
|
? " (disabled)"
|
3880 |
|
|
: b->enable_state == bp_permanent
|
3881 |
|
|
? " (permanent)"
|
3882 |
|
|
: ""),
|
3883 |
|
|
(others > 1) ? ","
|
3884 |
|
|
: ((others == 1) ? " and" : ""));
|
3885 |
|
|
}
|
3886 |
|
|
printf_filtered (_("also set at pc "));
|
3887 |
|
|
fputs_filtered (paddress (pc), gdb_stdout);
|
3888 |
|
|
printf_filtered (".\n");
|
3889 |
|
|
}
|
3890 |
|
|
}
|
3891 |
|
|
|
3892 |
|
|
/* Set the default place to put a breakpoint
|
3893 |
|
|
for the `break' command with no arguments. */
|
3894 |
|
|
|
3895 |
|
|
void
|
3896 |
|
|
set_default_breakpoint (int valid, CORE_ADDR addr, struct symtab *symtab,
|
3897 |
|
|
int line)
|
3898 |
|
|
{
|
3899 |
|
|
default_breakpoint_valid = valid;
|
3900 |
|
|
default_breakpoint_address = addr;
|
3901 |
|
|
default_breakpoint_symtab = symtab;
|
3902 |
|
|
default_breakpoint_line = line;
|
3903 |
|
|
}
|
3904 |
|
|
|
3905 |
|
|
/* Return true iff it is meaningful to use the address member of
|
3906 |
|
|
BPT. For some breakpoint types, the address member is irrelevant
|
3907 |
|
|
and it makes no sense to attempt to compare it to other addresses
|
3908 |
|
|
(or use it for any other purpose either).
|
3909 |
|
|
|
3910 |
|
|
More specifically, each of the following breakpoint types will always
|
3911 |
|
|
have a zero valued address and we don't want check_duplicates() to mark
|
3912 |
|
|
breakpoints of any of these types to be a duplicate of an actual
|
3913 |
|
|
breakpoint at address zero:
|
3914 |
|
|
|
3915 |
|
|
bp_watchpoint
|
3916 |
|
|
bp_hardware_watchpoint
|
3917 |
|
|
bp_read_watchpoint
|
3918 |
|
|
bp_access_watchpoint
|
3919 |
|
|
bp_catch_exec
|
3920 |
|
|
bp_longjmp_resume
|
3921 |
|
|
bp_catch_fork
|
3922 |
|
|
bp_catch_vork */
|
3923 |
|
|
|
3924 |
|
|
static int
|
3925 |
|
|
breakpoint_address_is_meaningful (struct breakpoint *bpt)
|
3926 |
|
|
{
|
3927 |
|
|
enum bptype type = bpt->type;
|
3928 |
|
|
|
3929 |
|
|
return (type != bp_watchpoint
|
3930 |
|
|
&& type != bp_hardware_watchpoint
|
3931 |
|
|
&& type != bp_read_watchpoint
|
3932 |
|
|
&& type != bp_access_watchpoint
|
3933 |
|
|
&& type != bp_catch_exec
|
3934 |
|
|
&& type != bp_longjmp_resume
|
3935 |
|
|
&& type != bp_catch_fork
|
3936 |
|
|
&& type != bp_catch_vfork);
|
3937 |
|
|
}
|
3938 |
|
|
|
3939 |
|
|
/* Rescan breakpoints at the same address and section as BPT,
|
3940 |
|
|
marking the first one as "first" and any others as "duplicates".
|
3941 |
|
|
This is so that the bpt instruction is only inserted once.
|
3942 |
|
|
If we have a permanent breakpoint at the same place as BPT, make
|
3943 |
|
|
that one the official one, and the rest as duplicates. */
|
3944 |
|
|
|
3945 |
|
|
static void
|
3946 |
|
|
check_duplicates_for (CORE_ADDR address, asection *section)
|
3947 |
|
|
{
|
3948 |
|
|
struct bp_location *b;
|
3949 |
|
|
int count = 0;
|
3950 |
|
|
struct bp_location *perm_bp = 0;
|
3951 |
|
|
|
3952 |
|
|
ALL_BP_LOCATIONS (b)
|
3953 |
|
|
if (b->owner->enable_state != bp_disabled
|
3954 |
|
|
&& b->owner->enable_state != bp_call_disabled
|
3955 |
|
|
&& b->enabled
|
3956 |
|
|
&& !b->shlib_disabled
|
3957 |
|
|
&& b->address == address /* address / overlay match */
|
3958 |
|
|
&& (!overlay_debugging || b->section == section)
|
3959 |
|
|
&& breakpoint_address_is_meaningful (b->owner))
|
3960 |
|
|
{
|
3961 |
|
|
/* Have we found a permanent breakpoint? */
|
3962 |
|
|
if (b->owner->enable_state == bp_permanent)
|
3963 |
|
|
{
|
3964 |
|
|
perm_bp = b;
|
3965 |
|
|
break;
|
3966 |
|
|
}
|
3967 |
|
|
|
3968 |
|
|
count++;
|
3969 |
|
|
b->duplicate = count > 1;
|
3970 |
|
|
}
|
3971 |
|
|
|
3972 |
|
|
/* If we found a permanent breakpoint at this address, go over the
|
3973 |
|
|
list again and declare all the other breakpoints there to be the
|
3974 |
|
|
duplicates. */
|
3975 |
|
|
if (perm_bp)
|
3976 |
|
|
{
|
3977 |
|
|
perm_bp->duplicate = 0;
|
3978 |
|
|
|
3979 |
|
|
/* Permanent breakpoint should always be inserted. */
|
3980 |
|
|
if (! perm_bp->inserted)
|
3981 |
|
|
internal_error (__FILE__, __LINE__,
|
3982 |
|
|
_("allegedly permanent breakpoint is not "
|
3983 |
|
|
"actually inserted"));
|
3984 |
|
|
|
3985 |
|
|
ALL_BP_LOCATIONS (b)
|
3986 |
|
|
if (b != perm_bp)
|
3987 |
|
|
{
|
3988 |
|
|
if (b->owner->enable_state != bp_disabled
|
3989 |
|
|
&& b->owner->enable_state != bp_call_disabled
|
3990 |
|
|
&& b->enabled && !b->shlib_disabled
|
3991 |
|
|
&& b->address == address /* address / overlay match */
|
3992 |
|
|
&& (!overlay_debugging || b->section == section)
|
3993 |
|
|
&& breakpoint_address_is_meaningful (b->owner))
|
3994 |
|
|
{
|
3995 |
|
|
if (b->inserted)
|
3996 |
|
|
internal_error (__FILE__, __LINE__,
|
3997 |
|
|
_("another breakpoint was inserted on top of "
|
3998 |
|
|
"a permanent breakpoint"));
|
3999 |
|
|
|
4000 |
|
|
b->duplicate = 1;
|
4001 |
|
|
}
|
4002 |
|
|
}
|
4003 |
|
|
}
|
4004 |
|
|
}
|
4005 |
|
|
|
4006 |
|
|
static void
|
4007 |
|
|
check_duplicates (struct breakpoint *bpt)
|
4008 |
|
|
{
|
4009 |
|
|
struct bp_location *bl = bpt->loc;
|
4010 |
|
|
|
4011 |
|
|
if (! breakpoint_address_is_meaningful (bpt))
|
4012 |
|
|
return;
|
4013 |
|
|
|
4014 |
|
|
for (; bl; bl = bl->next)
|
4015 |
|
|
check_duplicates_for (bl->address, bl->section);
|
4016 |
|
|
}
|
4017 |
|
|
|
4018 |
|
|
static void
|
4019 |
|
|
breakpoint_adjustment_warning (CORE_ADDR from_addr, CORE_ADDR to_addr,
|
4020 |
|
|
int bnum, int have_bnum)
|
4021 |
|
|
{
|
4022 |
|
|
char astr1[40];
|
4023 |
|
|
char astr2[40];
|
4024 |
|
|
|
4025 |
|
|
strcpy (astr1, hex_string_custom ((unsigned long) from_addr, 8));
|
4026 |
|
|
strcpy (astr2, hex_string_custom ((unsigned long) to_addr, 8));
|
4027 |
|
|
if (have_bnum)
|
4028 |
|
|
warning (_("Breakpoint %d address previously adjusted from %s to %s."),
|
4029 |
|
|
bnum, astr1, astr2);
|
4030 |
|
|
else
|
4031 |
|
|
warning (_("Breakpoint address adjusted from %s to %s."), astr1, astr2);
|
4032 |
|
|
}
|
4033 |
|
|
|
4034 |
|
|
/* Adjust a breakpoint's address to account for architectural constraints
|
4035 |
|
|
on breakpoint placement. Return the adjusted address. Note: Very
|
4036 |
|
|
few targets require this kind of adjustment. For most targets,
|
4037 |
|
|
this function is simply the identity function. */
|
4038 |
|
|
|
4039 |
|
|
static CORE_ADDR
|
4040 |
|
|
adjust_breakpoint_address (CORE_ADDR bpaddr, enum bptype bptype)
|
4041 |
|
|
{
|
4042 |
|
|
if (!gdbarch_adjust_breakpoint_address_p (current_gdbarch))
|
4043 |
|
|
{
|
4044 |
|
|
/* Very few targets need any kind of breakpoint adjustment. */
|
4045 |
|
|
return bpaddr;
|
4046 |
|
|
}
|
4047 |
|
|
else if (bptype == bp_watchpoint
|
4048 |
|
|
|| bptype == bp_hardware_watchpoint
|
4049 |
|
|
|| bptype == bp_read_watchpoint
|
4050 |
|
|
|| bptype == bp_access_watchpoint
|
4051 |
|
|
|| bptype == bp_catch_fork
|
4052 |
|
|
|| bptype == bp_catch_vfork
|
4053 |
|
|
|| bptype == bp_catch_exec)
|
4054 |
|
|
{
|
4055 |
|
|
/* Watchpoints and the various bp_catch_* eventpoints should not
|
4056 |
|
|
have their addresses modified. */
|
4057 |
|
|
return bpaddr;
|
4058 |
|
|
}
|
4059 |
|
|
else
|
4060 |
|
|
{
|
4061 |
|
|
CORE_ADDR adjusted_bpaddr;
|
4062 |
|
|
|
4063 |
|
|
/* Some targets have architectural constraints on the placement
|
4064 |
|
|
of breakpoint instructions. Obtain the adjusted address. */
|
4065 |
|
|
adjusted_bpaddr = gdbarch_adjust_breakpoint_address (current_gdbarch,
|
4066 |
|
|
bpaddr);
|
4067 |
|
|
|
4068 |
|
|
/* An adjusted breakpoint address can significantly alter
|
4069 |
|
|
a user's expectations. Print a warning if an adjustment
|
4070 |
|
|
is required. */
|
4071 |
|
|
if (adjusted_bpaddr != bpaddr)
|
4072 |
|
|
breakpoint_adjustment_warning (bpaddr, adjusted_bpaddr, 0, 0);
|
4073 |
|
|
|
4074 |
|
|
return adjusted_bpaddr;
|
4075 |
|
|
}
|
4076 |
|
|
}
|
4077 |
|
|
|
4078 |
|
|
/* Allocate a struct bp_location. */
|
4079 |
|
|
|
4080 |
|
|
static struct bp_location *
|
4081 |
|
|
allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type)
|
4082 |
|
|
{
|
4083 |
|
|
struct bp_location *loc, *loc_p;
|
4084 |
|
|
|
4085 |
|
|
loc = xmalloc (sizeof (struct bp_location));
|
4086 |
|
|
memset (loc, 0, sizeof (*loc));
|
4087 |
|
|
|
4088 |
|
|
loc->owner = bpt;
|
4089 |
|
|
loc->cond = NULL;
|
4090 |
|
|
loc->shlib_disabled = 0;
|
4091 |
|
|
loc->enabled = 1;
|
4092 |
|
|
|
4093 |
|
|
switch (bp_type)
|
4094 |
|
|
{
|
4095 |
|
|
case bp_breakpoint:
|
4096 |
|
|
case bp_until:
|
4097 |
|
|
case bp_finish:
|
4098 |
|
|
case bp_longjmp:
|
4099 |
|
|
case bp_longjmp_resume:
|
4100 |
|
|
case bp_step_resume:
|
4101 |
|
|
case bp_watchpoint_scope:
|
4102 |
|
|
case bp_call_dummy:
|
4103 |
|
|
case bp_shlib_event:
|
4104 |
|
|
case bp_thread_event:
|
4105 |
|
|
case bp_overlay_event:
|
4106 |
|
|
case bp_catch_load:
|
4107 |
|
|
case bp_catch_unload:
|
4108 |
|
|
loc->loc_type = bp_loc_software_breakpoint;
|
4109 |
|
|
break;
|
4110 |
|
|
case bp_hardware_breakpoint:
|
4111 |
|
|
loc->loc_type = bp_loc_hardware_breakpoint;
|
4112 |
|
|
break;
|
4113 |
|
|
case bp_hardware_watchpoint:
|
4114 |
|
|
case bp_read_watchpoint:
|
4115 |
|
|
case bp_access_watchpoint:
|
4116 |
|
|
loc->loc_type = bp_loc_hardware_watchpoint;
|
4117 |
|
|
break;
|
4118 |
|
|
case bp_watchpoint:
|
4119 |
|
|
case bp_catch_fork:
|
4120 |
|
|
case bp_catch_vfork:
|
4121 |
|
|
case bp_catch_exec:
|
4122 |
|
|
loc->loc_type = bp_loc_other;
|
4123 |
|
|
break;
|
4124 |
|
|
default:
|
4125 |
|
|
internal_error (__FILE__, __LINE__, _("unknown breakpoint type"));
|
4126 |
|
|
}
|
4127 |
|
|
|
4128 |
|
|
/* Add this breakpoint to the end of the chain. */
|
4129 |
|
|
|
4130 |
|
|
loc_p = bp_location_chain;
|
4131 |
|
|
if (loc_p == 0)
|
4132 |
|
|
bp_location_chain = loc;
|
4133 |
|
|
else
|
4134 |
|
|
{
|
4135 |
|
|
while (loc_p->global_next)
|
4136 |
|
|
loc_p = loc_p->global_next;
|
4137 |
|
|
loc_p->global_next = loc;
|
4138 |
|
|
}
|
4139 |
|
|
|
4140 |
|
|
return loc;
|
4141 |
|
|
}
|
4142 |
|
|
|
4143 |
|
|
static void free_bp_location (struct bp_location *loc)
|
4144 |
|
|
{
|
4145 |
|
|
if (loc->cond)
|
4146 |
|
|
xfree (loc->cond);
|
4147 |
|
|
xfree (loc);
|
4148 |
|
|
}
|
4149 |
|
|
|
4150 |
|
|
/* Helper to set_raw_breakpoint below. Creates a breakpoint
|
4151 |
|
|
that has type BPTYPE and has no locations as yet. */
|
4152 |
|
|
|
4153 |
|
|
static struct breakpoint *
|
4154 |
|
|
set_raw_breakpoint_without_location (enum bptype bptype)
|
4155 |
|
|
{
|
4156 |
|
|
struct breakpoint *b, *b1;
|
4157 |
|
|
|
4158 |
|
|
b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
|
4159 |
|
|
memset (b, 0, sizeof (*b));
|
4160 |
|
|
|
4161 |
|
|
b->type = bptype;
|
4162 |
|
|
b->language = current_language->la_language;
|
4163 |
|
|
b->input_radix = input_radix;
|
4164 |
|
|
b->thread = -1;
|
4165 |
|
|
b->enable_state = bp_enabled;
|
4166 |
|
|
b->next = 0;
|
4167 |
|
|
b->silent = 0;
|
4168 |
|
|
b->ignore_count = 0;
|
4169 |
|
|
b->commands = NULL;
|
4170 |
|
|
b->frame_id = null_frame_id;
|
4171 |
|
|
b->dll_pathname = NULL;
|
4172 |
|
|
b->triggered_dll_pathname = NULL;
|
4173 |
|
|
b->forked_inferior_pid = 0;
|
4174 |
|
|
b->exec_pathname = NULL;
|
4175 |
|
|
b->ops = NULL;
|
4176 |
|
|
b->condition_not_parsed = 0;
|
4177 |
|
|
|
4178 |
|
|
/* Add this breakpoint to the end of the chain
|
4179 |
|
|
so that a list of breakpoints will come out in order
|
4180 |
|
|
of increasing numbers. */
|
4181 |
|
|
|
4182 |
|
|
b1 = breakpoint_chain;
|
4183 |
|
|
if (b1 == 0)
|
4184 |
|
|
breakpoint_chain = b;
|
4185 |
|
|
else
|
4186 |
|
|
{
|
4187 |
|
|
while (b1->next)
|
4188 |
|
|
b1 = b1->next;
|
4189 |
|
|
b1->next = b;
|
4190 |
|
|
}
|
4191 |
|
|
return b;
|
4192 |
|
|
}
|
4193 |
|
|
|
4194 |
|
|
/* Initialize loc->function_name. */
|
4195 |
|
|
static void
|
4196 |
|
|
set_breakpoint_location_function (struct bp_location *loc)
|
4197 |
|
|
{
|
4198 |
|
|
if (loc->owner->type == bp_breakpoint
|
4199 |
|
|
|| loc->owner->type == bp_hardware_breakpoint)
|
4200 |
|
|
{
|
4201 |
|
|
find_pc_partial_function (loc->address, &(loc->function_name),
|
4202 |
|
|
NULL, NULL);
|
4203 |
|
|
if (loc->function_name)
|
4204 |
|
|
loc->function_name = xstrdup (loc->function_name);
|
4205 |
|
|
}
|
4206 |
|
|
}
|
4207 |
|
|
|
4208 |
|
|
/* set_raw_breakpoint is a low level routine for allocating and
|
4209 |
|
|
partially initializing a breakpoint of type BPTYPE. The newly
|
4210 |
|
|
created breakpoint's address, section, source file name, and line
|
4211 |
|
|
number are provided by SAL. The newly created and partially
|
4212 |
|
|
initialized breakpoint is added to the breakpoint chain and
|
4213 |
|
|
is also returned as the value of this function.
|
4214 |
|
|
|
4215 |
|
|
It is expected that the caller will complete the initialization of
|
4216 |
|
|
the newly created breakpoint struct as well as output any status
|
4217 |
|
|
information regarding the creation of a new breakpoint. In
|
4218 |
|
|
particular, set_raw_breakpoint does NOT set the breakpoint
|
4219 |
|
|
number! Care should be taken to not allow an error to occur
|
4220 |
|
|
prior to completing the initialization of the breakpoint. If this
|
4221 |
|
|
should happen, a bogus breakpoint will be left on the chain. */
|
4222 |
|
|
|
4223 |
|
|
struct breakpoint *
|
4224 |
|
|
set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
|
4225 |
|
|
{
|
4226 |
|
|
struct breakpoint *b = set_raw_breakpoint_without_location (bptype);
|
4227 |
|
|
CORE_ADDR adjusted_address;
|
4228 |
|
|
|
4229 |
|
|
/* Adjust the breakpoint's address prior to allocating a location.
|
4230 |
|
|
Once we call allocate_bp_location(), that mostly uninitialized
|
4231 |
|
|
location will be placed on the location chain. Adjustment of the
|
4232 |
|
|
breakpoint may cause read_memory_nobpt() to be called and we do
|
4233 |
|
|
not want its scan of the location chain to find a breakpoint and
|
4234 |
|
|
location that's only been partially initialized. */
|
4235 |
|
|
adjusted_address = adjust_breakpoint_address (sal.pc, bptype);
|
4236 |
|
|
|
4237 |
|
|
b->loc = allocate_bp_location (b, bptype);
|
4238 |
|
|
b->loc->requested_address = sal.pc;
|
4239 |
|
|
b->loc->address = adjusted_address;
|
4240 |
|
|
|
4241 |
|
|
if (sal.symtab == NULL)
|
4242 |
|
|
b->source_file = NULL;
|
4243 |
|
|
else
|
4244 |
|
|
b->source_file = savestring (sal.symtab->filename,
|
4245 |
|
|
strlen (sal.symtab->filename));
|
4246 |
|
|
b->loc->section = sal.section;
|
4247 |
|
|
b->line_number = sal.line;
|
4248 |
|
|
|
4249 |
|
|
set_breakpoint_location_function (b->loc);
|
4250 |
|
|
|
4251 |
|
|
check_duplicates (b);
|
4252 |
|
|
breakpoints_changed ();
|
4253 |
|
|
|
4254 |
|
|
return b;
|
4255 |
|
|
}
|
4256 |
|
|
|
4257 |
|
|
|
4258 |
|
|
/* Note that the breakpoint object B describes a permanent breakpoint
|
4259 |
|
|
instruction, hard-wired into the inferior's code. */
|
4260 |
|
|
void
|
4261 |
|
|
make_breakpoint_permanent (struct breakpoint *b)
|
4262 |
|
|
{
|
4263 |
|
|
struct bp_location *bl;
|
4264 |
|
|
b->enable_state = bp_permanent;
|
4265 |
|
|
|
4266 |
|
|
/* By definition, permanent breakpoints are already present in the code.
|
4267 |
|
|
Mark all locations as inserted. For now, make_breakpoint_permanent
|
4268 |
|
|
is called in just one place, so it's hard to say if it's reasonable
|
4269 |
|
|
to have permanent breakpoint with multiple locations or not,
|
4270 |
|
|
but it's easy to implmement. */
|
4271 |
|
|
for (bl = b->loc; bl; bl = bl->next)
|
4272 |
|
|
bl->inserted = 1;
|
4273 |
|
|
}
|
4274 |
|
|
|
4275 |
|
|
static struct breakpoint *
|
4276 |
|
|
create_internal_breakpoint (CORE_ADDR address, enum bptype type)
|
4277 |
|
|
{
|
4278 |
|
|
static int internal_breakpoint_number = -1;
|
4279 |
|
|
struct symtab_and_line sal;
|
4280 |
|
|
struct breakpoint *b;
|
4281 |
|
|
|
4282 |
|
|
init_sal (&sal); /* initialize to zeroes */
|
4283 |
|
|
|
4284 |
|
|
sal.pc = address;
|
4285 |
|
|
sal.section = find_pc_overlay (sal.pc);
|
4286 |
|
|
|
4287 |
|
|
b = set_raw_breakpoint (sal, type);
|
4288 |
|
|
b->number = internal_breakpoint_number--;
|
4289 |
|
|
b->disposition = disp_donttouch;
|
4290 |
|
|
|
4291 |
|
|
return b;
|
4292 |
|
|
}
|
4293 |
|
|
|
4294 |
|
|
|
4295 |
|
|
static void
|
4296 |
|
|
create_longjmp_breakpoint (char *func_name)
|
4297 |
|
|
{
|
4298 |
|
|
struct breakpoint *b;
|
4299 |
|
|
struct minimal_symbol *m;
|
4300 |
|
|
|
4301 |
|
|
if (func_name == NULL)
|
4302 |
|
|
b = create_internal_breakpoint (0, bp_longjmp_resume);
|
4303 |
|
|
else
|
4304 |
|
|
{
|
4305 |
|
|
if ((m = lookup_minimal_symbol_text (func_name, NULL)) == NULL)
|
4306 |
|
|
return;
|
4307 |
|
|
|
4308 |
|
|
b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m), bp_longjmp);
|
4309 |
|
|
}
|
4310 |
|
|
|
4311 |
|
|
b->enable_state = bp_disabled;
|
4312 |
|
|
b->silent = 1;
|
4313 |
|
|
if (func_name)
|
4314 |
|
|
b->addr_string = xstrdup (func_name);
|
4315 |
|
|
}
|
4316 |
|
|
|
4317 |
|
|
/* Call this routine when stepping and nexting to enable a breakpoint
|
4318 |
|
|
if we do a longjmp(). When we hit that breakpoint, call
|
4319 |
|
|
set_longjmp_resume_breakpoint() to figure out where we are going. */
|
4320 |
|
|
|
4321 |
|
|
void
|
4322 |
|
|
enable_longjmp_breakpoint (void)
|
4323 |
|
|
{
|
4324 |
|
|
struct breakpoint *b;
|
4325 |
|
|
|
4326 |
|
|
ALL_BREAKPOINTS (b)
|
4327 |
|
|
if (b->type == bp_longjmp)
|
4328 |
|
|
{
|
4329 |
|
|
b->enable_state = bp_enabled;
|
4330 |
|
|
check_duplicates (b);
|
4331 |
|
|
}
|
4332 |
|
|
}
|
4333 |
|
|
|
4334 |
|
|
void
|
4335 |
|
|
disable_longjmp_breakpoint (void)
|
4336 |
|
|
{
|
4337 |
|
|
struct breakpoint *b;
|
4338 |
|
|
|
4339 |
|
|
ALL_BREAKPOINTS (b)
|
4340 |
|
|
if (b->type == bp_longjmp
|
4341 |
|
|
|| b->type == bp_longjmp_resume)
|
4342 |
|
|
{
|
4343 |
|
|
b->enable_state = bp_disabled;
|
4344 |
|
|
check_duplicates (b);
|
4345 |
|
|
}
|
4346 |
|
|
}
|
4347 |
|
|
|
4348 |
|
|
static void
|
4349 |
|
|
create_overlay_event_breakpoint (char *func_name)
|
4350 |
|
|
{
|
4351 |
|
|
struct breakpoint *b;
|
4352 |
|
|
struct minimal_symbol *m;
|
4353 |
|
|
|
4354 |
|
|
if ((m = lookup_minimal_symbol_text (func_name, NULL)) == NULL)
|
4355 |
|
|
return;
|
4356 |
|
|
|
4357 |
|
|
b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
|
4358 |
|
|
bp_overlay_event);
|
4359 |
|
|
b->addr_string = xstrdup (func_name);
|
4360 |
|
|
|
4361 |
|
|
if (overlay_debugging == ovly_auto)
|
4362 |
|
|
{
|
4363 |
|
|
b->enable_state = bp_enabled;
|
4364 |
|
|
overlay_events_enabled = 1;
|
4365 |
|
|
}
|
4366 |
|
|
else
|
4367 |
|
|
{
|
4368 |
|
|
b->enable_state = bp_disabled;
|
4369 |
|
|
overlay_events_enabled = 0;
|
4370 |
|
|
}
|
4371 |
|
|
}
|
4372 |
|
|
|
4373 |
|
|
void
|
4374 |
|
|
enable_overlay_breakpoints (void)
|
4375 |
|
|
{
|
4376 |
|
|
struct breakpoint *b;
|
4377 |
|
|
|
4378 |
|
|
ALL_BREAKPOINTS (b)
|
4379 |
|
|
if (b->type == bp_overlay_event)
|
4380 |
|
|
{
|
4381 |
|
|
b->enable_state = bp_enabled;
|
4382 |
|
|
check_duplicates (b);
|
4383 |
|
|
overlay_events_enabled = 1;
|
4384 |
|
|
}
|
4385 |
|
|
}
|
4386 |
|
|
|
4387 |
|
|
void
|
4388 |
|
|
disable_overlay_breakpoints (void)
|
4389 |
|
|
{
|
4390 |
|
|
struct breakpoint *b;
|
4391 |
|
|
|
4392 |
|
|
ALL_BREAKPOINTS (b)
|
4393 |
|
|
if (b->type == bp_overlay_event)
|
4394 |
|
|
{
|
4395 |
|
|
b->enable_state = bp_disabled;
|
4396 |
|
|
check_duplicates (b);
|
4397 |
|
|
overlay_events_enabled = 0;
|
4398 |
|
|
}
|
4399 |
|
|
}
|
4400 |
|
|
|
4401 |
|
|
struct breakpoint *
|
4402 |
|
|
create_thread_event_breakpoint (CORE_ADDR address)
|
4403 |
|
|
{
|
4404 |
|
|
struct breakpoint *b;
|
4405 |
|
|
|
4406 |
|
|
b = create_internal_breakpoint (address, bp_thread_event);
|
4407 |
|
|
|
4408 |
|
|
b->enable_state = bp_enabled;
|
4409 |
|
|
/* addr_string has to be used or breakpoint_re_set will delete me. */
|
4410 |
|
|
b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address));
|
4411 |
|
|
|
4412 |
|
|
return b;
|
4413 |
|
|
}
|
4414 |
|
|
|
4415 |
|
|
void
|
4416 |
|
|
remove_thread_event_breakpoints (void)
|
4417 |
|
|
{
|
4418 |
|
|
struct breakpoint *b, *temp;
|
4419 |
|
|
|
4420 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
4421 |
|
|
if (b->type == bp_thread_event)
|
4422 |
|
|
delete_breakpoint (b);
|
4423 |
|
|
}
|
4424 |
|
|
|
4425 |
|
|
struct captured_parse_breakpoint_args
|
4426 |
|
|
{
|
4427 |
|
|
char **arg_p;
|
4428 |
|
|
struct symtabs_and_lines *sals_p;
|
4429 |
|
|
char ***addr_string_p;
|
4430 |
|
|
int *not_found_ptr;
|
4431 |
|
|
};
|
4432 |
|
|
|
4433 |
|
|
struct lang_and_radix
|
4434 |
|
|
{
|
4435 |
|
|
enum language lang;
|
4436 |
|
|
int radix;
|
4437 |
|
|
};
|
4438 |
|
|
|
4439 |
|
|
|
4440 |
|
|
void
|
4441 |
|
|
remove_solib_event_breakpoints (void)
|
4442 |
|
|
{
|
4443 |
|
|
struct breakpoint *b, *temp;
|
4444 |
|
|
|
4445 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
4446 |
|
|
if (b->type == bp_shlib_event)
|
4447 |
|
|
delete_breakpoint (b);
|
4448 |
|
|
}
|
4449 |
|
|
|
4450 |
|
|
struct breakpoint *
|
4451 |
|
|
create_solib_event_breakpoint (CORE_ADDR address)
|
4452 |
|
|
{
|
4453 |
|
|
struct breakpoint *b;
|
4454 |
|
|
|
4455 |
|
|
b = create_internal_breakpoint (address, bp_shlib_event);
|
4456 |
|
|
return b;
|
4457 |
|
|
}
|
4458 |
|
|
|
4459 |
|
|
/* Disable any breakpoints that are on code in shared libraries. Only
|
4460 |
|
|
apply to enabled breakpoints, disabled ones can just stay disabled. */
|
4461 |
|
|
|
4462 |
|
|
void
|
4463 |
|
|
disable_breakpoints_in_shlibs (void)
|
4464 |
|
|
{
|
4465 |
|
|
struct bp_location *loc;
|
4466 |
|
|
int disabled_shlib_breaks = 0;
|
4467 |
|
|
|
4468 |
|
|
ALL_BP_LOCATIONS (loc)
|
4469 |
|
|
{
|
4470 |
|
|
struct breakpoint *b = loc->owner;
|
4471 |
|
|
/* We apply the check to all breakpoints, including disabled
|
4472 |
|
|
for those with loc->duplicate set. This is so that when breakpoint
|
4473 |
|
|
becomes enabled, or the duplicate is removed, gdb will try to insert
|
4474 |
|
|
all breakpoints. If we don't set shlib_disabled here, we'll try
|
4475 |
|
|
to insert those breakpoints and fail. */
|
4476 |
|
|
if (((b->type == bp_breakpoint) || (b->type == bp_hardware_breakpoint))
|
4477 |
|
|
&& !loc->shlib_disabled
|
4478 |
|
|
#ifdef PC_SOLIB
|
4479 |
|
|
&& PC_SOLIB (loc->address)
|
4480 |
|
|
#else
|
4481 |
|
|
&& solib_address (loc->address)
|
4482 |
|
|
#endif
|
4483 |
|
|
)
|
4484 |
|
|
{
|
4485 |
|
|
loc->shlib_disabled = 1;
|
4486 |
|
|
}
|
4487 |
|
|
}
|
4488 |
|
|
}
|
4489 |
|
|
|
4490 |
|
|
/* Disable any breakpoints that are in in an unloaded shared library. Only
|
4491 |
|
|
apply to enabled breakpoints, disabled ones can just stay disabled. */
|
4492 |
|
|
|
4493 |
|
|
static void
|
4494 |
|
|
disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
|
4495 |
|
|
{
|
4496 |
|
|
struct bp_location *loc;
|
4497 |
|
|
int disabled_shlib_breaks = 0;
|
4498 |
|
|
|
4499 |
|
|
ALL_BP_LOCATIONS (loc)
|
4500 |
|
|
{
|
4501 |
|
|
struct breakpoint *b = loc->owner;
|
4502 |
|
|
if ((loc->loc_type == bp_loc_hardware_breakpoint
|
4503 |
|
|
|| loc->loc_type == bp_loc_software_breakpoint)
|
4504 |
|
|
&& !loc->shlib_disabled)
|
4505 |
|
|
{
|
4506 |
|
|
#ifdef PC_SOLIB
|
4507 |
|
|
char *so_name = PC_SOLIB (loc->address);
|
4508 |
|
|
#else
|
4509 |
|
|
char *so_name = solib_address (loc->address);
|
4510 |
|
|
#endif
|
4511 |
|
|
if (so_name && !strcmp (so_name, solib->so_name))
|
4512 |
|
|
{
|
4513 |
|
|
loc->shlib_disabled = 1;
|
4514 |
|
|
/* At this point, we cannot rely on remove_breakpoint
|
4515 |
|
|
succeeding so we must mark the breakpoint as not inserted
|
4516 |
|
|
to prevent future errors occurring in remove_breakpoints. */
|
4517 |
|
|
loc->inserted = 0;
|
4518 |
|
|
if (!disabled_shlib_breaks)
|
4519 |
|
|
{
|
4520 |
|
|
target_terminal_ours_for_output ();
|
4521 |
|
|
warning (_("Temporarily disabling breakpoints for unloaded shared library \"%s\""),
|
4522 |
|
|
so_name);
|
4523 |
|
|
}
|
4524 |
|
|
disabled_shlib_breaks = 1;
|
4525 |
|
|
}
|
4526 |
|
|
}
|
4527 |
|
|
}
|
4528 |
|
|
}
|
4529 |
|
|
|
4530 |
|
|
static void
|
4531 |
|
|
create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
|
4532 |
|
|
enum bptype bp_kind)
|
4533 |
|
|
{
|
4534 |
|
|
struct symtab_and_line sal;
|
4535 |
|
|
struct breakpoint *b;
|
4536 |
|
|
int thread = -1; /* All threads. */
|
4537 |
|
|
|
4538 |
|
|
init_sal (&sal);
|
4539 |
|
|
sal.pc = 0;
|
4540 |
|
|
sal.symtab = NULL;
|
4541 |
|
|
sal.line = 0;
|
4542 |
|
|
|
4543 |
|
|
b = set_raw_breakpoint (sal, bp_kind);
|
4544 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
4545 |
|
|
b->number = breakpoint_count;
|
4546 |
|
|
b->cond_string = (cond_string == NULL) ?
|
4547 |
|
|
NULL : savestring (cond_string, strlen (cond_string));
|
4548 |
|
|
b->thread = thread;
|
4549 |
|
|
b->addr_string = NULL;
|
4550 |
|
|
b->enable_state = bp_enabled;
|
4551 |
|
|
b->disposition = tempflag ? disp_del : disp_donttouch;
|
4552 |
|
|
b->forked_inferior_pid = 0;
|
4553 |
|
|
|
4554 |
|
|
mention (b);
|
4555 |
|
|
}
|
4556 |
|
|
|
4557 |
|
|
static void
|
4558 |
|
|
create_fork_event_catchpoint (int tempflag, char *cond_string)
|
4559 |
|
|
{
|
4560 |
|
|
create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_fork);
|
4561 |
|
|
}
|
4562 |
|
|
|
4563 |
|
|
static void
|
4564 |
|
|
create_vfork_event_catchpoint (int tempflag, char *cond_string)
|
4565 |
|
|
{
|
4566 |
|
|
create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_vfork);
|
4567 |
|
|
}
|
4568 |
|
|
|
4569 |
|
|
static void
|
4570 |
|
|
create_exec_event_catchpoint (int tempflag, char *cond_string)
|
4571 |
|
|
{
|
4572 |
|
|
struct symtab_and_line sal;
|
4573 |
|
|
struct breakpoint *b;
|
4574 |
|
|
int thread = -1; /* All threads. */
|
4575 |
|
|
|
4576 |
|
|
init_sal (&sal);
|
4577 |
|
|
sal.pc = 0;
|
4578 |
|
|
sal.symtab = NULL;
|
4579 |
|
|
sal.line = 0;
|
4580 |
|
|
|
4581 |
|
|
b = set_raw_breakpoint (sal, bp_catch_exec);
|
4582 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
4583 |
|
|
b->number = breakpoint_count;
|
4584 |
|
|
b->cond_string = (cond_string == NULL) ?
|
4585 |
|
|
NULL : savestring (cond_string, strlen (cond_string));
|
4586 |
|
|
b->thread = thread;
|
4587 |
|
|
b->addr_string = NULL;
|
4588 |
|
|
b->enable_state = bp_enabled;
|
4589 |
|
|
b->disposition = tempflag ? disp_del : disp_donttouch;
|
4590 |
|
|
|
4591 |
|
|
mention (b);
|
4592 |
|
|
}
|
4593 |
|
|
|
4594 |
|
|
static int
|
4595 |
|
|
hw_breakpoint_used_count (void)
|
4596 |
|
|
{
|
4597 |
|
|
struct breakpoint *b;
|
4598 |
|
|
int i = 0;
|
4599 |
|
|
|
4600 |
|
|
ALL_BREAKPOINTS (b)
|
4601 |
|
|
{
|
4602 |
|
|
if (b->type == bp_hardware_breakpoint && b->enable_state == bp_enabled)
|
4603 |
|
|
i++;
|
4604 |
|
|
}
|
4605 |
|
|
|
4606 |
|
|
return i;
|
4607 |
|
|
}
|
4608 |
|
|
|
4609 |
|
|
static int
|
4610 |
|
|
hw_watchpoint_used_count (enum bptype type, int *other_type_used)
|
4611 |
|
|
{
|
4612 |
|
|
struct breakpoint *b;
|
4613 |
|
|
int i = 0;
|
4614 |
|
|
|
4615 |
|
|
*other_type_used = 0;
|
4616 |
|
|
ALL_BREAKPOINTS (b)
|
4617 |
|
|
{
|
4618 |
|
|
if (breakpoint_enabled (b))
|
4619 |
|
|
{
|
4620 |
|
|
if (b->type == type)
|
4621 |
|
|
i++;
|
4622 |
|
|
else if ((b->type == bp_hardware_watchpoint ||
|
4623 |
|
|
b->type == bp_read_watchpoint ||
|
4624 |
|
|
b->type == bp_access_watchpoint))
|
4625 |
|
|
*other_type_used = 1;
|
4626 |
|
|
}
|
4627 |
|
|
}
|
4628 |
|
|
return i;
|
4629 |
|
|
}
|
4630 |
|
|
|
4631 |
|
|
/* Call this after hitting the longjmp() breakpoint. Use this to set
|
4632 |
|
|
a new breakpoint at the target of the jmp_buf.
|
4633 |
|
|
|
4634 |
|
|
FIXME - This ought to be done by setting a temporary breakpoint
|
4635 |
|
|
that gets deleted automatically... */
|
4636 |
|
|
|
4637 |
|
|
void
|
4638 |
|
|
set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_id frame_id)
|
4639 |
|
|
{
|
4640 |
|
|
struct breakpoint *b;
|
4641 |
|
|
|
4642 |
|
|
ALL_BREAKPOINTS (b)
|
4643 |
|
|
if (b->type == bp_longjmp_resume)
|
4644 |
|
|
{
|
4645 |
|
|
b->loc->requested_address = pc;
|
4646 |
|
|
b->loc->address = adjust_breakpoint_address (b->loc->requested_address,
|
4647 |
|
|
b->type);
|
4648 |
|
|
b->enable_state = bp_enabled;
|
4649 |
|
|
b->frame_id = frame_id;
|
4650 |
|
|
check_duplicates (b);
|
4651 |
|
|
return;
|
4652 |
|
|
}
|
4653 |
|
|
}
|
4654 |
|
|
|
4655 |
|
|
void
|
4656 |
|
|
disable_watchpoints_before_interactive_call_start (void)
|
4657 |
|
|
{
|
4658 |
|
|
struct breakpoint *b;
|
4659 |
|
|
|
4660 |
|
|
ALL_BREAKPOINTS (b)
|
4661 |
|
|
{
|
4662 |
|
|
if (((b->type == bp_watchpoint)
|
4663 |
|
|
|| (b->type == bp_hardware_watchpoint)
|
4664 |
|
|
|| (b->type == bp_read_watchpoint)
|
4665 |
|
|
|| (b->type == bp_access_watchpoint))
|
4666 |
|
|
&& breakpoint_enabled (b))
|
4667 |
|
|
{
|
4668 |
|
|
b->enable_state = bp_call_disabled;
|
4669 |
|
|
check_duplicates (b);
|
4670 |
|
|
}
|
4671 |
|
|
}
|
4672 |
|
|
}
|
4673 |
|
|
|
4674 |
|
|
void
|
4675 |
|
|
enable_watchpoints_after_interactive_call_stop (void)
|
4676 |
|
|
{
|
4677 |
|
|
struct breakpoint *b;
|
4678 |
|
|
|
4679 |
|
|
ALL_BREAKPOINTS (b)
|
4680 |
|
|
{
|
4681 |
|
|
if (((b->type == bp_watchpoint)
|
4682 |
|
|
|| (b->type == bp_hardware_watchpoint)
|
4683 |
|
|
|| (b->type == bp_read_watchpoint)
|
4684 |
|
|
|| (b->type == bp_access_watchpoint))
|
4685 |
|
|
&& (b->enable_state == bp_call_disabled))
|
4686 |
|
|
{
|
4687 |
|
|
b->enable_state = bp_enabled;
|
4688 |
|
|
check_duplicates (b);
|
4689 |
|
|
}
|
4690 |
|
|
}
|
4691 |
|
|
}
|
4692 |
|
|
|
4693 |
|
|
|
4694 |
|
|
/* Set a breakpoint that will evaporate an end of command
|
4695 |
|
|
at address specified by SAL.
|
4696 |
|
|
Restrict it to frame FRAME if FRAME is nonzero. */
|
4697 |
|
|
|
4698 |
|
|
struct breakpoint *
|
4699 |
|
|
set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
|
4700 |
|
|
enum bptype type)
|
4701 |
|
|
{
|
4702 |
|
|
struct breakpoint *b;
|
4703 |
|
|
b = set_raw_breakpoint (sal, type);
|
4704 |
|
|
b->enable_state = bp_enabled;
|
4705 |
|
|
b->disposition = disp_donttouch;
|
4706 |
|
|
b->frame_id = frame_id;
|
4707 |
|
|
|
4708 |
|
|
/* If we're debugging a multi-threaded program, then we
|
4709 |
|
|
want momentary breakpoints to be active in only a
|
4710 |
|
|
single thread of control. */
|
4711 |
|
|
if (in_thread_list (inferior_ptid))
|
4712 |
|
|
b->thread = pid_to_thread_id (inferior_ptid);
|
4713 |
|
|
|
4714 |
|
|
return b;
|
4715 |
|
|
}
|
4716 |
|
|
|
4717 |
|
|
|
4718 |
|
|
/* Tell the user we have just set a breakpoint B. */
|
4719 |
|
|
|
4720 |
|
|
static void
|
4721 |
|
|
mention (struct breakpoint *b)
|
4722 |
|
|
{
|
4723 |
|
|
int say_where = 0;
|
4724 |
|
|
struct cleanup *old_chain, *ui_out_chain;
|
4725 |
|
|
struct ui_stream *stb;
|
4726 |
|
|
|
4727 |
|
|
stb = ui_out_stream_new (uiout);
|
4728 |
|
|
old_chain = make_cleanup_ui_out_stream_delete (stb);
|
4729 |
|
|
|
4730 |
|
|
/* FIXME: This is misplaced; mention() is called by things (like
|
4731 |
|
|
hitting a watchpoint) other than breakpoint creation. It should
|
4732 |
|
|
be possible to clean this up and at the same time replace the
|
4733 |
|
|
random calls to breakpoint_changed with this hook, as has already
|
4734 |
|
|
been done for deprecated_delete_breakpoint_hook and so on. */
|
4735 |
|
|
if (deprecated_create_breakpoint_hook)
|
4736 |
|
|
deprecated_create_breakpoint_hook (b);
|
4737 |
|
|
breakpoint_create_event (b->number);
|
4738 |
|
|
|
4739 |
|
|
if (b->ops != NULL && b->ops->print_mention != NULL)
|
4740 |
|
|
b->ops->print_mention (b);
|
4741 |
|
|
else
|
4742 |
|
|
switch (b->type)
|
4743 |
|
|
{
|
4744 |
|
|
case bp_none:
|
4745 |
|
|
printf_filtered (_("(apparently deleted?) Eventpoint %d: "), b->number);
|
4746 |
|
|
break;
|
4747 |
|
|
case bp_watchpoint:
|
4748 |
|
|
ui_out_text (uiout, "Watchpoint ");
|
4749 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
|
4750 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
4751 |
|
|
ui_out_text (uiout, ": ");
|
4752 |
|
|
print_expression (b->exp, stb->stream);
|
4753 |
|
|
ui_out_field_stream (uiout, "exp", stb);
|
4754 |
|
|
do_cleanups (ui_out_chain);
|
4755 |
|
|
break;
|
4756 |
|
|
case bp_hardware_watchpoint:
|
4757 |
|
|
ui_out_text (uiout, "Hardware watchpoint ");
|
4758 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "wpt");
|
4759 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
4760 |
|
|
ui_out_text (uiout, ": ");
|
4761 |
|
|
print_expression (b->exp, stb->stream);
|
4762 |
|
|
ui_out_field_stream (uiout, "exp", stb);
|
4763 |
|
|
do_cleanups (ui_out_chain);
|
4764 |
|
|
break;
|
4765 |
|
|
case bp_read_watchpoint:
|
4766 |
|
|
ui_out_text (uiout, "Hardware read watchpoint ");
|
4767 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-rwpt");
|
4768 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
4769 |
|
|
ui_out_text (uiout, ": ");
|
4770 |
|
|
print_expression (b->exp, stb->stream);
|
4771 |
|
|
ui_out_field_stream (uiout, "exp", stb);
|
4772 |
|
|
do_cleanups (ui_out_chain);
|
4773 |
|
|
break;
|
4774 |
|
|
case bp_access_watchpoint:
|
4775 |
|
|
ui_out_text (uiout, "Hardware access (read/write) watchpoint ");
|
4776 |
|
|
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "hw-awpt");
|
4777 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
4778 |
|
|
ui_out_text (uiout, ": ");
|
4779 |
|
|
print_expression (b->exp, stb->stream);
|
4780 |
|
|
ui_out_field_stream (uiout, "exp", stb);
|
4781 |
|
|
do_cleanups (ui_out_chain);
|
4782 |
|
|
break;
|
4783 |
|
|
case bp_breakpoint:
|
4784 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
4785 |
|
|
{
|
4786 |
|
|
say_where = 0;
|
4787 |
|
|
break;
|
4788 |
|
|
}
|
4789 |
|
|
printf_filtered (_("Breakpoint %d"), b->number);
|
4790 |
|
|
say_where = 1;
|
4791 |
|
|
break;
|
4792 |
|
|
case bp_hardware_breakpoint:
|
4793 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
4794 |
|
|
{
|
4795 |
|
|
say_where = 0;
|
4796 |
|
|
break;
|
4797 |
|
|
}
|
4798 |
|
|
printf_filtered (_("Hardware assisted breakpoint %d"), b->number);
|
4799 |
|
|
say_where = 1;
|
4800 |
|
|
break;
|
4801 |
|
|
case bp_catch_load:
|
4802 |
|
|
case bp_catch_unload:
|
4803 |
|
|
printf_filtered (_("Catchpoint %d (%s %s)"),
|
4804 |
|
|
b->number,
|
4805 |
|
|
(b->type == bp_catch_load) ? "load" : "unload",
|
4806 |
|
|
(b->dll_pathname != NULL) ?
|
4807 |
|
|
b->dll_pathname : "<any library>");
|
4808 |
|
|
break;
|
4809 |
|
|
case bp_catch_fork:
|
4810 |
|
|
case bp_catch_vfork:
|
4811 |
|
|
printf_filtered (_("Catchpoint %d (%s)"),
|
4812 |
|
|
b->number,
|
4813 |
|
|
(b->type == bp_catch_fork) ? "fork" : "vfork");
|
4814 |
|
|
break;
|
4815 |
|
|
case bp_catch_exec:
|
4816 |
|
|
printf_filtered (_("Catchpoint %d (exec)"),
|
4817 |
|
|
b->number);
|
4818 |
|
|
break;
|
4819 |
|
|
|
4820 |
|
|
case bp_until:
|
4821 |
|
|
case bp_finish:
|
4822 |
|
|
case bp_longjmp:
|
4823 |
|
|
case bp_longjmp_resume:
|
4824 |
|
|
case bp_step_resume:
|
4825 |
|
|
case bp_call_dummy:
|
4826 |
|
|
case bp_watchpoint_scope:
|
4827 |
|
|
case bp_shlib_event:
|
4828 |
|
|
case bp_thread_event:
|
4829 |
|
|
case bp_overlay_event:
|
4830 |
|
|
break;
|
4831 |
|
|
}
|
4832 |
|
|
|
4833 |
|
|
if (say_where)
|
4834 |
|
|
{
|
4835 |
|
|
/* i18n: cagney/2005-02-11: Below needs to be merged into a
|
4836 |
|
|
single string. */
|
4837 |
|
|
if (b->loc == NULL)
|
4838 |
|
|
{
|
4839 |
|
|
printf_filtered (_(" (%s) pending."), b->addr_string);
|
4840 |
|
|
}
|
4841 |
|
|
else
|
4842 |
|
|
{
|
4843 |
|
|
if (addressprint || b->source_file == NULL)
|
4844 |
|
|
{
|
4845 |
|
|
printf_filtered (" at ");
|
4846 |
|
|
fputs_filtered (paddress (b->loc->address), gdb_stdout);
|
4847 |
|
|
}
|
4848 |
|
|
if (b->source_file)
|
4849 |
|
|
printf_filtered (": file %s, line %d.",
|
4850 |
|
|
b->source_file, b->line_number);
|
4851 |
|
|
|
4852 |
|
|
if (b->loc->next)
|
4853 |
|
|
{
|
4854 |
|
|
struct bp_location *loc = b->loc;
|
4855 |
|
|
int n = 0;
|
4856 |
|
|
for (; loc; loc = loc->next)
|
4857 |
|
|
++n;
|
4858 |
|
|
printf_filtered (" (%d locations)", n);
|
4859 |
|
|
}
|
4860 |
|
|
|
4861 |
|
|
}
|
4862 |
|
|
}
|
4863 |
|
|
do_cleanups (old_chain);
|
4864 |
|
|
if (ui_out_is_mi_like_p (uiout))
|
4865 |
|
|
return;
|
4866 |
|
|
printf_filtered ("\n");
|
4867 |
|
|
}
|
4868 |
|
|
|
4869 |
|
|
|
4870 |
|
|
static struct bp_location *
|
4871 |
|
|
add_location_to_breakpoint (struct breakpoint *b, enum bptype bptype,
|
4872 |
|
|
const struct symtab_and_line *sal)
|
4873 |
|
|
{
|
4874 |
|
|
struct bp_location *loc, **tmp;
|
4875 |
|
|
|
4876 |
|
|
loc = allocate_bp_location (b, bptype);
|
4877 |
|
|
for (tmp = &(b->loc); *tmp != NULL; tmp = &((*tmp)->next))
|
4878 |
|
|
;
|
4879 |
|
|
*tmp = loc;
|
4880 |
|
|
loc->requested_address = sal->pc;
|
4881 |
|
|
loc->address = adjust_breakpoint_address (loc->requested_address,
|
4882 |
|
|
bptype);
|
4883 |
|
|
loc->section = sal->section;
|
4884 |
|
|
|
4885 |
|
|
set_breakpoint_location_function (loc);
|
4886 |
|
|
return loc;
|
4887 |
|
|
}
|
4888 |
|
|
|
4889 |
|
|
/* Create a breakpoint with SAL as location. Use ADDR_STRING
|
4890 |
|
|
as textual description of the location, and COND_STRING
|
4891 |
|
|
as condition expression. */
|
4892 |
|
|
|
4893 |
|
|
static void
|
4894 |
|
|
create_breakpoint (struct symtabs_and_lines sals, char *addr_string,
|
4895 |
|
|
char *cond_string,
|
4896 |
|
|
enum bptype type, enum bpdisp disposition,
|
4897 |
|
|
int thread, int ignore_count, int from_tty)
|
4898 |
|
|
{
|
4899 |
|
|
struct breakpoint *b = NULL;
|
4900 |
|
|
int i;
|
4901 |
|
|
|
4902 |
|
|
if (type == bp_hardware_breakpoint)
|
4903 |
|
|
{
|
4904 |
|
|
int i = hw_breakpoint_used_count ();
|
4905 |
|
|
int target_resources_ok =
|
4906 |
|
|
TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint,
|
4907 |
|
|
i + 1, 0);
|
4908 |
|
|
if (target_resources_ok == 0)
|
4909 |
|
|
error (_("No hardware breakpoint support in the target."));
|
4910 |
|
|
else if (target_resources_ok < 0)
|
4911 |
|
|
error (_("Hardware breakpoints used exceeds limit."));
|
4912 |
|
|
}
|
4913 |
|
|
|
4914 |
|
|
for (i = 0; i < sals.nelts; ++i)
|
4915 |
|
|
{
|
4916 |
|
|
struct symtab_and_line sal = sals.sals[i];
|
4917 |
|
|
struct bp_location *loc;
|
4918 |
|
|
|
4919 |
|
|
if (from_tty)
|
4920 |
|
|
describe_other_breakpoints (sal.pc, sal.section, thread);
|
4921 |
|
|
|
4922 |
|
|
if (i == 0)
|
4923 |
|
|
{
|
4924 |
|
|
b = set_raw_breakpoint (sal, type);
|
4925 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
4926 |
|
|
b->number = breakpoint_count;
|
4927 |
|
|
b->thread = thread;
|
4928 |
|
|
|
4929 |
|
|
b->cond_string = cond_string;
|
4930 |
|
|
b->ignore_count = ignore_count;
|
4931 |
|
|
b->enable_state = bp_enabled;
|
4932 |
|
|
b->disposition = disposition;
|
4933 |
|
|
|
4934 |
|
|
loc = b->loc;
|
4935 |
|
|
}
|
4936 |
|
|
else
|
4937 |
|
|
{
|
4938 |
|
|
loc = add_location_to_breakpoint (b, type, &sal);
|
4939 |
|
|
}
|
4940 |
|
|
|
4941 |
|
|
if (b->cond_string)
|
4942 |
|
|
{
|
4943 |
|
|
char *arg = b->cond_string;
|
4944 |
|
|
loc->cond = parse_exp_1 (&arg, block_for_pc (loc->address), 0);
|
4945 |
|
|
if (*arg)
|
4946 |
|
|
error (_("Garbage %s follows condition"), arg);
|
4947 |
|
|
}
|
4948 |
|
|
}
|
4949 |
|
|
|
4950 |
|
|
if (addr_string)
|
4951 |
|
|
b->addr_string = addr_string;
|
4952 |
|
|
else
|
4953 |
|
|
/* addr_string has to be used or breakpoint_re_set will delete
|
4954 |
|
|
me. */
|
4955 |
|
|
b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address));
|
4956 |
|
|
|
4957 |
|
|
mention (b);
|
4958 |
|
|
}
|
4959 |
|
|
|
4960 |
|
|
/* Remove element at INDEX_TO_REMOVE from SAL, shifting other
|
4961 |
|
|
elements to fill the void space. */
|
4962 |
|
|
static void remove_sal (struct symtabs_and_lines *sal, int index_to_remove)
|
4963 |
|
|
{
|
4964 |
|
|
int i = index_to_remove+1;
|
4965 |
|
|
int last_index = sal->nelts-1;
|
4966 |
|
|
|
4967 |
|
|
for (;i <= last_index; ++i)
|
4968 |
|
|
sal->sals[i-1] = sal->sals[i];
|
4969 |
|
|
|
4970 |
|
|
--(sal->nelts);
|
4971 |
|
|
}
|
4972 |
|
|
|
4973 |
|
|
/* If appropriate, obtains all sals that correspond
|
4974 |
|
|
to the same file and line as SAL. This is done
|
4975 |
|
|
only if SAL does not have explicit PC and has
|
4976 |
|
|
line and file information. If we got just a single
|
4977 |
|
|
expanded sal, return the original.
|
4978 |
|
|
|
4979 |
|
|
Otherwise, if SAL.explicit_line is not set, filter out
|
4980 |
|
|
all sals for which the name of enclosing function
|
4981 |
|
|
is different from SAL. This makes sure that if we have
|
4982 |
|
|
breakpoint originally set in template instantiation, say
|
4983 |
|
|
foo<int>(), we won't expand SAL to locations at the same
|
4984 |
|
|
line in all existing instantiations of 'foo'.
|
4985 |
|
|
|
4986 |
|
|
*/
|
4987 |
|
|
struct symtabs_and_lines
|
4988 |
|
|
expand_line_sal_maybe (struct symtab_and_line sal)
|
4989 |
|
|
{
|
4990 |
|
|
struct symtabs_and_lines expanded;
|
4991 |
|
|
CORE_ADDR original_pc = sal.pc;
|
4992 |
|
|
char *original_function = NULL;
|
4993 |
|
|
int found;
|
4994 |
|
|
int i;
|
4995 |
|
|
|
4996 |
|
|
/* If we have explicit pc, don't expand.
|
4997 |
|
|
If we have no line number, we can't expand. */
|
4998 |
|
|
if (sal.explicit_pc || sal.line == 0 || sal.symtab == NULL)
|
4999 |
|
|
{
|
5000 |
|
|
expanded.nelts = 1;
|
5001 |
|
|
expanded.sals = xmalloc (sizeof (struct symtab_and_line));
|
5002 |
|
|
expanded.sals[0] = sal;
|
5003 |
|
|
return expanded;
|
5004 |
|
|
}
|
5005 |
|
|
|
5006 |
|
|
sal.pc = 0;
|
5007 |
|
|
find_pc_partial_function (original_pc, &original_function, NULL, NULL);
|
5008 |
|
|
|
5009 |
|
|
expanded = expand_line_sal (sal);
|
5010 |
|
|
if (expanded.nelts == 1)
|
5011 |
|
|
{
|
5012 |
|
|
/* We had one sal, we got one sal. Without futher
|
5013 |
|
|
processing, just return the original sal. */
|
5014 |
|
|
xfree (expanded.sals);
|
5015 |
|
|
expanded.nelts = 1;
|
5016 |
|
|
expanded.sals = xmalloc (sizeof (struct symtab_and_line));
|
5017 |
|
|
sal.pc = original_pc;
|
5018 |
|
|
expanded.sals[0] = sal;
|
5019 |
|
|
return expanded;
|
5020 |
|
|
}
|
5021 |
|
|
|
5022 |
|
|
if (!sal.explicit_line)
|
5023 |
|
|
{
|
5024 |
|
|
CORE_ADDR func_addr, func_end;
|
5025 |
|
|
for (i = 0; i < expanded.nelts; ++i)
|
5026 |
|
|
{
|
5027 |
|
|
CORE_ADDR pc = expanded.sals[i].pc;
|
5028 |
|
|
char *this_function;
|
5029 |
|
|
if (find_pc_partial_function (pc, &this_function,
|
5030 |
|
|
&func_addr, &func_end))
|
5031 |
|
|
{
|
5032 |
|
|
if (this_function &&
|
5033 |
|
|
strcmp (this_function, original_function) != 0)
|
5034 |
|
|
{
|
5035 |
|
|
remove_sal (&expanded, i);
|
5036 |
|
|
--i;
|
5037 |
|
|
}
|
5038 |
|
|
else if (func_addr == pc)
|
5039 |
|
|
{
|
5040 |
|
|
/* We're at beginning of a function, and should
|
5041 |
|
|
skip prologue. */
|
5042 |
|
|
struct symbol *sym = find_pc_function (pc);
|
5043 |
|
|
if (sym)
|
5044 |
|
|
expanded.sals[i] = find_function_start_sal (sym, 1);
|
5045 |
|
|
else
|
5046 |
|
|
expanded.sals[i].pc
|
5047 |
|
|
= gdbarch_skip_prologue (current_gdbarch, pc);
|
5048 |
|
|
}
|
5049 |
|
|
}
|
5050 |
|
|
}
|
5051 |
|
|
}
|
5052 |
|
|
|
5053 |
|
|
|
5054 |
|
|
if (expanded.nelts <= 1)
|
5055 |
|
|
{
|
5056 |
|
|
/* This is un ugly workaround. If we get zero
|
5057 |
|
|
expanded sals then something is really wrong.
|
5058 |
|
|
Fix that by returnign the original sal. */
|
5059 |
|
|
xfree (expanded.sals);
|
5060 |
|
|
expanded.nelts = 1;
|
5061 |
|
|
expanded.sals = xmalloc (sizeof (struct symtab_and_line));
|
5062 |
|
|
sal.pc = original_pc;
|
5063 |
|
|
expanded.sals[0] = sal;
|
5064 |
|
|
return expanded;
|
5065 |
|
|
}
|
5066 |
|
|
|
5067 |
|
|
if (original_pc)
|
5068 |
|
|
{
|
5069 |
|
|
found = 0;
|
5070 |
|
|
for (i = 0; i < expanded.nelts; ++i)
|
5071 |
|
|
if (expanded.sals[i].pc == original_pc)
|
5072 |
|
|
{
|
5073 |
|
|
found = 1;
|
5074 |
|
|
break;
|
5075 |
|
|
}
|
5076 |
|
|
gdb_assert (found);
|
5077 |
|
|
}
|
5078 |
|
|
|
5079 |
|
|
return expanded;
|
5080 |
|
|
}
|
5081 |
|
|
|
5082 |
|
|
/* Add SALS.nelts breakpoints to the breakpoint table. For each
|
5083 |
|
|
SALS.sal[i] breakpoint, include the corresponding ADDR_STRING[i]
|
5084 |
|
|
value. COND_STRING, if not NULL, specified the condition to be
|
5085 |
|
|
used for all breakpoints. Essentially the only case where
|
5086 |
|
|
SALS.nelts is not 1 is when we set a breakpoint on an overloaded
|
5087 |
|
|
function. In that case, it's still not possible to specify
|
5088 |
|
|
separate conditions for different overloaded functions, so
|
5089 |
|
|
we take just a single condition string.
|
5090 |
|
|
|
5091 |
|
|
NOTE: If the function succeeds, the caller is expected to cleanup
|
5092 |
|
|
the arrays ADDR_STRING, COND_STRING, and SALS (but not the
|
5093 |
|
|
array contents). If the function fails (error() is called), the
|
5094 |
|
|
caller is expected to cleanups both the ADDR_STRING, COND_STRING,
|
5095 |
|
|
COND and SALS arrays and each of those arrays contents. */
|
5096 |
|
|
|
5097 |
|
|
static void
|
5098 |
|
|
create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
|
5099 |
|
|
char *cond_string,
|
5100 |
|
|
enum bptype type, enum bpdisp disposition,
|
5101 |
|
|
int thread, int ignore_count, int from_tty)
|
5102 |
|
|
{
|
5103 |
|
|
int i;
|
5104 |
|
|
for (i = 0; i < sals.nelts; ++i)
|
5105 |
|
|
{
|
5106 |
|
|
struct symtabs_and_lines expanded =
|
5107 |
|
|
expand_line_sal_maybe (sals.sals[i]);
|
5108 |
|
|
|
5109 |
|
|
create_breakpoint (expanded, addr_string[i],
|
5110 |
|
|
cond_string, type, disposition,
|
5111 |
|
|
thread, ignore_count, from_tty);
|
5112 |
|
|
}
|
5113 |
|
|
}
|
5114 |
|
|
|
5115 |
|
|
/* Parse ARG which is assumed to be a SAL specification possibly
|
5116 |
|
|
followed by conditionals. On return, SALS contains an array of SAL
|
5117 |
|
|
addresses found. ADDR_STRING contains a vector of (canonical)
|
5118 |
|
|
address strings. ARG points to the end of the SAL. */
|
5119 |
|
|
|
5120 |
|
|
static void
|
5121 |
|
|
parse_breakpoint_sals (char **address,
|
5122 |
|
|
struct symtabs_and_lines *sals,
|
5123 |
|
|
char ***addr_string,
|
5124 |
|
|
int *not_found_ptr)
|
5125 |
|
|
{
|
5126 |
|
|
char *addr_start = *address;
|
5127 |
|
|
*addr_string = NULL;
|
5128 |
|
|
/* If no arg given, or if first arg is 'if ', use the default
|
5129 |
|
|
breakpoint. */
|
5130 |
|
|
if ((*address) == NULL
|
5131 |
|
|
|| (strncmp ((*address), "if", 2) == 0 && isspace ((*address)[2])))
|
5132 |
|
|
{
|
5133 |
|
|
if (default_breakpoint_valid)
|
5134 |
|
|
{
|
5135 |
|
|
struct symtab_and_line sal;
|
5136 |
|
|
init_sal (&sal); /* initialize to zeroes */
|
5137 |
|
|
sals->sals = (struct symtab_and_line *)
|
5138 |
|
|
xmalloc (sizeof (struct symtab_and_line));
|
5139 |
|
|
sal.pc = default_breakpoint_address;
|
5140 |
|
|
sal.line = default_breakpoint_line;
|
5141 |
|
|
sal.symtab = default_breakpoint_symtab;
|
5142 |
|
|
sal.section = find_pc_overlay (sal.pc);
|
5143 |
|
|
sals->sals[0] = sal;
|
5144 |
|
|
sals->nelts = 1;
|
5145 |
|
|
}
|
5146 |
|
|
else
|
5147 |
|
|
error (_("No default breakpoint address now."));
|
5148 |
|
|
}
|
5149 |
|
|
else
|
5150 |
|
|
{
|
5151 |
|
|
/* Force almost all breakpoints to be in terms of the
|
5152 |
|
|
current_source_symtab (which is decode_line_1's default). This
|
5153 |
|
|
should produce the results we want almost all of the time while
|
5154 |
|
|
leaving default_breakpoint_* alone.
|
5155 |
|
|
ObjC: However, don't match an Objective-C method name which
|
5156 |
|
|
may have a '+' or '-' succeeded by a '[' */
|
5157 |
|
|
|
5158 |
|
|
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
|
5159 |
|
|
|
5160 |
|
|
if (default_breakpoint_valid
|
5161 |
|
|
&& (!cursal.symtab
|
5162 |
|
|
|| ((strchr ("+-", (*address)[0]) != NULL)
|
5163 |
|
|
&& ((*address)[1] != '['))))
|
5164 |
|
|
*sals = decode_line_1 (address, 1, default_breakpoint_symtab,
|
5165 |
|
|
default_breakpoint_line, addr_string,
|
5166 |
|
|
not_found_ptr);
|
5167 |
|
|
else
|
5168 |
|
|
*sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0,
|
5169 |
|
|
addr_string, not_found_ptr);
|
5170 |
|
|
}
|
5171 |
|
|
/* For any SAL that didn't have a canonical string, fill one in. */
|
5172 |
|
|
if (sals->nelts > 0 && *addr_string == NULL)
|
5173 |
|
|
*addr_string = xcalloc (sals->nelts, sizeof (char **));
|
5174 |
|
|
if (addr_start != (*address))
|
5175 |
|
|
{
|
5176 |
|
|
int i;
|
5177 |
|
|
for (i = 0; i < sals->nelts; i++)
|
5178 |
|
|
{
|
5179 |
|
|
/* Add the string if not present. */
|
5180 |
|
|
if ((*addr_string)[i] == NULL)
|
5181 |
|
|
(*addr_string)[i] = savestring (addr_start, (*address) - addr_start);
|
5182 |
|
|
}
|
5183 |
|
|
}
|
5184 |
|
|
}
|
5185 |
|
|
|
5186 |
|
|
|
5187 |
|
|
/* Convert each SAL into a real PC. Verify that the PC can be
|
5188 |
|
|
inserted as a breakpoint. If it can't throw an error. */
|
5189 |
|
|
|
5190 |
|
|
static void
|
5191 |
|
|
breakpoint_sals_to_pc (struct symtabs_and_lines *sals,
|
5192 |
|
|
char *address)
|
5193 |
|
|
{
|
5194 |
|
|
int i;
|
5195 |
|
|
for (i = 0; i < sals->nelts; i++)
|
5196 |
|
|
resolve_sal_pc (&sals->sals[i]);
|
5197 |
|
|
}
|
5198 |
|
|
|
5199 |
|
|
static void
|
5200 |
|
|
do_captured_parse_breakpoint (struct ui_out *ui, void *data)
|
5201 |
|
|
{
|
5202 |
|
|
struct captured_parse_breakpoint_args *args = data;
|
5203 |
|
|
|
5204 |
|
|
parse_breakpoint_sals (args->arg_p, args->sals_p, args->addr_string_p,
|
5205 |
|
|
args->not_found_ptr);
|
5206 |
|
|
}
|
5207 |
|
|
|
5208 |
|
|
/* Given TOK, a string specification of condition and thread, as
|
5209 |
|
|
accepted by the 'break' command, extract the condition
|
5210 |
|
|
string and thread number and set *COND_STRING and *THREAD.
|
5211 |
|
|
PC identifies the context at which the condition should be parsed.
|
5212 |
|
|
If no condition is found, *COND_STRING is set to NULL.
|
5213 |
|
|
If no thread is found, *THREAD is set to -1. */
|
5214 |
|
|
static void
|
5215 |
|
|
find_condition_and_thread (char *tok, CORE_ADDR pc,
|
5216 |
|
|
char **cond_string, int *thread)
|
5217 |
|
|
{
|
5218 |
|
|
*cond_string = NULL;
|
5219 |
|
|
*thread = -1;
|
5220 |
|
|
while (tok && *tok)
|
5221 |
|
|
{
|
5222 |
|
|
char *end_tok;
|
5223 |
|
|
int toklen;
|
5224 |
|
|
char *cond_start = NULL;
|
5225 |
|
|
char *cond_end = NULL;
|
5226 |
|
|
while (*tok == ' ' || *tok == '\t')
|
5227 |
|
|
tok++;
|
5228 |
|
|
|
5229 |
|
|
end_tok = tok;
|
5230 |
|
|
|
5231 |
|
|
while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
|
5232 |
|
|
end_tok++;
|
5233 |
|
|
|
5234 |
|
|
toklen = end_tok - tok;
|
5235 |
|
|
|
5236 |
|
|
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
|
5237 |
|
|
{
|
5238 |
|
|
tok = cond_start = end_tok + 1;
|
5239 |
|
|
parse_exp_1 (&tok, block_for_pc (pc), 0);
|
5240 |
|
|
cond_end = tok;
|
5241 |
|
|
*cond_string = savestring (cond_start,
|
5242 |
|
|
cond_end - cond_start);
|
5243 |
|
|
}
|
5244 |
|
|
else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
|
5245 |
|
|
{
|
5246 |
|
|
char *tmptok;
|
5247 |
|
|
|
5248 |
|
|
tok = end_tok + 1;
|
5249 |
|
|
tmptok = tok;
|
5250 |
|
|
*thread = strtol (tok, &tok, 0);
|
5251 |
|
|
if (tok == tmptok)
|
5252 |
|
|
error (_("Junk after thread keyword."));
|
5253 |
|
|
if (!valid_thread_id (*thread))
|
5254 |
|
|
error (_("Unknown thread %d."), *thread);
|
5255 |
|
|
}
|
5256 |
|
|
else
|
5257 |
|
|
error (_("Junk at end of arguments."));
|
5258 |
|
|
}
|
5259 |
|
|
}
|
5260 |
|
|
|
5261 |
|
|
/* Set a breakpoint. This function is shared between
|
5262 |
|
|
CLI and MI functions for setting a breakpoint.
|
5263 |
|
|
This function has two major modes of operations,
|
5264 |
|
|
selected by the PARSE_CONDITION_AND_THREAD parameter.
|
5265 |
|
|
If non-zero, the function will parse arg, extracting
|
5266 |
|
|
breakpoint location, address and thread. Otherwise,
|
5267 |
|
|
ARG is just the location of breakpoint, with condition
|
5268 |
|
|
and thread specified by the COND_STRING and THREAD
|
5269 |
|
|
parameters. */
|
5270 |
|
|
|
5271 |
|
|
static void
|
5272 |
|
|
break_command_really (char *arg, char *cond_string, int thread,
|
5273 |
|
|
int parse_condition_and_thread,
|
5274 |
|
|
int tempflag, int hardwareflag,
|
5275 |
|
|
int ignore_count,
|
5276 |
|
|
enum auto_boolean pending_break_support,
|
5277 |
|
|
int from_tty)
|
5278 |
|
|
{
|
5279 |
|
|
struct gdb_exception e;
|
5280 |
|
|
struct symtabs_and_lines sals;
|
5281 |
|
|
struct symtab_and_line pending_sal;
|
5282 |
|
|
char *copy_arg;
|
5283 |
|
|
char *err_msg;
|
5284 |
|
|
char *addr_start = arg;
|
5285 |
|
|
char **addr_string;
|
5286 |
|
|
struct cleanup *old_chain;
|
5287 |
|
|
struct cleanup *breakpoint_chain = NULL;
|
5288 |
|
|
struct captured_parse_breakpoint_args parse_args;
|
5289 |
|
|
int i;
|
5290 |
|
|
int pending = 0;
|
5291 |
|
|
int not_found = 0;
|
5292 |
|
|
|
5293 |
|
|
sals.sals = NULL;
|
5294 |
|
|
sals.nelts = 0;
|
5295 |
|
|
addr_string = NULL;
|
5296 |
|
|
|
5297 |
|
|
parse_args.arg_p = &arg;
|
5298 |
|
|
parse_args.sals_p = &sals;
|
5299 |
|
|
parse_args.addr_string_p = &addr_string;
|
5300 |
|
|
parse_args.not_found_ptr = ¬_found;
|
5301 |
|
|
|
5302 |
|
|
e = catch_exception (uiout, do_captured_parse_breakpoint,
|
5303 |
|
|
&parse_args, RETURN_MASK_ALL);
|
5304 |
|
|
|
5305 |
|
|
/* If caller is interested in rc value from parse, set value. */
|
5306 |
|
|
switch (e.reason)
|
5307 |
|
|
{
|
5308 |
|
|
case RETURN_QUIT:
|
5309 |
|
|
throw_exception (e);
|
5310 |
|
|
case RETURN_ERROR:
|
5311 |
|
|
switch (e.error)
|
5312 |
|
|
{
|
5313 |
|
|
case NOT_FOUND_ERROR:
|
5314 |
|
|
|
5315 |
|
|
/* If pending breakpoint support is turned off, throw
|
5316 |
|
|
error. */
|
5317 |
|
|
|
5318 |
|
|
if (pending_break_support == AUTO_BOOLEAN_FALSE)
|
5319 |
|
|
throw_exception (e);
|
5320 |
|
|
|
5321 |
|
|
exception_print (gdb_stderr, e);
|
5322 |
|
|
|
5323 |
|
|
/* If pending breakpoint support is auto query and the user
|
5324 |
|
|
selects no, then simply return the error code. */
|
5325 |
|
|
if (pending_break_support == AUTO_BOOLEAN_AUTO &&
|
5326 |
|
|
!nquery ("Make breakpoint pending on future shared library load? "))
|
5327 |
|
|
return;
|
5328 |
|
|
|
5329 |
|
|
/* At this point, either the user was queried about setting
|
5330 |
|
|
a pending breakpoint and selected yes, or pending
|
5331 |
|
|
breakpoint behavior is on and thus a pending breakpoint
|
5332 |
|
|
is defaulted on behalf of the user. */
|
5333 |
|
|
copy_arg = xstrdup (addr_start);
|
5334 |
|
|
addr_string = ©_arg;
|
5335 |
|
|
sals.nelts = 1;
|
5336 |
|
|
sals.sals = &pending_sal;
|
5337 |
|
|
pending_sal.pc = 0;
|
5338 |
|
|
pending = 1;
|
5339 |
|
|
break;
|
5340 |
|
|
default:
|
5341 |
|
|
throw_exception (e);
|
5342 |
|
|
}
|
5343 |
|
|
default:
|
5344 |
|
|
if (!sals.nelts)
|
5345 |
|
|
return;
|
5346 |
|
|
}
|
5347 |
|
|
|
5348 |
|
|
/* Create a chain of things that always need to be cleaned up. */
|
5349 |
|
|
old_chain = make_cleanup (null_cleanup, 0);
|
5350 |
|
|
|
5351 |
|
|
if (!pending)
|
5352 |
|
|
{
|
5353 |
|
|
/* Make sure that all storage allocated to SALS gets freed. */
|
5354 |
|
|
make_cleanup (xfree, sals.sals);
|
5355 |
|
|
|
5356 |
|
|
/* Cleanup the addr_string array but not its contents. */
|
5357 |
|
|
make_cleanup (xfree, addr_string);
|
5358 |
|
|
}
|
5359 |
|
|
|
5360 |
|
|
/* ----------------------------- SNIP -----------------------------
|
5361 |
|
|
Anything added to the cleanup chain beyond this point is assumed
|
5362 |
|
|
to be part of a breakpoint. If the breakpoint create succeeds
|
5363 |
|
|
then the memory is not reclaimed. */
|
5364 |
|
|
breakpoint_chain = make_cleanup (null_cleanup, 0);
|
5365 |
|
|
|
5366 |
|
|
/* Mark the contents of the addr_string for cleanup. These go on
|
5367 |
|
|
the breakpoint_chain and only occure if the breakpoint create
|
5368 |
|
|
fails. */
|
5369 |
|
|
for (i = 0; i < sals.nelts; i++)
|
5370 |
|
|
{
|
5371 |
|
|
if (addr_string[i] != NULL)
|
5372 |
|
|
make_cleanup (xfree, addr_string[i]);
|
5373 |
|
|
}
|
5374 |
|
|
|
5375 |
|
|
/* Resolve all line numbers to PC's and verify that the addresses
|
5376 |
|
|
are ok for the target. */
|
5377 |
|
|
if (!pending)
|
5378 |
|
|
breakpoint_sals_to_pc (&sals, addr_start);
|
5379 |
|
|
|
5380 |
|
|
/* Verify that condition can be parsed, before setting any
|
5381 |
|
|
breakpoints. Allocate a separate condition expression for each
|
5382 |
|
|
breakpoint. */
|
5383 |
|
|
if (!pending)
|
5384 |
|
|
{
|
5385 |
|
|
if (parse_condition_and_thread)
|
5386 |
|
|
{
|
5387 |
|
|
/* Here we only parse 'arg' to separate condition
|
5388 |
|
|
from thread number, so parsing in context of first
|
5389 |
|
|
sal is OK. When setting the breakpoint we'll
|
5390 |
|
|
re-parse it in context of each sal. */
|
5391 |
|
|
cond_string = NULL;
|
5392 |
|
|
thread = -1;
|
5393 |
|
|
find_condition_and_thread (arg, sals.sals[0].pc, &cond_string, &thread);
|
5394 |
|
|
if (cond_string)
|
5395 |
|
|
make_cleanup (xfree, cond_string);
|
5396 |
|
|
}
|
5397 |
|
|
else
|
5398 |
|
|
{
|
5399 |
|
|
/* Create a private copy of condition string. */
|
5400 |
|
|
if (cond_string)
|
5401 |
|
|
{
|
5402 |
|
|
cond_string = xstrdup (cond_string);
|
5403 |
|
|
make_cleanup (xfree, cond_string);
|
5404 |
|
|
}
|
5405 |
|
|
}
|
5406 |
|
|
create_breakpoints (sals, addr_string, cond_string,
|
5407 |
|
|
hardwareflag ? bp_hardware_breakpoint
|
5408 |
|
|
: bp_breakpoint,
|
5409 |
|
|
tempflag ? disp_del : disp_donttouch,
|
5410 |
|
|
thread, ignore_count, from_tty);
|
5411 |
|
|
}
|
5412 |
|
|
else
|
5413 |
|
|
{
|
5414 |
|
|
struct symtab_and_line sal = {0};
|
5415 |
|
|
struct breakpoint *b;
|
5416 |
|
|
|
5417 |
|
|
make_cleanup (xfree, copy_arg);
|
5418 |
|
|
|
5419 |
|
|
b = set_raw_breakpoint_without_location (hardwareflag
|
5420 |
|
|
? bp_hardware_breakpoint
|
5421 |
|
|
: bp_breakpoint);
|
5422 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
5423 |
|
|
b->number = breakpoint_count;
|
5424 |
|
|
b->thread = -1;
|
5425 |
|
|
b->addr_string = addr_string[0];
|
5426 |
|
|
b->cond_string = NULL;
|
5427 |
|
|
b->ignore_count = ignore_count;
|
5428 |
|
|
b->disposition = tempflag ? disp_del : disp_donttouch;
|
5429 |
|
|
b->condition_not_parsed = 1;
|
5430 |
|
|
mention (b);
|
5431 |
|
|
}
|
5432 |
|
|
|
5433 |
|
|
if (sals.nelts > 1)
|
5434 |
|
|
warning (_("Multiple breakpoints were set.\n"
|
5435 |
|
|
"Use the \"delete\" command to delete unwanted breakpoints."));
|
5436 |
|
|
/* That's it. Discard the cleanups for data inserted into the
|
5437 |
|
|
breakpoint. */
|
5438 |
|
|
discard_cleanups (breakpoint_chain);
|
5439 |
|
|
/* But cleanup everything else. */
|
5440 |
|
|
do_cleanups (old_chain);
|
5441 |
|
|
}
|
5442 |
|
|
|
5443 |
|
|
/* Set a breakpoint.
|
5444 |
|
|
ARG is a string describing breakpoint address,
|
5445 |
|
|
condition, and thread.
|
5446 |
|
|
FLAG specifies if a breakpoint is hardware on,
|
5447 |
|
|
and if breakpoint is temporary, using BP_HARDWARE_FLAG
|
5448 |
|
|
and BP_TEMPFLAG. */
|
5449 |
|
|
|
5450 |
|
|
static void
|
5451 |
|
|
break_command_1 (char *arg, int flag, int from_tty)
|
5452 |
|
|
{
|
5453 |
|
|
int hardwareflag = flag & BP_HARDWAREFLAG;
|
5454 |
|
|
int tempflag = flag & BP_TEMPFLAG;
|
5455 |
|
|
|
5456 |
|
|
break_command_really (arg,
|
5457 |
|
|
NULL, 0, 1 /* parse arg */,
|
5458 |
|
|
tempflag, hardwareflag,
|
5459 |
|
|
|
5460 |
|
|
pending_break_support, from_tty);
|
5461 |
|
|
}
|
5462 |
|
|
|
5463 |
|
|
|
5464 |
|
|
void
|
5465 |
|
|
set_breakpoint (char *address, char *condition,
|
5466 |
|
|
int hardwareflag, int tempflag,
|
5467 |
|
|
int thread, int ignore_count,
|
5468 |
|
|
int pending)
|
5469 |
|
|
{
|
5470 |
|
|
break_command_really (address, condition, thread,
|
5471 |
|
|
|
5472 |
|
|
tempflag, hardwareflag,
|
5473 |
|
|
ignore_count,
|
5474 |
|
|
pending
|
5475 |
|
|
? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
|
5476 |
|
|
0);
|
5477 |
|
|
}
|
5478 |
|
|
|
5479 |
|
|
|
5480 |
|
|
/* Helper function for break_command_1 and disassemble_command. */
|
5481 |
|
|
|
5482 |
|
|
void
|
5483 |
|
|
resolve_sal_pc (struct symtab_and_line *sal)
|
5484 |
|
|
{
|
5485 |
|
|
CORE_ADDR pc;
|
5486 |
|
|
|
5487 |
|
|
if (sal->pc == 0 && sal->symtab != NULL)
|
5488 |
|
|
{
|
5489 |
|
|
if (!find_line_pc (sal->symtab, sal->line, &pc))
|
5490 |
|
|
error (_("No line %d in file \"%s\"."),
|
5491 |
|
|
sal->line, sal->symtab->filename);
|
5492 |
|
|
sal->pc = pc;
|
5493 |
|
|
}
|
5494 |
|
|
|
5495 |
|
|
if (sal->section == 0 && sal->symtab != NULL)
|
5496 |
|
|
{
|
5497 |
|
|
struct blockvector *bv;
|
5498 |
|
|
struct block *b;
|
5499 |
|
|
struct symbol *sym;
|
5500 |
|
|
|
5501 |
|
|
bv = blockvector_for_pc_sect (sal->pc, 0, &b, sal->symtab);
|
5502 |
|
|
if (bv != NULL)
|
5503 |
|
|
{
|
5504 |
|
|
sym = block_function (b);
|
5505 |
|
|
if (sym != NULL)
|
5506 |
|
|
{
|
5507 |
|
|
fixup_symbol_section (sym, sal->symtab->objfile);
|
5508 |
|
|
sal->section = SYMBOL_BFD_SECTION (sym);
|
5509 |
|
|
}
|
5510 |
|
|
else
|
5511 |
|
|
{
|
5512 |
|
|
/* It really is worthwhile to have the section, so we'll just
|
5513 |
|
|
have to look harder. This case can be executed if we have
|
5514 |
|
|
line numbers but no functions (as can happen in assembly
|
5515 |
|
|
source). */
|
5516 |
|
|
|
5517 |
|
|
struct minimal_symbol *msym;
|
5518 |
|
|
|
5519 |
|
|
msym = lookup_minimal_symbol_by_pc (sal->pc);
|
5520 |
|
|
if (msym)
|
5521 |
|
|
sal->section = SYMBOL_BFD_SECTION (msym);
|
5522 |
|
|
}
|
5523 |
|
|
}
|
5524 |
|
|
}
|
5525 |
|
|
}
|
5526 |
|
|
|
5527 |
|
|
void
|
5528 |
|
|
break_command (char *arg, int from_tty)
|
5529 |
|
|
{
|
5530 |
|
|
break_command_1 (arg, 0, from_tty);
|
5531 |
|
|
}
|
5532 |
|
|
|
5533 |
|
|
void
|
5534 |
|
|
tbreak_command (char *arg, int from_tty)
|
5535 |
|
|
{
|
5536 |
|
|
break_command_1 (arg, BP_TEMPFLAG, from_tty);
|
5537 |
|
|
}
|
5538 |
|
|
|
5539 |
|
|
static void
|
5540 |
|
|
hbreak_command (char *arg, int from_tty)
|
5541 |
|
|
{
|
5542 |
|
|
break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
|
5543 |
|
|
}
|
5544 |
|
|
|
5545 |
|
|
static void
|
5546 |
|
|
thbreak_command (char *arg, int from_tty)
|
5547 |
|
|
{
|
5548 |
|
|
break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
|
5549 |
|
|
}
|
5550 |
|
|
|
5551 |
|
|
static void
|
5552 |
|
|
stop_command (char *arg, int from_tty)
|
5553 |
|
|
{
|
5554 |
|
|
printf_filtered (_("Specify the type of breakpoint to set.\n\
|
5555 |
|
|
Usage: stop in <function | address>\n\
|
5556 |
|
|
stop at <line>\n"));
|
5557 |
|
|
}
|
5558 |
|
|
|
5559 |
|
|
static void
|
5560 |
|
|
stopin_command (char *arg, int from_tty)
|
5561 |
|
|
{
|
5562 |
|
|
int badInput = 0;
|
5563 |
|
|
|
5564 |
|
|
if (arg == (char *) NULL)
|
5565 |
|
|
badInput = 1;
|
5566 |
|
|
else if (*arg != '*')
|
5567 |
|
|
{
|
5568 |
|
|
char *argptr = arg;
|
5569 |
|
|
int hasColon = 0;
|
5570 |
|
|
|
5571 |
|
|
/* look for a ':'. If this is a line number specification, then
|
5572 |
|
|
say it is bad, otherwise, it should be an address or
|
5573 |
|
|
function/method name */
|
5574 |
|
|
while (*argptr && !hasColon)
|
5575 |
|
|
{
|
5576 |
|
|
hasColon = (*argptr == ':');
|
5577 |
|
|
argptr++;
|
5578 |
|
|
}
|
5579 |
|
|
|
5580 |
|
|
if (hasColon)
|
5581 |
|
|
badInput = (*argptr != ':'); /* Not a class::method */
|
5582 |
|
|
else
|
5583 |
|
|
badInput = isdigit (*arg); /* a simple line number */
|
5584 |
|
|
}
|
5585 |
|
|
|
5586 |
|
|
if (badInput)
|
5587 |
|
|
printf_filtered (_("Usage: stop in <function | address>\n"));
|
5588 |
|
|
else
|
5589 |
|
|
break_command_1 (arg, 0, from_tty);
|
5590 |
|
|
}
|
5591 |
|
|
|
5592 |
|
|
static void
|
5593 |
|
|
stopat_command (char *arg, int from_tty)
|
5594 |
|
|
{
|
5595 |
|
|
int badInput = 0;
|
5596 |
|
|
|
5597 |
|
|
if (arg == (char *) NULL || *arg == '*') /* no line number */
|
5598 |
|
|
badInput = 1;
|
5599 |
|
|
else
|
5600 |
|
|
{
|
5601 |
|
|
char *argptr = arg;
|
5602 |
|
|
int hasColon = 0;
|
5603 |
|
|
|
5604 |
|
|
/* look for a ':'. If there is a '::' then get out, otherwise
|
5605 |
|
|
it is probably a line number. */
|
5606 |
|
|
while (*argptr && !hasColon)
|
5607 |
|
|
{
|
5608 |
|
|
hasColon = (*argptr == ':');
|
5609 |
|
|
argptr++;
|
5610 |
|
|
}
|
5611 |
|
|
|
5612 |
|
|
if (hasColon)
|
5613 |
|
|
badInput = (*argptr == ':'); /* we have class::method */
|
5614 |
|
|
else
|
5615 |
|
|
badInput = !isdigit (*arg); /* not a line number */
|
5616 |
|
|
}
|
5617 |
|
|
|
5618 |
|
|
if (badInput)
|
5619 |
|
|
printf_filtered (_("Usage: stop at <line>\n"));
|
5620 |
|
|
else
|
5621 |
|
|
break_command_1 (arg, 0, from_tty);
|
5622 |
|
|
}
|
5623 |
|
|
|
5624 |
|
|
/* accessflag: hw_write: watch write,
|
5625 |
|
|
hw_read: watch read,
|
5626 |
|
|
hw_access: watch access (read or write) */
|
5627 |
|
|
static void
|
5628 |
|
|
watch_command_1 (char *arg, int accessflag, int from_tty)
|
5629 |
|
|
{
|
5630 |
|
|
struct breakpoint *b, *scope_breakpoint = NULL;
|
5631 |
|
|
struct symtab_and_line sal;
|
5632 |
|
|
struct expression *exp;
|
5633 |
|
|
struct block *exp_valid_block;
|
5634 |
|
|
struct value *val, *mark;
|
5635 |
|
|
struct frame_info *frame;
|
5636 |
|
|
struct frame_info *prev_frame = NULL;
|
5637 |
|
|
char *exp_start = NULL;
|
5638 |
|
|
char *exp_end = NULL;
|
5639 |
|
|
char *tok, *id_tok_start, *end_tok;
|
5640 |
|
|
int toklen;
|
5641 |
|
|
char *cond_start = NULL;
|
5642 |
|
|
char *cond_end = NULL;
|
5643 |
|
|
struct expression *cond = NULL;
|
5644 |
|
|
int i, other_type_used, target_resources_ok = 0;
|
5645 |
|
|
enum bptype bp_type;
|
5646 |
|
|
int mem_cnt = 0;
|
5647 |
|
|
int thread = -1;
|
5648 |
|
|
|
5649 |
|
|
init_sal (&sal); /* initialize to zeroes */
|
5650 |
|
|
|
5651 |
|
|
/* Make sure that we actually have parameters to parse. */
|
5652 |
|
|
if (arg != NULL && arg[0] != '\0')
|
5653 |
|
|
{
|
5654 |
|
|
toklen = strlen (arg); /* Size of argument list. */
|
5655 |
|
|
|
5656 |
|
|
/* Points tok to the end of the argument list. */
|
5657 |
|
|
tok = arg + toklen - 1;
|
5658 |
|
|
|
5659 |
|
|
/* Go backwards in the parameters list. Skip the last parameter.
|
5660 |
|
|
If we're expecting a 'thread <thread_num>' parameter, this should
|
5661 |
|
|
be the thread identifier. */
|
5662 |
|
|
while (tok > arg && (*tok == ' ' || *tok == '\t'))
|
5663 |
|
|
tok--;
|
5664 |
|
|
while (tok > arg && (*tok != ' ' && *tok != '\t'))
|
5665 |
|
|
tok--;
|
5666 |
|
|
|
5667 |
|
|
/* Points end_tok to the beginning of the last token. */
|
5668 |
|
|
id_tok_start = tok + 1;
|
5669 |
|
|
|
5670 |
|
|
/* Go backwards in the parameters list. Skip one more parameter.
|
5671 |
|
|
If we're expecting a 'thread <thread_num>' parameter, we should
|
5672 |
|
|
reach a "thread" token. */
|
5673 |
|
|
while (tok > arg && (*tok == ' ' || *tok == '\t'))
|
5674 |
|
|
tok--;
|
5675 |
|
|
|
5676 |
|
|
end_tok = tok;
|
5677 |
|
|
|
5678 |
|
|
while (tok > arg && (*tok != ' ' && *tok != '\t'))
|
5679 |
|
|
tok--;
|
5680 |
|
|
|
5681 |
|
|
/* Move the pointer forward to skip the whitespace and
|
5682 |
|
|
calculate the length of the token. */
|
5683 |
|
|
tok++;
|
5684 |
|
|
toklen = end_tok - tok;
|
5685 |
|
|
|
5686 |
|
|
if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
|
5687 |
|
|
{
|
5688 |
|
|
/* At this point we've found a "thread" token, which means
|
5689 |
|
|
the user is trying to set a watchpoint that triggers
|
5690 |
|
|
only in a specific thread. */
|
5691 |
|
|
char *endp;
|
5692 |
|
|
|
5693 |
|
|
/* Extract the thread ID from the next token. */
|
5694 |
|
|
thread = strtol (id_tok_start, &endp, 0);
|
5695 |
|
|
|
5696 |
|
|
/* Check if the user provided a valid numeric value for the
|
5697 |
|
|
thread ID. */
|
5698 |
|
|
if (*endp != ' ' && *endp != '\t' && *endp != '\0')
|
5699 |
|
|
error (_("Invalid thread ID specification %s."), id_tok_start);
|
5700 |
|
|
|
5701 |
|
|
/* Check if the thread actually exists. */
|
5702 |
|
|
if (!valid_thread_id (thread))
|
5703 |
|
|
error (_("Unknown thread %d."), thread);
|
5704 |
|
|
|
5705 |
|
|
/* Truncate the string and get rid of the thread <thread_num>
|
5706 |
|
|
parameter before the parameter list is parsed by the
|
5707 |
|
|
evaluate_expression() function. */
|
5708 |
|
|
*tok = '\0';
|
5709 |
|
|
}
|
5710 |
|
|
}
|
5711 |
|
|
|
5712 |
|
|
/* Parse the rest of the arguments. */
|
5713 |
|
|
innermost_block = NULL;
|
5714 |
|
|
exp_start = arg;
|
5715 |
|
|
exp = parse_exp_1 (&arg, 0, 0);
|
5716 |
|
|
exp_end = arg;
|
5717 |
|
|
exp_valid_block = innermost_block;
|
5718 |
|
|
mark = value_mark ();
|
5719 |
|
|
val = evaluate_expression (exp);
|
5720 |
|
|
release_value (val);
|
5721 |
|
|
if (value_lazy (val))
|
5722 |
|
|
value_fetch_lazy (val);
|
5723 |
|
|
|
5724 |
|
|
tok = arg;
|
5725 |
|
|
while (*tok == ' ' || *tok == '\t')
|
5726 |
|
|
tok++;
|
5727 |
|
|
end_tok = tok;
|
5728 |
|
|
|
5729 |
|
|
while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
|
5730 |
|
|
end_tok++;
|
5731 |
|
|
|
5732 |
|
|
toklen = end_tok - tok;
|
5733 |
|
|
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
|
5734 |
|
|
{
|
5735 |
|
|
tok = cond_start = end_tok + 1;
|
5736 |
|
|
cond = parse_exp_1 (&tok, 0, 0);
|
5737 |
|
|
cond_end = tok;
|
5738 |
|
|
}
|
5739 |
|
|
if (*tok)
|
5740 |
|
|
error (_("Junk at end of command."));
|
5741 |
|
|
|
5742 |
|
|
if (accessflag == hw_read)
|
5743 |
|
|
bp_type = bp_read_watchpoint;
|
5744 |
|
|
else if (accessflag == hw_access)
|
5745 |
|
|
bp_type = bp_access_watchpoint;
|
5746 |
|
|
else
|
5747 |
|
|
bp_type = bp_hardware_watchpoint;
|
5748 |
|
|
|
5749 |
|
|
mem_cnt = can_use_hardware_watchpoint (val);
|
5750 |
|
|
if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
|
5751 |
|
|
error (_("Expression cannot be implemented with read/access watchpoint."));
|
5752 |
|
|
if (mem_cnt != 0)
|
5753 |
|
|
{
|
5754 |
|
|
i = hw_watchpoint_used_count (bp_type, &other_type_used);
|
5755 |
|
|
target_resources_ok =
|
5756 |
|
|
TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type, i + mem_cnt,
|
5757 |
|
|
other_type_used);
|
5758 |
|
|
if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
|
5759 |
|
|
error (_("Target does not support this type of hardware watchpoint."));
|
5760 |
|
|
|
5761 |
|
|
if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
|
5762 |
|
|
error (_("Target can only support one kind of HW watchpoint at a time."));
|
5763 |
|
|
}
|
5764 |
|
|
|
5765 |
|
|
/* Change the type of breakpoint to an ordinary watchpoint if a hardware
|
5766 |
|
|
watchpoint could not be set. */
|
5767 |
|
|
if (!mem_cnt || target_resources_ok <= 0)
|
5768 |
|
|
bp_type = bp_watchpoint;
|
5769 |
|
|
|
5770 |
|
|
frame = block_innermost_frame (exp_valid_block);
|
5771 |
|
|
if (frame)
|
5772 |
|
|
prev_frame = get_prev_frame (frame);
|
5773 |
|
|
else
|
5774 |
|
|
prev_frame = NULL;
|
5775 |
|
|
|
5776 |
|
|
/* If the expression is "local", then set up a "watchpoint scope"
|
5777 |
|
|
breakpoint at the point where we've left the scope of the watchpoint
|
5778 |
|
|
expression. Create the scope breakpoint before the watchpoint, so
|
5779 |
|
|
that we will encounter it first in bpstat_stop_status. */
|
5780 |
|
|
if (innermost_block && prev_frame)
|
5781 |
|
|
{
|
5782 |
|
|
scope_breakpoint = create_internal_breakpoint (get_frame_pc (prev_frame),
|
5783 |
|
|
bp_watchpoint_scope);
|
5784 |
|
|
|
5785 |
|
|
scope_breakpoint->enable_state = bp_enabled;
|
5786 |
|
|
|
5787 |
|
|
/* Automatically delete the breakpoint when it hits. */
|
5788 |
|
|
scope_breakpoint->disposition = disp_del;
|
5789 |
|
|
|
5790 |
|
|
/* Only break in the proper frame (help with recursion). */
|
5791 |
|
|
scope_breakpoint->frame_id = get_frame_id (prev_frame);
|
5792 |
|
|
|
5793 |
|
|
/* Set the address at which we will stop. */
|
5794 |
|
|
scope_breakpoint->loc->requested_address
|
5795 |
|
|
= get_frame_pc (prev_frame);
|
5796 |
|
|
scope_breakpoint->loc->address
|
5797 |
|
|
= adjust_breakpoint_address (scope_breakpoint->loc->requested_address,
|
5798 |
|
|
scope_breakpoint->type);
|
5799 |
|
|
}
|
5800 |
|
|
|
5801 |
|
|
/* Now set up the breakpoint. */
|
5802 |
|
|
b = set_raw_breakpoint (sal, bp_type);
|
5803 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
5804 |
|
|
b->number = breakpoint_count;
|
5805 |
|
|
b->thread = thread;
|
5806 |
|
|
b->disposition = disp_donttouch;
|
5807 |
|
|
b->exp = exp;
|
5808 |
|
|
b->exp_valid_block = exp_valid_block;
|
5809 |
|
|
b->exp_string = savestring (exp_start, exp_end - exp_start);
|
5810 |
|
|
b->val = val;
|
5811 |
|
|
b->loc->cond = cond;
|
5812 |
|
|
if (cond_start)
|
5813 |
|
|
b->cond_string = savestring (cond_start, cond_end - cond_start);
|
5814 |
|
|
else
|
5815 |
|
|
b->cond_string = 0;
|
5816 |
|
|
|
5817 |
|
|
if (frame)
|
5818 |
|
|
b->watchpoint_frame = get_frame_id (frame);
|
5819 |
|
|
else
|
5820 |
|
|
b->watchpoint_frame = null_frame_id;
|
5821 |
|
|
|
5822 |
|
|
if (scope_breakpoint != NULL)
|
5823 |
|
|
{
|
5824 |
|
|
/* The scope breakpoint is related to the watchpoint. We will
|
5825 |
|
|
need to act on them together. */
|
5826 |
|
|
b->related_breakpoint = scope_breakpoint;
|
5827 |
|
|
scope_breakpoint->related_breakpoint = b;
|
5828 |
|
|
}
|
5829 |
|
|
|
5830 |
|
|
value_free_to_mark (mark);
|
5831 |
|
|
mention (b);
|
5832 |
|
|
}
|
5833 |
|
|
|
5834 |
|
|
/* Return count of locations need to be watched and can be handled
|
5835 |
|
|
in hardware. If the watchpoint can not be handled
|
5836 |
|
|
in hardware return zero. */
|
5837 |
|
|
|
5838 |
|
|
static int
|
5839 |
|
|
can_use_hardware_watchpoint (struct value *v)
|
5840 |
|
|
{
|
5841 |
|
|
int found_memory_cnt = 0;
|
5842 |
|
|
struct value *head = v;
|
5843 |
|
|
|
5844 |
|
|
/* Did the user specifically forbid us to use hardware watchpoints? */
|
5845 |
|
|
if (!can_use_hw_watchpoints)
|
5846 |
|
|
return 0;
|
5847 |
|
|
|
5848 |
|
|
/* Make sure that the value of the expression depends only upon
|
5849 |
|
|
memory contents, and values computed from them within GDB. If we
|
5850 |
|
|
find any register references or function calls, we can't use a
|
5851 |
|
|
hardware watchpoint.
|
5852 |
|
|
|
5853 |
|
|
The idea here is that evaluating an expression generates a series
|
5854 |
|
|
of values, one holding the value of every subexpression. (The
|
5855 |
|
|
expression a*b+c has five subexpressions: a, b, a*b, c, and
|
5856 |
|
|
a*b+c.) GDB's values hold almost enough information to establish
|
5857 |
|
|
the criteria given above --- they identify memory lvalues,
|
5858 |
|
|
register lvalues, computed values, etcetera. So we can evaluate
|
5859 |
|
|
the expression, and then scan the chain of values that leaves
|
5860 |
|
|
behind to decide whether we can detect any possible change to the
|
5861 |
|
|
expression's final value using only hardware watchpoints.
|
5862 |
|
|
|
5863 |
|
|
However, I don't think that the values returned by inferior
|
5864 |
|
|
function calls are special in any way. So this function may not
|
5865 |
|
|
notice that an expression involving an inferior function call
|
5866 |
|
|
can't be watched with hardware watchpoints. FIXME. */
|
5867 |
|
|
for (; v; v = value_next (v))
|
5868 |
|
|
{
|
5869 |
|
|
if (VALUE_LVAL (v) == lval_memory)
|
5870 |
|
|
{
|
5871 |
|
|
if (value_lazy (v))
|
5872 |
|
|
/* A lazy memory lvalue is one that GDB never needed to fetch;
|
5873 |
|
|
we either just used its address (e.g., `a' in `a.b') or
|
5874 |
|
|
we never needed it at all (e.g., `a' in `a,b'). */
|
5875 |
|
|
;
|
5876 |
|
|
else
|
5877 |
|
|
{
|
5878 |
|
|
/* Ahh, memory we actually used! Check if we can cover
|
5879 |
|
|
it with hardware watchpoints. */
|
5880 |
|
|
struct type *vtype = check_typedef (value_type (v));
|
5881 |
|
|
|
5882 |
|
|
/* We only watch structs and arrays if user asked for it
|
5883 |
|
|
explicitly, never if they just happen to appear in a
|
5884 |
|
|
middle of some value chain. */
|
5885 |
|
|
if (v == head
|
5886 |
|
|
|| (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
|
5887 |
|
|
&& TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
|
5888 |
|
|
{
|
5889 |
|
|
CORE_ADDR vaddr = VALUE_ADDRESS (v) + value_offset (v);
|
5890 |
|
|
int len = TYPE_LENGTH (value_type (v));
|
5891 |
|
|
|
5892 |
|
|
if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
|
5893 |
|
|
return 0;
|
5894 |
|
|
else
|
5895 |
|
|
found_memory_cnt++;
|
5896 |
|
|
}
|
5897 |
|
|
}
|
5898 |
|
|
}
|
5899 |
|
|
else if (VALUE_LVAL (v) != not_lval
|
5900 |
|
|
&& deprecated_value_modifiable (v) == 0)
|
5901 |
|
|
return 0; /* ??? What does this represent? */
|
5902 |
|
|
else if (VALUE_LVAL (v) == lval_register)
|
5903 |
|
|
return 0; /* cannot watch a register with a HW watchpoint */
|
5904 |
|
|
}
|
5905 |
|
|
|
5906 |
|
|
/* The expression itself looks suitable for using a hardware
|
5907 |
|
|
watchpoint, but give the target machine a chance to reject it. */
|
5908 |
|
|
return found_memory_cnt;
|
5909 |
|
|
}
|
5910 |
|
|
|
5911 |
|
|
void
|
5912 |
|
|
watch_command_wrapper (char *arg, int from_tty)
|
5913 |
|
|
{
|
5914 |
|
|
watch_command (arg, from_tty);
|
5915 |
|
|
}
|
5916 |
|
|
|
5917 |
|
|
static void
|
5918 |
|
|
watch_command (char *arg, int from_tty)
|
5919 |
|
|
{
|
5920 |
|
|
watch_command_1 (arg, hw_write, from_tty);
|
5921 |
|
|
}
|
5922 |
|
|
|
5923 |
|
|
void
|
5924 |
|
|
rwatch_command_wrapper (char *arg, int from_tty)
|
5925 |
|
|
{
|
5926 |
|
|
rwatch_command (arg, from_tty);
|
5927 |
|
|
}
|
5928 |
|
|
|
5929 |
|
|
static void
|
5930 |
|
|
rwatch_command (char *arg, int from_tty)
|
5931 |
|
|
{
|
5932 |
|
|
watch_command_1 (arg, hw_read, from_tty);
|
5933 |
|
|
}
|
5934 |
|
|
|
5935 |
|
|
void
|
5936 |
|
|
awatch_command_wrapper (char *arg, int from_tty)
|
5937 |
|
|
{
|
5938 |
|
|
awatch_command (arg, from_tty);
|
5939 |
|
|
}
|
5940 |
|
|
|
5941 |
|
|
static void
|
5942 |
|
|
awatch_command (char *arg, int from_tty)
|
5943 |
|
|
{
|
5944 |
|
|
watch_command_1 (arg, hw_access, from_tty);
|
5945 |
|
|
}
|
5946 |
|
|
|
5947 |
|
|
|
5948 |
|
|
/* Helper routines for the until_command routine in infcmd.c. Here
|
5949 |
|
|
because it uses the mechanisms of breakpoints. */
|
5950 |
|
|
|
5951 |
|
|
/* This function is called by fetch_inferior_event via the
|
5952 |
|
|
cmd_continuation pointer, to complete the until command. It takes
|
5953 |
|
|
care of cleaning up the temporary breakpoints set up by the until
|
5954 |
|
|
command. */
|
5955 |
|
|
static void
|
5956 |
|
|
until_break_command_continuation (struct continuation_arg *arg)
|
5957 |
|
|
{
|
5958 |
|
|
struct cleanup *cleanups;
|
5959 |
|
|
|
5960 |
|
|
cleanups = (struct cleanup *) arg->data.pointer;
|
5961 |
|
|
do_exec_cleanups (cleanups);
|
5962 |
|
|
}
|
5963 |
|
|
|
5964 |
|
|
void
|
5965 |
|
|
until_break_command (char *arg, int from_tty, int anywhere)
|
5966 |
|
|
{
|
5967 |
|
|
struct symtabs_and_lines sals;
|
5968 |
|
|
struct symtab_and_line sal;
|
5969 |
|
|
struct frame_info *frame = get_selected_frame (NULL);
|
5970 |
|
|
struct frame_info *prev_frame = get_prev_frame (frame);
|
5971 |
|
|
struct breakpoint *breakpoint;
|
5972 |
|
|
struct cleanup *old_chain;
|
5973 |
|
|
struct continuation_arg *arg1;
|
5974 |
|
|
|
5975 |
|
|
|
5976 |
|
|
clear_proceed_status ();
|
5977 |
|
|
|
5978 |
|
|
/* Set a breakpoint where the user wants it and at return from
|
5979 |
|
|
this function */
|
5980 |
|
|
|
5981 |
|
|
if (default_breakpoint_valid)
|
5982 |
|
|
sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
|
5983 |
|
|
default_breakpoint_line, (char ***) NULL, NULL);
|
5984 |
|
|
else
|
5985 |
|
|
sals = decode_line_1 (&arg, 1, (struct symtab *) NULL,
|
5986 |
|
|
0, (char ***) NULL, NULL);
|
5987 |
|
|
|
5988 |
|
|
if (sals.nelts != 1)
|
5989 |
|
|
error (_("Couldn't get information on specified line."));
|
5990 |
|
|
|
5991 |
|
|
sal = sals.sals[0];
|
5992 |
|
|
xfree (sals.sals); /* malloc'd, so freed */
|
5993 |
|
|
|
5994 |
|
|
if (*arg)
|
5995 |
|
|
error (_("Junk at end of arguments."));
|
5996 |
|
|
|
5997 |
|
|
resolve_sal_pc (&sal);
|
5998 |
|
|
|
5999 |
|
|
if (anywhere)
|
6000 |
|
|
/* If the user told us to continue until a specified location,
|
6001 |
|
|
we don't specify a frame at which we need to stop. */
|
6002 |
|
|
breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
|
6003 |
|
|
else
|
6004 |
|
|
/* Otherwise, specify the current frame, because we want to stop only
|
6005 |
|
|
at the very same frame. */
|
6006 |
|
|
breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame),
|
6007 |
|
|
bp_until);
|
6008 |
|
|
|
6009 |
|
|
if (!target_can_async_p ())
|
6010 |
|
|
old_chain = make_cleanup_delete_breakpoint (breakpoint);
|
6011 |
|
|
else
|
6012 |
|
|
old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
|
6013 |
|
|
|
6014 |
|
|
/* If we are running asynchronously, and the target supports async
|
6015 |
|
|
execution, we are not waiting for the target to stop, in the call
|
6016 |
|
|
tp proceed, below. This means that we cannot delete the
|
6017 |
|
|
brekpoints until the target has actually stopped. The only place
|
6018 |
|
|
where we get a chance to do that is in fetch_inferior_event, so
|
6019 |
|
|
we must set things up for that. */
|
6020 |
|
|
|
6021 |
|
|
if (target_can_async_p ())
|
6022 |
|
|
{
|
6023 |
|
|
/* In this case the arg for the continuation is just the point
|
6024 |
|
|
in the exec_cleanups chain from where to start doing
|
6025 |
|
|
cleanups, because all the continuation does is the cleanups in
|
6026 |
|
|
the exec_cleanup_chain. */
|
6027 |
|
|
arg1 =
|
6028 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
6029 |
|
|
arg1->next = NULL;
|
6030 |
|
|
arg1->data.pointer = old_chain;
|
6031 |
|
|
|
6032 |
|
|
add_continuation (until_break_command_continuation, arg1);
|
6033 |
|
|
}
|
6034 |
|
|
|
6035 |
|
|
/* Keep within the current frame, or in frames called by the current
|
6036 |
|
|
one. */
|
6037 |
|
|
if (prev_frame)
|
6038 |
|
|
{
|
6039 |
|
|
sal = find_pc_line (get_frame_pc (prev_frame), 0);
|
6040 |
|
|
sal.pc = get_frame_pc (prev_frame);
|
6041 |
|
|
breakpoint = set_momentary_breakpoint (sal, get_frame_id (prev_frame),
|
6042 |
|
|
bp_until);
|
6043 |
|
|
if (!target_can_async_p ())
|
6044 |
|
|
make_cleanup_delete_breakpoint (breakpoint);
|
6045 |
|
|
else
|
6046 |
|
|
make_exec_cleanup_delete_breakpoint (breakpoint);
|
6047 |
|
|
}
|
6048 |
|
|
|
6049 |
|
|
proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
|
6050 |
|
|
/* Do the cleanups now, anly if we are not running asynchronously,
|
6051 |
|
|
of if we are, but the target is still synchronous. */
|
6052 |
|
|
if (!target_can_async_p ())
|
6053 |
|
|
do_cleanups (old_chain);
|
6054 |
|
|
}
|
6055 |
|
|
|
6056 |
|
|
static void
|
6057 |
|
|
ep_skip_leading_whitespace (char **s)
|
6058 |
|
|
{
|
6059 |
|
|
if ((s == NULL) || (*s == NULL))
|
6060 |
|
|
return;
|
6061 |
|
|
while (isspace (**s))
|
6062 |
|
|
*s += 1;
|
6063 |
|
|
}
|
6064 |
|
|
|
6065 |
|
|
/* This function examines a string, and attempts to find a token
|
6066 |
|
|
that might be an event name in the leading characters. If a
|
6067 |
|
|
possible match is found, a pointer to the last character of
|
6068 |
|
|
the token is returned. Else, NULL is returned. */
|
6069 |
|
|
|
6070 |
|
|
static char *
|
6071 |
|
|
ep_find_event_name_end (char *arg)
|
6072 |
|
|
{
|
6073 |
|
|
char *s = arg;
|
6074 |
|
|
char *event_name_end = NULL;
|
6075 |
|
|
|
6076 |
|
|
/* If we could depend upon the presense of strrpbrk, we'd use that... */
|
6077 |
|
|
if (arg == NULL)
|
6078 |
|
|
return NULL;
|
6079 |
|
|
|
6080 |
|
|
/* We break out of the loop when we find a token delimiter.
|
6081 |
|
|
Basically, we're looking for alphanumerics and underscores;
|
6082 |
|
|
anything else delimites the token. */
|
6083 |
|
|
while (*s != '\0')
|
6084 |
|
|
{
|
6085 |
|
|
if (!isalnum (*s) && (*s != '_'))
|
6086 |
|
|
break;
|
6087 |
|
|
event_name_end = s;
|
6088 |
|
|
s++;
|
6089 |
|
|
}
|
6090 |
|
|
|
6091 |
|
|
return event_name_end;
|
6092 |
|
|
}
|
6093 |
|
|
|
6094 |
|
|
|
6095 |
|
|
/* This function attempts to parse an optional "if <cond>" clause
|
6096 |
|
|
from the arg string. If one is not found, it returns NULL.
|
6097 |
|
|
|
6098 |
|
|
Else, it returns a pointer to the condition string. (It does not
|
6099 |
|
|
attempt to evaluate the string against a particular block.) And,
|
6100 |
|
|
it updates arg to point to the first character following the parsed
|
6101 |
|
|
if clause in the arg string. */
|
6102 |
|
|
|
6103 |
|
|
static char *
|
6104 |
|
|
ep_parse_optional_if_clause (char **arg)
|
6105 |
|
|
{
|
6106 |
|
|
char *cond_string;
|
6107 |
|
|
|
6108 |
|
|
if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2]))
|
6109 |
|
|
return NULL;
|
6110 |
|
|
|
6111 |
|
|
/* Skip the "if" keyword. */
|
6112 |
|
|
(*arg) += 2;
|
6113 |
|
|
|
6114 |
|
|
/* Skip any extra leading whitespace, and record the start of the
|
6115 |
|
|
condition string. */
|
6116 |
|
|
ep_skip_leading_whitespace (arg);
|
6117 |
|
|
cond_string = *arg;
|
6118 |
|
|
|
6119 |
|
|
/* Assume that the condition occupies the remainder of the arg string. */
|
6120 |
|
|
(*arg) += strlen (cond_string);
|
6121 |
|
|
|
6122 |
|
|
return cond_string;
|
6123 |
|
|
}
|
6124 |
|
|
|
6125 |
|
|
/* This function attempts to parse an optional filename from the arg
|
6126 |
|
|
string. If one is not found, it returns NULL.
|
6127 |
|
|
|
6128 |
|
|
Else, it returns a pointer to the parsed filename. (This function
|
6129 |
|
|
makes no attempt to verify that a file of that name exists, or is
|
6130 |
|
|
accessible.) And, it updates arg to point to the first character
|
6131 |
|
|
following the parsed filename in the arg string.
|
6132 |
|
|
|
6133 |
|
|
Note that clients needing to preserve the returned filename for
|
6134 |
|
|
future access should copy it to their own buffers. */
|
6135 |
|
|
static char *
|
6136 |
|
|
ep_parse_optional_filename (char **arg)
|
6137 |
|
|
{
|
6138 |
|
|
static char filename[1024];
|
6139 |
|
|
char *arg_p = *arg;
|
6140 |
|
|
int i;
|
6141 |
|
|
char c;
|
6142 |
|
|
|
6143 |
|
|
if ((*arg_p == '\0') || isspace (*arg_p))
|
6144 |
|
|
return NULL;
|
6145 |
|
|
|
6146 |
|
|
for (i = 0;; i++)
|
6147 |
|
|
{
|
6148 |
|
|
c = *arg_p;
|
6149 |
|
|
if (isspace (c))
|
6150 |
|
|
c = '\0';
|
6151 |
|
|
filename[i] = c;
|
6152 |
|
|
if (c == '\0')
|
6153 |
|
|
break;
|
6154 |
|
|
arg_p++;
|
6155 |
|
|
}
|
6156 |
|
|
*arg = arg_p;
|
6157 |
|
|
|
6158 |
|
|
return filename;
|
6159 |
|
|
}
|
6160 |
|
|
|
6161 |
|
|
/* Commands to deal with catching events, such as signals, exceptions,
|
6162 |
|
|
process start/exit, etc. */
|
6163 |
|
|
|
6164 |
|
|
typedef enum
|
6165 |
|
|
{
|
6166 |
|
|
catch_fork, catch_vfork
|
6167 |
|
|
}
|
6168 |
|
|
catch_fork_kind;
|
6169 |
|
|
|
6170 |
|
|
static void
|
6171 |
|
|
catch_fork_command_1 (catch_fork_kind fork_kind, char *arg, int tempflag,
|
6172 |
|
|
int from_tty)
|
6173 |
|
|
{
|
6174 |
|
|
char *cond_string = NULL;
|
6175 |
|
|
|
6176 |
|
|
ep_skip_leading_whitespace (&arg);
|
6177 |
|
|
|
6178 |
|
|
/* The allowed syntax is:
|
6179 |
|
|
catch [v]fork
|
6180 |
|
|
catch [v]fork if <cond>
|
6181 |
|
|
|
6182 |
|
|
First, check if there's an if clause. */
|
6183 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6184 |
|
|
|
6185 |
|
|
if ((*arg != '\0') && !isspace (*arg))
|
6186 |
|
|
error (_("Junk at end of arguments."));
|
6187 |
|
|
|
6188 |
|
|
/* If this target supports it, create a fork or vfork catchpoint
|
6189 |
|
|
and enable reporting of such events. */
|
6190 |
|
|
switch (fork_kind)
|
6191 |
|
|
{
|
6192 |
|
|
case catch_fork:
|
6193 |
|
|
create_fork_event_catchpoint (tempflag, cond_string);
|
6194 |
|
|
break;
|
6195 |
|
|
case catch_vfork:
|
6196 |
|
|
create_vfork_event_catchpoint (tempflag, cond_string);
|
6197 |
|
|
break;
|
6198 |
|
|
default:
|
6199 |
|
|
error (_("unsupported or unknown fork kind; cannot catch it"));
|
6200 |
|
|
break;
|
6201 |
|
|
}
|
6202 |
|
|
}
|
6203 |
|
|
|
6204 |
|
|
static void
|
6205 |
|
|
catch_exec_command_1 (char *arg, int tempflag, int from_tty)
|
6206 |
|
|
{
|
6207 |
|
|
char *cond_string = NULL;
|
6208 |
|
|
|
6209 |
|
|
ep_skip_leading_whitespace (&arg);
|
6210 |
|
|
|
6211 |
|
|
/* The allowed syntax is:
|
6212 |
|
|
catch exec
|
6213 |
|
|
catch exec if <cond>
|
6214 |
|
|
|
6215 |
|
|
First, check if there's an if clause. */
|
6216 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6217 |
|
|
|
6218 |
|
|
if ((*arg != '\0') && !isspace (*arg))
|
6219 |
|
|
error (_("Junk at end of arguments."));
|
6220 |
|
|
|
6221 |
|
|
/* If this target supports it, create an exec catchpoint
|
6222 |
|
|
and enable reporting of such events. */
|
6223 |
|
|
create_exec_event_catchpoint (tempflag, cond_string);
|
6224 |
|
|
}
|
6225 |
|
|
|
6226 |
|
|
static void
|
6227 |
|
|
catch_load_command_1 (char *arg, int tempflag, int from_tty)
|
6228 |
|
|
{
|
6229 |
|
|
char *dll_pathname = NULL;
|
6230 |
|
|
char *cond_string = NULL;
|
6231 |
|
|
|
6232 |
|
|
ep_skip_leading_whitespace (&arg);
|
6233 |
|
|
|
6234 |
|
|
/* The allowed syntax is:
|
6235 |
|
|
catch load
|
6236 |
|
|
catch load if <cond>
|
6237 |
|
|
catch load <filename>
|
6238 |
|
|
catch load <filename> if <cond>
|
6239 |
|
|
|
6240 |
|
|
The user is not allowed to specify the <filename> after an
|
6241 |
|
|
if clause.
|
6242 |
|
|
|
6243 |
|
|
We'll ignore the pathological case of a file named "if".
|
6244 |
|
|
|
6245 |
|
|
First, check if there's an if clause. If so, then there
|
6246 |
|
|
cannot be a filename. */
|
6247 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6248 |
|
|
|
6249 |
|
|
/* If there was an if clause, then there cannot be a filename.
|
6250 |
|
|
Else, there might be a filename and an if clause. */
|
6251 |
|
|
if (cond_string == NULL)
|
6252 |
|
|
{
|
6253 |
|
|
dll_pathname = ep_parse_optional_filename (&arg);
|
6254 |
|
|
ep_skip_leading_whitespace (&arg);
|
6255 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6256 |
|
|
}
|
6257 |
|
|
|
6258 |
|
|
if ((*arg != '\0') && !isspace (*arg))
|
6259 |
|
|
error (_("Junk at end of arguments."));
|
6260 |
|
|
|
6261 |
|
|
/* Create a load breakpoint that only triggers when a load of
|
6262 |
|
|
the specified dll (or any dll, if no pathname was specified)
|
6263 |
|
|
occurs. */
|
6264 |
|
|
SOLIB_CREATE_CATCH_LOAD_HOOK (PIDGET (inferior_ptid), tempflag,
|
6265 |
|
|
dll_pathname, cond_string);
|
6266 |
|
|
}
|
6267 |
|
|
|
6268 |
|
|
static void
|
6269 |
|
|
catch_unload_command_1 (char *arg, int tempflag, int from_tty)
|
6270 |
|
|
{
|
6271 |
|
|
char *dll_pathname = NULL;
|
6272 |
|
|
char *cond_string = NULL;
|
6273 |
|
|
|
6274 |
|
|
ep_skip_leading_whitespace (&arg);
|
6275 |
|
|
|
6276 |
|
|
/* The allowed syntax is:
|
6277 |
|
|
catch unload
|
6278 |
|
|
catch unload if <cond>
|
6279 |
|
|
catch unload <filename>
|
6280 |
|
|
catch unload <filename> if <cond>
|
6281 |
|
|
|
6282 |
|
|
The user is not allowed to specify the <filename> after an
|
6283 |
|
|
if clause.
|
6284 |
|
|
|
6285 |
|
|
We'll ignore the pathological case of a file named "if".
|
6286 |
|
|
|
6287 |
|
|
First, check if there's an if clause. If so, then there
|
6288 |
|
|
cannot be a filename. */
|
6289 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6290 |
|
|
|
6291 |
|
|
/* If there was an if clause, then there cannot be a filename.
|
6292 |
|
|
Else, there might be a filename and an if clause. */
|
6293 |
|
|
if (cond_string == NULL)
|
6294 |
|
|
{
|
6295 |
|
|
dll_pathname = ep_parse_optional_filename (&arg);
|
6296 |
|
|
ep_skip_leading_whitespace (&arg);
|
6297 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6298 |
|
|
}
|
6299 |
|
|
|
6300 |
|
|
if ((*arg != '\0') && !isspace (*arg))
|
6301 |
|
|
error (_("Junk at end of arguments."));
|
6302 |
|
|
|
6303 |
|
|
/* Create an unload breakpoint that only triggers when an unload of
|
6304 |
|
|
the specified dll (or any dll, if no pathname was specified)
|
6305 |
|
|
occurs. */
|
6306 |
|
|
SOLIB_CREATE_CATCH_UNLOAD_HOOK (PIDGET (inferior_ptid), tempflag,
|
6307 |
|
|
dll_pathname, cond_string);
|
6308 |
|
|
}
|
6309 |
|
|
|
6310 |
|
|
static enum print_stop_action
|
6311 |
|
|
print_exception_catchpoint (struct breakpoint *b)
|
6312 |
|
|
{
|
6313 |
|
|
annotate_catchpoint (b->number);
|
6314 |
|
|
|
6315 |
|
|
if (strstr (b->addr_string, "throw") != NULL)
|
6316 |
|
|
printf_filtered (_("\nCatchpoint %d (exception thrown)\n"),
|
6317 |
|
|
b->number);
|
6318 |
|
|
else
|
6319 |
|
|
printf_filtered (_("\nCatchpoint %d (exception caught)\n"),
|
6320 |
|
|
b->number);
|
6321 |
|
|
|
6322 |
|
|
return PRINT_SRC_AND_LOC;
|
6323 |
|
|
}
|
6324 |
|
|
|
6325 |
|
|
static void
|
6326 |
|
|
print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
|
6327 |
|
|
{
|
6328 |
|
|
if (addressprint)
|
6329 |
|
|
{
|
6330 |
|
|
annotate_field (4);
|
6331 |
|
|
ui_out_field_core_addr (uiout, "addr", b->loc->address);
|
6332 |
|
|
}
|
6333 |
|
|
annotate_field (5);
|
6334 |
|
|
*last_addr = b->loc->address;
|
6335 |
|
|
if (strstr (b->addr_string, "throw") != NULL)
|
6336 |
|
|
ui_out_field_string (uiout, "what", "exception throw");
|
6337 |
|
|
else
|
6338 |
|
|
ui_out_field_string (uiout, "what", "exception catch");
|
6339 |
|
|
}
|
6340 |
|
|
|
6341 |
|
|
static void
|
6342 |
|
|
print_mention_exception_catchpoint (struct breakpoint *b)
|
6343 |
|
|
{
|
6344 |
|
|
if (strstr (b->addr_string, "throw") != NULL)
|
6345 |
|
|
printf_filtered (_("Catchpoint %d (throw)"), b->number);
|
6346 |
|
|
else
|
6347 |
|
|
printf_filtered (_("Catchpoint %d (catch)"), b->number);
|
6348 |
|
|
}
|
6349 |
|
|
|
6350 |
|
|
static struct breakpoint_ops gnu_v3_exception_catchpoint_ops = {
|
6351 |
|
|
print_exception_catchpoint,
|
6352 |
|
|
print_one_exception_catchpoint,
|
6353 |
|
|
print_mention_exception_catchpoint
|
6354 |
|
|
};
|
6355 |
|
|
|
6356 |
|
|
static int
|
6357 |
|
|
handle_gnu_v3_exceptions (int tempflag, char *cond_string,
|
6358 |
|
|
enum exception_event_kind ex_event, int from_tty)
|
6359 |
|
|
{
|
6360 |
|
|
char *trigger_func_name, *nameptr;
|
6361 |
|
|
struct symtabs_and_lines sals;
|
6362 |
|
|
struct breakpoint *b;
|
6363 |
|
|
|
6364 |
|
|
if (ex_event == EX_EVENT_CATCH)
|
6365 |
|
|
trigger_func_name = xstrdup ("__cxa_begin_catch");
|
6366 |
|
|
else
|
6367 |
|
|
trigger_func_name = xstrdup ("__cxa_throw");
|
6368 |
|
|
|
6369 |
|
|
nameptr = trigger_func_name;
|
6370 |
|
|
sals = decode_line_1 (&nameptr, 1, NULL, 0, NULL, NULL);
|
6371 |
|
|
if (sals.nelts == 0)
|
6372 |
|
|
{
|
6373 |
|
|
xfree (trigger_func_name);
|
6374 |
|
|
return 0;
|
6375 |
|
|
}
|
6376 |
|
|
|
6377 |
|
|
b = set_raw_breakpoint (sals.sals[0], bp_breakpoint);
|
6378 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
6379 |
|
|
b->number = breakpoint_count;
|
6380 |
|
|
b->cond_string = (cond_string == NULL) ?
|
6381 |
|
|
NULL : savestring (cond_string, strlen (cond_string));
|
6382 |
|
|
b->thread = -1;
|
6383 |
|
|
b->addr_string = trigger_func_name;
|
6384 |
|
|
b->enable_state = bp_enabled;
|
6385 |
|
|
b->disposition = tempflag ? disp_del : disp_donttouch;
|
6386 |
|
|
b->ops = &gnu_v3_exception_catchpoint_ops;
|
6387 |
|
|
|
6388 |
|
|
xfree (sals.sals);
|
6389 |
|
|
mention (b);
|
6390 |
|
|
return 1;
|
6391 |
|
|
}
|
6392 |
|
|
|
6393 |
|
|
/* Deal with "catch catch" and "catch throw" commands */
|
6394 |
|
|
|
6395 |
|
|
static void
|
6396 |
|
|
catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
|
6397 |
|
|
int tempflag, int from_tty)
|
6398 |
|
|
{
|
6399 |
|
|
char *cond_string = NULL;
|
6400 |
|
|
struct symtab_and_line *sal = NULL;
|
6401 |
|
|
|
6402 |
|
|
ep_skip_leading_whitespace (&arg);
|
6403 |
|
|
|
6404 |
|
|
cond_string = ep_parse_optional_if_clause (&arg);
|
6405 |
|
|
|
6406 |
|
|
if ((*arg != '\0') && !isspace (*arg))
|
6407 |
|
|
error (_("Junk at end of arguments."));
|
6408 |
|
|
|
6409 |
|
|
if ((ex_event != EX_EVENT_THROW) &&
|
6410 |
|
|
(ex_event != EX_EVENT_CATCH))
|
6411 |
|
|
error (_("Unsupported or unknown exception event; cannot catch it"));
|
6412 |
|
|
|
6413 |
|
|
if (handle_gnu_v3_exceptions (tempflag, cond_string, ex_event, from_tty))
|
6414 |
|
|
return;
|
6415 |
|
|
|
6416 |
|
|
warning (_("Unsupported with this platform/compiler combination."));
|
6417 |
|
|
}
|
6418 |
|
|
|
6419 |
|
|
/* Create a breakpoint struct for Ada exception catchpoints. */
|
6420 |
|
|
|
6421 |
|
|
static void
|
6422 |
|
|
create_ada_exception_breakpoint (struct symtab_and_line sal,
|
6423 |
|
|
char *addr_string,
|
6424 |
|
|
char *exp_string,
|
6425 |
|
|
char *cond_string,
|
6426 |
|
|
struct expression *cond,
|
6427 |
|
|
struct breakpoint_ops *ops,
|
6428 |
|
|
int tempflag,
|
6429 |
|
|
int from_tty)
|
6430 |
|
|
{
|
6431 |
|
|
struct breakpoint *b;
|
6432 |
|
|
|
6433 |
|
|
if (from_tty)
|
6434 |
|
|
{
|
6435 |
|
|
describe_other_breakpoints (sal.pc, sal.section, -1);
|
6436 |
|
|
/* FIXME: brobecker/2006-12-28: Actually, re-implement a special
|
6437 |
|
|
version for exception catchpoints, because two catchpoints
|
6438 |
|
|
used for different exception names will use the same address.
|
6439 |
|
|
In this case, a "breakpoint ... also set at..." warning is
|
6440 |
|
|
unproductive. Besides. the warning phrasing is also a bit
|
6441 |
|
|
inapropriate, we should use the word catchpoint, and tell
|
6442 |
|
|
the user what type of catchpoint it is. The above is good
|
6443 |
|
|
enough for now, though. */
|
6444 |
|
|
}
|
6445 |
|
|
|
6446 |
|
|
b = set_raw_breakpoint (sal, bp_breakpoint);
|
6447 |
|
|
set_breakpoint_count (breakpoint_count + 1);
|
6448 |
|
|
|
6449 |
|
|
b->enable_state = bp_enabled;
|
6450 |
|
|
b->disposition = tempflag ? disp_del : disp_donttouch;
|
6451 |
|
|
b->number = breakpoint_count;
|
6452 |
|
|
b->ignore_count = 0;
|
6453 |
|
|
b->loc->cond = cond;
|
6454 |
|
|
b->addr_string = addr_string;
|
6455 |
|
|
b->language = language_ada;
|
6456 |
|
|
b->cond_string = cond_string;
|
6457 |
|
|
b->exp_string = exp_string;
|
6458 |
|
|
b->thread = -1;
|
6459 |
|
|
b->ops = ops;
|
6460 |
|
|
|
6461 |
|
|
mention (b);
|
6462 |
|
|
}
|
6463 |
|
|
|
6464 |
|
|
/* Implement the "catch exception" command. */
|
6465 |
|
|
|
6466 |
|
|
static void
|
6467 |
|
|
catch_ada_exception_command (char *arg, int tempflag, int from_tty)
|
6468 |
|
|
{
|
6469 |
|
|
struct symtab_and_line sal;
|
6470 |
|
|
enum bptype type;
|
6471 |
|
|
char *addr_string = NULL;
|
6472 |
|
|
char *exp_string = NULL;
|
6473 |
|
|
char *cond_string = NULL;
|
6474 |
|
|
struct expression *cond = NULL;
|
6475 |
|
|
struct breakpoint_ops *ops = NULL;
|
6476 |
|
|
|
6477 |
|
|
sal = ada_decode_exception_location (arg, &addr_string, &exp_string,
|
6478 |
|
|
&cond_string, &cond, &ops);
|
6479 |
|
|
create_ada_exception_breakpoint (sal, addr_string, exp_string,
|
6480 |
|
|
cond_string, cond, ops, tempflag,
|
6481 |
|
|
from_tty);
|
6482 |
|
|
}
|
6483 |
|
|
|
6484 |
|
|
/* Implement the "catch assert" command. */
|
6485 |
|
|
|
6486 |
|
|
static void
|
6487 |
|
|
catch_assert_command (char *arg, int tempflag, int from_tty)
|
6488 |
|
|
{
|
6489 |
|
|
struct symtab_and_line sal;
|
6490 |
|
|
char *addr_string = NULL;
|
6491 |
|
|
struct breakpoint_ops *ops = NULL;
|
6492 |
|
|
|
6493 |
|
|
sal = ada_decode_assert_location (arg, &addr_string, &ops);
|
6494 |
|
|
create_ada_exception_breakpoint (sal, addr_string, NULL, NULL, NULL, ops,
|
6495 |
|
|
tempflag, from_tty);
|
6496 |
|
|
}
|
6497 |
|
|
|
6498 |
|
|
static void
|
6499 |
|
|
catch_command_1 (char *arg, int tempflag, int from_tty)
|
6500 |
|
|
{
|
6501 |
|
|
|
6502 |
|
|
/* The first argument may be an event name, such as "start" or "load".
|
6503 |
|
|
If so, then handle it as such. If it doesn't match an event name,
|
6504 |
|
|
then attempt to interpret it as an exception name. (This latter is
|
6505 |
|
|
the v4.16-and-earlier GDB meaning of the "catch" command.)
|
6506 |
|
|
|
6507 |
|
|
First, try to find the bounds of what might be an event name. */
|
6508 |
|
|
char *arg1_start = arg;
|
6509 |
|
|
char *arg1_end;
|
6510 |
|
|
int arg1_length;
|
6511 |
|
|
|
6512 |
|
|
if (arg1_start == NULL)
|
6513 |
|
|
{
|
6514 |
|
|
/* Old behaviour was to use pre-v-4.16 syntax */
|
6515 |
|
|
/* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
|
6516 |
|
|
/* return; */
|
6517 |
|
|
/* Now, this is not allowed */
|
6518 |
|
|
error (_("Catch requires an event name."));
|
6519 |
|
|
|
6520 |
|
|
}
|
6521 |
|
|
arg1_end = ep_find_event_name_end (arg1_start);
|
6522 |
|
|
if (arg1_end == NULL)
|
6523 |
|
|
error (_("catch requires an event"));
|
6524 |
|
|
arg1_length = arg1_end + 1 - arg1_start;
|
6525 |
|
|
|
6526 |
|
|
/* Try to match what we found against known event names. */
|
6527 |
|
|
if (strncmp (arg1_start, "signal", arg1_length) == 0)
|
6528 |
|
|
{
|
6529 |
|
|
error (_("Catch of signal not yet implemented"));
|
6530 |
|
|
}
|
6531 |
|
|
else if (strncmp (arg1_start, "catch", arg1_length) == 0)
|
6532 |
|
|
{
|
6533 |
|
|
catch_exception_command_1 (EX_EVENT_CATCH, arg1_end + 1,
|
6534 |
|
|
tempflag, from_tty);
|
6535 |
|
|
}
|
6536 |
|
|
else if (strncmp (arg1_start, "throw", arg1_length) == 0)
|
6537 |
|
|
{
|
6538 |
|
|
catch_exception_command_1 (EX_EVENT_THROW, arg1_end + 1,
|
6539 |
|
|
tempflag, from_tty);
|
6540 |
|
|
}
|
6541 |
|
|
else if (strncmp (arg1_start, "thread_start", arg1_length) == 0)
|
6542 |
|
|
{
|
6543 |
|
|
error (_("Catch of thread_start not yet implemented"));
|
6544 |
|
|
}
|
6545 |
|
|
else if (strncmp (arg1_start, "thread_exit", arg1_length) == 0)
|
6546 |
|
|
{
|
6547 |
|
|
error (_("Catch of thread_exit not yet implemented"));
|
6548 |
|
|
}
|
6549 |
|
|
else if (strncmp (arg1_start, "thread_join", arg1_length) == 0)
|
6550 |
|
|
{
|
6551 |
|
|
error (_("Catch of thread_join not yet implemented"));
|
6552 |
|
|
}
|
6553 |
|
|
else if (strncmp (arg1_start, "start", arg1_length) == 0)
|
6554 |
|
|
{
|
6555 |
|
|
error (_("Catch of start not yet implemented"));
|
6556 |
|
|
}
|
6557 |
|
|
else if (strncmp (arg1_start, "exit", arg1_length) == 0)
|
6558 |
|
|
{
|
6559 |
|
|
error (_("Catch of exit not yet implemented"));
|
6560 |
|
|
}
|
6561 |
|
|
else if (strncmp (arg1_start, "fork", arg1_length) == 0)
|
6562 |
|
|
{
|
6563 |
|
|
catch_fork_command_1 (catch_fork, arg1_end + 1, tempflag, from_tty);
|
6564 |
|
|
}
|
6565 |
|
|
else if (strncmp (arg1_start, "vfork", arg1_length) == 0)
|
6566 |
|
|
{
|
6567 |
|
|
catch_fork_command_1 (catch_vfork, arg1_end + 1, tempflag, from_tty);
|
6568 |
|
|
}
|
6569 |
|
|
else if (strncmp (arg1_start, "exec", arg1_length) == 0)
|
6570 |
|
|
{
|
6571 |
|
|
catch_exec_command_1 (arg1_end + 1, tempflag, from_tty);
|
6572 |
|
|
}
|
6573 |
|
|
else if (strncmp (arg1_start, "load", arg1_length) == 0)
|
6574 |
|
|
{
|
6575 |
|
|
catch_load_command_1 (arg1_end + 1, tempflag, from_tty);
|
6576 |
|
|
}
|
6577 |
|
|
else if (strncmp (arg1_start, "unload", arg1_length) == 0)
|
6578 |
|
|
{
|
6579 |
|
|
catch_unload_command_1 (arg1_end + 1, tempflag, from_tty);
|
6580 |
|
|
}
|
6581 |
|
|
else if (strncmp (arg1_start, "stop", arg1_length) == 0)
|
6582 |
|
|
{
|
6583 |
|
|
error (_("Catch of stop not yet implemented"));
|
6584 |
|
|
}
|
6585 |
|
|
else if (strncmp (arg1_start, "exception", arg1_length) == 0)
|
6586 |
|
|
{
|
6587 |
|
|
catch_ada_exception_command (arg1_end + 1, tempflag, from_tty);
|
6588 |
|
|
}
|
6589 |
|
|
|
6590 |
|
|
else if (strncmp (arg1_start, "assert", arg1_length) == 0)
|
6591 |
|
|
{
|
6592 |
|
|
catch_assert_command (arg1_end + 1, tempflag, from_tty);
|
6593 |
|
|
}
|
6594 |
|
|
|
6595 |
|
|
/* This doesn't appear to be an event name */
|
6596 |
|
|
|
6597 |
|
|
else
|
6598 |
|
|
{
|
6599 |
|
|
/* Pre-v.4.16 behaviour was to treat the argument
|
6600 |
|
|
as the name of an exception */
|
6601 |
|
|
/* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
|
6602 |
|
|
/* Now this is not allowed */
|
6603 |
|
|
error (_("Unknown event kind specified for catch"));
|
6604 |
|
|
|
6605 |
|
|
}
|
6606 |
|
|
}
|
6607 |
|
|
|
6608 |
|
|
static void
|
6609 |
|
|
catch_command (char *arg, int from_tty)
|
6610 |
|
|
{
|
6611 |
|
|
catch_command_1 (arg, 0, from_tty);
|
6612 |
|
|
}
|
6613 |
|
|
|
6614 |
|
|
|
6615 |
|
|
static void
|
6616 |
|
|
tcatch_command (char *arg, int from_tty)
|
6617 |
|
|
{
|
6618 |
|
|
catch_command_1 (arg, 1, from_tty);
|
6619 |
|
|
}
|
6620 |
|
|
|
6621 |
|
|
/* Delete breakpoints by address or line. */
|
6622 |
|
|
|
6623 |
|
|
static void
|
6624 |
|
|
clear_command (char *arg, int from_tty)
|
6625 |
|
|
{
|
6626 |
|
|
struct breakpoint *b;
|
6627 |
|
|
VEC(breakpoint_p) *found = 0;
|
6628 |
|
|
int ix;
|
6629 |
|
|
int default_match;
|
6630 |
|
|
struct symtabs_and_lines sals;
|
6631 |
|
|
struct symtab_and_line sal;
|
6632 |
|
|
int i;
|
6633 |
|
|
|
6634 |
|
|
if (arg)
|
6635 |
|
|
{
|
6636 |
|
|
sals = decode_line_spec (arg, 1);
|
6637 |
|
|
default_match = 0;
|
6638 |
|
|
}
|
6639 |
|
|
else
|
6640 |
|
|
{
|
6641 |
|
|
sals.sals = (struct symtab_and_line *)
|
6642 |
|
|
xmalloc (sizeof (struct symtab_and_line));
|
6643 |
|
|
make_cleanup (xfree, sals.sals);
|
6644 |
|
|
init_sal (&sal); /* initialize to zeroes */
|
6645 |
|
|
sal.line = default_breakpoint_line;
|
6646 |
|
|
sal.symtab = default_breakpoint_symtab;
|
6647 |
|
|
sal.pc = default_breakpoint_address;
|
6648 |
|
|
if (sal.symtab == 0)
|
6649 |
|
|
error (_("No source file specified."));
|
6650 |
|
|
|
6651 |
|
|
sals.sals[0] = sal;
|
6652 |
|
|
sals.nelts = 1;
|
6653 |
|
|
|
6654 |
|
|
default_match = 1;
|
6655 |
|
|
}
|
6656 |
|
|
|
6657 |
|
|
/* We don't call resolve_sal_pc here. That's not
|
6658 |
|
|
as bad as it seems, because all existing breakpoints
|
6659 |
|
|
typically have both file/line and pc set. So, if
|
6660 |
|
|
clear is given file/line, we can match this to existing
|
6661 |
|
|
breakpoint without obtaining pc at all.
|
6662 |
|
|
|
6663 |
|
|
We only support clearing given the address explicitly
|
6664 |
|
|
present in breakpoint table. Say, we've set breakpoint
|
6665 |
|
|
at file:line. There were several PC values for that file:line,
|
6666 |
|
|
due to optimization, all in one block.
|
6667 |
|
|
We've picked one PC value. If "clear" is issued with another
|
6668 |
|
|
PC corresponding to the same file:line, the breakpoint won't
|
6669 |
|
|
be cleared. We probably can still clear the breakpoint, but
|
6670 |
|
|
since the other PC value is never presented to user, user
|
6671 |
|
|
can only find it by guessing, and it does not seem important
|
6672 |
|
|
to support that. */
|
6673 |
|
|
|
6674 |
|
|
/* For each line spec given, delete bps which correspond
|
6675 |
|
|
to it. Do it in two passes, solely to preserve the current
|
6676 |
|
|
behavior that from_tty is forced true if we delete more than
|
6677 |
|
|
one breakpoint. */
|
6678 |
|
|
|
6679 |
|
|
found = NULL;
|
6680 |
|
|
for (i = 0; i < sals.nelts; i++)
|
6681 |
|
|
{
|
6682 |
|
|
/* If exact pc given, clear bpts at that pc.
|
6683 |
|
|
If line given (pc == 0), clear all bpts on specified line.
|
6684 |
|
|
If defaulting, clear all bpts on default line
|
6685 |
|
|
or at default pc.
|
6686 |
|
|
|
6687 |
|
|
defaulting sal.pc != 0 tests to do
|
6688 |
|
|
|
6689 |
|
|
|
6690 |
|
|
1 1 pc _and_ line
|
6691 |
|
|
|
6692 |
|
|
1 0 <can't happen> */
|
6693 |
|
|
|
6694 |
|
|
sal = sals.sals[i];
|
6695 |
|
|
|
6696 |
|
|
/* Find all matching breakpoints and add them to
|
6697 |
|
|
'found'. */
|
6698 |
|
|
ALL_BREAKPOINTS (b)
|
6699 |
|
|
{
|
6700 |
|
|
int match = 0;
|
6701 |
|
|
/* Are we going to delete b? */
|
6702 |
|
|
if (b->type != bp_none
|
6703 |
|
|
&& b->type != bp_watchpoint
|
6704 |
|
|
&& b->type != bp_hardware_watchpoint
|
6705 |
|
|
&& b->type != bp_read_watchpoint
|
6706 |
|
|
&& b->type != bp_access_watchpoint)
|
6707 |
|
|
{
|
6708 |
|
|
struct bp_location *loc = b->loc;
|
6709 |
|
|
for (; loc; loc = loc->next)
|
6710 |
|
|
{
|
6711 |
|
|
int pc_match = sal.pc
|
6712 |
|
|
&& (loc->address == sal.pc)
|
6713 |
|
|
&& (!section_is_overlay (loc->section)
|
6714 |
|
|
|| loc->section == sal.section);
|
6715 |
|
|
int line_match = ((default_match || (0 == sal.pc))
|
6716 |
|
|
&& b->source_file != NULL
|
6717 |
|
|
&& sal.symtab != NULL
|
6718 |
|
|
&& strcmp (b->source_file, sal.symtab->filename) == 0
|
6719 |
|
|
&& b->line_number == sal.line);
|
6720 |
|
|
if (pc_match || line_match)
|
6721 |
|
|
{
|
6722 |
|
|
match = 1;
|
6723 |
|
|
break;
|
6724 |
|
|
}
|
6725 |
|
|
}
|
6726 |
|
|
}
|
6727 |
|
|
|
6728 |
|
|
if (match)
|
6729 |
|
|
VEC_safe_push(breakpoint_p, found, b);
|
6730 |
|
|
}
|
6731 |
|
|
}
|
6732 |
|
|
/* Now go thru the 'found' chain and delete them. */
|
6733 |
|
|
if (VEC_empty(breakpoint_p, found))
|
6734 |
|
|
{
|
6735 |
|
|
if (arg)
|
6736 |
|
|
error (_("No breakpoint at %s."), arg);
|
6737 |
|
|
else
|
6738 |
|
|
error (_("No breakpoint at this line."));
|
6739 |
|
|
}
|
6740 |
|
|
|
6741 |
|
|
if (VEC_length(breakpoint_p, found) > 1)
|
6742 |
|
|
from_tty = 1; /* Always report if deleted more than one */
|
6743 |
|
|
if (from_tty)
|
6744 |
|
|
{
|
6745 |
|
|
if (VEC_length(breakpoint_p, found) == 1)
|
6746 |
|
|
printf_unfiltered (_("Deleted breakpoint "));
|
6747 |
|
|
else
|
6748 |
|
|
printf_unfiltered (_("Deleted breakpoints "));
|
6749 |
|
|
}
|
6750 |
|
|
breakpoints_changed ();
|
6751 |
|
|
|
6752 |
|
|
for (ix = 0; VEC_iterate(breakpoint_p, found, ix, b); ix++)
|
6753 |
|
|
{
|
6754 |
|
|
if (from_tty)
|
6755 |
|
|
printf_unfiltered ("%d ", b->number);
|
6756 |
|
|
delete_breakpoint (b);
|
6757 |
|
|
}
|
6758 |
|
|
if (from_tty)
|
6759 |
|
|
putchar_unfiltered ('\n');
|
6760 |
|
|
}
|
6761 |
|
|
|
6762 |
|
|
/* Delete breakpoint in BS if they are `delete' breakpoints and
|
6763 |
|
|
all breakpoints that are marked for deletion, whether hit or not.
|
6764 |
|
|
This is called after any breakpoint is hit, or after errors. */
|
6765 |
|
|
|
6766 |
|
|
void
|
6767 |
|
|
breakpoint_auto_delete (bpstat bs)
|
6768 |
|
|
{
|
6769 |
|
|
struct breakpoint *b, *temp;
|
6770 |
|
|
|
6771 |
|
|
for (; bs; bs = bs->next)
|
6772 |
|
|
if (bs->breakpoint_at && bs->breakpoint_at->owner->disposition == disp_del
|
6773 |
|
|
&& bs->stop)
|
6774 |
|
|
delete_breakpoint (bs->breakpoint_at->owner);
|
6775 |
|
|
|
6776 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
6777 |
|
|
{
|
6778 |
|
|
if (b->disposition == disp_del_at_next_stop)
|
6779 |
|
|
delete_breakpoint (b);
|
6780 |
|
|
}
|
6781 |
|
|
}
|
6782 |
|
|
|
6783 |
|
|
/* Remove locations of breakpoint BPT from
|
6784 |
|
|
the global list of breakpoint locations. */
|
6785 |
|
|
|
6786 |
|
|
static void
|
6787 |
|
|
unlink_locations_from_global_list (struct breakpoint *bpt)
|
6788 |
|
|
{
|
6789 |
|
|
/* This code assumes that the locations
|
6790 |
|
|
of a breakpoint are found in the global list
|
6791 |
|
|
in the same order, but not necessary adjacent. */
|
6792 |
|
|
struct bp_location **tmp = &bp_location_chain;
|
6793 |
|
|
struct bp_location *here = bpt->loc;
|
6794 |
|
|
|
6795 |
|
|
if (here == NULL)
|
6796 |
|
|
return;
|
6797 |
|
|
|
6798 |
|
|
for (; *tmp && here;)
|
6799 |
|
|
{
|
6800 |
|
|
if (*tmp == here)
|
6801 |
|
|
{
|
6802 |
|
|
*tmp = here->global_next;
|
6803 |
|
|
here = here->next;
|
6804 |
|
|
}
|
6805 |
|
|
else
|
6806 |
|
|
{
|
6807 |
|
|
tmp = &((*tmp)->global_next);
|
6808 |
|
|
}
|
6809 |
|
|
}
|
6810 |
|
|
}
|
6811 |
|
|
|
6812 |
|
|
/* Delete a breakpoint and clean up all traces of it in the data
|
6813 |
|
|
structures. */
|
6814 |
|
|
|
6815 |
|
|
void
|
6816 |
|
|
delete_breakpoint (struct breakpoint *bpt)
|
6817 |
|
|
{
|
6818 |
|
|
struct breakpoint *b;
|
6819 |
|
|
bpstat bs;
|
6820 |
|
|
struct bp_location *loc;
|
6821 |
|
|
|
6822 |
|
|
gdb_assert (bpt != NULL);
|
6823 |
|
|
|
6824 |
|
|
/* Has this bp already been deleted? This can happen because multiple
|
6825 |
|
|
lists can hold pointers to bp's. bpstat lists are especial culprits.
|
6826 |
|
|
|
6827 |
|
|
One example of this happening is a watchpoint's scope bp. When the
|
6828 |
|
|
scope bp triggers, we notice that the watchpoint is out of scope, and
|
6829 |
|
|
delete it. We also delete its scope bp. But the scope bp is marked
|
6830 |
|
|
"auto-deleting", and is already on a bpstat. That bpstat is then
|
6831 |
|
|
checked for auto-deleting bp's, which are deleted.
|
6832 |
|
|
|
6833 |
|
|
A real solution to this problem might involve reference counts in bp's,
|
6834 |
|
|
and/or giving them pointers back to their referencing bpstat's, and
|
6835 |
|
|
teaching delete_breakpoint to only free a bp's storage when no more
|
6836 |
|
|
references were extent. A cheaper bandaid was chosen. */
|
6837 |
|
|
if (bpt->type == bp_none)
|
6838 |
|
|
return;
|
6839 |
|
|
|
6840 |
|
|
if (deprecated_delete_breakpoint_hook)
|
6841 |
|
|
deprecated_delete_breakpoint_hook (bpt);
|
6842 |
|
|
breakpoint_delete_event (bpt->number);
|
6843 |
|
|
|
6844 |
|
|
for (loc = bpt->loc; loc; loc = loc->next)
|
6845 |
|
|
{
|
6846 |
|
|
if (loc->inserted)
|
6847 |
|
|
remove_breakpoint (loc, mark_inserted);
|
6848 |
|
|
|
6849 |
|
|
if (loc->cond)
|
6850 |
|
|
xfree (loc->cond);
|
6851 |
|
|
|
6852 |
|
|
if (loc->function_name)
|
6853 |
|
|
xfree (loc->function_name);
|
6854 |
|
|
}
|
6855 |
|
|
|
6856 |
|
|
if (breakpoint_chain == bpt)
|
6857 |
|
|
breakpoint_chain = bpt->next;
|
6858 |
|
|
|
6859 |
|
|
ALL_BREAKPOINTS (b)
|
6860 |
|
|
if (b->next == bpt)
|
6861 |
|
|
{
|
6862 |
|
|
b->next = bpt->next;
|
6863 |
|
|
break;
|
6864 |
|
|
}
|
6865 |
|
|
|
6866 |
|
|
unlink_locations_from_global_list (bpt);
|
6867 |
|
|
|
6868 |
|
|
check_duplicates (bpt);
|
6869 |
|
|
|
6870 |
|
|
if (bpt->type != bp_hardware_watchpoint
|
6871 |
|
|
&& bpt->type != bp_read_watchpoint
|
6872 |
|
|
&& bpt->type != bp_access_watchpoint
|
6873 |
|
|
&& bpt->type != bp_catch_fork
|
6874 |
|
|
&& bpt->type != bp_catch_vfork
|
6875 |
|
|
&& bpt->type != bp_catch_exec)
|
6876 |
|
|
for (loc = bpt->loc; loc; loc = loc->next)
|
6877 |
|
|
{
|
6878 |
|
|
/* If this breakpoint location was inserted, and there is
|
6879 |
|
|
another breakpoint at the same address, we need to
|
6880 |
|
|
insert the other breakpoint. */
|
6881 |
|
|
if (loc->inserted)
|
6882 |
|
|
{
|
6883 |
|
|
struct bp_location *loc2;
|
6884 |
|
|
ALL_BP_LOCATIONS (loc2)
|
6885 |
|
|
if (loc2->address == loc->address
|
6886 |
|
|
&& loc2->section == loc->section
|
6887 |
|
|
&& !loc->duplicate
|
6888 |
|
|
&& loc2->owner->enable_state != bp_disabled
|
6889 |
|
|
&& loc2->enabled
|
6890 |
|
|
&& !loc2->shlib_disabled
|
6891 |
|
|
&& loc2->owner->enable_state != bp_call_disabled)
|
6892 |
|
|
{
|
6893 |
|
|
int val;
|
6894 |
|
|
|
6895 |
|
|
/* We should never reach this point if there is a permanent
|
6896 |
|
|
breakpoint at the same address as the one being deleted.
|
6897 |
|
|
If there is a permanent breakpoint somewhere, it should
|
6898 |
|
|
always be the only one inserted. */
|
6899 |
|
|
if (loc2->owner->enable_state == bp_permanent)
|
6900 |
|
|
internal_error (__FILE__, __LINE__,
|
6901 |
|
|
_("another breakpoint was inserted on top of "
|
6902 |
|
|
"a permanent breakpoint"));
|
6903 |
|
|
|
6904 |
|
|
memset (&loc2->target_info, 0, sizeof (loc2->target_info));
|
6905 |
|
|
loc2->target_info.placed_address = loc2->address;
|
6906 |
|
|
if (b->type == bp_hardware_breakpoint)
|
6907 |
|
|
val = target_insert_hw_breakpoint (&loc2->target_info);
|
6908 |
|
|
else
|
6909 |
|
|
val = target_insert_breakpoint (&loc2->target_info);
|
6910 |
|
|
|
6911 |
|
|
/* If there was an error in the insert, print a message, then stop execution. */
|
6912 |
|
|
if (val != 0)
|
6913 |
|
|
{
|
6914 |
|
|
struct ui_file *tmp_error_stream = mem_fileopen ();
|
6915 |
|
|
make_cleanup_ui_file_delete (tmp_error_stream);
|
6916 |
|
|
|
6917 |
|
|
|
6918 |
|
|
if (b->type == bp_hardware_breakpoint)
|
6919 |
|
|
{
|
6920 |
|
|
fprintf_unfiltered (tmp_error_stream,
|
6921 |
|
|
"Cannot insert hardware breakpoint %d.\n"
|
6922 |
|
|
"You may have requested too many hardware breakpoints.\n",
|
6923 |
|
|
b->number);
|
6924 |
|
|
}
|
6925 |
|
|
else
|
6926 |
|
|
{
|
6927 |
|
|
fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n", b->number);
|
6928 |
|
|
fprintf_filtered (tmp_error_stream, "Error accessing memory address ");
|
6929 |
|
|
fputs_filtered (paddress (loc2->address),
|
6930 |
|
|
tmp_error_stream);
|
6931 |
|
|
fprintf_filtered (tmp_error_stream, ": %s.\n",
|
6932 |
|
|
safe_strerror (val));
|
6933 |
|
|
}
|
6934 |
|
|
|
6935 |
|
|
fprintf_unfiltered (tmp_error_stream,"The same program may be running in another process.");
|
6936 |
|
|
target_terminal_ours_for_output ();
|
6937 |
|
|
error_stream(tmp_error_stream);
|
6938 |
|
|
}
|
6939 |
|
|
else
|
6940 |
|
|
loc2->inserted = 1;
|
6941 |
|
|
}
|
6942 |
|
|
}
|
6943 |
|
|
}
|
6944 |
|
|
|
6945 |
|
|
free_command_lines (&bpt->commands);
|
6946 |
|
|
if (bpt->cond_string != NULL)
|
6947 |
|
|
xfree (bpt->cond_string);
|
6948 |
|
|
if (bpt->addr_string != NULL)
|
6949 |
|
|
xfree (bpt->addr_string);
|
6950 |
|
|
if (bpt->exp != NULL)
|
6951 |
|
|
xfree (bpt->exp);
|
6952 |
|
|
if (bpt->exp_string != NULL)
|
6953 |
|
|
xfree (bpt->exp_string);
|
6954 |
|
|
if (bpt->val != NULL)
|
6955 |
|
|
value_free (bpt->val);
|
6956 |
|
|
if (bpt->source_file != NULL)
|
6957 |
|
|
xfree (bpt->source_file);
|
6958 |
|
|
if (bpt->dll_pathname != NULL)
|
6959 |
|
|
xfree (bpt->dll_pathname);
|
6960 |
|
|
if (bpt->triggered_dll_pathname != NULL)
|
6961 |
|
|
xfree (bpt->triggered_dll_pathname);
|
6962 |
|
|
if (bpt->exec_pathname != NULL)
|
6963 |
|
|
xfree (bpt->exec_pathname);
|
6964 |
|
|
|
6965 |
|
|
/* Be sure no bpstat's are pointing at it after it's been freed. */
|
6966 |
|
|
/* FIXME, how can we find all bpstat's?
|
6967 |
|
|
We just check stop_bpstat for now. Note that we cannot just
|
6968 |
|
|
remove bpstats pointing at bpt from the stop_bpstat list
|
6969 |
|
|
entirely, as breakpoint commands are associated with the bpstat;
|
6970 |
|
|
if we remove it here, then the later call to
|
6971 |
|
|
bpstat_do_actions (&stop_bpstat);
|
6972 |
|
|
in event-top.c won't do anything, and temporary breakpoints
|
6973 |
|
|
with commands won't work. */
|
6974 |
|
|
for (bs = stop_bpstat; bs; bs = bs->next)
|
6975 |
|
|
if (bs->breakpoint_at && bs->breakpoint_at->owner == bpt)
|
6976 |
|
|
{
|
6977 |
|
|
bs->breakpoint_at = NULL;
|
6978 |
|
|
bs->old_val = NULL;
|
6979 |
|
|
/* bs->commands will be freed later. */
|
6980 |
|
|
}
|
6981 |
|
|
/* On the chance that someone will soon try again to delete this same
|
6982 |
|
|
bp, we mark it as deleted before freeing its storage. */
|
6983 |
|
|
bpt->type = bp_none;
|
6984 |
|
|
|
6985 |
|
|
for (loc = bpt->loc; loc;)
|
6986 |
|
|
{
|
6987 |
|
|
struct bp_location *loc_next = loc->next;
|
6988 |
|
|
xfree (loc);
|
6989 |
|
|
loc = loc_next;
|
6990 |
|
|
}
|
6991 |
|
|
xfree (bpt);
|
6992 |
|
|
}
|
6993 |
|
|
|
6994 |
|
|
static void
|
6995 |
|
|
do_delete_breakpoint_cleanup (void *b)
|
6996 |
|
|
{
|
6997 |
|
|
delete_breakpoint (b);
|
6998 |
|
|
}
|
6999 |
|
|
|
7000 |
|
|
struct cleanup *
|
7001 |
|
|
make_cleanup_delete_breakpoint (struct breakpoint *b)
|
7002 |
|
|
{
|
7003 |
|
|
return make_cleanup (do_delete_breakpoint_cleanup, b);
|
7004 |
|
|
}
|
7005 |
|
|
|
7006 |
|
|
struct cleanup *
|
7007 |
|
|
make_exec_cleanup_delete_breakpoint (struct breakpoint *b)
|
7008 |
|
|
{
|
7009 |
|
|
return make_exec_cleanup (do_delete_breakpoint_cleanup, b);
|
7010 |
|
|
}
|
7011 |
|
|
|
7012 |
|
|
void
|
7013 |
|
|
delete_command (char *arg, int from_tty)
|
7014 |
|
|
{
|
7015 |
|
|
struct breakpoint *b, *temp;
|
7016 |
|
|
|
7017 |
|
|
dont_repeat ();
|
7018 |
|
|
|
7019 |
|
|
if (arg == 0)
|
7020 |
|
|
{
|
7021 |
|
|
int breaks_to_delete = 0;
|
7022 |
|
|
|
7023 |
|
|
/* Delete all breakpoints if no argument.
|
7024 |
|
|
Do not delete internal or call-dummy breakpoints, these
|
7025 |
|
|
have to be deleted with an explicit breakpoint number argument. */
|
7026 |
|
|
ALL_BREAKPOINTS (b)
|
7027 |
|
|
{
|
7028 |
|
|
if (b->type != bp_call_dummy &&
|
7029 |
|
|
b->type != bp_shlib_event &&
|
7030 |
|
|
b->type != bp_thread_event &&
|
7031 |
|
|
b->type != bp_overlay_event &&
|
7032 |
|
|
b->number >= 0)
|
7033 |
|
|
{
|
7034 |
|
|
breaks_to_delete = 1;
|
7035 |
|
|
break;
|
7036 |
|
|
}
|
7037 |
|
|
}
|
7038 |
|
|
|
7039 |
|
|
/* Ask user only if there are some breakpoints to delete. */
|
7040 |
|
|
if (!from_tty
|
7041 |
|
|
|| (breaks_to_delete && query (_("Delete all breakpoints? "))))
|
7042 |
|
|
{
|
7043 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
7044 |
|
|
{
|
7045 |
|
|
if (b->type != bp_call_dummy &&
|
7046 |
|
|
b->type != bp_shlib_event &&
|
7047 |
|
|
b->type != bp_thread_event &&
|
7048 |
|
|
b->type != bp_overlay_event &&
|
7049 |
|
|
b->number >= 0)
|
7050 |
|
|
delete_breakpoint (b);
|
7051 |
|
|
}
|
7052 |
|
|
}
|
7053 |
|
|
}
|
7054 |
|
|
else
|
7055 |
|
|
map_breakpoint_numbers (arg, delete_breakpoint);
|
7056 |
|
|
}
|
7057 |
|
|
|
7058 |
|
|
static int
|
7059 |
|
|
all_locations_are_pending (struct bp_location *loc)
|
7060 |
|
|
{
|
7061 |
|
|
for (; loc; loc = loc->next)
|
7062 |
|
|
if (!loc->shlib_disabled)
|
7063 |
|
|
return 0;
|
7064 |
|
|
return 1;
|
7065 |
|
|
}
|
7066 |
|
|
|
7067 |
|
|
/* Subroutine of update_breakpoint_locations to simplify it.
|
7068 |
|
|
Return non-zero if multiple fns in list LOC have the same name.
|
7069 |
|
|
Null names are ignored. */
|
7070 |
|
|
|
7071 |
|
|
static int
|
7072 |
|
|
ambiguous_names_p (struct bp_location *loc)
|
7073 |
|
|
{
|
7074 |
|
|
struct bp_location *l;
|
7075 |
|
|
htab_t htab = htab_create_alloc (13, htab_hash_string,
|
7076 |
|
|
(int (*) (const void *, const void *)) streq,
|
7077 |
|
|
NULL, xcalloc, xfree);
|
7078 |
|
|
|
7079 |
|
|
for (l = loc; l != NULL; l = l->next)
|
7080 |
|
|
{
|
7081 |
|
|
const char **slot;
|
7082 |
|
|
const char *name = l->function_name;
|
7083 |
|
|
|
7084 |
|
|
/* Allow for some names to be NULL, ignore them. */
|
7085 |
|
|
if (name == NULL)
|
7086 |
|
|
continue;
|
7087 |
|
|
|
7088 |
|
|
slot = (const char **) htab_find_slot (htab, (const void *) name,
|
7089 |
|
|
INSERT);
|
7090 |
|
|
/* NOTE: We can assume slot != NULL here because xcalloc never returns
|
7091 |
|
|
NULL. */
|
7092 |
|
|
if (*slot != NULL)
|
7093 |
|
|
{
|
7094 |
|
|
htab_delete (htab);
|
7095 |
|
|
return 1;
|
7096 |
|
|
}
|
7097 |
|
|
*slot = name;
|
7098 |
|
|
}
|
7099 |
|
|
|
7100 |
|
|
htab_delete (htab);
|
7101 |
|
|
return 0;
|
7102 |
|
|
}
|
7103 |
|
|
|
7104 |
|
|
static void
|
7105 |
|
|
update_breakpoint_locations (struct breakpoint *b,
|
7106 |
|
|
struct symtabs_and_lines sals)
|
7107 |
|
|
{
|
7108 |
|
|
int i;
|
7109 |
|
|
char *s;
|
7110 |
|
|
struct bp_location *existing_locations = b->loc;
|
7111 |
|
|
|
7112 |
|
|
/* If there's no new locations, and all existing locations
|
7113 |
|
|
are pending, don't do anything. This optimizes
|
7114 |
|
|
the common case where all locations are in the same
|
7115 |
|
|
shared library, that was unloaded. We'd like to
|
7116 |
|
|
retain the location, so that when the library
|
7117 |
|
|
is loaded again, we don't loose the enabled/disabled
|
7118 |
|
|
status of the individual locations. */
|
7119 |
|
|
if (all_locations_are_pending (existing_locations) && sals.nelts == 0)
|
7120 |
|
|
return;
|
7121 |
|
|
|
7122 |
|
|
unlink_locations_from_global_list (b);
|
7123 |
|
|
b->loc = NULL;
|
7124 |
|
|
|
7125 |
|
|
for (i = 0; i < sals.nelts; ++i)
|
7126 |
|
|
{
|
7127 |
|
|
struct bp_location *new_loc =
|
7128 |
|
|
add_location_to_breakpoint (b, b->type, &(sals.sals[i]));
|
7129 |
|
|
|
7130 |
|
|
/* Reparse conditions, they might contain references to the
|
7131 |
|
|
old symtab. */
|
7132 |
|
|
if (b->cond_string != NULL)
|
7133 |
|
|
{
|
7134 |
|
|
struct gdb_exception e;
|
7135 |
|
|
|
7136 |
|
|
s = b->cond_string;
|
7137 |
|
|
TRY_CATCH (e, RETURN_MASK_ERROR)
|
7138 |
|
|
{
|
7139 |
|
|
new_loc->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc),
|
7140 |
|
|
0);
|
7141 |
|
|
}
|
7142 |
|
|
if (e.reason < 0)
|
7143 |
|
|
{
|
7144 |
|
|
warning (_("failed to reevaluate condition for breakpoint %d: %s"),
|
7145 |
|
|
b->number, e.message);
|
7146 |
|
|
new_loc->enabled = 0;
|
7147 |
|
|
}
|
7148 |
|
|
}
|
7149 |
|
|
|
7150 |
|
|
if (b->source_file != NULL)
|
7151 |
|
|
xfree (b->source_file);
|
7152 |
|
|
if (sals.sals[i].symtab == NULL)
|
7153 |
|
|
b->source_file = NULL;
|
7154 |
|
|
else
|
7155 |
|
|
b->source_file =
|
7156 |
|
|
savestring (sals.sals[i].symtab->filename,
|
7157 |
|
|
strlen (sals.sals[i].symtab->filename));
|
7158 |
|
|
|
7159 |
|
|
if (b->line_number == 0)
|
7160 |
|
|
b->line_number = sals.sals[i].line;
|
7161 |
|
|
}
|
7162 |
|
|
|
7163 |
|
|
/* If possible, carry over 'disable' status from existing breakpoints. */
|
7164 |
|
|
{
|
7165 |
|
|
struct bp_location *e = existing_locations;
|
7166 |
|
|
/* If there are multiple breakpoints with the same function name,
|
7167 |
|
|
e.g. for inline functions, comparing function names won't work.
|
7168 |
|
|
Instead compare pc addresses; this is just a heuristic as things
|
7169 |
|
|
may have moved, but in practice it gives the correct answer
|
7170 |
|
|
often enough until a better solution is found. */
|
7171 |
|
|
int have_ambiguous_names = ambiguous_names_p (b->loc);
|
7172 |
|
|
|
7173 |
|
|
for (; e; e = e->next)
|
7174 |
|
|
{
|
7175 |
|
|
if (!e->enabled && e->function_name)
|
7176 |
|
|
{
|
7177 |
|
|
struct bp_location *l = b->loc;
|
7178 |
|
|
if (have_ambiguous_names)
|
7179 |
|
|
{
|
7180 |
|
|
for (; l; l = l->next)
|
7181 |
|
|
if (e->address == l->address)
|
7182 |
|
|
{
|
7183 |
|
|
l->enabled = 0;
|
7184 |
|
|
break;
|
7185 |
|
|
}
|
7186 |
|
|
}
|
7187 |
|
|
else
|
7188 |
|
|
{
|
7189 |
|
|
for (; l; l = l->next)
|
7190 |
|
|
if (l->function_name
|
7191 |
|
|
&& strcmp (e->function_name, l->function_name) == 0)
|
7192 |
|
|
{
|
7193 |
|
|
l->enabled = 0;
|
7194 |
|
|
break;
|
7195 |
|
|
}
|
7196 |
|
|
}
|
7197 |
|
|
}
|
7198 |
|
|
}
|
7199 |
|
|
}
|
7200 |
|
|
|
7201 |
|
|
while (existing_locations)
|
7202 |
|
|
{
|
7203 |
|
|
struct bp_location *next = existing_locations->next;
|
7204 |
|
|
free_bp_location (existing_locations);
|
7205 |
|
|
existing_locations = next;
|
7206 |
|
|
}
|
7207 |
|
|
}
|
7208 |
|
|
|
7209 |
|
|
|
7210 |
|
|
/* Reset a breakpoint given it's struct breakpoint * BINT.
|
7211 |
|
|
The value we return ends up being the return value from catch_errors.
|
7212 |
|
|
Unused in this case. */
|
7213 |
|
|
|
7214 |
|
|
static int
|
7215 |
|
|
breakpoint_re_set_one (void *bint)
|
7216 |
|
|
{
|
7217 |
|
|
/* get past catch_errs */
|
7218 |
|
|
struct breakpoint *b = (struct breakpoint *) bint;
|
7219 |
|
|
struct value *mark;
|
7220 |
|
|
int i;
|
7221 |
|
|
int not_found = 0;
|
7222 |
|
|
int *not_found_ptr = ¬_found;
|
7223 |
|
|
struct symtabs_and_lines sals = {};
|
7224 |
|
|
struct symtabs_and_lines expanded;
|
7225 |
|
|
char *s;
|
7226 |
|
|
enum enable_state save_enable;
|
7227 |
|
|
struct gdb_exception e;
|
7228 |
|
|
|
7229 |
|
|
|
7230 |
|
|
switch (b->type)
|
7231 |
|
|
{
|
7232 |
|
|
case bp_none:
|
7233 |
|
|
warning (_("attempted to reset apparently deleted breakpoint #%d?"),
|
7234 |
|
|
b->number);
|
7235 |
|
|
return 0;
|
7236 |
|
|
case bp_breakpoint:
|
7237 |
|
|
case bp_hardware_breakpoint:
|
7238 |
|
|
case bp_catch_load:
|
7239 |
|
|
case bp_catch_unload:
|
7240 |
|
|
if (b->addr_string == NULL)
|
7241 |
|
|
{
|
7242 |
|
|
/* Anything without a string can't be re-set. */
|
7243 |
|
|
delete_breakpoint (b);
|
7244 |
|
|
return 0;
|
7245 |
|
|
}
|
7246 |
|
|
|
7247 |
|
|
set_language (b->language);
|
7248 |
|
|
input_radix = b->input_radix;
|
7249 |
|
|
s = b->addr_string;
|
7250 |
|
|
TRY_CATCH (e, RETURN_MASK_ERROR)
|
7251 |
|
|
{
|
7252 |
|
|
sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL,
|
7253 |
|
|
not_found_ptr);
|
7254 |
|
|
}
|
7255 |
|
|
if (e.reason < 0)
|
7256 |
|
|
{
|
7257 |
|
|
int not_found_and_ok = 0;
|
7258 |
|
|
/* For pending breakpoints, it's expected that parsing
|
7259 |
|
|
will fail until the right shared library is loaded.
|
7260 |
|
|
User has already told to create pending breakpoints and
|
7261 |
|
|
don't need extra messages. If breakpoint is in bp_shlib_disabled
|
7262 |
|
|
state, then user already saw the message about that breakpoint
|
7263 |
|
|
being disabled, and don't want to see more errors. */
|
7264 |
|
|
if (not_found
|
7265 |
|
|
&& (b->condition_not_parsed
|
7266 |
|
|
|| (b->loc && b->loc->shlib_disabled)
|
7267 |
|
|
|| b->enable_state == bp_disabled))
|
7268 |
|
|
not_found_and_ok = 1;
|
7269 |
|
|
|
7270 |
|
|
if (!not_found_and_ok)
|
7271 |
|
|
{
|
7272 |
|
|
/* We surely don't want to warn about the same breakpoint
|
7273 |
|
|
10 times. One solution, implemented here, is disable
|
7274 |
|
|
the breakpoint on error. Another solution would be to
|
7275 |
|
|
have separate 'warning emitted' flag. Since this
|
7276 |
|
|
happens only when a binary has changed, I don't know
|
7277 |
|
|
which approach is better. */
|
7278 |
|
|
b->enable_state = bp_disabled;
|
7279 |
|
|
throw_exception (e);
|
7280 |
|
|
}
|
7281 |
|
|
}
|
7282 |
|
|
|
7283 |
|
|
if (not_found)
|
7284 |
|
|
break;
|
7285 |
|
|
|
7286 |
|
|
gdb_assert (sals.nelts == 1);
|
7287 |
|
|
resolve_sal_pc (&sals.sals[0]);
|
7288 |
|
|
if (b->condition_not_parsed && s && s[0])
|
7289 |
|
|
{
|
7290 |
|
|
char *cond_string = 0;
|
7291 |
|
|
int thread = -1;
|
7292 |
|
|
find_condition_and_thread (s, sals.sals[0].pc,
|
7293 |
|
|
&cond_string, &thread);
|
7294 |
|
|
if (cond_string)
|
7295 |
|
|
b->cond_string = cond_string;
|
7296 |
|
|
b->thread = thread;
|
7297 |
|
|
b->condition_not_parsed = 0;
|
7298 |
|
|
}
|
7299 |
|
|
expanded = expand_line_sal_maybe (sals.sals[0]);
|
7300 |
|
|
update_breakpoint_locations (b, expanded);
|
7301 |
|
|
|
7302 |
|
|
/* Now that this is re-enabled, check_duplicates
|
7303 |
|
|
can be used. */
|
7304 |
|
|
check_duplicates (b);
|
7305 |
|
|
|
7306 |
|
|
xfree (sals.sals);
|
7307 |
|
|
break;
|
7308 |
|
|
|
7309 |
|
|
case bp_watchpoint:
|
7310 |
|
|
case bp_hardware_watchpoint:
|
7311 |
|
|
case bp_read_watchpoint:
|
7312 |
|
|
case bp_access_watchpoint:
|
7313 |
|
|
/* Watchpoint can be either on expression using entirely global variables,
|
7314 |
|
|
or it can be on local variables.
|
7315 |
|
|
|
7316 |
|
|
Watchpoints of the first kind are never auto-deleted, and even persist
|
7317 |
|
|
across program restarts. Since they can use variables from shared
|
7318 |
|
|
libraries, we need to reparse expression as libraries are loaded
|
7319 |
|
|
and unloaded.
|
7320 |
|
|
|
7321 |
|
|
Watchpoints on local variables can also change meaning as result
|
7322 |
|
|
of solib event. For example, if a watchpoint uses both a local and
|
7323 |
|
|
a global variables in expression, it's a local watchpoint, but
|
7324 |
|
|
unloading of a shared library will make the expression invalid.
|
7325 |
|
|
This is not a very common use case, but we still re-evaluate
|
7326 |
|
|
expression, to avoid surprises to the user.
|
7327 |
|
|
|
7328 |
|
|
Note that for local watchpoints, we re-evaluate it only if
|
7329 |
|
|
watchpoints frame id is still valid. If it's not, it means
|
7330 |
|
|
the watchpoint is out of scope and will be deleted soon. In fact,
|
7331 |
|
|
I'm not sure we'll ever be called in this case.
|
7332 |
|
|
|
7333 |
|
|
If a local watchpoint's frame id is still valid, then
|
7334 |
|
|
b->exp_valid_block is likewise valid, and we can safely use it.
|
7335 |
|
|
|
7336 |
|
|
Don't do anything about disabled watchpoints, since they will
|
7337 |
|
|
be reevaluated again when enabled. */
|
7338 |
|
|
update_watchpoint (b, 1 /* reparse */);
|
7339 |
|
|
break;
|
7340 |
|
|
/* We needn't really do anything to reset these, since the mask
|
7341 |
|
|
that requests them is unaffected by e.g., new libraries being
|
7342 |
|
|
loaded. */
|
7343 |
|
|
case bp_catch_fork:
|
7344 |
|
|
case bp_catch_vfork:
|
7345 |
|
|
case bp_catch_exec:
|
7346 |
|
|
break;
|
7347 |
|
|
|
7348 |
|
|
default:
|
7349 |
|
|
printf_filtered (_("Deleting unknown breakpoint type %d\n"), b->type);
|
7350 |
|
|
/* fall through */
|
7351 |
|
|
/* Delete longjmp and overlay event breakpoints; they will be
|
7352 |
|
|
reset later by breakpoint_re_set. */
|
7353 |
|
|
case bp_longjmp:
|
7354 |
|
|
case bp_longjmp_resume:
|
7355 |
|
|
case bp_overlay_event:
|
7356 |
|
|
delete_breakpoint (b);
|
7357 |
|
|
break;
|
7358 |
|
|
|
7359 |
|
|
/* This breakpoint is special, it's set up when the inferior
|
7360 |
|
|
starts and we really don't want to touch it. */
|
7361 |
|
|
case bp_shlib_event:
|
7362 |
|
|
|
7363 |
|
|
/* Like bp_shlib_event, this breakpoint type is special.
|
7364 |
|
|
Once it is set up, we do not want to touch it. */
|
7365 |
|
|
case bp_thread_event:
|
7366 |
|
|
|
7367 |
|
|
/* Keep temporary breakpoints, which can be encountered when we step
|
7368 |
|
|
over a dlopen call and SOLIB_ADD is resetting the breakpoints.
|
7369 |
|
|
Otherwise these should have been blown away via the cleanup chain
|
7370 |
|
|
or by breakpoint_init_inferior when we rerun the executable. */
|
7371 |
|
|
case bp_until:
|
7372 |
|
|
case bp_finish:
|
7373 |
|
|
case bp_watchpoint_scope:
|
7374 |
|
|
case bp_call_dummy:
|
7375 |
|
|
case bp_step_resume:
|
7376 |
|
|
break;
|
7377 |
|
|
}
|
7378 |
|
|
|
7379 |
|
|
return 0;
|
7380 |
|
|
}
|
7381 |
|
|
|
7382 |
|
|
/* Re-set all breakpoints after symbols have been re-loaded. */
|
7383 |
|
|
void
|
7384 |
|
|
breakpoint_re_set (void)
|
7385 |
|
|
{
|
7386 |
|
|
struct breakpoint *b, *temp;
|
7387 |
|
|
enum language save_language;
|
7388 |
|
|
int save_input_radix;
|
7389 |
|
|
|
7390 |
|
|
save_language = current_language->la_language;
|
7391 |
|
|
save_input_radix = input_radix;
|
7392 |
|
|
ALL_BREAKPOINTS_SAFE (b, temp)
|
7393 |
|
|
{
|
7394 |
|
|
/* Format possible error msg */
|
7395 |
|
|
char *message = xstrprintf ("Error in re-setting breakpoint %d: ",
|
7396 |
|
|
b->number);
|
7397 |
|
|
struct cleanup *cleanups = make_cleanup (xfree, message);
|
7398 |
|
|
catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
|
7399 |
|
|
do_cleanups (cleanups);
|
7400 |
|
|
}
|
7401 |
|
|
set_language (save_language);
|
7402 |
|
|
input_radix = save_input_radix;
|
7403 |
|
|
|
7404 |
|
|
if (gdbarch_get_longjmp_target_p (current_gdbarch))
|
7405 |
|
|
{
|
7406 |
|
|
create_longjmp_breakpoint ("longjmp");
|
7407 |
|
|
create_longjmp_breakpoint ("_longjmp");
|
7408 |
|
|
create_longjmp_breakpoint ("siglongjmp");
|
7409 |
|
|
create_longjmp_breakpoint ("_siglongjmp");
|
7410 |
|
|
create_longjmp_breakpoint (NULL);
|
7411 |
|
|
}
|
7412 |
|
|
|
7413 |
|
|
create_overlay_event_breakpoint ("_ovly_debug_event");
|
7414 |
|
|
}
|
7415 |
|
|
|
7416 |
|
|
/* Reset the thread number of this breakpoint:
|
7417 |
|
|
|
7418 |
|
|
- If the breakpoint is for all threads, leave it as-is.
|
7419 |
|
|
- Else, reset it to the current thread for inferior_ptid. */
|
7420 |
|
|
void
|
7421 |
|
|
breakpoint_re_set_thread (struct breakpoint *b)
|
7422 |
|
|
{
|
7423 |
|
|
if (b->thread != -1)
|
7424 |
|
|
{
|
7425 |
|
|
if (in_thread_list (inferior_ptid))
|
7426 |
|
|
b->thread = pid_to_thread_id (inferior_ptid);
|
7427 |
|
|
}
|
7428 |
|
|
}
|
7429 |
|
|
|
7430 |
|
|
/* Set ignore-count of breakpoint number BPTNUM to COUNT.
|
7431 |
|
|
If from_tty is nonzero, it prints a message to that effect,
|
7432 |
|
|
which ends with a period (no newline). */
|
7433 |
|
|
|
7434 |
|
|
void
|
7435 |
|
|
set_ignore_count (int bptnum, int count, int from_tty)
|
7436 |
|
|
{
|
7437 |
|
|
struct breakpoint *b;
|
7438 |
|
|
|
7439 |
|
|
if (count < 0)
|
7440 |
|
|
count = 0;
|
7441 |
|
|
|
7442 |
|
|
ALL_BREAKPOINTS (b)
|
7443 |
|
|
if (b->number == bptnum)
|
7444 |
|
|
{
|
7445 |
|
|
b->ignore_count = count;
|
7446 |
|
|
if (from_tty)
|
7447 |
|
|
{
|
7448 |
|
|
if (count == 0)
|
7449 |
|
|
printf_filtered (_("Will stop next time breakpoint %d is reached."),
|
7450 |
|
|
bptnum);
|
7451 |
|
|
else if (count == 1)
|
7452 |
|
|
printf_filtered (_("Will ignore next crossing of breakpoint %d."),
|
7453 |
|
|
bptnum);
|
7454 |
|
|
else
|
7455 |
|
|
printf_filtered (_("Will ignore next %d crossings of breakpoint %d."),
|
7456 |
|
|
count, bptnum);
|
7457 |
|
|
}
|
7458 |
|
|
breakpoints_changed ();
|
7459 |
|
|
breakpoint_modify_event (b->number);
|
7460 |
|
|
return;
|
7461 |
|
|
}
|
7462 |
|
|
|
7463 |
|
|
error (_("No breakpoint number %d."), bptnum);
|
7464 |
|
|
}
|
7465 |
|
|
|
7466 |
|
|
/* Clear the ignore counts of all breakpoints. */
|
7467 |
|
|
void
|
7468 |
|
|
breakpoint_clear_ignore_counts (void)
|
7469 |
|
|
{
|
7470 |
|
|
struct breakpoint *b;
|
7471 |
|
|
|
7472 |
|
|
ALL_BREAKPOINTS (b)
|
7473 |
|
|
b->ignore_count = 0;
|
7474 |
|
|
}
|
7475 |
|
|
|
7476 |
|
|
/* Command to set ignore-count of breakpoint N to COUNT. */
|
7477 |
|
|
|
7478 |
|
|
static void
|
7479 |
|
|
ignore_command (char *args, int from_tty)
|
7480 |
|
|
{
|
7481 |
|
|
char *p = args;
|
7482 |
|
|
int num;
|
7483 |
|
|
|
7484 |
|
|
if (p == 0)
|
7485 |
|
|
error_no_arg (_("a breakpoint number"));
|
7486 |
|
|
|
7487 |
|
|
num = get_number (&p);
|
7488 |
|
|
if (num == 0)
|
7489 |
|
|
error (_("bad breakpoint number: '%s'"), args);
|
7490 |
|
|
if (*p == 0)
|
7491 |
|
|
error (_("Second argument (specified ignore-count) is missing."));
|
7492 |
|
|
|
7493 |
|
|
set_ignore_count (num,
|
7494 |
|
|
longest_to_int (value_as_long (parse_and_eval (p))),
|
7495 |
|
|
from_tty);
|
7496 |
|
|
if (from_tty)
|
7497 |
|
|
printf_filtered ("\n");
|
7498 |
|
|
}
|
7499 |
|
|
|
7500 |
|
|
/* Call FUNCTION on each of the breakpoints
|
7501 |
|
|
whose numbers are given in ARGS. */
|
7502 |
|
|
|
7503 |
|
|
static void
|
7504 |
|
|
map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *))
|
7505 |
|
|
{
|
7506 |
|
|
char *p = args;
|
7507 |
|
|
char *p1;
|
7508 |
|
|
int num;
|
7509 |
|
|
struct breakpoint *b, *tmp;
|
7510 |
|
|
int match;
|
7511 |
|
|
|
7512 |
|
|
if (p == 0)
|
7513 |
|
|
error_no_arg (_("one or more breakpoint numbers"));
|
7514 |
|
|
|
7515 |
|
|
while (*p)
|
7516 |
|
|
{
|
7517 |
|
|
match = 0;
|
7518 |
|
|
p1 = p;
|
7519 |
|
|
|
7520 |
|
|
num = get_number_or_range (&p1);
|
7521 |
|
|
if (num == 0)
|
7522 |
|
|
{
|
7523 |
|
|
warning (_("bad breakpoint number at or near '%s'"), p);
|
7524 |
|
|
}
|
7525 |
|
|
else
|
7526 |
|
|
{
|
7527 |
|
|
ALL_BREAKPOINTS_SAFE (b, tmp)
|
7528 |
|
|
if (b->number == num)
|
7529 |
|
|
{
|
7530 |
|
|
struct breakpoint *related_breakpoint = b->related_breakpoint;
|
7531 |
|
|
match = 1;
|
7532 |
|
|
function (b);
|
7533 |
|
|
if (related_breakpoint)
|
7534 |
|
|
function (related_breakpoint);
|
7535 |
|
|
break;
|
7536 |
|
|
}
|
7537 |
|
|
if (match == 0)
|
7538 |
|
|
printf_unfiltered (_("No breakpoint number %d.\n"), num);
|
7539 |
|
|
}
|
7540 |
|
|
p = p1;
|
7541 |
|
|
}
|
7542 |
|
|
}
|
7543 |
|
|
|
7544 |
|
|
static struct bp_location *
|
7545 |
|
|
find_location_by_number (char *number)
|
7546 |
|
|
{
|
7547 |
|
|
char *dot = strchr (number, '.');
|
7548 |
|
|
char *p1;
|
7549 |
|
|
int bp_num;
|
7550 |
|
|
int loc_num;
|
7551 |
|
|
struct breakpoint *b;
|
7552 |
|
|
struct bp_location *loc;
|
7553 |
|
|
|
7554 |
|
|
*dot = '\0';
|
7555 |
|
|
|
7556 |
|
|
p1 = number;
|
7557 |
|
|
bp_num = get_number_or_range (&p1);
|
7558 |
|
|
if (bp_num == 0)
|
7559 |
|
|
error (_("Bad breakpoint number '%s'"), number);
|
7560 |
|
|
|
7561 |
|
|
ALL_BREAKPOINTS (b)
|
7562 |
|
|
if (b->number == bp_num)
|
7563 |
|
|
{
|
7564 |
|
|
break;
|
7565 |
|
|
}
|
7566 |
|
|
|
7567 |
|
|
if (!b || b->number != bp_num)
|
7568 |
|
|
error (_("Bad breakpoint number '%s'"), number);
|
7569 |
|
|
|
7570 |
|
|
p1 = dot+1;
|
7571 |
|
|
loc_num = get_number_or_range (&p1);
|
7572 |
|
|
if (loc_num == 0)
|
7573 |
|
|
error (_("Bad breakpoint location number '%s'"), number);
|
7574 |
|
|
|
7575 |
|
|
--loc_num;
|
7576 |
|
|
loc = b->loc;
|
7577 |
|
|
for (;loc_num && loc; --loc_num, loc = loc->next)
|
7578 |
|
|
;
|
7579 |
|
|
if (!loc)
|
7580 |
|
|
error (_("Bad breakpoint location number '%s'"), dot+1);
|
7581 |
|
|
|
7582 |
|
|
return loc;
|
7583 |
|
|
}
|
7584 |
|
|
|
7585 |
|
|
|
7586 |
|
|
/* Set ignore-count of breakpoint number BPTNUM to COUNT.
|
7587 |
|
|
If from_tty is nonzero, it prints a message to that effect,
|
7588 |
|
|
which ends with a period (no newline). */
|
7589 |
|
|
|
7590 |
|
|
void
|
7591 |
|
|
disable_breakpoint (struct breakpoint *bpt)
|
7592 |
|
|
{
|
7593 |
|
|
/* Never disable a watchpoint scope breakpoint; we want to
|
7594 |
|
|
hit them when we leave scope so we can delete both the
|
7595 |
|
|
watchpoint and its scope breakpoint at that time. */
|
7596 |
|
|
if (bpt->type == bp_watchpoint_scope)
|
7597 |
|
|
return;
|
7598 |
|
|
|
7599 |
|
|
/* You can't disable permanent breakpoints. */
|
7600 |
|
|
if (bpt->enable_state == bp_permanent)
|
7601 |
|
|
return;
|
7602 |
|
|
|
7603 |
|
|
bpt->enable_state = bp_disabled;
|
7604 |
|
|
|
7605 |
|
|
check_duplicates (bpt);
|
7606 |
|
|
|
7607 |
|
|
if (deprecated_modify_breakpoint_hook)
|
7608 |
|
|
deprecated_modify_breakpoint_hook (bpt);
|
7609 |
|
|
breakpoint_modify_event (bpt->number);
|
7610 |
|
|
}
|
7611 |
|
|
|
7612 |
|
|
static void
|
7613 |
|
|
disable_command (char *args, int from_tty)
|
7614 |
|
|
{
|
7615 |
|
|
struct breakpoint *bpt;
|
7616 |
|
|
if (args == 0)
|
7617 |
|
|
ALL_BREAKPOINTS (bpt)
|
7618 |
|
|
switch (bpt->type)
|
7619 |
|
|
{
|
7620 |
|
|
case bp_none:
|
7621 |
|
|
warning (_("attempted to disable apparently deleted breakpoint #%d?"),
|
7622 |
|
|
bpt->number);
|
7623 |
|
|
continue;
|
7624 |
|
|
case bp_breakpoint:
|
7625 |
|
|
case bp_catch_load:
|
7626 |
|
|
case bp_catch_unload:
|
7627 |
|
|
case bp_catch_fork:
|
7628 |
|
|
case bp_catch_vfork:
|
7629 |
|
|
case bp_catch_exec:
|
7630 |
|
|
case bp_hardware_breakpoint:
|
7631 |
|
|
case bp_watchpoint:
|
7632 |
|
|
case bp_hardware_watchpoint:
|
7633 |
|
|
case bp_read_watchpoint:
|
7634 |
|
|
case bp_access_watchpoint:
|
7635 |
|
|
disable_breakpoint (bpt);
|
7636 |
|
|
default:
|
7637 |
|
|
continue;
|
7638 |
|
|
}
|
7639 |
|
|
else if (strchr (args, '.'))
|
7640 |
|
|
{
|
7641 |
|
|
struct bp_location *loc = find_location_by_number (args);
|
7642 |
|
|
if (loc)
|
7643 |
|
|
loc->enabled = 0;
|
7644 |
|
|
check_duplicates (loc->owner);
|
7645 |
|
|
}
|
7646 |
|
|
else
|
7647 |
|
|
map_breakpoint_numbers (args, disable_breakpoint);
|
7648 |
|
|
}
|
7649 |
|
|
|
7650 |
|
|
static void
|
7651 |
|
|
do_enable_breakpoint (struct breakpoint *bpt, enum bpdisp disposition)
|
7652 |
|
|
{
|
7653 |
|
|
int target_resources_ok, other_type_used;
|
7654 |
|
|
struct value *mark;
|
7655 |
|
|
|
7656 |
|
|
if (bpt->type == bp_hardware_breakpoint)
|
7657 |
|
|
{
|
7658 |
|
|
int i;
|
7659 |
|
|
i = hw_breakpoint_used_count ();
|
7660 |
|
|
target_resources_ok =
|
7661 |
|
|
TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint,
|
7662 |
|
|
i + 1, 0);
|
7663 |
|
|
if (target_resources_ok == 0)
|
7664 |
|
|
error (_("No hardware breakpoint support in the target."));
|
7665 |
|
|
else if (target_resources_ok < 0)
|
7666 |
|
|
error (_("Hardware breakpoints used exceeds limit."));
|
7667 |
|
|
}
|
7668 |
|
|
|
7669 |
|
|
if (bpt->type == bp_watchpoint ||
|
7670 |
|
|
bpt->type == bp_hardware_watchpoint ||
|
7671 |
|
|
bpt->type == bp_read_watchpoint ||
|
7672 |
|
|
bpt->type == bp_access_watchpoint)
|
7673 |
|
|
{
|
7674 |
|
|
struct frame_id saved_frame_id;
|
7675 |
|
|
|
7676 |
|
|
saved_frame_id = get_frame_id (get_selected_frame (NULL));
|
7677 |
|
|
if (bpt->exp_valid_block != NULL)
|
7678 |
|
|
{
|
7679 |
|
|
struct frame_info *fr =
|
7680 |
|
|
fr = frame_find_by_id (bpt->watchpoint_frame);
|
7681 |
|
|
if (fr == NULL)
|
7682 |
|
|
{
|
7683 |
|
|
printf_filtered (_("\
|
7684 |
|
|
Cannot enable watchpoint %d because the block in which its expression\n\
|
7685 |
|
|
is valid is not currently in scope.\n"), bpt->number);
|
7686 |
|
|
return;
|
7687 |
|
|
}
|
7688 |
|
|
select_frame (fr);
|
7689 |
|
|
}
|
7690 |
|
|
|
7691 |
|
|
if (bpt->val)
|
7692 |
|
|
value_free (bpt->val);
|
7693 |
|
|
mark = value_mark ();
|
7694 |
|
|
bpt->val = evaluate_expression (bpt->exp);
|
7695 |
|
|
release_value (bpt->val);
|
7696 |
|
|
if (value_lazy (bpt->val))
|
7697 |
|
|
value_fetch_lazy (bpt->val);
|
7698 |
|
|
|
7699 |
|
|
if (bpt->type == bp_hardware_watchpoint ||
|
7700 |
|
|
bpt->type == bp_read_watchpoint ||
|
7701 |
|
|
bpt->type == bp_access_watchpoint)
|
7702 |
|
|
{
|
7703 |
|
|
int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
|
7704 |
|
|
int mem_cnt = can_use_hardware_watchpoint (bpt->val);
|
7705 |
|
|
|
7706 |
|
|
/* Hack around 'unused var' error for some targets here */
|
7707 |
|
|
(void) mem_cnt, (void) i;
|
7708 |
|
|
target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
|
7709 |
|
|
bpt->type, i + mem_cnt, other_type_used);
|
7710 |
|
|
/* we can consider of type is bp_hardware_watchpoint, convert to
|
7711 |
|
|
bp_watchpoint in the following condition */
|
7712 |
|
|
if (target_resources_ok < 0)
|
7713 |
|
|
{
|
7714 |
|
|
printf_filtered (_("\
|
7715 |
|
|
Cannot enable watchpoint %d because target watch resources\n\
|
7716 |
|
|
have been allocated for other watchpoints.\n"), bpt->number);
|
7717 |
|
|
value_free_to_mark (mark);
|
7718 |
|
|
return;
|
7719 |
|
|
}
|
7720 |
|
|
}
|
7721 |
|
|
|
7722 |
|
|
select_frame (frame_find_by_id (saved_frame_id));
|
7723 |
|
|
value_free_to_mark (mark);
|
7724 |
|
|
}
|
7725 |
|
|
|
7726 |
|
|
if (bpt->enable_state != bp_permanent)
|
7727 |
|
|
bpt->enable_state = bp_enabled;
|
7728 |
|
|
bpt->disposition = disposition;
|
7729 |
|
|
check_duplicates (bpt);
|
7730 |
|
|
breakpoints_changed ();
|
7731 |
|
|
|
7732 |
|
|
if (deprecated_modify_breakpoint_hook)
|
7733 |
|
|
deprecated_modify_breakpoint_hook (bpt);
|
7734 |
|
|
breakpoint_modify_event (bpt->number);
|
7735 |
|
|
}
|
7736 |
|
|
|
7737 |
|
|
|
7738 |
|
|
void
|
7739 |
|
|
enable_breakpoint (struct breakpoint *bpt)
|
7740 |
|
|
{
|
7741 |
|
|
do_enable_breakpoint (bpt, bpt->disposition);
|
7742 |
|
|
}
|
7743 |
|
|
|
7744 |
|
|
/* The enable command enables the specified breakpoints (or all defined
|
7745 |
|
|
breakpoints) so they once again become (or continue to be) effective
|
7746 |
|
|
in stopping the inferior. */
|
7747 |
|
|
|
7748 |
|
|
static void
|
7749 |
|
|
enable_command (char *args, int from_tty)
|
7750 |
|
|
{
|
7751 |
|
|
struct breakpoint *bpt;
|
7752 |
|
|
if (args == 0)
|
7753 |
|
|
ALL_BREAKPOINTS (bpt)
|
7754 |
|
|
switch (bpt->type)
|
7755 |
|
|
{
|
7756 |
|
|
case bp_none:
|
7757 |
|
|
warning (_("attempted to enable apparently deleted breakpoint #%d?"),
|
7758 |
|
|
bpt->number);
|
7759 |
|
|
continue;
|
7760 |
|
|
case bp_breakpoint:
|
7761 |
|
|
case bp_catch_load:
|
7762 |
|
|
case bp_catch_unload:
|
7763 |
|
|
case bp_catch_fork:
|
7764 |
|
|
case bp_catch_vfork:
|
7765 |
|
|
case bp_catch_exec:
|
7766 |
|
|
case bp_hardware_breakpoint:
|
7767 |
|
|
case bp_watchpoint:
|
7768 |
|
|
case bp_hardware_watchpoint:
|
7769 |
|
|
case bp_read_watchpoint:
|
7770 |
|
|
case bp_access_watchpoint:
|
7771 |
|
|
enable_breakpoint (bpt);
|
7772 |
|
|
default:
|
7773 |
|
|
continue;
|
7774 |
|
|
}
|
7775 |
|
|
else if (strchr (args, '.'))
|
7776 |
|
|
{
|
7777 |
|
|
struct bp_location *loc = find_location_by_number (args);
|
7778 |
|
|
if (loc)
|
7779 |
|
|
loc->enabled = 1;
|
7780 |
|
|
check_duplicates (loc->owner);
|
7781 |
|
|
}
|
7782 |
|
|
else
|
7783 |
|
|
map_breakpoint_numbers (args, enable_breakpoint);
|
7784 |
|
|
}
|
7785 |
|
|
|
7786 |
|
|
static void
|
7787 |
|
|
enable_once_breakpoint (struct breakpoint *bpt)
|
7788 |
|
|
{
|
7789 |
|
|
do_enable_breakpoint (bpt, disp_disable);
|
7790 |
|
|
}
|
7791 |
|
|
|
7792 |
|
|
static void
|
7793 |
|
|
enable_once_command (char *args, int from_tty)
|
7794 |
|
|
{
|
7795 |
|
|
map_breakpoint_numbers (args, enable_once_breakpoint);
|
7796 |
|
|
}
|
7797 |
|
|
|
7798 |
|
|
static void
|
7799 |
|
|
enable_delete_breakpoint (struct breakpoint *bpt)
|
7800 |
|
|
{
|
7801 |
|
|
do_enable_breakpoint (bpt, disp_del);
|
7802 |
|
|
}
|
7803 |
|
|
|
7804 |
|
|
static void
|
7805 |
|
|
enable_delete_command (char *args, int from_tty)
|
7806 |
|
|
{
|
7807 |
|
|
map_breakpoint_numbers (args, enable_delete_breakpoint);
|
7808 |
|
|
}
|
7809 |
|
|
|
7810 |
|
|
static void
|
7811 |
|
|
set_breakpoint_cmd (char *args, int from_tty)
|
7812 |
|
|
{
|
7813 |
|
|
}
|
7814 |
|
|
|
7815 |
|
|
static void
|
7816 |
|
|
show_breakpoint_cmd (char *args, int from_tty)
|
7817 |
|
|
{
|
7818 |
|
|
}
|
7819 |
|
|
|
7820 |
|
|
/* Use default_breakpoint_'s, or nothing if they aren't valid. */
|
7821 |
|
|
|
7822 |
|
|
struct symtabs_and_lines
|
7823 |
|
|
decode_line_spec_1 (char *string, int funfirstline)
|
7824 |
|
|
{
|
7825 |
|
|
struct symtabs_and_lines sals;
|
7826 |
|
|
if (string == 0)
|
7827 |
|
|
error (_("Empty line specification."));
|
7828 |
|
|
if (default_breakpoint_valid)
|
7829 |
|
|
sals = decode_line_1 (&string, funfirstline,
|
7830 |
|
|
default_breakpoint_symtab,
|
7831 |
|
|
default_breakpoint_line,
|
7832 |
|
|
(char ***) NULL, NULL);
|
7833 |
|
|
else
|
7834 |
|
|
sals = decode_line_1 (&string, funfirstline,
|
7835 |
|
|
(struct symtab *) NULL, 0, (char ***) NULL, NULL);
|
7836 |
|
|
if (*string)
|
7837 |
|
|
error (_("Junk at end of line specification: %s"), string);
|
7838 |
|
|
return sals;
|
7839 |
|
|
}
|
7840 |
|
|
|
7841 |
|
|
/* Create and insert a raw software breakpoint at PC. Return an
|
7842 |
|
|
identifier, which should be used to remove the breakpoint later.
|
7843 |
|
|
In general, places which call this should be using something on the
|
7844 |
|
|
breakpoint chain instead; this function should be eliminated
|
7845 |
|
|
someday. */
|
7846 |
|
|
|
7847 |
|
|
void *
|
7848 |
|
|
deprecated_insert_raw_breakpoint (CORE_ADDR pc)
|
7849 |
|
|
{
|
7850 |
|
|
struct bp_target_info *bp_tgt;
|
7851 |
|
|
|
7852 |
|
|
bp_tgt = xmalloc (sizeof (struct bp_target_info));
|
7853 |
|
|
memset (bp_tgt, 0, sizeof (struct bp_target_info));
|
7854 |
|
|
|
7855 |
|
|
bp_tgt->placed_address = pc;
|
7856 |
|
|
if (target_insert_breakpoint (bp_tgt) != 0)
|
7857 |
|
|
{
|
7858 |
|
|
/* Could not insert the breakpoint. */
|
7859 |
|
|
xfree (bp_tgt);
|
7860 |
|
|
return NULL;
|
7861 |
|
|
}
|
7862 |
|
|
|
7863 |
|
|
return bp_tgt;
|
7864 |
|
|
}
|
7865 |
|
|
|
7866 |
|
|
/* Remove a breakpoint BP inserted by deprecated_insert_raw_breakpoint. */
|
7867 |
|
|
|
7868 |
|
|
int
|
7869 |
|
|
deprecated_remove_raw_breakpoint (void *bp)
|
7870 |
|
|
{
|
7871 |
|
|
struct bp_target_info *bp_tgt = bp;
|
7872 |
|
|
int ret;
|
7873 |
|
|
|
7874 |
|
|
ret = target_remove_breakpoint (bp_tgt);
|
7875 |
|
|
xfree (bp_tgt);
|
7876 |
|
|
|
7877 |
|
|
return ret;
|
7878 |
|
|
}
|
7879 |
|
|
|
7880 |
|
|
/* One (or perhaps two) breakpoints used for software single stepping. */
|
7881 |
|
|
|
7882 |
|
|
static void *single_step_breakpoints[2];
|
7883 |
|
|
|
7884 |
|
|
/* Create and insert a breakpoint for software single step. */
|
7885 |
|
|
|
7886 |
|
|
void
|
7887 |
|
|
insert_single_step_breakpoint (CORE_ADDR next_pc)
|
7888 |
|
|
{
|
7889 |
|
|
void **bpt_p;
|
7890 |
|
|
|
7891 |
|
|
if (single_step_breakpoints[0] == NULL)
|
7892 |
|
|
bpt_p = &single_step_breakpoints[0];
|
7893 |
|
|
else
|
7894 |
|
|
{
|
7895 |
|
|
gdb_assert (single_step_breakpoints[1] == NULL);
|
7896 |
|
|
bpt_p = &single_step_breakpoints[1];
|
7897 |
|
|
}
|
7898 |
|
|
|
7899 |
|
|
/* NOTE drow/2006-04-11: A future improvement to this function would be
|
7900 |
|
|
to only create the breakpoints once, and actually put them on the
|
7901 |
|
|
breakpoint chain. That would let us use set_raw_breakpoint. We could
|
7902 |
|
|
adjust the addresses each time they were needed. Doing this requires
|
7903 |
|
|
corresponding changes elsewhere where single step breakpoints are
|
7904 |
|
|
handled, however. So, for now, we use this. */
|
7905 |
|
|
|
7906 |
|
|
*bpt_p = deprecated_insert_raw_breakpoint (next_pc);
|
7907 |
|
|
if (*bpt_p == NULL)
|
7908 |
|
|
error (_("Could not insert single-step breakpoint at 0x%s"),
|
7909 |
|
|
paddr_nz (next_pc));
|
7910 |
|
|
}
|
7911 |
|
|
|
7912 |
|
|
/* Remove and delete any breakpoints used for software single step. */
|
7913 |
|
|
|
7914 |
|
|
void
|
7915 |
|
|
remove_single_step_breakpoints (void)
|
7916 |
|
|
{
|
7917 |
|
|
gdb_assert (single_step_breakpoints[0] != NULL);
|
7918 |
|
|
|
7919 |
|
|
/* See insert_single_step_breakpoint for more about this deprecated
|
7920 |
|
|
call. */
|
7921 |
|
|
deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
|
7922 |
|
|
single_step_breakpoints[0] = NULL;
|
7923 |
|
|
|
7924 |
|
|
if (single_step_breakpoints[1] != NULL)
|
7925 |
|
|
{
|
7926 |
|
|
deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
|
7927 |
|
|
single_step_breakpoints[1] = NULL;
|
7928 |
|
|
}
|
7929 |
|
|
}
|
7930 |
|
|
|
7931 |
|
|
/* Check whether a software single-step breakpoint is inserted at PC. */
|
7932 |
|
|
|
7933 |
|
|
static int
|
7934 |
|
|
single_step_breakpoint_inserted_here_p (CORE_ADDR pc)
|
7935 |
|
|
{
|
7936 |
|
|
int i;
|
7937 |
|
|
|
7938 |
|
|
for (i = 0; i < 2; i++)
|
7939 |
|
|
{
|
7940 |
|
|
struct bp_target_info *bp_tgt = single_step_breakpoints[i];
|
7941 |
|
|
if (bp_tgt && bp_tgt->placed_address == pc)
|
7942 |
|
|
return 1;
|
7943 |
|
|
}
|
7944 |
|
|
|
7945 |
|
|
return 0;
|
7946 |
|
|
}
|
7947 |
|
|
|
7948 |
|
|
|
7949 |
|
|
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
|
7950 |
|
|
It is defined as a macro to prevent duplication.
|
7951 |
|
|
COMMAND should be a string constant containing the name of the command. */
|
7952 |
|
|
#define BREAK_ARGS_HELP(command) \
|
7953 |
|
|
command" [LOCATION] [thread THREADNUM] [if CONDITION]\n\
|
7954 |
|
|
LOCATION may be a line number, function name, or \"*\" and an address.\n\
|
7955 |
|
|
If a line number is specified, break at start of code for that line.\n\
|
7956 |
|
|
If a function is specified, break at start of code for that function.\n\
|
7957 |
|
|
If an address is specified, break at that exact address.\n\
|
7958 |
|
|
With no LOCATION, uses current execution address of selected stack frame.\n\
|
7959 |
|
|
This is useful for breaking on return to a stack frame.\n\
|
7960 |
|
|
\n\
|
7961 |
|
|
THREADNUM is the number from \"info threads\".\n\
|
7962 |
|
|
CONDITION is a boolean expression.\n\
|
7963 |
|
|
\n\
|
7964 |
|
|
Multiple breakpoints at one place are permitted, and useful if conditional.\n\
|
7965 |
|
|
\n\
|
7966 |
|
|
Do \"help breakpoints\" for info on other commands dealing with breakpoints."
|
7967 |
|
|
|
7968 |
|
|
void
|
7969 |
|
|
_initialize_breakpoint (void)
|
7970 |
|
|
{
|
7971 |
|
|
static struct cmd_list_element *breakpoint_set_cmdlist;
|
7972 |
|
|
static struct cmd_list_element *breakpoint_show_cmdlist;
|
7973 |
|
|
struct cmd_list_element *c;
|
7974 |
|
|
|
7975 |
|
|
observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
|
7976 |
|
|
|
7977 |
|
|
breakpoint_chain = 0;
|
7978 |
|
|
/* Don't bother to call set_breakpoint_count. $bpnum isn't useful
|
7979 |
|
|
before a breakpoint is set. */
|
7980 |
|
|
breakpoint_count = 0;
|
7981 |
|
|
|
7982 |
|
|
add_com ("ignore", class_breakpoint, ignore_command, _("\
|
7983 |
|
|
Set ignore-count of breakpoint number N to COUNT.\n\
|
7984 |
|
|
Usage is `ignore N COUNT'."));
|
7985 |
|
|
if (xdb_commands)
|
7986 |
|
|
add_com_alias ("bc", "ignore", class_breakpoint, 1);
|
7987 |
|
|
|
7988 |
|
|
add_com ("commands", class_breakpoint, commands_command, _("\
|
7989 |
|
|
Set commands to be executed when a breakpoint is hit.\n\
|
7990 |
|
|
Give breakpoint number as argument after \"commands\".\n\
|
7991 |
|
|
With no argument, the targeted breakpoint is the last one set.\n\
|
7992 |
|
|
The commands themselves follow starting on the next line.\n\
|
7993 |
|
|
Type a line containing \"end\" to indicate the end of them.\n\
|
7994 |
|
|
Give \"silent\" as the first line to make the breakpoint silent;\n\
|
7995 |
|
|
then no output is printed when it is hit, except what the commands print."));
|
7996 |
|
|
|
7997 |
|
|
add_com ("condition", class_breakpoint, condition_command, _("\
|
7998 |
|
|
Specify breakpoint number N to break only if COND is true.\n\
|
7999 |
|
|
Usage is `condition N COND', where N is an integer and COND is an\n\
|
8000 |
|
|
expression to be evaluated whenever breakpoint N is reached."));
|
8001 |
|
|
|
8002 |
|
|
c = add_com ("tbreak", class_breakpoint, tbreak_command, _("\
|
8003 |
|
|
Set a temporary breakpoint.\n\
|
8004 |
|
|
Like \"break\" except the breakpoint is only temporary,\n\
|
8005 |
|
|
so it will be deleted when hit. Equivalent to \"break\" followed\n\
|
8006 |
|
|
by using \"enable delete\" on the breakpoint number.\n\
|
8007 |
|
|
\n"
|
8008 |
|
|
BREAK_ARGS_HELP ("tbreak")));
|
8009 |
|
|
set_cmd_completer (c, location_completer);
|
8010 |
|
|
|
8011 |
|
|
c = add_com ("hbreak", class_breakpoint, hbreak_command, _("\
|
8012 |
|
|
Set a hardware assisted breakpoint.\n\
|
8013 |
|
|
Like \"break\" except the breakpoint requires hardware support,\n\
|
8014 |
|
|
some target hardware may not have this support.\n\
|
8015 |
|
|
\n"
|
8016 |
|
|
BREAK_ARGS_HELP ("hbreak")));
|
8017 |
|
|
set_cmd_completer (c, location_completer);
|
8018 |
|
|
|
8019 |
|
|
c = add_com ("thbreak", class_breakpoint, thbreak_command, _("\
|
8020 |
|
|
Set a temporary hardware assisted breakpoint.\n\
|
8021 |
|
|
Like \"hbreak\" except the breakpoint is only temporary,\n\
|
8022 |
|
|
so it will be deleted when hit.\n\
|
8023 |
|
|
\n"
|
8024 |
|
|
BREAK_ARGS_HELP ("thbreak")));
|
8025 |
|
|
set_cmd_completer (c, location_completer);
|
8026 |
|
|
|
8027 |
|
|
add_prefix_cmd ("enable", class_breakpoint, enable_command, _("\
|
8028 |
|
|
Enable some breakpoints.\n\
|
8029 |
|
|
Give breakpoint numbers (separated by spaces) as arguments.\n\
|
8030 |
|
|
With no subcommand, breakpoints are enabled until you command otherwise.\n\
|
8031 |
|
|
This is used to cancel the effect of the \"disable\" command.\n\
|
8032 |
|
|
With a subcommand you can enable temporarily."),
|
8033 |
|
|
&enablelist, "enable ", 1, &cmdlist);
|
8034 |
|
|
if (xdb_commands)
|
8035 |
|
|
add_com ("ab", class_breakpoint, enable_command, _("\
|
8036 |
|
|
Enable some breakpoints.\n\
|
8037 |
|
|
Give breakpoint numbers (separated by spaces) as arguments.\n\
|
8038 |
|
|
With no subcommand, breakpoints are enabled until you command otherwise.\n\
|
8039 |
|
|
This is used to cancel the effect of the \"disable\" command.\n\
|
8040 |
|
|
With a subcommand you can enable temporarily."));
|
8041 |
|
|
|
8042 |
|
|
add_com_alias ("en", "enable", class_breakpoint, 1);
|
8043 |
|
|
|
8044 |
|
|
add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command, _("\
|
8045 |
|
|
Enable some breakpoints.\n\
|
8046 |
|
|
Give breakpoint numbers (separated by spaces) as arguments.\n\
|
8047 |
|
|
This is used to cancel the effect of the \"disable\" command.\n\
|
8048 |
|
|
May be abbreviated to simply \"enable\".\n"),
|
8049 |
|
|
&enablebreaklist, "enable breakpoints ", 1, &enablelist);
|
8050 |
|
|
|
8051 |
|
|
add_cmd ("once", no_class, enable_once_command, _("\
|
8052 |
|
|
Enable breakpoints for one hit. Give breakpoint numbers.\n\
|
8053 |
|
|
If a breakpoint is hit while enabled in this fashion, it becomes disabled."),
|
8054 |
|
|
&enablebreaklist);
|
8055 |
|
|
|
8056 |
|
|
add_cmd ("delete", no_class, enable_delete_command, _("\
|
8057 |
|
|
Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
|
8058 |
|
|
If a breakpoint is hit while enabled in this fashion, it is deleted."),
|
8059 |
|
|
&enablebreaklist);
|
8060 |
|
|
|
8061 |
|
|
add_cmd ("delete", no_class, enable_delete_command, _("\
|
8062 |
|
|
Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
|
8063 |
|
|
If a breakpoint is hit while enabled in this fashion, it is deleted."),
|
8064 |
|
|
&enablelist);
|
8065 |
|
|
|
8066 |
|
|
add_cmd ("once", no_class, enable_once_command, _("\
|
8067 |
|
|
Enable breakpoints for one hit. Give breakpoint numbers.\n\
|
8068 |
|
|
If a breakpoint is hit while enabled in this fashion, it becomes disabled."),
|
8069 |
|
|
&enablelist);
|
8070 |
|
|
|
8071 |
|
|
add_prefix_cmd ("disable", class_breakpoint, disable_command, _("\
|
8072 |
|
|
Disable some breakpoints.\n\
|
8073 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8074 |
|
|
To disable all breakpoints, give no argument.\n\
|
8075 |
|
|
A disabled breakpoint is not forgotten, but has no effect until reenabled."),
|
8076 |
|
|
&disablelist, "disable ", 1, &cmdlist);
|
8077 |
|
|
add_com_alias ("dis", "disable", class_breakpoint, 1);
|
8078 |
|
|
add_com_alias ("disa", "disable", class_breakpoint, 1);
|
8079 |
|
|
if (xdb_commands)
|
8080 |
|
|
add_com ("sb", class_breakpoint, disable_command, _("\
|
8081 |
|
|
Disable some breakpoints.\n\
|
8082 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8083 |
|
|
To disable all breakpoints, give no argument.\n\
|
8084 |
|
|
A disabled breakpoint is not forgotten, but has no effect until reenabled."));
|
8085 |
|
|
|
8086 |
|
|
add_cmd ("breakpoints", class_alias, disable_command, _("\
|
8087 |
|
|
Disable some breakpoints.\n\
|
8088 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8089 |
|
|
To disable all breakpoints, give no argument.\n\
|
8090 |
|
|
A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
|
8091 |
|
|
This command may be abbreviated \"disable\"."),
|
8092 |
|
|
&disablelist);
|
8093 |
|
|
|
8094 |
|
|
add_prefix_cmd ("delete", class_breakpoint, delete_command, _("\
|
8095 |
|
|
Delete some breakpoints or auto-display expressions.\n\
|
8096 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8097 |
|
|
To delete all breakpoints, give no argument.\n\
|
8098 |
|
|
\n\
|
8099 |
|
|
Also a prefix command for deletion of other GDB objects.\n\
|
8100 |
|
|
The \"unset\" command is also an alias for \"delete\"."),
|
8101 |
|
|
&deletelist, "delete ", 1, &cmdlist);
|
8102 |
|
|
add_com_alias ("d", "delete", class_breakpoint, 1);
|
8103 |
|
|
add_com_alias ("del", "delete", class_breakpoint, 1);
|
8104 |
|
|
if (xdb_commands)
|
8105 |
|
|
add_com ("db", class_breakpoint, delete_command, _("\
|
8106 |
|
|
Delete some breakpoints.\n\
|
8107 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8108 |
|
|
To delete all breakpoints, give no argument.\n"));
|
8109 |
|
|
|
8110 |
|
|
add_cmd ("breakpoints", class_alias, delete_command, _("\
|
8111 |
|
|
Delete some breakpoints or auto-display expressions.\n\
|
8112 |
|
|
Arguments are breakpoint numbers with spaces in between.\n\
|
8113 |
|
|
To delete all breakpoints, give no argument.\n\
|
8114 |
|
|
This command may be abbreviated \"delete\"."),
|
8115 |
|
|
&deletelist);
|
8116 |
|
|
|
8117 |
|
|
add_com ("clear", class_breakpoint, clear_command, _("\
|
8118 |
|
|
Clear breakpoint at specified line or function.\n\
|
8119 |
|
|
Argument may be line number, function name, or \"*\" and an address.\n\
|
8120 |
|
|
If line number is specified, all breakpoints in that line are cleared.\n\
|
8121 |
|
|
If function is specified, breakpoints at beginning of function are cleared.\n\
|
8122 |
|
|
If an address is specified, breakpoints at that address are cleared.\n\
|
8123 |
|
|
\n\
|
8124 |
|
|
With no argument, clears all breakpoints in the line that the selected frame\n\
|
8125 |
|
|
is executing in.\n\
|
8126 |
|
|
\n\
|
8127 |
|
|
See also the \"delete\" command which clears breakpoints by number."));
|
8128 |
|
|
|
8129 |
|
|
c = add_com ("break", class_breakpoint, break_command, _("\
|
8130 |
|
|
Set breakpoint at specified line or function.\n"
|
8131 |
|
|
BREAK_ARGS_HELP ("break")));
|
8132 |
|
|
set_cmd_completer (c, location_completer);
|
8133 |
|
|
|
8134 |
|
|
add_com_alias ("b", "break", class_run, 1);
|
8135 |
|
|
add_com_alias ("br", "break", class_run, 1);
|
8136 |
|
|
add_com_alias ("bre", "break", class_run, 1);
|
8137 |
|
|
add_com_alias ("brea", "break", class_run, 1);
|
8138 |
|
|
|
8139 |
|
|
if (xdb_commands)
|
8140 |
|
|
{
|
8141 |
|
|
add_com_alias ("ba", "break", class_breakpoint, 1);
|
8142 |
|
|
add_com_alias ("bu", "ubreak", class_breakpoint, 1);
|
8143 |
|
|
}
|
8144 |
|
|
|
8145 |
|
|
if (dbx_commands)
|
8146 |
|
|
{
|
8147 |
|
|
add_abbrev_prefix_cmd ("stop", class_breakpoint, stop_command, _("\
|
8148 |
|
|
Break in function/address or break at a line in the current file."),
|
8149 |
|
|
&stoplist, "stop ", 1, &cmdlist);
|
8150 |
|
|
add_cmd ("in", class_breakpoint, stopin_command,
|
8151 |
|
|
_("Break in function or address."), &stoplist);
|
8152 |
|
|
add_cmd ("at", class_breakpoint, stopat_command,
|
8153 |
|
|
_("Break at a line in the current file."), &stoplist);
|
8154 |
|
|
add_com ("status", class_info, breakpoints_info, _("\
|
8155 |
|
|
Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
|
8156 |
|
|
The \"Type\" column indicates one of:\n\
|
8157 |
|
|
\tbreakpoint - normal breakpoint\n\
|
8158 |
|
|
\twatchpoint - watchpoint\n\
|
8159 |
|
|
The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
|
8160 |
|
|
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
|
8161 |
|
|
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
|
8162 |
|
|
address and file/line number respectively.\n\
|
8163 |
|
|
\n\
|
8164 |
|
|
Convenience variable \"$_\" and default examine address for \"x\"\n\
|
8165 |
|
|
are set to the address of the last breakpoint listed unless the command\n\
|
8166 |
|
|
is prefixed with \"server \".\n\n\
|
8167 |
|
|
Convenience variable \"$bpnum\" contains the number of the last\n\
|
8168 |
|
|
breakpoint set."));
|
8169 |
|
|
}
|
8170 |
|
|
|
8171 |
|
|
add_info ("breakpoints", breakpoints_info, _("\
|
8172 |
|
|
Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
|
8173 |
|
|
The \"Type\" column indicates one of:\n\
|
8174 |
|
|
\tbreakpoint - normal breakpoint\n\
|
8175 |
|
|
\twatchpoint - watchpoint\n\
|
8176 |
|
|
The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
|
8177 |
|
|
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
|
8178 |
|
|
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
|
8179 |
|
|
address and file/line number respectively.\n\
|
8180 |
|
|
\n\
|
8181 |
|
|
Convenience variable \"$_\" and default examine address for \"x\"\n\
|
8182 |
|
|
are set to the address of the last breakpoint listed unless the command\n\
|
8183 |
|
|
is prefixed with \"server \".\n\n\
|
8184 |
|
|
Convenience variable \"$bpnum\" contains the number of the last\n\
|
8185 |
|
|
breakpoint set."));
|
8186 |
|
|
|
8187 |
|
|
if (xdb_commands)
|
8188 |
|
|
add_com ("lb", class_breakpoint, breakpoints_info, _("\
|
8189 |
|
|
Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
|
8190 |
|
|
The \"Type\" column indicates one of:\n\
|
8191 |
|
|
\tbreakpoint - normal breakpoint\n\
|
8192 |
|
|
\twatchpoint - watchpoint\n\
|
8193 |
|
|
The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
|
8194 |
|
|
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
|
8195 |
|
|
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
|
8196 |
|
|
address and file/line number respectively.\n\
|
8197 |
|
|
\n\
|
8198 |
|
|
Convenience variable \"$_\" and default examine address for \"x\"\n\
|
8199 |
|
|
are set to the address of the last breakpoint listed unless the command\n\
|
8200 |
|
|
is prefixed with \"server \".\n\n\
|
8201 |
|
|
Convenience variable \"$bpnum\" contains the number of the last\n\
|
8202 |
|
|
breakpoint set."));
|
8203 |
|
|
|
8204 |
|
|
add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, _("\
|
8205 |
|
|
Status of all breakpoints, or breakpoint number NUMBER.\n\
|
8206 |
|
|
The \"Type\" column indicates one of:\n\
|
8207 |
|
|
\tbreakpoint - normal breakpoint\n\
|
8208 |
|
|
\twatchpoint - watchpoint\n\
|
8209 |
|
|
\tlongjmp - internal breakpoint used to step through longjmp()\n\
|
8210 |
|
|
\tlongjmp resume - internal breakpoint at the target of longjmp()\n\
|
8211 |
|
|
\tuntil - internal breakpoint used by the \"until\" command\n\
|
8212 |
|
|
\tfinish - internal breakpoint used by the \"finish\" command\n\
|
8213 |
|
|
The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
|
8214 |
|
|
the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
|
8215 |
|
|
breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
|
8216 |
|
|
address and file/line number respectively.\n\
|
8217 |
|
|
\n\
|
8218 |
|
|
Convenience variable \"$_\" and default examine address for \"x\"\n\
|
8219 |
|
|
are set to the address of the last breakpoint listed unless the command\n\
|
8220 |
|
|
is prefixed with \"server \".\n\n\
|
8221 |
|
|
Convenience variable \"$bpnum\" contains the number of the last\n\
|
8222 |
|
|
breakpoint set."),
|
8223 |
|
|
&maintenanceinfolist);
|
8224 |
|
|
|
8225 |
|
|
add_com ("catch", class_breakpoint, catch_command, _("\
|
8226 |
|
|
Set catchpoints to catch events.\n\
|
8227 |
|
|
Raised signals may be caught:\n\
|
8228 |
|
|
\tcatch signal - all signals\n\
|
8229 |
|
|
\tcatch signal <signame> - a particular signal\n\
|
8230 |
|
|
Raised exceptions may be caught:\n\
|
8231 |
|
|
\tcatch throw - all exceptions, when thrown\n\
|
8232 |
|
|
\tcatch throw <exceptname> - a particular exception, when thrown\n\
|
8233 |
|
|
\tcatch catch - all exceptions, when caught\n\
|
8234 |
|
|
\tcatch catch <exceptname> - a particular exception, when caught\n\
|
8235 |
|
|
Thread or process events may be caught:\n\
|
8236 |
|
|
\tcatch thread_start - any threads, just after creation\n\
|
8237 |
|
|
\tcatch thread_exit - any threads, just before expiration\n\
|
8238 |
|
|
\tcatch thread_join - any threads, just after joins\n\
|
8239 |
|
|
Process events may be caught:\n\
|
8240 |
|
|
\tcatch start - any processes, just after creation\n\
|
8241 |
|
|
\tcatch exit - any processes, just before expiration\n\
|
8242 |
|
|
\tcatch fork - calls to fork()\n\
|
8243 |
|
|
\tcatch vfork - calls to vfork()\n\
|
8244 |
|
|
\tcatch exec - calls to exec()\n\
|
8245 |
|
|
Dynamically-linked library events may be caught:\n\
|
8246 |
|
|
\tcatch load - loads of any library\n\
|
8247 |
|
|
\tcatch load <libname> - loads of a particular library\n\
|
8248 |
|
|
\tcatch unload - unloads of any library\n\
|
8249 |
|
|
\tcatch unload <libname> - unloads of a particular library\n\
|
8250 |
|
|
The act of your program's execution stopping may also be caught:\n\
|
8251 |
|
|
\tcatch stop\n\n\
|
8252 |
|
|
C++ exceptions may be caught:\n\
|
8253 |
|
|
\tcatch throw - all exceptions, when thrown\n\
|
8254 |
|
|
\tcatch catch - all exceptions, when caught\n\
|
8255 |
|
|
Ada exceptions may be caught:\n\
|
8256 |
|
|
\tcatch exception - all exceptions, when raised\n\
|
8257 |
|
|
\tcatch exception <name> - a particular exception, when raised\n\
|
8258 |
|
|
\tcatch exception unhandled - all unhandled exceptions, when raised\n\
|
8259 |
|
|
\tcatch assert - all failed assertions, when raised\n\
|
8260 |
|
|
\n\
|
8261 |
|
|
Do \"help set follow-fork-mode\" for info on debugging your program\n\
|
8262 |
|
|
after a fork or vfork is caught.\n\n\
|
8263 |
|
|
Do \"help breakpoints\" for info on other commands dealing with breakpoints."));
|
8264 |
|
|
|
8265 |
|
|
add_com ("tcatch", class_breakpoint, tcatch_command, _("\
|
8266 |
|
|
Set temporary catchpoints to catch events.\n\
|
8267 |
|
|
Args like \"catch\" command.\n\
|
8268 |
|
|
Like \"catch\" except the catchpoint is only temporary,\n\
|
8269 |
|
|
so it will be deleted when hit. Equivalent to \"catch\" followed\n\
|
8270 |
|
|
by using \"enable delete\" on the catchpoint number."));
|
8271 |
|
|
|
8272 |
|
|
c = add_com ("watch", class_breakpoint, watch_command, _("\
|
8273 |
|
|
Set a watchpoint for an expression.\n\
|
8274 |
|
|
A watchpoint stops execution of your program whenever the value of\n\
|
8275 |
|
|
an expression changes."));
|
8276 |
|
|
set_cmd_completer (c, location_completer);
|
8277 |
|
|
|
8278 |
|
|
c = add_com ("rwatch", class_breakpoint, rwatch_command, _("\
|
8279 |
|
|
Set a read watchpoint for an expression.\n\
|
8280 |
|
|
A watchpoint stops execution of your program whenever the value of\n\
|
8281 |
|
|
an expression is read."));
|
8282 |
|
|
set_cmd_completer (c, location_completer);
|
8283 |
|
|
|
8284 |
|
|
c = add_com ("awatch", class_breakpoint, awatch_command, _("\
|
8285 |
|
|
Set a watchpoint for an expression.\n\
|
8286 |
|
|
A watchpoint stops execution of your program whenever the value of\n\
|
8287 |
|
|
an expression is either read or written."));
|
8288 |
|
|
set_cmd_completer (c, location_completer);
|
8289 |
|
|
|
8290 |
|
|
add_info ("watchpoints", breakpoints_info,
|
8291 |
|
|
_("Synonym for ``info breakpoints''."));
|
8292 |
|
|
|
8293 |
|
|
|
8294 |
|
|
/* XXX: cagney/2005-02-23: This should be a boolean, and should
|
8295 |
|
|
respond to changes - contrary to the description. */
|
8296 |
|
|
add_setshow_zinteger_cmd ("can-use-hw-watchpoints", class_support,
|
8297 |
|
|
&can_use_hw_watchpoints, _("\
|
8298 |
|
|
Set debugger's willingness to use watchpoint hardware."), _("\
|
8299 |
|
|
Show debugger's willingness to use watchpoint hardware."), _("\
|
8300 |
|
|
If zero, gdb will not use hardware for new watchpoints, even if\n\
|
8301 |
|
|
such is available. (However, any hardware watchpoints that were\n\
|
8302 |
|
|
created before setting this to nonzero, will continue to use watchpoint\n\
|
8303 |
|
|
hardware.)"),
|
8304 |
|
|
NULL,
|
8305 |
|
|
show_can_use_hw_watchpoints,
|
8306 |
|
|
&setlist, &showlist);
|
8307 |
|
|
|
8308 |
|
|
can_use_hw_watchpoints = 1;
|
8309 |
|
|
|
8310 |
|
|
add_prefix_cmd ("breakpoint", class_maintenance, set_breakpoint_cmd, _("\
|
8311 |
|
|
Breakpoint specific settings\n\
|
8312 |
|
|
Configure various breakpoint-specific variables such as\n\
|
8313 |
|
|
pending breakpoint behavior"),
|
8314 |
|
|
&breakpoint_set_cmdlist, "set breakpoint ",
|
8315 |
|
|
0/*allow-unknown*/, &setlist);
|
8316 |
|
|
add_prefix_cmd ("breakpoint", class_maintenance, show_breakpoint_cmd, _("\
|
8317 |
|
|
Breakpoint specific settings\n\
|
8318 |
|
|
Configure various breakpoint-specific variables such as\n\
|
8319 |
|
|
pending breakpoint behavior"),
|
8320 |
|
|
&breakpoint_show_cmdlist, "show breakpoint ",
|
8321 |
|
|
0/*allow-unknown*/, &showlist);
|
8322 |
|
|
|
8323 |
|
|
add_setshow_auto_boolean_cmd ("pending", no_class,
|
8324 |
|
|
&pending_break_support, _("\
|
8325 |
|
|
Set debugger's behavior regarding pending breakpoints."), _("\
|
8326 |
|
|
Show debugger's behavior regarding pending breakpoints."), _("\
|
8327 |
|
|
If on, an unrecognized breakpoint location will cause gdb to create a\n\
|
8328 |
|
|
pending breakpoint. If off, an unrecognized breakpoint location results in\n\
|
8329 |
|
|
an error. If auto, an unrecognized breakpoint location results in a\n\
|
8330 |
|
|
user-query to see if a pending breakpoint should be created."),
|
8331 |
|
|
NULL,
|
8332 |
|
|
show_pending_break_support,
|
8333 |
|
|
&breakpoint_set_cmdlist,
|
8334 |
|
|
&breakpoint_show_cmdlist);
|
8335 |
|
|
|
8336 |
|
|
pending_break_support = AUTO_BOOLEAN_AUTO;
|
8337 |
|
|
|
8338 |
|
|
add_setshow_boolean_cmd ("auto-hw", no_class,
|
8339 |
|
|
&automatic_hardware_breakpoints, _("\
|
8340 |
|
|
Set automatic usage of hardware breakpoints."), _("\
|
8341 |
|
|
Show automatic usage of hardware breakpoints."), _("\
|
8342 |
|
|
If set, the debugger will automatically use hardware breakpoints for\n\
|
8343 |
|
|
breakpoints set with \"break\" but falling in read-only memory. If not set,\n\
|
8344 |
|
|
a warning will be emitted for such breakpoints."),
|
8345 |
|
|
NULL,
|
8346 |
|
|
show_automatic_hardware_breakpoints,
|
8347 |
|
|
&breakpoint_set_cmdlist,
|
8348 |
|
|
&breakpoint_show_cmdlist);
|
8349 |
|
|
|
8350 |
|
|
automatic_hardware_breakpoints = 1;
|
8351 |
|
|
}
|