1 /* Everything about breakpoints, for GDB.
3 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
5 Free Software Foundation, Inc.
7 This file is part of GDB.
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 2 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
28 #include "breakpoint.h"
30 #include "expression.h"
36 #include "gdbthread.h"
39 #include "gdb_string.h"
46 #include "completer.h"
49 #include "cli/cli-script.h"
50 #include "gdb_assert.h"
55 #include "exceptions.h"
57 #include "gdb-events.h"
59 /* Prototypes for local functions. */
61 static void until_break_command_continuation (struct continuation_arg
*arg
);
63 static void catch_command_1 (char *, int, int);
65 static void enable_delete_command (char *, int);
67 static void enable_delete_breakpoint (struct breakpoint
*);
69 static void enable_once_command (char *, int);
71 static void enable_once_breakpoint (struct breakpoint
*);
73 static void disable_command (char *, int);
75 static void enable_command (char *, int);
77 static void map_breakpoint_numbers (char *, void (*)(struct breakpoint
*));
79 static void ignore_command (char *, int);
81 static int breakpoint_re_set_one (void *);
83 static void clear_command (char *, int);
85 static void catch_command (char *, int);
87 static void watch_command (char *, int);
89 static int can_use_hardware_watchpoint (struct value
*);
91 static int break_command_1 (char *, int, int, struct breakpoint
*);
93 static void mention (struct breakpoint
*);
95 struct breakpoint
*set_raw_breakpoint (struct symtab_and_line
, enum bptype
);
97 static void check_duplicates (struct breakpoint
*);
99 static void breakpoint_adjustment_warning (CORE_ADDR
, CORE_ADDR
, int, int);
101 static CORE_ADDR
adjust_breakpoint_address (CORE_ADDR bpaddr
,
104 static void describe_other_breakpoints (CORE_ADDR
, asection
*);
106 static void breakpoints_info (char *, int);
108 static void breakpoint_1 (int, int);
110 static bpstat
bpstat_alloc (struct breakpoint
*, bpstat
);
112 static int breakpoint_cond_eval (void *);
114 static void cleanup_executing_breakpoints (void *);
116 static void commands_command (char *, int);
118 static void condition_command (char *, int);
120 static int get_number_trailer (char **, int);
122 void set_breakpoint_count (int);
131 static int remove_breakpoint (struct bp_location
*, insertion_state_t
);
133 static enum print_stop_action
print_it_typical (bpstat
);
135 static enum print_stop_action
print_bp_stop_message (bpstat bs
);
139 enum exception_event_kind kind
;
142 args_for_catchpoint_enable
;
144 static int watchpoint_check (void *);
146 static int cover_target_enable_exception_callback (void *);
148 static void maintenance_info_breakpoints (char *, int);
150 static void create_longjmp_breakpoint (char *);
152 static void create_overlay_event_breakpoint (char *);
154 static int hw_breakpoint_used_count (void);
156 static int hw_watchpoint_used_count (enum bptype
, int *);
158 static void hbreak_command (char *, int);
160 static void thbreak_command (char *, int);
162 static void watch_command_1 (char *, int, int);
164 static void rwatch_command (char *, int);
166 static void awatch_command (char *, int);
168 static void do_enable_breakpoint (struct breakpoint
*, enum bpdisp
);
170 static void solib_load_unload_1 (char *hookname
,
173 char *cond_string
, enum bptype bp_kind
);
175 static void create_fork_vfork_event_catchpoint (int tempflag
,
177 enum bptype bp_kind
);
179 static void stop_command (char *arg
, int from_tty
);
181 static void stopin_command (char *arg
, int from_tty
);
183 static void stopat_command (char *arg
, int from_tty
);
185 static char *ep_find_event_name_end (char *arg
);
187 static char *ep_parse_optional_if_clause (char **arg
);
189 static char *ep_parse_optional_filename (char **arg
);
191 static void create_exception_catchpoint (int tempflag
, char *cond_string
,
192 enum exception_event_kind ex_event
,
193 struct symtab_and_line
*sal
);
195 static void catch_exception_command_1 (enum exception_event_kind ex_event
,
196 char *arg
, int tempflag
, int from_tty
);
198 static void tcatch_command (char *arg
, int from_tty
);
200 static void ep_skip_leading_whitespace (char **s
);
202 /* Prototypes for exported functions. */
204 /* If FALSE, gdb will not use hardware support for watchpoints, even
205 if such is available. */
206 static int can_use_hw_watchpoints
;
209 show_can_use_hw_watchpoints (struct ui_file
*file
, int from_tty
,
210 struct cmd_list_element
*c
,
213 fprintf_filtered (file
, _("\
214 Debugger's willingness to use watchpoint hardware is %s.\n"),
218 /* If AUTO_BOOLEAN_FALSE, gdb will not attempt to create pending breakpoints.
219 If AUTO_BOOLEAN_TRUE, gdb will automatically create pending breakpoints
220 for unrecognized breakpoint locations.
221 If AUTO_BOOLEAN_AUTO, gdb will query when breakpoints are unrecognized. */
222 static enum auto_boolean pending_break_support
;
224 show_pending_break_support (struct ui_file
*file
, int from_tty
,
225 struct cmd_list_element
*c
,
228 fprintf_filtered (file
, _("\
229 Debugger's behavior regarding pending breakpoints is %s.\n"),
233 void _initialize_breakpoint (void);
235 extern int addressprint
; /* Print machine addresses? */
237 /* Are we executing breakpoint commands? */
238 static int executing_breakpoint_commands
;
240 /* Are overlay event breakpoints enabled? */
241 static int overlay_events_enabled
;
243 /* Walk the following statement or block through all breakpoints.
244 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
247 #define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
249 #define ALL_BREAKPOINTS_SAFE(B,TMP) \
250 for (B = breakpoint_chain; \
251 B ? (TMP=B->next, 1): 0; \
254 /* Similar iterators for the low-level breakpoints. */
256 #define ALL_BP_LOCATIONS(B) for (B = bp_location_chain; B; B = B->next)
258 #define ALL_BP_LOCATIONS_SAFE(B,TMP) \
259 for (B = bp_location_chain; \
260 B ? (TMP=B->next, 1): 0; \
263 /* True if breakpoint hit counts should be displayed in breakpoint info. */
265 int show_breakpoint_hit_counts
= 1;
267 /* Chains of all breakpoints defined. */
269 struct breakpoint
*breakpoint_chain
;
271 struct bp_location
*bp_location_chain
;
273 /* Number of last breakpoint made. */
275 int breakpoint_count
;
277 /* Pointer to current exception event record */
278 static struct exception_event_record
*current_exception_event
;
280 /* Indicator of whether exception catchpoints should be nuked between
281 runs of a program. */
282 int deprecated_exception_catchpoints_are_fragile
= 0;
284 /* Indicator of when exception catchpoints set-up should be
285 reinitialized -- e.g. when program is re-run. */
286 int deprecated_exception_support_initialized
= 0;
288 /* This function returns a pointer to the string representation of the
289 pathname of the dynamically-linked library that has just been
292 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
293 or undefined results are guaranteed.
295 This string's contents are only valid immediately after the
296 inferior has stopped in the dynamic linker hook, and becomes
297 invalid as soon as the inferior is continued. Clients should make
298 a copy of this string if they wish to continue the inferior and
299 then access the string. */
301 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
302 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
305 /* This function returns a pointer to the string representation of the
306 pathname of the dynamically-linked library that has just been
309 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
310 TRUE, or undefined results are guaranteed.
312 This string's contents are only valid immediately after the
313 inferior has stopped in the dynamic linker hook, and becomes
314 invalid as soon as the inferior is continued. Clients should make
315 a copy of this string if they wish to continue the inferior and
316 then access the string. */
318 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
319 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
322 /* This function is called by the "catch load" command. It allows the
323 debugger to be notified by the dynamic linker when a specified
324 library file (or any library file, if filename is NULL) is loaded. */
326 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
327 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
328 error (_("catch of library loads not yet implemented on this platform"))
331 /* This function is called by the "catch unload" command. It allows
332 the debugger to be notified by the dynamic linker when a specified
333 library file (or any library file, if filename is NULL) is
336 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
337 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid, tempflag, filename, cond_string) \
338 error (_("catch of library unloads not yet implemented on this platform"))
341 /* Return whether a breakpoint is an active enabled breakpoint. */
343 breakpoint_enabled (struct breakpoint
*b
)
345 return (b
->enable_state
== bp_enabled
&& !b
->pending
);
348 /* Set breakpoint count to NUM. */
351 set_breakpoint_count (int num
)
353 breakpoint_count
= num
;
354 set_internalvar (lookup_internalvar ("bpnum"),
355 value_from_longest (builtin_type_int
, (LONGEST
) num
));
358 /* Used in run_command to zero the hit count when a new run starts. */
361 clear_breakpoint_hit_counts (void)
363 struct breakpoint
*b
;
369 /* Default address, symtab and line to put a breakpoint at
370 for "break" command with no arg.
371 if default_breakpoint_valid is zero, the other three are
372 not valid, and "break" with no arg is an error.
374 This set by print_stack_frame, which calls set_default_breakpoint. */
376 int default_breakpoint_valid
;
377 CORE_ADDR default_breakpoint_address
;
378 struct symtab
*default_breakpoint_symtab
;
379 int default_breakpoint_line
;
381 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
382 Advance *PP after the string and any trailing whitespace.
384 Currently the string can either be a number or "$" followed by the name
385 of a convenience variable. Making it an expression wouldn't work well
386 for map_breakpoint_numbers (e.g. "4 + 5 + 6").
388 TRAILER is a character which can be found after the number; most
389 commonly this is `-'. If you don't want a trailer, use \0. */
391 get_number_trailer (char **pp
, int trailer
)
393 int retval
= 0; /* default */
397 /* Empty line means refer to the last breakpoint. */
398 return breakpoint_count
;
401 /* Make a copy of the name, so we can null-terminate it
402 to pass to lookup_internalvar(). */
407 while (isalnum (*p
) || *p
== '_')
409 varname
= (char *) alloca (p
- start
+ 1);
410 strncpy (varname
, start
, p
- start
);
411 varname
[p
- start
] = '\0';
412 val
= value_of_internalvar (lookup_internalvar (varname
));
413 if (TYPE_CODE (value_type (val
)) == TYPE_CODE_INT
)
414 retval
= (int) value_as_long (val
);
417 printf_filtered (_("Convenience variable must have integer value.\n"));
425 while (*p
>= '0' && *p
<= '9')
428 /* There is no number here. (e.g. "cond a == b"). */
430 /* Skip non-numeric token */
431 while (*p
&& !isspace((int) *p
))
433 /* Return zero, which caller must interpret as error. */
439 if (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
441 /* Trailing junk: return 0 and let caller print error msg. */
442 while (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
453 /* Like get_number_trailer, but don't allow a trailer. */
455 get_number (char **pp
)
457 return get_number_trailer (pp
, '\0');
460 /* Parse a number or a range.
461 * A number will be of the form handled by get_number.
462 * A range will be of the form <number1> - <number2>, and
463 * will represent all the integers between number1 and number2,
466 * While processing a range, this fuction is called iteratively;
467 * At each call it will return the next value in the range.
469 * At the beginning of parsing a range, the char pointer PP will
470 * be advanced past <number1> and left pointing at the '-' token.
471 * Subsequent calls will not advance the pointer until the range
472 * is completed. The call that completes the range will advance
473 * pointer PP past <number2>.
477 get_number_or_range (char **pp
)
479 static int last_retval
, end_value
;
480 static char *end_ptr
;
481 static int in_range
= 0;
485 /* Default case: pp is pointing either to a solo number,
486 or to the first number of a range. */
487 last_retval
= get_number_trailer (pp
, '-');
492 /* This is the start of a range (<number1> - <number2>).
493 Skip the '-', parse and remember the second number,
494 and also remember the end of the final token. */
498 while (isspace ((int) *end_ptr
))
499 end_ptr
++; /* skip white space */
500 end_value
= get_number (temp
);
501 if (end_value
< last_retval
)
503 error (_("inverted range"));
505 else if (end_value
== last_retval
)
507 /* degenerate range (number1 == number2). Advance the
508 token pointer so that the range will be treated as a
517 error (_("negative value"));
520 /* pp points to the '-' that betokens a range. All
521 number-parsing has already been done. Return the next
522 integer value (one greater than the saved previous value).
523 Do not advance the token pointer 'pp' until the end of range
526 if (++last_retval
== end_value
)
528 /* End of range reached; advance token pointer. */
538 /* condition N EXP -- set break condition of breakpoint N to EXP. */
541 condition_command (char *arg
, int from_tty
)
543 struct breakpoint
*b
;
548 error_no_arg (_("breakpoint number"));
551 bnum
= get_number (&p
);
553 error (_("Bad breakpoint argument: '%s'"), arg
);
556 if (b
->number
== bnum
)
563 if (b
->cond_string
!= NULL
)
564 xfree (b
->cond_string
);
569 b
->cond_string
= NULL
;
571 printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum
);
576 /* I don't know if it matters whether this is the string the user
577 typed in or the decompiled expression. */
578 b
->cond_string
= savestring (arg
, strlen (arg
));
581 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->loc
->address
), 0);
583 error (_("Junk at end of expression"));
586 breakpoints_changed ();
587 breakpoint_modify_event (b
->number
);
591 error (_("No breakpoint number %d."), bnum
);
595 commands_command (char *arg
, int from_tty
)
597 struct breakpoint
*b
;
600 struct command_line
*l
;
602 /* If we allowed this, we would have problems with when to
603 free the storage, if we change the commands currently
606 if (executing_breakpoint_commands
)
607 error (_("Can't use the \"commands\" command among a breakpoint's commands."));
610 bnum
= get_number (&p
);
613 error (_("Unexpected extra arguments following breakpoint number."));
616 if (b
->number
== bnum
)
618 char *tmpbuf
= xstrprintf ("Type commands for when breakpoint %d is hit, one per line.",
620 struct cleanup
*cleanups
= make_cleanup (xfree
, tmpbuf
);
621 l
= read_command_lines (tmpbuf
, from_tty
);
622 do_cleanups (cleanups
);
623 free_command_lines (&b
->commands
);
625 breakpoints_changed ();
626 breakpoint_modify_event (b
->number
);
629 error (_("No breakpoint number %d."), bnum
);
632 /* Like target_read_memory() but if breakpoints are inserted, return
633 the shadow contents instead of the breakpoints themselves.
635 Read "memory data" from whatever target or inferior we have.
636 Returns zero if successful, errno value if not. EIO is used
637 for address out of bounds. If breakpoints are inserted, returns
638 shadow contents, not the breakpoints themselves. From breakpoint.c. */
641 deprecated_read_memory_nobpt (CORE_ADDR memaddr
, char *myaddr
, unsigned len
)
644 struct bp_location
*b
;
645 CORE_ADDR bp_addr
= 0;
648 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
649 /* No breakpoints on this machine. */
650 return target_read_memory (memaddr
, myaddr
, len
);
654 if (b
->owner
->type
== bp_none
)
655 warning (_("reading through apparently deleted breakpoint #%d?"),
658 if (b
->loc_type
!= bp_loc_software_breakpoint
)
662 /* Addresses and length of the part of the breakpoint that
664 /* XXXX The m68k, sh and h8300 have different local and remote
665 breakpoint values. BREAKPOINT_FROM_PC still manages to
666 correctly determine the breakpoints memory address and size
667 for these targets. */
668 bp_addr
= b
->address
;
670 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
675 if (bp_addr
+ bp_size
<= memaddr
)
676 /* The breakpoint is entirely before the chunk of memory we
679 if (bp_addr
>= memaddr
+ len
)
680 /* The breakpoint is entirely after the chunk of memory we are
683 /* Copy the breakpoint from the shadow contents, and recurse for
684 the things before and after. */
686 /* Offset within shadow_contents. */
689 if (bp_addr
< memaddr
)
691 /* Only copy the second part of the breakpoint. */
692 bp_size
-= memaddr
- bp_addr
;
693 bptoffset
= memaddr
- bp_addr
;
697 if (bp_addr
+ bp_size
> memaddr
+ len
)
699 /* Only copy the first part of the breakpoint. */
700 bp_size
-= (bp_addr
+ bp_size
) - (memaddr
+ len
);
703 memcpy (myaddr
+ bp_addr
- memaddr
,
704 b
->shadow_contents
+ bptoffset
, bp_size
);
706 if (bp_addr
> memaddr
)
708 /* Copy the section of memory before the breakpoint. */
709 status
= deprecated_read_memory_nobpt (memaddr
, myaddr
, bp_addr
- memaddr
);
714 if (bp_addr
+ bp_size
< memaddr
+ len
)
716 /* Copy the section of memory after the breakpoint. */
717 status
= deprecated_read_memory_nobpt (bp_addr
+ bp_size
,
718 myaddr
+ bp_addr
+ bp_size
- memaddr
,
719 memaddr
+ len
- (bp_addr
+ bp_size
));
726 /* Nothing overlaps. Just call read_memory_noerr. */
727 return target_read_memory (memaddr
, myaddr
, len
);
731 /* A wrapper function for inserting catchpoints. */
733 insert_catchpoint (struct ui_out
*uo
, void *args
)
735 struct breakpoint
*b
= (struct breakpoint
*) args
;
741 target_insert_fork_catchpoint (PIDGET (inferior_ptid
));
744 target_insert_vfork_catchpoint (PIDGET (inferior_ptid
));
747 target_insert_exec_catchpoint (PIDGET (inferior_ptid
));
750 internal_error (__FILE__
, __LINE__
, _("unknown breakpoint type"));
755 /* Helper routine: free the value chain for a breakpoint (watchpoint). */
757 static void free_valchain (struct bp_location
*b
)
762 /* Free the saved value chain. We will construct a new one
763 the next time the watchpoint is inserted. */
764 for (v
= b
->owner
->val_chain
; v
; v
= n
)
769 b
->owner
->val_chain
= NULL
;
772 /* Insert a low-level "breakpoint" of some type. BPT is the breakpoint.
773 Any error messages are printed to TMP_ERROR_STREAM; and DISABLED_BREAKS,
774 PROCESS_WARNING, and HW_BREAKPOINT_ERROR are used to report problems.
776 NOTE drow/2003-09-09: This routine could be broken down to an object-style
777 method for each breakpoint or catchpoint type. */
779 insert_bp_location (struct bp_location
*bpt
,
780 struct ui_file
*tmp_error_stream
,
781 int *disabled_breaks
, int *process_warning
,
782 int *hw_breakpoint_error
)
786 /* Permanent breakpoints cannot be inserted or removed. Disabled
787 breakpoints should not be inserted. */
788 if (!breakpoint_enabled (bpt
->owner
))
791 if (bpt
->inserted
|| bpt
->duplicate
)
794 if (bpt
->loc_type
== bp_loc_software_breakpoint
795 || bpt
->loc_type
== bp_loc_hardware_breakpoint
)
797 /* First check to see if we have to handle an overlay. */
798 if (overlay_debugging
== ovly_off
799 || bpt
->section
== NULL
800 || !(section_is_overlay (bpt
->section
)))
802 /* No overlay handling: just set the breakpoint. */
804 if (bpt
->loc_type
== bp_loc_hardware_breakpoint
)
805 val
= target_insert_hw_breakpoint (bpt
->address
,
806 bpt
->shadow_contents
);
808 val
= target_insert_breakpoint (bpt
->address
,
809 bpt
->shadow_contents
);
813 /* This breakpoint is in an overlay section.
814 Shall we set a breakpoint at the LMA? */
815 if (!overlay_events_enabled
)
817 /* Yes -- overlay event support is not active,
818 so we must try to set a breakpoint at the LMA.
819 This will not work for a hardware breakpoint. */
820 if (bpt
->loc_type
== bp_loc_hardware_breakpoint
)
821 warning (_("hardware breakpoint %d not supported in overlay!"),
825 CORE_ADDR addr
= overlay_unmapped_address (bpt
->address
,
827 /* Set a software (trap) breakpoint at the LMA. */
828 val
= target_insert_breakpoint (addr
, bpt
->shadow_contents
);
830 fprintf_unfiltered (tmp_error_stream
,
831 "Overlay breakpoint %d failed: in ROM?",
835 /* Shall we set a breakpoint at the VMA? */
836 if (section_is_mapped (bpt
->section
))
838 /* Yes. This overlay section is mapped into memory. */
839 if (bpt
->loc_type
== bp_loc_hardware_breakpoint
)
840 val
= target_insert_hw_breakpoint (bpt
->address
,
841 bpt
->shadow_contents
);
843 val
= target_insert_breakpoint (bpt
->address
,
844 bpt
->shadow_contents
);
848 /* No. This breakpoint will not be inserted.
849 No error, but do not mark the bp as 'inserted'. */
856 /* Can't set the breakpoint. */
858 #if defined (DISABLE_UNSETTABLE_BREAK)
859 DISABLE_UNSETTABLE_BREAK (bpt
->address
)
861 solib_address (bpt
->address
)
865 /* See also: disable_breakpoints_in_shlibs. */
867 bpt
->owner
->enable_state
= bp_shlib_disabled
;
868 if (!*disabled_breaks
)
870 fprintf_unfiltered (tmp_error_stream
,
871 "Cannot insert breakpoint %d.\n",
873 fprintf_unfiltered (tmp_error_stream
,
874 "Temporarily disabling shared library breakpoints:\n");
876 *disabled_breaks
= 1;
877 fprintf_unfiltered (tmp_error_stream
,
878 "breakpoint #%d\n", bpt
->owner
->number
);
882 #ifdef ONE_PROCESS_WRITETEXT
883 *process_warning
= 1;
885 if (bpt
->loc_type
== bp_loc_hardware_breakpoint
)
887 *hw_breakpoint_error
= 1;
888 fprintf_unfiltered (tmp_error_stream
,
889 "Cannot insert hardware breakpoint %d.\n",
894 fprintf_unfiltered (tmp_error_stream
,
895 "Cannot insert breakpoint %d.\n",
897 fprintf_filtered (tmp_error_stream
,
898 "Error accessing memory address ");
899 deprecated_print_address_numeric (bpt
->address
, 1, tmp_error_stream
);
900 fprintf_filtered (tmp_error_stream
, ": %s.\n",
901 safe_strerror (val
));
912 else if (bpt
->loc_type
== bp_loc_hardware_watchpoint
913 /* NOTE drow/2003-09-08: This state only exists for removing
914 watchpoints. It's not clear that it's necessary... */
915 && bpt
->owner
->disposition
!= disp_del_at_next_stop
)
917 /* FIXME drow/2003-09-08: This code sets multiple hardware watchpoints
918 based on the expression. Ideally this should happen at a higher level,
919 and there should be one bp_location for each computed address we
920 must watch. As soon as a many-to-one mapping is available I'll
923 int within_current_scope
;
924 struct value
*mark
= value_mark ();
926 struct frame_id saved_frame_id
;
928 /* Save the current frame's ID so we can restore it after
929 evaluating the watchpoint expression on its own frame. */
930 /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
931 took a frame parameter, so that we didn't have to change the
933 saved_frame_id
= get_frame_id (deprecated_selected_frame
);
935 /* Determine if the watchpoint is within scope. */
936 if (bpt
->owner
->exp_valid_block
== NULL
)
937 within_current_scope
= 1;
940 struct frame_info
*fi
;
941 fi
= frame_find_by_id (bpt
->owner
->watchpoint_frame
);
942 within_current_scope
= (fi
!= NULL
);
943 if (within_current_scope
)
947 if (within_current_scope
)
951 /* Evaluate the expression and cut the chain of values
952 produced off from the value chain.
954 Make sure the value returned isn't lazy; we use
955 laziness to determine what memory GDB actually needed
956 in order to compute the value of the expression. */
957 v
= evaluate_expression (bpt
->owner
->exp
);
959 value_release_to_mark (mark
);
961 bpt
->owner
->val_chain
= v
;
964 /* Look at each value on the value chain. */
965 for (; v
; v
= value_next (v
))
967 /* If it's a memory location, and GDB actually needed
968 its contents to evaluate the expression, then we
970 if (VALUE_LVAL (v
) == lval_memory
973 struct type
*vtype
= check_typedef (value_type (v
));
975 /* We only watch structs and arrays if user asked
976 for it explicitly, never if they just happen to
977 appear in the middle of some value chain. */
978 if (v
== bpt
->owner
->val_chain
979 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
980 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
985 addr
= VALUE_ADDRESS (v
) + value_offset (v
);
986 len
= TYPE_LENGTH (value_type (v
));
988 if (bpt
->owner
->type
== bp_read_watchpoint
)
990 else if (bpt
->owner
->type
== bp_access_watchpoint
)
993 val
= target_insert_watchpoint (addr
, len
, type
);
996 /* Don't exit the loop, try to insert
997 every value on the value chain. That's
998 because we will be removing all the
999 watches below, and removing a
1000 watchpoint we didn't insert could have
1008 /* Failure to insert a watchpoint on any memory value in the
1009 value chain brings us here. */
1012 remove_breakpoint (bpt
, mark_uninserted
);
1013 *hw_breakpoint_error
= 1;
1014 fprintf_unfiltered (tmp_error_stream
,
1015 "Could not insert hardware watchpoint %d.\n",
1016 bpt
->owner
->number
);
1022 printf_filtered (_("\
1023 Hardware watchpoint %d deleted because the program has left the block \n\
1024 in which its expression is valid.\n"),
1025 bpt
->owner
->number
);
1026 if (bpt
->owner
->related_breakpoint
)
1027 bpt
->owner
->related_breakpoint
->disposition
= disp_del_at_next_stop
;
1028 bpt
->owner
->disposition
= disp_del_at_next_stop
;
1031 /* Restore the selected frame. */
1032 select_frame (frame_find_by_id (saved_frame_id
));
1037 else if (ep_is_exception_catchpoint (bpt
->owner
))
1039 /* FIXME drow/2003-09-09: This code sets both a catchpoint and a
1040 breakpoint. Once again, it would be better if this was represented
1041 as two bp_locations. */
1043 /* If we get here, we must have a callback mechanism for exception
1044 events -- with g++ style embedded label support, we insert
1045 ordinary breakpoints and not catchpoints. */
1046 val
= target_insert_breakpoint (bpt
->address
, bpt
->shadow_contents
);
1049 /* Couldn't set breakpoint for some reason */
1050 fprintf_unfiltered (tmp_error_stream
,
1051 "Cannot insert catchpoint %d; disabling it.\n",
1052 bpt
->owner
->number
);
1053 fprintf_filtered (tmp_error_stream
,
1054 "Error accessing memory address ");
1055 deprecated_print_address_numeric (bpt
->address
, 1, tmp_error_stream
);
1056 fprintf_filtered (tmp_error_stream
, ": %s.\n",
1057 safe_strerror (val
));
1058 bpt
->owner
->enable_state
= bp_disabled
;
1062 /* Bp set, now make sure callbacks are enabled */
1063 /* Format possible error msg */
1064 char *message
= xstrprintf ("Error inserting catchpoint %d:\n",
1065 bpt
->owner
->number
);
1066 struct cleanup
*cleanups
= make_cleanup (xfree
, message
);
1068 args_for_catchpoint_enable args
;
1069 args
.kind
= bpt
->owner
->type
== bp_catch_catch
?
1070 EX_EVENT_CATCH
: EX_EVENT_THROW
;
1072 val
= catch_errors (cover_target_enable_exception_callback
,
1073 &args
, message
, RETURN_MASK_ALL
);
1074 do_cleanups (cleanups
);
1075 if (val
!= 0 && val
!= -1)
1078 /* Check if something went wrong; val == 0 can be ignored */
1081 /* something went wrong */
1082 fprintf_unfiltered (tmp_error_stream
,
1083 "Cannot insert catchpoint %d; disabling it.\n",
1084 bpt
->owner
->number
);
1085 bpt
->owner
->enable_state
= bp_disabled
;
1092 else if (bpt
->owner
->type
== bp_catch_fork
1093 || bpt
->owner
->type
== bp_catch_vfork
1094 || bpt
->owner
->type
== bp_catch_exec
)
1096 struct gdb_exception e
= catch_exception (uiout
, insert_catchpoint
,
1097 bpt
->owner
, RETURN_MASK_ERROR
);
1098 exception_fprintf (gdb_stderr
, e
, "warning: inserting catchpoint %d: ",
1099 bpt
->owner
->number
);
1101 bpt
->owner
->enable_state
= bp_disabled
;
1105 /* We've already printed an error message if there was a problem
1106 inserting this catchpoint, and we've disabled the catchpoint,
1107 so just return success. */
1114 /* insert_breakpoints is used when starting or continuing the program.
1115 remove_breakpoints is used when the program stops.
1116 Both return zero if successful,
1117 or an `errno' value if could not write the inferior. */
1120 insert_breakpoints (void)
1122 struct bp_location
*b
, *temp
;
1123 int return_val
= 0; /* return success code. */
1125 int disabled_breaks
= 0;
1126 int hw_breakpoint_error
= 0;
1127 int process_warning
= 0;
1129 struct ui_file
*tmp_error_stream
= mem_fileopen ();
1130 make_cleanup_ui_file_delete (tmp_error_stream
);
1132 /* Explicitly mark the warning -- this will only be printed if
1133 there was an error. */
1134 fprintf_unfiltered (tmp_error_stream
, "Warning:\n");
1136 ALL_BP_LOCATIONS_SAFE (b
, temp
)
1138 /* Permanent breakpoints cannot be inserted or removed. Disabled
1139 breakpoints should not be inserted. */
1140 if (!breakpoint_enabled (b
->owner
))
1143 /* FIXME drow/2003-10-07: This code should be pushed elsewhere when
1144 hardware watchpoints are split into multiple loc breakpoints. */
1145 if ((b
->loc_type
== bp_loc_hardware_watchpoint
1146 || b
->owner
->type
== bp_watchpoint
) && !b
->owner
->val
)
1149 val
= evaluate_expression (b
->owner
->exp
);
1150 release_value (val
);
1151 if (value_lazy (val
))
1152 value_fetch_lazy (val
);
1153 b
->owner
->val
= val
;
1156 val
= insert_bp_location (b
, tmp_error_stream
,
1157 &disabled_breaks
, &process_warning
,
1158 &hw_breakpoint_error
);
1165 /* If a hardware breakpoint or watchpoint was inserted, add a
1166 message about possibly exhausted resources. */
1167 if (hw_breakpoint_error
)
1169 fprintf_unfiltered (tmp_error_stream
,
1170 "Could not insert hardware breakpoints:\n\
1171 You may have requested too many hardware breakpoints/watchpoints.\n");
1173 #ifdef ONE_PROCESS_WRITETEXT
1174 if (process_warning
)
1175 fprintf_unfiltered (tmp_error_stream
,
1176 "The same program may be running in another process.");
1178 target_terminal_ours_for_output ();
1179 error_stream (tmp_error_stream
);
1185 remove_breakpoints (void)
1187 struct bp_location
*b
;
1190 ALL_BP_LOCATIONS (b
)
1194 val
= remove_breakpoint (b
, mark_uninserted
);
1203 remove_hw_watchpoints (void)
1205 struct bp_location
*b
;
1208 ALL_BP_LOCATIONS (b
)
1210 if (b
->inserted
&& b
->loc_type
== bp_loc_hardware_watchpoint
)
1212 val
= remove_breakpoint (b
, mark_uninserted
);
1221 reattach_breakpoints (int pid
)
1223 struct bp_location
*b
;
1225 struct cleanup
*old_chain
= save_inferior_ptid ();
1227 /* Set inferior_ptid; remove_breakpoint uses this global. */
1228 inferior_ptid
= pid_to_ptid (pid
);
1229 ALL_BP_LOCATIONS (b
)
1233 remove_breakpoint (b
, mark_inserted
);
1234 if (b
->loc_type
== bp_loc_hardware_breakpoint
)
1235 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
1237 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
1238 /* FIXME drow/2003-10-07: This doesn't handle any other kinds of
1239 breakpoints. It's wrong for watchpoints, for example. */
1242 do_cleanups (old_chain
);
1247 do_cleanups (old_chain
);
1252 update_breakpoints_after_exec (void)
1254 struct breakpoint
*b
;
1255 struct breakpoint
*temp
;
1257 /* Doing this first prevents the badness of having delete_breakpoint()
1258 write a breakpoint's current "shadow contents" to lift the bp. That
1259 shadow is NOT valid after an exec()! */
1260 mark_breakpoints_out ();
1262 ALL_BREAKPOINTS_SAFE (b
, temp
)
1264 /* Solib breakpoints must be explicitly reset after an exec(). */
1265 if (b
->type
== bp_shlib_event
)
1267 delete_breakpoint (b
);
1271 /* Thread event breakpoints must be set anew after an exec(),
1272 as must overlay event breakpoints. */
1273 if (b
->type
== bp_thread_event
|| b
->type
== bp_overlay_event
)
1275 delete_breakpoint (b
);
1279 /* Step-resume breakpoints are meaningless after an exec(). */
1280 if (b
->type
== bp_step_resume
)
1282 delete_breakpoint (b
);
1286 /* Ditto the sigtramp handler breakpoints. */
1287 if (b
->type
== bp_through_sigtramp
)
1289 delete_breakpoint (b
);
1293 /* Ditto the exception-handling catchpoints. */
1294 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1296 delete_breakpoint (b
);
1300 /* Don't delete an exec catchpoint, because else the inferior
1301 won't stop when it ought!
1303 Similarly, we probably ought to keep vfork catchpoints, 'cause
1304 on this target, we may not be able to stop when the vfork is
1305 seen, but only when the subsequent exec is seen. (And because
1306 deleting fork catchpoints here but not vfork catchpoints will
1307 seem mysterious to users, keep those too.)
1309 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1310 target address field, if any, is sufficient to have it be reset
1311 automagically. Certainly on HP-UX that's true.
1313 Jim Blandy <jimb@redhat.com>: Actually, zero is a perfectly
1314 valid code address on some platforms (like the mn10300
1315 simulators). We shouldn't assign any special interpretation to
1316 a breakpoint with a zero address. And in fact, GDB doesn't ---
1317 I can't see what that comment above is talking about. As far
1318 as I can tell, setting the address of a
1319 bp_catch_exec/bp_catch_vfork/bp_catch_fork breakpoint to zero
1320 is meaningless, since those are implemented with HP-UX kernel
1321 hackery, not by storing breakpoint instructions somewhere. */
1322 if ((b
->type
== bp_catch_exec
) ||
1323 (b
->type
== bp_catch_vfork
) ||
1324 (b
->type
== bp_catch_fork
))
1326 b
->loc
->address
= (CORE_ADDR
) NULL
;
1330 /* bp_finish is a special case. The only way we ought to be able
1331 to see one of these when an exec() has happened, is if the user
1332 caught a vfork, and then said "finish". Ordinarily a finish just
1333 carries them to the call-site of the current callee, by setting
1334 a temporary bp there and resuming. But in this case, the finish
1335 will carry them entirely through the vfork & exec.
1337 We don't want to allow a bp_finish to remain inserted now. But
1338 we can't safely delete it, 'cause finish_command has a handle to
1339 the bp on a bpstat, and will later want to delete it. There's a
1340 chance (and I've seen it happen) that if we delete the bp_finish
1341 here, that its storage will get reused by the time finish_command
1342 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1343 We really must allow finish_command to delete a bp_finish.
1345 In the absense of a general solution for the "how do we know
1346 it's safe to delete something others may have handles to?"
1347 problem, what we'll do here is just uninsert the bp_finish, and
1348 let finish_command delete it.
1350 (We know the bp_finish is "doomed" in the sense that it's
1351 momentary, and will be deleted as soon as finish_command sees
1352 the inferior stopped. So it doesn't matter that the bp's
1353 address is probably bogus in the new a.out, unlike e.g., the
1354 solib breakpoints.) */
1356 if (b
->type
== bp_finish
)
1361 /* Without a symbolic address, we have little hope of the
1362 pre-exec() address meaning the same thing in the post-exec()
1364 if (b
->addr_string
== NULL
)
1366 delete_breakpoint (b
);
1370 /* If this breakpoint has survived the above battery of checks, then
1371 it must have a symbolic address. Be sure that it gets reevaluated
1372 to a target address, rather than reusing the old evaluation.
1374 Jim Blandy <jimb@redhat.com>: As explained above in the comment
1375 for bp_catch_exec and friends, I'm pretty sure this is entirely
1376 unnecessary. A call to breakpoint_re_set_one always recomputes
1377 the breakpoint's address from scratch, or deletes it if it can't.
1378 So I think this assignment could be deleted without effect. */
1379 b
->loc
->address
= (CORE_ADDR
) NULL
;
1381 /* FIXME what about longjmp breakpoints? Re-create them here? */
1382 create_overlay_event_breakpoint ("_ovly_debug_event");
1386 detach_breakpoints (int pid
)
1388 struct bp_location
*b
;
1390 struct cleanup
*old_chain
= save_inferior_ptid ();
1392 if (pid
== PIDGET (inferior_ptid
))
1393 error (_("Cannot detach breakpoints of inferior_ptid"));
1395 /* Set inferior_ptid; remove_breakpoint uses this global. */
1396 inferior_ptid
= pid_to_ptid (pid
);
1397 ALL_BP_LOCATIONS (b
)
1401 val
= remove_breakpoint (b
, mark_inserted
);
1404 do_cleanups (old_chain
);
1409 do_cleanups (old_chain
);
1414 remove_breakpoint (struct bp_location
*b
, insertion_state_t is
)
1418 if (b
->owner
->enable_state
== bp_permanent
)
1419 /* Permanent breakpoints cannot be inserted or removed. */
1422 if (b
->owner
->type
== bp_none
)
1423 warning (_("attempted to remove apparently deleted breakpoint #%d?"),
1426 if (b
->loc_type
== bp_loc_software_breakpoint
1427 || b
->loc_type
== bp_loc_hardware_breakpoint
)
1429 /* "Normal" instruction breakpoint: either the standard
1430 trap-instruction bp (bp_breakpoint), or a
1431 bp_hardware_breakpoint. */
1433 /* First check to see if we have to handle an overlay. */
1434 if (overlay_debugging
== ovly_off
1435 || b
->section
== NULL
1436 || !(section_is_overlay (b
->section
)))
1438 /* No overlay handling: just remove the breakpoint. */
1440 if (b
->loc_type
== bp_loc_hardware_breakpoint
)
1441 val
= target_remove_hw_breakpoint (b
->address
,
1442 b
->shadow_contents
);
1444 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1448 /* This breakpoint is in an overlay section.
1449 Did we set a breakpoint at the LMA? */
1450 if (!overlay_events_enabled
)
1452 /* Yes -- overlay event support is not active, so we
1453 should have set a breakpoint at the LMA. Remove it.
1455 CORE_ADDR addr
= overlay_unmapped_address (b
->address
,
1457 /* Ignore any failures: if the LMA is in ROM, we will
1458 have already warned when we failed to insert it. */
1459 if (b
->loc_type
== bp_loc_hardware_breakpoint
)
1460 target_remove_hw_breakpoint (addr
, b
->shadow_contents
);
1462 target_remove_breakpoint (addr
, b
->shadow_contents
);
1464 /* Did we set a breakpoint at the VMA?
1465 If so, we will have marked the breakpoint 'inserted'. */
1468 /* Yes -- remove it. Previously we did not bother to
1469 remove the breakpoint if the section had been
1470 unmapped, but let's not rely on that being safe. We
1471 don't know what the overlay manager might do. */
1472 if (b
->loc_type
== bp_loc_hardware_breakpoint
)
1473 val
= target_remove_hw_breakpoint (b
->address
,
1474 b
->shadow_contents
);
1476 val
= target_remove_breakpoint (b
->address
,
1477 b
->shadow_contents
);
1481 /* No -- not inserted, so no need to remove. No error. */
1487 b
->inserted
= (is
== mark_inserted
);
1489 else if (b
->loc_type
== bp_loc_hardware_watchpoint
1490 && breakpoint_enabled (b
->owner
)
1496 b
->inserted
= (is
== mark_inserted
);
1497 /* Walk down the saved value chain. */
1498 for (v
= b
->owner
->val_chain
; v
; v
= value_next (v
))
1500 /* For each memory reference remove the watchpoint
1502 if (VALUE_LVAL (v
) == lval_memory
1503 && ! value_lazy (v
))
1505 struct type
*vtype
= check_typedef (value_type (v
));
1507 if (v
== b
->owner
->val_chain
1508 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
1509 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
1514 addr
= VALUE_ADDRESS (v
) + value_offset (v
);
1515 len
= TYPE_LENGTH (value_type (v
));
1517 if (b
->owner
->type
== bp_read_watchpoint
)
1519 else if (b
->owner
->type
== bp_access_watchpoint
)
1522 val
= target_remove_watchpoint (addr
, len
, type
);
1529 /* Failure to remove any of the hardware watchpoints comes here. */
1530 if ((is
== mark_uninserted
) && (b
->inserted
))
1531 warning (_("Could not remove hardware watchpoint %d."),
1534 else if ((b
->owner
->type
== bp_catch_fork
||
1535 b
->owner
->type
== bp_catch_vfork
||
1536 b
->owner
->type
== bp_catch_exec
)
1537 && breakpoint_enabled (b
->owner
)
1541 switch (b
->owner
->type
)
1544 val
= target_remove_fork_catchpoint (PIDGET (inferior_ptid
));
1546 case bp_catch_vfork
:
1547 val
= target_remove_vfork_catchpoint (PIDGET (inferior_ptid
));
1550 val
= target_remove_exec_catchpoint (PIDGET (inferior_ptid
));
1553 warning (_("Internal error, %s line %d."), __FILE__
, __LINE__
);
1558 b
->inserted
= (is
== mark_inserted
);
1560 else if ((b
->owner
->type
== bp_catch_catch
||
1561 b
->owner
->type
== bp_catch_throw
)
1562 && breakpoint_enabled (b
->owner
)
1566 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1569 b
->inserted
= (is
== mark_inserted
);
1571 else if (ep_is_exception_catchpoint (b
->owner
)
1572 && b
->inserted
/* sometimes previous insert doesn't happen */
1573 && breakpoint_enabled (b
->owner
)
1577 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1581 b
->inserted
= (is
== mark_inserted
);
1587 /* Clear the "inserted" flag in all breakpoints. */
1590 mark_breakpoints_out (void)
1592 struct bp_location
*bpt
;
1594 ALL_BP_LOCATIONS (bpt
)
1598 /* Clear the "inserted" flag in all breakpoints and delete any
1599 breakpoints which should go away between runs of the program.
1601 Plus other such housekeeping that has to be done for breakpoints
1604 Note: this function gets called at the end of a run (by
1605 generic_mourn_inferior) and when a run begins (by
1606 init_wait_for_inferior). */
1611 breakpoint_init_inferior (enum inf_context context
)
1613 struct breakpoint
*b
, *temp
;
1614 struct bp_location
*bpt
;
1615 static int warning_needed
= 0;
1617 ALL_BP_LOCATIONS (bpt
)
1620 ALL_BREAKPOINTS_SAFE (b
, temp
)
1625 case bp_watchpoint_scope
:
1627 /* If the call dummy breakpoint is at the entry point it will
1628 cause problems when the inferior is rerun, so we better
1631 Also get rid of scope breakpoints. */
1632 delete_breakpoint (b
);
1636 case bp_hardware_watchpoint
:
1637 case bp_read_watchpoint
:
1638 case bp_access_watchpoint
:
1640 /* Likewise for watchpoints on local expressions. */
1641 if (b
->exp_valid_block
!= NULL
)
1642 delete_breakpoint (b
);
1643 if (context
== inf_starting
)
1645 /* Reset val field to force reread of starting value
1646 in insert_breakpoints. */
1648 value_free (b
->val
);
1653 /* Likewise for exception catchpoints in dynamic-linked
1654 executables where required */
1655 if (ep_is_exception_catchpoint (b
)
1656 && deprecated_exception_catchpoints_are_fragile
)
1659 delete_breakpoint (b
);
1665 if (deprecated_exception_catchpoints_are_fragile
)
1666 deprecated_exception_support_initialized
= 0;
1668 /* Don't issue the warning unless it's really needed... */
1669 if (warning_needed
&& (context
!= inf_exited
))
1671 warning (_("Exception catchpoints from last run were deleted.\n"
1672 "You must reinsert them explicitly."));
1677 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1678 exists at PC. It returns ordinary_breakpoint_here if it's an
1679 ordinary breakpoint, or permanent_breakpoint_here if it's a
1680 permanent breakpoint.
1681 - When continuing from a location with an ordinary breakpoint, we
1682 actually single step once before calling insert_breakpoints.
1683 - When continuing from a localion with a permanent breakpoint, we
1684 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1685 the target, to advance the PC past the breakpoint. */
1687 enum breakpoint_here
1688 breakpoint_here_p (CORE_ADDR pc
)
1690 struct bp_location
*bpt
;
1691 int any_breakpoint_here
= 0;
1693 ALL_BP_LOCATIONS (bpt
)
1695 if (bpt
->loc_type
!= bp_loc_software_breakpoint
1696 && bpt
->loc_type
!= bp_loc_hardware_breakpoint
)
1699 if ((breakpoint_enabled (bpt
->owner
)
1700 || bpt
->owner
->enable_state
== bp_permanent
)
1701 && bpt
->address
== pc
) /* bp is enabled and matches pc */
1703 if (overlay_debugging
1704 && section_is_overlay (bpt
->section
)
1705 && !section_is_mapped (bpt
->section
))
1706 continue; /* unmapped overlay -- can't be a match */
1707 else if (bpt
->owner
->enable_state
== bp_permanent
)
1708 return permanent_breakpoint_here
;
1710 any_breakpoint_here
= 1;
1714 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1718 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1719 but it only returns true if there is actually a breakpoint inserted
1723 breakpoint_inserted_here_p (CORE_ADDR pc
)
1725 struct bp_location
*bpt
;
1727 ALL_BP_LOCATIONS (bpt
)
1729 if (bpt
->loc_type
!= bp_loc_software_breakpoint
1730 && bpt
->loc_type
!= bp_loc_hardware_breakpoint
)
1734 && bpt
->address
== pc
) /* bp is inserted and matches pc */
1736 if (overlay_debugging
1737 && section_is_overlay (bpt
->section
)
1738 && !section_is_mapped (bpt
->section
))
1739 continue; /* unmapped overlay -- can't be a match */
1748 /* This function returns non-zero iff there is a software breakpoint
1752 software_breakpoint_inserted_here_p (CORE_ADDR pc
)
1754 struct bp_location
*bpt
;
1755 int any_breakpoint_here
= 0;
1757 ALL_BP_LOCATIONS (bpt
)
1759 if (bpt
->loc_type
!= bp_loc_software_breakpoint
)
1762 if ((breakpoint_enabled (bpt
->owner
)
1763 || bpt
->owner
->enable_state
== bp_permanent
)
1765 && bpt
->address
== pc
) /* bp is enabled and matches pc */
1767 if (overlay_debugging
1768 && section_is_overlay (bpt
->section
)
1769 && !section_is_mapped (bpt
->section
))
1770 continue; /* unmapped overlay -- can't be a match */
1779 /* breakpoint_thread_match (PC, PTID) returns true if the breakpoint at
1780 PC is valid for process/thread PTID. */
1783 breakpoint_thread_match (CORE_ADDR pc
, ptid_t ptid
)
1785 struct bp_location
*bpt
;
1788 thread
= pid_to_thread_id (ptid
);
1790 ALL_BP_LOCATIONS (bpt
)
1792 if (bpt
->loc_type
!= bp_loc_software_breakpoint
1793 && bpt
->loc_type
!= bp_loc_hardware_breakpoint
)
1796 if ((breakpoint_enabled (bpt
->owner
)
1797 || bpt
->owner
->enable_state
== bp_permanent
)
1798 && bpt
->address
== pc
1799 && (bpt
->owner
->thread
== -1 || bpt
->owner
->thread
== thread
))
1801 if (overlay_debugging
1802 && section_is_overlay (bpt
->section
)
1803 && !section_is_mapped (bpt
->section
))
1804 continue; /* unmapped overlay -- can't be a match */
1814 /* bpstat stuff. External routines' interfaces are documented
1818 ep_is_catchpoint (struct breakpoint
*ep
)
1821 (ep
->type
== bp_catch_load
)
1822 || (ep
->type
== bp_catch_unload
)
1823 || (ep
->type
== bp_catch_fork
)
1824 || (ep
->type
== bp_catch_vfork
)
1825 || (ep
->type
== bp_catch_exec
)
1826 || (ep
->type
== bp_catch_catch
)
1827 || (ep
->type
== bp_catch_throw
);
1829 /* ??rehrauer: Add more kinds here, as are implemented... */
1833 ep_is_shlib_catchpoint (struct breakpoint
*ep
)
1836 (ep
->type
== bp_catch_load
)
1837 || (ep
->type
== bp_catch_unload
);
1841 ep_is_exception_catchpoint (struct breakpoint
*ep
)
1844 (ep
->type
== bp_catch_catch
)
1845 || (ep
->type
== bp_catch_throw
);
1848 /* Clear a bpstat so that it says we are not at any breakpoint.
1849 Also free any storage that is part of a bpstat. */
1852 bpstat_clear (bpstat
*bsp
)
1863 if (p
->old_val
!= NULL
)
1864 value_free (p
->old_val
);
1865 free_command_lines (&p
->commands
);
1872 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1873 is part of the bpstat is copied as well. */
1876 bpstat_copy (bpstat bs
)
1880 bpstat retval
= NULL
;
1885 for (; bs
!= NULL
; bs
= bs
->next
)
1887 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1888 memcpy (tmp
, bs
, sizeof (*tmp
));
1889 if (bs
->commands
!= NULL
)
1890 tmp
->commands
= copy_command_lines (bs
->commands
);
1891 if (bs
->old_val
!= NULL
)
1892 tmp
->old_val
= value_copy (bs
->old_val
);
1895 /* This is the first thing in the chain. */
1905 /* Find the bpstat associated with this breakpoint */
1908 bpstat_find_breakpoint (bpstat bsp
, struct breakpoint
*breakpoint
)
1913 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1915 if (bsp
->breakpoint_at
== breakpoint
)
1921 /* Find a step_resume breakpoint associated with this bpstat.
1922 (If there are multiple step_resume bp's on the list, this function
1923 will arbitrarily pick one.)
1925 It is an error to use this function if BPSTAT doesn't contain a
1926 step_resume breakpoint.
1928 See wait_for_inferior's use of this function. */
1930 bpstat_find_step_resume_breakpoint (bpstat bsp
)
1934 gdb_assert (bsp
!= NULL
);
1936 current_thread
= pid_to_thread_id (inferior_ptid
);
1938 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1940 if ((bsp
->breakpoint_at
!= NULL
) &&
1941 (bsp
->breakpoint_at
->type
== bp_step_resume
) &&
1942 (bsp
->breakpoint_at
->thread
== current_thread
||
1943 bsp
->breakpoint_at
->thread
== -1))
1944 return bsp
->breakpoint_at
;
1947 internal_error (__FILE__
, __LINE__
, _("No step_resume breakpoint found."));
1951 /* Return the breakpoint number of the first breakpoint we are stopped
1952 at. *BSP upon return is a bpstat which points to the remaining
1953 breakpoints stopped at (but which is not guaranteed to be good for
1954 anything but further calls to bpstat_num).
1955 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1958 bpstat_num (bpstat
*bsp
)
1960 struct breakpoint
*b
;
1963 return 0; /* No more breakpoint values */
1966 b
= (*bsp
)->breakpoint_at
;
1967 *bsp
= (*bsp
)->next
;
1969 return -1; /* breakpoint that's been deleted since */
1971 return b
->number
; /* We have its number */
1975 /* Modify BS so that the actions will not be performed. */
1978 bpstat_clear_actions (bpstat bs
)
1980 for (; bs
!= NULL
; bs
= bs
->next
)
1982 free_command_lines (&bs
->commands
);
1983 if (bs
->old_val
!= NULL
)
1985 value_free (bs
->old_val
);
1991 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1993 cleanup_executing_breakpoints (void *ignore
)
1995 executing_breakpoint_commands
= 0;
1998 /* Execute all the commands associated with all the breakpoints at this
1999 location. Any of these commands could cause the process to proceed
2000 beyond this point, etc. We look out for such changes by checking
2001 the global "breakpoint_proceeded" after each command. */
2004 bpstat_do_actions (bpstat
*bsp
)
2007 struct cleanup
*old_chain
;
2009 /* Avoid endless recursion if a `source' command is contained
2011 if (executing_breakpoint_commands
)
2014 executing_breakpoint_commands
= 1;
2015 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
2018 /* Note that (as of this writing), our callers all appear to
2019 be passing us the address of global stop_bpstat. And, if
2020 our calls to execute_control_command cause the inferior to
2021 proceed, that global (and hence, *bsp) will change.
2023 We must be careful to not touch *bsp unless the inferior
2024 has not proceeded. */
2026 /* This pointer will iterate over the list of bpstat's. */
2029 breakpoint_proceeded
= 0;
2030 for (; bs
!= NULL
; bs
= bs
->next
)
2032 struct command_line
*cmd
;
2033 struct cleanup
*this_cmd_tree_chain
;
2035 /* Take ownership of the BSP's command tree, if it has one.
2037 The command tree could legitimately contain commands like
2038 'step' and 'next', which call clear_proceed_status, which
2039 frees stop_bpstat's command tree. To make sure this doesn't
2040 free the tree we're executing out from under us, we need to
2041 take ownership of the tree ourselves. Since a given bpstat's
2042 commands are only executed once, we don't need to copy it; we
2043 can clear the pointer in the bpstat, and make sure we free
2044 the tree when we're done. */
2047 this_cmd_tree_chain
= make_cleanup_free_command_lines (&cmd
);
2051 execute_control_command (cmd
);
2053 if (breakpoint_proceeded
)
2059 /* We can free this command tree now. */
2060 do_cleanups (this_cmd_tree_chain
);
2062 if (breakpoint_proceeded
)
2063 /* The inferior is proceeded by the command; bomb out now.
2064 The bpstat chain has been blown away by wait_for_inferior.
2065 But since execution has stopped again, there is a new bpstat
2066 to look at, so start over. */
2069 do_cleanups (old_chain
);
2072 /* This is the normal print function for a bpstat. In the future,
2073 much of this logic could (should?) be moved to bpstat_stop_status,
2074 by having it set different print_it values.
2076 Current scheme: When we stop, bpstat_print() is called. It loops
2077 through the bpstat list of things causing this stop, calling the
2078 print_bp_stop_message function on each one. The behavior of the
2079 print_bp_stop_message function depends on the print_it field of
2080 bpstat. If such field so indicates, call this function here.
2082 Return values from this routine (ultimately used by bpstat_print()
2083 and normal_stop() to decide what to do):
2084 PRINT_NOTHING: Means we already printed all we needed to print,
2085 don't print anything else.
2086 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
2087 that something to be followed by a location.
2088 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
2089 that something to be followed by a location.
2090 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
2093 static enum print_stop_action
2094 print_it_typical (bpstat bs
)
2096 struct cleanup
*old_chain
, *ui_out_chain
;
2097 struct ui_stream
*stb
;
2098 stb
= ui_out_stream_new (uiout
);
2099 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
2100 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
2101 which has since been deleted. */
2102 if (bs
->breakpoint_at
== NULL
)
2103 return PRINT_UNKNOWN
;
2105 switch (bs
->breakpoint_at
->type
)
2108 case bp_hardware_breakpoint
:
2109 if (bs
->breakpoint_at
->loc
->address
!= bs
->breakpoint_at
->loc
->requested_address
)
2110 breakpoint_adjustment_warning (bs
->breakpoint_at
->loc
->requested_address
,
2111 bs
->breakpoint_at
->loc
->address
,
2112 bs
->breakpoint_at
->number
, 1);
2113 annotate_breakpoint (bs
->breakpoint_at
->number
);
2114 ui_out_text (uiout
, "\nBreakpoint ");
2115 if (ui_out_is_mi_like_p (uiout
))
2116 ui_out_field_string (uiout
, "reason", "breakpoint-hit");
2117 ui_out_field_int (uiout
, "bkptno", bs
->breakpoint_at
->number
);
2118 ui_out_text (uiout
, ", ");
2119 return PRINT_SRC_AND_LOC
;
2122 case bp_shlib_event
:
2123 /* Did we stop because the user set the stop_on_solib_events
2124 variable? (If so, we report this as a generic, "Stopped due
2125 to shlib event" message.) */
2126 printf_filtered (_("Stopped due to shared library event\n"));
2127 return PRINT_NOTHING
;
2130 case bp_thread_event
:
2131 /* Not sure how we will get here.
2132 GDB should not stop for these breakpoints. */
2133 printf_filtered (_("Thread Event Breakpoint: gdb should not stop!\n"));
2134 return PRINT_NOTHING
;
2137 case bp_overlay_event
:
2138 /* By analogy with the thread event, GDB should not stop for these. */
2139 printf_filtered (_("Overlay Event Breakpoint: gdb should not stop!\n"));
2140 return PRINT_NOTHING
;
2144 annotate_catchpoint (bs
->breakpoint_at
->number
);
2145 printf_filtered (_("\nCatchpoint %d (loaded %s), "),
2146 bs
->breakpoint_at
->number
,
2147 bs
->breakpoint_at
->triggered_dll_pathname
);
2148 return PRINT_SRC_AND_LOC
;
2151 case bp_catch_unload
:
2152 annotate_catchpoint (bs
->breakpoint_at
->number
);
2153 printf_filtered (_("\nCatchpoint %d (unloaded %s), "),
2154 bs
->breakpoint_at
->number
,
2155 bs
->breakpoint_at
->triggered_dll_pathname
);
2156 return PRINT_SRC_AND_LOC
;
2160 annotate_catchpoint (bs
->breakpoint_at
->number
);
2161 printf_filtered (_("\nCatchpoint %d (forked process %d), "),
2162 bs
->breakpoint_at
->number
,
2163 bs
->breakpoint_at
->forked_inferior_pid
);
2164 return PRINT_SRC_AND_LOC
;
2167 case bp_catch_vfork
:
2168 annotate_catchpoint (bs
->breakpoint_at
->number
);
2169 printf_filtered (_("\nCatchpoint %d (vforked process %d), "),
2170 bs
->breakpoint_at
->number
,
2171 bs
->breakpoint_at
->forked_inferior_pid
);
2172 return PRINT_SRC_AND_LOC
;
2176 annotate_catchpoint (bs
->breakpoint_at
->number
);
2177 printf_filtered (_("\nCatchpoint %d (exec'd %s), "),
2178 bs
->breakpoint_at
->number
,
2179 bs
->breakpoint_at
->exec_pathname
);
2180 return PRINT_SRC_AND_LOC
;
2183 case bp_catch_catch
:
2184 if (current_exception_event
&&
2185 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
2187 annotate_catchpoint (bs
->breakpoint_at
->number
);
2188 printf_filtered (_("\nCatchpoint %d (exception caught), "),
2189 bs
->breakpoint_at
->number
);
2190 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2191 printf_filtered (_("throw location %s:%d, "),
2192 CURRENT_EXCEPTION_THROW_FILE
,
2193 CURRENT_EXCEPTION_THROW_LINE
);
2195 printf_filtered (_("throw location unknown, "));
2197 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2198 printf_filtered (_("catch location %s:%d\n"),
2199 CURRENT_EXCEPTION_CATCH_FILE
,
2200 CURRENT_EXCEPTION_CATCH_LINE
);
2202 printf_filtered (_("catch location unknown\n"));
2204 /* don't bother to print location frame info */
2205 return PRINT_SRC_ONLY
;
2209 /* really throw, some other bpstat will handle it */
2210 return PRINT_UNKNOWN
;
2214 case bp_catch_throw
:
2215 if (current_exception_event
&&
2216 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
2218 annotate_catchpoint (bs
->breakpoint_at
->number
);
2219 printf_filtered (_("\nCatchpoint %d (exception thrown), "),
2220 bs
->breakpoint_at
->number
);
2221 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2222 printf_filtered (_("throw location %s:%d, "),
2223 CURRENT_EXCEPTION_THROW_FILE
,
2224 CURRENT_EXCEPTION_THROW_LINE
);
2226 printf_filtered (_("throw location unknown, "));
2228 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2229 printf_filtered (_("catch location %s:%d\n"),
2230 CURRENT_EXCEPTION_CATCH_FILE
,
2231 CURRENT_EXCEPTION_CATCH_LINE
);
2233 printf_filtered (_("catch location unknown\n"));
2235 /* don't bother to print location frame info */
2236 return PRINT_SRC_ONLY
;
2240 /* really catch, some other bpstat will handle it */
2241 return PRINT_UNKNOWN
;
2246 case bp_hardware_watchpoint
:
2247 if (bs
->old_val
!= NULL
)
2249 annotate_watchpoint (bs
->breakpoint_at
->number
);
2250 if (ui_out_is_mi_like_p (uiout
))
2251 ui_out_field_string (uiout
, "reason", "watchpoint-trigger");
2252 mention (bs
->breakpoint_at
);
2253 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "value");
2254 ui_out_text (uiout
, "\nOld value = ");
2255 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2256 ui_out_field_stream (uiout
, "old", stb
);
2257 ui_out_text (uiout
, "\nNew value = ");
2258 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2259 ui_out_field_stream (uiout
, "new", stb
);
2260 do_cleanups (ui_out_chain
);
2261 ui_out_text (uiout
, "\n");
2262 value_free (bs
->old_val
);
2265 /* More than one watchpoint may have been triggered. */
2266 return PRINT_UNKNOWN
;
2269 case bp_read_watchpoint
:
2270 if (ui_out_is_mi_like_p (uiout
))
2271 ui_out_field_string (uiout
, "reason", "read-watchpoint-trigger");
2272 mention (bs
->breakpoint_at
);
2273 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "value");
2274 ui_out_text (uiout
, "\nValue = ");
2275 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2276 ui_out_field_stream (uiout
, "value", stb
);
2277 do_cleanups (ui_out_chain
);
2278 ui_out_text (uiout
, "\n");
2279 return PRINT_UNKNOWN
;
2282 case bp_access_watchpoint
:
2283 if (bs
->old_val
!= NULL
)
2285 annotate_watchpoint (bs
->breakpoint_at
->number
);
2286 if (ui_out_is_mi_like_p (uiout
))
2287 ui_out_field_string (uiout
, "reason", "access-watchpoint-trigger");
2288 mention (bs
->breakpoint_at
);
2289 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "value");
2290 ui_out_text (uiout
, "\nOld value = ");
2291 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2292 ui_out_field_stream (uiout
, "old", stb
);
2293 value_free (bs
->old_val
);
2295 ui_out_text (uiout
, "\nNew value = ");
2299 mention (bs
->breakpoint_at
);
2300 if (ui_out_is_mi_like_p (uiout
))
2301 ui_out_field_string (uiout
, "reason", "access-watchpoint-trigger");
2302 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "value");
2303 ui_out_text (uiout
, "\nValue = ");
2305 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0,Val_pretty_default
);
2306 ui_out_field_stream (uiout
, "new", stb
);
2307 do_cleanups (ui_out_chain
);
2308 ui_out_text (uiout
, "\n");
2309 return PRINT_UNKNOWN
;
2312 /* Fall through, we don't deal with these types of breakpoints
2316 if (ui_out_is_mi_like_p (uiout
))
2317 ui_out_field_string (uiout
, "reason", "function-finished");
2318 return PRINT_UNKNOWN
;
2322 if (ui_out_is_mi_like_p (uiout
))
2323 ui_out_field_string (uiout
, "reason", "location-reached");
2324 return PRINT_UNKNOWN
;
2329 case bp_longjmp_resume
:
2330 case bp_step_resume
:
2331 case bp_through_sigtramp
:
2332 case bp_watchpoint_scope
:
2335 return PRINT_UNKNOWN
;
2339 /* Generic routine for printing messages indicating why we
2340 stopped. The behavior of this function depends on the value
2341 'print_it' in the bpstat structure. Under some circumstances we
2342 may decide not to print anything here and delegate the task to
2345 static enum print_stop_action
2346 print_bp_stop_message (bpstat bs
)
2348 switch (bs
->print_it
)
2351 /* Nothing should be printed for this bpstat entry. */
2352 return PRINT_UNKNOWN
;
2356 /* We still want to print the frame, but we already printed the
2357 relevant messages. */
2358 return PRINT_SRC_AND_LOC
;
2361 case print_it_normal
:
2362 /* Normal case. Call the breakpoint's print_it method, or
2363 print_it_typical. */
2364 if (bs
->breakpoint_at
!= NULL
&& bs
->breakpoint_at
->ops
!= NULL
2365 && bs
->breakpoint_at
->ops
->print_it
!= NULL
)
2366 return bs
->breakpoint_at
->ops
->print_it (bs
->breakpoint_at
);
2368 return print_it_typical (bs
);
2372 internal_error (__FILE__
, __LINE__
,
2373 _("print_bp_stop_message: unrecognized enum value"));
2378 /* Print a message indicating what happened. This is called from
2379 normal_stop(). The input to this routine is the head of the bpstat
2380 list - a list of the eventpoints that caused this stop. This
2381 routine calls the generic print routine for printing a message
2382 about reasons for stopping. This will print (for example) the
2383 "Breakpoint n," part of the output. The return value of this
2386 PRINT_UNKNOWN: Means we printed nothing
2387 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2388 code to print the location. An example is
2389 "Breakpoint 1, " which should be followed by
2391 PRINT_SRC_ONLY: Means we printed something, but there is no need
2392 to also print the location part of the message.
2393 An example is the catch/throw messages, which
2394 don't require a location appended to the end.
2395 PRINT_NOTHING: We have done some printing and we don't need any
2396 further info to be printed.*/
2398 enum print_stop_action
2399 bpstat_print (bpstat bs
)
2403 /* Maybe another breakpoint in the chain caused us to stop.
2404 (Currently all watchpoints go on the bpstat whether hit or not.
2405 That probably could (should) be changed, provided care is taken
2406 with respect to bpstat_explains_signal). */
2407 for (; bs
; bs
= bs
->next
)
2409 val
= print_bp_stop_message (bs
);
2410 if (val
== PRINT_SRC_ONLY
2411 || val
== PRINT_SRC_AND_LOC
2412 || val
== PRINT_NOTHING
)
2416 /* We reached the end of the chain, or we got a null BS to start
2417 with and nothing was printed. */
2418 return PRINT_UNKNOWN
;
2421 /* Evaluate the expression EXP and return 1 if value is zero.
2422 This is used inside a catch_errors to evaluate the breakpoint condition.
2423 The argument is a "struct expression *" that has been cast to char * to
2424 make it pass through catch_errors. */
2427 breakpoint_cond_eval (void *exp
)
2429 struct value
*mark
= value_mark ();
2430 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2431 value_free_to_mark (mark
);
2435 /* Allocate a new bpstat and chain it to the current one. */
2438 bpstat_alloc (struct breakpoint
*b
, bpstat cbs
/* Current "bs" value */ )
2442 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2444 bs
->breakpoint_at
= b
;
2445 /* If the condition is false, etc., don't do the commands. */
2446 bs
->commands
= NULL
;
2448 bs
->print_it
= print_it_normal
;
2452 /* Possible return values for watchpoint_check (this can't be an enum
2453 because of check_errors). */
2454 /* The watchpoint has been deleted. */
2455 #define WP_DELETED 1
2456 /* The value has changed. */
2457 #define WP_VALUE_CHANGED 2
2458 /* The value has not changed. */
2459 #define WP_VALUE_NOT_CHANGED 3
2461 #define BP_TEMPFLAG 1
2462 #define BP_HARDWAREFLAG 2
2464 /* Check watchpoint condition. */
2467 watchpoint_check (void *p
)
2469 bpstat bs
= (bpstat
) p
;
2470 struct breakpoint
*b
;
2471 struct frame_info
*fr
;
2472 int within_current_scope
;
2474 b
= bs
->breakpoint_at
;
2476 if (b
->exp_valid_block
== NULL
)
2477 within_current_scope
= 1;
2480 /* There is no current frame at this moment. If we're going to have
2481 any chance of handling watchpoints on local variables, we'll need
2482 the frame chain (so we can determine if we're in scope). */
2483 reinit_frame_cache ();
2484 fr
= frame_find_by_id (b
->watchpoint_frame
);
2485 within_current_scope
= (fr
!= NULL
);
2486 /* in_function_epilogue_p() returns a non-zero value if we're still
2487 in the function but the stack frame has already been invalidated.
2488 Since we can't rely on the values of local variables after the
2489 stack has been destroyed, we are treating the watchpoint in that
2490 state as `not changed' without further checking.
2492 vinschen/2003-09-04: The former implementation left out the case
2493 that the watchpoint frame couldn't be found by frame_find_by_id()
2494 because the current PC is currently in an epilogue. Calling
2495 gdbarch_in_function_epilogue_p() also when fr == NULL fixes that. */
2496 if ((!within_current_scope
|| fr
== get_current_frame ())
2497 && gdbarch_in_function_epilogue_p (current_gdbarch
, read_pc ()))
2498 return WP_VALUE_NOT_CHANGED
;
2499 if (fr
&& within_current_scope
)
2500 /* If we end up stopping, the current frame will get selected
2501 in normal_stop. So this call to select_frame won't affect
2506 if (within_current_scope
)
2508 /* We use value_{,free_to_}mark because it could be a
2509 *long* time before we return to the command level and
2510 call free_all_values. We can't call free_all_values because
2511 we might be in the middle of evaluating a function call. */
2513 struct value
*mark
= value_mark ();
2514 struct value
*new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2515 if (!value_equal (b
->val
, new_val
))
2517 release_value (new_val
);
2518 value_free_to_mark (mark
);
2519 bs
->old_val
= b
->val
;
2521 /* We will stop here */
2522 return WP_VALUE_CHANGED
;
2526 /* Nothing changed, don't do anything. */
2527 value_free_to_mark (mark
);
2528 /* We won't stop here */
2529 return WP_VALUE_NOT_CHANGED
;
2534 /* This seems like the only logical thing to do because
2535 if we temporarily ignored the watchpoint, then when
2536 we reenter the block in which it is valid it contains
2537 garbage (in the case of a function, it may have two
2538 garbage values, one before and one after the prologue).
2539 So we can't even detect the first assignment to it and
2540 watch after that (since the garbage may or may not equal
2541 the first value assigned). */
2542 /* We print all the stop information in print_it_typical(), but
2543 in this case, by the time we call print_it_typical() this bp
2544 will be deleted already. So we have no choice but print the
2545 information here. */
2546 if (ui_out_is_mi_like_p (uiout
))
2547 ui_out_field_string (uiout
, "reason", "watchpoint-scope");
2548 ui_out_text (uiout
, "\nWatchpoint ");
2549 ui_out_field_int (uiout
, "wpnum", bs
->breakpoint_at
->number
);
2550 ui_out_text (uiout
, " deleted because the program has left the block in\n\
2551 which its expression is valid.\n");
2553 if (b
->related_breakpoint
)
2554 b
->related_breakpoint
->disposition
= disp_del_at_next_stop
;
2555 b
->disposition
= disp_del_at_next_stop
;
2561 /* Get a bpstat associated with having just stopped at address
2562 BP_ADDR in thread PTID. STOPPED_BY_WATCHPOINT is 1 if the
2563 target thinks we stopped due to a hardware watchpoint, 0 if we
2564 know we did not trigger a hardware watchpoint, and -1 if we do not know. */
2566 /* Determine whether we stopped at a breakpoint, etc, or whether we
2567 don't understand this stop. Result is a chain of bpstat's such that:
2569 if we don't understand the stop, the result is a null pointer.
2571 if we understand why we stopped, the result is not null.
2573 Each element of the chain refers to a particular breakpoint or
2574 watchpoint at which we have stopped. (We may have stopped for
2575 several reasons concurrently.)
2577 Each element of the chain has valid next, breakpoint_at,
2578 commands, FIXME??? fields. */
2581 bpstat_stop_status (CORE_ADDR bp_addr
, ptid_t ptid
, int stopped_by_watchpoint
)
2583 struct breakpoint
*b
, *temp
;
2584 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2585 int real_breakpoint
= 0;
2586 /* Root of the chain of bpstat's */
2587 struct bpstats root_bs
[1];
2588 /* Pointer to the last thing in the chain currently. */
2589 bpstat bs
= root_bs
;
2590 int thread_id
= pid_to_thread_id (ptid
);
2592 ALL_BREAKPOINTS_SAFE (b
, temp
)
2594 if (!breakpoint_enabled (b
) && b
->enable_state
!= bp_permanent
)
2597 if (b
->type
!= bp_watchpoint
2598 && b
->type
!= bp_hardware_watchpoint
2599 && b
->type
!= bp_read_watchpoint
2600 && b
->type
!= bp_access_watchpoint
2601 && b
->type
!= bp_hardware_breakpoint
2602 && b
->type
!= bp_catch_fork
2603 && b
->type
!= bp_catch_vfork
2604 && b
->type
!= bp_catch_exec
2605 && b
->type
!= bp_catch_catch
2606 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2608 if (b
->loc
->address
!= bp_addr
) /* address doesn't match */
2610 if (overlay_debugging
/* unmapped overlay section */
2611 && section_is_overlay (b
->loc
->section
)
2612 && !section_is_mapped (b
->loc
->section
))
2616 /* Continuable hardware watchpoints are treated as non-existent if the
2617 reason we stopped wasn't a hardware watchpoint (we didn't stop on
2618 some data address). Otherwise gdb won't stop on a break instruction
2619 in the code (not from a breakpoint) when a hardware watchpoint has
2622 if ((b
->type
== bp_hardware_watchpoint
2623 || b
->type
== bp_read_watchpoint
2624 || b
->type
== bp_access_watchpoint
)
2625 && !stopped_by_watchpoint
)
2628 if (b
->type
== bp_hardware_breakpoint
)
2630 if (b
->loc
->address
!= bp_addr
)
2632 if (overlay_debugging
/* unmapped overlay section */
2633 && section_is_overlay (b
->loc
->section
)
2634 && !section_is_mapped (b
->loc
->section
))
2638 /* Is this a catchpoint of a load or unload? If so, did we
2639 get a load or unload of the specified library? If not,
2641 if ((b
->type
== bp_catch_load
)
2642 #if defined(SOLIB_HAVE_LOAD_EVENT)
2643 && (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid
))
2644 || ((b
->dll_pathname
!= NULL
)
2645 && (strcmp (b
->dll_pathname
,
2646 SOLIB_LOADED_LIBRARY_PATHNAME (
2647 PIDGET (inferior_ptid
)))
2653 if ((b
->type
== bp_catch_unload
)
2654 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2655 && (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid
))
2656 || ((b
->dll_pathname
!= NULL
)
2657 && (strcmp (b
->dll_pathname
,
2658 SOLIB_UNLOADED_LIBRARY_PATHNAME (
2659 PIDGET (inferior_ptid
)))
2665 if ((b
->type
== bp_catch_fork
)
2666 && !inferior_has_forked (PIDGET (inferior_ptid
),
2667 &b
->forked_inferior_pid
))
2670 if ((b
->type
== bp_catch_vfork
)
2671 && !inferior_has_vforked (PIDGET (inferior_ptid
),
2672 &b
->forked_inferior_pid
))
2675 if ((b
->type
== bp_catch_exec
)
2676 && !inferior_has_execd (PIDGET (inferior_ptid
), &b
->exec_pathname
))
2679 if (ep_is_exception_catchpoint (b
) &&
2680 !(current_exception_event
= target_get_current_exception_event ()))
2683 /* Come here if it's a watchpoint, or if the break address matches */
2685 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2687 /* Watchpoints may change this, if not found to have triggered. */
2691 if (b
->type
== bp_watchpoint
||
2692 b
->type
== bp_hardware_watchpoint
)
2694 char *message
= xstrprintf ("Error evaluating expression for watchpoint %d\n",
2696 struct cleanup
*cleanups
= make_cleanup (xfree
, message
);
2697 int e
= catch_errors (watchpoint_check
, bs
, message
,
2699 do_cleanups (cleanups
);
2703 /* We've already printed what needs to be printed. */
2704 /* Actually this is superfluous, because by the time we
2705 call print_it_typical() the wp will be already deleted,
2706 and the function will return immediately. */
2707 bs
->print_it
= print_it_done
;
2710 case WP_VALUE_CHANGED
:
2714 case WP_VALUE_NOT_CHANGED
:
2716 bs
->print_it
= print_it_noop
;
2723 /* Error from catch_errors. */
2724 printf_filtered (_("Watchpoint %d deleted.\n"), b
->number
);
2725 if (b
->related_breakpoint
)
2726 b
->related_breakpoint
->disposition
= disp_del_at_next_stop
;
2727 b
->disposition
= disp_del_at_next_stop
;
2728 /* We've already printed what needs to be printed. */
2729 bs
->print_it
= print_it_done
;
2735 else if (b
->type
== bp_read_watchpoint
||
2736 b
->type
== bp_access_watchpoint
)
2742 if (!target_stopped_data_address (¤t_target
, &addr
))
2744 for (v
= b
->val_chain
; v
; v
= value_next (v
))
2746 if (VALUE_LVAL (v
) == lval_memory
2747 && ! value_lazy (v
))
2749 struct type
*vtype
= check_typedef (value_type (v
));
2751 if (v
== b
->val_chain
2752 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
2753 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
2757 vaddr
= VALUE_ADDRESS (v
) + value_offset (v
);
2758 /* Exact match not required. Within range is
2760 if (addr
>= vaddr
&&
2761 addr
< vaddr
+ TYPE_LENGTH (value_type (v
)))
2768 char *message
= xstrprintf ("Error evaluating expression for watchpoint %d\n",
2770 struct cleanup
*cleanups
= make_cleanup (xfree
, message
);
2771 int e
= catch_errors (watchpoint_check
, bs
, message
,
2773 do_cleanups (cleanups
);
2777 /* We've already printed what needs to be printed. */
2778 bs
->print_it
= print_it_done
;
2781 case WP_VALUE_CHANGED
:
2782 if (b
->type
== bp_read_watchpoint
)
2784 /* Don't stop: read watchpoints shouldn't fire if
2785 the value has changed. This is for targets
2786 which cannot set read-only watchpoints. */
2787 bs
->print_it
= print_it_noop
;
2793 case WP_VALUE_NOT_CHANGED
:
2800 /* Error from catch_errors. */
2801 printf_filtered (_("Watchpoint %d deleted.\n"), b
->number
);
2802 if (b
->related_breakpoint
)
2803 b
->related_breakpoint
->disposition
= disp_del_at_next_stop
;
2804 b
->disposition
= disp_del_at_next_stop
;
2805 /* We've already printed what needs to be printed. */
2806 bs
->print_it
= print_it_done
;
2810 else /* found == 0 */
2812 /* This is a case where some watchpoint(s) triggered,
2813 but not at the address of this watchpoint (FOUND
2814 was left zero). So don't print anything for this
2816 bs
->print_it
= print_it_noop
;
2823 /* By definition, an encountered breakpoint is a triggered
2827 real_breakpoint
= 1;
2830 if (frame_id_p (b
->frame_id
)
2831 && !frame_id_eq (b
->frame_id
, get_frame_id (get_current_frame ())))
2835 int value_is_zero
= 0;
2839 /* Need to select the frame, with all that implies
2840 so that the conditions will have the right context. */
2841 select_frame (get_current_frame ());
2843 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2844 "Error in testing breakpoint condition:\n",
2846 /* FIXME-someday, should give breakpoint # */
2849 if (b
->cond
&& value_is_zero
)
2852 /* Don't consider this a hit. */
2855 else if (b
->thread
!= -1 && b
->thread
!= thread_id
)
2858 /* Don't consider this a hit. */
2861 else if (b
->ignore_count
> 0)
2864 annotate_ignore_count_change ();
2869 /* We will stop here */
2870 if (b
->disposition
== disp_disable
)
2871 b
->enable_state
= bp_disabled
;
2874 bs
->commands
= b
->commands
;
2876 (strcmp ("silent", bs
->commands
->line
) == 0
2877 || (xdb_commands
&& strcmp ("Q", bs
->commands
->line
) == 0)))
2879 bs
->commands
= bs
->commands
->next
;
2882 bs
->commands
= copy_command_lines (bs
->commands
);
2885 /* Print nothing for this entry if we dont stop or if we dont print. */
2886 if (bs
->stop
== 0 || bs
->print
== 0)
2887 bs
->print_it
= print_it_noop
;
2890 bs
->next
= NULL
; /* Terminate the chain */
2891 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2893 /* The value of a hardware watchpoint hasn't changed, but the
2894 intermediate memory locations we are watching may have. */
2895 if (bs
&& !bs
->stop
&&
2896 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2897 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2898 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2900 remove_breakpoints ();
2901 insert_breakpoints ();
2906 /* Tell what to do about this bpstat. */
2908 bpstat_what (bpstat bs
)
2910 /* Classify each bpstat as one of the following. */
2913 /* This bpstat element has no effect on the main_action. */
2916 /* There was a watchpoint, stop but don't print. */
2919 /* There was a watchpoint, stop and print. */
2922 /* There was a breakpoint but we're not stopping. */
2925 /* There was a breakpoint, stop but don't print. */
2928 /* There was a breakpoint, stop and print. */
2931 /* We hit the longjmp breakpoint. */
2934 /* We hit the longjmp_resume breakpoint. */
2937 /* We hit the step_resume breakpoint. */
2940 /* We hit the through_sigtramp breakpoint. */
2943 /* We hit the shared library event breakpoint. */
2946 /* We caught a shared library event. */
2949 /* This is just used to count how many enums there are. */
2953 /* Here is the table which drives this routine. So that we can
2954 format it pretty, we define some abbreviations for the
2955 enum bpstat_what codes. */
2956 #define kc BPSTAT_WHAT_KEEP_CHECKING
2957 #define ss BPSTAT_WHAT_STOP_SILENT
2958 #define sn BPSTAT_WHAT_STOP_NOISY
2959 #define sgl BPSTAT_WHAT_SINGLE
2960 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2961 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2962 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2963 #define sr BPSTAT_WHAT_STEP_RESUME
2964 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2965 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2966 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2968 /* "Can't happen." Might want to print an error message.
2969 abort() is not out of the question, but chances are GDB is just
2970 a bit confused, not unusable. */
2971 #define err BPSTAT_WHAT_STOP_NOISY
2973 /* Given an old action and a class, come up with a new action. */
2974 /* One interesting property of this table is that wp_silent is the same
2975 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2976 after stopping, the check for whether to step over a breakpoint
2977 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2978 reference to how we stopped. We retain separate wp_silent and
2979 bp_silent codes in case we want to change that someday.
2981 Another possibly interesting property of this table is that
2982 there's a partial ordering, priority-like, of the actions. Once
2983 you've decided that some action is appropriate, you'll never go
2984 back and decide something of a lower priority is better. The
2987 kc < clr sgl shl shlr slr sn sr ss ts
2988 sgl < clrs shl shlr slr sn sr ss ts
2989 slr < err shl shlr sn sr ss ts
2990 clr < clrs err shl shlr sn sr ss ts
2991 clrs < err shl shlr sn sr ss ts
2992 ss < shl shlr sn sr ts
2999 What I think this means is that we don't need a damned table
3000 here. If you just put the rows and columns in the right order,
3001 it'd look awfully regular. We could simply walk the bpstat list
3002 and choose the highest priority action we find, with a little
3003 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
3004 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
3005 is messy anyway). */
3007 /* step_resume entries: a step resume breakpoint overrides another
3008 breakpoint of signal handling (see comment in wait_for_inferior
3009 at where we set the step_resume breakpoint). */
3010 /* We handle the through_sigtramp_breakpoint the same way; having both
3011 one of those and a step_resume_breakpoint is probably very rare (?). */
3013 static const enum bpstat_what_main_action
3014 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
3017 /* kc ss sn sgl slr clr clrs sr ts shl shlr
3020 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
3022 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
3024 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
3026 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
3028 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
3030 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
3032 {slr
, ss
, sn
, slr
, slr
, err
, err
, sr
, ts
, shl
, shlr
},
3034 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
3036 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
3038 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
3040 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
3042 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
3057 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
3058 struct bpstat_what retval
;
3060 retval
.call_dummy
= 0;
3061 for (; bs
!= NULL
; bs
= bs
->next
)
3063 enum class bs_class
= no_effect
;
3064 if (bs
->breakpoint_at
== NULL
)
3065 /* I suspect this can happen if it was a momentary breakpoint
3066 which has since been deleted. */
3068 switch (bs
->breakpoint_at
->type
)
3074 case bp_hardware_breakpoint
:
3080 bs_class
= bp_noisy
;
3082 bs_class
= bp_silent
;
3085 bs_class
= bp_nostop
;
3088 case bp_hardware_watchpoint
:
3089 case bp_read_watchpoint
:
3090 case bp_access_watchpoint
:
3094 bs_class
= wp_noisy
;
3096 bs_class
= wp_silent
;
3099 /* There was a watchpoint, but we're not stopping.
3100 This requires no further action. */
3101 bs_class
= no_effect
;
3104 bs_class
= long_jump
;
3106 case bp_longjmp_resume
:
3107 bs_class
= long_resume
;
3109 case bp_step_resume
:
3112 bs_class
= step_resume
;
3115 /* It is for the wrong frame. */
3116 bs_class
= bp_nostop
;
3118 case bp_through_sigtramp
:
3119 bs_class
= through_sig
;
3121 case bp_watchpoint_scope
:
3122 bs_class
= bp_nostop
;
3124 case bp_shlib_event
:
3125 bs_class
= shlib_event
;
3127 case bp_thread_event
:
3128 case bp_overlay_event
:
3129 bs_class
= bp_nostop
;
3132 case bp_catch_unload
:
3133 /* Only if this catchpoint triggered should we cause the
3134 step-out-of-dld behaviour. Otherwise, we ignore this
3137 bs_class
= catch_shlib_event
;
3139 bs_class
= no_effect
;
3142 case bp_catch_vfork
:
3147 bs_class
= bp_noisy
;
3149 bs_class
= bp_silent
;
3152 /* There was a catchpoint, but we're not stopping.
3153 This requires no further action. */
3154 bs_class
= no_effect
;
3156 case bp_catch_catch
:
3157 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
3158 bs_class
= bp_nostop
;
3160 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
3162 case bp_catch_throw
:
3163 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
3164 bs_class
= bp_nostop
;
3166 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
3169 /* Make sure the action is stop (silent or noisy),
3170 so infrun.c pops the dummy frame. */
3171 bs_class
= bp_silent
;
3172 retval
.call_dummy
= 1;
3175 current_action
= table
[(int) bs_class
][(int) current_action
];
3177 retval
.main_action
= current_action
;
3181 /* Nonzero if we should step constantly (e.g. watchpoints on machines
3182 without hardware support). This isn't related to a specific bpstat,
3183 just to things like whether watchpoints are set. */
3186 bpstat_should_step (void)
3188 struct breakpoint
*b
;
3190 if (breakpoint_enabled (b
) && b
->type
== bp_watchpoint
)
3195 /* Nonzero if there are enabled hardware watchpoints. */
3197 bpstat_have_active_hw_watchpoints (void)
3199 struct bp_location
*bpt
;
3200 ALL_BP_LOCATIONS (bpt
)
3201 if (breakpoint_enabled (bpt
->owner
)
3203 && bpt
->loc_type
== bp_loc_hardware_watchpoint
)
3209 /* Given a bpstat that records zero or more triggered eventpoints, this
3210 function returns another bpstat which contains only the catchpoints
3211 on that first list, if any. */
3213 bpstat_get_triggered_catchpoints (bpstat ep_list
, bpstat
*cp_list
)
3215 struct bpstats root_bs
[1];
3216 bpstat bs
= root_bs
;
3217 struct breakpoint
*ep
;
3220 bpstat_clear (cp_list
);
3221 root_bs
->next
= NULL
;
3223 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
3225 /* Is this eventpoint a catchpoint? If not, ignore it. */
3226 ep
= ep_list
->breakpoint_at
;
3229 if ((ep
->type
!= bp_catch_load
) &&
3230 (ep
->type
!= bp_catch_unload
) &&
3231 (ep
->type
!= bp_catch_catch
) &&
3232 (ep
->type
!= bp_catch_throw
))
3233 /* pai: (temp) ADD fork/vfork here!! */
3236 /* Yes; add it to the list. */
3237 bs
= bpstat_alloc (ep
, bs
);
3242 #if defined(SOLIB_ADD)
3243 /* Also, for each triggered catchpoint, tag it with the name of
3244 the library that caused this trigger. (We copy the name now,
3245 because it's only guaranteed to be available NOW, when the
3246 catchpoint triggers. Clients who may wish to know the name
3247 later must get it from the catchpoint itself.) */
3248 if (ep
->triggered_dll_pathname
!= NULL
)
3249 xfree (ep
->triggered_dll_pathname
);
3250 if (ep
->type
== bp_catch_load
)
3251 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (
3252 PIDGET (inferior_ptid
));
3254 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (
3255 PIDGET (inferior_ptid
));
3257 dll_pathname
= NULL
;
3261 ep
->triggered_dll_pathname
= (char *)
3262 xmalloc (strlen (dll_pathname
) + 1);
3263 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
3266 ep
->triggered_dll_pathname
= NULL
;
3272 /* Print B to gdb_stdout. */
3274 print_one_breakpoint (struct breakpoint
*b
,
3275 CORE_ADDR
*last_addr
)
3277 struct command_line
*l
;
3279 struct ep_type_description
3284 static struct ep_type_description bptypes
[] =
3286 {bp_none
, "?deleted?"},
3287 {bp_breakpoint
, "breakpoint"},
3288 {bp_hardware_breakpoint
, "hw breakpoint"},
3289 {bp_until
, "until"},
3290 {bp_finish
, "finish"},
3291 {bp_watchpoint
, "watchpoint"},
3292 {bp_hardware_watchpoint
, "hw watchpoint"},
3293 {bp_read_watchpoint
, "read watchpoint"},
3294 {bp_access_watchpoint
, "acc watchpoint"},
3295 {bp_longjmp
, "longjmp"},
3296 {bp_longjmp_resume
, "longjmp resume"},
3297 {bp_step_resume
, "step resume"},
3298 {bp_through_sigtramp
, "sigtramp"},
3299 {bp_watchpoint_scope
, "watchpoint scope"},
3300 {bp_call_dummy
, "call dummy"},
3301 {bp_shlib_event
, "shlib events"},
3302 {bp_thread_event
, "thread events"},
3303 {bp_overlay_event
, "overlay events"},
3304 {bp_catch_load
, "catch load"},
3305 {bp_catch_unload
, "catch unload"},
3306 {bp_catch_fork
, "catch fork"},
3307 {bp_catch_vfork
, "catch vfork"},
3308 {bp_catch_exec
, "catch exec"},
3309 {bp_catch_catch
, "catch catch"},
3310 {bp_catch_throw
, "catch throw"}
3313 static char *bpdisps
[] =
3314 {"del", "dstp", "dis", "keep"};
3315 static char bpenables
[] = "nynny";
3316 char wrap_indent
[80];
3317 struct ui_stream
*stb
= ui_out_stream_new (uiout
);
3318 struct cleanup
*old_chain
= make_cleanup_ui_out_stream_delete (stb
);
3319 struct cleanup
*bkpt_chain
;
3322 bkpt_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "bkpt");
3326 ui_out_field_int (uiout
, "number", b
->number
);
3330 if (((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
3331 || ((int) b
->type
!= bptypes
[(int) b
->type
].type
))
3332 internal_error (__FILE__
, __LINE__
,
3333 _("bptypes table does not describe type #%d."),
3335 ui_out_field_string (uiout
, "type", bptypes
[(int) b
->type
].description
);
3339 ui_out_field_string (uiout
, "disp", bpdisps
[(int) b
->disposition
]);
3343 ui_out_field_fmt (uiout
, "enabled", "%c", bpenables
[(int) b
->enable_state
]);
3344 ui_out_spaces (uiout
, 2);
3347 strcpy (wrap_indent
, " ");
3350 if (TARGET_ADDR_BIT
<= 32)
3351 strcat (wrap_indent
, " ");
3353 strcat (wrap_indent
, " ");
3356 if (b
->ops
!= NULL
&& b
->ops
->print_one
!= NULL
)
3357 b
->ops
->print_one (b
, last_addr
);
3362 internal_error (__FILE__
, __LINE__
,
3363 _("print_one_breakpoint: bp_none encountered\n"));
3367 case bp_hardware_watchpoint
:
3368 case bp_read_watchpoint
:
3369 case bp_access_watchpoint
:
3370 /* Field 4, the address, is omitted (which makes the columns
3371 not line up too nicely with the headers, but the effect
3372 is relatively readable). */
3374 ui_out_field_skip (uiout
, "addr");
3376 print_expression (b
->exp
, stb
->stream
);
3377 ui_out_field_stream (uiout
, "what", stb
);
3381 case bp_catch_unload
:
3382 /* Field 4, the address, is omitted (which makes the columns
3383 not line up too nicely with the headers, but the effect
3384 is relatively readable). */
3386 ui_out_field_skip (uiout
, "addr");
3388 if (b
->dll_pathname
== NULL
)
3390 ui_out_field_string (uiout
, "what", "<any library>");
3391 ui_out_spaces (uiout
, 1);
3395 ui_out_text (uiout
, "library \"");
3396 ui_out_field_string (uiout
, "what", b
->dll_pathname
);
3397 ui_out_text (uiout
, "\" ");
3402 case bp_catch_vfork
:
3403 /* Field 4, the address, is omitted (which makes the columns
3404 not line up too nicely with the headers, but the effect
3405 is relatively readable). */
3407 ui_out_field_skip (uiout
, "addr");
3409 if (b
->forked_inferior_pid
!= 0)
3411 ui_out_text (uiout
, "process ");
3412 ui_out_field_int (uiout
, "what", b
->forked_inferior_pid
);
3413 ui_out_spaces (uiout
, 1);
3417 /* Field 4, the address, is omitted (which makes the columns
3418 not line up too nicely with the headers, but the effect
3419 is relatively readable). */
3421 ui_out_field_skip (uiout
, "addr");
3423 if (b
->exec_pathname
!= NULL
)
3425 ui_out_text (uiout
, "program \"");
3426 ui_out_field_string (uiout
, "what", b
->exec_pathname
);
3427 ui_out_text (uiout
, "\" ");
3431 case bp_catch_catch
:
3432 /* Field 4, the address, is omitted (which makes the columns
3433 not line up too nicely with the headers, but the effect
3434 is relatively readable). */
3436 ui_out_field_skip (uiout
, "addr");
3438 ui_out_field_string (uiout
, "what", "exception catch");
3439 ui_out_spaces (uiout
, 1);
3442 case bp_catch_throw
:
3443 /* Field 4, the address, is omitted (which makes the columns
3444 not line up too nicely with the headers, but the effect
3445 is relatively readable). */
3447 ui_out_field_skip (uiout
, "addr");
3449 ui_out_field_string (uiout
, "what", "exception throw");
3450 ui_out_spaces (uiout
, 1);
3454 case bp_hardware_breakpoint
:
3458 case bp_longjmp_resume
:
3459 case bp_step_resume
:
3460 case bp_through_sigtramp
:
3461 case bp_watchpoint_scope
:
3463 case bp_shlib_event
:
3464 case bp_thread_event
:
3465 case bp_overlay_event
:
3470 ui_out_field_string (uiout
, "addr", "<PENDING>");
3472 ui_out_field_core_addr (uiout
, "addr", b
->loc
->address
);
3475 *last_addr
= b
->loc
->address
;
3478 sym
= find_pc_sect_function (b
->loc
->address
, b
->loc
->section
);
3481 ui_out_text (uiout
, "in ");
3482 ui_out_field_string (uiout
, "func",
3483 SYMBOL_PRINT_NAME (sym
));
3484 ui_out_wrap_hint (uiout
, wrap_indent
);
3485 ui_out_text (uiout
, " at ");
3487 ui_out_field_string (uiout
, "file", b
->source_file
);
3488 ui_out_text (uiout
, ":");
3489 ui_out_field_int (uiout
, "line", b
->line_number
);
3491 else if (b
->pending
)
3493 ui_out_field_string (uiout
, "pending", b
->addr_string
);
3497 print_address_symbolic (b
->loc
->address
, stb
->stream
, demangle
, "");
3498 ui_out_field_stream (uiout
, "at", stb
);
3503 if (b
->thread
!= -1)
3505 /* FIXME: This seems to be redundant and lost here; see the
3506 "stop only in" line a little further down. */
3507 ui_out_text (uiout
, " thread ");
3508 ui_out_field_int (uiout
, "thread", b
->thread
);
3511 ui_out_text (uiout
, "\n");
3513 if (frame_id_p (b
->frame_id
))
3516 ui_out_text (uiout
, "\tstop only in stack frame at ");
3517 /* FIXME: cagney/2002-12-01: Shouldn't be poeking around inside
3519 ui_out_field_core_addr (uiout
, "frame", b
->frame_id
.stack_addr
);
3520 ui_out_text (uiout
, "\n");
3526 ui_out_text (uiout
, "\tstop only if ");
3527 print_expression (b
->cond
, stb
->stream
);
3528 ui_out_field_stream (uiout
, "cond", stb
);
3529 ui_out_text (uiout
, "\n");
3532 if (b
->pending
&& b
->cond_string
)
3535 ui_out_text (uiout
, "\tstop only if ");
3536 ui_out_field_string (uiout
, "cond", b
->cond_string
);
3537 ui_out_text (uiout
, "\n");
3540 if (b
->thread
!= -1)
3542 /* FIXME should make an annotation for this */
3543 ui_out_text (uiout
, "\tstop only in thread ");
3544 ui_out_field_int (uiout
, "thread", b
->thread
);
3545 ui_out_text (uiout
, "\n");
3548 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3550 /* FIXME should make an annotation for this */
3551 if (ep_is_catchpoint (b
))
3552 ui_out_text (uiout
, "\tcatchpoint");
3554 ui_out_text (uiout
, "\tbreakpoint");
3555 ui_out_text (uiout
, " already hit ");
3556 ui_out_field_int (uiout
, "times", b
->hit_count
);
3557 if (b
->hit_count
== 1)
3558 ui_out_text (uiout
, " time\n");
3560 ui_out_text (uiout
, " times\n");
3563 /* Output the count also if it is zero, but only if this is
3564 mi. FIXME: Should have a better test for this. */
3565 if (ui_out_is_mi_like_p (uiout
))
3566 if (show_breakpoint_hit_counts
&& b
->hit_count
== 0)
3567 ui_out_field_int (uiout
, "times", b
->hit_count
);
3569 if (b
->ignore_count
)
3572 ui_out_text (uiout
, "\tignore next ");
3573 ui_out_field_int (uiout
, "ignore", b
->ignore_count
);
3574 ui_out_text (uiout
, " hits\n");
3577 if ((l
= b
->commands
))
3579 struct cleanup
*script_chain
;
3582 script_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "script");
3583 print_command_lines (uiout
, l
, 4);
3584 do_cleanups (script_chain
);
3586 do_cleanups (bkpt_chain
);
3587 do_cleanups (old_chain
);
3590 struct captured_breakpoint_query_args
3596 do_captured_breakpoint_query (struct ui_out
*uiout
, void *data
)
3598 struct captured_breakpoint_query_args
*args
= data
;
3599 struct breakpoint
*b
;
3600 CORE_ADDR dummy_addr
= 0;
3603 if (args
->bnum
== b
->number
)
3605 print_one_breakpoint (b
, &dummy_addr
);
3613 gdb_breakpoint_query (struct ui_out
*uiout
, int bnum
, char **error_message
)
3615 struct captured_breakpoint_query_args args
;
3617 /* For the moment we don't trust print_one_breakpoint() to not throw
3619 return catch_exceptions_with_msg (uiout
, do_captured_breakpoint_query
, &args
,
3620 error_message
, RETURN_MASK_ALL
);
3623 /* Return non-zero if B is user settable (breakpoints, watchpoints,
3624 catchpoints, et.al.). */
3627 user_settable_breakpoint (const struct breakpoint
*b
)
3629 return (b
->type
== bp_breakpoint
3630 || b
->type
== bp_catch_load
3631 || b
->type
== bp_catch_unload
3632 || b
->type
== bp_catch_fork
3633 || b
->type
== bp_catch_vfork
3634 || b
->type
== bp_catch_exec
3635 || b
->type
== bp_catch_catch
3636 || b
->type
== bp_catch_throw
3637 || b
->type
== bp_hardware_breakpoint
3638 || b
->type
== bp_watchpoint
3639 || b
->type
== bp_read_watchpoint
3640 || b
->type
== bp_access_watchpoint
3641 || b
->type
== bp_hardware_watchpoint
);
3644 /* Print information on user settable breakpoint (watchpoint, etc)
3645 number BNUM. If BNUM is -1 print all user settable breakpoints.
3646 If ALLFLAG is non-zero, include non- user settable breakpoints. */
3649 breakpoint_1 (int bnum
, int allflag
)
3651 struct breakpoint
*b
;
3652 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
3653 int nr_printable_breakpoints
;
3654 struct cleanup
*bkpttbl_chain
;
3656 /* Compute the number of rows in the table. */
3657 nr_printable_breakpoints
= 0;
3660 || bnum
== b
->number
)
3662 if (allflag
|| user_settable_breakpoint (b
))
3663 nr_printable_breakpoints
++;
3668 = make_cleanup_ui_out_table_begin_end (uiout
, 6, nr_printable_breakpoints
,
3672 = make_cleanup_ui_out_table_begin_end (uiout
, 5, nr_printable_breakpoints
,
3675 if (nr_printable_breakpoints
> 0)
3676 annotate_breakpoints_headers ();
3677 if (nr_printable_breakpoints
> 0)
3679 ui_out_table_header (uiout
, 3, ui_left
, "number", "Num"); /* 1 */
3680 if (nr_printable_breakpoints
> 0)
3682 ui_out_table_header (uiout
, 14, ui_left
, "type", "Type"); /* 2 */
3683 if (nr_printable_breakpoints
> 0)
3685 ui_out_table_header (uiout
, 4, ui_left
, "disp", "Disp"); /* 3 */
3686 if (nr_printable_breakpoints
> 0)
3688 ui_out_table_header (uiout
, 3, ui_left
, "enabled", "Enb"); /* 4 */
3691 if (nr_printable_breakpoints
> 0)
3693 if (TARGET_ADDR_BIT
<= 32)
3694 ui_out_table_header (uiout
, 10, ui_left
, "addr", "Address");/* 5 */
3696 ui_out_table_header (uiout
, 18, ui_left
, "addr", "Address");/* 5 */
3698 if (nr_printable_breakpoints
> 0)
3700 ui_out_table_header (uiout
, 40, ui_noalign
, "what", "What"); /* 6 */
3701 ui_out_table_body (uiout
);
3702 if (nr_printable_breakpoints
> 0)
3703 annotate_breakpoints_table ();
3707 || bnum
== b
->number
)
3709 /* We only print out user settable breakpoints unless the
3711 if (allflag
|| user_settable_breakpoint (b
))
3712 print_one_breakpoint (b
, &last_addr
);
3715 do_cleanups (bkpttbl_chain
);
3717 if (nr_printable_breakpoints
== 0)
3720 ui_out_message (uiout
, 0, "No breakpoints or watchpoints.\n");
3722 ui_out_message (uiout
, 0, "No breakpoint or watchpoint number %d.\n",
3727 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3728 that a comparison of an unsigned with -1 is always false. */
3729 if (last_addr
!= (CORE_ADDR
) -1)
3730 set_next_address (last_addr
);
3733 /* FIXME? Should this be moved up so that it is only called when
3734 there have been breakpoints? */
3735 annotate_breakpoints_table_end ();
3739 breakpoints_info (char *bnum_exp
, int from_tty
)
3744 bnum
= parse_and_eval_long (bnum_exp
);
3746 breakpoint_1 (bnum
, 0);
3750 maintenance_info_breakpoints (char *bnum_exp
, int from_tty
)
3755 bnum
= parse_and_eval_long (bnum_exp
);
3757 breakpoint_1 (bnum
, 1);
3760 /* Print a message describing any breakpoints set at PC. */
3763 describe_other_breakpoints (CORE_ADDR pc
, asection
*section
)
3766 struct breakpoint
*b
;
3769 if (b
->loc
->address
== pc
) /* address match / overlay match */
3770 if (!b
->pending
&& (!overlay_debugging
|| b
->loc
->section
== section
))
3775 printf_filtered (_("Note: breakpoint "));
3776 else /* if (others == ???) */
3777 printf_filtered (_("Note: breakpoints "));
3779 if (b
->loc
->address
== pc
) /* address match / overlay match */
3780 if (!b
->pending
&& (!overlay_debugging
|| b
->loc
->section
== section
))
3783 printf_filtered ("%d%s%s ",
3785 ((b
->enable_state
== bp_disabled
||
3786 b
->enable_state
== bp_shlib_disabled
||
3787 b
->enable_state
== bp_call_disabled
)
3789 : b
->enable_state
== bp_permanent
3793 : ((others
== 1) ? " and" : ""));
3795 printf_filtered (_("also set at pc "));
3796 deprecated_print_address_numeric (pc
, 1, gdb_stdout
);
3797 printf_filtered (".\n");
3801 /* Set the default place to put a breakpoint
3802 for the `break' command with no arguments. */
3805 set_default_breakpoint (int valid
, CORE_ADDR addr
, struct symtab
*symtab
,
3808 default_breakpoint_valid
= valid
;
3809 default_breakpoint_address
= addr
;
3810 default_breakpoint_symtab
= symtab
;
3811 default_breakpoint_line
= line
;
3814 /* Return true iff it is meaningful to use the address member of
3815 BPT. For some breakpoint types, the address member is irrelevant
3816 and it makes no sense to attempt to compare it to other addresses
3817 (or use it for any other purpose either).
3819 More specifically, each of the following breakpoint types will always
3820 have a zero valued address and we don't want check_duplicates() to mark
3821 breakpoints of any of these types to be a duplicate of an actual
3822 breakpoint at address zero:
3825 bp_hardware_watchpoint
3827 bp_access_watchpoint
3834 breakpoint_address_is_meaningful (struct breakpoint
*bpt
)
3836 enum bptype type
= bpt
->type
;
3838 return (type
!= bp_watchpoint
3839 && type
!= bp_hardware_watchpoint
3840 && type
!= bp_read_watchpoint
3841 && type
!= bp_access_watchpoint
3842 && type
!= bp_catch_exec
3843 && type
!= bp_longjmp_resume
3844 && type
!= bp_catch_fork
3845 && type
!= bp_catch_vfork
);
3848 /* Rescan breakpoints at the same address and section as BPT,
3849 marking the first one as "first" and any others as "duplicates".
3850 This is so that the bpt instruction is only inserted once.
3851 If we have a permanent breakpoint at the same place as BPT, make
3852 that one the official one, and the rest as duplicates. */
3855 check_duplicates (struct breakpoint
*bpt
)
3857 struct bp_location
*b
;
3859 struct bp_location
*perm_bp
= 0;
3860 CORE_ADDR address
= bpt
->loc
->address
;
3861 asection
*section
= bpt
->loc
->section
;
3863 if (! breakpoint_address_is_meaningful (bpt
))
3866 ALL_BP_LOCATIONS (b
)
3867 if (b
->owner
->enable_state
!= bp_disabled
3868 && b
->owner
->enable_state
!= bp_shlib_disabled
3869 && !b
->owner
->pending
3870 && b
->owner
->enable_state
!= bp_call_disabled
3871 && b
->address
== address
/* address / overlay match */
3872 && (!overlay_debugging
|| b
->section
== section
)
3873 && breakpoint_address_is_meaningful (b
->owner
))
3875 /* Have we found a permanent breakpoint? */
3876 if (b
->owner
->enable_state
== bp_permanent
)
3883 b
->duplicate
= count
> 1;
3886 /* If we found a permanent breakpoint at this address, go over the
3887 list again and declare all the other breakpoints there to be the
3891 perm_bp
->duplicate
= 0;
3893 /* Permanent breakpoint should always be inserted. */
3894 if (! perm_bp
->inserted
)
3895 internal_error (__FILE__
, __LINE__
,
3896 _("allegedly permanent breakpoint is not "
3897 "actually inserted"));
3899 ALL_BP_LOCATIONS (b
)
3902 if (b
->owner
->enable_state
!= bp_disabled
3903 && b
->owner
->enable_state
!= bp_shlib_disabled
3904 && !b
->owner
->pending
3905 && b
->owner
->enable_state
!= bp_call_disabled
3906 && b
->address
== address
/* address / overlay match */
3907 && (!overlay_debugging
|| b
->section
== section
)
3908 && breakpoint_address_is_meaningful (b
->owner
))
3911 internal_error (__FILE__
, __LINE__
,
3912 _("another breakpoint was inserted on top of "
3913 "a permanent breakpoint"));
3922 breakpoint_adjustment_warning (CORE_ADDR from_addr
, CORE_ADDR to_addr
,
3923 int bnum
, int have_bnum
)
3928 strcpy (astr1
, hex_string_custom ((unsigned long) from_addr
, 8));
3929 strcpy (astr2
, hex_string_custom ((unsigned long) to_addr
, 8));
3931 warning (_("Breakpoint %d address previously adjusted from %s to %s."),
3932 bnum
, astr1
, astr2
);
3934 warning (_("Breakpoint address adjusted from %s to %s."), astr1
, astr2
);
3937 /* Adjust a breakpoint's address to account for architectural constraints
3938 on breakpoint placement. Return the adjusted address. Note: Very
3939 few targets require this kind of adjustment. For most targets,
3940 this function is simply the identity function. */
3943 adjust_breakpoint_address (CORE_ADDR bpaddr
, enum bptype bptype
)
3945 if (!gdbarch_adjust_breakpoint_address_p (current_gdbarch
))
3947 /* Very few targets need any kind of breakpoint adjustment. */
3950 else if (bptype
== bp_watchpoint
3951 || bptype
== bp_hardware_watchpoint
3952 || bptype
== bp_read_watchpoint
3953 || bptype
== bp_access_watchpoint
3954 || bptype
== bp_catch_fork
3955 || bptype
== bp_catch_vfork
3956 || bptype
== bp_catch_exec
)
3958 /* Watchpoints and the various bp_catch_* eventpoints should not
3959 have their addresses modified. */
3964 CORE_ADDR adjusted_bpaddr
;
3966 /* Some targets have architectural constraints on the placement
3967 of breakpoint instructions. Obtain the adjusted address. */
3968 adjusted_bpaddr
= gdbarch_adjust_breakpoint_address (current_gdbarch
,
3971 /* An adjusted breakpoint address can significantly alter
3972 a user's expectations. Print a warning if an adjustment
3974 if (adjusted_bpaddr
!= bpaddr
)
3975 breakpoint_adjustment_warning (bpaddr
, adjusted_bpaddr
, 0, 0);
3977 return adjusted_bpaddr
;
3981 /* Allocate a struct bp_location. */
3983 static struct bp_location
*
3984 allocate_bp_location (struct breakpoint
*bpt
, enum bptype bp_type
)
3986 struct bp_location
*loc
, *loc_p
;
3988 loc
= xmalloc (sizeof (struct bp_location
));
3989 memset (loc
, 0, sizeof (*loc
));
3999 case bp_longjmp_resume
:
4000 case bp_step_resume
:
4001 case bp_through_sigtramp
:
4002 case bp_watchpoint_scope
:
4004 case bp_shlib_event
:
4005 case bp_thread_event
:
4006 case bp_overlay_event
:
4008 case bp_catch_unload
:
4009 loc
->loc_type
= bp_loc_software_breakpoint
;
4011 case bp_hardware_breakpoint
:
4012 loc
->loc_type
= bp_loc_hardware_breakpoint
;
4014 case bp_hardware_watchpoint
:
4015 case bp_read_watchpoint
:
4016 case bp_access_watchpoint
:
4017 loc
->loc_type
= bp_loc_hardware_watchpoint
;
4021 case bp_catch_vfork
:
4023 case bp_catch_catch
:
4024 case bp_catch_throw
:
4025 loc
->loc_type
= bp_loc_other
;
4028 internal_error (__FILE__
, __LINE__
, _("unknown breakpoint type"));
4031 /* Add this breakpoint to the end of the chain. */
4033 loc_p
= bp_location_chain
;
4035 bp_location_chain
= loc
;
4039 loc_p
= loc_p
->next
;
4046 /* set_raw_breakpoint() is a low level routine for allocating and
4047 partially initializing a breakpoint of type BPTYPE. The newly
4048 created breakpoint's address, section, source file name, and line
4049 number are provided by SAL. The newly created and partially
4050 initialized breakpoint is added to the breakpoint chain and
4051 is also returned as the value of this function.
4053 It is expected that the caller will complete the initialization of
4054 the newly created breakpoint struct as well as output any status
4055 information regarding the creation of a new breakpoint. In
4056 particular, set_raw_breakpoint() does NOT set the breakpoint
4057 number! Care should be taken to not allow an error() to occur
4058 prior to completing the initialization of the breakpoint. If this
4059 should happen, a bogus breakpoint will be left on the chain. */
4062 set_raw_breakpoint (struct symtab_and_line sal
, enum bptype bptype
)
4064 struct breakpoint
*b
, *b1
;
4066 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
4067 memset (b
, 0, sizeof (*b
));
4068 b
->loc
= allocate_bp_location (b
, bptype
);
4069 b
->loc
->requested_address
= sal
.pc
;
4070 b
->loc
->address
= adjust_breakpoint_address (b
->loc
->requested_address
,
4072 if (sal
.symtab
== NULL
)
4073 b
->source_file
= NULL
;
4075 b
->source_file
= savestring (sal
.symtab
->filename
,
4076 strlen (sal
.symtab
->filename
));
4077 b
->loc
->section
= sal
.section
;
4079 b
->language
= current_language
->la_language
;
4080 b
->input_radix
= input_radix
;
4082 b
->line_number
= sal
.line
;
4083 b
->enable_state
= bp_enabled
;
4086 b
->ignore_count
= 0;
4088 b
->frame_id
= null_frame_id
;
4089 b
->dll_pathname
= NULL
;
4090 b
->triggered_dll_pathname
= NULL
;
4091 b
->forked_inferior_pid
= 0;
4092 b
->exec_pathname
= NULL
;
4096 /* Add this breakpoint to the end of the chain
4097 so that a list of breakpoints will come out in order
4098 of increasing numbers. */
4100 b1
= breakpoint_chain
;
4102 breakpoint_chain
= b
;
4110 check_duplicates (b
);
4111 breakpoints_changed ();
4117 /* Note that the breakpoint object B describes a permanent breakpoint
4118 instruction, hard-wired into the inferior's code. */
4120 make_breakpoint_permanent (struct breakpoint
*b
)
4122 b
->enable_state
= bp_permanent
;
4124 /* By definition, permanent breakpoints are already present in the code. */
4125 b
->loc
->inserted
= 1;
4128 static struct breakpoint
*
4129 create_internal_breakpoint (CORE_ADDR address
, enum bptype type
)
4131 static int internal_breakpoint_number
= -1;
4132 struct symtab_and_line sal
;
4133 struct breakpoint
*b
;
4135 init_sal (&sal
); /* initialize to zeroes */
4138 sal
.section
= find_pc_overlay (sal
.pc
);
4140 b
= set_raw_breakpoint (sal
, type
);
4141 b
->number
= internal_breakpoint_number
--;
4142 b
->disposition
= disp_donttouch
;
4149 create_longjmp_breakpoint (char *func_name
)
4151 struct breakpoint
*b
;
4152 struct minimal_symbol
*m
;
4154 if (func_name
== NULL
)
4155 b
= create_internal_breakpoint (0, bp_longjmp_resume
);
4158 if ((m
= lookup_minimal_symbol_text (func_name
, NULL
)) == NULL
)
4161 b
= create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m
), bp_longjmp
);
4164 b
->enable_state
= bp_disabled
;
4167 b
->addr_string
= xstrdup (func_name
);
4170 /* Call this routine when stepping and nexting to enable a breakpoint
4171 if we do a longjmp(). When we hit that breakpoint, call
4172 set_longjmp_resume_breakpoint() to figure out where we are going. */
4175 enable_longjmp_breakpoint (void)
4177 struct breakpoint
*b
;
4180 if (b
->type
== bp_longjmp
)
4182 b
->enable_state
= bp_enabled
;
4183 check_duplicates (b
);
4188 disable_longjmp_breakpoint (void)
4190 struct breakpoint
*b
;
4193 if (b
->type
== bp_longjmp
4194 || b
->type
== bp_longjmp_resume
)
4196 b
->enable_state
= bp_disabled
;
4197 check_duplicates (b
);
4202 create_overlay_event_breakpoint (char *func_name
)
4204 struct breakpoint
*b
;
4205 struct minimal_symbol
*m
;
4207 if ((m
= lookup_minimal_symbol_text (func_name
, NULL
)) == NULL
)
4210 b
= create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m
),
4212 b
->addr_string
= xstrdup (func_name
);
4214 if (overlay_debugging
== ovly_auto
)
4216 b
->enable_state
= bp_enabled
;
4217 overlay_events_enabled
= 1;
4221 b
->enable_state
= bp_disabled
;
4222 overlay_events_enabled
= 0;
4227 enable_overlay_breakpoints (void)
4229 struct breakpoint
*b
;
4232 if (b
->type
== bp_overlay_event
)
4234 b
->enable_state
= bp_enabled
;
4235 check_duplicates (b
);
4236 overlay_events_enabled
= 1;
4241 disable_overlay_breakpoints (void)
4243 struct breakpoint
*b
;
4246 if (b
->type
== bp_overlay_event
)
4248 b
->enable_state
= bp_disabled
;
4249 check_duplicates (b
);
4250 overlay_events_enabled
= 0;
4255 create_thread_event_breakpoint (CORE_ADDR address
)
4257 struct breakpoint
*b
;
4259 b
= create_internal_breakpoint (address
, bp_thread_event
);
4261 b
->enable_state
= bp_enabled
;
4262 /* addr_string has to be used or breakpoint_re_set will delete me. */
4263 b
->addr_string
= xstrprintf ("*0x%s", paddr (b
->loc
->address
));
4269 remove_thread_event_breakpoints (void)
4271 struct breakpoint
*b
, *temp
;
4273 ALL_BREAKPOINTS_SAFE (b
, temp
)
4274 if (b
->type
== bp_thread_event
)
4275 delete_breakpoint (b
);
4278 struct captured_parse_breakpoint_args
4281 struct symtabs_and_lines
*sals_p
;
4282 char ***addr_string_p
;
4286 struct lang_and_radix
4292 /* Cleanup helper routine to restore the current language and
4295 do_restore_lang_radix_cleanup (void *old
)
4297 struct lang_and_radix
*p
= old
;
4298 set_language (p
->lang
);
4299 input_radix
= p
->radix
;
4302 /* Try and resolve a pending breakpoint. */
4304 resolve_pending_breakpoint (struct breakpoint
*b
)
4306 /* Try and reparse the breakpoint in case the shared library
4308 struct symtabs_and_lines sals
;
4309 struct symtab_and_line pending_sal
;
4310 char **cond_string
= (char **) NULL
;
4311 char *copy_arg
= b
->addr_string
;
4316 struct ui_file
*old_gdb_stderr
;
4317 struct lang_and_radix old_lr
;
4318 struct cleanup
*old_chain
;
4320 /* Set language, input-radix, then reissue breakpoint command.
4321 Ensure the language and input-radix are restored afterwards. */
4322 old_lr
.lang
= current_language
->la_language
;
4323 old_lr
.radix
= input_radix
;
4324 old_chain
= make_cleanup (do_restore_lang_radix_cleanup
, &old_lr
);
4326 set_language (b
->language
);
4327 input_radix
= b
->input_radix
;
4328 rc
= break_command_1 (b
->addr_string
, b
->flag
, b
->from_tty
, b
);
4330 if (rc
== GDB_RC_OK
)
4331 /* Pending breakpoint has been resolved. */
4332 printf_filtered (_("Pending breakpoint \"%s\" resolved\n"), b
->addr_string
);
4334 do_cleanups (old_chain
);
4339 remove_solib_event_breakpoints (void)
4341 struct breakpoint
*b
, *temp
;
4343 ALL_BREAKPOINTS_SAFE (b
, temp
)
4344 if (b
->type
== bp_shlib_event
)
4345 delete_breakpoint (b
);
4349 create_solib_event_breakpoint (CORE_ADDR address
)
4351 struct breakpoint
*b
;
4353 b
= create_internal_breakpoint (address
, bp_shlib_event
);
4357 /* Disable any breakpoints that are on code in shared libraries. Only
4358 apply to enabled breakpoints, disabled ones can just stay disabled. */
4361 disable_breakpoints_in_shlibs (int silent
)
4363 struct breakpoint
*b
;
4364 int disabled_shlib_breaks
= 0;
4366 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
4369 if (((b
->type
== bp_breakpoint
) || (b
->type
== bp_hardware_breakpoint
))
4370 && breakpoint_enabled (b
) && !b
->loc
->duplicate
4372 && PC_SOLIB (b
->loc
->address
)
4374 && solib_address (b
->loc
->address
)
4378 b
->enable_state
= bp_shlib_disabled
;
4381 if (!disabled_shlib_breaks
)
4383 target_terminal_ours_for_output ();
4384 warning (_("Temporarily disabling shared library breakpoints:"));
4386 disabled_shlib_breaks
= 1;
4387 warning (_("breakpoint #%d "), b
->number
);
4393 /* Disable any breakpoints that are in in an unloaded shared library. Only
4394 apply to enabled breakpoints, disabled ones can just stay disabled. */
4397 disable_breakpoints_in_unloaded_shlib (struct so_list
*solib
)
4399 struct breakpoint
*b
;
4400 int disabled_shlib_breaks
= 0;
4402 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
4405 if ((b
->loc
->loc_type
== bp_loc_hardware_breakpoint
4406 || b
->loc
->loc_type
== bp_loc_software_breakpoint
)
4407 && breakpoint_enabled (b
) && !b
->loc
->duplicate
)
4410 char *so_name
= PC_SOLIB (b
->loc
->address
);
4412 char *so_name
= solib_address (b
->loc
->address
);
4414 if (so_name
&& !strcmp (so_name
, solib
->so_name
))
4416 b
->enable_state
= bp_shlib_disabled
;
4417 /* At this point, we cannot rely on remove_breakpoint
4418 succeeding so we must mark the breakpoint as not inserted
4419 to prevent future errors occurring in remove_breakpoints. */
4420 b
->loc
->inserted
= 0;
4421 if (!disabled_shlib_breaks
)
4423 target_terminal_ours_for_output ();
4424 warning (_("Temporarily disabling breakpoints for unloaded shared library \"%s\""),
4427 disabled_shlib_breaks
= 1;
4433 /* Try to reenable any breakpoints in shared libraries. */
4435 re_enable_breakpoints_in_shlibs (void)
4437 struct breakpoint
*b
, *tmp
;
4439 ALL_BREAKPOINTS_SAFE (b
, tmp
)
4441 if (b
->enable_state
== bp_shlib_disabled
)
4445 /* Do not reenable the breakpoint if the shared library is
4446 still not mapped in. */
4448 lib
= PC_SOLIB (b
->loc
->address
);
4450 lib
= solib_address (b
->loc
->address
);
4452 if (lib
!= NULL
&& target_read_memory (b
->loc
->address
, buf
, 1) == 0)
4453 b
->enable_state
= bp_enabled
;
4455 else if (b
->pending
&& (b
->enable_state
== bp_enabled
))
4457 if (resolve_pending_breakpoint (b
) == GDB_RC_OK
)
4458 delete_breakpoint (b
);
4464 solib_load_unload_1 (char *hookname
, int tempflag
, char *dll_pathname
,
4465 char *cond_string
, enum bptype bp_kind
)
4467 struct breakpoint
*b
;
4468 struct symtabs_and_lines sals
;
4469 struct cleanup
*old_chain
;
4470 struct cleanup
*canonical_strings_chain
= NULL
;
4471 char *addr_start
= hookname
;
4472 char *addr_end
= NULL
;
4473 char **canonical
= (char **) NULL
;
4474 int thread
= -1; /* All threads. */
4476 /* Set a breakpoint on the specified hook. */
4477 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
,
4478 0, &canonical
, NULL
);
4479 addr_end
= hookname
;
4481 if (sals
.nelts
== 0)
4483 warning (_("Unable to set a breakpoint on dynamic linker callback.\n"
4484 "Suggest linking with /opt/langtools/lib/end.o.\n"
4485 "GDB will be unable to track shl_load/shl_unload calls."));
4488 if (sals
.nelts
!= 1)
4490 warning (_("Unable to set unique breakpoint on dynamic linker callback.\n"
4491 "GDB will be unable to track shl_load/shl_unload calls."));
4495 /* Make sure that all storage allocated in decode_line_1 gets freed
4496 in case the following errors out. */
4497 old_chain
= make_cleanup (xfree
, sals
.sals
);
4498 if (canonical
!= (char **) NULL
)
4500 make_cleanup (xfree
, canonical
);
4501 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
4502 if (canonical
[0] != NULL
)
4503 make_cleanup (xfree
, canonical
[0]);
4506 resolve_sal_pc (&sals
.sals
[0]);
4508 /* Remove the canonical strings from the cleanup, they are needed below. */
4509 if (canonical
!= (char **) NULL
)
4510 discard_cleanups (canonical_strings_chain
);
4512 b
= set_raw_breakpoint (sals
.sals
[0], bp_kind
);
4513 set_breakpoint_count (breakpoint_count
+ 1);
4514 b
->number
= breakpoint_count
;
4516 b
->cond_string
= (cond_string
== NULL
) ?
4517 NULL
: savestring (cond_string
, strlen (cond_string
));
4520 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
4521 b
->addr_string
= canonical
[0];
4522 else if (addr_start
)
4523 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4525 b
->enable_state
= bp_enabled
;
4526 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
4528 if (dll_pathname
== NULL
)
4529 b
->dll_pathname
= NULL
;
4532 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
4533 strcpy (b
->dll_pathname
, dll_pathname
);
4537 do_cleanups (old_chain
);
4541 create_solib_load_event_breakpoint (char *hookname
, int tempflag
,
4542 char *dll_pathname
, char *cond_string
)
4544 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
4545 cond_string
, bp_catch_load
);
4549 create_solib_unload_event_breakpoint (char *hookname
, int tempflag
,
4550 char *dll_pathname
, char *cond_string
)
4552 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
4553 cond_string
, bp_catch_unload
);
4557 create_fork_vfork_event_catchpoint (int tempflag
, char *cond_string
,
4558 enum bptype bp_kind
)
4560 struct symtab_and_line sal
;
4561 struct breakpoint
*b
;
4562 int thread
= -1; /* All threads. */
4569 b
= set_raw_breakpoint (sal
, bp_kind
);
4570 set_breakpoint_count (breakpoint_count
+ 1);
4571 b
->number
= breakpoint_count
;
4573 b
->cond_string
= (cond_string
== NULL
) ?
4574 NULL
: savestring (cond_string
, strlen (cond_string
));
4576 b
->addr_string
= NULL
;
4577 b
->enable_state
= bp_enabled
;
4578 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
4579 b
->forked_inferior_pid
= 0;
4585 create_fork_event_catchpoint (int tempflag
, char *cond_string
)
4587 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
4591 create_vfork_event_catchpoint (int tempflag
, char *cond_string
)
4593 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
4597 create_exec_event_catchpoint (int tempflag
, char *cond_string
)
4599 struct symtab_and_line sal
;
4600 struct breakpoint
*b
;
4601 int thread
= -1; /* All threads. */
4608 b
= set_raw_breakpoint (sal
, bp_catch_exec
);
4609 set_breakpoint_count (breakpoint_count
+ 1);
4610 b
->number
= breakpoint_count
;
4612 b
->cond_string
= (cond_string
== NULL
) ?
4613 NULL
: savestring (cond_string
, strlen (cond_string
));
4615 b
->addr_string
= NULL
;
4616 b
->enable_state
= bp_enabled
;
4617 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
4623 hw_breakpoint_used_count (void)
4625 struct breakpoint
*b
;
4630 if (b
->type
== bp_hardware_breakpoint
&& b
->enable_state
== bp_enabled
)
4638 hw_watchpoint_used_count (enum bptype type
, int *other_type_used
)
4640 struct breakpoint
*b
;
4643 *other_type_used
= 0;
4646 if (breakpoint_enabled (b
))
4648 if (b
->type
== type
)
4650 else if ((b
->type
== bp_hardware_watchpoint
||
4651 b
->type
== bp_read_watchpoint
||
4652 b
->type
== bp_access_watchpoint
))
4653 *other_type_used
= 1;
4659 /* Call this after hitting the longjmp() breakpoint. Use this to set
4660 a new breakpoint at the target of the jmp_buf.
4662 FIXME - This ought to be done by setting a temporary breakpoint
4663 that gets deleted automatically... */
4666 set_longjmp_resume_breakpoint (CORE_ADDR pc
, struct frame_id frame_id
)
4668 struct breakpoint
*b
;
4671 if (b
->type
== bp_longjmp_resume
)
4673 b
->loc
->requested_address
= pc
;
4674 b
->loc
->address
= adjust_breakpoint_address (b
->loc
->requested_address
,
4676 b
->enable_state
= bp_enabled
;
4677 b
->frame_id
= frame_id
;
4678 check_duplicates (b
);
4684 disable_watchpoints_before_interactive_call_start (void)
4686 struct breakpoint
*b
;
4690 if (((b
->type
== bp_watchpoint
)
4691 || (b
->type
== bp_hardware_watchpoint
)
4692 || (b
->type
== bp_read_watchpoint
)
4693 || (b
->type
== bp_access_watchpoint
)
4694 || ep_is_exception_catchpoint (b
))
4695 && breakpoint_enabled (b
))
4697 b
->enable_state
= bp_call_disabled
;
4698 check_duplicates (b
);
4704 enable_watchpoints_after_interactive_call_stop (void)
4706 struct breakpoint
*b
;
4710 if (((b
->type
== bp_watchpoint
)
4711 || (b
->type
== bp_hardware_watchpoint
)
4712 || (b
->type
== bp_read_watchpoint
)
4713 || (b
->type
== bp_access_watchpoint
)
4714 || ep_is_exception_catchpoint (b
))
4715 && (b
->enable_state
== bp_call_disabled
))
4717 b
->enable_state
= bp_enabled
;
4718 check_duplicates (b
);
4724 /* Set a breakpoint that will evaporate an end of command
4725 at address specified by SAL.
4726 Restrict it to frame FRAME if FRAME is nonzero. */
4729 set_momentary_breakpoint (struct symtab_and_line sal
, struct frame_id frame_id
,
4732 struct breakpoint
*b
;
4733 b
= set_raw_breakpoint (sal
, type
);
4734 b
->enable_state
= bp_enabled
;
4735 b
->disposition
= disp_donttouch
;
4736 b
->frame_id
= frame_id
;
4738 /* If we're debugging a multi-threaded program, then we
4739 want momentary breakpoints to be active in only a
4740 single thread of control. */
4741 if (in_thread_list (inferior_ptid
))
4742 b
->thread
= pid_to_thread_id (inferior_ptid
);
4748 /* Tell the user we have just set a breakpoint B. */
4751 mention (struct breakpoint
*b
)
4754 struct cleanup
*old_chain
, *ui_out_chain
;
4755 struct ui_stream
*stb
;
4757 stb
= ui_out_stream_new (uiout
);
4758 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
4760 /* FIXME: This is misplaced; mention() is called by things (like
4761 hitting a watchpoint) other than breakpoint creation. It should
4762 be possible to clean this up and at the same time replace the
4763 random calls to breakpoint_changed with this hook, as has already
4764 been done for deprecated_delete_breakpoint_hook and so on. */
4765 if (deprecated_create_breakpoint_hook
)
4766 deprecated_create_breakpoint_hook (b
);
4767 breakpoint_create_event (b
->number
);
4769 if (b
->ops
!= NULL
&& b
->ops
->print_mention
!= NULL
)
4770 b
->ops
->print_mention (b
);
4775 printf_filtered (_("(apparently deleted?) Eventpoint %d: "), b
->number
);
4778 ui_out_text (uiout
, "Watchpoint ");
4779 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "wpt");
4780 ui_out_field_int (uiout
, "number", b
->number
);
4781 ui_out_text (uiout
, ": ");
4782 print_expression (b
->exp
, stb
->stream
);
4783 ui_out_field_stream (uiout
, "exp", stb
);
4784 do_cleanups (ui_out_chain
);
4786 case bp_hardware_watchpoint
:
4787 ui_out_text (uiout
, "Hardware watchpoint ");
4788 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "wpt");
4789 ui_out_field_int (uiout
, "number", b
->number
);
4790 ui_out_text (uiout
, ": ");
4791 print_expression (b
->exp
, stb
->stream
);
4792 ui_out_field_stream (uiout
, "exp", stb
);
4793 do_cleanups (ui_out_chain
);
4795 case bp_read_watchpoint
:
4796 ui_out_text (uiout
, "Hardware read watchpoint ");
4797 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "hw-rwpt");
4798 ui_out_field_int (uiout
, "number", b
->number
);
4799 ui_out_text (uiout
, ": ");
4800 print_expression (b
->exp
, stb
->stream
);
4801 ui_out_field_stream (uiout
, "exp", stb
);
4802 do_cleanups (ui_out_chain
);
4804 case bp_access_watchpoint
:
4805 ui_out_text (uiout
, "Hardware access (read/write) watchpoint ");
4806 ui_out_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "hw-awpt");
4807 ui_out_field_int (uiout
, "number", b
->number
);
4808 ui_out_text (uiout
, ": ");
4809 print_expression (b
->exp
, stb
->stream
);
4810 ui_out_field_stream (uiout
, "exp", stb
);
4811 do_cleanups (ui_out_chain
);
4814 if (ui_out_is_mi_like_p (uiout
))
4819 printf_filtered (_("Breakpoint %d"), b
->number
);
4822 case bp_hardware_breakpoint
:
4823 if (ui_out_is_mi_like_p (uiout
))
4828 printf_filtered (_("Hardware assisted breakpoint %d"), b
->number
);
4832 case bp_catch_unload
:
4833 printf_filtered (_("Catchpoint %d (%s %s)"),
4835 (b
->type
== bp_catch_load
) ? "load" : "unload",
4836 (b
->dll_pathname
!= NULL
) ?
4837 b
->dll_pathname
: "<any library>");
4840 case bp_catch_vfork
:
4841 printf_filtered (_("Catchpoint %d (%s)"),
4843 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
4846 printf_filtered (_("Catchpoint %d (exec)"),
4849 case bp_catch_catch
:
4850 case bp_catch_throw
:
4851 printf_filtered (_("Catchpoint %d (%s)"),
4853 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
4859 case bp_longjmp_resume
:
4860 case bp_step_resume
:
4861 case bp_through_sigtramp
:
4863 case bp_watchpoint_scope
:
4864 case bp_shlib_event
:
4865 case bp_thread_event
:
4866 case bp_overlay_event
:
4872 /* i18n: cagney/2005-02-11: Below needs to be merged into a
4876 printf_filtered (_(" (%s) pending."), b
->addr_string
);
4880 if (addressprint
|| b
->source_file
== NULL
)
4882 printf_filtered (" at ");
4883 deprecated_print_address_numeric (b
->loc
->address
, 1, gdb_stdout
);
4886 printf_filtered (": file %s, line %d.",
4887 b
->source_file
, b
->line_number
);
4890 do_cleanups (old_chain
);
4891 if (ui_out_is_mi_like_p (uiout
))
4893 printf_filtered ("\n");
4897 /* Add SALS.nelts breakpoints to the breakpoint table. For each
4898 SALS.sal[i] breakpoint, include the corresponding ADDR_STRING[i],
4899 COND[i] and COND_STRING[i] values.
4901 The parameter PENDING_BP points to a pending breakpoint that is
4902 the basis of the breakpoints currently being created. The pending
4903 breakpoint may contain a separate condition string or commands
4904 that were added after the initial pending breakpoint was created.
4906 NOTE: If the function succeeds, the caller is expected to cleanup
4907 the arrays ADDR_STRING, COND_STRING, COND and SALS (but not the
4908 array contents). If the function fails (error() is called), the
4909 caller is expected to cleanups both the ADDR_STRING, COND_STRING,
4910 COND and SALS arrays and each of those arrays contents. */
4913 create_breakpoints (struct symtabs_and_lines sals
, char **addr_string
,
4914 struct expression
**cond
, char **cond_string
,
4915 enum bptype type
, enum bpdisp disposition
,
4916 int thread
, int ignore_count
, int from_tty
,
4917 struct breakpoint
*pending_bp
)
4919 if (type
== bp_hardware_breakpoint
)
4921 int i
= hw_breakpoint_used_count ();
4922 int target_resources_ok
=
4923 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4925 if (target_resources_ok
== 0)
4926 error (_("No hardware breakpoint support in the target."));
4927 else if (target_resources_ok
< 0)
4928 error (_("Hardware breakpoints used exceeds limit."));
4931 /* Now set all the breakpoints. */
4934 for (i
= 0; i
< sals
.nelts
; i
++)
4936 struct breakpoint
*b
;
4937 struct symtab_and_line sal
= sals
.sals
[i
];
4940 describe_other_breakpoints (sal
.pc
, sal
.section
);
4942 b
= set_raw_breakpoint (sal
, type
);
4943 set_breakpoint_count (breakpoint_count
+ 1);
4944 b
->number
= breakpoint_count
;
4948 b
->addr_string
= addr_string
[i
];
4950 /* addr_string has to be used or breakpoint_re_set will delete
4952 b
->addr_string
= xstrprintf ("*0x%s", paddr (b
->loc
->address
));
4953 b
->cond_string
= cond_string
[i
];
4954 b
->ignore_count
= ignore_count
;
4955 b
->enable_state
= bp_enabled
;
4956 b
->disposition
= disposition
;
4957 /* If resolving a pending breakpoint, a check must be made to see if
4958 the user has specified a new condition or commands for the
4959 breakpoint. A new condition will override any condition that was
4960 initially specified with the initial breakpoint command. */
4964 if (pending_bp
->cond_string
)
4966 arg
= pending_bp
->cond_string
;
4967 b
->cond_string
= savestring (arg
, strlen (arg
));
4968 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->loc
->address
), 0);
4970 error (_("Junk at end of pending breakpoint condition expression"));
4972 /* If there are commands associated with the breakpoint, they should
4974 if (pending_bp
->commands
)
4975 b
->commands
= copy_command_lines (pending_bp
->commands
);
4977 /* We have to copy over the ignore_count and thread as well. */
4978 b
->ignore_count
= pending_bp
->ignore_count
;
4979 b
->thread
= pending_bp
->thread
;
4986 /* Parse ARG which is assumed to be a SAL specification possibly
4987 followed by conditionals. On return, SALS contains an array of SAL
4988 addresses found. ADDR_STRING contains a vector of (canonical)
4989 address strings. ARG points to the end of the SAL. */
4992 parse_breakpoint_sals (char **address
,
4993 struct symtabs_and_lines
*sals
,
4994 char ***addr_string
,
4997 char *addr_start
= *address
;
4998 *addr_string
= NULL
;
4999 /* If no arg given, or if first arg is 'if ', use the default
5001 if ((*address
) == NULL
5002 || (strncmp ((*address
), "if", 2) == 0 && isspace ((*address
)[2])))
5004 if (default_breakpoint_valid
)
5006 struct symtab_and_line sal
;
5007 init_sal (&sal
); /* initialize to zeroes */
5008 sals
->sals
= (struct symtab_and_line
*)
5009 xmalloc (sizeof (struct symtab_and_line
));
5010 sal
.pc
= default_breakpoint_address
;
5011 sal
.line
= default_breakpoint_line
;
5012 sal
.symtab
= default_breakpoint_symtab
;
5013 sal
.section
= find_pc_overlay (sal
.pc
);
5014 sals
->sals
[0] = sal
;
5018 error (_("No default breakpoint address now."));
5022 /* Force almost all breakpoints to be in terms of the
5023 current_source_symtab (which is decode_line_1's default). This
5024 should produce the results we want almost all of the time while
5025 leaving default_breakpoint_* alone.
5026 ObjC: However, don't match an Objective-C method name which
5027 may have a '+' or '-' succeeded by a '[' */
5029 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
5031 if (default_breakpoint_valid
5033 || ((strchr ("+-", (*address
)[0]) != NULL
)
5034 && ((*address
)[1] != '['))))
5035 *sals
= decode_line_1 (address
, 1, default_breakpoint_symtab
,
5036 default_breakpoint_line
, addr_string
,
5039 *sals
= decode_line_1 (address
, 1, (struct symtab
*) NULL
, 0,
5040 addr_string
, not_found_ptr
);
5042 /* For any SAL that didn't have a canonical string, fill one in. */
5043 if (sals
->nelts
> 0 && *addr_string
== NULL
)
5044 *addr_string
= xcalloc (sals
->nelts
, sizeof (char **));
5045 if (addr_start
!= (*address
))
5048 for (i
= 0; i
< sals
->nelts
; i
++)
5050 /* Add the string if not present. */
5051 if ((*addr_string
)[i
] == NULL
)
5052 (*addr_string
)[i
] = savestring (addr_start
, (*address
) - addr_start
);
5058 /* Convert each SAL into a real PC. Verify that the PC can be
5059 inserted as a breakpoint. If it can't throw an error. */
5062 breakpoint_sals_to_pc (struct symtabs_and_lines
*sals
,
5066 for (i
= 0; i
< sals
->nelts
; i
++)
5068 resolve_sal_pc (&sals
->sals
[i
]);
5070 /* It's possible for the PC to be nonzero, but still an illegal
5071 value on some targets.
5073 For example, on HP-UX if you start gdb, and before running the
5074 inferior you try to set a breakpoint on a shared library function
5075 "foo" where the inferior doesn't call "foo" directly but does
5076 pass its address to another function call, then we do find a
5077 minimal symbol for the "foo", but it's address is invalid.
5078 (Appears to be an index into a table that the loader sets up
5079 when the inferior is run.)
5081 Give the target a chance to bless sals.sals[i].pc before we
5082 try to make a breakpoint for it. */
5083 #ifdef DEPRECATED_PC_REQUIRES_RUN_BEFORE_USE
5084 if (DEPRECATED_PC_REQUIRES_RUN_BEFORE_USE (sals
->sals
[i
].pc
))
5086 if (address
== NULL
)
5087 error (_("Cannot break without a running program."));
5089 error (_("Cannot break on %s without a running program."),
5097 do_captured_parse_breakpoint (struct ui_out
*ui
, void *data
)
5099 struct captured_parse_breakpoint_args
*args
= data
;
5101 parse_breakpoint_sals (args
->arg_p
, args
->sals_p
, args
->addr_string_p
,
5102 args
->not_found_ptr
);
5105 /* Set a breakpoint according to ARG (function, linenum or *address)
5106 flag: first bit : 0 non-temporary, 1 temporary.
5107 second bit : 0 normal breakpoint, 1 hardware breakpoint.
5109 PENDING_BP is non-NULL when this function is being called to resolve
5110 a pending breakpoint. */
5113 break_command_1 (char *arg
, int flag
, int from_tty
, struct breakpoint
*pending_bp
)
5115 struct gdb_exception e
;
5116 int tempflag
, hardwareflag
;
5117 struct symtabs_and_lines sals
;
5118 struct expression
**cond
= 0;
5119 struct symtab_and_line pending_sal
;
5120 char **cond_string
= (char **) NULL
;
5123 char *addr_start
= arg
;
5125 struct cleanup
*old_chain
;
5126 struct cleanup
*breakpoint_chain
= NULL
;
5127 struct captured_parse_breakpoint_args parse_args
;
5131 int ignore_count
= 0;
5134 hardwareflag
= flag
& BP_HARDWAREFLAG
;
5135 tempflag
= flag
& BP_TEMPFLAG
;
5141 parse_args
.arg_p
= &arg
;
5142 parse_args
.sals_p
= &sals
;
5143 parse_args
.addr_string_p
= &addr_string
;
5144 parse_args
.not_found_ptr
= ¬_found
;
5146 e
= catch_exception (uiout
, do_captured_parse_breakpoint
,
5147 &parse_args
, RETURN_MASK_ALL
);
5149 /* If caller is interested in rc value from parse, set value. */
5153 exception_print (gdb_stderr
, e
);
5158 case NOT_FOUND_ERROR
:
5159 /* If called to resolve pending breakpoint, just return
5164 exception_print (gdb_stderr
, e
);
5166 /* If pending breakpoint support is turned off, throw
5169 if (pending_break_support
== AUTO_BOOLEAN_FALSE
)
5170 deprecated_throw_reason (RETURN_ERROR
);
5172 /* If pending breakpoint support is auto query and the user
5173 selects no, then simply return the error code. */
5174 if (pending_break_support
== AUTO_BOOLEAN_AUTO
&&
5175 !nquery ("Make breakpoint pending on future shared library load? "))
5178 /* At this point, either the user was queried about setting
5179 a pending breakpoint and selected yes, or pending
5180 breakpoint behavior is on and thus a pending breakpoint
5181 is defaulted on behalf of the user. */
5182 copy_arg
= xstrdup (addr_start
);
5183 addr_string
= ©_arg
;
5185 sals
.sals
= &pending_sal
;
5190 exception_print (gdb_stderr
, e
);
5198 /* Create a chain of things that always need to be cleaned up. */
5199 old_chain
= make_cleanup (null_cleanup
, 0);
5203 /* Make sure that all storage allocated to SALS gets freed. */
5204 make_cleanup (xfree
, sals
.sals
);
5206 /* Cleanup the addr_string array but not its contents. */
5207 make_cleanup (xfree
, addr_string
);
5210 /* Allocate space for all the cond expressions. */
5211 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
5212 make_cleanup (xfree
, cond
);
5214 /* Allocate space for all the cond strings. */
5215 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
5216 make_cleanup (xfree
, cond_string
);
5218 /* ----------------------------- SNIP -----------------------------
5219 Anything added to the cleanup chain beyond this point is assumed
5220 to be part of a breakpoint. If the breakpoint create succeeds
5221 then the memory is not reclaimed. */
5222 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
5224 /* Mark the contents of the addr_string for cleanup. These go on
5225 the breakpoint_chain and only occure if the breakpoint create
5227 for (i
= 0; i
< sals
.nelts
; i
++)
5229 if (addr_string
[i
] != NULL
)
5230 make_cleanup (xfree
, addr_string
[i
]);
5233 /* Resolve all line numbers to PC's and verify that the addresses
5234 are ok for the target. */
5236 breakpoint_sals_to_pc (&sals
, addr_start
);
5238 /* Verify that condition can be parsed, before setting any
5239 breakpoints. Allocate a separate condition expression for each
5241 thread
= -1; /* No specific thread yet */
5244 for (i
= 0; i
< sals
.nelts
; i
++)
5251 char *cond_start
= NULL
;
5252 char *cond_end
= NULL
;
5253 while (*tok
== ' ' || *tok
== '\t')
5258 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
5261 toklen
= end_tok
- tok
;
5263 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
5265 tok
= cond_start
= end_tok
+ 1;
5266 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
),
5268 make_cleanup (xfree
, cond
[i
]);
5270 cond_string
[i
] = savestring (cond_start
,
5271 cond_end
- cond_start
);
5272 make_cleanup (xfree
, cond_string
[i
]);
5274 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
5280 thread
= strtol (tok
, &tok
, 0);
5282 error (_("Junk after thread keyword."));
5283 if (!valid_thread_id (thread
))
5284 error (_("Unknown thread %d."), thread
);
5287 error (_("Junk at end of arguments."));
5290 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
5291 hardwareflag
? bp_hardware_breakpoint
5293 tempflag
? disp_del
: disp_donttouch
,
5294 thread
, ignore_count
, from_tty
,
5299 struct symtab_and_line sal
;
5300 struct breakpoint
*b
;
5305 make_cleanup (xfree
, copy_arg
);
5307 b
= set_raw_breakpoint (sal
, hardwareflag
? bp_hardware_breakpoint
5309 set_breakpoint_count (breakpoint_count
+ 1);
5310 b
->number
= breakpoint_count
;
5313 b
->addr_string
= *addr_string
;
5314 b
->cond_string
= *cond_string
;
5315 b
->ignore_count
= ignore_count
;
5317 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
5318 b
->from_tty
= from_tty
;
5324 warning (_("Multiple breakpoints were set.\n"
5325 "Use the \"delete\" command to delete unwanted breakpoints."));
5326 /* That's it. Discard the cleanups for data inserted into the
5328 discard_cleanups (breakpoint_chain
);
5329 /* But cleanup everything else. */
5330 do_cleanups (old_chain
);
5335 /* Set a breakpoint of TYPE/DISPOSITION according to ARG (function,
5336 linenum or *address) with COND and IGNORE_COUNT. */
5338 struct captured_breakpoint_args
5349 do_captured_breakpoint (struct ui_out
*uiout
, void *data
)
5351 struct captured_breakpoint_args
*args
= data
;
5352 struct symtabs_and_lines sals
;
5353 struct expression
**cond
;
5354 struct cleanup
*old_chain
;
5355 struct cleanup
*breakpoint_chain
= NULL
;
5362 /* Parse the source and lines spec. Delay check that the expression
5363 didn't contain trailing garbage until after cleanups are in
5367 address_end
= args
->address
;
5369 parse_breakpoint_sals (&address_end
, &sals
, &addr_string
, 0);
5374 /* Create a chain of things at always need to be cleaned up. */
5375 old_chain
= make_cleanup (null_cleanup
, 0);
5377 /* Always have a addr_string array, even if it is empty. */
5378 make_cleanup (xfree
, addr_string
);
5380 /* Make sure that all storage allocated to SALS gets freed. */
5381 make_cleanup (xfree
, sals
.sals
);
5383 /* Allocate space for all the cond expressions. */
5384 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
5385 make_cleanup (xfree
, cond
);
5387 /* Allocate space for all the cond strings. */
5388 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
5389 make_cleanup (xfree
, cond_string
);
5391 /* ----------------------------- SNIP -----------------------------
5392 Anything added to the cleanup chain beyond this point is assumed
5393 to be part of a breakpoint. If the breakpoint create goes
5394 through then that memory is not cleaned up. */
5395 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
5397 /* Mark the contents of the addr_string for cleanup. These go on
5398 the breakpoint_chain and only occure if the breakpoint create
5400 for (i
= 0; i
< sals
.nelts
; i
++)
5402 if (addr_string
[i
] != NULL
)
5403 make_cleanup (xfree
, addr_string
[i
]);
5406 /* Wait until now before checking for garbage at the end of the
5407 address. That way cleanups can take care of freeing any
5409 if (*address_end
!= '\0')
5410 error (_("Garbage %s following breakpoint address"), address_end
);
5412 /* Resolve all line numbers to PC's. */
5413 breakpoint_sals_to_pc (&sals
, args
->address
);
5415 /* Verify that conditions can be parsed, before setting any
5417 for (i
= 0; i
< sals
.nelts
; i
++)
5419 if (args
->condition
!= NULL
)
5421 char *tok
= args
->condition
;
5422 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
5424 error (_("Garbage %s follows condition"), tok
);
5425 make_cleanup (xfree
, cond
[i
]);
5426 cond_string
[i
] = xstrdup (args
->condition
);
5430 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
5431 args
->hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
5432 args
->tempflag
? disp_del
: disp_donttouch
,
5433 args
->thread
, args
->ignore_count
, 0/*from-tty*/,
5434 NULL
/*pending_bp*/);
5436 /* That's it. Discard the cleanups for data inserted into the
5438 discard_cleanups (breakpoint_chain
);
5439 /* But cleanup everything else. */
5440 do_cleanups (old_chain
);
5445 gdb_breakpoint (char *address
, char *condition
,
5446 int hardwareflag
, int tempflag
,
5447 int thread
, int ignore_count
,
5448 char **error_message
)
5450 struct captured_breakpoint_args args
;
5451 args
.address
= address
;
5452 args
.condition
= condition
;
5453 args
.hardwareflag
= hardwareflag
;
5454 args
.tempflag
= tempflag
;
5455 args
.thread
= thread
;
5456 args
.ignore_count
= ignore_count
;
5457 return catch_exceptions_with_msg (uiout
, do_captured_breakpoint
, &args
,
5458 error_message
, RETURN_MASK_ALL
);
5462 /* Helper function for break_command_1 and disassemble_command. */
5465 resolve_sal_pc (struct symtab_and_line
*sal
)
5469 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
5471 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
5472 error (_("No line %d in file \"%s\"."),
5473 sal
->line
, sal
->symtab
->filename
);
5477 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
5479 struct blockvector
*bv
;
5484 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
5487 b
= BLOCKVECTOR_BLOCK (bv
, index
);
5488 sym
= block_function (b
);
5491 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
5492 sal
->section
= SYMBOL_BFD_SECTION (sym
);
5496 /* It really is worthwhile to have the section, so we'll just
5497 have to look harder. This case can be executed if we have
5498 line numbers but no functions (as can happen in assembly
5501 struct minimal_symbol
*msym
;
5503 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
5505 sal
->section
= SYMBOL_BFD_SECTION (msym
);
5512 break_command (char *arg
, int from_tty
)
5514 break_command_1 (arg
, 0, from_tty
, NULL
);
5518 tbreak_command (char *arg
, int from_tty
)
5520 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
, NULL
);
5524 hbreak_command (char *arg
, int from_tty
)
5526 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
, NULL
);
5530 thbreak_command (char *arg
, int from_tty
)
5532 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
, NULL
);
5536 stop_command (char *arg
, int from_tty
)
5538 printf_filtered (_("Specify the type of breakpoint to set.\n\
5539 Usage: stop in <function | address>\n\
5540 stop at <line>\n"));
5544 stopin_command (char *arg
, int from_tty
)
5548 if (arg
== (char *) NULL
)
5550 else if (*arg
!= '*')
5555 /* look for a ':'. If this is a line number specification, then
5556 say it is bad, otherwise, it should be an address or
5557 function/method name */
5558 while (*argptr
&& !hasColon
)
5560 hasColon
= (*argptr
== ':');
5565 badInput
= (*argptr
!= ':'); /* Not a class::method */
5567 badInput
= isdigit (*arg
); /* a simple line number */
5571 printf_filtered (_("Usage: stop in <function | address>\n"));
5573 break_command_1 (arg
, 0, from_tty
, NULL
);
5577 stopat_command (char *arg
, int from_tty
)
5581 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
5588 /* look for a ':'. If there is a '::' then get out, otherwise
5589 it is probably a line number. */
5590 while (*argptr
&& !hasColon
)
5592 hasColon
= (*argptr
== ':');
5597 badInput
= (*argptr
== ':'); /* we have class::method */
5599 badInput
= !isdigit (*arg
); /* not a line number */
5603 printf_filtered (_("Usage: stop at <line>\n"));
5605 break_command_1 (arg
, 0, from_tty
, NULL
);
5608 /* accessflag: hw_write: watch write,
5609 hw_read: watch read,
5610 hw_access: watch access (read or write) */
5612 watch_command_1 (char *arg
, int accessflag
, int from_tty
)
5614 struct breakpoint
*b
;
5615 struct symtab_and_line sal
;
5616 struct expression
*exp
;
5617 struct block
*exp_valid_block
;
5618 struct value
*val
, *mark
;
5619 struct frame_info
*frame
;
5620 struct frame_info
*prev_frame
= NULL
;
5621 char *exp_start
= NULL
;
5622 char *exp_end
= NULL
;
5623 char *tok
, *end_tok
;
5625 char *cond_start
= NULL
;
5626 char *cond_end
= NULL
;
5627 struct expression
*cond
= NULL
;
5628 int i
, other_type_used
, target_resources_ok
= 0;
5629 enum bptype bp_type
;
5632 init_sal (&sal
); /* initialize to zeroes */
5634 /* Parse arguments. */
5635 innermost_block
= NULL
;
5637 exp
= parse_exp_1 (&arg
, 0, 0);
5639 exp_valid_block
= innermost_block
;
5640 mark
= value_mark ();
5641 val
= evaluate_expression (exp
);
5642 release_value (val
);
5643 if (value_lazy (val
))
5644 value_fetch_lazy (val
);
5647 while (*tok
== ' ' || *tok
== '\t')
5651 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
5654 toklen
= end_tok
- tok
;
5655 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
5657 tok
= cond_start
= end_tok
+ 1;
5658 cond
= parse_exp_1 (&tok
, 0, 0);
5662 error (_("Junk at end of command."));
5664 if (accessflag
== hw_read
)
5665 bp_type
= bp_read_watchpoint
;
5666 else if (accessflag
== hw_access
)
5667 bp_type
= bp_access_watchpoint
;
5669 bp_type
= bp_hardware_watchpoint
;
5671 mem_cnt
= can_use_hardware_watchpoint (val
);
5672 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
5673 error (_("Expression cannot be implemented with read/access watchpoint."));
5676 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
5677 target_resources_ok
=
5678 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
5680 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
5681 error (_("Target does not support this type of hardware watchpoint."));
5683 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
5684 error (_("Target can only support one kind of HW watchpoint at a time."));
5687 #if defined(HPUXHPPA)
5688 /* On HP-UX if you set a h/w
5689 watchpoint before the "run" command, the inferior dies with a e.g.,
5690 SIGILL once you start it. I initially believed this was due to a
5691 bad interaction between page protection traps and the initial
5692 startup sequence by the dynamic linker.
5694 However, I tried avoiding that by having HP-UX's implementation of
5695 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_ptid
5696 yet, which forced slow watches before a "run" or "attach", and it
5697 still fails somewhere in the startup code.
5699 Until I figure out what's happening, I'm disallowing watches altogether
5700 before the "run" or "attach" command. We'll tell the user they must
5701 set watches after getting the program started. */
5702 if (!target_has_execution
)
5704 warning (_("can't do that without a running program; try \"break main\"), \"run\" first");
5707 #endif /* HPUXHPPA */
5709 /* Change the type of breakpoint to an ordinary watchpoint if a hardware
5710 watchpoint could not be set. */
5711 if (!mem_cnt
|| target_resources_ok
<= 0)
5712 bp_type
= bp_watchpoint
;
5714 /* Now set up the breakpoint. */
5715 b
= set_raw_breakpoint (sal
, bp_type
);
5716 set_breakpoint_count (breakpoint_count
+ 1);
5717 b
->number
= breakpoint_count
;
5718 b
->disposition
= disp_donttouch
;
5720 b
->exp_valid_block
= exp_valid_block
;
5721 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
5725 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
5729 frame
= block_innermost_frame (exp_valid_block
);
5732 prev_frame
= get_prev_frame (frame
);
5733 b
->watchpoint_frame
= get_frame_id (frame
);
5737 memset (&b
->watchpoint_frame
, 0, sizeof (b
->watchpoint_frame
));
5740 /* If the expression is "local", then set up a "watchpoint scope"
5741 breakpoint at the point where we've left the scope of the watchpoint
5743 if (innermost_block
)
5747 struct breakpoint
*scope_breakpoint
;
5748 scope_breakpoint
= create_internal_breakpoint (get_frame_pc (prev_frame
),
5749 bp_watchpoint_scope
);
5751 scope_breakpoint
->enable_state
= bp_enabled
;
5753 /* Automatically delete the breakpoint when it hits. */
5754 scope_breakpoint
->disposition
= disp_del
;
5756 /* Only break in the proper frame (help with recursion). */
5757 scope_breakpoint
->frame_id
= get_frame_id (prev_frame
);
5759 /* Set the address at which we will stop. */
5760 scope_breakpoint
->loc
->requested_address
5761 = get_frame_pc (prev_frame
);
5762 scope_breakpoint
->loc
->address
5763 = adjust_breakpoint_address (scope_breakpoint
->loc
->requested_address
,
5764 scope_breakpoint
->type
);
5766 /* The scope breakpoint is related to the watchpoint. We
5767 will need to act on them together. */
5768 b
->related_breakpoint
= scope_breakpoint
;
5771 value_free_to_mark (mark
);
5775 /* Return count of locations need to be watched and can be handled
5776 in hardware. If the watchpoint can not be handled
5777 in hardware return zero. */
5779 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
5780 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
5781 (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN))
5785 can_use_hardware_watchpoint (struct value
*v
)
5787 int found_memory_cnt
= 0;
5788 struct value
*head
= v
;
5790 /* Did the user specifically forbid us to use hardware watchpoints? */
5791 if (!can_use_hw_watchpoints
)
5794 /* Make sure that the value of the expression depends only upon
5795 memory contents, and values computed from them within GDB. If we
5796 find any register references or function calls, we can't use a
5797 hardware watchpoint.
5799 The idea here is that evaluating an expression generates a series
5800 of values, one holding the value of every subexpression. (The
5801 expression a*b+c has five subexpressions: a, b, a*b, c, and
5802 a*b+c.) GDB's values hold almost enough information to establish
5803 the criteria given above --- they identify memory lvalues,
5804 register lvalues, computed values, etcetera. So we can evaluate
5805 the expression, and then scan the chain of values that leaves
5806 behind to decide whether we can detect any possible change to the
5807 expression's final value using only hardware watchpoints.
5809 However, I don't think that the values returned by inferior
5810 function calls are special in any way. So this function may not
5811 notice that an expression involving an inferior function call
5812 can't be watched with hardware watchpoints. FIXME. */
5813 for (; v
; v
= value_next (v
))
5815 if (VALUE_LVAL (v
) == lval_memory
)
5818 /* A lazy memory lvalue is one that GDB never needed to fetch;
5819 we either just used its address (e.g., `a' in `a.b') or
5820 we never needed it at all (e.g., `a' in `a,b'). */
5824 /* Ahh, memory we actually used! Check if we can cover
5825 it with hardware watchpoints. */
5826 struct type
*vtype
= check_typedef (value_type (v
));
5828 /* We only watch structs and arrays if user asked for it
5829 explicitly, never if they just happen to appear in a
5830 middle of some value chain. */
5832 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
5833 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
5835 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + value_offset (v
);
5836 int len
= TYPE_LENGTH (value_type (v
));
5838 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
5845 else if (VALUE_LVAL (v
) != not_lval
5846 && deprecated_value_modifiable (v
) == 0)
5847 return 0; /* ??? What does this represent? */
5848 else if (VALUE_LVAL (v
) == lval_register
)
5849 return 0; /* cannot watch a register with a HW watchpoint */
5852 /* The expression itself looks suitable for using a hardware
5853 watchpoint, but give the target machine a chance to reject it. */
5854 return found_memory_cnt
;
5858 watch_command_wrapper (char *arg
, int from_tty
)
5860 watch_command (arg
, from_tty
);
5864 watch_command (char *arg
, int from_tty
)
5866 watch_command_1 (arg
, hw_write
, from_tty
);
5870 rwatch_command_wrapper (char *arg
, int from_tty
)
5872 rwatch_command (arg
, from_tty
);
5876 rwatch_command (char *arg
, int from_tty
)
5878 watch_command_1 (arg
, hw_read
, from_tty
);
5882 awatch_command_wrapper (char *arg
, int from_tty
)
5884 awatch_command (arg
, from_tty
);
5888 awatch_command (char *arg
, int from_tty
)
5890 watch_command_1 (arg
, hw_access
, from_tty
);
5894 /* Helper routines for the until_command routine in infcmd.c. Here
5895 because it uses the mechanisms of breakpoints. */
5897 /* This function is called by fetch_inferior_event via the
5898 cmd_continuation pointer, to complete the until command. It takes
5899 care of cleaning up the temporary breakpoints set up by the until
5902 until_break_command_continuation (struct continuation_arg
*arg
)
5904 struct cleanup
*cleanups
;
5906 cleanups
= (struct cleanup
*) arg
->data
.pointer
;
5907 do_exec_cleanups (cleanups
);
5911 until_break_command (char *arg
, int from_tty
, int anywhere
)
5913 struct symtabs_and_lines sals
;
5914 struct symtab_and_line sal
;
5915 struct frame_info
*prev_frame
= get_prev_frame (deprecated_selected_frame
);
5916 struct breakpoint
*breakpoint
;
5917 struct cleanup
*old_chain
;
5918 struct continuation_arg
*arg1
;
5921 clear_proceed_status ();
5923 /* Set a breakpoint where the user wants it and at return from
5926 if (default_breakpoint_valid
)
5927 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
5928 default_breakpoint_line
, (char ***) NULL
, NULL
);
5930 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
5931 0, (char ***) NULL
, NULL
);
5933 if (sals
.nelts
!= 1)
5934 error (_("Couldn't get information on specified line."));
5937 xfree (sals
.sals
); /* malloc'd, so freed */
5940 error (_("Junk at end of arguments."));
5942 resolve_sal_pc (&sal
);
5945 /* If the user told us to continue until a specified location,
5946 we don't specify a frame at which we need to stop. */
5947 breakpoint
= set_momentary_breakpoint (sal
, null_frame_id
, bp_until
);
5949 /* Otherwise, specify the current frame, because we want to stop only
5950 at the very same frame. */
5951 breakpoint
= set_momentary_breakpoint (sal
,
5952 get_frame_id (deprecated_selected_frame
),
5955 if (!target_can_async_p ())
5956 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
5958 old_chain
= make_exec_cleanup_delete_breakpoint (breakpoint
);
5960 /* If we are running asynchronously, and the target supports async
5961 execution, we are not waiting for the target to stop, in the call
5962 tp proceed, below. This means that we cannot delete the
5963 brekpoints until the target has actually stopped. The only place
5964 where we get a chance to do that is in fetch_inferior_event, so
5965 we must set things up for that. */
5967 if (target_can_async_p ())
5969 /* In this case the arg for the continuation is just the point
5970 in the exec_cleanups chain from where to start doing
5971 cleanups, because all the continuation does is the cleanups in
5972 the exec_cleanup_chain. */
5974 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
5976 arg1
->data
.pointer
= old_chain
;
5978 add_continuation (until_break_command_continuation
, arg1
);
5981 /* Keep within the current frame, or in frames called by the current
5985 sal
= find_pc_line (get_frame_pc (prev_frame
), 0);
5986 sal
.pc
= get_frame_pc (prev_frame
);
5987 breakpoint
= set_momentary_breakpoint (sal
, get_frame_id (prev_frame
),
5989 if (!target_can_async_p ())
5990 make_cleanup_delete_breakpoint (breakpoint
);
5992 make_exec_cleanup_delete_breakpoint (breakpoint
);
5995 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
5996 /* Do the cleanups now, anly if we are not running asynchronously,
5997 of if we are, but the target is still synchronous. */
5998 if (!target_can_async_p ())
5999 do_cleanups (old_chain
);
6003 ep_skip_leading_whitespace (char **s
)
6005 if ((s
== NULL
) || (*s
== NULL
))
6007 while (isspace (**s
))
6011 /* This function examines a string, and attempts to find a token
6012 that might be an event name in the leading characters. If a
6013 possible match is found, a pointer to the last character of
6014 the token is returned. Else, NULL is returned. */
6017 ep_find_event_name_end (char *arg
)
6020 char *event_name_end
= NULL
;
6022 /* If we could depend upon the presense of strrpbrk, we'd use that... */
6026 /* We break out of the loop when we find a token delimiter.
6027 Basically, we're looking for alphanumerics and underscores;
6028 anything else delimites the token. */
6031 if (!isalnum (*s
) && (*s
!= '_'))
6037 return event_name_end
;
6041 /* This function attempts to parse an optional "if <cond>" clause
6042 from the arg string. If one is not found, it returns NULL.
6044 Else, it returns a pointer to the condition string. (It does not
6045 attempt to evaluate the string against a particular block.) And,
6046 it updates arg to point to the first character following the parsed
6047 if clause in the arg string. */
6050 ep_parse_optional_if_clause (char **arg
)
6054 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
6057 /* Skip the "if" keyword. */
6060 /* Skip any extra leading whitespace, and record the start of the
6061 condition string. */
6062 ep_skip_leading_whitespace (arg
);
6065 /* Assume that the condition occupies the remainder of the arg string. */
6066 (*arg
) += strlen (cond_string
);
6071 /* This function attempts to parse an optional filename from the arg
6072 string. If one is not found, it returns NULL.
6074 Else, it returns a pointer to the parsed filename. (This function
6075 makes no attempt to verify that a file of that name exists, or is
6076 accessible.) And, it updates arg to point to the first character
6077 following the parsed filename in the arg string.
6079 Note that clients needing to preserve the returned filename for
6080 future access should copy it to their own buffers. */
6082 ep_parse_optional_filename (char **arg
)
6084 static char filename
[1024];
6089 if ((*arg_p
== '\0') || isspace (*arg_p
))
6107 /* Commands to deal with catching events, such as signals, exceptions,
6108 process start/exit, etc. */
6112 catch_fork
, catch_vfork
6117 catch_fork_command_1 (catch_fork_kind fork_kind
, char *arg
, int tempflag
,
6120 char *cond_string
= NULL
;
6122 ep_skip_leading_whitespace (&arg
);
6124 /* The allowed syntax is:
6126 catch [v]fork if <cond>
6128 First, check if there's an if clause. */
6129 cond_string
= ep_parse_optional_if_clause (&arg
);
6131 if ((*arg
!= '\0') && !isspace (*arg
))
6132 error (_("Junk at end of arguments."));
6134 /* If this target supports it, create a fork or vfork catchpoint
6135 and enable reporting of such events. */
6139 create_fork_event_catchpoint (tempflag
, cond_string
);
6142 create_vfork_event_catchpoint (tempflag
, cond_string
);
6145 error (_("unsupported or unknown fork kind; cannot catch it"));
6151 catch_exec_command_1 (char *arg
, int tempflag
, int from_tty
)
6153 char *cond_string
= NULL
;
6155 ep_skip_leading_whitespace (&arg
);
6157 /* The allowed syntax is:
6159 catch exec if <cond>
6161 First, check if there's an if clause. */
6162 cond_string
= ep_parse_optional_if_clause (&arg
);
6164 if ((*arg
!= '\0') && !isspace (*arg
))
6165 error (_("Junk at end of arguments."));
6167 /* If this target supports it, create an exec catchpoint
6168 and enable reporting of such events. */
6169 create_exec_event_catchpoint (tempflag
, cond_string
);
6173 catch_load_command_1 (char *arg
, int tempflag
, int from_tty
)
6175 char *dll_pathname
= NULL
;
6176 char *cond_string
= NULL
;
6178 ep_skip_leading_whitespace (&arg
);
6180 /* The allowed syntax is:
6182 catch load if <cond>
6183 catch load <filename>
6184 catch load <filename> if <cond>
6186 The user is not allowed to specify the <filename> after an
6189 We'll ignore the pathological case of a file named "if".
6191 First, check if there's an if clause. If so, then there
6192 cannot be a filename. */
6193 cond_string
= ep_parse_optional_if_clause (&arg
);
6195 /* If there was an if clause, then there cannot be a filename.
6196 Else, there might be a filename and an if clause. */
6197 if (cond_string
== NULL
)
6199 dll_pathname
= ep_parse_optional_filename (&arg
);
6200 ep_skip_leading_whitespace (&arg
);
6201 cond_string
= ep_parse_optional_if_clause (&arg
);
6204 if ((*arg
!= '\0') && !isspace (*arg
))
6205 error (_("Junk at end of arguments."));
6207 /* Create a load breakpoint that only triggers when a load of
6208 the specified dll (or any dll, if no pathname was specified)
6210 SOLIB_CREATE_CATCH_LOAD_HOOK (PIDGET (inferior_ptid
), tempflag
,
6211 dll_pathname
, cond_string
);
6215 catch_unload_command_1 (char *arg
, int tempflag
, int from_tty
)
6217 char *dll_pathname
= NULL
;
6218 char *cond_string
= NULL
;
6220 ep_skip_leading_whitespace (&arg
);
6222 /* The allowed syntax is:
6224 catch unload if <cond>
6225 catch unload <filename>
6226 catch unload <filename> if <cond>
6228 The user is not allowed to specify the <filename> after an
6231 We'll ignore the pathological case of a file named "if".
6233 First, check if there's an if clause. If so, then there
6234 cannot be a filename. */
6235 cond_string
= ep_parse_optional_if_clause (&arg
);
6237 /* If there was an if clause, then there cannot be a filename.
6238 Else, there might be a filename and an if clause. */
6239 if (cond_string
== NULL
)
6241 dll_pathname
= ep_parse_optional_filename (&arg
);
6242 ep_skip_leading_whitespace (&arg
);
6243 cond_string
= ep_parse_optional_if_clause (&arg
);
6246 if ((*arg
!= '\0') && !isspace (*arg
))
6247 error (_("Junk at end of arguments."));
6249 /* Create an unload breakpoint that only triggers when an unload of
6250 the specified dll (or any dll, if no pathname was specified)
6252 SOLIB_CREATE_CATCH_UNLOAD_HOOK (PIDGET (inferior_ptid
), tempflag
,
6253 dll_pathname
, cond_string
);
6256 /* Commands to deal with catching exceptions. */
6258 /* Set a breakpoint at the specified callback routine for an
6259 exception event callback */
6262 create_exception_catchpoint (int tempflag
, char *cond_string
,
6263 enum exception_event_kind ex_event
,
6264 struct symtab_and_line
*sal
)
6266 struct breakpoint
*b
;
6267 int thread
= -1; /* All threads. */
6270 if (!sal
) /* no exception support? */
6275 case EX_EVENT_THROW
:
6276 bptype
= bp_catch_throw
;
6278 case EX_EVENT_CATCH
:
6279 bptype
= bp_catch_catch
;
6281 default: /* error condition */
6282 error (_("Internal error -- invalid catchpoint kind"));
6285 b
= set_raw_breakpoint (*sal
, bptype
);
6286 set_breakpoint_count (breakpoint_count
+ 1);
6287 b
->number
= breakpoint_count
;
6289 b
->cond_string
= (cond_string
== NULL
) ?
6290 NULL
: savestring (cond_string
, strlen (cond_string
));
6292 b
->addr_string
= NULL
;
6293 b
->enable_state
= bp_enabled
;
6294 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
6298 static enum print_stop_action
6299 print_exception_catchpoint (struct breakpoint
*b
)
6301 annotate_catchpoint (b
->number
);
6303 if (strstr (b
->addr_string
, "throw") != NULL
)
6304 printf_filtered (_("\nCatchpoint %d (exception thrown)\n"),
6307 printf_filtered (_("\nCatchpoint %d (exception caught)\n"),
6310 return PRINT_SRC_AND_LOC
;
6314 print_one_exception_catchpoint (struct breakpoint
*b
, CORE_ADDR
*last_addr
)
6319 ui_out_field_core_addr (uiout
, "addr", b
->loc
->address
);
6322 *last_addr
= b
->loc
->address
;
6323 if (strstr (b
->addr_string
, "throw") != NULL
)
6324 ui_out_field_string (uiout
, "what", "exception throw");
6326 ui_out_field_string (uiout
, "what", "exception catch");
6330 print_mention_exception_catchpoint (struct breakpoint
*b
)
6332 if (strstr (b
->addr_string
, "throw") != NULL
)
6333 printf_filtered (_("Catchpoint %d (throw)"), b
->number
);
6335 printf_filtered (_("Catchpoint %d (catch)"), b
->number
);
6338 static struct breakpoint_ops gnu_v3_exception_catchpoint_ops
= {
6339 print_exception_catchpoint
,
6340 print_one_exception_catchpoint
,
6341 print_mention_exception_catchpoint
6345 handle_gnu_v3_exceptions (int tempflag
, char *cond_string
,
6346 enum exception_event_kind ex_event
, int from_tty
)
6348 char *trigger_func_name
, *nameptr
;
6349 struct symtabs_and_lines sals
;
6350 struct breakpoint
*b
;
6352 if (ex_event
== EX_EVENT_CATCH
)
6353 trigger_func_name
= xstrdup ("__cxa_begin_catch");
6355 trigger_func_name
= xstrdup ("__cxa_throw");
6357 nameptr
= trigger_func_name
;
6358 sals
= decode_line_1 (&nameptr
, 1, NULL
, 0, NULL
, NULL
);
6359 if (sals
.nelts
== 0)
6361 xfree (trigger_func_name
);
6365 b
= set_raw_breakpoint (sals
.sals
[0], bp_breakpoint
);
6366 set_breakpoint_count (breakpoint_count
+ 1);
6367 b
->number
= breakpoint_count
;
6369 b
->cond_string
= (cond_string
== NULL
) ?
6370 NULL
: savestring (cond_string
, strlen (cond_string
));
6372 b
->addr_string
= trigger_func_name
;
6373 b
->enable_state
= bp_enabled
;
6374 b
->disposition
= tempflag
? disp_del
: disp_donttouch
;
6375 b
->ops
= &gnu_v3_exception_catchpoint_ops
;
6382 /* Deal with "catch catch" and "catch throw" commands */
6385 catch_exception_command_1 (enum exception_event_kind ex_event
, char *arg
,
6386 int tempflag
, int from_tty
)
6388 char *cond_string
= NULL
;
6389 struct symtab_and_line
*sal
= NULL
;
6391 ep_skip_leading_whitespace (&arg
);
6393 cond_string
= ep_parse_optional_if_clause (&arg
);
6395 if ((*arg
!= '\0') && !isspace (*arg
))
6396 error (_("Junk at end of arguments."));
6398 if ((ex_event
!= EX_EVENT_THROW
) &&
6399 (ex_event
!= EX_EVENT_CATCH
))
6400 error (_("Unsupported or unknown exception event; cannot catch it"));
6402 if (handle_gnu_v3_exceptions (tempflag
, cond_string
, ex_event
, from_tty
))
6405 /* See if we can find a callback routine */
6406 sal
= target_enable_exception_callback (ex_event
, 1);
6410 /* We have callbacks from the runtime system for exceptions.
6411 Set a breakpoint on the sal found, if no errors */
6412 if (sal
!= (struct symtab_and_line
*) -1)
6413 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
6415 return; /* something went wrong with setting up callbacks */
6418 warning (_("Unsupported with this platform/compiler combination."));
6421 /* Cover routine to allow wrapping target_enable_exception_catchpoints
6422 inside a catch_errors */
6425 cover_target_enable_exception_callback (void *arg
)
6427 args_for_catchpoint_enable
*args
= arg
;
6428 struct symtab_and_line
*sal
;
6429 sal
= target_enable_exception_callback (args
->kind
, args
->enable_p
);
6432 else if (sal
== (struct symtab_and_line
*) -1)
6435 return 1; /*is valid */
6439 catch_command_1 (char *arg
, int tempflag
, int from_tty
)
6442 /* The first argument may be an event name, such as "start" or "load".
6443 If so, then handle it as such. If it doesn't match an event name,
6444 then attempt to interpret it as an exception name. (This latter is
6445 the v4.16-and-earlier GDB meaning of the "catch" command.)
6447 First, try to find the bounds of what might be an event name. */
6448 char *arg1_start
= arg
;
6452 if (arg1_start
== NULL
)
6454 /* Old behaviour was to use pre-v-4.16 syntax */
6455 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6457 /* Now, this is not allowed */
6458 error (_("Catch requires an event name."));
6461 arg1_end
= ep_find_event_name_end (arg1_start
);
6462 if (arg1_end
== NULL
)
6463 error (_("catch requires an event"));
6464 arg1_length
= arg1_end
+ 1 - arg1_start
;
6466 /* Try to match what we found against known event names. */
6467 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
6469 error (_("Catch of signal not yet implemented"));
6471 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
6473 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
6474 tempflag
, from_tty
);
6476 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
6478 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
6479 tempflag
, from_tty
);
6481 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
6483 error (_("Catch of thread_start not yet implemented"));
6485 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
6487 error (_("Catch of thread_exit not yet implemented"));
6489 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
6491 error (_("Catch of thread_join not yet implemented"));
6493 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
6495 error (_("Catch of start not yet implemented"));
6497 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
6499 error (_("Catch of exit not yet implemented"));
6501 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
6503 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
6505 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
6507 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
6509 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
6511 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6513 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
6515 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6517 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
6519 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6521 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
6523 error (_("Catch of stop not yet implemented"));
6526 /* This doesn't appear to be an event name */
6530 /* Pre-v.4.16 behaviour was to treat the argument
6531 as the name of an exception */
6532 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6533 /* Now this is not allowed */
6534 error (_("Unknown event kind specified for catch"));
6539 /* Used by the gui, could be made a worker for other things. */
6542 set_breakpoint_sal (struct symtab_and_line sal
)
6544 struct breakpoint
*b
;
6545 b
= set_raw_breakpoint (sal
, bp_breakpoint
);
6546 set_breakpoint_count (breakpoint_count
+ 1);
6547 b
->number
= breakpoint_count
;
6554 catch_command (char *arg
, int from_tty
)
6556 catch_command_1 (arg
, 0, from_tty
);
6561 tcatch_command (char *arg
, int from_tty
)
6563 catch_command_1 (arg
, 1, from_tty
);
6566 /* Delete breakpoints by address or line. */
6569 clear_command (char *arg
, int from_tty
)
6571 struct breakpoint
*b
, *tmp
, *prev
, *found
;
6573 struct symtabs_and_lines sals
;
6574 struct symtab_and_line sal
;
6579 sals
= decode_line_spec (arg
, 1);
6584 sals
.sals
= (struct symtab_and_line
*)
6585 xmalloc (sizeof (struct symtab_and_line
));
6586 make_cleanup (xfree
, sals
.sals
);
6587 init_sal (&sal
); /* initialize to zeroes */
6588 sal
.line
= default_breakpoint_line
;
6589 sal
.symtab
= default_breakpoint_symtab
;
6590 sal
.pc
= default_breakpoint_address
;
6591 if (sal
.symtab
== 0)
6592 error (_("No source file specified."));
6600 /* For each line spec given, delete bps which correspond
6601 to it. Do it in two passes, solely to preserve the current
6602 behavior that from_tty is forced true if we delete more than
6606 for (i
= 0; i
< sals
.nelts
; i
++)
6608 /* If exact pc given, clear bpts at that pc.
6609 If line given (pc == 0), clear all bpts on specified line.
6610 If defaulting, clear all bpts on default line
6613 defaulting sal.pc != 0 tests to do
6618 1 0 <can't happen> */
6623 /* Find all matching breakpoints, remove them from the
6624 breakpoint chain, and add them to the 'found' chain. */
6625 ALL_BREAKPOINTS_SAFE (b
, tmp
)
6627 /* Are we going to delete b? */
6628 if (b
->type
!= bp_none
6629 && b
->type
!= bp_watchpoint
6630 && b
->type
!= bp_hardware_watchpoint
6631 && b
->type
!= bp_read_watchpoint
6632 && b
->type
!= bp_access_watchpoint
6633 /* Not if b is a watchpoint of any sort... */
6634 && (((sal
.pc
&& (b
->loc
->address
== sal
.pc
))
6635 && (!section_is_overlay (b
->loc
->section
)
6636 || b
->loc
->section
== sal
.section
))
6637 /* Yes, if sal.pc matches b (modulo overlays). */
6638 || ((default_match
|| (0 == sal
.pc
))
6639 && b
->source_file
!= NULL
6640 && sal
.symtab
!= NULL
6641 && strcmp (b
->source_file
, sal
.symtab
->filename
) == 0
6642 && b
->line_number
== sal
.line
)))
6643 /* Yes, if sal source file and line matches b. */
6645 /* Remove it from breakpoint_chain... */
6646 if (b
== breakpoint_chain
)
6648 /* b is at the head of the list */
6649 breakpoint_chain
= b
->next
;
6653 prev
->next
= b
->next
;
6655 /* And add it to 'found' chain. */
6661 /* Keep b, and keep a pointer to it. */
6666 /* Now go thru the 'found' chain and delete them. */
6670 error (_("No breakpoint at %s."), arg
);
6672 error (_("No breakpoint at this line."));
6676 from_tty
= 1; /* Always report if deleted more than one */
6680 printf_unfiltered (_("Deleted breakpoint "));
6682 printf_unfiltered (_("Deleted breakpoints "));
6684 breakpoints_changed ();
6688 printf_unfiltered ("%d ", found
->number
);
6690 delete_breakpoint (found
);
6694 putchar_unfiltered ('\n');
6697 /* Delete breakpoint in BS if they are `delete' breakpoints and
6698 all breakpoints that are marked for deletion, whether hit or not.
6699 This is called after any breakpoint is hit, or after errors. */
6702 breakpoint_auto_delete (bpstat bs
)
6704 struct breakpoint
*b
, *temp
;
6706 for (; bs
; bs
= bs
->next
)
6707 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== disp_del
6709 delete_breakpoint (bs
->breakpoint_at
);
6711 ALL_BREAKPOINTS_SAFE (b
, temp
)
6713 if (b
->disposition
== disp_del_at_next_stop
)
6714 delete_breakpoint (b
);
6718 /* Delete a breakpoint and clean up all traces of it in the data
6722 delete_breakpoint (struct breakpoint
*bpt
)
6724 struct breakpoint
*b
;
6726 struct bp_location
*loc
;
6728 gdb_assert (bpt
!= NULL
);
6730 /* Has this bp already been deleted? This can happen because multiple
6731 lists can hold pointers to bp's. bpstat lists are especial culprits.
6733 One example of this happening is a watchpoint's scope bp. When the
6734 scope bp triggers, we notice that the watchpoint is out of scope, and
6735 delete it. We also delete its scope bp. But the scope bp is marked
6736 "auto-deleting", and is already on a bpstat. That bpstat is then
6737 checked for auto-deleting bp's, which are deleted.
6739 A real solution to this problem might involve reference counts in bp's,
6740 and/or giving them pointers back to their referencing bpstat's, and
6741 teaching delete_breakpoint to only free a bp's storage when no more
6742 references were extent. A cheaper bandaid was chosen. */
6743 if (bpt
->type
== bp_none
)
6746 if (deprecated_delete_breakpoint_hook
)
6747 deprecated_delete_breakpoint_hook (bpt
);
6748 breakpoint_delete_event (bpt
->number
);
6750 if (bpt
->loc
->inserted
)
6751 remove_breakpoint (bpt
->loc
, mark_inserted
);
6753 free_valchain (bpt
->loc
);
6755 if (breakpoint_chain
== bpt
)
6756 breakpoint_chain
= bpt
->next
;
6758 if (bp_location_chain
== bpt
->loc
)
6759 bp_location_chain
= bpt
->loc
->next
;
6761 /* If we have callback-style exception catchpoints, don't go through
6762 the adjustments to the C++ runtime library etc. if the inferior
6763 isn't actually running. target_enable_exception_callback for a
6764 null target ops vector gives an undesirable error message, so we
6765 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
6766 exceptions are supported in this way, it's OK for now. FIXME */
6767 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
6769 /* Format possible error msg */
6770 char *message
= xstrprintf ("Error in deleting catchpoint %d:\n",
6772 struct cleanup
*cleanups
= make_cleanup (xfree
, message
);
6773 args_for_catchpoint_enable args
;
6774 args
.kind
= bpt
->type
== bp_catch_catch
?
6775 EX_EVENT_CATCH
: EX_EVENT_THROW
;
6777 catch_errors (cover_target_enable_exception_callback
, &args
,
6778 message
, RETURN_MASK_ALL
);
6779 do_cleanups (cleanups
);
6786 b
->next
= bpt
->next
;
6790 ALL_BP_LOCATIONS (loc
)
6791 if (loc
->next
== bpt
->loc
)
6793 loc
->next
= bpt
->loc
->next
;
6797 check_duplicates (bpt
);
6798 /* If this breakpoint was inserted, and there is another breakpoint
6799 at the same address, we need to insert the other breakpoint. */
6800 if (bpt
->loc
->inserted
6801 && bpt
->type
!= bp_hardware_watchpoint
6802 && bpt
->type
!= bp_read_watchpoint
6803 && bpt
->type
!= bp_access_watchpoint
6804 && bpt
->type
!= bp_catch_fork
6805 && bpt
->type
!= bp_catch_vfork
6806 && bpt
->type
!= bp_catch_exec
)
6809 if (b
->loc
->address
== bpt
->loc
->address
6810 && b
->loc
->section
== bpt
->loc
->section
6811 && !b
->loc
->duplicate
6812 && b
->enable_state
!= bp_disabled
6813 && b
->enable_state
!= bp_shlib_disabled
6815 && b
->enable_state
!= bp_call_disabled
)
6819 /* We should never reach this point if there is a permanent
6820 breakpoint at the same address as the one being deleted.
6821 If there is a permanent breakpoint somewhere, it should
6822 always be the only one inserted. */
6823 if (b
->enable_state
== bp_permanent
)
6824 internal_error (__FILE__
, __LINE__
,
6825 _("another breakpoint was inserted on top of "
6826 "a permanent breakpoint"));
6828 if (b
->type
== bp_hardware_breakpoint
)
6829 val
= target_insert_hw_breakpoint (b
->loc
->address
, b
->loc
->shadow_contents
);
6831 val
= target_insert_breakpoint (b
->loc
->address
, b
->loc
->shadow_contents
);
6833 /* If there was an error in the insert, print a message, then stop execution. */
6836 struct ui_file
*tmp_error_stream
= mem_fileopen ();
6837 make_cleanup_ui_file_delete (tmp_error_stream
);
6840 if (b
->type
== bp_hardware_breakpoint
)
6842 fprintf_unfiltered (tmp_error_stream
,
6843 "Cannot insert hardware breakpoint %d.\n"
6844 "You may have requested too many hardware breakpoints.\n",
6849 fprintf_unfiltered (tmp_error_stream
, "Cannot insert breakpoint %d.\n", b
->number
);
6850 fprintf_filtered (tmp_error_stream
, "Error accessing memory address ");
6851 deprecated_print_address_numeric (b
->loc
->address
, 1, tmp_error_stream
);
6852 fprintf_filtered (tmp_error_stream
, ": %s.\n",
6853 safe_strerror (val
));
6856 fprintf_unfiltered (tmp_error_stream
,"The same program may be running in another process.");
6857 target_terminal_ours_for_output ();
6858 error_stream(tmp_error_stream
);
6861 b
->loc
->inserted
= 1;
6865 free_command_lines (&bpt
->commands
);
6868 if (bpt
->cond_string
!= NULL
)
6869 xfree (bpt
->cond_string
);
6870 if (bpt
->addr_string
!= NULL
)
6871 xfree (bpt
->addr_string
);
6872 if (bpt
->exp
!= NULL
)
6874 if (bpt
->exp_string
!= NULL
)
6875 xfree (bpt
->exp_string
);
6876 if (bpt
->val
!= NULL
)
6877 value_free (bpt
->val
);
6878 if (bpt
->source_file
!= NULL
)
6879 xfree (bpt
->source_file
);
6880 if (bpt
->dll_pathname
!= NULL
)
6881 xfree (bpt
->dll_pathname
);
6882 if (bpt
->triggered_dll_pathname
!= NULL
)
6883 xfree (bpt
->triggered_dll_pathname
);
6884 if (bpt
->exec_pathname
!= NULL
)
6885 xfree (bpt
->exec_pathname
);
6887 /* Be sure no bpstat's are pointing at it after it's been freed. */
6888 /* FIXME, how can we find all bpstat's?
6889 We just check stop_bpstat for now. */
6890 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6891 if (bs
->breakpoint_at
== bpt
)
6893 bs
->breakpoint_at
= NULL
;
6895 /* bs->commands will be freed later. */
6897 /* On the chance that someone will soon try again to delete this same
6898 bp, we mark it as deleted before freeing its storage. */
6899 bpt
->type
= bp_none
;
6906 do_delete_breakpoint_cleanup (void *b
)
6908 delete_breakpoint (b
);
6912 make_cleanup_delete_breakpoint (struct breakpoint
*b
)
6914 return make_cleanup (do_delete_breakpoint_cleanup
, b
);
6918 make_exec_cleanup_delete_breakpoint (struct breakpoint
*b
)
6920 return make_exec_cleanup (do_delete_breakpoint_cleanup
, b
);
6924 delete_command (char *arg
, int from_tty
)
6926 struct breakpoint
*b
, *temp
;
6932 int breaks_to_delete
= 0;
6934 /* Delete all breakpoints if no argument.
6935 Do not delete internal or call-dummy breakpoints, these
6936 have to be deleted with an explicit breakpoint number argument. */
6939 if (b
->type
!= bp_call_dummy
&&
6940 b
->type
!= bp_shlib_event
&&
6941 b
->type
!= bp_thread_event
&&
6942 b
->type
!= bp_overlay_event
&&
6944 breaks_to_delete
= 1;
6947 /* Ask user only if there are some breakpoints to delete. */
6949 || (breaks_to_delete
&& query (_("Delete all breakpoints? "))))
6951 ALL_BREAKPOINTS_SAFE (b
, temp
)
6953 if (b
->type
!= bp_call_dummy
&&
6954 b
->type
!= bp_shlib_event
&&
6955 b
->type
!= bp_thread_event
&&
6956 b
->type
!= bp_overlay_event
&&
6958 delete_breakpoint (b
);
6963 map_breakpoint_numbers (arg
, delete_breakpoint
);
6966 /* Reset a breakpoint given it's struct breakpoint * BINT.
6967 The value we return ends up being the return value from catch_errors.
6968 Unused in this case. */
6971 breakpoint_re_set_one (void *bint
)
6973 /* get past catch_errs */
6974 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6978 int *not_found_ptr
= NULL
;
6979 struct symtabs_and_lines sals
;
6981 enum enable_state save_enable
;
6986 warning (_("attempted to reset apparently deleted breakpoint #%d?"),
6990 case bp_hardware_breakpoint
:
6992 case bp_catch_unload
:
6993 if (b
->addr_string
== NULL
)
6995 /* Anything without a string can't be re-set. */
6996 delete_breakpoint (b
);
6999 /* HACK: cagney/2001-11-11: kettenis/2001-11-11: MarkK wrote:
7001 ``And a hack it is, although Apple's Darwin version of GDB
7002 contains an almost identical hack to implement a "future
7003 break" command. It seems to work in many real world cases,
7004 but it is easy to come up with a test case where the patch
7005 doesn't help at all.''
7007 ``It seems that the way GDB implements breakpoints - in -
7008 shared - libraries was designed for a.out shared library
7009 systems (SunOS 4) where shared libraries were loaded at a
7010 fixed address in memory. Since ELF shared libraries can (and
7011 will) be loaded at any address in memory, things break.
7012 Fixing this is not trivial. Therefore, I'm not sure whether
7013 we should add this hack to the branch only. I cannot
7014 guarantee that things will be fixed on the trunk in the near
7017 In case we have a problem, disable this breakpoint. We'll
7018 restore its status if we succeed. Don't disable a
7019 shlib_disabled breakpoint though. There's a fair chance we
7020 can't re-set it if the shared library it's in hasn't been
7026 save_enable
= b
->enable_state
;
7027 if (b
->enable_state
!= bp_shlib_disabled
)
7028 b
->enable_state
= bp_disabled
;
7030 /* If resetting a shlib-disabled breakpoint, we don't want to
7031 see an error message if it is not found since we will expect
7032 this to occur until the shared library is finally reloaded.
7033 We accomplish this by giving decode_line_1 a pointer to use
7034 for silent notification that the symbol is not found. */
7035 not_found_ptr
= ¬_found
;
7037 set_language (b
->language
);
7038 input_radix
= b
->input_radix
;
7040 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
,
7042 for (i
= 0; i
< sals
.nelts
; i
++)
7044 resolve_sal_pc (&sals
.sals
[i
]);
7046 /* Reparse conditions, they might contain references to the
7048 if (b
->cond_string
!= NULL
)
7054 /* Avoid re-freeing b->exp if an error during the call
7058 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
7061 /* We need to re-set the breakpoint if the address changes... */
7062 if (b
->loc
->address
!= sals
.sals
[i
].pc
7063 /* ...or new and old breakpoints both have source files, and
7064 the source file name or the line number changes... */
7065 || (b
->source_file
!= NULL
7066 && sals
.sals
[i
].symtab
!= NULL
7067 && (strcmp (b
->source_file
, sals
.sals
[i
].symtab
->filename
) != 0
7068 || b
->line_number
!= sals
.sals
[i
].line
)
7070 /* ...or we switch between having a source file and not having
7072 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
7075 if (b
->source_file
!= NULL
)
7076 xfree (b
->source_file
);
7077 if (sals
.sals
[i
].symtab
== NULL
)
7078 b
->source_file
= NULL
;
7081 savestring (sals
.sals
[i
].symtab
->filename
,
7082 strlen (sals
.sals
[i
].symtab
->filename
));
7083 b
->line_number
= sals
.sals
[i
].line
;
7084 b
->loc
->requested_address
= sals
.sals
[i
].pc
;
7086 = adjust_breakpoint_address (b
->loc
->requested_address
,
7089 /* Used to check for duplicates here, but that can
7090 cause trouble, as it doesn't check for disabled
7095 /* Might be better to do this just once per breakpoint_re_set,
7096 rather than once for every breakpoint. */
7097 breakpoints_changed ();
7099 b
->loc
->section
= sals
.sals
[i
].section
;
7100 b
->enable_state
= save_enable
; /* Restore it, this worked. */
7103 /* Now that this is re-enabled, check_duplicates
7105 check_duplicates (b
);
7112 case bp_hardware_watchpoint
:
7113 case bp_read_watchpoint
:
7114 case bp_access_watchpoint
:
7115 innermost_block
= NULL
;
7116 /* The issue arises of what context to evaluate this in. The
7117 same one as when it was set, but what does that mean when
7118 symbols have been re-read? We could save the filename and
7119 functionname, but if the context is more local than that, the
7120 best we could do would be something like how many levels deep
7121 and which index at that particular level, but that's going to
7122 be less stable than filenames or function names. */
7124 /* So for now, just use a global context. */
7128 /* Avoid re-freeing b->exp if an error during the call to
7129 parse_expression. */
7132 b
->exp
= parse_expression (b
->exp_string
);
7133 b
->exp_valid_block
= innermost_block
;
7134 mark
= value_mark ();
7137 value_free (b
->val
);
7138 /* Avoid re-freeing b->val if an error during the call to
7139 evaluate_expression. */
7142 b
->val
= evaluate_expression (b
->exp
);
7143 release_value (b
->val
);
7144 if (value_lazy (b
->val
) && breakpoint_enabled (b
))
7145 value_fetch_lazy (b
->val
);
7147 if (b
->cond_string
!= NULL
)
7153 /* Avoid re-freeing b->exp if an error during the call
7157 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
7159 if (breakpoint_enabled (b
))
7161 value_free_to_mark (mark
);
7163 case bp_catch_catch
:
7164 case bp_catch_throw
:
7166 /* We needn't really do anything to reset these, since the mask
7167 that requests them is unaffected by e.g., new libraries being
7170 case bp_catch_vfork
:
7175 printf_filtered (_("Deleting unknown breakpoint type %d\n"), b
->type
);
7177 /* Delete longjmp and overlay event breakpoints; they will be
7178 reset later by breakpoint_re_set. */
7180 case bp_longjmp_resume
:
7181 case bp_overlay_event
:
7182 delete_breakpoint (b
);
7185 /* This breakpoint is special, it's set up when the inferior
7186 starts and we really don't want to touch it. */
7187 case bp_shlib_event
:
7189 /* Like bp_shlib_event, this breakpoint type is special.
7190 Once it is set up, we do not want to touch it. */
7191 case bp_thread_event
:
7193 /* Keep temporary breakpoints, which can be encountered when we step
7194 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
7195 Otherwise these should have been blown away via the cleanup chain
7196 or by breakpoint_init_inferior when we rerun the executable. */
7199 case bp_watchpoint_scope
:
7201 case bp_step_resume
:
7208 /* Re-set all breakpoints after symbols have been re-loaded. */
7210 breakpoint_re_set (void)
7212 struct breakpoint
*b
, *temp
;
7213 enum language save_language
;
7214 int save_input_radix
;
7216 save_language
= current_language
->la_language
;
7217 save_input_radix
= input_radix
;
7218 ALL_BREAKPOINTS_SAFE (b
, temp
)
7220 /* Format possible error msg */
7221 char *message
= xstrprintf ("Error in re-setting breakpoint %d:\n",
7223 struct cleanup
*cleanups
= make_cleanup (xfree
, message
);
7224 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
7225 do_cleanups (cleanups
);
7227 set_language (save_language
);
7228 input_radix
= save_input_radix
;
7230 if (GET_LONGJMP_TARGET_P ())
7232 create_longjmp_breakpoint ("longjmp");
7233 create_longjmp_breakpoint ("_longjmp");
7234 create_longjmp_breakpoint ("siglongjmp");
7235 create_longjmp_breakpoint ("_siglongjmp");
7236 create_longjmp_breakpoint (NULL
);
7239 create_overlay_event_breakpoint ("_ovly_debug_event");
7242 /* Reset the thread number of this breakpoint:
7244 - If the breakpoint is for all threads, leave it as-is.
7245 - Else, reset it to the current thread for inferior_ptid. */
7247 breakpoint_re_set_thread (struct breakpoint
*b
)
7249 if (b
->thread
!= -1)
7251 if (in_thread_list (inferior_ptid
))
7252 b
->thread
= pid_to_thread_id (inferior_ptid
);
7256 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
7257 If from_tty is nonzero, it prints a message to that effect,
7258 which ends with a period (no newline). */
7261 set_ignore_count (int bptnum
, int count
, int from_tty
)
7263 struct breakpoint
*b
;
7269 if (b
->number
== bptnum
)
7271 b
->ignore_count
= count
;
7275 printf_filtered (_("Will stop next time breakpoint %d is reached."),
7277 else if (count
== 1)
7278 printf_filtered (_("Will ignore next crossing of breakpoint %d."),
7281 printf_filtered (_("Will ignore next %d crossings of breakpoint %d."),
7284 breakpoints_changed ();
7285 breakpoint_modify_event (b
->number
);
7289 error (_("No breakpoint number %d."), bptnum
);
7292 /* Clear the ignore counts of all breakpoints. */
7294 breakpoint_clear_ignore_counts (void)
7296 struct breakpoint
*b
;
7299 b
->ignore_count
= 0;
7302 /* Command to set ignore-count of breakpoint N to COUNT. */
7305 ignore_command (char *args
, int from_tty
)
7311 error_no_arg (_("a breakpoint number"));
7313 num
= get_number (&p
);
7315 error (_("bad breakpoint number: '%s'"), args
);
7317 error (_("Second argument (specified ignore-count) is missing."));
7319 set_ignore_count (num
,
7320 longest_to_int (value_as_long (parse_and_eval (p
))),
7323 printf_filtered ("\n");
7326 /* Call FUNCTION on each of the breakpoints
7327 whose numbers are given in ARGS. */
7330 map_breakpoint_numbers (char *args
, void (*function
) (struct breakpoint
*))
7335 struct breakpoint
*b
, *tmp
;
7339 error_no_arg (_("one or more breakpoint numbers"));
7346 num
= get_number_or_range (&p1
);
7349 warning (_("bad breakpoint number at or near '%s'"), p
);
7353 ALL_BREAKPOINTS_SAFE (b
, tmp
)
7354 if (b
->number
== num
)
7356 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
7359 if (related_breakpoint
)
7360 function (related_breakpoint
);
7364 printf_unfiltered (_("No breakpoint number %d.\n"), num
);
7370 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
7371 If from_tty is nonzero, it prints a message to that effect,
7372 which ends with a period (no newline). */
7375 disable_breakpoint (struct breakpoint
*bpt
)
7377 /* Never disable a watchpoint scope breakpoint; we want to
7378 hit them when we leave scope so we can delete both the
7379 watchpoint and its scope breakpoint at that time. */
7380 if (bpt
->type
== bp_watchpoint_scope
)
7383 /* You can't disable permanent breakpoints. */
7384 if (bpt
->enable_state
== bp_permanent
)
7387 bpt
->enable_state
= bp_disabled
;
7389 check_duplicates (bpt
);
7391 if (deprecated_modify_breakpoint_hook
)
7392 deprecated_modify_breakpoint_hook (bpt
);
7393 breakpoint_modify_event (bpt
->number
);
7397 disable_command (char *args
, int from_tty
)
7399 struct breakpoint
*bpt
;
7401 ALL_BREAKPOINTS (bpt
)
7405 warning (_("attempted to disable apparently deleted breakpoint #%d?"),
7410 case bp_catch_unload
:
7412 case bp_catch_vfork
:
7414 case bp_catch_catch
:
7415 case bp_catch_throw
:
7416 case bp_hardware_breakpoint
:
7418 case bp_hardware_watchpoint
:
7419 case bp_read_watchpoint
:
7420 case bp_access_watchpoint
:
7421 disable_breakpoint (bpt
);
7426 map_breakpoint_numbers (args
, disable_breakpoint
);
7430 do_enable_breakpoint (struct breakpoint
*bpt
, enum bpdisp disposition
)
7432 int target_resources_ok
, other_type_used
;
7435 if (bpt
->type
== bp_hardware_breakpoint
)
7438 i
= hw_breakpoint_used_count ();
7439 target_resources_ok
=
7440 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
7442 if (target_resources_ok
== 0)
7443 error (_("No hardware breakpoint support in the target."));
7444 else if (target_resources_ok
< 0)
7445 error (_("Hardware breakpoints used exceeds limit."));
7450 if (bpt
->enable_state
!= bp_enabled
)
7452 /* When enabling a pending breakpoint, we need to check if the breakpoint
7453 is resolvable since shared libraries could have been loaded
7454 after the breakpoint was disabled. */
7455 breakpoints_changed ();
7456 if (resolve_pending_breakpoint (bpt
) == GDB_RC_OK
)
7458 delete_breakpoint (bpt
);
7461 bpt
->enable_state
= bp_enabled
;
7462 bpt
->disposition
= disposition
;
7465 else /* Not a pending breakpoint. */
7467 if (bpt
->enable_state
!= bp_permanent
)
7468 bpt
->enable_state
= bp_enabled
;
7469 bpt
->disposition
= disposition
;
7470 check_duplicates (bpt
);
7471 breakpoints_changed ();
7473 if (bpt
->type
== bp_watchpoint
||
7474 bpt
->type
== bp_hardware_watchpoint
||
7475 bpt
->type
== bp_read_watchpoint
||
7476 bpt
->type
== bp_access_watchpoint
)
7478 struct frame_id saved_frame_id
;
7480 saved_frame_id
= get_frame_id (get_selected_frame (NULL
));
7481 if (bpt
->exp_valid_block
!= NULL
)
7483 struct frame_info
*fr
=
7484 fr
= frame_find_by_id (bpt
->watchpoint_frame
);
7487 printf_filtered (_("\
7488 Cannot enable watchpoint %d because the block in which its expression\n\
7489 is valid is not currently in scope.\n"), bpt
->number
);
7490 bpt
->enable_state
= bp_disabled
;
7496 value_free (bpt
->val
);
7497 mark
= value_mark ();
7498 bpt
->val
= evaluate_expression (bpt
->exp
);
7499 release_value (bpt
->val
);
7500 if (value_lazy (bpt
->val
))
7501 value_fetch_lazy (bpt
->val
);
7503 if (bpt
->type
== bp_hardware_watchpoint
||
7504 bpt
->type
== bp_read_watchpoint
||
7505 bpt
->type
== bp_access_watchpoint
)
7507 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
7508 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
7510 /* Hack around 'unused var' error for some targets here */
7512 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
7513 bpt
->type
, i
+ mem_cnt
, other_type_used
);
7514 /* we can consider of type is bp_hardware_watchpoint, convert to
7515 bp_watchpoint in the following condition */
7516 if (target_resources_ok
< 0)
7518 printf_filtered (_("\
7519 Cannot enable watchpoint %d because target watch resources\n\
7520 have been allocated for other watchpoints.\n"), bpt
->number
);
7521 bpt
->enable_state
= bp_disabled
;
7522 value_free_to_mark (mark
);
7527 select_frame (frame_find_by_id (saved_frame_id
));
7528 value_free_to_mark (mark
);
7532 if (deprecated_modify_breakpoint_hook
)
7533 deprecated_modify_breakpoint_hook (bpt
);
7534 breakpoint_modify_event (bpt
->number
);
7538 enable_breakpoint (struct breakpoint
*bpt
)
7540 do_enable_breakpoint (bpt
, bpt
->disposition
);
7543 /* The enable command enables the specified breakpoints (or all defined
7544 breakpoints) so they once again become (or continue to be) effective
7545 in stopping the inferior. */
7548 enable_command (char *args
, int from_tty
)
7550 struct breakpoint
*bpt
;
7552 ALL_BREAKPOINTS (bpt
)
7556 warning (_("attempted to enable apparently deleted breakpoint #%d?"),
7561 case bp_catch_unload
:
7563 case bp_catch_vfork
:
7565 case bp_catch_catch
:
7566 case bp_catch_throw
:
7567 case bp_hardware_breakpoint
:
7569 case bp_hardware_watchpoint
:
7570 case bp_read_watchpoint
:
7571 case bp_access_watchpoint
:
7572 enable_breakpoint (bpt
);
7577 map_breakpoint_numbers (args
, enable_breakpoint
);
7581 enable_once_breakpoint (struct breakpoint
*bpt
)
7583 do_enable_breakpoint (bpt
, disp_disable
);
7587 enable_once_command (char *args
, int from_tty
)
7589 map_breakpoint_numbers (args
, enable_once_breakpoint
);
7593 enable_delete_breakpoint (struct breakpoint
*bpt
)
7595 do_enable_breakpoint (bpt
, disp_del
);
7599 enable_delete_command (char *args
, int from_tty
)
7601 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
7605 set_breakpoint_cmd (char *args
, int from_tty
)
7610 show_breakpoint_cmd (char *args
, int from_tty
)
7614 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
7616 struct symtabs_and_lines
7617 decode_line_spec_1 (char *string
, int funfirstline
)
7619 struct symtabs_and_lines sals
;
7621 error (_("Empty line specification."));
7622 if (default_breakpoint_valid
)
7623 sals
= decode_line_1 (&string
, funfirstline
,
7624 default_breakpoint_symtab
,
7625 default_breakpoint_line
,
7626 (char ***) NULL
, NULL
);
7628 sals
= decode_line_1 (&string
, funfirstline
,
7629 (struct symtab
*) NULL
, 0, (char ***) NULL
, NULL
);
7631 error (_("Junk at end of line specification: %s"), string
);
7636 _initialize_breakpoint (void)
7638 static struct cmd_list_element
*breakpoint_set_cmdlist
;
7639 static struct cmd_list_element
*breakpoint_show_cmdlist
;
7640 struct cmd_list_element
*c
;
7642 observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib
);
7644 breakpoint_chain
= 0;
7645 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
7646 before a breakpoint is set. */
7647 breakpoint_count
= 0;
7649 add_com ("ignore", class_breakpoint
, ignore_command
, _("\
7650 Set ignore-count of breakpoint number N to COUNT.\n\
7651 Usage is `ignore N COUNT'."));
7653 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
7655 add_com ("commands", class_breakpoint
, commands_command
, _("\
7656 Set commands to be executed when a breakpoint is hit.\n\
7657 Give breakpoint number as argument after \"commands\".\n\
7658 With no argument, the targeted breakpoint is the last one set.\n\
7659 The commands themselves follow starting on the next line.\n\
7660 Type a line containing \"end\" to indicate the end of them.\n\
7661 Give \"silent\" as the first line to make the breakpoint silent;\n\
7662 then no output is printed when it is hit, except what the commands print."));
7664 add_com ("condition", class_breakpoint
, condition_command
, _("\
7665 Specify breakpoint number N to break only if COND is true.\n\
7666 Usage is `condition N COND', where N is an integer and COND is an\n\
7667 expression to be evaluated whenever breakpoint N is reached."));
7669 c
= add_com ("tbreak", class_breakpoint
, tbreak_command
, _("\
7670 Set a temporary breakpoint. Args like \"break\" command.\n\
7671 Like \"break\" except the breakpoint is only temporary,\n\
7672 so it will be deleted when hit. Equivalent to \"break\" followed\n\
7673 by using \"enable delete\" on the breakpoint number."));
7674 set_cmd_completer (c
, location_completer
);
7676 c
= add_com ("hbreak", class_breakpoint
, hbreak_command
, _("\
7677 Set a hardware assisted breakpoint. Args like \"break\" command.\n\
7678 Like \"break\" except the breakpoint requires hardware support,\n\
7679 some target hardware may not have this support."));
7680 set_cmd_completer (c
, location_completer
);
7682 c
= add_com ("thbreak", class_breakpoint
, thbreak_command
, _("\
7683 Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
7684 Like \"hbreak\" except the breakpoint is only temporary,\n\
7685 so it will be deleted when hit."));
7686 set_cmd_completer (c
, location_completer
);
7688 add_prefix_cmd ("enable", class_breakpoint
, enable_command
, _("\
7689 Enable some breakpoints.\n\
7690 Give breakpoint numbers (separated by spaces) as arguments.\n\
7691 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7692 This is used to cancel the effect of the \"disable\" command.\n\
7693 With a subcommand you can enable temporarily."),
7694 &enablelist
, "enable ", 1, &cmdlist
);
7696 add_com ("ab", class_breakpoint
, enable_command
, _("\
7697 Enable some breakpoints.\n\
7698 Give breakpoint numbers (separated by spaces) as arguments.\n\
7699 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7700 This is used to cancel the effect of the \"disable\" command.\n\
7701 With a subcommand you can enable temporarily."));
7703 add_com_alias ("en", "enable", class_breakpoint
, 1);
7705 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
, _("\
7706 Enable some breakpoints.\n\
7707 Give breakpoint numbers (separated by spaces) as arguments.\n\
7708 This is used to cancel the effect of the \"disable\" command.\n\
7709 May be abbreviated to simply \"enable\".\n"),
7710 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
7712 add_cmd ("once", no_class
, enable_once_command
, _("\
7713 Enable breakpoints for one hit. Give breakpoint numbers.\n\
7714 If a breakpoint is hit while enabled in this fashion, it becomes disabled."),
7717 add_cmd ("delete", no_class
, enable_delete_command
, _("\
7718 Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7719 If a breakpoint is hit while enabled in this fashion, it is deleted."),
7722 add_cmd ("delete", no_class
, enable_delete_command
, _("\
7723 Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7724 If a breakpoint is hit while enabled in this fashion, it is deleted."),
7727 add_cmd ("once", no_class
, enable_once_command
, _("\
7728 Enable breakpoints for one hit. Give breakpoint numbers.\n\
7729 If a breakpoint is hit while enabled in this fashion, it becomes disabled."),
7732 add_prefix_cmd ("disable", class_breakpoint
, disable_command
, _("\
7733 Disable some breakpoints.\n\
7734 Arguments are breakpoint numbers with spaces in between.\n\
7735 To disable all breakpoints, give no argument.\n\
7736 A disabled breakpoint is not forgotten, but has no effect until reenabled."),
7737 &disablelist
, "disable ", 1, &cmdlist
);
7738 add_com_alias ("dis", "disable", class_breakpoint
, 1);
7739 add_com_alias ("disa", "disable", class_breakpoint
, 1);
7741 add_com ("sb", class_breakpoint
, disable_command
, _("\
7742 Disable some breakpoints.\n\
7743 Arguments are breakpoint numbers with spaces in between.\n\
7744 To disable all breakpoints, give no argument.\n\
7745 A disabled breakpoint is not forgotten, but has no effect until reenabled."));
7747 add_cmd ("breakpoints", class_alias
, disable_command
, _("\
7748 Disable some breakpoints.\n\
7749 Arguments are breakpoint numbers with spaces in between.\n\
7750 To disable all breakpoints, give no argument.\n\
7751 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
7752 This command may be abbreviated \"disable\"."),
7755 add_prefix_cmd ("delete", class_breakpoint
, delete_command
, _("\
7756 Delete some breakpoints or auto-display expressions.\n\
7757 Arguments are breakpoint numbers with spaces in between.\n\
7758 To delete all breakpoints, give no argument.\n\
7760 Also a prefix command for deletion of other GDB objects.\n\
7761 The \"unset\" command is also an alias for \"delete\"."),
7762 &deletelist
, "delete ", 1, &cmdlist
);
7763 add_com_alias ("d", "delete", class_breakpoint
, 1);
7765 add_com ("db", class_breakpoint
, delete_command
, _("\
7766 Delete some breakpoints.\n\
7767 Arguments are breakpoint numbers with spaces in between.\n\
7768 To delete all breakpoints, give no argument.\n"));
7770 add_cmd ("breakpoints", class_alias
, delete_command
, _("\
7771 Delete some breakpoints or auto-display expressions.\n\
7772 Arguments are breakpoint numbers with spaces in between.\n\
7773 To delete all breakpoints, give no argument.\n\
7774 This command may be abbreviated \"delete\"."),
7777 add_com ("clear", class_breakpoint
, clear_command
, _("\
7778 Clear breakpoint at specified line or function.\n\
7779 Argument may be line number, function name, or \"*\" and an address.\n\
7780 If line number is specified, all breakpoints in that line are cleared.\n\
7781 If function is specified, breakpoints at beginning of function are cleared.\n\
7782 If an address is specified, breakpoints at that address are cleared.\n\
7784 With no argument, clears all breakpoints in the line that the selected frame\n\
7787 See also the \"delete\" command which clears breakpoints by number."));
7789 c
= add_com ("break", class_breakpoint
, break_command
, _("\
7790 Set breakpoint at specified line or function.\n\
7791 Argument may be line number, function name, or \"*\" and an address.\n\
7792 If line number is specified, break at start of code for that line.\n\
7793 If function is specified, break at start of code for that function.\n\
7794 If an address is specified, break at that exact address.\n\
7795 With no arg, uses current execution address of selected stack frame.\n\
7796 This is useful for breaking on return to a stack frame.\n\
7798 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7800 Do \"help breakpoints\" for info on other commands dealing with breakpoints."));
7801 set_cmd_completer (c
, location_completer
);
7803 add_com_alias ("b", "break", class_run
, 1);
7804 add_com_alias ("br", "break", class_run
, 1);
7805 add_com_alias ("bre", "break", class_run
, 1);
7806 add_com_alias ("brea", "break", class_run
, 1);
7810 add_com_alias ("ba", "break", class_breakpoint
, 1);
7811 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
7816 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
, _("\
7817 Break in function/address or break at a line in the current file."),
7818 &stoplist
, "stop ", 1, &cmdlist
);
7819 add_cmd ("in", class_breakpoint
, stopin_command
,
7820 _("Break in function or address."), &stoplist
);
7821 add_cmd ("at", class_breakpoint
, stopat_command
,
7822 _("Break at a line in the current file."), &stoplist
);
7823 add_com ("status", class_info
, breakpoints_info
, _("\
7824 Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7825 The \"Type\" column indicates one of:\n\
7826 \tbreakpoint - normal breakpoint\n\
7827 \twatchpoint - watchpoint\n\
7828 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7829 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7830 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7831 address and file/line number respectively.\n\
7833 Convenience variable \"$_\" and default examine address for \"x\"\n\
7834 are set to the address of the last breakpoint listed.\n\n\
7835 Convenience variable \"$bpnum\" contains the number of the last\n\
7839 add_info ("breakpoints", breakpoints_info
, _("\
7840 Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7841 The \"Type\" column indicates one of:\n\
7842 \tbreakpoint - normal breakpoint\n\
7843 \twatchpoint - watchpoint\n\
7844 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7845 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7846 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7847 address and file/line number respectively.\n\
7849 Convenience variable \"$_\" and default examine address for \"x\"\n\
7850 are set to the address of the last breakpoint listed.\n\n\
7851 Convenience variable \"$bpnum\" contains the number of the last\n\
7855 add_com ("lb", class_breakpoint
, breakpoints_info
, _("\
7856 Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7857 The \"Type\" column indicates one of:\n\
7858 \tbreakpoint - normal breakpoint\n\
7859 \twatchpoint - watchpoint\n\
7860 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7861 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7862 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7863 address and file/line number respectively.\n\
7865 Convenience variable \"$_\" and default examine address for \"x\"\n\
7866 are set to the address of the last breakpoint listed.\n\n\
7867 Convenience variable \"$bpnum\" contains the number of the last\n\
7870 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
, _("\
7871 Status of all breakpoints, or breakpoint number NUMBER.\n\
7872 The \"Type\" column indicates one of:\n\
7873 \tbreakpoint - normal breakpoint\n\
7874 \twatchpoint - watchpoint\n\
7875 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7876 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7877 \tuntil - internal breakpoint used by the \"until\" command\n\
7878 \tfinish - internal breakpoint used by the \"finish\" command\n\
7879 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7880 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7881 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7882 address and file/line number respectively.\n\
7884 Convenience variable \"$_\" and default examine address for \"x\"\n\
7885 are set to the address of the last breakpoint listed.\n\
7887 Convenience variable \"$bpnum\" contains the number of the last\n\
7889 &maintenanceinfolist
);
7891 add_com ("catch", class_breakpoint
, catch_command
, _("\
7892 Set catchpoints to catch events.\n\
7893 Raised signals may be caught:\n\
7894 \tcatch signal - all signals\n\
7895 \tcatch signal <signame> - a particular signal\n\
7896 Raised exceptions may be caught:\n\
7897 \tcatch throw - all exceptions, when thrown\n\
7898 \tcatch throw <exceptname> - a particular exception, when thrown\n\
7899 \tcatch catch - all exceptions, when caught\n\
7900 \tcatch catch <exceptname> - a particular exception, when caught\n\
7901 Thread or process events may be caught:\n\
7902 \tcatch thread_start - any threads, just after creation\n\
7903 \tcatch thread_exit - any threads, just before expiration\n\
7904 \tcatch thread_join - any threads, just after joins\n\
7905 Process events may be caught:\n\
7906 \tcatch start - any processes, just after creation\n\
7907 \tcatch exit - any processes, just before expiration\n\
7908 \tcatch fork - calls to fork()\n\
7909 \tcatch vfork - calls to vfork()\n\
7910 \tcatch exec - calls to exec()\n\
7911 Dynamically-linked library events may be caught:\n\
7912 \tcatch load - loads of any library\n\
7913 \tcatch load <libname> - loads of a particular library\n\
7914 \tcatch unload - unloads of any library\n\
7915 \tcatch unload <libname> - unloads of a particular library\n\
7916 The act of your program's execution stopping may also be caught:\n\
7918 C++ exceptions may be caught:\n\
7919 \tcatch throw - all exceptions, when thrown\n\
7920 \tcatch catch - all exceptions, when caught\n\
7922 Do \"help set follow-fork-mode\" for info on debugging your program\n\
7923 after a fork or vfork is caught.\n\n\
7924 Do \"help breakpoints\" for info on other commands dealing with breakpoints."));
7926 add_com ("tcatch", class_breakpoint
, tcatch_command
, _("\
7927 Set temporary catchpoints to catch events.\n\
7928 Args like \"catch\" command.\n\
7929 Like \"catch\" except the catchpoint is only temporary,\n\
7930 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7931 by using \"enable delete\" on the catchpoint number."));
7933 c
= add_com ("watch", class_breakpoint
, watch_command
, _("\
7934 Set a watchpoint for an expression.\n\
7935 A watchpoint stops execution of your program whenever the value of\n\
7936 an expression changes."));
7937 set_cmd_completer (c
, location_completer
);
7939 c
= add_com ("rwatch", class_breakpoint
, rwatch_command
, _("\
7940 Set a read watchpoint for an expression.\n\
7941 A watchpoint stops execution of your program whenever the value of\n\
7942 an expression is read."));
7943 set_cmd_completer (c
, location_completer
);
7945 c
= add_com ("awatch", class_breakpoint
, awatch_command
, _("\
7946 Set a watchpoint for an expression.\n\
7947 A watchpoint stops execution of your program whenever the value of\n\
7948 an expression is either read or written."));
7949 set_cmd_completer (c
, location_completer
);
7951 add_info ("watchpoints", breakpoints_info
,
7952 _("Synonym for ``info breakpoints''."));
7955 /* XXX: cagney/2005-02-23: This should be a boolean, and should
7956 respond to changes - contrary to the description. */
7957 add_setshow_zinteger_cmd ("can-use-hw-watchpoints", class_support
,
7958 &can_use_hw_watchpoints
, _("\
7959 Set debugger's willingness to use watchpoint hardware."), _("\
7960 Show debugger's willingness to use watchpoint hardware."), _("\
7961 If zero, gdb will not use hardware for new watchpoints, even if\n\
7962 such is available. (However, any hardware watchpoints that were\n\
7963 created before setting this to nonzero, will continue to use watchpoint\n\
7966 show_can_use_hw_watchpoints
,
7967 &setlist
, &showlist
);
7969 can_use_hw_watchpoints
= 1;
7971 add_prefix_cmd ("breakpoint", class_maintenance
, set_breakpoint_cmd
, _("\
7972 Breakpoint specific settings\n\
7973 Configure various breakpoint-specific variables such as\n\
7974 pending breakpoint behavior"),
7975 &breakpoint_set_cmdlist
, "set breakpoint ",
7976 0/*allow-unknown*/, &setlist
);
7977 add_prefix_cmd ("breakpoint", class_maintenance
, show_breakpoint_cmd
, _("\
7978 Breakpoint specific settings\n\
7979 Configure various breakpoint-specific variables such as\n\
7980 pending breakpoint behavior"),
7981 &breakpoint_show_cmdlist
, "show breakpoint ",
7982 0/*allow-unknown*/, &showlist
);
7984 add_setshow_auto_boolean_cmd ("pending", no_class
,
7985 &pending_break_support
, _("\
7986 Set debugger's behavior regarding pending breakpoints."), _("\
7987 Show debugger's behavior regarding pending breakpoints."), _("\
7988 If on, an unrecognized breakpoint location will cause gdb to create a\n\
7989 pending breakpoint. If off, an unrecognized breakpoint location results in\n\
7990 an error. If auto, an unrecognized breakpoint location results in a\n\
7991 user-query to see if a pending breakpoint should be created."),
7993 show_pending_break_support
,
7994 &breakpoint_set_cmdlist
,
7995 &breakpoint_show_cmdlist
);
7997 pending_break_support
= AUTO_BOOLEAN_AUTO
;