1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "breakpoint.h"
28 #include "expression.h"
34 #include "gdbthread.h"
37 #include "gdb_string.h"
43 #include "gdb-events.h"
45 /* Prototypes for local functions. */
47 static void until_break_command_continuation (struct continuation_arg
*arg
);
50 catch_command_1
PARAMS ((char *, int, int));
53 enable_delete_command
PARAMS ((char *, int));
56 enable_delete_breakpoint
PARAMS ((struct breakpoint
*));
59 enable_once_command
PARAMS ((char *, int));
62 enable_once_breakpoint
PARAMS ((struct breakpoint
*));
65 disable_command
PARAMS ((char *, int));
68 enable_command
PARAMS ((char *, int));
71 map_breakpoint_numbers
PARAMS ((char *, void (*)(struct breakpoint
*)));
74 ignore_command
PARAMS ((char *, int));
76 static int breakpoint_re_set_one
PARAMS ((PTR
));
79 clear_command
PARAMS ((char *, int));
82 catch_command
PARAMS ((char *, int));
85 handle_gnu_4_16_catch_command
PARAMS ((char *, int, int));
87 static struct symtabs_and_lines
88 get_catch_sals
PARAMS ((int));
91 watch_command
PARAMS ((char *, int));
94 can_use_hardware_watchpoint
PARAMS ((struct value
*));
96 static void break_at_finish_command
PARAMS ((char *, int));
97 static void break_at_finish_at_depth_command
PARAMS ((char *, int));
100 tbreak_command
PARAMS ((char *, int));
102 static void tbreak_at_finish_command
PARAMS ((char *, int));
105 break_command_1
PARAMS ((char *, int, int));
108 mention
PARAMS ((struct breakpoint
*));
111 set_raw_breakpoint
PARAMS ((struct symtab_and_line
));
114 check_duplicates
PARAMS ((CORE_ADDR
, asection
*));
117 describe_other_breakpoints
PARAMS ((CORE_ADDR
, asection
*));
120 breakpoints_info
PARAMS ((char *, int));
123 breakpoint_1
PARAMS ((int, int));
126 bpstat_alloc
PARAMS ((struct breakpoint
*, bpstat
));
128 static int breakpoint_cond_eval
PARAMS ((PTR
));
131 cleanup_executing_breakpoints
PARAMS ((PTR
));
134 commands_command
PARAMS ((char *, int));
137 condition_command
PARAMS ((char *, int));
140 get_number
PARAMS ((char **));
143 set_breakpoint_count
PARAMS ((int));
146 static struct breakpoint
*
147 create_temp_exception_breakpoint
PARAMS ((CORE_ADDR
));
158 remove_breakpoint
PARAMS ((struct breakpoint
*, insertion_state_t
));
160 static enum print_stop_action print_it_typical
PARAMS ((bpstat
));
162 static enum print_stop_action
print_bp_stop_message (bpstat bs
);
166 enum exception_event_kind kind
;
169 args_for_catchpoint_enable
;
171 static int watchpoint_check
PARAMS ((PTR
));
173 static int cover_target_enable_exception_callback
PARAMS ((PTR
));
175 static void maintenance_info_breakpoints
PARAMS ((char *, int));
177 #ifdef GET_LONGJMP_TARGET
178 static void create_longjmp_breakpoint
PARAMS ((char *));
181 static int hw_breakpoint_used_count
PARAMS ((void));
183 static int hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
185 static void hbreak_command
PARAMS ((char *, int));
187 static void thbreak_command
PARAMS ((char *, int));
189 static void watch_command_1
PARAMS ((char *, int, int));
191 static void rwatch_command
PARAMS ((char *, int));
193 static void awatch_command
PARAMS ((char *, int));
195 static void do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
197 static void solib_load_unload_1
PARAMS ((char *hookname
,
201 enum bptype bp_kind
));
203 static void create_fork_vfork_event_catchpoint
PARAMS ((int tempflag
,
205 enum bptype bp_kind
));
207 static void break_at_finish_at_depth_command_1
PARAMS ((char *arg
,
211 static void break_at_finish_command_1
PARAMS ((char *arg
,
215 static void stop_command
PARAMS ((char *arg
, int from_tty
));
217 static void stopin_command
PARAMS ((char *arg
, int from_tty
));
219 static void stopat_command
PARAMS ((char *arg
, int from_tty
));
221 static char *ep_find_event_name_end
PARAMS ((char *arg
));
223 static char *ep_parse_optional_if_clause
PARAMS ((char **arg
));
225 static char *ep_parse_optional_filename
PARAMS ((char **arg
));
227 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
228 static void catch_exec_command_1
PARAMS ((char *arg
, int tempflag
,
232 static void create_exception_catchpoint
233 PARAMS ((int tempflag
, char *cond_string
,
234 enum exception_event_kind ex_event
,
235 struct symtab_and_line
* sal
));
237 static void catch_exception_command_1
238 PARAMS ((enum exception_event_kind ex_event
,
239 char *arg
, int tempflag
, int from_tty
));
241 static void tcatch_command
PARAMS ((char *arg
, int from_tty
));
243 static void ep_skip_leading_whitespace
PARAMS ((char **s
));
245 /* Prototypes for exported functions. */
248 awatch_command
PARAMS ((char *, int));
251 do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
253 /* If FALSE, gdb will not use hardware support for watchpoints, even
254 if such is available. */
255 static int can_use_hw_watchpoints
;
257 void _initialize_breakpoint
PARAMS ((void));
259 void set_breakpoint_count
PARAMS ((int));
261 extern int addressprint
; /* Print machine addresses? */
263 #if defined (GET_LONGJMP_TARGET) || defined (SOLIB_ADD)
264 static int internal_breakpoint_number
= -1;
267 /* Are we executing breakpoint commands? */
268 static int executing_breakpoint_commands
;
270 /* Walk the following statement or block through all breakpoints.
271 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
274 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
276 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
277 for (b = breakpoint_chain; \
278 b? (tmp=b->next, 1): 0; \
281 /* True if SHIFT_INST_REGS defined, false otherwise. */
283 int must_shift_inst_regs
=
284 #if defined(SHIFT_INST_REGS)
291 /* True if breakpoint hit counts should be displayed in breakpoint info. */
293 int show_breakpoint_hit_counts
= 1;
295 /* Chain of all breakpoints defined. */
297 struct breakpoint
*breakpoint_chain
;
299 /* Number of last breakpoint made. */
301 int breakpoint_count
;
303 /* Pointer to current exception event record */
304 static struct exception_event_record
*current_exception_event
;
306 /* Indicator of whether exception catchpoints should be nuked
307 between runs of a program */
308 int exception_catchpoints_are_fragile
= 0;
310 /* Indicator of when exception catchpoints set-up should be
311 reinitialized -- e.g. when program is re-run */
312 int exception_support_initialized
= 0;
314 /* This function returns a pointer to the string representation of the
315 pathname of the dynamically-linked library that has just been
318 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
319 or undefined results are guaranteed.
321 This string's contents are only valid immediately after the
322 inferior has stopped in the dynamic linker hook, and becomes
323 invalid as soon as the inferior is continued. Clients should make
324 a copy of this string if they wish to continue the inferior and
325 then access the string. */
327 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
328 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
331 /* This function returns a pointer to the string representation of the
332 pathname of the dynamically-linked library that has just been
335 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
336 TRUE, or undefined results are guaranteed.
338 This string's contents are only valid immediately after the
339 inferior has stopped in the dynamic linker hook, and becomes
340 invalid as soon as the inferior is continued. Clients should make
341 a copy of this string if they wish to continue the inferior and
342 then access the string. */
344 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
345 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
348 /* This function is called by the "catch load" command. It allows the
349 debugger to be notified by the dynamic linker when a specified
350 library file (or any library file, if filename is NULL) is loaded. */
352 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
353 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
354 error ("catch of library loads not yet implemented on this platform")
357 /* This function is called by the "catch unload" command. It allows
358 the debugger to be notified by the dynamic linker when a specified
359 library file (or any library file, if filename is NULL) is
362 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
363 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
364 error ("catch of library unloads not yet implemented on this platform")
367 /* Set breakpoint count to NUM. */
370 set_breakpoint_count (num
)
373 breakpoint_count
= num
;
374 set_internalvar (lookup_internalvar ("bpnum"),
375 value_from_longest (builtin_type_int
, (LONGEST
) num
));
378 /* Used in run_command to zero the hit count when a new run starts. */
381 clear_breakpoint_hit_counts ()
383 struct breakpoint
*b
;
389 /* Default address, symtab and line to put a breakpoint at
390 for "break" command with no arg.
391 if default_breakpoint_valid is zero, the other three are
392 not valid, and "break" with no arg is an error.
394 This set by print_stack_frame, which calls set_default_breakpoint. */
396 int default_breakpoint_valid
;
397 CORE_ADDR default_breakpoint_address
;
398 struct symtab
*default_breakpoint_symtab
;
399 int default_breakpoint_line
;
401 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
402 Advance *PP after the string and any trailing whitespace.
404 Currently the string can either be a number or "$" followed by the name
405 of a convenience variable. Making it an expression wouldn't work well
406 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
415 /* Empty line means refer to the last breakpoint. */
416 return breakpoint_count
;
419 /* Make a copy of the name, so we can null-terminate it
420 to pass to lookup_internalvar(). */
425 while (isalnum (*p
) || *p
== '_')
427 varname
= (char *) alloca (p
- start
+ 1);
428 strncpy (varname
, start
, p
- start
);
429 varname
[p
- start
] = '\0';
430 val
= value_of_internalvar (lookup_internalvar (varname
));
431 if (TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_INT
)
433 "Convenience variables used to specify breakpoints must have integer values."
435 retval
= (int) value_as_long (val
);
441 while (*p
>= '0' && *p
<= '9')
444 /* There is no number here. (e.g. "cond a == b"). */
445 error_no_arg ("breakpoint number");
448 if (!(isspace (*p
) || *p
== '\0'))
449 error ("breakpoint number expected");
456 /* condition N EXP -- set break condition of breakpoint N to EXP. */
459 condition_command (arg
, from_tty
)
463 register struct breakpoint
*b
;
468 error_no_arg ("breakpoint number");
471 bnum
= get_number (&p
);
474 if (b
->number
== bnum
)
478 free ((PTR
) b
->cond
);
481 if (b
->cond_string
!= NULL
)
482 free ((PTR
) b
->cond_string
);
487 b
->cond_string
= NULL
;
489 printf_filtered ("Breakpoint %d now unconditional.\n", bnum
);
494 /* I don't know if it matters whether this is the string the user
495 typed in or the decompiled expression. */
496 b
->cond_string
= savestring (arg
, strlen (arg
));
497 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->address
), 0);
499 error ("Junk at end of expression");
501 breakpoints_changed ();
505 error ("No breakpoint number %d.", bnum
);
510 commands_command (arg
, from_tty
)
514 register struct breakpoint
*b
;
517 struct command_line
*l
;
519 /* If we allowed this, we would have problems with when to
520 free the storage, if we change the commands currently
523 if (executing_breakpoint_commands
)
524 error ("Can't use the \"commands\" command among a breakpoint's commands.");
527 bnum
= get_number (&p
);
529 error ("Unexpected extra arguments following breakpoint number.");
532 if (b
->number
== bnum
)
536 "Type commands for when breakpoint %d is hit, one per line.",
538 l
= read_command_lines (tmpbuf
, from_tty
);
539 free_command_lines (&b
->commands
);
541 breakpoints_changed ();
544 error ("No breakpoint number %d.", bnum
);
547 /* Like target_read_memory() but if breakpoints are inserted, return
548 the shadow contents instead of the breakpoints themselves.
550 Read "memory data" from whatever target or inferior we have.
551 Returns zero if successful, errno value if not. EIO is used
552 for address out of bounds. If breakpoints are inserted, returns
553 shadow contents, not the breakpoints themselves. From breakpoint.c. */
556 read_memory_nobpt (memaddr
, myaddr
, len
)
562 struct breakpoint
*b
;
563 CORE_ADDR bp_addr
= 0;
566 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
567 /* No breakpoints on this machine. */
568 return target_read_memory (memaddr
, myaddr
, len
);
572 if (b
->type
== bp_none
)
573 warning ("reading through apparently deleted breakpoint #%d?",
576 /* memory breakpoint? */
577 if (b
->type
== bp_watchpoint
578 || b
->type
== bp_hardware_watchpoint
579 || b
->type
== bp_read_watchpoint
580 || b
->type
== bp_access_watchpoint
)
585 /* Addresses and length of the part of the breakpoint that
587 /* XXXX The m68k, sh and h8300 have different local and remote
588 breakpoint values. BREAKPOINT_FROM_PC still manages to
589 correctly determine the breakpoints memory address and size
590 for these targets. */
591 bp_addr
= b
->address
;
593 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
598 if (bp_addr
+ bp_size
<= memaddr
)
599 /* The breakpoint is entirely before the chunk of memory we
602 if (bp_addr
>= memaddr
+ len
)
603 /* The breakpoint is entirely after the chunk of memory we are
606 /* Copy the breakpoint from the shadow contents, and recurse for
607 the things before and after. */
609 /* Offset within shadow_contents. */
612 if (bp_addr
< memaddr
)
614 /* Only copy the second part of the breakpoint. */
615 bp_size
-= memaddr
- bp_addr
;
616 bptoffset
= memaddr
- bp_addr
;
620 if (bp_addr
+ bp_size
> memaddr
+ len
)
622 /* Only copy the first part of the breakpoint. */
623 bp_size
-= (bp_addr
+ bp_size
) - (memaddr
+ len
);
626 memcpy (myaddr
+ bp_addr
- memaddr
,
627 b
->shadow_contents
+ bptoffset
, bp_size
);
629 if (bp_addr
> memaddr
)
631 /* Copy the section of memory before the breakpoint. */
632 status
= read_memory_nobpt (memaddr
, myaddr
, bp_addr
- memaddr
);
637 if (bp_addr
+ bp_size
< memaddr
+ len
)
639 /* Copy the section of memory after the breakpoint. */
640 status
= read_memory_nobpt
642 myaddr
+ bp_addr
+ bp_size
- memaddr
,
643 memaddr
+ len
- (bp_addr
+ bp_size
));
650 /* Nothing overlaps. Just call read_memory_noerr. */
651 return target_read_memory (memaddr
, myaddr
, len
);
655 /* insert_breakpoints is used when starting or continuing the program.
656 remove_breakpoints is used when the program stops.
657 Both return zero if successful,
658 or an `errno' value if could not write the inferior. */
661 insert_breakpoints ()
663 register struct breakpoint
*b
, *temp
;
664 int return_val
= 0; /* return success code. */
666 int disabled_breaks
= 0;
668 static char message1
[] = "Error inserting catchpoint %d:\n";
669 static char message
[sizeof (message1
) + 30];
672 ALL_BREAKPOINTS_SAFE (b
, temp
)
674 if (b
->enable
== permanent
)
675 /* Permanent breakpoints cannot be inserted or removed. */
677 else if (b
->type
!= bp_watchpoint
678 && b
->type
!= bp_hardware_watchpoint
679 && b
->type
!= bp_read_watchpoint
680 && b
->type
!= bp_access_watchpoint
681 && b
->type
!= bp_catch_fork
682 && b
->type
!= bp_catch_vfork
683 && b
->type
!= bp_catch_exec
684 && b
->type
!= bp_catch_throw
685 && b
->type
!= bp_catch_catch
686 && b
->enable
!= disabled
687 && b
->enable
!= shlib_disabled
688 && b
->enable
!= call_disabled
692 if (b
->type
== bp_hardware_breakpoint
)
693 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
696 /* Check to see if breakpoint is in an overlay section;
697 if so, we should set the breakpoint at the LMA address.
698 Only if the section is currently mapped should we ALSO
699 set a break at the VMA address. */
700 if (overlay_debugging
&& b
->section
&&
701 section_is_overlay (b
->section
))
705 addr
= overlay_unmapped_address (b
->address
, b
->section
);
706 val
= target_insert_breakpoint (addr
, b
->shadow_contents
);
707 /* This would be the time to check val, to see if the
708 breakpoint write to the load address succeeded.
709 However, this might be an ordinary occurrance, eg. if
710 the unmapped overlay is in ROM. */
711 val
= 0; /* in case unmapped address failed */
712 if (section_is_mapped (b
->section
))
713 val
= target_insert_breakpoint (b
->address
,
716 else /* ordinary (non-overlay) address */
717 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
721 /* Can't set the breakpoint. */
722 #if defined (DISABLE_UNSETTABLE_BREAK)
723 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
725 /* See also: disable_breakpoints_in_shlibs. */
727 b
->enable
= shlib_disabled
;
728 if (!disabled_breaks
)
730 target_terminal_ours_for_output ();
731 warning ("Cannot insert breakpoint %d:", b
->number
);
732 warning ("Temporarily disabling shared library breakpoints:");
735 warning ("breakpoint #%d ", b
->number
);
740 target_terminal_ours_for_output ();
741 warning ("Cannot insert breakpoint %d:", b
->number
);
742 #ifdef ONE_PROCESS_WRITETEXT
743 warning ("The same program may be running in another process.");
745 memory_error (val
, b
->address
); /* which bombs us out */
752 return_val
= val
; /* remember failure */
754 else if (ep_is_exception_catchpoint (b
)
755 && b
->enable
!= disabled
756 && b
->enable
!= shlib_disabled
757 && b
->enable
!= call_disabled
762 /* If we get here, we must have a callback mechanism for exception
763 events -- with g++ style embedded label support, we insert
764 ordinary breakpoints and not catchpoints. */
765 /* Format possible error message */
766 sprintf (message
, message1
, b
->number
);
768 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
771 /* Couldn't set breakpoint for some reason */
772 target_terminal_ours_for_output ();
773 warning ("Cannot insert catchpoint %d; disabling it.",
775 b
->enable
= disabled
;
779 /* Bp set, now make sure callbacks are enabled */
781 args_for_catchpoint_enable args
;
782 args
.kind
= b
->type
== bp_catch_catch
?
783 EX_EVENT_CATCH
: EX_EVENT_THROW
;
785 val
= catch_errors (cover_target_enable_exception_callback
,
787 message
, RETURN_MASK_ALL
);
788 if (val
!= 0 && val
!= -1)
792 /* Check if something went wrong; val == 0 can be ignored */
795 /* something went wrong */
796 target_terminal_ours_for_output ();
797 warning ("Cannot insert catchpoint %d; disabling it.",
799 b
->enable
= disabled
;
804 return_val
= val
; /* remember failure */
807 else if ((b
->type
== bp_hardware_watchpoint
||
808 b
->type
== bp_read_watchpoint
||
809 b
->type
== bp_access_watchpoint
)
810 && b
->enable
== enabled
814 struct frame_info
*saved_frame
;
815 int saved_level
, within_current_scope
;
816 value_ptr mark
= value_mark ();
819 /* Save the current frame and level so we can restore it after
820 evaluating the watchpoint expression on its own frame. */
821 saved_frame
= selected_frame
;
822 saved_level
= selected_frame_level
;
824 /* Determine if the watchpoint is within scope. */
825 if (b
->exp_valid_block
== NULL
)
826 within_current_scope
= 1;
829 struct frame_info
*fi
;
831 /* There might be no current frame at this moment if we are
832 resuming from a step over a breakpoint.
833 Set up current frame before trying to find the watchpoint
835 get_current_frame ();
836 fi
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
837 within_current_scope
= (fi
!= NULL
);
838 if (within_current_scope
)
839 select_frame (fi
, -1);
842 if (within_current_scope
)
844 /* Evaluate the expression and cut the chain of values
845 produced off from the value chain. */
846 v
= evaluate_expression (b
->exp
);
847 value_release_to_mark (mark
);
852 /* Look at each value on the value chain. */
853 for (; v
; v
= v
->next
)
855 /* If it's a memory location, then we must watch it. */
856 if (v
->lval
== lval_memory
)
861 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
862 len
= TYPE_LENGTH (VALUE_TYPE (v
));
864 if (b
->type
== bp_read_watchpoint
)
866 else if (b
->type
== bp_access_watchpoint
)
869 val
= target_insert_watchpoint (addr
, len
, type
);
878 /* Failure to insert a watchpoint on any memory value in the
879 value chain brings us here. */
882 remove_breakpoint (b
, mark_uninserted
);
883 warning ("Could not insert hardware watchpoint %d.",
890 printf_filtered ("Hardware watchpoint %d deleted", b
->number
);
891 printf_filtered ("because the program has left the block \n");
892 printf_filtered ("in which its expression is valid.\n");
893 if (b
->related_breakpoint
)
894 b
->related_breakpoint
->disposition
= del_at_next_stop
;
895 b
->disposition
= del_at_next_stop
;
898 /* Restore the frame and level. */
899 if ((saved_frame
!= selected_frame
) ||
900 (saved_level
!= selected_frame_level
))
901 select_and_print_frame (saved_frame
, saved_level
);
904 return_val
= val
; /* remember failure */
906 else if ((b
->type
== bp_catch_fork
907 || b
->type
== bp_catch_vfork
908 || b
->type
== bp_catch_exec
)
909 && b
->enable
== enabled
917 val
= target_insert_fork_catchpoint (inferior_pid
);
920 val
= target_insert_vfork_catchpoint (inferior_pid
);
923 val
= target_insert_exec_catchpoint (inferior_pid
);
926 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
931 target_terminal_ours_for_output ();
932 warning ("Cannot insert catchpoint %d.", b
->number
);
938 return_val
= val
; /* remember failure */
947 remove_breakpoints ()
949 register struct breakpoint
*b
;
956 val
= remove_breakpoint (b
, mark_uninserted
);
965 reattach_breakpoints (pid
)
968 register struct breakpoint
*b
;
970 int saved_inferior_pid
= inferior_pid
;
972 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
973 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
978 remove_breakpoint (b
, mark_inserted
);
979 if (b
->type
== bp_hardware_breakpoint
)
980 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
982 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
985 inferior_pid
= saved_inferior_pid
;
990 inferior_pid
= saved_inferior_pid
;
995 update_breakpoints_after_exec ()
997 struct breakpoint
*b
;
998 struct breakpoint
*temp
;
1000 /* Doing this first prevents the badness of having delete_breakpoint()
1001 write a breakpoint's current "shadow contents" to lift the bp. That
1002 shadow is NOT valid after an exec()! */
1003 mark_breakpoints_out ();
1005 ALL_BREAKPOINTS_SAFE (b
, temp
)
1007 /* Solib breakpoints must be explicitly reset after an exec(). */
1008 if (b
->type
== bp_shlib_event
)
1010 delete_breakpoint (b
);
1014 /* Step-resume breakpoints are meaningless after an exec(). */
1015 if (b
->type
== bp_step_resume
)
1017 delete_breakpoint (b
);
1021 /* Ditto the sigtramp handler breakpoints. */
1022 if (b
->type
== bp_through_sigtramp
)
1024 delete_breakpoint (b
);
1028 /* Ditto the exception-handling catchpoints. */
1029 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1031 delete_breakpoint (b
);
1035 /* Don't delete an exec catchpoint, because else the inferior
1036 won't stop when it ought!
1038 Similarly, we probably ought to keep vfork catchpoints, 'cause
1039 on this target, we may not be able to stop when the vfork is
1040 seen, but only when the subsequent exec is seen. (And because
1041 deleting fork catchpoints here but not vfork catchpoints will
1042 seem mysterious to users, keep those too.)
1044 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1045 target address field, if any, is sufficient to have it be reset
1046 automagically. Certainly on HP-UX that's true. */
1047 if ((b
->type
== bp_catch_exec
) ||
1048 (b
->type
== bp_catch_vfork
) ||
1049 (b
->type
== bp_catch_fork
))
1051 b
->address
= (CORE_ADDR
) NULL
;
1055 /* bp_finish is a special case. The only way we ought to be able
1056 to see one of these when an exec() has happened, is if the user
1057 caught a vfork, and then said "finish". Ordinarily a finish just
1058 carries them to the call-site of the current callee, by setting
1059 a temporary bp there and resuming. But in this case, the finish
1060 will carry them entirely through the vfork & exec.
1062 We don't want to allow a bp_finish to remain inserted now. But
1063 we can't safely delete it, 'cause finish_command has a handle to
1064 the bp on a bpstat, and will later want to delete it. There's a
1065 chance (and I've seen it happen) that if we delete the bp_finish
1066 here, that its storage will get reused by the time finish_command
1067 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1068 We really must allow finish_command to delete a bp_finish.
1070 In the absense of a general solution for the "how do we know
1071 it's safe to delete something others may have handles to?"
1072 problem, what we'll do here is just uninsert the bp_finish, and
1073 let finish_command delete it.
1075 (We know the bp_finish is "doomed" in the sense that it's
1076 momentary, and will be deleted as soon as finish_command sees
1077 the inferior stopped. So it doesn't matter that the bp's
1078 address is probably bogus in the new a.out, unlike e.g., the
1079 solib breakpoints.) */
1081 if (b
->type
== bp_finish
)
1086 /* Without a symbolic address, we have little hope of the
1087 pre-exec() address meaning the same thing in the post-exec()
1089 if (b
->addr_string
== NULL
)
1091 delete_breakpoint (b
);
1095 /* If this breakpoint has survived the above battery of checks, then
1096 it must have a symbolic address. Be sure that it gets reevaluated
1097 to a target address, rather than reusing the old evaluation. */
1098 b
->address
= (CORE_ADDR
) NULL
;
1103 detach_breakpoints (pid
)
1106 register struct breakpoint
*b
;
1108 int saved_inferior_pid
= inferior_pid
;
1110 if (pid
== inferior_pid
)
1111 error ("Cannot detach breakpoints of inferior_pid");
1113 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1114 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1119 val
= remove_breakpoint (b
, mark_inserted
);
1122 inferior_pid
= saved_inferior_pid
;
1127 inferior_pid
= saved_inferior_pid
;
1132 remove_breakpoint (b
, is
)
1133 struct breakpoint
*b
;
1134 insertion_state_t is
;
1138 if (b
->enable
== permanent
)
1139 /* Permanent breakpoints cannot be inserted or removed. */
1142 if (b
->type
== bp_none
)
1143 warning ("attempted to remove apparently deleted breakpoint #%d?",
1146 if (b
->type
!= bp_watchpoint
1147 && b
->type
!= bp_hardware_watchpoint
1148 && b
->type
!= bp_read_watchpoint
1149 && b
->type
!= bp_access_watchpoint
1150 && b
->type
!= bp_catch_fork
1151 && b
->type
!= bp_catch_vfork
1152 && b
->type
!= bp_catch_exec
1153 && b
->type
!= bp_catch_catch
1154 && b
->type
!= bp_catch_throw
)
1156 if (b
->type
== bp_hardware_breakpoint
)
1157 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1160 /* Check to see if breakpoint is in an overlay section;
1161 if so, we should remove the breakpoint at the LMA address.
1162 If that is not equal to the raw address, then we should
1163 presumable remove the breakpoint there as well. */
1164 if (overlay_debugging
&& b
->section
&&
1165 section_is_overlay (b
->section
))
1169 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1170 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1171 /* This would be the time to check val, to see if the
1172 shadow breakpoint write to the load address succeeded.
1173 However, this might be an ordinary occurrance, eg. if
1174 the unmapped overlay is in ROM. */
1175 val
= 0; /* in case unmapped address failed */
1176 if (section_is_mapped (b
->section
))
1177 val
= target_remove_breakpoint (b
->address
,
1178 b
->shadow_contents
);
1180 else /* ordinary (non-overlay) address */
1181 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1185 b
->inserted
= (is
== mark_inserted
);
1187 else if ((b
->type
== bp_hardware_watchpoint
||
1188 b
->type
== bp_read_watchpoint
||
1189 b
->type
== bp_access_watchpoint
)
1190 && b
->enable
== enabled
1195 b
->inserted
= (is
== mark_inserted
);
1196 /* Walk down the saved value chain. */
1197 for (v
= b
->val_chain
; v
; v
= v
->next
)
1199 /* For each memory reference remove the watchpoint
1201 if (v
->lval
== lval_memory
)
1206 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1207 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1209 if (b
->type
== bp_read_watchpoint
)
1211 else if (b
->type
== bp_access_watchpoint
)
1214 val
= target_remove_watchpoint (addr
, len
, type
);
1220 /* Failure to remove any of the hardware watchpoints comes here. */
1221 if ((is
== mark_uninserted
) && (b
->inserted
))
1222 warning ("Could not remove hardware watchpoint %d.",
1225 /* Free the saved value chain. We will construct a new one
1226 the next time the watchpoint is inserted. */
1227 for (v
= b
->val_chain
; v
; v
= n
)
1232 b
->val_chain
= NULL
;
1234 else if ((b
->type
== bp_catch_fork
||
1235 b
->type
== bp_catch_vfork
||
1236 b
->type
== bp_catch_exec
)
1237 && b
->enable
== enabled
1244 val
= target_remove_fork_catchpoint (inferior_pid
);
1246 case bp_catch_vfork
:
1247 val
= target_remove_vfork_catchpoint (inferior_pid
);
1250 val
= target_remove_exec_catchpoint (inferior_pid
);
1253 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1258 b
->inserted
= (is
== mark_inserted
);
1260 else if ((b
->type
== bp_catch_catch
||
1261 b
->type
== bp_catch_throw
)
1262 && b
->enable
== enabled
1266 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1269 b
->inserted
= (is
== mark_inserted
);
1271 else if (ep_is_exception_catchpoint (b
)
1272 && b
->inserted
/* sometimes previous insert doesn't happen */
1273 && b
->enable
== enabled
1277 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1281 b
->inserted
= (is
== mark_inserted
);
1287 /* Clear the "inserted" flag in all breakpoints. */
1290 mark_breakpoints_out ()
1292 register struct breakpoint
*b
;
1298 /* Clear the "inserted" flag in all breakpoints and delete any
1299 breakpoints which should go away between runs of the program.
1301 Plus other such housekeeping that has to be done for breakpoints
1304 Note: this function gets called at the end of a run (by
1305 generic_mourn_inferior) and when a run begins (by
1306 init_wait_for_inferior). */
1311 breakpoint_init_inferior (context
)
1312 enum inf_context context
;
1314 register struct breakpoint
*b
, *temp
;
1315 static int warning_needed
= 0;
1317 ALL_BREAKPOINTS_SAFE (b
, temp
)
1324 case bp_watchpoint_scope
:
1326 /* If the call dummy breakpoint is at the entry point it will
1327 cause problems when the inferior is rerun, so we better
1330 Also get rid of scope breakpoints. */
1331 delete_breakpoint (b
);
1335 case bp_hardware_watchpoint
:
1336 case bp_read_watchpoint
:
1337 case bp_access_watchpoint
:
1339 /* Likewise for watchpoints on local expressions. */
1340 if (b
->exp_valid_block
!= NULL
)
1341 delete_breakpoint (b
);
1344 /* Likewise for exception catchpoints in dynamic-linked
1345 executables where required */
1346 if (ep_is_exception_catchpoint (b
) &&
1347 exception_catchpoints_are_fragile
)
1350 delete_breakpoint (b
);
1356 if (exception_catchpoints_are_fragile
)
1357 exception_support_initialized
= 0;
1359 /* Don't issue the warning unless it's really needed... */
1360 if (warning_needed
&& (context
!= inf_exited
))
1362 warning ("Exception catchpoints from last run were deleted.");
1363 warning ("You must reinsert them explicitly.");
1368 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1369 exists at PC. It returns ordinary_breakpoint_here if it's an
1370 ordinary breakpoint, or permanent_breakpoint_here if it's a
1371 permanent breakpoint.
1372 - When continuing from a location with an ordinary breakpoint, we
1373 actually single step once before calling insert_breakpoints.
1374 - When continuing from a localion with a permanent breakpoint, we
1375 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1376 the target, to advance the PC past the breakpoint. */
1378 enum breakpoint_here
1379 breakpoint_here_p (pc
)
1382 register struct breakpoint
*b
;
1383 int any_breakpoint_here
= 0;
1386 if ((b
->enable
== enabled
1387 || b
->enable
== permanent
)
1388 && b
->address
== pc
) /* bp is enabled and matches pc */
1390 if (overlay_debugging
&&
1391 section_is_overlay (b
->section
) &&
1392 !section_is_mapped (b
->section
))
1393 continue; /* unmapped overlay -- can't be a match */
1394 else if (b
->enable
== permanent
)
1395 return permanent_breakpoint_here
;
1397 any_breakpoint_here
= 1;
1400 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1404 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1405 but it only returns true if there is actually a breakpoint inserted
1409 breakpoint_inserted_here_p (pc
)
1412 register struct breakpoint
*b
;
1416 && b
->address
== pc
) /* bp is inserted and matches pc */
1418 if (overlay_debugging
&&
1419 section_is_overlay (b
->section
) &&
1420 !section_is_mapped (b
->section
))
1421 continue; /* unmapped overlay -- can't be a match */
1429 /* Return nonzero if FRAME is a dummy frame. We can't use
1430 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1431 much time, at least using get_saved_register on the 68k. This
1432 means that for this function to work right a port must use the
1433 bp_call_dummy breakpoint. */
1436 frame_in_dummy (frame
)
1437 struct frame_info
*frame
;
1439 struct breakpoint
*b
;
1444 if (USE_GENERIC_DUMMY_FRAMES
)
1445 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1449 if (b
->type
== bp_call_dummy
1450 && b
->frame
== frame
->frame
1451 /* We need to check the PC as well as the frame on the sparc,
1452 for signals.exp in the testsuite. */
1455 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1456 && frame
->pc
<= b
->address
)
1462 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1463 is valid for process/thread PID. */
1466 breakpoint_thread_match (pc
, pid
)
1470 struct breakpoint
*b
;
1473 thread
= pid_to_thread_id (pid
);
1476 if (b
->enable
!= disabled
1477 && b
->enable
!= shlib_disabled
1478 && b
->enable
!= call_disabled
1480 && (b
->thread
== -1 || b
->thread
== thread
))
1482 if (overlay_debugging
&&
1483 section_is_overlay (b
->section
) &&
1484 !section_is_mapped (b
->section
))
1485 continue; /* unmapped overlay -- can't be a match */
1494 /* bpstat stuff. External routines' interfaces are documented
1498 ep_is_catchpoint (ep
)
1499 struct breakpoint
*ep
;
1502 (ep
->type
== bp_catch_load
)
1503 || (ep
->type
== bp_catch_unload
)
1504 || (ep
->type
== bp_catch_fork
)
1505 || (ep
->type
== bp_catch_vfork
)
1506 || (ep
->type
== bp_catch_exec
)
1507 || (ep
->type
== bp_catch_catch
)
1508 || (ep
->type
== bp_catch_throw
)
1511 /* ??rehrauer: Add more kinds here, as are implemented... */
1516 ep_is_shlib_catchpoint (ep
)
1517 struct breakpoint
*ep
;
1520 (ep
->type
== bp_catch_load
)
1521 || (ep
->type
== bp_catch_unload
)
1526 ep_is_exception_catchpoint (ep
)
1527 struct breakpoint
*ep
;
1530 (ep
->type
== bp_catch_catch
)
1531 || (ep
->type
== bp_catch_throw
)
1535 /* Clear a bpstat so that it says we are not at any breakpoint.
1536 Also free any storage that is part of a bpstat. */
1551 if (p
->old_val
!= NULL
)
1552 value_free (p
->old_val
);
1559 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1560 is part of the bpstat is copied as well. */
1568 bpstat retval
= NULL
;
1573 for (; bs
!= NULL
; bs
= bs
->next
)
1575 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1576 memcpy (tmp
, bs
, sizeof (*tmp
));
1578 /* This is the first thing in the chain. */
1588 /* Find the bpstat associated with this breakpoint */
1591 bpstat_find_breakpoint (bsp
, breakpoint
)
1593 struct breakpoint
*breakpoint
;
1598 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1600 if (bsp
->breakpoint_at
== breakpoint
)
1606 /* Find a step_resume breakpoint associated with this bpstat.
1607 (If there are multiple step_resume bp's on the list, this function
1608 will arbitrarily pick one.)
1610 It is an error to use this function if BPSTAT doesn't contain a
1611 step_resume breakpoint.
1613 See wait_for_inferior's use of this function. */
1615 bpstat_find_step_resume_breakpoint (bsp
)
1619 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1621 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1623 if ((bsp
->breakpoint_at
!= NULL
) &&
1624 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1625 return bsp
->breakpoint_at
;
1628 error ("Internal error (no step_resume breakpoint found)");
1632 /* Return the breakpoint number of the first breakpoint we are stopped
1633 at. *BSP upon return is a bpstat which points to the remaining
1634 breakpoints stopped at (but which is not guaranteed to be good for
1635 anything but further calls to bpstat_num).
1636 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1642 struct breakpoint
*b
;
1645 return 0; /* No more breakpoint values */
1648 b
= (*bsp
)->breakpoint_at
;
1649 *bsp
= (*bsp
)->next
;
1651 return -1; /* breakpoint that's been deleted since */
1653 return b
->number
; /* We have its number */
1657 /* Modify BS so that the actions will not be performed. */
1660 bpstat_clear_actions (bs
)
1663 for (; bs
!= NULL
; bs
= bs
->next
)
1665 bs
->commands
= NULL
;
1666 if (bs
->old_val
!= NULL
)
1668 value_free (bs
->old_val
);
1674 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1677 cleanup_executing_breakpoints (ignore
)
1680 executing_breakpoint_commands
= 0;
1683 /* Execute all the commands associated with all the breakpoints at this
1684 location. Any of these commands could cause the process to proceed
1685 beyond this point, etc. We look out for such changes by checking
1686 the global "breakpoint_proceeded" after each command. */
1689 bpstat_do_actions (bsp
)
1693 struct cleanup
*old_chain
;
1694 struct command_line
*cmd
;
1696 /* Avoid endless recursion if a `source' command is contained
1698 if (executing_breakpoint_commands
)
1701 executing_breakpoint_commands
= 1;
1702 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1705 /* Note that (as of this writing), our callers all appear to
1706 be passing us the address of global stop_bpstat. And, if
1707 our calls to execute_control_command cause the inferior to
1708 proceed, that global (and hence, *bsp) will change.
1710 We must be careful to not touch *bsp unless the inferior
1711 has not proceeded. */
1713 /* This pointer will iterate over the list of bpstat's. */
1716 breakpoint_proceeded
= 0;
1717 for (; bs
!= NULL
; bs
= bs
->next
)
1722 execute_control_command (cmd
);
1724 if (breakpoint_proceeded
)
1729 if (breakpoint_proceeded
)
1730 /* The inferior is proceeded by the command; bomb out now.
1731 The bpstat chain has been blown away by wait_for_inferior.
1732 But since execution has stopped again, there is a new bpstat
1733 to look at, so start over. */
1736 bs
->commands
= NULL
;
1739 executing_breakpoint_commands
= 0;
1740 discard_cleanups (old_chain
);
1743 /* This is the normal print function for a bpstat. In the future,
1744 much of this logic could (should?) be moved to bpstat_stop_status,
1745 by having it set different print_it values.
1747 Current scheme: When we stop, bpstat_print() is called. It loops
1748 through the bpstat list of things causing this stop, calling the
1749 print_bp_stop_message function on each one. The behavior of the
1750 print_bp_stop_message function depends on the print_it field of
1751 bpstat. If such field so indicates, call this function here.
1753 Return values from this routine (ultimately used by bpstat_print()
1754 and normal_stop() to decide what to do):
1755 PRINT_NOTHING: Means we already printed all we needed to print,
1756 don't print anything else.
1757 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
1758 that something to be followed by a location.
1759 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
1760 that something to be followed by a location.
1761 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
1764 static enum print_stop_action
1765 print_it_typical (bs
)
1768 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1769 which has since been deleted. */
1770 if (bs
->breakpoint_at
== NULL
)
1771 return PRINT_UNKNOWN
;
1773 switch (bs
->breakpoint_at
->type
)
1776 case bp_hardware_breakpoint
:
1777 /* I think the user probably only wants to see one breakpoint
1778 number, not all of them. */
1779 annotate_breakpoint (bs
->breakpoint_at
->number
);
1780 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1781 return PRINT_SRC_AND_LOC
;
1784 case bp_shlib_event
:
1785 /* Did we stop because the user set the stop_on_solib_events
1786 variable? (If so, we report this as a generic, "Stopped due
1787 to shlib event" message.) */
1788 printf_filtered ("Stopped due to shared library event\n");
1789 return PRINT_NOTHING
;
1793 annotate_catchpoint (bs
->breakpoint_at
->number
);
1794 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1795 printf_filtered ("loaded");
1796 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1797 return PRINT_SRC_AND_LOC
;
1800 case bp_catch_unload
:
1801 annotate_catchpoint (bs
->breakpoint_at
->number
);
1802 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1803 printf_filtered ("unloaded");
1804 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1805 return PRINT_SRC_AND_LOC
;
1809 annotate_catchpoint (bs
->breakpoint_at
->number
);
1810 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1811 printf_filtered ("forked");
1812 printf_filtered (" process %d), ",
1813 bs
->breakpoint_at
->forked_inferior_pid
);
1814 return PRINT_SRC_AND_LOC
;
1817 case bp_catch_vfork
:
1818 annotate_catchpoint (bs
->breakpoint_at
->number
);
1819 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1820 printf_filtered ("vforked");
1821 printf_filtered (" process %d), ",
1822 bs
->breakpoint_at
->forked_inferior_pid
);
1823 return PRINT_SRC_AND_LOC
;
1827 annotate_catchpoint (bs
->breakpoint_at
->number
);
1828 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1829 bs
->breakpoint_at
->number
,
1830 bs
->breakpoint_at
->exec_pathname
);
1831 return PRINT_SRC_AND_LOC
;
1834 case bp_catch_catch
:
1835 if (current_exception_event
&&
1836 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1838 annotate_catchpoint (bs
->breakpoint_at
->number
);
1839 printf_filtered ("\nCatchpoint %d (exception caught), ",
1840 bs
->breakpoint_at
->number
);
1841 printf_filtered ("throw location ");
1842 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1843 printf_filtered ("%s:%d",
1844 CURRENT_EXCEPTION_THROW_FILE
,
1845 CURRENT_EXCEPTION_THROW_LINE
);
1847 printf_filtered ("unknown");
1849 printf_filtered (", catch location ");
1850 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1851 printf_filtered ("%s:%d",
1852 CURRENT_EXCEPTION_CATCH_FILE
,
1853 CURRENT_EXCEPTION_CATCH_LINE
);
1855 printf_filtered ("unknown");
1857 printf_filtered ("\n");
1858 /* don't bother to print location frame info */
1859 return PRINT_SRC_ONLY
;
1863 /* really throw, some other bpstat will handle it */
1864 return PRINT_UNKNOWN
;
1868 case bp_catch_throw
:
1869 if (current_exception_event
&&
1870 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
1872 annotate_catchpoint (bs
->breakpoint_at
->number
);
1873 printf_filtered ("\nCatchpoint %d (exception thrown), ",
1874 bs
->breakpoint_at
->number
);
1875 printf_filtered ("throw location ");
1876 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1877 printf_filtered ("%s:%d",
1878 CURRENT_EXCEPTION_THROW_FILE
,
1879 CURRENT_EXCEPTION_THROW_LINE
);
1881 printf_filtered ("unknown");
1883 printf_filtered (", catch location ");
1884 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1885 printf_filtered ("%s:%d",
1886 CURRENT_EXCEPTION_CATCH_FILE
,
1887 CURRENT_EXCEPTION_CATCH_LINE
);
1889 printf_filtered ("unknown");
1891 printf_filtered ("\n");
1892 /* don't bother to print location frame info */
1893 return PRINT_SRC_ONLY
;
1897 /* really catch, some other bpstat will handle it */
1898 return PRINT_UNKNOWN
;
1903 case bp_hardware_watchpoint
:
1904 if (bs
->old_val
!= NULL
)
1906 annotate_watchpoint (bs
->breakpoint_at
->number
);
1907 mention (bs
->breakpoint_at
);
1908 printf_filtered ("\nOld value = ");
1909 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
1910 printf_filtered ("\nNew value = ");
1911 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1912 Val_pretty_default
);
1913 printf_filtered ("\n");
1914 value_free (bs
->old_val
);
1917 /* More than one watchpoint may have been triggered. */
1918 return PRINT_UNKNOWN
;
1921 case bp_read_watchpoint
:
1922 mention (bs
->breakpoint_at
);
1923 printf_filtered ("\nValue = ");
1924 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1925 Val_pretty_default
);
1926 printf_filtered ("\n");
1927 return PRINT_UNKNOWN
;
1930 case bp_access_watchpoint
:
1931 if (bs
->old_val
!= NULL
)
1933 annotate_watchpoint (bs
->breakpoint_at
->number
);
1934 mention (bs
->breakpoint_at
);
1935 printf_filtered ("\nOld value = ");
1936 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
1937 value_free (bs
->old_val
);
1939 printf_filtered ("\nNew value = ");
1943 mention (bs
->breakpoint_at
);
1944 printf_filtered ("\nValue = ");
1946 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1947 Val_pretty_default
);
1948 printf_filtered ("\n");
1949 return PRINT_UNKNOWN
;
1951 /* Fall through, we don't deal with these types of breakpoints
1958 case bp_longjmp_resume
:
1959 case bp_step_resume
:
1960 case bp_through_sigtramp
:
1961 case bp_watchpoint_scope
:
1964 return PRINT_UNKNOWN
;
1968 /* Generic routine for printing messages indicating why we
1969 stopped. The behavior of this function depends on the value
1970 'print_it' in the bpstat structure. Under some circumstances we
1971 may decide not to print anything here and delegate the task to
1974 static enum print_stop_action
1975 print_bp_stop_message (bpstat bs
)
1977 switch (bs
->print_it
)
1980 /* Nothing should be printed for this bpstat entry. */
1981 return PRINT_UNKNOWN
;
1985 /* We still want to print the frame, but we already printed the
1986 relevant messages. */
1987 return PRINT_SRC_AND_LOC
;
1990 case print_it_normal
:
1991 /* Normal case, we handle everything in print_it_typical. */
1992 return print_it_typical (bs
);
1995 internal_error ("print_bp_stop_message: unrecognized enum value");
2001 /* Print a message indicating what happened. This is called from
2002 normal_stop(). The input to this routine is the head of the bpstat
2003 list - a list of the eventpoints that caused this stop. This
2004 routine calls the generic print routine for printing a message
2005 about reasons for stopping. This will print (for example) the
2006 "Breakpoint n," part of the output. The return value of this
2009 PRINT_UNKNOWN: Means we printed nothing
2010 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2011 code to print the location. An example is
2012 "Breakpoint 1, " which should be followed by
2014 PRINT_SRC_ONLY: Means we printed something, but there is no need
2015 to also print the location part of the message.
2016 An example is the catch/throw messages, which
2017 don't require a location appended to the end.
2018 PRINT_NOTHING: We have done some printing and we don't need any
2019 further info to be printed.*/
2021 enum print_stop_action
2027 /* Maybe another breakpoint in the chain caused us to stop.
2028 (Currently all watchpoints go on the bpstat whether hit or not.
2029 That probably could (should) be changed, provided care is taken
2030 with respect to bpstat_explains_signal). */
2031 for (; bs
; bs
= bs
->next
)
2033 val
= print_bp_stop_message (bs
);
2034 if (val
== PRINT_SRC_ONLY
2035 || val
== PRINT_SRC_AND_LOC
2036 || val
== PRINT_NOTHING
)
2040 /* We reached the end of the chain, or we got a null BS to start
2041 with and nothing was printed. */
2042 return PRINT_UNKNOWN
;
2045 /* Evaluate the expression EXP and return 1 if value is zero.
2046 This is used inside a catch_errors to evaluate the breakpoint condition.
2047 The argument is a "struct expression *" that has been cast to char * to
2048 make it pass through catch_errors. */
2051 breakpoint_cond_eval (exp
)
2054 value_ptr mark
= value_mark ();
2055 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2056 value_free_to_mark (mark
);
2060 /* Allocate a new bpstat and chain it to the current one. */
2063 bpstat_alloc (b
, cbs
)
2064 register struct breakpoint
*b
;
2065 bpstat cbs
; /* Current "bs" value */
2069 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2071 bs
->breakpoint_at
= b
;
2072 /* If the condition is false, etc., don't do the commands. */
2073 bs
->commands
= NULL
;
2075 bs
->print_it
= print_it_normal
;
2079 /* Possible return values for watchpoint_check (this can't be an enum
2080 because of check_errors). */
2081 /* The watchpoint has been deleted. */
2082 #define WP_DELETED 1
2083 /* The value has changed. */
2084 #define WP_VALUE_CHANGED 2
2085 /* The value has not changed. */
2086 #define WP_VALUE_NOT_CHANGED 3
2088 #define BP_TEMPFLAG 1
2089 #define BP_HARDWAREFLAG 2
2091 /* Check watchpoint condition. */
2094 watchpoint_check (p
)
2097 bpstat bs
= (bpstat
) p
;
2098 struct breakpoint
*b
;
2099 struct frame_info
*fr
;
2100 int within_current_scope
;
2102 b
= bs
->breakpoint_at
;
2104 if (b
->exp_valid_block
== NULL
)
2105 within_current_scope
= 1;
2108 /* There is no current frame at this moment. If we're going to have
2109 any chance of handling watchpoints on local variables, we'll need
2110 the frame chain (so we can determine if we're in scope). */
2111 reinit_frame_cache ();
2112 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2113 within_current_scope
= (fr
!= NULL
);
2114 if (within_current_scope
)
2115 /* If we end up stopping, the current frame will get selected
2116 in normal_stop. So this call to select_frame won't affect
2118 select_frame (fr
, -1);
2121 if (within_current_scope
)
2123 /* We use value_{,free_to_}mark because it could be a
2124 *long* time before we return to the command level and
2125 call free_all_values. We can't call free_all_values because
2126 we might be in the middle of evaluating a function call. */
2128 value_ptr mark
= value_mark ();
2129 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2130 if (!value_equal (b
->val
, new_val
))
2132 release_value (new_val
);
2133 value_free_to_mark (mark
);
2134 bs
->old_val
= b
->val
;
2136 /* We will stop here */
2137 return WP_VALUE_CHANGED
;
2141 /* Nothing changed, don't do anything. */
2142 value_free_to_mark (mark
);
2143 /* We won't stop here */
2144 return WP_VALUE_NOT_CHANGED
;
2149 /* This seems like the only logical thing to do because
2150 if we temporarily ignored the watchpoint, then when
2151 we reenter the block in which it is valid it contains
2152 garbage (in the case of a function, it may have two
2153 garbage values, one before and one after the prologue).
2154 So we can't even detect the first assignment to it and
2155 watch after that (since the garbage may or may not equal
2156 the first value assigned). */
2158 Watchpoint %d deleted because the program has left the block in\n\
2159 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2160 if (b
->related_breakpoint
)
2161 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2162 b
->disposition
= del_at_next_stop
;
2168 /* Get a bpstat associated with having just stopped at address *PC
2169 and frame address CORE_ADDRESS. Update *PC to point at the
2170 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2171 if this is known to not be a real breakpoint (it could still be a
2172 watchpoint, though). */
2174 /* Determine whether we stopped at a breakpoint, etc, or whether we
2175 don't understand this stop. Result is a chain of bpstat's such that:
2177 if we don't understand the stop, the result is a null pointer.
2179 if we understand why we stopped, the result is not null.
2181 Each element of the chain refers to a particular breakpoint or
2182 watchpoint at which we have stopped. (We may have stopped for
2183 several reasons concurrently.)
2185 Each element of the chain has valid next, breakpoint_at,
2186 commands, FIXME??? fields. */
2189 bpstat_stop_status (pc
, not_a_breakpoint
)
2191 int not_a_breakpoint
;
2193 register struct breakpoint
*b
, *temp
;
2195 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2196 int real_breakpoint
= 0;
2197 /* Root of the chain of bpstat's */
2198 struct bpstats root_bs
[1];
2199 /* Pointer to the last thing in the chain currently. */
2200 bpstat bs
= root_bs
;
2201 static char message1
[] =
2202 "Error evaluating expression for watchpoint %d\n";
2203 char message
[sizeof (message1
) + 30 /* slop */ ];
2205 /* Get the address where the breakpoint would have been. */
2206 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2207 0 : DECR_PC_AFTER_BREAK
);
2209 ALL_BREAKPOINTS_SAFE (b
, temp
)
2211 if (b
->enable
== disabled
2212 || b
->enable
== shlib_disabled
2213 || b
->enable
== call_disabled
)
2216 if (b
->type
!= bp_watchpoint
2217 && b
->type
!= bp_hardware_watchpoint
2218 && b
->type
!= bp_read_watchpoint
2219 && b
->type
!= bp_access_watchpoint
2220 && b
->type
!= bp_hardware_breakpoint
2221 && b
->type
!= bp_catch_fork
2222 && b
->type
!= bp_catch_vfork
2223 && b
->type
!= bp_catch_exec
2224 && b
->type
!= bp_catch_catch
2225 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2226 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2227 (overlay_debugging
&& /* overlay doesn't match */
2228 section_is_overlay (b
->section
) &&
2229 !section_is_mapped (b
->section
)))
2232 if (b
->type
== bp_hardware_breakpoint
2233 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2236 /* Is this a catchpoint of a load or unload? If so, did we
2237 get a load or unload of the specified library? If not,
2239 if ((b
->type
== bp_catch_load
)
2240 #if defined(SOLIB_HAVE_LOAD_EVENT)
2241 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2242 || ((b
->dll_pathname
!= NULL
)
2243 && (strcmp (b
->dll_pathname
,
2244 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2250 if ((b
->type
== bp_catch_unload
)
2251 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2252 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2253 || ((b
->dll_pathname
!= NULL
)
2254 && (strcmp (b
->dll_pathname
,
2255 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2261 if ((b
->type
== bp_catch_fork
)
2262 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2265 if ((b
->type
== bp_catch_vfork
)
2266 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2269 if ((b
->type
== bp_catch_exec
)
2270 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2273 if (ep_is_exception_catchpoint (b
) &&
2274 !(current_exception_event
= target_get_current_exception_event ()))
2277 /* Come here if it's a watchpoint, or if the break address matches */
2279 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2281 /* Watchpoints may change this, if not found to have triggered. */
2285 sprintf (message
, message1
, b
->number
);
2286 if (b
->type
== bp_watchpoint
||
2287 b
->type
== bp_hardware_watchpoint
)
2289 switch (catch_errors (watchpoint_check
, bs
, message
,
2293 /* We've already printed what needs to be printed. */
2294 bs
->print_it
= print_it_done
;
2297 case WP_VALUE_CHANGED
:
2301 case WP_VALUE_NOT_CHANGED
:
2303 bs
->print_it
= print_it_noop
;
2305 /* Don't consider this a hit. */
2312 /* Error from catch_errors. */
2313 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2314 if (b
->related_breakpoint
)
2315 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2316 b
->disposition
= del_at_next_stop
;
2317 /* We've already printed what needs to be printed. */
2318 bs
->print_it
= print_it_done
;
2324 else if (b
->type
== bp_read_watchpoint
||
2325 b
->type
== bp_access_watchpoint
)
2331 addr
= target_stopped_data_address ();
2334 for (v
= b
->val_chain
; v
; v
= v
->next
)
2336 if (v
->lval
== lval_memory
)
2340 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2341 /* Exact match not required. Within range is sufficient.
2343 if (addr
>= vaddr
&&
2344 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2349 switch (catch_errors (watchpoint_check
, bs
, message
,
2353 /* We've already printed what needs to be printed. */
2354 bs
->print_it
= print_it_done
;
2357 case WP_VALUE_CHANGED
:
2358 case WP_VALUE_NOT_CHANGED
:
2365 /* Error from catch_errors. */
2366 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2367 if (b
->related_breakpoint
)
2368 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2369 b
->disposition
= del_at_next_stop
;
2370 /* We've already printed what needs to be printed. */
2371 bs
->print_it
= print_it_done
;
2374 else /* found == 0 */
2376 /* This is a case where some watchpoint(s) triggered,
2377 but not at the address of this watchpoint (FOUND
2378 was left zero). So don't print anything for this
2380 bs
->print_it
= print_it_noop
;
2387 /* By definition, an encountered breakpoint is a triggered
2391 real_breakpoint
= 1;
2394 if (b
->frame
&& b
->frame
!= (get_current_frame ())->frame
&&
2395 (b
->type
== bp_step_resume
&&
2396 (INNER_THAN (get_current_frame ()->frame
, b
->frame
))))
2400 int value_is_zero
= 0;
2404 /* Need to select the frame, with all that implies
2405 so that the conditions will have the right context. */
2406 select_frame (get_current_frame (), 0);
2408 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2409 "Error in testing breakpoint condition:\n",
2411 /* FIXME-someday, should give breakpoint # */
2414 if (b
->cond
&& value_is_zero
)
2417 /* Don't consider this a hit. */
2420 else if (b
->ignore_count
> 0)
2427 /* We will stop here */
2428 if (b
->disposition
== disable
)
2429 b
->enable
= disabled
;
2430 bs
->commands
= b
->commands
;
2434 (STREQ ("silent", bs
->commands
->line
) ||
2435 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2437 bs
->commands
= bs
->commands
->next
;
2442 /* Print nothing for this entry if we dont stop or if we dont print. */
2443 if (bs
->stop
== 0 || bs
->print
== 0)
2444 bs
->print_it
= print_it_noop
;
2447 bs
->next
= NULL
; /* Terminate the chain */
2448 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2450 if (real_breakpoint
&& bs
)
2452 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2454 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2456 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2462 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2465 #if defined (SHIFT_INST_REGS)
2467 #else /* No SHIFT_INST_REGS. */
2469 #endif /* No SHIFT_INST_REGS. */
2474 /* The value of a hardware watchpoint hasn't changed, but the
2475 intermediate memory locations we are watching may have. */
2476 if (bs
&& !bs
->stop
&&
2477 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2478 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2479 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2481 remove_breakpoints ();
2482 insert_breakpoints ();
2487 /* Tell what to do about this bpstat. */
2492 /* Classify each bpstat as one of the following. */
2495 /* This bpstat element has no effect on the main_action. */
2498 /* There was a watchpoint, stop but don't print. */
2501 /* There was a watchpoint, stop and print. */
2504 /* There was a breakpoint but we're not stopping. */
2507 /* There was a breakpoint, stop but don't print. */
2510 /* There was a breakpoint, stop and print. */
2513 /* We hit the longjmp breakpoint. */
2516 /* We hit the longjmp_resume breakpoint. */
2519 /* We hit the step_resume breakpoint. */
2522 /* We hit the through_sigtramp breakpoint. */
2525 /* We hit the shared library event breakpoint. */
2528 /* We caught a shared library event. */
2531 /* This is just used to count how many enums there are. */
2535 /* Here is the table which drives this routine. So that we can
2536 format it pretty, we define some abbreviations for the
2537 enum bpstat_what codes. */
2538 #define kc BPSTAT_WHAT_KEEP_CHECKING
2539 #define ss BPSTAT_WHAT_STOP_SILENT
2540 #define sn BPSTAT_WHAT_STOP_NOISY
2541 #define sgl BPSTAT_WHAT_SINGLE
2542 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2543 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2544 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2545 #define sr BPSTAT_WHAT_STEP_RESUME
2546 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2547 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2548 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2550 /* "Can't happen." Might want to print an error message.
2551 abort() is not out of the question, but chances are GDB is just
2552 a bit confused, not unusable. */
2553 #define err BPSTAT_WHAT_STOP_NOISY
2555 /* Given an old action and a class, come up with a new action. */
2556 /* One interesting property of this table is that wp_silent is the same
2557 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2558 after stopping, the check for whether to step over a breakpoint
2559 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2560 reference to how we stopped. We retain separate wp_silent and
2561 bp_silent codes in case we want to change that someday.
2563 Another possibly interesting property of this table is that
2564 there's a partial ordering, priority-like, of the actions. Once
2565 you've decided that some action is appropriate, you'll never go
2566 back and decide something of a lower priority is better. The
2569 kc < clr sgl shl slr sn sr ss ts
2570 sgl < clrs shl shlr slr sn sr ss ts
2571 slr < err shl shlr sn sr ss ts
2572 clr < clrs err shl shlr sn sr ss ts
2573 clrs < err shl shlr sn sr ss ts
2574 ss < shl shlr sn sr ts
2581 What I think this means is that we don't need a damned table
2582 here. If you just put the rows and columns in the right order,
2583 it'd look awfully regular. We could simply walk the bpstat list
2584 and choose the highest priority action we find, with a little
2585 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2586 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2587 is messy anyway). */
2589 /* step_resume entries: a step resume breakpoint overrides another
2590 breakpoint of signal handling (see comment in wait_for_inferior
2591 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2592 /* We handle the through_sigtramp_breakpoint the same way; having both
2593 one of those and a step_resume_breakpoint is probably very rare (?). */
2595 static const enum bpstat_what_main_action
2596 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2599 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2602 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2604 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2606 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2608 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2610 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2612 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2614 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2616 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2618 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2620 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2622 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2624 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2639 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2640 struct bpstat_what retval
;
2642 retval
.call_dummy
= 0;
2643 for (; bs
!= NULL
; bs
= bs
->next
)
2645 enum class bs_class
= no_effect
;
2646 if (bs
->breakpoint_at
== NULL
)
2647 /* I suspect this can happen if it was a momentary breakpoint
2648 which has since been deleted. */
2650 switch (bs
->breakpoint_at
->type
)
2656 case bp_hardware_breakpoint
:
2662 bs_class
= bp_noisy
;
2664 bs_class
= bp_silent
;
2667 bs_class
= bp_nostop
;
2670 case bp_hardware_watchpoint
:
2671 case bp_read_watchpoint
:
2672 case bp_access_watchpoint
:
2676 bs_class
= wp_noisy
;
2678 bs_class
= wp_silent
;
2681 /* There was a watchpoint, but we're not stopping.
2682 This requires no further action. */
2683 bs_class
= no_effect
;
2686 bs_class
= long_jump
;
2688 case bp_longjmp_resume
:
2689 bs_class
= long_resume
;
2691 case bp_step_resume
:
2694 bs_class
= step_resume
;
2697 /* It is for the wrong frame. */
2698 bs_class
= bp_nostop
;
2700 case bp_through_sigtramp
:
2701 bs_class
= through_sig
;
2703 case bp_watchpoint_scope
:
2704 bs_class
= bp_nostop
;
2706 case bp_shlib_event
:
2707 bs_class
= shlib_event
;
2710 case bp_catch_unload
:
2711 /* Only if this catchpoint triggered should we cause the
2712 step-out-of-dld behaviour. Otherwise, we ignore this
2715 bs_class
= catch_shlib_event
;
2717 bs_class
= no_effect
;
2720 case bp_catch_vfork
:
2725 bs_class
= bp_noisy
;
2727 bs_class
= bp_silent
;
2730 /* There was a catchpoint, but we're not stopping.
2731 This requires no further action. */
2732 bs_class
= no_effect
;
2734 case bp_catch_catch
:
2735 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2736 bs_class
= bp_nostop
;
2738 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2740 case bp_catch_throw
:
2741 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2742 bs_class
= bp_nostop
;
2744 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2747 /* Make sure the action is stop (silent or noisy),
2748 so infrun.c pops the dummy frame. */
2749 bs_class
= bp_silent
;
2750 retval
.call_dummy
= 1;
2753 current_action
= table
[(int) bs_class
][(int) current_action
];
2755 retval
.main_action
= current_action
;
2759 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2760 without hardware support). This isn't related to a specific bpstat,
2761 just to things like whether watchpoints are set. */
2764 bpstat_should_step ()
2766 struct breakpoint
*b
;
2768 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2773 /* Nonzero if there are enabled hardware watchpoints. */
2775 bpstat_have_active_hw_watchpoints ()
2777 struct breakpoint
*b
;
2779 if ((b
->enable
== enabled
) &&
2781 ((b
->type
== bp_hardware_watchpoint
) ||
2782 (b
->type
== bp_read_watchpoint
) ||
2783 (b
->type
== bp_access_watchpoint
)))
2789 /* Given a bpstat that records zero or more triggered eventpoints, this
2790 function returns another bpstat which contains only the catchpoints
2791 on that first list, if any. */
2793 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
2797 struct bpstats root_bs
[1];
2798 bpstat bs
= root_bs
;
2799 struct breakpoint
*ep
;
2802 bpstat_clear (cp_list
);
2803 root_bs
->next
= NULL
;
2805 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
2807 /* Is this eventpoint a catchpoint? If not, ignore it. */
2808 ep
= ep_list
->breakpoint_at
;
2811 if ((ep
->type
!= bp_catch_load
) &&
2812 (ep
->type
!= bp_catch_unload
) &&
2813 (ep
->type
!= bp_catch_catch
) &&
2814 (ep
->type
!= bp_catch_throw
))
2815 /* pai: (temp) ADD fork/vfork here!! */
2818 /* Yes; add it to the list. */
2819 bs
= bpstat_alloc (ep
, bs
);
2824 #if defined(SOLIB_ADD)
2825 /* Also, for each triggered catchpoint, tag it with the name of
2826 the library that caused this trigger. (We copy the name now,
2827 because it's only guaranteed to be available NOW, when the
2828 catchpoint triggers. Clients who may wish to know the name
2829 later must get it from the catchpoint itself.) */
2830 if (ep
->triggered_dll_pathname
!= NULL
)
2831 free (ep
->triggered_dll_pathname
);
2832 if (ep
->type
== bp_catch_load
)
2833 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
2835 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
2837 dll_pathname
= NULL
;
2841 ep
->triggered_dll_pathname
= (char *)
2842 xmalloc (strlen (dll_pathname
) + 1);
2843 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
2846 ep
->triggered_dll_pathname
= NULL
;
2852 /* Print information on breakpoint number BNUM, or -1 if all.
2853 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2854 is nonzero, process only watchpoints. */
2861 ep_type_description_t
;
2864 breakpoint_1 (bnum
, allflag
)
2868 register struct breakpoint
*b
;
2869 register struct command_line
*l
;
2870 register struct symbol
*sym
;
2871 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
2872 int found_a_breakpoint
= 0;
2873 static ep_type_description_t bptypes
[] =
2875 {bp_none
, "?deleted?"},
2876 {bp_breakpoint
, "breakpoint"},
2877 {bp_hardware_breakpoint
, "hw breakpoint"},
2878 {bp_until
, "until"},
2879 {bp_finish
, "finish"},
2880 {bp_watchpoint
, "watchpoint"},
2881 {bp_hardware_watchpoint
, "hw watchpoint"},
2882 {bp_read_watchpoint
, "read watchpoint"},
2883 {bp_access_watchpoint
, "acc watchpoint"},
2884 {bp_longjmp
, "longjmp"},
2885 {bp_longjmp_resume
, "longjmp resume"},
2886 {bp_step_resume
, "step resume"},
2887 {bp_through_sigtramp
, "sigtramp"},
2888 {bp_watchpoint_scope
, "watchpoint scope"},
2889 {bp_call_dummy
, "call dummy"},
2890 {bp_shlib_event
, "shlib events"},
2891 {bp_catch_load
, "catch load"},
2892 {bp_catch_unload
, "catch unload"},
2893 {bp_catch_fork
, "catch fork"},
2894 {bp_catch_vfork
, "catch vfork"},
2895 {bp_catch_exec
, "catch exec"},
2896 {bp_catch_catch
, "catch catch"},
2897 {bp_catch_throw
, "catch throw"}
2900 static char *bpdisps
[] =
2901 {"del", "dstp", "dis", "keep"};
2902 static char bpenables
[] = "nynny";
2903 char wrap_indent
[80];
2909 || bnum
== b
->number
)
2911 /* We only print out user settable breakpoints unless the allflag is set. */
2913 && b
->type
!= bp_breakpoint
2914 && b
->type
!= bp_catch_load
2915 && b
->type
!= bp_catch_unload
2916 && b
->type
!= bp_catch_fork
2917 && b
->type
!= bp_catch_vfork
2918 && b
->type
!= bp_catch_exec
2919 && b
->type
!= bp_catch_catch
2920 && b
->type
!= bp_catch_throw
2921 && b
->type
!= bp_hardware_breakpoint
2922 && b
->type
!= bp_watchpoint
2923 && b
->type
!= bp_read_watchpoint
2924 && b
->type
!= bp_access_watchpoint
2925 && b
->type
!= bp_hardware_watchpoint
)
2928 if (!found_a_breakpoint
++)
2930 annotate_breakpoints_headers ();
2933 printf_filtered ("Num ");
2935 printf_filtered ("Type ");
2937 printf_filtered ("Disp ");
2939 printf_filtered ("Enb ");
2943 printf_filtered ("Address ");
2946 printf_filtered ("What\n");
2948 annotate_breakpoints_table ();
2953 printf_filtered ("%-3d ", b
->number
);
2955 if ((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
2956 error ("bptypes table does not describe type #%d.", (int) b
->type
);
2957 if ((int) b
->type
!= bptypes
[(int) b
->type
].type
)
2958 error ("bptypes table does not describe type #%d?", (int) b
->type
);
2959 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
2961 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
2963 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
2965 strcpy (wrap_indent
, " ");
2967 strcat (wrap_indent
, " ");
2971 case bp_hardware_watchpoint
:
2972 case bp_read_watchpoint
:
2973 case bp_access_watchpoint
:
2974 /* Field 4, the address, is omitted (which makes the columns
2975 not line up too nicely with the headers, but the effect
2976 is relatively readable). */
2978 print_expression (b
->exp
, gdb_stdout
);
2982 case bp_catch_unload
:
2983 /* Field 4, the address, is omitted (which makes the columns
2984 not line up too nicely with the headers, but the effect
2985 is relatively readable). */
2987 if (b
->dll_pathname
== NULL
)
2988 printf_filtered ("<any library> ");
2990 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
2994 case bp_catch_vfork
:
2995 /* Field 4, the address, is omitted (which makes the columns
2996 not line up too nicely with the headers, but the effect
2997 is relatively readable). */
2999 if (b
->forked_inferior_pid
!= 0)
3000 printf_filtered ("process %d ", b
->forked_inferior_pid
);
3004 /* Field 4, the address, is omitted (which makes the columns
3005 not line up too nicely with the headers, but the effect
3006 is relatively readable). */
3008 if (b
->exec_pathname
!= NULL
)
3009 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
3011 case bp_catch_catch
:
3012 /* Field 4, the address, is omitted (which makes the columns
3013 not line up too nicely with the headers, but the effect
3014 is relatively readable). */
3016 printf_filtered ("exception catch ");
3018 case bp_catch_throw
:
3019 /* Field 4, the address, is omitted (which makes the columns
3020 not line up too nicely with the headers, but the effect
3021 is relatively readable). */
3023 printf_filtered ("exception throw ");
3027 case bp_hardware_breakpoint
:
3031 case bp_longjmp_resume
:
3032 case bp_step_resume
:
3033 case bp_through_sigtramp
:
3034 case bp_watchpoint_scope
:
3036 case bp_shlib_event
:
3040 /* FIXME-32x64: need a print_address_numeric with
3044 local_hex_string_custom
3045 ((unsigned long) b
->address
, "08l"));
3050 last_addr
= b
->address
;
3053 sym
= find_pc_sect_function (b
->address
, b
->section
);
3056 fputs_filtered ("in ", gdb_stdout
);
3057 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3058 wrap_here (wrap_indent
);
3059 fputs_filtered (" at ", gdb_stdout
);
3061 fputs_filtered (b
->source_file
, gdb_stdout
);
3062 printf_filtered (":%d", b
->line_number
);
3065 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3069 if (b
->thread
!= -1)
3070 printf_filtered (" thread %d", b
->thread
);
3072 printf_filtered ("\n");
3078 printf_filtered ("\tstop only in stack frame at ");
3079 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3080 printf_filtered ("\n");
3087 printf_filtered ("\tstop only if ");
3088 print_expression (b
->cond
, gdb_stdout
);
3089 printf_filtered ("\n");
3092 if (b
->thread
!= -1)
3094 /* FIXME should make an annotation for this */
3095 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3098 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3100 /* FIXME should make an annotation for this */
3101 if (ep_is_catchpoint (b
))
3102 printf_filtered ("\tcatchpoint");
3104 printf_filtered ("\tbreakpoint");
3105 printf_filtered (" already hit %d time%s\n",
3106 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3109 if (b
->ignore_count
)
3113 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3116 if ((l
= b
->commands
))
3122 print_command_line (l
, 4, gdb_stdout
);
3128 if (!found_a_breakpoint
)
3131 printf_filtered ("No breakpoints or watchpoints.\n");
3133 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3136 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3137 that a comparison of an unsigned with -1 is always false. */
3138 if (last_addr
!= (CORE_ADDR
) -1)
3139 set_next_address (last_addr
);
3141 annotate_breakpoints_table_end ();
3146 breakpoints_info (bnum_exp
, from_tty
)
3153 bnum
= parse_and_eval_address (bnum_exp
);
3155 breakpoint_1 (bnum
, 0);
3160 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3167 bnum
= parse_and_eval_address (bnum_exp
);
3169 breakpoint_1 (bnum
, 1);
3172 /* Print a message describing any breakpoints set at PC. */
3175 describe_other_breakpoints (pc
, section
)
3179 register int others
= 0;
3180 register struct breakpoint
*b
;
3183 if (b
->address
== pc
)
3184 if (overlay_debugging
== 0 ||
3185 b
->section
== section
)
3189 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3191 if (b
->address
== pc
)
3192 if (overlay_debugging
== 0 ||
3193 b
->section
== section
)
3199 ((b
->enable
== disabled
||
3200 b
->enable
== shlib_disabled
||
3201 b
->enable
== call_disabled
) ? " (disabled)"
3202 : b
->enable
== permanent
? " (permanent)"
3204 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3206 printf_filtered ("also set at pc ");
3207 print_address_numeric (pc
, 1, gdb_stdout
);
3208 printf_filtered (".\n");
3212 /* Set the default place to put a breakpoint
3213 for the `break' command with no arguments. */
3216 set_default_breakpoint (valid
, addr
, symtab
, line
)
3219 struct symtab
*symtab
;
3222 default_breakpoint_valid
= valid
;
3223 default_breakpoint_address
= addr
;
3224 default_breakpoint_symtab
= symtab
;
3225 default_breakpoint_line
= line
;
3228 /* Rescan breakpoints at address ADDRESS,
3229 marking the first one as "first" and any others as "duplicates".
3230 This is so that the bpt instruction is only inserted once.
3231 If we have a permanent breakpoint at ADDRESS, make that one
3232 the official one, and the rest as duplicates. */
3235 check_duplicates (address
, section
)
3239 register struct breakpoint
*b
;
3240 register int count
= 0;
3241 struct breakpoint
*perm_bp
= 0;
3243 if (address
== 0) /* Watchpoints are uninteresting */
3247 if (b
->enable
!= disabled
3248 && b
->enable
!= shlib_disabled
3249 && b
->enable
!= call_disabled
3250 && b
->address
== address
3251 && (overlay_debugging
== 0 || b
->section
== section
))
3253 /* Have we found a permanent breakpoint? */
3254 if (b
->enable
== permanent
)
3261 b
->duplicate
= count
> 1;
3264 /* If we found a permanent breakpoint at this address, go over the
3265 list again and declare all the other breakpoints there to be the
3269 perm_bp
->duplicate
= 0;
3271 /* Permanent breakpoint should always be inserted. */
3272 if (! perm_bp
->inserted
)
3273 internal_error ("allegedly permanent breakpoint is not "
3274 "actually inserted");
3280 internal_error ("another breakpoint was inserted on top of "
3281 "a permanent breakpoint");
3283 if (b
->enable
!= disabled
3284 && b
->enable
!= shlib_disabled
3285 && b
->enable
!= call_disabled
3286 && b
->address
== address
3287 && (overlay_debugging
== 0 || b
->section
== section
))
3293 /* Low level routine to set a breakpoint.
3294 Takes as args the three things that every breakpoint must have.
3295 Returns the breakpoint object so caller can set other things.
3296 Does not set the breakpoint number!
3297 Does not print anything.
3299 ==> This routine should not be called if there is a chance of later
3300 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3301 your arguments BEFORE calling this routine! */
3304 set_raw_breakpoint (sal
)
3305 struct symtab_and_line sal
;
3307 register struct breakpoint
*b
, *b1
;
3309 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3310 memset (b
, 0, sizeof (*b
));
3311 b
->address
= sal
.pc
;
3312 if (sal
.symtab
== NULL
)
3313 b
->source_file
= NULL
;
3315 b
->source_file
= savestring (sal
.symtab
->filename
,
3316 strlen (sal
.symtab
->filename
));
3317 b
->section
= sal
.section
;
3318 b
->language
= current_language
->la_language
;
3319 b
->input_radix
= input_radix
;
3321 b
->line_number
= sal
.line
;
3322 b
->enable
= enabled
;
3325 b
->ignore_count
= 0;
3328 b
->dll_pathname
= NULL
;
3329 b
->triggered_dll_pathname
= NULL
;
3330 b
->forked_inferior_pid
= 0;
3331 b
->exec_pathname
= NULL
;
3333 /* Add this breakpoint to the end of the chain
3334 so that a list of breakpoints will come out in order
3335 of increasing numbers. */
3337 b1
= breakpoint_chain
;
3339 breakpoint_chain
= b
;
3347 check_duplicates (sal
.pc
, sal
.section
);
3348 breakpoints_changed ();
3354 /* Note that the breakpoint object B describes a permanent breakpoint
3355 instruction, hard-wired into the inferior's code. */
3357 make_breakpoint_permanent (struct breakpoint
*b
)
3359 b
->enable
= permanent
;
3361 /* By definition, permanent breakpoints are already present in the code. */
3365 #ifdef GET_LONGJMP_TARGET
3368 create_longjmp_breakpoint (func_name
)
3371 struct symtab_and_line sal
;
3372 struct breakpoint
*b
;
3374 INIT_SAL (&sal
); /* initialize to zeroes */
3375 if (func_name
!= NULL
)
3377 struct minimal_symbol
*m
;
3379 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3380 (struct objfile
*) NULL
);
3382 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3386 sal
.section
= find_pc_overlay (sal
.pc
);
3387 b
= set_raw_breakpoint (sal
);
3391 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3392 b
->disposition
= donttouch
;
3393 b
->enable
= disabled
;
3396 b
->addr_string
= strsave (func_name
);
3397 b
->number
= internal_breakpoint_number
--;
3400 #endif /* #ifdef GET_LONGJMP_TARGET */
3402 /* Call this routine when stepping and nexting to enable a breakpoint
3403 if we do a longjmp(). When we hit that breakpoint, call
3404 set_longjmp_resume_breakpoint() to figure out where we are going. */
3407 enable_longjmp_breakpoint ()
3409 register struct breakpoint
*b
;
3412 if (b
->type
== bp_longjmp
)
3414 b
->enable
= enabled
;
3415 check_duplicates (b
->address
, b
->section
);
3420 disable_longjmp_breakpoint ()
3422 register struct breakpoint
*b
;
3425 if (b
->type
== bp_longjmp
3426 || b
->type
== bp_longjmp_resume
)
3428 b
->enable
= disabled
;
3429 check_duplicates (b
->address
, b
->section
);
3435 remove_solib_event_breakpoints ()
3437 register struct breakpoint
*b
, *temp
;
3439 ALL_BREAKPOINTS_SAFE (b
, temp
)
3440 if (b
->type
== bp_shlib_event
)
3441 delete_breakpoint (b
);
3445 create_solib_event_breakpoint (address
)
3448 struct breakpoint
*b
;
3449 struct symtab_and_line sal
;
3451 INIT_SAL (&sal
); /* initialize to zeroes */
3453 sal
.section
= find_pc_overlay (sal
.pc
);
3454 b
= set_raw_breakpoint (sal
);
3455 b
->number
= internal_breakpoint_number
--;
3456 b
->disposition
= donttouch
;
3457 b
->type
= bp_shlib_event
;
3462 /* Disable any breakpoints that are on code in shared libraries. Only
3463 apply to enabled breakpoints, disabled ones can just stay disabled. */
3466 disable_breakpoints_in_shlibs (silent
)
3469 struct breakpoint
*b
;
3470 int disabled_shlib_breaks
= 0;
3472 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3475 #if defined (PC_SOLIB)
3476 if (((b
->type
== bp_breakpoint
) ||
3477 (b
->type
== bp_hardware_breakpoint
)) &&
3478 b
->enable
== enabled
&&
3480 PC_SOLIB (b
->address
))
3482 b
->enable
= shlib_disabled
;
3485 if (!disabled_shlib_breaks
)
3487 target_terminal_ours_for_output ();
3488 warning ("Temporarily disabling shared library breakpoints:");
3490 disabled_shlib_breaks
= 1;
3491 warning ("breakpoint #%d ", b
->number
);
3498 /* Try to reenable any breakpoints in shared libraries. */
3500 re_enable_breakpoints_in_shlibs ()
3502 struct breakpoint
*b
;
3505 if (b
->enable
== shlib_disabled
)
3509 /* Do not reenable the breakpoint if the shared library
3510 is still not mapped in. */
3511 if (target_read_memory (b
->address
, buf
, 1) == 0)
3512 b
->enable
= enabled
;
3519 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
3524 enum bptype bp_kind
;
3526 struct breakpoint
*b
;
3527 struct symtabs_and_lines sals
;
3528 struct cleanup
*old_chain
;
3529 struct cleanup
*canonical_strings_chain
= NULL
;
3530 char *addr_start
= hookname
;
3531 char *addr_end
= NULL
;
3532 char **canonical
= (char **) NULL
;
3533 int thread
= -1; /* All threads. */
3535 /* Set a breakpoint on the specified hook. */
3536 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3537 addr_end
= hookname
;
3539 if (sals
.nelts
== 0)
3541 warning ("Unable to set a breakpoint on dynamic linker callback.");
3542 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3543 warning ("GDB will be unable to track shl_load/shl_unload calls");
3546 if (sals
.nelts
!= 1)
3548 warning ("Unable to set unique breakpoint on dynamic linker callback.");
3549 warning ("GDB will be unable to track shl_load/shl_unload calls");
3553 /* Make sure that all storage allocated in decode_line_1 gets freed
3554 in case the following errors out. */
3555 old_chain
= make_cleanup (free
, sals
.sals
);
3556 if (canonical
!= (char **) NULL
)
3558 make_cleanup (free
, canonical
);
3559 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3560 if (canonical
[0] != NULL
)
3561 make_cleanup (free
, canonical
[0]);
3564 resolve_sal_pc (&sals
.sals
[0]);
3566 /* Remove the canonical strings from the cleanup, they are needed below. */
3567 if (canonical
!= (char **) NULL
)
3568 discard_cleanups (canonical_strings_chain
);
3570 b
= set_raw_breakpoint (sals
.sals
[0]);
3571 set_breakpoint_count (breakpoint_count
+ 1);
3572 b
->number
= breakpoint_count
;
3574 b
->cond_string
= (cond_string
== NULL
) ?
3575 NULL
: savestring (cond_string
, strlen (cond_string
));
3578 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
3579 b
->addr_string
= canonical
[0];
3580 else if (addr_start
)
3581 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
3583 b
->enable
= enabled
;
3584 b
->disposition
= tempflag
? del
: donttouch
;
3586 if (dll_pathname
== NULL
)
3587 b
->dll_pathname
= NULL
;
3590 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
3591 strcpy (b
->dll_pathname
, dll_pathname
);
3596 do_cleanups (old_chain
);
3600 create_solib_load_event_breakpoint (hookname
, tempflag
,
3601 dll_pathname
, cond_string
)
3607 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
3608 cond_string
, bp_catch_load
);
3612 create_solib_unload_event_breakpoint (hookname
, tempflag
,
3613 dll_pathname
, cond_string
)
3619 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
3620 cond_string
, bp_catch_unload
);
3624 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
3627 enum bptype bp_kind
;
3629 struct symtab_and_line sal
;
3630 struct breakpoint
*b
;
3631 int thread
= -1; /* All threads. */
3638 b
= set_raw_breakpoint (sal
);
3639 set_breakpoint_count (breakpoint_count
+ 1);
3640 b
->number
= breakpoint_count
;
3642 b
->cond_string
= (cond_string
== NULL
) ?
3643 NULL
: savestring (cond_string
, strlen (cond_string
));
3645 b
->addr_string
= NULL
;
3646 b
->enable
= enabled
;
3647 b
->disposition
= tempflag
? del
: donttouch
;
3648 b
->forked_inferior_pid
= 0;
3656 create_fork_event_catchpoint (tempflag
, cond_string
)
3660 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
3664 create_vfork_event_catchpoint (tempflag
, cond_string
)
3668 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
3672 create_exec_event_catchpoint (tempflag
, cond_string
)
3676 struct symtab_and_line sal
;
3677 struct breakpoint
*b
;
3678 int thread
= -1; /* All threads. */
3685 b
= set_raw_breakpoint (sal
);
3686 set_breakpoint_count (breakpoint_count
+ 1);
3687 b
->number
= breakpoint_count
;
3689 b
->cond_string
= (cond_string
== NULL
) ?
3690 NULL
: savestring (cond_string
, strlen (cond_string
));
3692 b
->addr_string
= NULL
;
3693 b
->enable
= enabled
;
3694 b
->disposition
= tempflag
? del
: donttouch
;
3696 b
->type
= bp_catch_exec
;
3702 hw_breakpoint_used_count ()
3704 register struct breakpoint
*b
;
3709 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
3717 hw_watchpoint_used_count (type
, other_type_used
)
3719 int *other_type_used
;
3721 register struct breakpoint
*b
;
3724 *other_type_used
= 0;
3727 if (b
->enable
== enabled
)
3729 if (b
->type
== type
)
3731 else if ((b
->type
== bp_hardware_watchpoint
||
3732 b
->type
== bp_read_watchpoint
||
3733 b
->type
== bp_access_watchpoint
)
3734 && b
->enable
== enabled
)
3735 *other_type_used
= 1;
3741 /* Call this after hitting the longjmp() breakpoint. Use this to set
3742 a new breakpoint at the target of the jmp_buf.
3744 FIXME - This ought to be done by setting a temporary breakpoint
3745 that gets deleted automatically... */
3748 set_longjmp_resume_breakpoint (pc
, frame
)
3750 struct frame_info
*frame
;
3752 register struct breakpoint
*b
;
3755 if (b
->type
== bp_longjmp_resume
)
3758 b
->enable
= enabled
;
3760 b
->frame
= frame
->frame
;
3763 check_duplicates (b
->address
, b
->section
);
3769 disable_watchpoints_before_interactive_call_start ()
3771 struct breakpoint
*b
;
3775 if (((b
->type
== bp_watchpoint
)
3776 || (b
->type
== bp_hardware_watchpoint
)
3777 || (b
->type
== bp_read_watchpoint
)
3778 || (b
->type
== bp_access_watchpoint
)
3779 || ep_is_exception_catchpoint (b
))
3780 && (b
->enable
== enabled
))
3782 b
->enable
= call_disabled
;
3783 check_duplicates (b
->address
, b
->section
);
3789 enable_watchpoints_after_interactive_call_stop ()
3791 struct breakpoint
*b
;
3795 if (((b
->type
== bp_watchpoint
)
3796 || (b
->type
== bp_hardware_watchpoint
)
3797 || (b
->type
== bp_read_watchpoint
)
3798 || (b
->type
== bp_access_watchpoint
)
3799 || ep_is_exception_catchpoint (b
))
3800 && (b
->enable
== call_disabled
))
3802 b
->enable
= enabled
;
3803 check_duplicates (b
->address
, b
->section
);
3809 /* Set a breakpoint that will evaporate an end of command
3810 at address specified by SAL.
3811 Restrict it to frame FRAME if FRAME is nonzero. */
3814 set_momentary_breakpoint (sal
, frame
, type
)
3815 struct symtab_and_line sal
;
3816 struct frame_info
*frame
;
3819 register struct breakpoint
*b
;
3820 b
= set_raw_breakpoint (sal
);
3822 b
->enable
= enabled
;
3823 b
->disposition
= donttouch
;
3824 b
->frame
= (frame
? frame
->frame
: 0);
3826 /* If we're debugging a multi-threaded program, then we
3827 want momentary breakpoints to be active in only a
3828 single thread of control. */
3829 if (in_thread_list (inferior_pid
))
3830 b
->thread
= pid_to_thread_id (inferior_pid
);
3836 /* Tell the user we have just set a breakpoint B. */
3840 struct breakpoint
*b
;
3844 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3845 watchpoint) other than breakpoint creation. It should be possible to
3846 clean this up and at the same time replace the random calls to
3847 breakpoint_changed with this hook, as has already been done for
3848 delete_breakpoint_hook and so on. */
3849 if (create_breakpoint_hook
)
3850 create_breakpoint_hook (b
);
3851 breakpoint_create_event (b
->number
);
3856 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
3859 printf_filtered ("Watchpoint %d: ", b
->number
);
3860 print_expression (b
->exp
, gdb_stdout
);
3862 case bp_hardware_watchpoint
:
3863 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
3864 print_expression (b
->exp
, gdb_stdout
);
3866 case bp_read_watchpoint
:
3867 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
3868 print_expression (b
->exp
, gdb_stdout
);
3870 case bp_access_watchpoint
:
3871 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
3873 print_expression (b
->exp
, gdb_stdout
);
3876 printf_filtered ("Breakpoint %d", b
->number
);
3879 case bp_hardware_breakpoint
:
3880 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
3884 case bp_catch_unload
:
3885 printf_filtered ("Catchpoint %d (%s %s)",
3887 (b
->type
== bp_catch_load
) ? "load" : "unload",
3888 (b
->dll_pathname
!= NULL
) ?
3889 b
->dll_pathname
: "<any library>");
3892 case bp_catch_vfork
:
3893 printf_filtered ("Catchpoint %d (%s)",
3895 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
3898 printf_filtered ("Catchpoint %d (exec)",
3901 case bp_catch_catch
:
3902 case bp_catch_throw
:
3903 printf_filtered ("Catchpoint %d (%s)",
3905 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
3911 case bp_longjmp_resume
:
3912 case bp_step_resume
:
3913 case bp_through_sigtramp
:
3915 case bp_watchpoint_scope
:
3916 case bp_shlib_event
:
3921 if (addressprint
|| b
->source_file
== NULL
)
3923 printf_filtered (" at ");
3924 print_address_numeric (b
->address
, 1, gdb_stdout
);
3927 printf_filtered (": file %s, line %d.",
3928 b
->source_file
, b
->line_number
);
3929 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
3930 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
3932 printf_filtered ("\n");
3936 /* Set a breakpoint according to ARG (function, linenum or *address)
3937 flag: first bit : 0 non-temporary, 1 temporary.
3938 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3941 break_command_1 (arg
, flag
, from_tty
)
3945 int tempflag
, hardwareflag
;
3946 struct symtabs_and_lines sals
;
3947 struct symtab_and_line sal
;
3948 register struct expression
*cond
= 0;
3949 register struct breakpoint
*b
;
3951 /* Pointers in arg to the start, and one past the end, of the condition. */
3952 char *cond_start
= NULL
;
3953 char *cond_end
= NULL
;
3954 /* Pointers in arg to the start, and one past the end,
3955 of the address part. */
3956 char *addr_start
= NULL
;
3957 char *addr_end
= NULL
;
3958 struct cleanup
*old_chain
;
3959 struct cleanup
*canonical_strings_chain
= NULL
;
3960 char **canonical
= (char **) NULL
;
3964 hardwareflag
= flag
& BP_HARDWAREFLAG
;
3965 tempflag
= flag
& BP_TEMPFLAG
;
3970 INIT_SAL (&sal
); /* initialize to zeroes */
3972 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3974 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
3975 && (arg
[2] == ' ' || arg
[2] == '\t')))
3977 if (default_breakpoint_valid
)
3979 sals
.sals
= (struct symtab_and_line
*)
3980 xmalloc (sizeof (struct symtab_and_line
));
3981 sal
.pc
= default_breakpoint_address
;
3982 sal
.line
= default_breakpoint_line
;
3983 sal
.symtab
= default_breakpoint_symtab
;
3984 sal
.section
= find_pc_overlay (sal
.pc
);
3989 error ("No default breakpoint address now.");
3995 /* Force almost all breakpoints to be in terms of the
3996 current_source_symtab (which is decode_line_1's default). This
3997 should produce the results we want almost all of the time while
3998 leaving default_breakpoint_* alone. */
3999 if (default_breakpoint_valid
4000 && (!current_source_symtab
4001 || (arg
&& (*arg
== '+' || *arg
== '-'))))
4002 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
4003 default_breakpoint_line
, &canonical
);
4005 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
, 0, &canonical
);
4013 /* Make sure that all storage allocated in decode_line_1 gets freed
4014 in case the following `for' loop errors out. */
4015 old_chain
= make_cleanup (free
, sals
.sals
);
4016 if (canonical
!= (char **) NULL
)
4018 make_cleanup (free
, canonical
);
4019 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
4020 for (i
= 0; i
< sals
.nelts
; i
++)
4022 if (canonical
[i
] != NULL
)
4023 make_cleanup (free
, canonical
[i
]);
4027 thread
= -1; /* No specific thread yet */
4029 /* Resolve all line numbers to PC's, and verify that conditions
4030 can be parsed, before setting any breakpoints. */
4031 for (i
= 0; i
< sals
.nelts
; i
++)
4033 char *tok
, *end_tok
;
4036 resolve_sal_pc (&sals
.sals
[i
]);
4038 /* It's possible for the PC to be nonzero, but still an illegal
4039 value on some targets.
4041 For example, on HP-UX if you start gdb, and before running the
4042 inferior you try to set a breakpoint on a shared library function
4043 "foo" where the inferior doesn't call "foo" directly but does
4044 pass its address to another function call, then we do find a
4045 minimal symbol for the "foo", but it's address is invalid.
4046 (Appears to be an index into a table that the loader sets up
4047 when the inferior is run.)
4049 Give the target a chance to bless sals.sals[i].pc before we
4050 try to make a breakpoint for it. */
4051 if (PC_REQUIRES_RUN_BEFORE_USE (sals
.sals
[i
].pc
))
4053 error ("Cannot break on %s without a running program.",
4061 while (*tok
== ' ' || *tok
== '\t')
4066 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4069 toklen
= end_tok
- tok
;
4071 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4073 tok
= cond_start
= end_tok
+ 1;
4074 cond
= parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4077 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4083 thread
= strtol (tok
, &tok
, 0);
4085 error ("Junk after thread keyword.");
4086 if (!valid_thread_id (thread
))
4087 error ("Unknown thread %d\n", thread
);
4090 error ("Junk at end of arguments.");
4095 int i
, target_resources_ok
;
4097 i
= hw_breakpoint_used_count ();
4098 target_resources_ok
=
4099 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4101 if (target_resources_ok
== 0)
4102 error ("No hardware breakpoint support in the target.");
4103 else if (target_resources_ok
< 0)
4104 error ("Hardware breakpoints used exceeds limit.");
4107 /* Remove the canonical strings from the cleanup, they are needed below. */
4108 if (canonical
!= (char **) NULL
)
4109 discard_cleanups (canonical_strings_chain
);
4111 /* Now set all the breakpoints. */
4112 for (i
= 0; i
< sals
.nelts
; i
++)
4117 describe_other_breakpoints (sal
.pc
, sal
.section
);
4119 b
= set_raw_breakpoint (sal
);
4120 set_breakpoint_count (breakpoint_count
+ 1);
4121 b
->number
= breakpoint_count
;
4122 b
->type
= hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
;
4126 /* If a canonical line spec is needed use that instead of the
4128 if (canonical
!= (char **) NULL
&& canonical
[i
] != NULL
)
4129 b
->addr_string
= canonical
[i
];
4130 else if (addr_start
)
4131 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4133 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4135 b
->enable
= enabled
;
4136 b
->disposition
= tempflag
? del
: donttouch
;
4142 warning ("Multiple breakpoints were set.");
4143 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4145 do_cleanups (old_chain
);
4149 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4154 struct frame_info
*frame
;
4155 CORE_ADDR low
, high
, selected_pc
= 0;
4156 char *extra_args
, *level_arg
, *addr_string
;
4157 int extra_args_len
= 0, if_arg
= 0;
4160 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4163 if (default_breakpoint_valid
)
4167 selected_pc
= selected_frame
->pc
;
4172 error ("No selected frame.");
4175 error ("No default breakpoint address now.");
4179 extra_args
= strchr (arg
, ' ');
4183 extra_args_len
= strlen (extra_args
);
4184 level_arg
= (char *) xmalloc (extra_args
- arg
);
4185 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4186 level_arg
[extra_args
- arg
- 1] = '\0';
4190 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4191 strcpy (level_arg
, arg
);
4194 frame
= parse_frame_specification (level_arg
);
4196 selected_pc
= frame
->pc
;
4203 extra_args_len
= strlen (arg
);
4208 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4210 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4212 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4214 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4215 break_command_1 (addr_string
, flag
, from_tty
);
4219 error ("No function contains the specified address");
4222 error ("Unable to set breakpoint at procedure exit");
4227 break_at_finish_command_1 (arg
, flag
, from_tty
)
4232 char *addr_string
, *break_string
, *beg_addr_string
;
4233 CORE_ADDR low
, high
;
4234 struct symtabs_and_lines sals
;
4235 struct symtab_and_line sal
;
4236 struct cleanup
*old_chain
;
4238 int extra_args_len
= 0;
4242 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4244 if (default_breakpoint_valid
)
4248 addr_string
= (char *) xmalloc (15);
4249 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
4254 error ("No selected frame.");
4257 error ("No default breakpoint address now.");
4261 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
4262 strcpy (addr_string
, arg
);
4268 extra_args_len
= strlen (arg
);
4272 /* get the stuff after the function name or address */
4273 extra_args
= strchr (arg
, ' ');
4277 extra_args_len
= strlen (extra_args
);
4284 beg_addr_string
= addr_string
;
4285 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
4288 free (beg_addr_string
);
4289 old_chain
= make_cleanup (free
, sals
.sals
);
4290 for (i
= 0; (i
< sals
.nelts
); i
++)
4293 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
4295 break_string
= (char *) xmalloc (extra_args_len
+ 26);
4297 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4299 sprintf (break_string
, "*0x%s", paddr_nz (high
));
4300 break_command_1 (break_string
, flag
, from_tty
);
4301 free (break_string
);
4304 error ("No function contains the specified address");
4308 warning ("Multiple breakpoints were set.\n");
4309 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4311 do_cleanups (old_chain
);
4315 /* Helper function for break_command_1 and disassemble_command. */
4318 resolve_sal_pc (sal
)
4319 struct symtab_and_line
*sal
;
4323 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
4325 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
4326 error ("No line %d in file \"%s\".",
4327 sal
->line
, sal
->symtab
->filename
);
4331 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
4333 struct blockvector
*bv
;
4338 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
4341 b
= BLOCKVECTOR_BLOCK (bv
, index
);
4342 sym
= block_function (b
);
4345 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
4346 sal
->section
= SYMBOL_BFD_SECTION (sym
);
4350 /* It really is worthwhile to have the section, so we'll just
4351 have to look harder. This case can be executed if we have
4352 line numbers but no functions (as can happen in assembly
4355 struct minimal_symbol
*msym
;
4357 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
4359 sal
->section
= SYMBOL_BFD_SECTION (msym
);
4366 break_command (arg
, from_tty
)
4370 break_command_1 (arg
, 0, from_tty
);
4374 break_at_finish_command (arg
, from_tty
)
4378 break_at_finish_command_1 (arg
, 0, from_tty
);
4382 break_at_finish_at_depth_command (arg
, from_tty
)
4386 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
4390 tbreak_command (arg
, from_tty
)
4394 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4398 tbreak_at_finish_command (arg
, from_tty
)
4402 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4406 hbreak_command (arg
, from_tty
)
4410 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
4414 thbreak_command (arg
, from_tty
)
4418 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
4422 stop_command (arg
, from_tty
)
4426 printf_filtered ("Specify the type of breakpoint to set.\n\
4427 Usage: stop in <function | address>\n\
4432 stopin_command (arg
, from_tty
)
4438 if (arg
== (char *) NULL
)
4440 else if (*arg
!= '*')
4445 /* look for a ':'. If this is a line number specification, then
4446 say it is bad, otherwise, it should be an address or
4447 function/method name */
4448 while (*argptr
&& !hasColon
)
4450 hasColon
= (*argptr
== ':');
4455 badInput
= (*argptr
!= ':'); /* Not a class::method */
4457 badInput
= isdigit (*arg
); /* a simple line number */
4461 printf_filtered ("Usage: stop in <function | address>\n");
4463 break_command_1 (arg
, 0, from_tty
);
4467 stopat_command (arg
, from_tty
)
4473 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
4480 /* look for a ':'. If there is a '::' then get out, otherwise
4481 it is probably a line number. */
4482 while (*argptr
&& !hasColon
)
4484 hasColon
= (*argptr
== ':');
4489 badInput
= (*argptr
== ':'); /* we have class::method */
4491 badInput
= !isdigit (*arg
); /* not a line number */
4495 printf_filtered ("Usage: stop at <line>\n");
4497 break_command_1 (arg
, 0, from_tty
);
4501 /* accessflag: hw_write: watch write,
4502 hw_read: watch read,
4503 hw_access: watch access (read or write) */
4505 watch_command_1 (arg
, accessflag
, from_tty
)
4510 struct breakpoint
*b
;
4511 struct symtab_and_line sal
;
4512 struct expression
*exp
;
4513 struct block
*exp_valid_block
;
4514 struct value
*val
, *mark
;
4515 struct frame_info
*frame
;
4516 struct frame_info
*prev_frame
= NULL
;
4517 char *exp_start
= NULL
;
4518 char *exp_end
= NULL
;
4519 char *tok
, *end_tok
;
4521 char *cond_start
= NULL
;
4522 char *cond_end
= NULL
;
4523 struct expression
*cond
= NULL
;
4524 int i
, other_type_used
, target_resources_ok
= 0;
4525 enum bptype bp_type
;
4528 INIT_SAL (&sal
); /* initialize to zeroes */
4530 /* Parse arguments. */
4531 innermost_block
= NULL
;
4533 exp
= parse_exp_1 (&arg
, 0, 0);
4535 exp_valid_block
= innermost_block
;
4536 mark
= value_mark ();
4537 val
= evaluate_expression (exp
);
4538 release_value (val
);
4539 if (VALUE_LAZY (val
))
4540 value_fetch_lazy (val
);
4543 while (*tok
== ' ' || *tok
== '\t')
4547 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4550 toklen
= end_tok
- tok
;
4551 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4553 tok
= cond_start
= end_tok
+ 1;
4554 cond
= parse_exp_1 (&tok
, 0, 0);
4558 error ("Junk at end of command.");
4560 if (accessflag
== hw_read
)
4561 bp_type
= bp_read_watchpoint
;
4562 else if (accessflag
== hw_access
)
4563 bp_type
= bp_access_watchpoint
;
4565 bp_type
= bp_hardware_watchpoint
;
4567 mem_cnt
= can_use_hardware_watchpoint (val
);
4568 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
4569 error ("Expression cannot be implemented with read/access watchpoint.");
4572 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
4573 target_resources_ok
=
4574 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
4576 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
4577 error ("Target does not support this type of hardware watchpoint.");
4579 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
4580 error ("Target can only support one kind of HW watchpoint at a time.");
4583 #if defined(HPUXHPPA)
4584 /* On HP-UX if you set a h/w
4585 watchpoint before the "run" command, the inferior dies with a e.g.,
4586 SIGILL once you start it. I initially believed this was due to a
4587 bad interaction between page protection traps and the initial
4588 startup sequence by the dynamic linker.
4590 However, I tried avoiding that by having HP-UX's implementation of
4591 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4592 yet, which forced slow watches before a "run" or "attach", and it
4593 still fails somewhere in the startup code.
4595 Until I figure out what's happening, I'm disallowing watches altogether
4596 before the "run" or "attach" command. We'll tell the user they must
4597 set watches after getting the program started. */
4598 if (!target_has_execution
)
4600 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4603 #endif /* HPUXHPPA */
4605 /* Now set up the breakpoint. */
4606 b
= set_raw_breakpoint (sal
);
4607 set_breakpoint_count (breakpoint_count
+ 1);
4608 b
->number
= breakpoint_count
;
4609 b
->disposition
= donttouch
;
4611 b
->exp_valid_block
= exp_valid_block
;
4612 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
4616 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4620 frame
= block_innermost_frame (exp_valid_block
);
4623 prev_frame
= get_prev_frame (frame
);
4624 b
->watchpoint_frame
= frame
->frame
;
4627 b
->watchpoint_frame
= (CORE_ADDR
) 0;
4629 if (mem_cnt
&& target_resources_ok
> 0)
4632 b
->type
= bp_watchpoint
;
4634 /* If the expression is "local", then set up a "watchpoint scope"
4635 breakpoint at the point where we've left the scope of the watchpoint
4637 if (innermost_block
)
4641 struct breakpoint
*scope_breakpoint
;
4642 struct symtab_and_line scope_sal
;
4644 INIT_SAL (&scope_sal
); /* initialize to zeroes */
4645 scope_sal
.pc
= get_frame_pc (prev_frame
);
4646 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
4648 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
4649 set_breakpoint_count (breakpoint_count
+ 1);
4650 scope_breakpoint
->number
= breakpoint_count
;
4652 scope_breakpoint
->type
= bp_watchpoint_scope
;
4653 scope_breakpoint
->enable
= enabled
;
4655 /* Automatically delete the breakpoint when it hits. */
4656 scope_breakpoint
->disposition
= del
;
4658 /* Only break in the proper frame (help with recursion). */
4659 scope_breakpoint
->frame
= prev_frame
->frame
;
4661 /* Set the address at which we will stop. */
4662 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
4664 /* The scope breakpoint is related to the watchpoint. We
4665 will need to act on them together. */
4666 b
->related_breakpoint
= scope_breakpoint
;
4669 value_free_to_mark (mark
);
4673 /* Return count of locations need to be watched and can be handled
4674 in hardware. If the watchpoint can not be handled
4675 in hardware return zero. */
4677 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4678 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
4679 ((BYTE_SIZE) <= (REGISTER_SIZE))
4682 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
4683 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
4684 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
4688 can_use_hardware_watchpoint (v
)
4691 int found_memory_cnt
= 0;
4693 /* Did the user specifically forbid us to use hardware watchpoints? */
4694 if (!can_use_hw_watchpoints
)
4697 /* Make sure all the intermediate values are in memory. Also make sure
4698 we found at least one memory expression. Guards against watch 0x12345,
4699 which is meaningless, but could cause errors if one tries to insert a
4700 hardware watchpoint for the constant expression. */
4701 for (; v
; v
= v
->next
)
4703 if (v
->lval
== lval_memory
)
4705 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
4706 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
4708 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
4713 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
4714 return 0; /* ??? What does this represent? */
4715 else if (v
->lval
== lval_register
)
4716 return 0; /* cannot watch a register with a HW watchpoint */
4719 /* The expression itself looks suitable for using a hardware
4720 watchpoint, but give the target machine a chance to reject it. */
4721 return found_memory_cnt
;
4725 watch_command (arg
, from_tty
)
4729 watch_command_1 (arg
, hw_write
, from_tty
);
4733 rwatch_command (arg
, from_tty
)
4737 watch_command_1 (arg
, hw_read
, from_tty
);
4741 awatch_command (arg
, from_tty
)
4745 watch_command_1 (arg
, hw_access
, from_tty
);
4749 /* Helper routines for the until_command routine in infcmd.c. Here
4750 because it uses the mechanisms of breakpoints. */
4752 /* This function is called by fetch_inferior_event via the
4753 cmd_continuation pointer, to complete the until command. It takes
4754 care of cleaning up the temporary breakpoints set up by the until
4757 until_break_command_continuation (struct continuation_arg
*arg
)
4759 /* Do all the exec cleanups, which at this point should only be the
4760 one set up in the first part of the until_break_command
4762 do_exec_cleanups (ALL_CLEANUPS
);
4767 until_break_command (arg
, from_tty
)
4771 struct symtabs_and_lines sals
;
4772 struct symtab_and_line sal
;
4773 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
4774 struct breakpoint
*breakpoint
;
4775 struct cleanup
*old_chain
;
4777 clear_proceed_status ();
4779 /* Set a breakpoint where the user wants it and at return from
4782 if (default_breakpoint_valid
)
4783 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
4784 default_breakpoint_line
, (char ***) NULL
);
4786 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
4787 0, (char ***) NULL
);
4789 if (sals
.nelts
!= 1)
4790 error ("Couldn't get information on specified line.");
4793 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
4796 error ("Junk at end of arguments.");
4798 resolve_sal_pc (&sal
);
4800 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
4802 if (!event_loop_p
|| !target_can_async_p ())
4803 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
4806 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4808 /* If we are running asynchronously, and the target supports async
4809 execution, we are not waiting for the target to stop, in the call
4810 tp proceed, below. This means that we cannot delete the
4811 brekpoints until the target has actually stopped. The only place
4812 where we get a chance to do that is in fetch_inferior_event, so
4813 we must set things up for that. */
4815 if (event_loop_p
&& target_can_async_p ())
4817 /* In this case we don't need args for the continuation, because
4818 all it needs to do is do the cleanups in the
4819 exec_cleanup_chain, which will be only those inserted by this
4820 function. We can get away by using ALL_CLEANUPS. */
4821 add_continuation (until_break_command_continuation
, NULL
);
4824 /* Keep within the current frame */
4828 sal
= find_pc_line (prev_frame
->pc
, 0);
4829 sal
.pc
= prev_frame
->pc
;
4830 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
4831 if (!event_loop_p
|| !target_can_async_p ())
4832 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4834 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4837 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
4838 /* Do the cleanups now, anly if we are not running asynchronously,
4839 of if we are, but the target is still synchronous. */
4840 if (!event_loop_p
|| !target_can_async_p ())
4841 do_cleanups (old_chain
);
4845 /* These aren't used; I don't konw what they were for. */
4846 /* Set a breakpoint at the catch clause for NAME. */
4848 catch_breakpoint (name
)
4854 disable_catch_breakpoint ()
4859 delete_catch_breakpoint ()
4864 enable_catch_breakpoint ()
4871 struct sal_chain
*next
;
4872 struct symtab_and_line sal
;
4876 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4877 had been commented out in the v.4.16 sources, and stays
4878 disabled there now because "catch NAME" syntax isn't allowed.
4880 /* This isn't used; I don't know what it was for. */
4881 /* For each catch clause identified in ARGS, run FUNCTION
4882 with that clause as an argument. */
4883 static struct symtabs_and_lines
4884 map_catch_names (args
, function
)
4888 register char *p
= args
;
4890 struct symtabs_and_lines sals
;
4892 struct sal_chain
*sal_chain
= 0;
4896 error_no_arg ("one or more catch names");
4904 /* Don't swallow conditional part. */
4905 if (p1
[0] == 'i' && p1
[1] == 'f'
4906 && (p1
[2] == ' ' || p1
[2] == '\t'))
4912 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
4916 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
4917 error ("Arguments must be catch names.");
4923 struct sal_chain
*next
= (struct sal_chain
*)
4924 alloca (sizeof (struct sal_chain
));
4925 next
->next
= sal_chain
;
4926 next
->sal
= get_catch_sal (p
);
4931 printf_unfiltered ("No catch clause for exception %s.\n", p
);
4936 while (*p
== ' ' || *p
== '\t')
4942 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4944 static struct symtabs_and_lines
4945 get_catch_sals (this_level_only
)
4946 int this_level_only
;
4948 register struct blockvector
*bl
;
4949 register struct block
*block
;
4950 int index
, have_default
= 0;
4952 struct symtabs_and_lines sals
;
4953 struct sal_chain
*sal_chain
= 0;
4954 char *blocks_searched
;
4956 /* Not sure whether an error message is always the correct response,
4957 but it's better than a core dump. */
4958 if (selected_frame
== NULL
)
4959 error ("No selected frame.");
4960 block
= get_frame_block (selected_frame
);
4961 pc
= selected_frame
->pc
;
4967 error ("No symbol table info available.\n");
4969 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
4970 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4971 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4975 CORE_ADDR end
= BLOCK_END (block
) - 4;
4978 if (bl
!= blockvector_for_pc (end
, &index
))
4979 error ("blockvector blotch");
4980 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
4981 error ("blockvector botch");
4982 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
4985 /* Don't print out blocks that have gone by. */
4986 while (index
< last_index
4987 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
4990 while (index
< last_index
4991 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
4993 if (blocks_searched
[index
] == 0)
4995 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
4998 register struct symbol
*sym
;
5000 nsyms
= BLOCK_NSYMS (b
);
5002 for (i
= 0; i
< nsyms
; i
++)
5004 sym
= BLOCK_SYM (b
, i
);
5005 if (STREQ (SYMBOL_NAME (sym
), "default"))
5011 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
5013 struct sal_chain
*next
= (struct sal_chain
*)
5014 alloca (sizeof (struct sal_chain
));
5015 next
->next
= sal_chain
;
5016 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
5021 blocks_searched
[index
] = 1;
5027 if (sal_chain
&& this_level_only
)
5030 /* After handling the function's top-level block, stop.
5031 Don't continue to its superblock, the block of
5032 per-file symbols. */
5033 if (BLOCK_FUNCTION (block
))
5035 block
= BLOCK_SUPERBLOCK (block
);
5040 struct sal_chain
*tmp_chain
;
5042 /* Count the number of entries. */
5043 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
5044 tmp_chain
= tmp_chain
->next
)
5048 sals
.sals
= (struct symtab_and_line
*)
5049 xmalloc (index
* sizeof (struct symtab_and_line
));
5050 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5051 sals
.sals
[index
] = sal_chain
->sal
;
5058 ep_skip_leading_whitespace (s
)
5061 if ((s
== NULL
) || (*s
== NULL
))
5063 while (isspace (**s
))
5067 /* This function examines a string, and attempts to find a token
5068 that might be an event name in the leading characters. If a
5069 possible match is found, a pointer to the last character of
5070 the token is returned. Else, NULL is returned. */
5073 ep_find_event_name_end (arg
)
5077 char *event_name_end
= NULL
;
5079 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5083 /* We break out of the loop when we find a token delimiter.
5084 Basically, we're looking for alphanumerics and underscores;
5085 anything else delimites the token. */
5088 if (!isalnum (*s
) && (*s
!= '_'))
5094 return event_name_end
;
5098 /* This function attempts to parse an optional "if <cond>" clause
5099 from the arg string. If one is not found, it returns NULL.
5101 Else, it returns a pointer to the condition string. (It does not
5102 attempt to evaluate the string against a particular block.) And,
5103 it updates arg to point to the first character following the parsed
5104 if clause in the arg string. */
5107 ep_parse_optional_if_clause (arg
)
5112 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5115 /* Skip the "if" keyword. */
5118 /* Skip any extra leading whitespace, and record the start of the
5119 condition string. */
5120 ep_skip_leading_whitespace (arg
);
5123 /* Assume that the condition occupies the remainder of the arg string. */
5124 (*arg
) += strlen (cond_string
);
5129 /* This function attempts to parse an optional filename from the arg
5130 string. If one is not found, it returns NULL.
5132 Else, it returns a pointer to the parsed filename. (This function
5133 makes no attempt to verify that a file of that name exists, or is
5134 accessible.) And, it updates arg to point to the first character
5135 following the parsed filename in the arg string.
5137 Note that clients needing to preserve the returned filename for
5138 future access should copy it to their own buffers. */
5140 ep_parse_optional_filename (arg
)
5143 static char filename
[1024];
5148 if ((*arg_p
== '\0') || isspace (*arg_p
))
5166 /* Commands to deal with catching events, such as signals, exceptions,
5167 process start/exit, etc. */
5171 catch_fork
, catch_vfork
5175 #if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
5176 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
5182 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
5183 catch_fork_kind fork_kind
;
5188 char *cond_string
= NULL
;
5190 ep_skip_leading_whitespace (&arg
);
5192 /* The allowed syntax is:
5194 catch [v]fork if <cond>
5196 First, check if there's an if clause. */
5197 cond_string
= ep_parse_optional_if_clause (&arg
);
5199 if ((*arg
!= '\0') && !isspace (*arg
))
5200 error ("Junk at end of arguments.");
5202 /* If this target supports it, create a fork or vfork catchpoint
5203 and enable reporting of such events. */
5207 create_fork_event_catchpoint (tempflag
, cond_string
);
5210 create_vfork_event_catchpoint (tempflag
, cond_string
);
5213 error ("unsupported or unknown fork kind; cannot catch it");
5219 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5221 catch_exec_command_1 (arg
, tempflag
, from_tty
)
5226 char *cond_string
= NULL
;
5228 ep_skip_leading_whitespace (&arg
);
5230 /* The allowed syntax is:
5232 catch exec if <cond>
5234 First, check if there's an if clause. */
5235 cond_string
= ep_parse_optional_if_clause (&arg
);
5237 if ((*arg
!= '\0') && !isspace (*arg
))
5238 error ("Junk at end of arguments.");
5240 /* If this target supports it, create an exec catchpoint
5241 and enable reporting of such events. */
5242 create_exec_event_catchpoint (tempflag
, cond_string
);
5246 #if defined(SOLIB_ADD)
5248 catch_load_command_1 (arg
, tempflag
, from_tty
)
5253 char *dll_pathname
= NULL
;
5254 char *cond_string
= NULL
;
5256 ep_skip_leading_whitespace (&arg
);
5258 /* The allowed syntax is:
5260 catch load if <cond>
5261 catch load <filename>
5262 catch load <filename> if <cond>
5264 The user is not allowed to specify the <filename> after an
5267 We'll ignore the pathological case of a file named "if".
5269 First, check if there's an if clause. If so, then there
5270 cannot be a filename. */
5271 cond_string
= ep_parse_optional_if_clause (&arg
);
5273 /* If there was an if clause, then there cannot be a filename.
5274 Else, there might be a filename and an if clause. */
5275 if (cond_string
== NULL
)
5277 dll_pathname
= ep_parse_optional_filename (&arg
);
5278 ep_skip_leading_whitespace (&arg
);
5279 cond_string
= ep_parse_optional_if_clause (&arg
);
5282 if ((*arg
!= '\0') && !isspace (*arg
))
5283 error ("Junk at end of arguments.");
5285 /* Create a load breakpoint that only triggers when a load of
5286 the specified dll (or any dll, if no pathname was specified)
5288 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
5289 dll_pathname
, cond_string
);
5293 catch_unload_command_1 (arg
, tempflag
, from_tty
)
5298 char *dll_pathname
= NULL
;
5299 char *cond_string
= NULL
;
5301 ep_skip_leading_whitespace (&arg
);
5303 /* The allowed syntax is:
5305 catch unload if <cond>
5306 catch unload <filename>
5307 catch unload <filename> if <cond>
5309 The user is not allowed to specify the <filename> after an
5312 We'll ignore the pathological case of a file named "if".
5314 First, check if there's an if clause. If so, then there
5315 cannot be a filename. */
5316 cond_string
= ep_parse_optional_if_clause (&arg
);
5318 /* If there was an if clause, then there cannot be a filename.
5319 Else, there might be a filename and an if clause. */
5320 if (cond_string
== NULL
)
5322 dll_pathname
= ep_parse_optional_filename (&arg
);
5323 ep_skip_leading_whitespace (&arg
);
5324 cond_string
= ep_parse_optional_if_clause (&arg
);
5327 if ((*arg
!= '\0') && !isspace (*arg
))
5328 error ("Junk at end of arguments.");
5330 /* Create an unload breakpoint that only triggers when an unload of
5331 the specified dll (or any dll, if no pathname was specified)
5333 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
5334 dll_pathname
, cond_string
);
5336 #endif /* SOLIB_ADD */
5338 /* Commands to deal with catching exceptions. */
5340 /* Set a breakpoint at the specified callback routine for an
5341 exception event callback */
5344 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
5347 enum exception_event_kind ex_event
;
5348 struct symtab_and_line
*sal
;
5350 struct breakpoint
*b
;
5351 int thread
= -1; /* All threads. */
5353 if (!sal
) /* no exception support? */
5356 b
= set_raw_breakpoint (*sal
);
5357 set_breakpoint_count (breakpoint_count
+ 1);
5358 b
->number
= breakpoint_count
;
5360 b
->cond_string
= (cond_string
== NULL
) ?
5361 NULL
: savestring (cond_string
, strlen (cond_string
));
5363 b
->addr_string
= NULL
;
5364 b
->enable
= enabled
;
5365 b
->disposition
= tempflag
? del
: donttouch
;
5368 case EX_EVENT_THROW
:
5369 b
->type
= bp_catch_throw
;
5371 case EX_EVENT_CATCH
:
5372 b
->type
= bp_catch_catch
;
5374 default: /* error condition */
5376 b
->enable
= disabled
;
5377 error ("Internal error -- invalid catchpoint kind");
5382 /* Deal with "catch catch" and "catch throw" commands */
5385 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
5386 enum exception_event_kind ex_event
;
5391 char *cond_string
= NULL
;
5392 struct symtab_and_line
*sal
= NULL
;
5394 ep_skip_leading_whitespace (&arg
);
5396 cond_string
= ep_parse_optional_if_clause (&arg
);
5398 if ((*arg
!= '\0') && !isspace (*arg
))
5399 error ("Junk at end of arguments.");
5401 if ((ex_event
!= EX_EVENT_THROW
) &&
5402 (ex_event
!= EX_EVENT_CATCH
))
5403 error ("Unsupported or unknown exception event; cannot catch it");
5405 /* See if we can find a callback routine */
5406 sal
= target_enable_exception_callback (ex_event
, 1);
5410 /* We have callbacks from the runtime system for exceptions.
5411 Set a breakpoint on the sal found, if no errors */
5412 if (sal
!= (struct symtab_and_line
*) -1)
5413 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
5415 return; /* something went wrong with setting up callbacks */
5419 /* No callbacks from runtime system for exceptions.
5420 Try GNU C++ exception breakpoints using labels in debug info. */
5421 if (ex_event
== EX_EVENT_CATCH
)
5423 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
5425 else if (ex_event
== EX_EVENT_THROW
)
5427 /* Set a breakpoint on __raise_exception () */
5429 warning ("Unsupported with this platform/compiler combination.");
5430 warning ("Perhaps you can achieve the effect you want by setting");
5431 warning ("a breakpoint on __raise_exception().");
5436 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5437 inside a catch_errors */
5440 cover_target_enable_exception_callback (arg
)
5443 args_for_catchpoint_enable
*args
= arg
;
5444 struct symtab_and_line
*sal
;
5445 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
5448 else if (sal
== (struct symtab_and_line
*) -1)
5451 return 1; /*is valid */
5456 /* This is the original v.4.16 and earlier version of the
5457 catch_command_1() function. Now that other flavours of "catch"
5458 have been introduced, and since exception handling can be handled
5459 in other ways (through target ops) also, this is used only for the
5460 GNU C++ exception handling system.
5461 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5462 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5463 there was no code in GDB 4.16 for "catch throw".
5465 Called from catch_exception_command_1 () */
5469 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
5474 /* First, translate ARG into something we can deal with in terms
5477 struct symtabs_and_lines sals
;
5478 struct symtab_and_line sal
;
5479 register struct expression
*cond
= 0;
5480 register struct breakpoint
*b
;
5484 INIT_SAL (&sal
); /* initialize to zeroes */
5486 /* If no arg given, or if first arg is 'if ', all active catch clauses
5487 are breakpointed. */
5489 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
5490 && (arg
[2] == ' ' || arg
[2] == '\t')))
5492 /* Grab all active catch clauses. */
5493 sals
= get_catch_sals (0);
5497 /* Grab selected catch clauses. */
5498 error ("catch NAME not implemented");
5501 /* Not sure why this code has been disabled. I'm leaving
5502 it disabled. We can never come here now anyway
5503 since we don't allow the "catch NAME" syntax.
5506 /* This isn't used; I don't know what it was for. */
5507 sals
= map_catch_names (arg
, catch_breakpoint
);
5515 for (i
= 0; i
< sals
.nelts
; i
++)
5517 resolve_sal_pc (&sals
.sals
[i
]);
5521 if (arg
[0] == 'i' && arg
[1] == 'f'
5522 && (arg
[2] == ' ' || arg
[2] == '\t'))
5523 cond
= parse_exp_1 ((arg
+= 2, &arg
),
5524 block_for_pc (sals
.sals
[i
].pc
), 0);
5526 error ("Junk at end of arguments.");
5531 for (i
= 0; i
< sals
.nelts
; i
++)
5536 describe_other_breakpoints (sal
.pc
, sal
.section
);
5538 b
= set_raw_breakpoint (sal
);
5539 set_breakpoint_count (breakpoint_count
+ 1);
5540 b
->number
= breakpoint_count
;
5542 /* Important -- this is an ordinary breakpoint. For platforms
5543 with callback support for exceptions,
5544 create_exception_catchpoint() will create special bp types
5545 (bp_catch_catch and bp_catch_throw), and there is code in
5546 insert_breakpoints() and elsewhere that depends on that. */
5547 b
->type
= bp_breakpoint
;
5550 b
->enable
= enabled
;
5551 b
->disposition
= tempflag
? del
: donttouch
;
5558 warning ("Multiple breakpoints were set.");
5559 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5561 free ((PTR
) sals
.sals
);
5565 /* This creates a temporary internal breakpoint
5566 just to placate infrun */
5567 static struct breakpoint
*
5568 create_temp_exception_breakpoint (pc
)
5571 struct symtab_and_line sal
;
5572 struct breakpoint
*b
;
5579 b
= set_raw_breakpoint (sal
);
5581 error ("Internal error -- couldn't set temp exception breakpoint");
5583 b
->type
= bp_breakpoint
;
5584 b
->disposition
= del
;
5585 b
->enable
= enabled
;
5587 b
->number
= internal_breakpoint_number
--;
5593 catch_command_1 (arg
, tempflag
, from_tty
)
5599 /* The first argument may be an event name, such as "start" or "load".
5600 If so, then handle it as such. If it doesn't match an event name,
5601 then attempt to interpret it as an exception name. (This latter is
5602 the v4.16-and-earlier GDB meaning of the "catch" command.)
5604 First, try to find the bounds of what might be an event name. */
5605 char *arg1_start
= arg
;
5609 if (arg1_start
== NULL
)
5611 /* Old behaviour was to use pre-v-4.16 syntax */
5612 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5614 /* Now, this is not allowed */
5615 error ("Catch requires an event name.");
5618 arg1_end
= ep_find_event_name_end (arg1_start
);
5619 if (arg1_end
== NULL
)
5620 error ("catch requires an event");
5621 arg1_length
= arg1_end
+ 1 - arg1_start
;
5623 /* Try to match what we found against known event names. */
5624 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
5626 error ("Catch of signal not yet implemented");
5628 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
5630 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
5631 tempflag
, from_tty
);
5633 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
5635 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
5636 tempflag
, from_tty
);
5638 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
5640 error ("Catch of thread_start not yet implemented");
5642 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
5644 error ("Catch of thread_exit not yet implemented");
5646 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
5648 error ("Catch of thread_join not yet implemented");
5650 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
5652 error ("Catch of start not yet implemented");
5654 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
5656 error ("Catch of exit not yet implemented");
5658 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
5660 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5661 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
5663 error ("Catch of fork not yet implemented");
5666 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
5668 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5669 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
5671 error ("Catch of vfork not yet implemented");
5674 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
5676 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5677 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5679 error ("Catch of exec not yet implemented");
5682 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
5684 #if defined(SOLIB_ADD)
5685 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5687 error ("Catch of load not implemented");
5690 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
5692 #if defined(SOLIB_ADD)
5693 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5695 error ("Catch of load not implemented");
5698 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
5700 error ("Catch of stop not yet implemented");
5703 /* This doesn't appear to be an event name */
5707 /* Pre-v.4.16 behaviour was to treat the argument
5708 as the name of an exception */
5709 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5710 /* Now this is not allowed */
5711 error ("Unknown event kind specified for catch");
5716 /* Used by the gui, could be made a worker for other things. */
5719 set_breakpoint_sal (sal
)
5720 struct symtab_and_line sal
;
5722 struct breakpoint
*b
;
5723 b
= set_raw_breakpoint (sal
);
5724 set_breakpoint_count (breakpoint_count
+ 1);
5725 b
->number
= breakpoint_count
;
5726 b
->type
= bp_breakpoint
;
5733 /* These aren't used; I don't know what they were for. */
5734 /* Disable breakpoints on all catch clauses described in ARGS. */
5736 disable_catch (args
)
5739 /* Map the disable command to catch clauses described in ARGS. */
5742 /* Enable breakpoints on all catch clauses described in ARGS. */
5747 /* Map the disable command to catch clauses described in ARGS. */
5750 /* Delete breakpoints on all catch clauses in the active scope. */
5755 /* Map the delete command to catch clauses described in ARGS. */
5760 catch_command (arg
, from_tty
)
5764 catch_command_1 (arg
, 0, from_tty
);
5769 tcatch_command (arg
, from_tty
)
5773 catch_command_1 (arg
, 1, from_tty
);
5778 clear_command (arg
, from_tty
)
5782 register struct breakpoint
*b
, *b1
;
5784 struct symtabs_and_lines sals
;
5785 struct symtab_and_line sal
;
5786 register struct breakpoint
*found
;
5791 sals
= decode_line_spec (arg
, 1);
5796 sals
.sals
= (struct symtab_and_line
*)
5797 xmalloc (sizeof (struct symtab_and_line
));
5798 INIT_SAL (&sal
); /* initialize to zeroes */
5799 sal
.line
= default_breakpoint_line
;
5800 sal
.symtab
= default_breakpoint_symtab
;
5801 sal
.pc
= default_breakpoint_address
;
5802 if (sal
.symtab
== 0)
5803 error ("No source file specified.");
5811 /* For each line spec given, delete bps which correspond
5812 to it. We do this in two loops: the first loop looks at
5813 the initial bp(s) in the chain which should be deleted,
5814 the second goes down the rest of the chain looking ahead
5815 one so it can take those bps off the chain without messing
5819 for (i
= 0; i
< sals
.nelts
; i
++)
5821 /* If exact pc given, clear bpts at that pc.
5822 If line given (pc == 0), clear all bpts on specified line.
5823 If defaulting, clear all bpts on default line
5826 defaulting sal.pc != 0 tests to do
5831 1 0 <can't happen> */
5834 found
= (struct breakpoint
*) 0;
5837 while (breakpoint_chain
5838 /* Why don't we check here that this is not
5839 a watchpoint, etc., as we do below?
5840 I can't make it fail, but don't know
5841 what's stopping the failure: a watchpoint
5842 of the same address as "sal.pc" should
5843 wind up being deleted. */
5845 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
5846 (overlay_debugging
== 0 ||
5847 breakpoint_chain
->section
== sal
.section
))
5848 || ((default_match
|| (0 == sal
.pc
))
5849 && breakpoint_chain
->source_file
!= NULL
5850 && sal
.symtab
!= NULL
5851 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
5852 && breakpoint_chain
->line_number
== sal
.line
)))
5855 b1
= breakpoint_chain
;
5856 breakpoint_chain
= b1
->next
;
5864 && b
->next
->type
!= bp_none
5865 && b
->next
->type
!= bp_watchpoint
5866 && b
->next
->type
!= bp_hardware_watchpoint
5867 && b
->next
->type
!= bp_read_watchpoint
5868 && b
->next
->type
!= bp_access_watchpoint
5869 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
5870 (overlay_debugging
== 0 ||
5871 b
->next
->section
== sal
.section
))
5872 || ((default_match
|| (0 == sal
.pc
))
5873 && b
->next
->source_file
!= NULL
5874 && sal
.symtab
!= NULL
5875 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
5876 && b
->next
->line_number
== sal
.line
)))
5889 error ("No breakpoint at %s.", arg
);
5891 error ("No breakpoint at this line.");
5895 from_tty
= 1; /* Always report if deleted more than one */
5897 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
5898 breakpoints_changed ();
5902 printf_unfiltered ("%d ", found
->number
);
5904 delete_breakpoint (found
);
5908 putchar_unfiltered ('\n');
5910 free ((PTR
) sals
.sals
);
5913 /* Delete breakpoint in BS if they are `delete' breakpoints and
5914 all breakpoints that are marked for deletion, whether hit or not.
5915 This is called after any breakpoint is hit, or after errors. */
5918 breakpoint_auto_delete (bs
)
5921 struct breakpoint
*b
, *temp
;
5923 for (; bs
; bs
= bs
->next
)
5924 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
5926 delete_breakpoint (bs
->breakpoint_at
);
5928 ALL_BREAKPOINTS_SAFE (b
, temp
)
5930 if (b
->disposition
== del_at_next_stop
)
5931 delete_breakpoint (b
);
5935 /* Delete a breakpoint and clean up all traces of it in the data
5939 delete_breakpoint (bpt
)
5940 struct breakpoint
*bpt
;
5942 register struct breakpoint
*b
;
5946 error ("Internal error (attempted to delete a NULL breakpoint)");
5949 /* Has this bp already been deleted? This can happen because multiple
5950 lists can hold pointers to bp's. bpstat lists are especial culprits.
5952 One example of this happening is a watchpoint's scope bp. When the
5953 scope bp triggers, we notice that the watchpoint is out of scope, and
5954 delete it. We also delete its scope bp. But the scope bp is marked
5955 "auto-deleting", and is already on a bpstat. That bpstat is then
5956 checked for auto-deleting bp's, which are deleted.
5958 A real solution to this problem might involve reference counts in bp's,
5959 and/or giving them pointers back to their referencing bpstat's, and
5960 teaching delete_breakpoint to only free a bp's storage when no more
5961 references were extent. A cheaper bandaid was chosen. */
5962 if (bpt
->type
== bp_none
)
5965 if (delete_breakpoint_hook
)
5966 delete_breakpoint_hook (bpt
);
5967 breakpoint_delete_event (bpt
->number
);
5970 remove_breakpoint (bpt
, mark_uninserted
);
5972 if (breakpoint_chain
== bpt
)
5973 breakpoint_chain
= bpt
->next
;
5975 /* If we have callback-style exception catchpoints, don't go through
5976 the adjustments to the C++ runtime library etc. if the inferior
5977 isn't actually running. target_enable_exception_callback for a
5978 null target ops vector gives an undesirable error message, so we
5979 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5980 exceptions are supported in this way, it's OK for now. FIXME */
5981 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
5983 static char message1
[] = "Error in deleting catchpoint %d:\n";
5984 static char message
[sizeof (message1
) + 30];
5985 args_for_catchpoint_enable args
;
5987 /* Format possible error msg */
5988 sprintf (message
, message1
, bpt
->number
);
5989 args
.kind
= bpt
->type
== bp_catch_catch
?
5990 EX_EVENT_CATCH
: EX_EVENT_THROW
;
5992 catch_errors (cover_target_enable_exception_callback
, &args
,
5993 message
, RETURN_MASK_ALL
);
6000 b
->next
= bpt
->next
;
6004 /* Before turning off the visuals for the bp, check to see that
6005 there are no other bps at the same address. */
6012 clearIt
= (b
->address
!= bpt
->address
);
6019 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
6020 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
6024 check_duplicates (bpt
->address
, bpt
->section
);
6025 /* If this breakpoint was inserted, and there is another breakpoint
6026 at the same address, we need to insert the other breakpoint. */
6028 && bpt
->type
!= bp_hardware_watchpoint
6029 && bpt
->type
!= bp_read_watchpoint
6030 && bpt
->type
!= bp_access_watchpoint
6031 && bpt
->type
!= bp_catch_fork
6032 && bpt
->type
!= bp_catch_vfork
6033 && bpt
->type
!= bp_catch_exec
)
6036 if (b
->address
== bpt
->address
6037 && b
->section
== bpt
->section
6039 && b
->enable
!= disabled
6040 && b
->enable
!= shlib_disabled
6041 && b
->enable
!= call_disabled
)
6045 /* We should never reach this point if there is a permanent
6046 breakpoint at the same address as the one being deleted.
6047 If there is a permanent breakpoint somewhere, it should
6048 always be the only one inserted. */
6049 if (b
->enable
== permanent
)
6050 internal_error ("another breakpoint was inserted on top of "
6051 "a permanent breakpoint");
6053 if (b
->type
== bp_hardware_breakpoint
)
6054 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6056 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6060 target_terminal_ours_for_output ();
6061 warning ("Cannot insert breakpoint %d:", b
->number
);
6062 memory_error (val
, b
->address
); /* which bombs us out */
6069 free_command_lines (&bpt
->commands
);
6072 if (bpt
->cond_string
!= NULL
)
6073 free (bpt
->cond_string
);
6074 if (bpt
->addr_string
!= NULL
)
6075 free (bpt
->addr_string
);
6076 if (bpt
->exp
!= NULL
)
6078 if (bpt
->exp_string
!= NULL
)
6079 free (bpt
->exp_string
);
6080 if (bpt
->val
!= NULL
)
6081 value_free (bpt
->val
);
6082 if (bpt
->source_file
!= NULL
)
6083 free (bpt
->source_file
);
6084 if (bpt
->dll_pathname
!= NULL
)
6085 free (bpt
->dll_pathname
);
6086 if (bpt
->triggered_dll_pathname
!= NULL
)
6087 free (bpt
->triggered_dll_pathname
);
6088 if (bpt
->exec_pathname
!= NULL
)
6089 free (bpt
->exec_pathname
);
6091 /* Be sure no bpstat's are pointing at it after it's been freed. */
6092 /* FIXME, how can we find all bpstat's?
6093 We just check stop_bpstat for now. */
6094 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6095 if (bs
->breakpoint_at
== bpt
)
6097 bs
->breakpoint_at
= NULL
;
6099 /* we'd call bpstat_clear_actions, but that free's stuff and due
6100 to the multiple pointers pointing to one item with no
6101 reference counts found anywhere through out the bpstat's (how
6102 do you spell fragile?), we don't want to free things twice --
6103 better a memory leak than a corrupt malloc pool! */
6104 bs
->commands
= NULL
;
6107 /* On the chance that someone will soon try again to delete this same
6108 bp, we mark it as deleted before freeing its storage. */
6109 bpt
->type
= bp_none
;
6115 delete_command (arg
, from_tty
)
6119 struct breakpoint
*b
, *temp
;
6123 int breaks_to_delete
= 0;
6125 /* Delete all breakpoints if no argument.
6126 Do not delete internal or call-dummy breakpoints, these
6127 have to be deleted with an explicit breakpoint number argument. */
6130 if (b
->type
!= bp_call_dummy
&&
6131 b
->type
!= bp_shlib_event
&&
6133 breaks_to_delete
= 1;
6136 /* Ask user only if there are some breakpoints to delete. */
6138 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6140 ALL_BREAKPOINTS_SAFE (b
, temp
)
6142 if (b
->type
!= bp_call_dummy
&&
6143 b
->type
!= bp_shlib_event
&&
6145 delete_breakpoint (b
);
6150 map_breakpoint_numbers (arg
, delete_breakpoint
);
6153 /* Reset a breakpoint given it's struct breakpoint * BINT.
6154 The value we return ends up being the return value from catch_errors.
6155 Unused in this case. */
6158 breakpoint_re_set_one (bint
)
6161 /* get past catch_errs */
6162 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6165 struct symtabs_and_lines sals
;
6167 enum enable save_enable
;
6172 warning ("attempted to reset apparently deleted breakpoint #%d?",
6176 case bp_hardware_breakpoint
:
6178 case bp_catch_unload
:
6179 if (b
->addr_string
== NULL
)
6181 /* Anything without a string can't be re-set. */
6182 delete_breakpoint (b
);
6185 /* In case we have a problem, disable this breakpoint. We'll restore
6186 its status if we succeed. */
6187 save_enable
= b
->enable
;
6188 b
->enable
= disabled
;
6190 set_language (b
->language
);
6191 input_radix
= b
->input_radix
;
6193 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
6194 for (i
= 0; i
< sals
.nelts
; i
++)
6196 resolve_sal_pc (&sals
.sals
[i
]);
6198 /* Reparse conditions, they might contain references to the
6200 if (b
->cond_string
!= NULL
)
6204 free ((PTR
) b
->cond
);
6205 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
6208 /* We need to re-set the breakpoint if the address changes... */
6209 if (b
->address
!= sals
.sals
[i
].pc
6210 /* ...or new and old breakpoints both have source files, and
6211 the source file name or the line number changes... */
6212 || (b
->source_file
!= NULL
6213 && sals
.sals
[i
].symtab
!= NULL
6214 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
6215 || b
->line_number
!= sals
.sals
[i
].line
)
6217 /* ...or we switch between having a source file and not having
6219 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
6222 if (b
->source_file
!= NULL
)
6223 free (b
->source_file
);
6224 if (sals
.sals
[i
].symtab
== NULL
)
6225 b
->source_file
= NULL
;
6228 savestring (sals
.sals
[i
].symtab
->filename
,
6229 strlen (sals
.sals
[i
].symtab
->filename
));
6230 b
->line_number
= sals
.sals
[i
].line
;
6231 b
->address
= sals
.sals
[i
].pc
;
6233 /* Used to check for duplicates here, but that can
6234 cause trouble, as it doesn't check for disable
6239 /* Might be better to do this just once per breakpoint_re_set,
6240 rather than once for every breakpoint. */
6241 breakpoints_changed ();
6243 b
->section
= sals
.sals
[i
].section
;
6244 b
->enable
= save_enable
; /* Restore it, this worked. */
6247 /* Now that this is re-enabled, check_duplicates
6249 check_duplicates (b
->address
, b
->section
);
6252 free ((PTR
) sals
.sals
);
6256 case bp_hardware_watchpoint
:
6257 case bp_read_watchpoint
:
6258 case bp_access_watchpoint
:
6259 innermost_block
= NULL
;
6260 /* The issue arises of what context to evaluate this in. The
6261 same one as when it was set, but what does that mean when
6262 symbols have been re-read? We could save the filename and
6263 functionname, but if the context is more local than that, the
6264 best we could do would be something like how many levels deep
6265 and which index at that particular level, but that's going to
6266 be less stable than filenames or function names. */
6268 /* So for now, just use a global context. */
6270 free ((PTR
) b
->exp
);
6271 b
->exp
= parse_expression (b
->exp_string
);
6272 b
->exp_valid_block
= innermost_block
;
6273 mark
= value_mark ();
6275 value_free (b
->val
);
6276 b
->val
= evaluate_expression (b
->exp
);
6277 release_value (b
->val
);
6278 if (VALUE_LAZY (b
->val
))
6279 value_fetch_lazy (b
->val
);
6281 if (b
->cond_string
!= NULL
)
6285 free ((PTR
) b
->cond
);
6286 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
6288 if (b
->enable
== enabled
)
6290 value_free_to_mark (mark
);
6292 case bp_catch_catch
:
6293 case bp_catch_throw
:
6295 /* We needn't really do anything to reset these, since the mask
6296 that requests them is unaffected by e.g., new libraries being
6299 case bp_catch_vfork
:
6304 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
6306 /* Delete longjmp breakpoints, they will be reset later by
6307 breakpoint_re_set. */
6309 case bp_longjmp_resume
:
6310 delete_breakpoint (b
);
6313 /* This breakpoint is special, it's set up when the inferior
6314 starts and we really don't want to touch it. */
6315 case bp_shlib_event
:
6317 /* Keep temporary breakpoints, which can be encountered when we step
6318 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6319 Otherwise these should have been blown away via the cleanup chain
6320 or by breakpoint_init_inferior when we rerun the executable. */
6323 case bp_watchpoint_scope
:
6325 case bp_step_resume
:
6332 /* Re-set all breakpoints after symbols have been re-loaded. */
6334 breakpoint_re_set ()
6336 struct breakpoint
*b
, *temp
;
6337 enum language save_language
;
6338 int save_input_radix
;
6339 static char message1
[] = "Error in re-setting breakpoint %d:\n";
6340 char message
[sizeof (message1
) + 30 /* slop */ ];
6342 save_language
= current_language
->la_language
;
6343 save_input_radix
= input_radix
;
6344 ALL_BREAKPOINTS_SAFE (b
, temp
)
6346 /* Format possible error msg */
6347 sprintf (message
, message1
, b
->number
);
6348 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
6350 set_language (save_language
);
6351 input_radix
= save_input_radix
;
6353 #ifdef GET_LONGJMP_TARGET
6354 create_longjmp_breakpoint ("longjmp");
6355 create_longjmp_breakpoint ("_longjmp");
6356 create_longjmp_breakpoint ("siglongjmp");
6357 create_longjmp_breakpoint ("_siglongjmp");
6358 create_longjmp_breakpoint (NULL
);
6362 /* Took this out (temporarily at least), since it produces an extra
6363 blank line at startup. This messes up the gdbtests. -PB */
6364 /* Blank line to finish off all those mention() messages we just printed. */
6365 printf_filtered ("\n");
6369 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6370 If from_tty is nonzero, it prints a message to that effect,
6371 which ends with a period (no newline). */
6373 /* Reset the thread number of this breakpoint:
6375 - If the breakpoint is for all threads, leave it as-is.
6376 - Else, reset it to the current thread for inferior_pid. */
6378 breakpoint_re_set_thread (b
)
6379 struct breakpoint
*b
;
6381 if (b
->thread
!= -1)
6383 if (in_thread_list (inferior_pid
))
6384 b
->thread
= pid_to_thread_id (inferior_pid
);
6389 set_ignore_count (bptnum
, count
, from_tty
)
6390 int bptnum
, count
, from_tty
;
6392 register struct breakpoint
*b
;
6398 if (b
->number
== bptnum
)
6400 b
->ignore_count
= count
;
6403 else if (count
== 0)
6404 printf_filtered ("Will stop next time breakpoint %d is reached.",
6406 else if (count
== 1)
6407 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6410 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6412 breakpoints_changed ();
6416 error ("No breakpoint number %d.", bptnum
);
6419 /* Clear the ignore counts of all breakpoints. */
6421 breakpoint_clear_ignore_counts ()
6423 struct breakpoint
*b
;
6426 b
->ignore_count
= 0;
6429 /* Command to set ignore-count of breakpoint N to COUNT. */
6432 ignore_command (args
, from_tty
)
6440 error_no_arg ("a breakpoint number");
6442 num
= get_number (&p
);
6445 error ("Second argument (specified ignore-count) is missing.");
6447 set_ignore_count (num
,
6448 longest_to_int (value_as_long (parse_and_eval (p
))),
6450 printf_filtered ("\n");
6451 breakpoints_changed ();
6454 /* Call FUNCTION on each of the breakpoints
6455 whose numbers are given in ARGS. */
6458 map_breakpoint_numbers (args
, function
)
6460 void (*function
) PARAMS ((struct breakpoint
*));
6462 register char *p
= args
;
6465 register struct breakpoint
*b
;
6468 error_no_arg ("one or more breakpoint numbers");
6474 num
= get_number (&p1
);
6477 if (b
->number
== num
)
6479 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
6481 if (related_breakpoint
)
6482 function (related_breakpoint
);
6485 printf_unfiltered ("No breakpoint number %d.\n", num
);
6492 disable_breakpoint (bpt
)
6493 struct breakpoint
*bpt
;
6495 /* Never disable a watchpoint scope breakpoint; we want to
6496 hit them when we leave scope so we can delete both the
6497 watchpoint and its scope breakpoint at that time. */
6498 if (bpt
->type
== bp_watchpoint_scope
)
6501 /* You can't disable permanent breakpoints. */
6502 if (bpt
->enable
== permanent
)
6505 bpt
->enable
= disabled
;
6507 check_duplicates (bpt
->address
, bpt
->section
);
6509 if (modify_breakpoint_hook
)
6510 modify_breakpoint_hook (bpt
);
6511 breakpoint_modify_event (bpt
->number
);
6516 disable_command (args
, from_tty
)
6520 register struct breakpoint
*bpt
;
6522 ALL_BREAKPOINTS (bpt
)
6526 warning ("attempted to disable apparently deleted breakpoint #%d?",
6531 case bp_catch_unload
:
6533 case bp_catch_vfork
:
6535 case bp_catch_catch
:
6536 case bp_catch_throw
:
6537 case bp_hardware_breakpoint
:
6539 case bp_hardware_watchpoint
:
6540 case bp_read_watchpoint
:
6541 case bp_access_watchpoint
:
6542 disable_breakpoint (bpt
);
6547 map_breakpoint_numbers (args
, disable_breakpoint
);
6551 do_enable_breakpoint (bpt
, disposition
)
6552 struct breakpoint
*bpt
;
6553 enum bpdisp disposition
;
6555 struct frame_info
*save_selected_frame
= NULL
;
6556 int save_selected_frame_level
= -1;
6557 int target_resources_ok
, other_type_used
;
6560 if (bpt
->type
== bp_hardware_breakpoint
)
6563 i
= hw_breakpoint_used_count ();
6564 target_resources_ok
=
6565 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
6567 if (target_resources_ok
== 0)
6568 error ("No hardware breakpoint support in the target.");
6569 else if (target_resources_ok
< 0)
6570 error ("Hardware breakpoints used exceeds limit.");
6573 if (bpt
->enable
!= permanent
)
6574 bpt
->enable
= enabled
;
6575 bpt
->disposition
= disposition
;
6576 check_duplicates (bpt
->address
, bpt
->section
);
6577 breakpoints_changed ();
6579 if (bpt
->type
== bp_watchpoint
||
6580 bpt
->type
== bp_hardware_watchpoint
||
6581 bpt
->type
== bp_read_watchpoint
||
6582 bpt
->type
== bp_access_watchpoint
)
6584 if (bpt
->exp_valid_block
!= NULL
)
6586 struct frame_info
*fr
=
6588 /* Ensure that we have the current frame. Else, this
6589 next query may pessimistically be answered as, "No,
6590 not within current scope". */
6591 get_current_frame ();
6592 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
6596 Cannot enable watchpoint %d because the block in which its expression\n\
6597 is valid is not currently in scope.\n", bpt
->number
);
6598 bpt
->enable
= disabled
;
6602 save_selected_frame
= selected_frame
;
6603 save_selected_frame_level
= selected_frame_level
;
6604 select_frame (fr
, -1);
6607 value_free (bpt
->val
);
6608 mark
= value_mark ();
6609 bpt
->val
= evaluate_expression (bpt
->exp
);
6610 release_value (bpt
->val
);
6611 if (VALUE_LAZY (bpt
->val
))
6612 value_fetch_lazy (bpt
->val
);
6614 if (bpt
->type
== bp_hardware_watchpoint
||
6615 bpt
->type
== bp_read_watchpoint
||
6616 bpt
->type
== bp_access_watchpoint
)
6618 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
6619 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
6621 /* Hack around 'unused var' error for some targets here */
6623 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6624 bpt
->type
, i
+ mem_cnt
, other_type_used
);
6625 /* we can consider of type is bp_hardware_watchpoint, convert to
6626 bp_watchpoint in the following condition */
6627 if (target_resources_ok
< 0)
6630 Cannot enable watchpoint %d because target watch resources\n\
6631 have been allocated for other watchpoints.\n", bpt
->number
);
6632 bpt
->enable
= disabled
;
6633 value_free_to_mark (mark
);
6638 if (save_selected_frame_level
>= 0)
6639 select_and_print_frame (save_selected_frame
,
6640 save_selected_frame_level
);
6641 value_free_to_mark (mark
);
6643 if (modify_breakpoint_hook
)
6644 modify_breakpoint_hook (bpt
);
6645 breakpoint_modify_event (bpt
->number
);
6649 enable_breakpoint (bpt
)
6650 struct breakpoint
*bpt
;
6652 do_enable_breakpoint (bpt
, bpt
->disposition
);
6655 /* The enable command enables the specified breakpoints (or all defined
6656 breakpoints) so they once again become (or continue to be) effective
6657 in stopping the inferior. */
6661 enable_command (args
, from_tty
)
6665 register struct breakpoint
*bpt
;
6667 ALL_BREAKPOINTS (bpt
)
6671 warning ("attempted to enable apparently deleted breakpoint #%d?",
6676 case bp_catch_unload
:
6678 case bp_catch_vfork
:
6680 case bp_catch_catch
:
6681 case bp_catch_throw
:
6682 case bp_hardware_breakpoint
:
6684 case bp_hardware_watchpoint
:
6685 case bp_read_watchpoint
:
6686 case bp_access_watchpoint
:
6687 enable_breakpoint (bpt
);
6692 map_breakpoint_numbers (args
, enable_breakpoint
);
6696 enable_once_breakpoint (bpt
)
6697 struct breakpoint
*bpt
;
6699 do_enable_breakpoint (bpt
, disable
);
6704 enable_once_command (args
, from_tty
)
6708 map_breakpoint_numbers (args
, enable_once_breakpoint
);
6712 enable_delete_breakpoint (bpt
)
6713 struct breakpoint
*bpt
;
6715 do_enable_breakpoint (bpt
, del
);
6720 enable_delete_command (args
, from_tty
)
6724 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
6727 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6729 struct symtabs_and_lines
6730 decode_line_spec_1 (string
, funfirstline
)
6734 struct symtabs_and_lines sals
;
6736 error ("Empty line specification.");
6737 if (default_breakpoint_valid
)
6738 sals
= decode_line_1 (&string
, funfirstline
,
6739 default_breakpoint_symtab
,
6740 default_breakpoint_line
,
6743 sals
= decode_line_1 (&string
, funfirstline
,
6744 (struct symtab
*) NULL
, 0, (char ***) NULL
);
6746 error ("Junk at end of line specification: %s", string
);
6751 _initialize_breakpoint ()
6753 struct cmd_list_element
*c
;
6755 breakpoint_chain
= 0;
6756 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6757 before a breakpoint is set. */
6758 breakpoint_count
= 0;
6760 add_com ("ignore", class_breakpoint
, ignore_command
,
6761 "Set ignore-count of breakpoint number N to COUNT.\n\
6762 Usage is `ignore N COUNT'.");
6764 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
6766 add_com ("commands", class_breakpoint
, commands_command
,
6767 "Set commands to be executed when a breakpoint is hit.\n\
6768 Give breakpoint number as argument after \"commands\".\n\
6769 With no argument, the targeted breakpoint is the last one set.\n\
6770 The commands themselves follow starting on the next line.\n\
6771 Type a line containing \"end\" to indicate the end of them.\n\
6772 Give \"silent\" as the first line to make the breakpoint silent;\n\
6773 then no output is printed when it is hit, except what the commands print.");
6775 add_com ("condition", class_breakpoint
, condition_command
,
6776 "Specify breakpoint number N to break only if COND is true.\n\
6777 Usage is `condition N COND', where N is an integer and COND is an\n\
6778 expression to be evaluated whenever breakpoint N is reached. ");
6780 add_com ("tbreak", class_breakpoint
, tbreak_command
,
6781 "Set a temporary breakpoint. Args like \"break\" command.\n\
6782 Like \"break\" except the breakpoint is only temporary,\n\
6783 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6784 by using \"enable delete\" on the breakpoint number.");
6785 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
6786 "Set temporary breakpoint at procedure exit. Either there should\n\
6787 be no argument or the argument must be a depth.\n");
6789 add_com ("hbreak", class_breakpoint
, hbreak_command
,
6790 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6791 Like \"break\" except the breakpoint requires hardware support,\n\
6792 some target hardware may not have this support.");
6794 add_com ("thbreak", class_breakpoint
, thbreak_command
,
6795 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6796 Like \"hbreak\" except the breakpoint is only temporary,\n\
6797 so it will be deleted when hit.");
6799 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
6800 "Enable some breakpoints.\n\
6801 Give breakpoint numbers (separated by spaces) as arguments.\n\
6802 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6803 This is used to cancel the effect of the \"disable\" command.\n\
6804 With a subcommand you can enable temporarily.",
6805 &enablelist
, "enable ", 1, &cmdlist
);
6807 add_com ("ab", class_breakpoint
, enable_command
,
6808 "Enable some breakpoints.\n\
6809 Give breakpoint numbers (separated by spaces) as arguments.\n\
6810 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6811 This is used to cancel the effect of the \"disable\" command.\n\
6812 With a subcommand you can enable temporarily.");
6814 add_com_alias ("en", "enable", class_breakpoint
, 1);
6816 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
6817 "Enable some breakpoints.\n\
6818 Give breakpoint numbers (separated by spaces) as arguments.\n\
6819 This is used to cancel the effect of the \"disable\" command.\n\
6820 May be abbreviated to simply \"enable\".\n",
6821 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
6823 add_cmd ("once", no_class
, enable_once_command
,
6824 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6825 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6828 add_cmd ("delete", no_class
, enable_delete_command
,
6829 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6830 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6833 add_cmd ("delete", no_class
, enable_delete_command
,
6834 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6835 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6838 add_cmd ("once", no_class
, enable_once_command
,
6839 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6840 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6843 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
6844 "Disable some breakpoints.\n\
6845 Arguments are breakpoint numbers with spaces in between.\n\
6846 To disable all breakpoints, give no argument.\n\
6847 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6848 &disablelist
, "disable ", 1, &cmdlist
);
6849 add_com_alias ("dis", "disable", class_breakpoint
, 1);
6850 add_com_alias ("disa", "disable", class_breakpoint
, 1);
6852 add_com ("sb", class_breakpoint
, disable_command
,
6853 "Disable some breakpoints.\n\
6854 Arguments are breakpoint numbers with spaces in between.\n\
6855 To disable all breakpoints, give no argument.\n\
6856 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6858 add_cmd ("breakpoints", class_alias
, disable_command
,
6859 "Disable some breakpoints.\n\
6860 Arguments are breakpoint numbers with spaces in between.\n\
6861 To disable all breakpoints, give no argument.\n\
6862 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6863 This command may be abbreviated \"disable\".",
6866 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
6867 "Delete some breakpoints or auto-display expressions.\n\
6868 Arguments are breakpoint numbers with spaces in between.\n\
6869 To delete all breakpoints, give no argument.\n\
6871 Also a prefix command for deletion of other GDB objects.\n\
6872 The \"unset\" command is also an alias for \"delete\".",
6873 &deletelist
, "delete ", 1, &cmdlist
);
6874 add_com_alias ("d", "delete", class_breakpoint
, 1);
6876 add_com ("db", class_breakpoint
, delete_command
,
6877 "Delete some breakpoints.\n\
6878 Arguments are breakpoint numbers with spaces in between.\n\
6879 To delete all breakpoints, give no argument.\n");
6881 add_cmd ("breakpoints", class_alias
, delete_command
,
6882 "Delete some breakpoints or auto-display expressions.\n\
6883 Arguments are breakpoint numbers with spaces in between.\n\
6884 To delete all breakpoints, give no argument.\n\
6885 This command may be abbreviated \"delete\".",
6888 add_com ("clear", class_breakpoint
, clear_command
,
6889 concat ("Clear breakpoint at specified line or function.\n\
6890 Argument may be line number, function name, or \"*\" and an address.\n\
6891 If line number is specified, all breakpoints in that line are cleared.\n\
6892 If function is specified, breakpoints at beginning of function are cleared.\n\
6893 If an address is specified, breakpoints at that address are cleared.\n\n",
6894 "With no argument, clears all breakpoints in the line that the selected frame\n\
6897 See also the \"delete\" command which clears breakpoints by number.", NULL
));
6899 add_com ("break", class_breakpoint
, break_command
,
6900 concat ("Set breakpoint at specified line or function.\n\
6901 Argument may be line number, function name, or \"*\" and an address.\n\
6902 If line number is specified, break at start of code for that line.\n\
6903 If function is specified, break at start of code for that function.\n\
6904 If an address is specified, break at that exact address.\n",
6905 "With no arg, uses current execution address of selected stack frame.\n\
6906 This is useful for breaking on return to a stack frame.\n\
6908 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6910 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6911 add_com_alias ("b", "break", class_run
, 1);
6912 add_com_alias ("br", "break", class_run
, 1);
6913 add_com_alias ("bre", "break", class_run
, 1);
6914 add_com_alias ("brea", "break", class_run
, 1);
6916 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
6917 concat ("Set breakpoint at procedure exit. \n\
6918 Argument may be function name, or \"*\" and an address.\n\
6919 If function is specified, break at end of code for that function.\n\
6920 If an address is specified, break at the end of the function that contains \n\
6921 that exact address.\n",
6922 "With no arg, uses current execution address of selected stack frame.\n\
6923 This is useful for breaking on return to a stack frame.\n\
6925 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6927 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6928 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
6929 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
6930 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
6931 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
6935 add_com_alias ("ba", "break", class_breakpoint
, 1);
6936 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
6937 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
6938 "Set breakpoint at procedure exit. Either there should\n\
6939 be no argument or the argument must be a depth.\n");
6944 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
6945 "Break in function/address or break at a line in the current file.",
6946 &stoplist
, "stop ", 1, &cmdlist
);
6947 add_cmd ("in", class_breakpoint
, stopin_command
,
6948 "Break in function or address.\n", &stoplist
);
6949 add_cmd ("at", class_breakpoint
, stopat_command
,
6950 "Break at a line in the current file.\n", &stoplist
);
6951 add_com ("status", class_info
, breakpoints_info
,
6952 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6953 The \"Type\" column indicates one of:\n\
6954 \tbreakpoint - normal breakpoint\n\
6955 \twatchpoint - watchpoint\n\
6956 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6957 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6958 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6959 address and file/line number respectively.\n\n",
6960 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6961 are set to the address of the last breakpoint listed.\n\n\
6962 Convenience variable \"$bpnum\" contains the number of the last\n\
6963 breakpoint set.", NULL
));
6966 add_info ("breakpoints", breakpoints_info
,
6967 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6968 The \"Type\" column indicates one of:\n\
6969 \tbreakpoint - normal breakpoint\n\
6970 \twatchpoint - watchpoint\n\
6971 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6972 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6973 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6974 address and file/line number respectively.\n\n",
6975 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6976 are set to the address of the last breakpoint listed.\n\n\
6977 Convenience variable \"$bpnum\" contains the number of the last\n\
6978 breakpoint set.", NULL
));
6981 add_com ("lb", class_breakpoint
, breakpoints_info
,
6982 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6983 The \"Type\" column indicates one of:\n\
6984 \tbreakpoint - normal breakpoint\n\
6985 \twatchpoint - watchpoint\n\
6986 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6987 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6988 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6989 address and file/line number respectively.\n\n",
6990 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6991 are set to the address of the last breakpoint listed.\n\n\
6992 Convenience variable \"$bpnum\" contains the number of the last\n\
6993 breakpoint set.", NULL
));
6995 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
6996 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6997 The \"Type\" column indicates one of:\n\
6998 \tbreakpoint - normal breakpoint\n\
6999 \twatchpoint - watchpoint\n\
7000 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7001 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7002 \tuntil - internal breakpoint used by the \"until\" command\n\
7003 \tfinish - internal breakpoint used by the \"finish\" command\n",
7004 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7005 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7006 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7007 address and file/line number respectively.\n\n",
7008 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7009 are set to the address of the last breakpoint listed.\n\n\
7010 Convenience variable \"$bpnum\" contains the number of the last\n\
7011 breakpoint set.", NULL
),
7012 &maintenanceinfolist
);
7014 add_com ("catch", class_breakpoint
, catch_command
,
7015 "Set catchpoints to catch events.\n\
7016 Raised signals may be caught:\n\
7017 \tcatch signal - all signals\n\
7018 \tcatch signal <signame> - a particular signal\n\
7019 Raised exceptions may be caught:\n\
7020 \tcatch throw - all exceptions, when thrown\n\
7021 \tcatch throw <exceptname> - a particular exception, when thrown\n\
7022 \tcatch catch - all exceptions, when caught\n\
7023 \tcatch catch <exceptname> - a particular exception, when caught\n\
7024 Thread or process events may be caught:\n\
7025 \tcatch thread_start - any threads, just after creation\n\
7026 \tcatch thread_exit - any threads, just before expiration\n\
7027 \tcatch thread_join - any threads, just after joins\n\
7028 Process events may be caught:\n\
7029 \tcatch start - any processes, just after creation\n\
7030 \tcatch exit - any processes, just before expiration\n\
7031 \tcatch fork - calls to fork()\n\
7032 \tcatch vfork - calls to vfork()\n\
7033 \tcatch exec - calls to exec()\n\
7034 Dynamically-linked library events may be caught:\n\
7035 \tcatch load - loads of any library\n\
7036 \tcatch load <libname> - loads of a particular library\n\
7037 \tcatch unload - unloads of any library\n\
7038 \tcatch unload <libname> - unloads of a particular library\n\
7039 The act of your program's execution stopping may also be caught:\n\
7041 C++ exceptions may be caught:\n\
7042 \tcatch throw - all exceptions, when thrown\n\
7043 \tcatch catch - all exceptions, when caught\n\
7045 Do \"help set follow-fork-mode\" for info on debugging your program\n\
7046 after a fork or vfork is caught.\n\n\
7047 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
7049 add_com ("tcatch", class_breakpoint
, tcatch_command
,
7050 "Set temporary catchpoints to catch events.\n\
7051 Args like \"catch\" command.\n\
7052 Like \"catch\" except the catchpoint is only temporary,\n\
7053 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7054 by using \"enable delete\" on the catchpoint number.");
7056 add_com ("watch", class_breakpoint
, watch_command
,
7057 "Set a watchpoint for an expression.\n\
7058 A watchpoint stops execution of your program whenever the value of\n\
7059 an expression changes.");
7061 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7062 "Set a read watchpoint for an expression.\n\
7063 A watchpoint stops execution of your program whenever the value of\n\
7064 an expression is read.");
7066 add_com ("awatch", class_breakpoint
, awatch_command
,
7067 "Set a watchpoint for an expression.\n\
7068 A watchpoint stops execution of your program whenever the value of\n\
7069 an expression is either read or written.");
7071 add_info ("watchpoints", breakpoints_info
,
7072 "Synonym for ``info breakpoints''.");
7075 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7076 (char *) &can_use_hw_watchpoints
,
7077 "Set debugger's willingness to use watchpoint hardware.\n\
7078 If zero, gdb will not use hardware for new watchpoints, even if\n\
7079 such is available. (However, any hardware watchpoints that were\n\
7080 created before setting this to nonzero, will continue to use watchpoint\n\
7083 add_show_from_set (c
, &showlist
);
7085 can_use_hw_watchpoints
= 1;