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 int print_it_normal
PARAMS ((bpstat
));
164 enum exception_event_kind kind
;
167 args_for_catchpoint_enable
;
169 static int watchpoint_check
PARAMS ((PTR
));
171 static int cover_target_enable_exception_callback
PARAMS ((PTR
));
173 static int print_it_done
PARAMS ((bpstat
));
175 static int print_it_noop
PARAMS ((bpstat
));
177 static void maintenance_info_breakpoints
PARAMS ((char *, int));
179 #ifdef GET_LONGJMP_TARGET
180 static void create_longjmp_breakpoint
PARAMS ((char *));
183 static int hw_breakpoint_used_count
PARAMS ((void));
185 static int hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
187 static void hbreak_command
PARAMS ((char *, int));
189 static void thbreak_command
PARAMS ((char *, int));
191 static void watch_command_1
PARAMS ((char *, int, int));
193 static void rwatch_command
PARAMS ((char *, int));
195 static void awatch_command
PARAMS ((char *, int));
197 static void do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
199 static void solib_load_unload_1
PARAMS ((char *hookname
,
203 enum bptype bp_kind
));
205 static void create_fork_vfork_event_catchpoint
PARAMS ((int tempflag
,
207 enum bptype bp_kind
));
209 static void break_at_finish_at_depth_command_1
PARAMS ((char *arg
,
213 static void break_at_finish_command_1
PARAMS ((char *arg
,
217 static void stop_command
PARAMS ((char *arg
, int from_tty
));
219 static void stopin_command
PARAMS ((char *arg
, int from_tty
));
221 static void stopat_command
PARAMS ((char *arg
, int from_tty
));
223 static char *ep_find_event_name_end
PARAMS ((char *arg
));
225 static char *ep_parse_optional_if_clause
PARAMS ((char **arg
));
227 static char *ep_parse_optional_filename
PARAMS ((char **arg
));
229 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_it 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 functions.
1747 Current scheme: When we stop, bpstat_print() is called.
1748 It loops through the bpstat list of things causing this stop,
1749 calling the print_it function for each one. The default
1750 print_it function, used for breakpoints, is print_it_normal().
1751 (Also see print_it_noop() and print_it_done()).
1753 Return values from this routine (used by bpstat_print() to
1755 1: Means we printed something, and we do *not* desire that
1756 something to be followed by a location.
1757 0: Means we printed something, and we *do* desire that
1758 something to be followed by a location.
1759 -1: Means we printed nothing. */
1762 print_it_normal (bs
)
1765 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1766 which has since been deleted. */
1767 if (bs
->breakpoint_at
== NULL
1768 || (bs
->breakpoint_at
->type
!= bp_breakpoint
1769 && bs
->breakpoint_at
->type
!= bp_catch_load
1770 && bs
->breakpoint_at
->type
!= bp_catch_unload
1771 && bs
->breakpoint_at
->type
!= bp_catch_fork
1772 && bs
->breakpoint_at
->type
!= bp_catch_vfork
1773 && bs
->breakpoint_at
->type
!= bp_catch_exec
1774 && bs
->breakpoint_at
->type
!= bp_catch_catch
1775 && bs
->breakpoint_at
->type
!= bp_catch_throw
1776 && bs
->breakpoint_at
->type
!= bp_hardware_breakpoint
1777 && bs
->breakpoint_at
->type
!= bp_watchpoint
1778 && bs
->breakpoint_at
->type
!= bp_read_watchpoint
1779 && bs
->breakpoint_at
->type
!= bp_access_watchpoint
1780 && bs
->breakpoint_at
->type
!= bp_hardware_watchpoint
))
1783 if (ep_is_shlib_catchpoint (bs
->breakpoint_at
))
1785 annotate_catchpoint (bs
->breakpoint_at
->number
);
1786 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1787 if (bs
->breakpoint_at
->type
== bp_catch_load
)
1788 printf_filtered ("loaded");
1789 else if (bs
->breakpoint_at
->type
== bp_catch_unload
)
1790 printf_filtered ("unloaded");
1791 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1794 else if (bs
->breakpoint_at
->type
== bp_catch_fork
||
1795 bs
->breakpoint_at
->type
== bp_catch_vfork
)
1797 annotate_catchpoint (bs
->breakpoint_at
->number
);
1798 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1799 if (bs
->breakpoint_at
->type
== bp_catch_fork
)
1800 printf_filtered ("forked");
1801 else if (bs
->breakpoint_at
->type
== bp_catch_vfork
)
1802 printf_filtered ("vforked");
1803 printf_filtered (" process %d), ",
1804 bs
->breakpoint_at
->forked_inferior_pid
);
1807 else if (bs
->breakpoint_at
->type
== bp_catch_exec
)
1809 annotate_catchpoint (bs
->breakpoint_at
->number
);
1810 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1811 bs
->breakpoint_at
->number
,
1812 bs
->breakpoint_at
->exec_pathname
);
1815 else if (bs
->breakpoint_at
->type
== bp_catch_catch
)
1817 if (current_exception_event
&&
1818 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1820 annotate_catchpoint (bs
->breakpoint_at
->number
);
1821 printf_filtered ("\nCatchpoint %d (exception caught), ",
1822 bs
->breakpoint_at
->number
);
1823 printf_filtered ("throw location ");
1824 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1825 printf_filtered ("%s:%d",
1826 CURRENT_EXCEPTION_THROW_FILE
,
1827 CURRENT_EXCEPTION_THROW_LINE
);
1829 printf_filtered ("unknown");
1831 printf_filtered (", catch location ");
1832 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1833 printf_filtered ("%s:%d",
1834 CURRENT_EXCEPTION_CATCH_FILE
,
1835 CURRENT_EXCEPTION_CATCH_LINE
);
1837 printf_filtered ("unknown");
1839 printf_filtered ("\n");
1840 return 1; /* don't bother to print location frame info */
1844 return -1; /* really throw, some other bpstat will handle it */
1847 else if (bs
->breakpoint_at
->type
== bp_catch_throw
)
1849 if (current_exception_event
&&
1850 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
1852 annotate_catchpoint (bs
->breakpoint_at
->number
);
1853 printf_filtered ("\nCatchpoint %d (exception thrown), ",
1854 bs
->breakpoint_at
->number
);
1855 printf_filtered ("throw location ");
1856 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1857 printf_filtered ("%s:%d",
1858 CURRENT_EXCEPTION_THROW_FILE
,
1859 CURRENT_EXCEPTION_THROW_LINE
);
1861 printf_filtered ("unknown");
1863 printf_filtered (", catch location ");
1864 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1865 printf_filtered ("%s:%d",
1866 CURRENT_EXCEPTION_CATCH_FILE
,
1867 CURRENT_EXCEPTION_CATCH_LINE
);
1869 printf_filtered ("unknown");
1871 printf_filtered ("\n");
1872 return 1; /* don't bother to print location frame info */
1876 return -1; /* really catch, some other bpstat willhandle it */
1880 else if (bs
->breakpoint_at
->type
== bp_breakpoint
||
1881 bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
1883 /* I think the user probably only wants to see one breakpoint
1884 number, not all of them. */
1885 annotate_breakpoint (bs
->breakpoint_at
->number
);
1886 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1889 else if ((bs
->old_val
!= NULL
) &&
1890 (bs
->breakpoint_at
->type
== bp_watchpoint
||
1891 bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1892 bs
->breakpoint_at
->type
== bp_hardware_watchpoint
))
1894 annotate_watchpoint (bs
->breakpoint_at
->number
);
1895 mention (bs
->breakpoint_at
);
1896 printf_filtered ("\nOld value = ");
1897 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
1898 printf_filtered ("\nNew value = ");
1899 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1900 Val_pretty_default
);
1901 printf_filtered ("\n");
1902 value_free (bs
->old_val
);
1904 /* More than one watchpoint may have been triggered. */
1907 else if (bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1908 bs
->breakpoint_at
->type
== bp_read_watchpoint
)
1910 mention (bs
->breakpoint_at
);
1911 printf_filtered ("\nValue = ");
1912 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1913 Val_pretty_default
);
1914 printf_filtered ("\n");
1917 /* We can't deal with it.
1918 Maybe another member of the bpstat chain can. */
1922 /* Print a message indicating what happened.
1923 This is called from normal_stop().
1924 The input to this routine is the head of the bpstat list - a list
1925 of the eventpoints that caused this stop.
1926 This routine calls the "print_it" routine(s) associated
1927 with these eventpoints. This will print (for example)
1928 the "Breakpoint n," part of the output.
1929 The return value of this routine is one of:
1931 -1: Means we printed nothing
1932 0: Means we printed something, and expect subsequent
1933 code to print the location. An example is
1934 "Breakpoint 1, " which should be followed by
1936 1 : Means we printed something, but there is no need
1937 to also print the location part of the message.
1938 An example is the catch/throw messages, which
1939 don't require a location appended to the end. */
1950 val
= (*bs
->print_it
) (bs
);
1954 /* Maybe another breakpoint in the chain caused us to stop.
1955 (Currently all watchpoints go on the bpstat whether hit or not.
1956 That probably could (should) be changed, provided care is taken
1957 with respect to bpstat_explains_signal). */
1959 return bpstat_print (bs
->next
);
1961 /* We reached the end of the chain without printing anything. */
1965 /* Evaluate the expression EXP and return 1 if value is zero.
1966 This is used inside a catch_errors to evaluate the breakpoint condition.
1967 The argument is a "struct expression *" that has been cast to char * to
1968 make it pass through catch_errors. */
1971 breakpoint_cond_eval (exp
)
1974 value_ptr mark
= value_mark ();
1975 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
1976 value_free_to_mark (mark
);
1980 /* Allocate a new bpstat and chain it to the current one. */
1983 bpstat_alloc (b
, cbs
)
1984 register struct breakpoint
*b
;
1985 bpstat cbs
; /* Current "bs" value */
1989 bs
= (bpstat
) xmalloc (sizeof (*bs
));
1991 bs
->breakpoint_at
= b
;
1992 /* If the condition is false, etc., don't do the commands. */
1993 bs
->commands
= NULL
;
1995 bs
->print_it
= print_it_normal
;
1999 /* Possible return values for watchpoint_check (this can't be an enum
2000 because of check_errors). */
2001 /* The watchpoint has been deleted. */
2002 #define WP_DELETED 1
2003 /* The value has changed. */
2004 #define WP_VALUE_CHANGED 2
2005 /* The value has not changed. */
2006 #define WP_VALUE_NOT_CHANGED 3
2008 #define BP_TEMPFLAG 1
2009 #define BP_HARDWAREFLAG 2
2011 /* Check watchpoint condition. */
2014 watchpoint_check (p
)
2017 bpstat bs
= (bpstat
) p
;
2018 struct breakpoint
*b
;
2019 struct frame_info
*fr
;
2020 int within_current_scope
;
2022 b
= bs
->breakpoint_at
;
2024 if (b
->exp_valid_block
== NULL
)
2025 within_current_scope
= 1;
2028 /* There is no current frame at this moment. If we're going to have
2029 any chance of handling watchpoints on local variables, we'll need
2030 the frame chain (so we can determine if we're in scope). */
2031 reinit_frame_cache ();
2032 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2033 within_current_scope
= (fr
!= NULL
);
2034 if (within_current_scope
)
2035 /* If we end up stopping, the current frame will get selected
2036 in normal_stop. So this call to select_frame won't affect
2038 select_frame (fr
, -1);
2041 if (within_current_scope
)
2043 /* We use value_{,free_to_}mark because it could be a
2044 *long* time before we return to the command level and
2045 call free_all_values. We can't call free_all_values because
2046 we might be in the middle of evaluating a function call. */
2048 value_ptr mark
= value_mark ();
2049 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2050 if (!value_equal (b
->val
, new_val
))
2052 release_value (new_val
);
2053 value_free_to_mark (mark
);
2054 bs
->old_val
= b
->val
;
2056 /* We will stop here */
2057 return WP_VALUE_CHANGED
;
2061 /* Nothing changed, don't do anything. */
2062 value_free_to_mark (mark
);
2063 /* We won't stop here */
2064 return WP_VALUE_NOT_CHANGED
;
2069 /* This seems like the only logical thing to do because
2070 if we temporarily ignored the watchpoint, then when
2071 we reenter the block in which it is valid it contains
2072 garbage (in the case of a function, it may have two
2073 garbage values, one before and one after the prologue).
2074 So we can't even detect the first assignment to it and
2075 watch after that (since the garbage may or may not equal
2076 the first value assigned). */
2078 Watchpoint %d deleted because the program has left the block in\n\
2079 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2080 if (b
->related_breakpoint
)
2081 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2082 b
->disposition
= del_at_next_stop
;
2088 /* This is used when everything which needs to be printed has
2089 already been printed. But we still want to print the frame. */
2091 /* Background: When we stop, bpstat_print() is called.
2092 It loops through the bpstat list of things causing this stop,
2093 calling the print_it function for each one. The default
2094 print_it function, used for breakpoints, is print_it_normal().
2095 Also see print_it_noop() and print_it_done() are the other
2096 two possibilities. See comments in bpstat_print() and
2097 in header of print_it_normal() for more detail. */
2106 /* This is used when nothing should be printed for this bpstat entry. */
2107 /* Background: When we stop, bpstat_print() is called.
2108 It loops through the bpstat list of things causing this stop,
2109 calling the print_it function for each one. The default
2110 print_it function, used for breakpoints, is print_it_normal().
2111 Also see print_it_noop() and print_it_done() are the other
2112 two possibilities. See comments in bpstat_print() and
2113 in header of print_it_normal() for more detail. */
2122 /* Get a bpstat associated with having just stopped at address *PC
2123 and frame address CORE_ADDRESS. Update *PC to point at the
2124 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2125 if this is known to not be a real breakpoint (it could still be a
2126 watchpoint, though). */
2128 /* Determine whether we stopped at a breakpoint, etc, or whether we
2129 don't understand this stop. Result is a chain of bpstat's such that:
2131 if we don't understand the stop, the result is a null pointer.
2133 if we understand why we stopped, the result is not null.
2135 Each element of the chain refers to a particular breakpoint or
2136 watchpoint at which we have stopped. (We may have stopped for
2137 several reasons concurrently.)
2139 Each element of the chain has valid next, breakpoint_at,
2140 commands, FIXME??? fields. */
2143 bpstat_stop_status (pc
, not_a_breakpoint
)
2145 int not_a_breakpoint
;
2147 register struct breakpoint
*b
, *temp
;
2149 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2150 int real_breakpoint
= 0;
2151 /* Root of the chain of bpstat's */
2152 struct bpstats root_bs
[1];
2153 /* Pointer to the last thing in the chain currently. */
2154 bpstat bs
= root_bs
;
2155 static char message1
[] =
2156 "Error evaluating expression for watchpoint %d\n";
2157 char message
[sizeof (message1
) + 30 /* slop */ ];
2159 /* Get the address where the breakpoint would have been. */
2160 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2161 0 : DECR_PC_AFTER_BREAK
);
2163 ALL_BREAKPOINTS_SAFE (b
, temp
)
2165 if (b
->enable
== disabled
2166 || b
->enable
== shlib_disabled
2167 || b
->enable
== call_disabled
)
2170 if (b
->type
!= bp_watchpoint
2171 && b
->type
!= bp_hardware_watchpoint
2172 && b
->type
!= bp_read_watchpoint
2173 && b
->type
!= bp_access_watchpoint
2174 && b
->type
!= bp_hardware_breakpoint
2175 && b
->type
!= bp_catch_fork
2176 && b
->type
!= bp_catch_vfork
2177 && b
->type
!= bp_catch_exec
2178 && b
->type
!= bp_catch_catch
2179 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2180 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2181 (overlay_debugging
&& /* overlay doesn't match */
2182 section_is_overlay (b
->section
) &&
2183 !section_is_mapped (b
->section
)))
2186 if (b
->type
== bp_hardware_breakpoint
2187 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2190 /* Is this a catchpoint of a load or unload? If so, did we
2191 get a load or unload of the specified library? If not,
2193 if ((b
->type
== bp_catch_load
)
2194 #if defined(SOLIB_HAVE_LOAD_EVENT)
2195 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2196 || ((b
->dll_pathname
!= NULL
)
2197 && (strcmp (b
->dll_pathname
,
2198 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2204 if ((b
->type
== bp_catch_unload
)
2205 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2206 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2207 || ((b
->dll_pathname
!= NULL
)
2208 && (strcmp (b
->dll_pathname
,
2209 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2215 if ((b
->type
== bp_catch_fork
)
2216 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2219 if ((b
->type
== bp_catch_vfork
)
2220 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2223 if ((b
->type
== bp_catch_exec
)
2224 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2227 if (ep_is_exception_catchpoint (b
) &&
2228 !(current_exception_event
= target_get_current_exception_event ()))
2231 /* Come here if it's a watchpoint, or if the break address matches */
2233 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2235 /* Watchpoints may change this, if not found to have triggered. */
2239 sprintf (message
, message1
, b
->number
);
2240 if (b
->type
== bp_watchpoint
||
2241 b
->type
== bp_hardware_watchpoint
)
2243 switch (catch_errors (watchpoint_check
, bs
, message
,
2247 /* We've already printed what needs to be printed. */
2248 bs
->print_it
= print_it_done
;
2251 case WP_VALUE_CHANGED
:
2255 case WP_VALUE_NOT_CHANGED
:
2257 bs
->print_it
= print_it_noop
;
2259 /* Don't consider this a hit. */
2266 /* Error from catch_errors. */
2267 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2268 if (b
->related_breakpoint
)
2269 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2270 b
->disposition
= del_at_next_stop
;
2271 /* We've already printed what needs to be printed. */
2272 bs
->print_it
= print_it_done
;
2278 else if (b
->type
== bp_read_watchpoint
||
2279 b
->type
== bp_access_watchpoint
)
2285 addr
= target_stopped_data_address ();
2288 for (v
= b
->val_chain
; v
; v
= v
->next
)
2290 if (v
->lval
== lval_memory
)
2294 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2295 /* Exact match not required. Within range is sufficient.
2297 if (addr
>= vaddr
&&
2298 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2303 switch (catch_errors (watchpoint_check
, bs
, message
,
2307 /* We've already printed what needs to be printed. */
2308 bs
->print_it
= print_it_done
;
2311 case WP_VALUE_CHANGED
:
2312 case WP_VALUE_NOT_CHANGED
:
2319 /* Error from catch_errors. */
2320 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2321 if (b
->related_breakpoint
)
2322 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2323 b
->disposition
= del_at_next_stop
;
2324 /* We've already printed what needs to be printed. */
2325 bs
->print_it
= print_it_done
;
2328 else /* found == 0 */
2330 /* This is a case where some watchpoint(s) triggered,
2331 but not at the address of this watchpoint (FOUND
2332 was left zero). So don't print anything for this
2334 bs
->print_it
= print_it_noop
;
2341 /* By definition, an encountered breakpoint is a triggered
2345 real_breakpoint
= 1;
2348 if (b
->frame
&& b
->frame
!= (get_current_frame ())->frame
&&
2349 (b
->type
== bp_step_resume
&&
2350 (INNER_THAN (get_current_frame ()->frame
, b
->frame
))))
2354 int value_is_zero
= 0;
2358 /* Need to select the frame, with all that implies
2359 so that the conditions will have the right context. */
2360 select_frame (get_current_frame (), 0);
2362 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2363 "Error in testing breakpoint condition:\n",
2365 /* FIXME-someday, should give breakpoint # */
2368 if (b
->cond
&& value_is_zero
)
2371 /* Don't consider this a hit. */
2374 else if (b
->ignore_count
> 0)
2381 /* We will stop here */
2382 if (b
->disposition
== disable
)
2383 b
->enable
= disabled
;
2384 bs
->commands
= b
->commands
;
2388 (STREQ ("silent", bs
->commands
->line
) ||
2389 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2391 bs
->commands
= bs
->commands
->next
;
2396 /* Print nothing for this entry if we dont stop or if we dont print. */
2397 if (bs
->stop
== 0 || bs
->print
== 0)
2398 bs
->print_it
= print_it_noop
;
2401 bs
->next
= NULL
; /* Terminate the chain */
2402 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2404 if (real_breakpoint
&& bs
)
2406 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2408 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2410 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2416 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2419 #if defined (SHIFT_INST_REGS)
2421 #else /* No SHIFT_INST_REGS. */
2423 #endif /* No SHIFT_INST_REGS. */
2428 /* The value of a hardware watchpoint hasn't changed, but the
2429 intermediate memory locations we are watching may have. */
2430 if (bs
&& !bs
->stop
&&
2431 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2432 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2433 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2435 remove_breakpoints ();
2436 insert_breakpoints ();
2441 /* Tell what to do about this bpstat. */
2446 /* Classify each bpstat as one of the following. */
2449 /* This bpstat element has no effect on the main_action. */
2452 /* There was a watchpoint, stop but don't print. */
2455 /* There was a watchpoint, stop and print. */
2458 /* There was a breakpoint but we're not stopping. */
2461 /* There was a breakpoint, stop but don't print. */
2464 /* There was a breakpoint, stop and print. */
2467 /* We hit the longjmp breakpoint. */
2470 /* We hit the longjmp_resume breakpoint. */
2473 /* We hit the step_resume breakpoint. */
2476 /* We hit the through_sigtramp breakpoint. */
2479 /* We hit the shared library event breakpoint. */
2482 /* We caught a shared library event. */
2485 /* This is just used to count how many enums there are. */
2489 /* Here is the table which drives this routine. So that we can
2490 format it pretty, we define some abbreviations for the
2491 enum bpstat_what codes. */
2492 #define kc BPSTAT_WHAT_KEEP_CHECKING
2493 #define ss BPSTAT_WHAT_STOP_SILENT
2494 #define sn BPSTAT_WHAT_STOP_NOISY
2495 #define sgl BPSTAT_WHAT_SINGLE
2496 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2497 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2498 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2499 #define sr BPSTAT_WHAT_STEP_RESUME
2500 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2501 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2502 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2504 /* "Can't happen." Might want to print an error message.
2505 abort() is not out of the question, but chances are GDB is just
2506 a bit confused, not unusable. */
2507 #define err BPSTAT_WHAT_STOP_NOISY
2509 /* Given an old action and a class, come up with a new action. */
2510 /* One interesting property of this table is that wp_silent is the same
2511 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2512 after stopping, the check for whether to step over a breakpoint
2513 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2514 reference to how we stopped. We retain separate wp_silent and
2515 bp_silent codes in case we want to change that someday.
2517 Another possibly interesting property of this table is that
2518 there's a partial ordering, priority-like, of the actions. Once
2519 you've decided that some action is appropriate, you'll never go
2520 back and decide something of a lower priority is better. The
2523 kc < clr sgl shl slr sn sr ss ts
2524 sgl < clrs shl shlr slr sn sr ss ts
2525 slr < err shl shlr sn sr ss ts
2526 clr < clrs err shl shlr sn sr ss ts
2527 clrs < err shl shlr sn sr ss ts
2528 ss < shl shlr sn sr ts
2535 What I think this means is that we don't need a damned table
2536 here. If you just put the rows and columns in the right order,
2537 it'd look awfully regular. We could simply walk the bpstat list
2538 and choose the highest priority action we find, with a little
2539 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2540 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2541 is messy anyway). */
2543 /* step_resume entries: a step resume breakpoint overrides another
2544 breakpoint of signal handling (see comment in wait_for_inferior
2545 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2546 /* We handle the through_sigtramp_breakpoint the same way; having both
2547 one of those and a step_resume_breakpoint is probably very rare (?). */
2549 static const enum bpstat_what_main_action
2550 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2553 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2556 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2558 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2560 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2562 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2564 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2566 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2568 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2570 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2572 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2574 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2576 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2578 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2593 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2594 struct bpstat_what retval
;
2596 retval
.call_dummy
= 0;
2597 for (; bs
!= NULL
; bs
= bs
->next
)
2599 enum class bs_class
= no_effect
;
2600 if (bs
->breakpoint_at
== NULL
)
2601 /* I suspect this can happen if it was a momentary breakpoint
2602 which has since been deleted. */
2604 switch (bs
->breakpoint_at
->type
)
2610 case bp_hardware_breakpoint
:
2616 bs_class
= bp_noisy
;
2618 bs_class
= bp_silent
;
2621 bs_class
= bp_nostop
;
2624 case bp_hardware_watchpoint
:
2625 case bp_read_watchpoint
:
2626 case bp_access_watchpoint
:
2630 bs_class
= wp_noisy
;
2632 bs_class
= wp_silent
;
2635 /* There was a watchpoint, but we're not stopping.
2636 This requires no further action. */
2637 bs_class
= no_effect
;
2640 bs_class
= long_jump
;
2642 case bp_longjmp_resume
:
2643 bs_class
= long_resume
;
2645 case bp_step_resume
:
2648 bs_class
= step_resume
;
2651 /* It is for the wrong frame. */
2652 bs_class
= bp_nostop
;
2654 case bp_through_sigtramp
:
2655 bs_class
= through_sig
;
2657 case bp_watchpoint_scope
:
2658 bs_class
= bp_nostop
;
2660 case bp_shlib_event
:
2661 bs_class
= shlib_event
;
2664 case bp_catch_unload
:
2665 /* Only if this catchpoint triggered should we cause the
2666 step-out-of-dld behaviour. Otherwise, we ignore this
2669 bs_class
= catch_shlib_event
;
2671 bs_class
= no_effect
;
2674 case bp_catch_vfork
:
2679 bs_class
= bp_noisy
;
2681 bs_class
= bp_silent
;
2684 /* There was a catchpoint, but we're not stopping.
2685 This requires no further action. */
2686 bs_class
= no_effect
;
2688 case bp_catch_catch
:
2689 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2690 bs_class
= bp_nostop
;
2692 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2694 case bp_catch_throw
:
2695 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2696 bs_class
= bp_nostop
;
2698 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2701 /* Make sure the action is stop (silent or noisy),
2702 so infrun.c pops the dummy frame. */
2703 bs_class
= bp_silent
;
2704 retval
.call_dummy
= 1;
2707 current_action
= table
[(int) bs_class
][(int) current_action
];
2709 retval
.main_action
= current_action
;
2713 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2714 without hardware support). This isn't related to a specific bpstat,
2715 just to things like whether watchpoints are set. */
2718 bpstat_should_step ()
2720 struct breakpoint
*b
;
2722 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2727 /* Nonzero if there are enabled hardware watchpoints. */
2729 bpstat_have_active_hw_watchpoints ()
2731 struct breakpoint
*b
;
2733 if ((b
->enable
== enabled
) &&
2735 ((b
->type
== bp_hardware_watchpoint
) ||
2736 (b
->type
== bp_read_watchpoint
) ||
2737 (b
->type
== bp_access_watchpoint
)))
2743 /* Given a bpstat that records zero or more triggered eventpoints, this
2744 function returns another bpstat which contains only the catchpoints
2745 on that first list, if any. */
2747 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
2751 struct bpstats root_bs
[1];
2752 bpstat bs
= root_bs
;
2753 struct breakpoint
*ep
;
2756 bpstat_clear (cp_list
);
2757 root_bs
->next
= NULL
;
2759 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
2761 /* Is this eventpoint a catchpoint? If not, ignore it. */
2762 ep
= ep_list
->breakpoint_at
;
2765 if ((ep
->type
!= bp_catch_load
) &&
2766 (ep
->type
!= bp_catch_unload
) &&
2767 (ep
->type
!= bp_catch_catch
) &&
2768 (ep
->type
!= bp_catch_throw
))
2769 /* pai: (temp) ADD fork/vfork here!! */
2772 /* Yes; add it to the list. */
2773 bs
= bpstat_alloc (ep
, bs
);
2778 #if defined(SOLIB_ADD)
2779 /* Also, for each triggered catchpoint, tag it with the name of
2780 the library that caused this trigger. (We copy the name now,
2781 because it's only guaranteed to be available NOW, when the
2782 catchpoint triggers. Clients who may wish to know the name
2783 later must get it from the catchpoint itself.) */
2784 if (ep
->triggered_dll_pathname
!= NULL
)
2785 free (ep
->triggered_dll_pathname
);
2786 if (ep
->type
== bp_catch_load
)
2787 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
2789 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
2791 dll_pathname
= NULL
;
2795 ep
->triggered_dll_pathname
= (char *)
2796 xmalloc (strlen (dll_pathname
) + 1);
2797 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
2800 ep
->triggered_dll_pathname
= NULL
;
2806 /* Print information on breakpoint number BNUM, or -1 if all.
2807 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2808 is nonzero, process only watchpoints. */
2815 ep_type_description_t
;
2818 breakpoint_1 (bnum
, allflag
)
2822 register struct breakpoint
*b
;
2823 register struct command_line
*l
;
2824 register struct symbol
*sym
;
2825 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
2826 int found_a_breakpoint
= 0;
2827 static ep_type_description_t bptypes
[] =
2829 {bp_none
, "?deleted?"},
2830 {bp_breakpoint
, "breakpoint"},
2831 {bp_hardware_breakpoint
, "hw breakpoint"},
2832 {bp_until
, "until"},
2833 {bp_finish
, "finish"},
2834 {bp_watchpoint
, "watchpoint"},
2835 {bp_hardware_watchpoint
, "hw watchpoint"},
2836 {bp_read_watchpoint
, "read watchpoint"},
2837 {bp_access_watchpoint
, "acc watchpoint"},
2838 {bp_longjmp
, "longjmp"},
2839 {bp_longjmp_resume
, "longjmp resume"},
2840 {bp_step_resume
, "step resume"},
2841 {bp_through_sigtramp
, "sigtramp"},
2842 {bp_watchpoint_scope
, "watchpoint scope"},
2843 {bp_call_dummy
, "call dummy"},
2844 {bp_shlib_event
, "shlib events"},
2845 {bp_catch_load
, "catch load"},
2846 {bp_catch_unload
, "catch unload"},
2847 {bp_catch_fork
, "catch fork"},
2848 {bp_catch_vfork
, "catch vfork"},
2849 {bp_catch_exec
, "catch exec"},
2850 {bp_catch_catch
, "catch catch"},
2851 {bp_catch_throw
, "catch throw"}
2854 static char *bpdisps
[] =
2855 {"del", "dstp", "dis", "keep"};
2856 static char bpenables
[] = "nynny";
2857 char wrap_indent
[80];
2863 || bnum
== b
->number
)
2865 /* We only print out user settable breakpoints unless the allflag is set. */
2867 && b
->type
!= bp_breakpoint
2868 && b
->type
!= bp_catch_load
2869 && b
->type
!= bp_catch_unload
2870 && b
->type
!= bp_catch_fork
2871 && b
->type
!= bp_catch_vfork
2872 && b
->type
!= bp_catch_exec
2873 && b
->type
!= bp_catch_catch
2874 && b
->type
!= bp_catch_throw
2875 && b
->type
!= bp_hardware_breakpoint
2876 && b
->type
!= bp_watchpoint
2877 && b
->type
!= bp_read_watchpoint
2878 && b
->type
!= bp_access_watchpoint
2879 && b
->type
!= bp_hardware_watchpoint
)
2882 if (!found_a_breakpoint
++)
2884 annotate_breakpoints_headers ();
2887 printf_filtered ("Num ");
2889 printf_filtered ("Type ");
2891 printf_filtered ("Disp ");
2893 printf_filtered ("Enb ");
2897 printf_filtered ("Address ");
2900 printf_filtered ("What\n");
2902 annotate_breakpoints_table ();
2907 printf_filtered ("%-3d ", b
->number
);
2909 if ((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
2910 error ("bptypes table does not describe type #%d.", (int) b
->type
);
2911 if ((int) b
->type
!= bptypes
[(int) b
->type
].type
)
2912 error ("bptypes table does not describe type #%d?", (int) b
->type
);
2913 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
2915 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
2917 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
2919 strcpy (wrap_indent
, " ");
2921 strcat (wrap_indent
, " ");
2925 case bp_hardware_watchpoint
:
2926 case bp_read_watchpoint
:
2927 case bp_access_watchpoint
:
2928 /* Field 4, the address, is omitted (which makes the columns
2929 not line up too nicely with the headers, but the effect
2930 is relatively readable). */
2932 print_expression (b
->exp
, gdb_stdout
);
2936 case bp_catch_unload
:
2937 /* Field 4, the address, is omitted (which makes the columns
2938 not line up too nicely with the headers, but the effect
2939 is relatively readable). */
2941 if (b
->dll_pathname
== NULL
)
2942 printf_filtered ("<any library> ");
2944 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
2948 case bp_catch_vfork
:
2949 /* Field 4, the address, is omitted (which makes the columns
2950 not line up too nicely with the headers, but the effect
2951 is relatively readable). */
2953 if (b
->forked_inferior_pid
!= 0)
2954 printf_filtered ("process %d ", b
->forked_inferior_pid
);
2958 /* Field 4, the address, is omitted (which makes the columns
2959 not line up too nicely with the headers, but the effect
2960 is relatively readable). */
2962 if (b
->exec_pathname
!= NULL
)
2963 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
2965 case bp_catch_catch
:
2966 /* Field 4, the address, is omitted (which makes the columns
2967 not line up too nicely with the headers, but the effect
2968 is relatively readable). */
2970 printf_filtered ("exception catch ");
2972 case bp_catch_throw
:
2973 /* Field 4, the address, is omitted (which makes the columns
2974 not line up too nicely with the headers, but the effect
2975 is relatively readable). */
2977 printf_filtered ("exception throw ");
2981 case bp_hardware_breakpoint
:
2985 case bp_longjmp_resume
:
2986 case bp_step_resume
:
2987 case bp_through_sigtramp
:
2988 case bp_watchpoint_scope
:
2990 case bp_shlib_event
:
2994 /* FIXME-32x64: need a print_address_numeric with
2998 local_hex_string_custom
2999 ((unsigned long) b
->address
, "08l"));
3004 last_addr
= b
->address
;
3007 sym
= find_pc_sect_function (b
->address
, b
->section
);
3010 fputs_filtered ("in ", gdb_stdout
);
3011 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3012 wrap_here (wrap_indent
);
3013 fputs_filtered (" at ", gdb_stdout
);
3015 fputs_filtered (b
->source_file
, gdb_stdout
);
3016 printf_filtered (":%d", b
->line_number
);
3019 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3023 if (b
->thread
!= -1)
3024 printf_filtered (" thread %d", b
->thread
);
3026 printf_filtered ("\n");
3032 printf_filtered ("\tstop only in stack frame at ");
3033 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3034 printf_filtered ("\n");
3041 printf_filtered ("\tstop only if ");
3042 print_expression (b
->cond
, gdb_stdout
);
3043 printf_filtered ("\n");
3046 if (b
->thread
!= -1)
3048 /* FIXME should make an annotation for this */
3049 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3052 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3054 /* FIXME should make an annotation for this */
3055 if (ep_is_catchpoint (b
))
3056 printf_filtered ("\tcatchpoint");
3058 printf_filtered ("\tbreakpoint");
3059 printf_filtered (" already hit %d time%s\n",
3060 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3063 if (b
->ignore_count
)
3067 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3070 if ((l
= b
->commands
))
3076 print_command_line (l
, 4, gdb_stdout
);
3082 if (!found_a_breakpoint
)
3085 printf_filtered ("No breakpoints or watchpoints.\n");
3087 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3090 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3091 that a comparison of an unsigned with -1 is always false. */
3092 if (last_addr
!= (CORE_ADDR
) -1)
3093 set_next_address (last_addr
);
3095 annotate_breakpoints_table_end ();
3100 breakpoints_info (bnum_exp
, from_tty
)
3107 bnum
= parse_and_eval_address (bnum_exp
);
3109 breakpoint_1 (bnum
, 0);
3114 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3121 bnum
= parse_and_eval_address (bnum_exp
);
3123 breakpoint_1 (bnum
, 1);
3126 /* Print a message describing any breakpoints set at PC. */
3129 describe_other_breakpoints (pc
, section
)
3133 register int others
= 0;
3134 register struct breakpoint
*b
;
3137 if (b
->address
== pc
)
3138 if (overlay_debugging
== 0 ||
3139 b
->section
== section
)
3143 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3145 if (b
->address
== pc
)
3146 if (overlay_debugging
== 0 ||
3147 b
->section
== section
)
3153 ((b
->enable
== disabled
||
3154 b
->enable
== shlib_disabled
||
3155 b
->enable
== call_disabled
) ? " (disabled)"
3156 : b
->enable
== permanent
? " (permanent)"
3158 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3160 printf_filtered ("also set at pc ");
3161 print_address_numeric (pc
, 1, gdb_stdout
);
3162 printf_filtered (".\n");
3166 /* Set the default place to put a breakpoint
3167 for the `break' command with no arguments. */
3170 set_default_breakpoint (valid
, addr
, symtab
, line
)
3173 struct symtab
*symtab
;
3176 default_breakpoint_valid
= valid
;
3177 default_breakpoint_address
= addr
;
3178 default_breakpoint_symtab
= symtab
;
3179 default_breakpoint_line
= line
;
3182 /* Rescan breakpoints at address ADDRESS,
3183 marking the first one as "first" and any others as "duplicates".
3184 This is so that the bpt instruction is only inserted once.
3185 If we have a permanent breakpoint at ADDRESS, make that one
3186 the official one, and the rest as duplicates. */
3189 check_duplicates (address
, section
)
3193 register struct breakpoint
*b
;
3194 register int count
= 0;
3195 struct breakpoint
*perm_bp
= 0;
3197 if (address
== 0) /* Watchpoints are uninteresting */
3201 if (b
->enable
!= disabled
3202 && b
->enable
!= shlib_disabled
3203 && b
->enable
!= call_disabled
3204 && b
->address
== address
3205 && (overlay_debugging
== 0 || b
->section
== section
))
3207 /* Have we found a permanent breakpoint? */
3208 if (b
->enable
== permanent
)
3215 b
->duplicate
= count
> 1;
3218 /* If we found a permanent breakpoint at this address, go over the
3219 list again and declare all the other breakpoints there to be the
3223 perm_bp
->duplicate
= 0;
3225 /* Permanent breakpoint should always be inserted. */
3226 if (! perm_bp
->inserted
)
3227 internal_error ("allegedly permanent breakpoint is not "
3228 "actually inserted");
3234 internal_error ("another breakpoint was inserted on top of "
3235 "a permanent breakpoint");
3237 if (b
->enable
!= disabled
3238 && b
->enable
!= shlib_disabled
3239 && b
->enable
!= call_disabled
3240 && b
->address
== address
3241 && (overlay_debugging
== 0 || b
->section
== section
))
3247 /* Low level routine to set a breakpoint.
3248 Takes as args the three things that every breakpoint must have.
3249 Returns the breakpoint object so caller can set other things.
3250 Does not set the breakpoint number!
3251 Does not print anything.
3253 ==> This routine should not be called if there is a chance of later
3254 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3255 your arguments BEFORE calling this routine! */
3258 set_raw_breakpoint (sal
)
3259 struct symtab_and_line sal
;
3261 register struct breakpoint
*b
, *b1
;
3263 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3264 memset (b
, 0, sizeof (*b
));
3265 b
->address
= sal
.pc
;
3266 if (sal
.symtab
== NULL
)
3267 b
->source_file
= NULL
;
3269 b
->source_file
= savestring (sal
.symtab
->filename
,
3270 strlen (sal
.symtab
->filename
));
3271 b
->section
= sal
.section
;
3272 b
->language
= current_language
->la_language
;
3273 b
->input_radix
= input_radix
;
3275 b
->line_number
= sal
.line
;
3276 b
->enable
= enabled
;
3279 b
->ignore_count
= 0;
3282 b
->dll_pathname
= NULL
;
3283 b
->triggered_dll_pathname
= NULL
;
3284 b
->forked_inferior_pid
= 0;
3285 b
->exec_pathname
= NULL
;
3287 /* Add this breakpoint to the end of the chain
3288 so that a list of breakpoints will come out in order
3289 of increasing numbers. */
3291 b1
= breakpoint_chain
;
3293 breakpoint_chain
= b
;
3301 check_duplicates (sal
.pc
, sal
.section
);
3302 breakpoints_changed ();
3308 /* Note that the breakpoint object B describes a permanent breakpoint
3309 instruction, hard-wired into the inferior's code. */
3311 make_breakpoint_permanent (struct breakpoint
*b
)
3313 b
->enable
= permanent
;
3315 /* By definition, permanent breakpoints are already present in the code. */
3319 #ifdef GET_LONGJMP_TARGET
3322 create_longjmp_breakpoint (func_name
)
3325 struct symtab_and_line sal
;
3326 struct breakpoint
*b
;
3328 INIT_SAL (&sal
); /* initialize to zeroes */
3329 if (func_name
!= NULL
)
3331 struct minimal_symbol
*m
;
3333 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3334 (struct objfile
*) NULL
);
3336 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3340 sal
.section
= find_pc_overlay (sal
.pc
);
3341 b
= set_raw_breakpoint (sal
);
3345 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3346 b
->disposition
= donttouch
;
3347 b
->enable
= disabled
;
3350 b
->addr_string
= strsave (func_name
);
3351 b
->number
= internal_breakpoint_number
--;
3354 #endif /* #ifdef GET_LONGJMP_TARGET */
3356 /* Call this routine when stepping and nexting to enable a breakpoint
3357 if we do a longjmp(). When we hit that breakpoint, call
3358 set_longjmp_resume_breakpoint() to figure out where we are going. */
3361 enable_longjmp_breakpoint ()
3363 register struct breakpoint
*b
;
3366 if (b
->type
== bp_longjmp
)
3368 b
->enable
= enabled
;
3369 check_duplicates (b
->address
, b
->section
);
3374 disable_longjmp_breakpoint ()
3376 register struct breakpoint
*b
;
3379 if (b
->type
== bp_longjmp
3380 || b
->type
== bp_longjmp_resume
)
3382 b
->enable
= disabled
;
3383 check_duplicates (b
->address
, b
->section
);
3389 remove_solib_event_breakpoints ()
3391 register struct breakpoint
*b
, *temp
;
3393 ALL_BREAKPOINTS_SAFE (b
, temp
)
3394 if (b
->type
== bp_shlib_event
)
3395 delete_breakpoint (b
);
3399 create_solib_event_breakpoint (address
)
3402 struct breakpoint
*b
;
3403 struct symtab_and_line sal
;
3405 INIT_SAL (&sal
); /* initialize to zeroes */
3407 sal
.section
= find_pc_overlay (sal
.pc
);
3408 b
= set_raw_breakpoint (sal
);
3409 b
->number
= internal_breakpoint_number
--;
3410 b
->disposition
= donttouch
;
3411 b
->type
= bp_shlib_event
;
3416 /* Disable any breakpoints that are on code in shared libraries. Only
3417 apply to enabled breakpoints, disabled ones can just stay disabled. */
3420 disable_breakpoints_in_shlibs (silent
)
3423 struct breakpoint
*b
;
3424 int disabled_shlib_breaks
= 0;
3426 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3429 #if defined (PC_SOLIB)
3430 if (((b
->type
== bp_breakpoint
) ||
3431 (b
->type
== bp_hardware_breakpoint
)) &&
3432 b
->enable
== enabled
&&
3434 PC_SOLIB (b
->address
))
3436 b
->enable
= shlib_disabled
;
3439 if (!disabled_shlib_breaks
)
3441 target_terminal_ours_for_output ();
3442 warning ("Temporarily disabling shared library breakpoints:");
3444 disabled_shlib_breaks
= 1;
3445 warning ("breakpoint #%d ", b
->number
);
3452 /* Try to reenable any breakpoints in shared libraries. */
3454 re_enable_breakpoints_in_shlibs ()
3456 struct breakpoint
*b
;
3459 if (b
->enable
== shlib_disabled
)
3463 /* Do not reenable the breakpoint if the shared library
3464 is still not mapped in. */
3465 if (target_read_memory (b
->address
, buf
, 1) == 0)
3466 b
->enable
= enabled
;
3473 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
3478 enum bptype bp_kind
;
3480 struct breakpoint
*b
;
3481 struct symtabs_and_lines sals
;
3482 struct cleanup
*old_chain
;
3483 struct cleanup
*canonical_strings_chain
= NULL
;
3484 char *addr_start
= hookname
;
3485 char *addr_end
= NULL
;
3486 char **canonical
= (char **) NULL
;
3487 int thread
= -1; /* All threads. */
3489 /* Set a breakpoint on the specified hook. */
3490 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3491 addr_end
= hookname
;
3493 if (sals
.nelts
== 0)
3495 warning ("Unable to set a breakpoint on dynamic linker callback.");
3496 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3497 warning ("GDB will be unable to track shl_load/shl_unload calls");
3500 if (sals
.nelts
!= 1)
3502 warning ("Unable to set unique breakpoint on dynamic linker callback.");
3503 warning ("GDB will be unable to track shl_load/shl_unload calls");
3507 /* Make sure that all storage allocated in decode_line_1 gets freed
3508 in case the following errors out. */
3509 old_chain
= make_cleanup (free
, sals
.sals
);
3510 if (canonical
!= (char **) NULL
)
3512 make_cleanup (free
, canonical
);
3513 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3514 if (canonical
[0] != NULL
)
3515 make_cleanup (free
, canonical
[0]);
3518 resolve_sal_pc (&sals
.sals
[0]);
3520 /* Remove the canonical strings from the cleanup, they are needed below. */
3521 if (canonical
!= (char **) NULL
)
3522 discard_cleanups (canonical_strings_chain
);
3524 b
= set_raw_breakpoint (sals
.sals
[0]);
3525 set_breakpoint_count (breakpoint_count
+ 1);
3526 b
->number
= breakpoint_count
;
3528 b
->cond_string
= (cond_string
== NULL
) ?
3529 NULL
: savestring (cond_string
, strlen (cond_string
));
3532 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
3533 b
->addr_string
= canonical
[0];
3534 else if (addr_start
)
3535 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
3537 b
->enable
= enabled
;
3538 b
->disposition
= tempflag
? del
: donttouch
;
3540 if (dll_pathname
== NULL
)
3541 b
->dll_pathname
= NULL
;
3544 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
3545 strcpy (b
->dll_pathname
, dll_pathname
);
3550 do_cleanups (old_chain
);
3554 create_solib_load_event_breakpoint (hookname
, tempflag
,
3555 dll_pathname
, cond_string
)
3561 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
3562 cond_string
, bp_catch_load
);
3566 create_solib_unload_event_breakpoint (hookname
, tempflag
,
3567 dll_pathname
, cond_string
)
3573 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
3574 cond_string
, bp_catch_unload
);
3578 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
3581 enum bptype bp_kind
;
3583 struct symtab_and_line sal
;
3584 struct breakpoint
*b
;
3585 int thread
= -1; /* All threads. */
3592 b
= set_raw_breakpoint (sal
);
3593 set_breakpoint_count (breakpoint_count
+ 1);
3594 b
->number
= breakpoint_count
;
3596 b
->cond_string
= (cond_string
== NULL
) ?
3597 NULL
: savestring (cond_string
, strlen (cond_string
));
3599 b
->addr_string
= NULL
;
3600 b
->enable
= enabled
;
3601 b
->disposition
= tempflag
? del
: donttouch
;
3602 b
->forked_inferior_pid
= 0;
3610 create_fork_event_catchpoint (tempflag
, cond_string
)
3614 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
3618 create_vfork_event_catchpoint (tempflag
, cond_string
)
3622 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
3626 create_exec_event_catchpoint (tempflag
, cond_string
)
3630 struct symtab_and_line sal
;
3631 struct breakpoint
*b
;
3632 int thread
= -1; /* All threads. */
3639 b
= set_raw_breakpoint (sal
);
3640 set_breakpoint_count (breakpoint_count
+ 1);
3641 b
->number
= breakpoint_count
;
3643 b
->cond_string
= (cond_string
== NULL
) ?
3644 NULL
: savestring (cond_string
, strlen (cond_string
));
3646 b
->addr_string
= NULL
;
3647 b
->enable
= enabled
;
3648 b
->disposition
= tempflag
? del
: donttouch
;
3650 b
->type
= bp_catch_exec
;
3656 hw_breakpoint_used_count ()
3658 register struct breakpoint
*b
;
3663 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
3671 hw_watchpoint_used_count (type
, other_type_used
)
3673 int *other_type_used
;
3675 register struct breakpoint
*b
;
3678 *other_type_used
= 0;
3681 if (b
->enable
== enabled
)
3683 if (b
->type
== type
)
3685 else if ((b
->type
== bp_hardware_watchpoint
||
3686 b
->type
== bp_read_watchpoint
||
3687 b
->type
== bp_access_watchpoint
)
3688 && b
->enable
== enabled
)
3689 *other_type_used
= 1;
3695 /* Call this after hitting the longjmp() breakpoint. Use this to set
3696 a new breakpoint at the target of the jmp_buf.
3698 FIXME - This ought to be done by setting a temporary breakpoint
3699 that gets deleted automatically... */
3702 set_longjmp_resume_breakpoint (pc
, frame
)
3704 struct frame_info
*frame
;
3706 register struct breakpoint
*b
;
3709 if (b
->type
== bp_longjmp_resume
)
3712 b
->enable
= enabled
;
3714 b
->frame
= frame
->frame
;
3717 check_duplicates (b
->address
, b
->section
);
3723 disable_watchpoints_before_interactive_call_start ()
3725 struct breakpoint
*b
;
3729 if (((b
->type
== bp_watchpoint
)
3730 || (b
->type
== bp_hardware_watchpoint
)
3731 || (b
->type
== bp_read_watchpoint
)
3732 || (b
->type
== bp_access_watchpoint
)
3733 || ep_is_exception_catchpoint (b
))
3734 && (b
->enable
== enabled
))
3736 b
->enable
= call_disabled
;
3737 check_duplicates (b
->address
, b
->section
);
3743 enable_watchpoints_after_interactive_call_stop ()
3745 struct breakpoint
*b
;
3749 if (((b
->type
== bp_watchpoint
)
3750 || (b
->type
== bp_hardware_watchpoint
)
3751 || (b
->type
== bp_read_watchpoint
)
3752 || (b
->type
== bp_access_watchpoint
)
3753 || ep_is_exception_catchpoint (b
))
3754 && (b
->enable
== call_disabled
))
3756 b
->enable
= enabled
;
3757 check_duplicates (b
->address
, b
->section
);
3763 /* Set a breakpoint that will evaporate an end of command
3764 at address specified by SAL.
3765 Restrict it to frame FRAME if FRAME is nonzero. */
3768 set_momentary_breakpoint (sal
, frame
, type
)
3769 struct symtab_and_line sal
;
3770 struct frame_info
*frame
;
3773 register struct breakpoint
*b
;
3774 b
= set_raw_breakpoint (sal
);
3776 b
->enable
= enabled
;
3777 b
->disposition
= donttouch
;
3778 b
->frame
= (frame
? frame
->frame
: 0);
3780 /* If we're debugging a multi-threaded program, then we
3781 want momentary breakpoints to be active in only a
3782 single thread of control. */
3783 if (in_thread_list (inferior_pid
))
3784 b
->thread
= pid_to_thread_id (inferior_pid
);
3790 /* Tell the user we have just set a breakpoint B. */
3794 struct breakpoint
*b
;
3798 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3799 watchpoint) other than breakpoint creation. It should be possible to
3800 clean this up and at the same time replace the random calls to
3801 breakpoint_changed with this hook, as has already been done for
3802 delete_breakpoint_hook and so on. */
3803 if (create_breakpoint_hook
)
3804 create_breakpoint_hook (b
);
3805 breakpoint_create_event (b
->number
);
3810 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
3813 printf_filtered ("Watchpoint %d: ", b
->number
);
3814 print_expression (b
->exp
, gdb_stdout
);
3816 case bp_hardware_watchpoint
:
3817 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
3818 print_expression (b
->exp
, gdb_stdout
);
3820 case bp_read_watchpoint
:
3821 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
3822 print_expression (b
->exp
, gdb_stdout
);
3824 case bp_access_watchpoint
:
3825 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
3827 print_expression (b
->exp
, gdb_stdout
);
3830 printf_filtered ("Breakpoint %d", b
->number
);
3833 case bp_hardware_breakpoint
:
3834 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
3838 case bp_catch_unload
:
3839 printf_filtered ("Catchpoint %d (%s %s)",
3841 (b
->type
== bp_catch_load
) ? "load" : "unload",
3842 (b
->dll_pathname
!= NULL
) ?
3843 b
->dll_pathname
: "<any library>");
3846 case bp_catch_vfork
:
3847 printf_filtered ("Catchpoint %d (%s)",
3849 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
3852 printf_filtered ("Catchpoint %d (exec)",
3855 case bp_catch_catch
:
3856 case bp_catch_throw
:
3857 printf_filtered ("Catchpoint %d (%s)",
3859 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
3865 case bp_longjmp_resume
:
3866 case bp_step_resume
:
3867 case bp_through_sigtramp
:
3869 case bp_watchpoint_scope
:
3870 case bp_shlib_event
:
3875 if (addressprint
|| b
->source_file
== NULL
)
3877 printf_filtered (" at ");
3878 print_address_numeric (b
->address
, 1, gdb_stdout
);
3881 printf_filtered (": file %s, line %d.",
3882 b
->source_file
, b
->line_number
);
3883 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
3884 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
3886 printf_filtered ("\n");
3890 /* Set a breakpoint according to ARG (function, linenum or *address)
3891 flag: first bit : 0 non-temporary, 1 temporary.
3892 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3895 break_command_1 (arg
, flag
, from_tty
)
3899 int tempflag
, hardwareflag
;
3900 struct symtabs_and_lines sals
;
3901 struct symtab_and_line sal
;
3902 register struct expression
*cond
= 0;
3903 register struct breakpoint
*b
;
3905 /* Pointers in arg to the start, and one past the end, of the condition. */
3906 char *cond_start
= NULL
;
3907 char *cond_end
= NULL
;
3908 /* Pointers in arg to the start, and one past the end,
3909 of the address part. */
3910 char *addr_start
= NULL
;
3911 char *addr_end
= NULL
;
3912 struct cleanup
*old_chain
;
3913 struct cleanup
*canonical_strings_chain
= NULL
;
3914 char **canonical
= (char **) NULL
;
3918 hardwareflag
= flag
& BP_HARDWAREFLAG
;
3919 tempflag
= flag
& BP_TEMPFLAG
;
3924 INIT_SAL (&sal
); /* initialize to zeroes */
3926 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3928 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
3929 && (arg
[2] == ' ' || arg
[2] == '\t')))
3931 if (default_breakpoint_valid
)
3933 sals
.sals
= (struct symtab_and_line
*)
3934 xmalloc (sizeof (struct symtab_and_line
));
3935 sal
.pc
= default_breakpoint_address
;
3936 sal
.line
= default_breakpoint_line
;
3937 sal
.symtab
= default_breakpoint_symtab
;
3938 sal
.section
= find_pc_overlay (sal
.pc
);
3943 error ("No default breakpoint address now.");
3949 /* Force almost all breakpoints to be in terms of the
3950 current_source_symtab (which is decode_line_1's default). This
3951 should produce the results we want almost all of the time while
3952 leaving default_breakpoint_* alone. */
3953 if (default_breakpoint_valid
3954 && (!current_source_symtab
3955 || (arg
&& (*arg
== '+' || *arg
== '-'))))
3956 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
3957 default_breakpoint_line
, &canonical
);
3959 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3967 /* Make sure that all storage allocated in decode_line_1 gets freed
3968 in case the following `for' loop errors out. */
3969 old_chain
= make_cleanup (free
, sals
.sals
);
3970 if (canonical
!= (char **) NULL
)
3972 make_cleanup (free
, canonical
);
3973 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3974 for (i
= 0; i
< sals
.nelts
; i
++)
3976 if (canonical
[i
] != NULL
)
3977 make_cleanup (free
, canonical
[i
]);
3981 thread
= -1; /* No specific thread yet */
3983 /* Resolve all line numbers to PC's, and verify that conditions
3984 can be parsed, before setting any breakpoints. */
3985 for (i
= 0; i
< sals
.nelts
; i
++)
3987 char *tok
, *end_tok
;
3990 resolve_sal_pc (&sals
.sals
[i
]);
3992 /* It's possible for the PC to be nonzero, but still an illegal
3993 value on some targets.
3995 For example, on HP-UX if you start gdb, and before running the
3996 inferior you try to set a breakpoint on a shared library function
3997 "foo" where the inferior doesn't call "foo" directly but does
3998 pass its address to another function call, then we do find a
3999 minimal symbol for the "foo", but it's address is invalid.
4000 (Appears to be an index into a table that the loader sets up
4001 when the inferior is run.)
4003 Give the target a chance to bless sals.sals[i].pc before we
4004 try to make a breakpoint for it. */
4005 if (PC_REQUIRES_RUN_BEFORE_USE (sals
.sals
[i
].pc
))
4007 error ("Cannot break on %s without a running program.",
4015 while (*tok
== ' ' || *tok
== '\t')
4020 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4023 toklen
= end_tok
- tok
;
4025 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4027 tok
= cond_start
= end_tok
+ 1;
4028 cond
= parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4031 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4037 thread
= strtol (tok
, &tok
, 0);
4039 error ("Junk after thread keyword.");
4040 if (!valid_thread_id (thread
))
4041 error ("Unknown thread %d\n", thread
);
4044 error ("Junk at end of arguments.");
4049 int i
, target_resources_ok
;
4051 i
= hw_breakpoint_used_count ();
4052 target_resources_ok
=
4053 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4055 if (target_resources_ok
== 0)
4056 error ("No hardware breakpoint support in the target.");
4057 else if (target_resources_ok
< 0)
4058 error ("Hardware breakpoints used exceeds limit.");
4061 /* Remove the canonical strings from the cleanup, they are needed below. */
4062 if (canonical
!= (char **) NULL
)
4063 discard_cleanups (canonical_strings_chain
);
4065 /* Now set all the breakpoints. */
4066 for (i
= 0; i
< sals
.nelts
; i
++)
4071 describe_other_breakpoints (sal
.pc
, sal
.section
);
4073 b
= set_raw_breakpoint (sal
);
4074 set_breakpoint_count (breakpoint_count
+ 1);
4075 b
->number
= breakpoint_count
;
4076 b
->type
= hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
;
4080 /* If a canonical line spec is needed use that instead of the
4082 if (canonical
!= (char **) NULL
&& canonical
[i
] != NULL
)
4083 b
->addr_string
= canonical
[i
];
4084 else if (addr_start
)
4085 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4087 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4089 b
->enable
= enabled
;
4090 b
->disposition
= tempflag
? del
: donttouch
;
4096 warning ("Multiple breakpoints were set.");
4097 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4099 do_cleanups (old_chain
);
4103 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4108 struct frame_info
*frame
;
4109 CORE_ADDR low
, high
, selected_pc
= 0;
4110 char *extra_args
, *level_arg
, *addr_string
;
4111 int extra_args_len
= 0, if_arg
= 0;
4114 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4117 if (default_breakpoint_valid
)
4121 selected_pc
= selected_frame
->pc
;
4126 error ("No selected frame.");
4129 error ("No default breakpoint address now.");
4133 extra_args
= strchr (arg
, ' ');
4137 extra_args_len
= strlen (extra_args
);
4138 level_arg
= (char *) xmalloc (extra_args
- arg
);
4139 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4140 level_arg
[extra_args
- arg
- 1] = '\0';
4144 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4145 strcpy (level_arg
, arg
);
4148 frame
= parse_frame_specification (level_arg
);
4150 selected_pc
= frame
->pc
;
4157 extra_args_len
= strlen (arg
);
4162 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4164 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4166 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4168 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4169 break_command_1 (addr_string
, flag
, from_tty
);
4173 error ("No function contains the specified address");
4176 error ("Unable to set breakpoint at procedure exit");
4181 break_at_finish_command_1 (arg
, flag
, from_tty
)
4186 char *addr_string
, *break_string
, *beg_addr_string
;
4187 CORE_ADDR low
, high
;
4188 struct symtabs_and_lines sals
;
4189 struct symtab_and_line sal
;
4190 struct cleanup
*old_chain
;
4192 int extra_args_len
= 0;
4196 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4198 if (default_breakpoint_valid
)
4202 addr_string
= (char *) xmalloc (15);
4203 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
4208 error ("No selected frame.");
4211 error ("No default breakpoint address now.");
4215 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
4216 strcpy (addr_string
, arg
);
4222 extra_args_len
= strlen (arg
);
4226 /* get the stuff after the function name or address */
4227 extra_args
= strchr (arg
, ' ');
4231 extra_args_len
= strlen (extra_args
);
4238 beg_addr_string
= addr_string
;
4239 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
4242 free (beg_addr_string
);
4243 old_chain
= make_cleanup (free
, sals
.sals
);
4244 for (i
= 0; (i
< sals
.nelts
); i
++)
4247 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
4249 break_string
= (char *) xmalloc (extra_args_len
+ 26);
4251 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4253 sprintf (break_string
, "*0x%s", paddr_nz (high
));
4254 break_command_1 (break_string
, flag
, from_tty
);
4255 free (break_string
);
4258 error ("No function contains the specified address");
4262 warning ("Multiple breakpoints were set.\n");
4263 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4265 do_cleanups (old_chain
);
4269 /* Helper function for break_command_1 and disassemble_command. */
4272 resolve_sal_pc (sal
)
4273 struct symtab_and_line
*sal
;
4277 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
4279 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
4280 error ("No line %d in file \"%s\".",
4281 sal
->line
, sal
->symtab
->filename
);
4285 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
4287 struct blockvector
*bv
;
4292 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
4295 b
= BLOCKVECTOR_BLOCK (bv
, index
);
4296 sym
= block_function (b
);
4299 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
4300 sal
->section
= SYMBOL_BFD_SECTION (sym
);
4304 /* It really is worthwhile to have the section, so we'll just
4305 have to look harder. This case can be executed if we have
4306 line numbers but no functions (as can happen in assembly
4309 struct minimal_symbol
*msym
;
4311 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
4313 sal
->section
= SYMBOL_BFD_SECTION (msym
);
4320 break_command (arg
, from_tty
)
4324 break_command_1 (arg
, 0, from_tty
);
4328 break_at_finish_command (arg
, from_tty
)
4332 break_at_finish_command_1 (arg
, 0, from_tty
);
4336 break_at_finish_at_depth_command (arg
, from_tty
)
4340 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
4344 tbreak_command (arg
, from_tty
)
4348 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4352 tbreak_at_finish_command (arg
, from_tty
)
4356 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4360 hbreak_command (arg
, from_tty
)
4364 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
4368 thbreak_command (arg
, from_tty
)
4372 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
4376 stop_command (arg
, from_tty
)
4380 printf_filtered ("Specify the type of breakpoint to set.\n\
4381 Usage: stop in <function | address>\n\
4386 stopin_command (arg
, from_tty
)
4392 if (arg
== (char *) NULL
)
4394 else if (*arg
!= '*')
4399 /* look for a ':'. If this is a line number specification, then
4400 say it is bad, otherwise, it should be an address or
4401 function/method name */
4402 while (*argptr
&& !hasColon
)
4404 hasColon
= (*argptr
== ':');
4409 badInput
= (*argptr
!= ':'); /* Not a class::method */
4411 badInput
= isdigit (*arg
); /* a simple line number */
4415 printf_filtered ("Usage: stop in <function | address>\n");
4417 break_command_1 (arg
, 0, from_tty
);
4421 stopat_command (arg
, from_tty
)
4427 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
4434 /* look for a ':'. If there is a '::' then get out, otherwise
4435 it is probably a line number. */
4436 while (*argptr
&& !hasColon
)
4438 hasColon
= (*argptr
== ':');
4443 badInput
= (*argptr
== ':'); /* we have class::method */
4445 badInput
= !isdigit (*arg
); /* not a line number */
4449 printf_filtered ("Usage: stop at <line>\n");
4451 break_command_1 (arg
, 0, from_tty
);
4455 /* accessflag: hw_write: watch write,
4456 hw_read: watch read,
4457 hw_access: watch access (read or write) */
4459 watch_command_1 (arg
, accessflag
, from_tty
)
4464 struct breakpoint
*b
;
4465 struct symtab_and_line sal
;
4466 struct expression
*exp
;
4467 struct block
*exp_valid_block
;
4468 struct value
*val
, *mark
;
4469 struct frame_info
*frame
;
4470 struct frame_info
*prev_frame
= NULL
;
4471 char *exp_start
= NULL
;
4472 char *exp_end
= NULL
;
4473 char *tok
, *end_tok
;
4475 char *cond_start
= NULL
;
4476 char *cond_end
= NULL
;
4477 struct expression
*cond
= NULL
;
4478 int i
, other_type_used
, target_resources_ok
= 0;
4479 enum bptype bp_type
;
4482 INIT_SAL (&sal
); /* initialize to zeroes */
4484 /* Parse arguments. */
4485 innermost_block
= NULL
;
4487 exp
= parse_exp_1 (&arg
, 0, 0);
4489 exp_valid_block
= innermost_block
;
4490 mark
= value_mark ();
4491 val
= evaluate_expression (exp
);
4492 release_value (val
);
4493 if (VALUE_LAZY (val
))
4494 value_fetch_lazy (val
);
4497 while (*tok
== ' ' || *tok
== '\t')
4501 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4504 toklen
= end_tok
- tok
;
4505 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4507 tok
= cond_start
= end_tok
+ 1;
4508 cond
= parse_exp_1 (&tok
, 0, 0);
4512 error ("Junk at end of command.");
4514 if (accessflag
== hw_read
)
4515 bp_type
= bp_read_watchpoint
;
4516 else if (accessflag
== hw_access
)
4517 bp_type
= bp_access_watchpoint
;
4519 bp_type
= bp_hardware_watchpoint
;
4521 mem_cnt
= can_use_hardware_watchpoint (val
);
4522 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
4523 error ("Expression cannot be implemented with read/access watchpoint.");
4526 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
4527 target_resources_ok
=
4528 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
4530 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
4531 error ("Target does not support this type of hardware watchpoint.");
4533 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
4534 error ("Target can only support one kind of HW watchpoint at a time.");
4537 #if defined(HPUXHPPA)
4538 /* On HP-UX if you set a h/w
4539 watchpoint before the "run" command, the inferior dies with a e.g.,
4540 SIGILL once you start it. I initially believed this was due to a
4541 bad interaction between page protection traps and the initial
4542 startup sequence by the dynamic linker.
4544 However, I tried avoiding that by having HP-UX's implementation of
4545 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4546 yet, which forced slow watches before a "run" or "attach", and it
4547 still fails somewhere in the startup code.
4549 Until I figure out what's happening, I'm disallowing watches altogether
4550 before the "run" or "attach" command. We'll tell the user they must
4551 set watches after getting the program started. */
4552 if (!target_has_execution
)
4554 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4557 #endif /* HPUXHPPA */
4559 /* Now set up the breakpoint. */
4560 b
= set_raw_breakpoint (sal
);
4561 set_breakpoint_count (breakpoint_count
+ 1);
4562 b
->number
= breakpoint_count
;
4563 b
->disposition
= donttouch
;
4565 b
->exp_valid_block
= exp_valid_block
;
4566 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
4570 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4574 frame
= block_innermost_frame (exp_valid_block
);
4577 prev_frame
= get_prev_frame (frame
);
4578 b
->watchpoint_frame
= frame
->frame
;
4581 b
->watchpoint_frame
= (CORE_ADDR
) 0;
4583 if (mem_cnt
&& target_resources_ok
> 0)
4586 b
->type
= bp_watchpoint
;
4588 /* If the expression is "local", then set up a "watchpoint scope"
4589 breakpoint at the point where we've left the scope of the watchpoint
4591 if (innermost_block
)
4595 struct breakpoint
*scope_breakpoint
;
4596 struct symtab_and_line scope_sal
;
4598 INIT_SAL (&scope_sal
); /* initialize to zeroes */
4599 scope_sal
.pc
= get_frame_pc (prev_frame
);
4600 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
4602 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
4603 set_breakpoint_count (breakpoint_count
+ 1);
4604 scope_breakpoint
->number
= breakpoint_count
;
4606 scope_breakpoint
->type
= bp_watchpoint_scope
;
4607 scope_breakpoint
->enable
= enabled
;
4609 /* Automatically delete the breakpoint when it hits. */
4610 scope_breakpoint
->disposition
= del
;
4612 /* Only break in the proper frame (help with recursion). */
4613 scope_breakpoint
->frame
= prev_frame
->frame
;
4615 /* Set the address at which we will stop. */
4616 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
4618 /* The scope breakpoint is related to the watchpoint. We
4619 will need to act on them together. */
4620 b
->related_breakpoint
= scope_breakpoint
;
4623 value_free_to_mark (mark
);
4627 /* Return count of locations need to be watched and can be handled
4628 in hardware. If the watchpoint can not be handled
4629 in hardware return zero. */
4631 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4632 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
4633 ((BYTE_SIZE) <= (REGISTER_SIZE))
4636 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
4637 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
4638 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
4642 can_use_hardware_watchpoint (v
)
4645 int found_memory_cnt
= 0;
4647 /* Did the user specifically forbid us to use hardware watchpoints? */
4648 if (!can_use_hw_watchpoints
)
4651 /* Make sure all the intermediate values are in memory. Also make sure
4652 we found at least one memory expression. Guards against watch 0x12345,
4653 which is meaningless, but could cause errors if one tries to insert a
4654 hardware watchpoint for the constant expression. */
4655 for (; v
; v
= v
->next
)
4657 if (v
->lval
== lval_memory
)
4659 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
4660 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
4662 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
4667 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
4668 return 0; /* ??? What does this represent? */
4669 else if (v
->lval
== lval_register
)
4670 return 0; /* cannot watch a register with a HW watchpoint */
4673 /* The expression itself looks suitable for using a hardware
4674 watchpoint, but give the target machine a chance to reject it. */
4675 return found_memory_cnt
;
4679 watch_command (arg
, from_tty
)
4683 watch_command_1 (arg
, hw_write
, from_tty
);
4687 rwatch_command (arg
, from_tty
)
4691 watch_command_1 (arg
, hw_read
, from_tty
);
4695 awatch_command (arg
, from_tty
)
4699 watch_command_1 (arg
, hw_access
, from_tty
);
4703 /* Helper routines for the until_command routine in infcmd.c. Here
4704 because it uses the mechanisms of breakpoints. */
4706 /* This function is called by fetch_inferior_event via the
4707 cmd_continuation pointer, to complete the until command. It takes
4708 care of cleaning up the temporary breakpoints set up by the until
4711 until_break_command_continuation (struct continuation_arg
*arg
)
4713 /* Do all the exec cleanups, which at this point should only be the
4714 one set up in the first part of the until_break_command
4716 do_exec_cleanups (ALL_CLEANUPS
);
4721 until_break_command (arg
, from_tty
)
4725 struct symtabs_and_lines sals
;
4726 struct symtab_and_line sal
;
4727 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
4728 struct breakpoint
*breakpoint
;
4729 struct cleanup
*old_chain
;
4731 clear_proceed_status ();
4733 /* Set a breakpoint where the user wants it and at return from
4736 if (default_breakpoint_valid
)
4737 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
4738 default_breakpoint_line
, (char ***) NULL
);
4740 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
4741 0, (char ***) NULL
);
4743 if (sals
.nelts
!= 1)
4744 error ("Couldn't get information on specified line.");
4747 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
4750 error ("Junk at end of arguments.");
4752 resolve_sal_pc (&sal
);
4754 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
4756 if (!event_loop_p
|| !target_can_async_p ())
4757 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
4760 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4762 /* If we are running asynchronously, and the target supports async
4763 execution, we are not waiting for the target to stop, in the call
4764 tp proceed, below. This means that we cannot delete the
4765 brekpoints until the target has actually stopped. The only place
4766 where we get a chance to do that is in fetch_inferior_event, so
4767 we must set things up for that. */
4769 if (event_loop_p
&& target_can_async_p ())
4771 /* In this case we don't need args for the continuation, because
4772 all it needs to do is do the cleanups in the
4773 exec_cleanup_chain, which will be only those inserted by this
4774 function. We can get away by using ALL_CLEANUPS. */
4775 add_continuation (until_break_command_continuation
, NULL
);
4778 /* Keep within the current frame */
4782 sal
= find_pc_line (prev_frame
->pc
, 0);
4783 sal
.pc
= prev_frame
->pc
;
4784 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
4785 if (!event_loop_p
|| !target_can_async_p ())
4786 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4788 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4791 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
4792 /* Do the cleanups now, anly if we are not running asynchronously,
4793 of if we are, but the target is still synchronous. */
4794 if (!event_loop_p
|| !target_can_async_p ())
4795 do_cleanups (old_chain
);
4799 /* These aren't used; I don't konw what they were for. */
4800 /* Set a breakpoint at the catch clause for NAME. */
4802 catch_breakpoint (name
)
4808 disable_catch_breakpoint ()
4813 delete_catch_breakpoint ()
4818 enable_catch_breakpoint ()
4825 struct sal_chain
*next
;
4826 struct symtab_and_line sal
;
4830 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4831 had been commented out in the v.4.16 sources, and stays
4832 disabled there now because "catch NAME" syntax isn't allowed.
4834 /* This isn't used; I don't know what it was for. */
4835 /* For each catch clause identified in ARGS, run FUNCTION
4836 with that clause as an argument. */
4837 static struct symtabs_and_lines
4838 map_catch_names (args
, function
)
4842 register char *p
= args
;
4844 struct symtabs_and_lines sals
;
4846 struct sal_chain
*sal_chain
= 0;
4850 error_no_arg ("one or more catch names");
4858 /* Don't swallow conditional part. */
4859 if (p1
[0] == 'i' && p1
[1] == 'f'
4860 && (p1
[2] == ' ' || p1
[2] == '\t'))
4866 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
4870 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
4871 error ("Arguments must be catch names.");
4877 struct sal_chain
*next
= (struct sal_chain
*)
4878 alloca (sizeof (struct sal_chain
));
4879 next
->next
= sal_chain
;
4880 next
->sal
= get_catch_sal (p
);
4885 printf_unfiltered ("No catch clause for exception %s.\n", p
);
4890 while (*p
== ' ' || *p
== '\t')
4896 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4898 static struct symtabs_and_lines
4899 get_catch_sals (this_level_only
)
4900 int this_level_only
;
4902 register struct blockvector
*bl
;
4903 register struct block
*block
;
4904 int index
, have_default
= 0;
4906 struct symtabs_and_lines sals
;
4907 struct sal_chain
*sal_chain
= 0;
4908 char *blocks_searched
;
4910 /* Not sure whether an error message is always the correct response,
4911 but it's better than a core dump. */
4912 if (selected_frame
== NULL
)
4913 error ("No selected frame.");
4914 block
= get_frame_block (selected_frame
);
4915 pc
= selected_frame
->pc
;
4921 error ("No symbol table info available.\n");
4923 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
4924 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4925 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4929 CORE_ADDR end
= BLOCK_END (block
) - 4;
4932 if (bl
!= blockvector_for_pc (end
, &index
))
4933 error ("blockvector blotch");
4934 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
4935 error ("blockvector botch");
4936 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
4939 /* Don't print out blocks that have gone by. */
4940 while (index
< last_index
4941 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
4944 while (index
< last_index
4945 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
4947 if (blocks_searched
[index
] == 0)
4949 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
4952 register struct symbol
*sym
;
4954 nsyms
= BLOCK_NSYMS (b
);
4956 for (i
= 0; i
< nsyms
; i
++)
4958 sym
= BLOCK_SYM (b
, i
);
4959 if (STREQ (SYMBOL_NAME (sym
), "default"))
4965 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
4967 struct sal_chain
*next
= (struct sal_chain
*)
4968 alloca (sizeof (struct sal_chain
));
4969 next
->next
= sal_chain
;
4970 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
4975 blocks_searched
[index
] = 1;
4981 if (sal_chain
&& this_level_only
)
4984 /* After handling the function's top-level block, stop.
4985 Don't continue to its superblock, the block of
4986 per-file symbols. */
4987 if (BLOCK_FUNCTION (block
))
4989 block
= BLOCK_SUPERBLOCK (block
);
4994 struct sal_chain
*tmp_chain
;
4996 /* Count the number of entries. */
4997 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
4998 tmp_chain
= tmp_chain
->next
)
5002 sals
.sals
= (struct symtab_and_line
*)
5003 xmalloc (index
* sizeof (struct symtab_and_line
));
5004 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5005 sals
.sals
[index
] = sal_chain
->sal
;
5012 ep_skip_leading_whitespace (s
)
5015 if ((s
== NULL
) || (*s
== NULL
))
5017 while (isspace (**s
))
5021 /* This function examines a string, and attempts to find a token
5022 that might be an event name in the leading characters. If a
5023 possible match is found, a pointer to the last character of
5024 the token is returned. Else, NULL is returned. */
5027 ep_find_event_name_end (arg
)
5031 char *event_name_end
= NULL
;
5033 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5037 /* We break out of the loop when we find a token delimiter.
5038 Basically, we're looking for alphanumerics and underscores;
5039 anything else delimites the token. */
5042 if (!isalnum (*s
) && (*s
!= '_'))
5048 return event_name_end
;
5052 /* This function attempts to parse an optional "if <cond>" clause
5053 from the arg string. If one is not found, it returns NULL.
5055 Else, it returns a pointer to the condition string. (It does not
5056 attempt to evaluate the string against a particular block.) And,
5057 it updates arg to point to the first character following the parsed
5058 if clause in the arg string. */
5061 ep_parse_optional_if_clause (arg
)
5066 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5069 /* Skip the "if" keyword. */
5072 /* Skip any extra leading whitespace, and record the start of the
5073 condition string. */
5074 ep_skip_leading_whitespace (arg
);
5077 /* Assume that the condition occupies the remainder of the arg string. */
5078 (*arg
) += strlen (cond_string
);
5083 /* This function attempts to parse an optional filename from the arg
5084 string. If one is not found, it returns NULL.
5086 Else, it returns a pointer to the parsed filename. (This function
5087 makes no attempt to verify that a file of that name exists, or is
5088 accessible.) And, it updates arg to point to the first character
5089 following the parsed filename in the arg string.
5091 Note that clients needing to preserve the returned filename for
5092 future access should copy it to their own buffers. */
5094 ep_parse_optional_filename (arg
)
5097 static char filename
[1024];
5102 if ((*arg_p
== '\0') || isspace (*arg_p
))
5120 /* Commands to deal with catching events, such as signals, exceptions,
5121 process start/exit, etc. */
5125 catch_fork
, catch_vfork
5129 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
5135 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
5136 catch_fork_kind fork_kind
;
5141 char *cond_string
= NULL
;
5143 ep_skip_leading_whitespace (&arg
);
5145 /* The allowed syntax is:
5147 catch [v]fork if <cond>
5149 First, check if there's an if clause. */
5150 cond_string
= ep_parse_optional_if_clause (&arg
);
5152 if ((*arg
!= '\0') && !isspace (*arg
))
5153 error ("Junk at end of arguments.");
5155 /* If this target supports it, create a fork or vfork catchpoint
5156 and enable reporting of such events. */
5160 create_fork_event_catchpoint (tempflag
, cond_string
);
5163 create_vfork_event_catchpoint (tempflag
, cond_string
);
5166 error ("unsupported or unknown fork kind; cannot catch it");
5172 catch_exec_command_1 (arg
, tempflag
, from_tty
)
5177 char *cond_string
= NULL
;
5179 ep_skip_leading_whitespace (&arg
);
5181 /* The allowed syntax is:
5183 catch exec if <cond>
5185 First, check if there's an if clause. */
5186 cond_string
= ep_parse_optional_if_clause (&arg
);
5188 if ((*arg
!= '\0') && !isspace (*arg
))
5189 error ("Junk at end of arguments.");
5191 /* If this target supports it, create an exec catchpoint
5192 and enable reporting of such events. */
5193 create_exec_event_catchpoint (tempflag
, cond_string
);
5196 #if defined(SOLIB_ADD)
5198 catch_load_command_1 (arg
, tempflag
, from_tty
)
5203 char *dll_pathname
= NULL
;
5204 char *cond_string
= NULL
;
5206 ep_skip_leading_whitespace (&arg
);
5208 /* The allowed syntax is:
5210 catch load if <cond>
5211 catch load <filename>
5212 catch load <filename> if <cond>
5214 The user is not allowed to specify the <filename> after an
5217 We'll ignore the pathological case of a file named "if".
5219 First, check if there's an if clause. If so, then there
5220 cannot be a filename. */
5221 cond_string
= ep_parse_optional_if_clause (&arg
);
5223 /* If there was an if clause, then there cannot be a filename.
5224 Else, there might be a filename and an if clause. */
5225 if (cond_string
== NULL
)
5227 dll_pathname
= ep_parse_optional_filename (&arg
);
5228 ep_skip_leading_whitespace (&arg
);
5229 cond_string
= ep_parse_optional_if_clause (&arg
);
5232 if ((*arg
!= '\0') && !isspace (*arg
))
5233 error ("Junk at end of arguments.");
5235 /* Create a load breakpoint that only triggers when a load of
5236 the specified dll (or any dll, if no pathname was specified)
5238 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
5239 dll_pathname
, cond_string
);
5243 catch_unload_command_1 (arg
, tempflag
, from_tty
)
5248 char *dll_pathname
= NULL
;
5249 char *cond_string
= NULL
;
5251 ep_skip_leading_whitespace (&arg
);
5253 /* The allowed syntax is:
5255 catch unload if <cond>
5256 catch unload <filename>
5257 catch unload <filename> if <cond>
5259 The user is not allowed to specify the <filename> after an
5262 We'll ignore the pathological case of a file named "if".
5264 First, check if there's an if clause. If so, then there
5265 cannot be a filename. */
5266 cond_string
= ep_parse_optional_if_clause (&arg
);
5268 /* If there was an if clause, then there cannot be a filename.
5269 Else, there might be a filename and an if clause. */
5270 if (cond_string
== NULL
)
5272 dll_pathname
= ep_parse_optional_filename (&arg
);
5273 ep_skip_leading_whitespace (&arg
);
5274 cond_string
= ep_parse_optional_if_clause (&arg
);
5277 if ((*arg
!= '\0') && !isspace (*arg
))
5278 error ("Junk at end of arguments.");
5280 /* Create an unload breakpoint that only triggers when an unload of
5281 the specified dll (or any dll, if no pathname was specified)
5283 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
5284 dll_pathname
, cond_string
);
5286 #endif /* SOLIB_ADD */
5288 /* Commands to deal with catching exceptions. */
5290 /* Set a breakpoint at the specified callback routine for an
5291 exception event callback */
5294 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
5297 enum exception_event_kind ex_event
;
5298 struct symtab_and_line
*sal
;
5300 struct breakpoint
*b
;
5301 int thread
= -1; /* All threads. */
5303 if (!sal
) /* no exception support? */
5306 b
= set_raw_breakpoint (*sal
);
5307 set_breakpoint_count (breakpoint_count
+ 1);
5308 b
->number
= breakpoint_count
;
5310 b
->cond_string
= (cond_string
== NULL
) ?
5311 NULL
: savestring (cond_string
, strlen (cond_string
));
5313 b
->addr_string
= NULL
;
5314 b
->enable
= enabled
;
5315 b
->disposition
= tempflag
? del
: donttouch
;
5318 case EX_EVENT_THROW
:
5319 b
->type
= bp_catch_throw
;
5321 case EX_EVENT_CATCH
:
5322 b
->type
= bp_catch_catch
;
5324 default: /* error condition */
5326 b
->enable
= disabled
;
5327 error ("Internal error -- invalid catchpoint kind");
5332 /* Deal with "catch catch" and "catch throw" commands */
5335 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
5336 enum exception_event_kind ex_event
;
5341 char *cond_string
= NULL
;
5342 struct symtab_and_line
*sal
= NULL
;
5344 ep_skip_leading_whitespace (&arg
);
5346 cond_string
= ep_parse_optional_if_clause (&arg
);
5348 if ((*arg
!= '\0') && !isspace (*arg
))
5349 error ("Junk at end of arguments.");
5351 if ((ex_event
!= EX_EVENT_THROW
) &&
5352 (ex_event
!= EX_EVENT_CATCH
))
5353 error ("Unsupported or unknown exception event; cannot catch it");
5355 /* See if we can find a callback routine */
5356 sal
= target_enable_exception_callback (ex_event
, 1);
5360 /* We have callbacks from the runtime system for exceptions.
5361 Set a breakpoint on the sal found, if no errors */
5362 if (sal
!= (struct symtab_and_line
*) -1)
5363 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
5365 return; /* something went wrong with setting up callbacks */
5369 /* No callbacks from runtime system for exceptions.
5370 Try GNU C++ exception breakpoints using labels in debug info. */
5371 if (ex_event
== EX_EVENT_CATCH
)
5373 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
5375 else if (ex_event
== EX_EVENT_THROW
)
5377 /* Set a breakpoint on __raise_exception () */
5379 warning ("Unsupported with this platform/compiler combination.");
5380 warning ("Perhaps you can achieve the effect you want by setting");
5381 warning ("a breakpoint on __raise_exception().");
5386 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5387 inside a catch_errors */
5390 cover_target_enable_exception_callback (arg
)
5393 args_for_catchpoint_enable
*args
= arg
;
5394 struct symtab_and_line
*sal
;
5395 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
5398 else if (sal
== (struct symtab_and_line
*) -1)
5401 return 1; /*is valid */
5406 /* This is the original v.4.16 and earlier version of the
5407 catch_command_1() function. Now that other flavours of "catch"
5408 have been introduced, and since exception handling can be handled
5409 in other ways (through target ops) also, this is used only for the
5410 GNU C++ exception handling system.
5411 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5412 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5413 there was no code in GDB 4.16 for "catch throw".
5415 Called from catch_exception_command_1 () */
5419 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
5424 /* First, translate ARG into something we can deal with in terms
5427 struct symtabs_and_lines sals
;
5428 struct symtab_and_line sal
;
5429 register struct expression
*cond
= 0;
5430 register struct breakpoint
*b
;
5434 INIT_SAL (&sal
); /* initialize to zeroes */
5436 /* If no arg given, or if first arg is 'if ', all active catch clauses
5437 are breakpointed. */
5439 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
5440 && (arg
[2] == ' ' || arg
[2] == '\t')))
5442 /* Grab all active catch clauses. */
5443 sals
= get_catch_sals (0);
5447 /* Grab selected catch clauses. */
5448 error ("catch NAME not implemented");
5451 /* Not sure why this code has been disabled. I'm leaving
5452 it disabled. We can never come here now anyway
5453 since we don't allow the "catch NAME" syntax.
5456 /* This isn't used; I don't know what it was for. */
5457 sals
= map_catch_names (arg
, catch_breakpoint
);
5465 for (i
= 0; i
< sals
.nelts
; i
++)
5467 resolve_sal_pc (&sals
.sals
[i
]);
5471 if (arg
[0] == 'i' && arg
[1] == 'f'
5472 && (arg
[2] == ' ' || arg
[2] == '\t'))
5473 cond
= parse_exp_1 ((arg
+= 2, &arg
),
5474 block_for_pc (sals
.sals
[i
].pc
), 0);
5476 error ("Junk at end of arguments.");
5481 for (i
= 0; i
< sals
.nelts
; i
++)
5486 describe_other_breakpoints (sal
.pc
, sal
.section
);
5488 b
= set_raw_breakpoint (sal
);
5489 set_breakpoint_count (breakpoint_count
+ 1);
5490 b
->number
= breakpoint_count
;
5492 /* Important -- this is an ordinary breakpoint. For platforms
5493 with callback support for exceptions,
5494 create_exception_catchpoint() will create special bp types
5495 (bp_catch_catch and bp_catch_throw), and there is code in
5496 insert_breakpoints() and elsewhere that depends on that. */
5497 b
->type
= bp_breakpoint
;
5500 b
->enable
= enabled
;
5501 b
->disposition
= tempflag
? del
: donttouch
;
5508 warning ("Multiple breakpoints were set.");
5509 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5511 free ((PTR
) sals
.sals
);
5515 /* This creates a temporary internal breakpoint
5516 just to placate infrun */
5517 static struct breakpoint
*
5518 create_temp_exception_breakpoint (pc
)
5521 struct symtab_and_line sal
;
5522 struct breakpoint
*b
;
5529 b
= set_raw_breakpoint (sal
);
5531 error ("Internal error -- couldn't set temp exception breakpoint");
5533 b
->type
= bp_breakpoint
;
5534 b
->disposition
= del
;
5535 b
->enable
= enabled
;
5537 b
->number
= internal_breakpoint_number
--;
5543 catch_command_1 (arg
, tempflag
, from_tty
)
5549 /* The first argument may be an event name, such as "start" or "load".
5550 If so, then handle it as such. If it doesn't match an event name,
5551 then attempt to interpret it as an exception name. (This latter is
5552 the v4.16-and-earlier GDB meaning of the "catch" command.)
5554 First, try to find the bounds of what might be an event name. */
5555 char *arg1_start
= arg
;
5559 if (arg1_start
== NULL
)
5561 /* Old behaviour was to use pre-v-4.16 syntax */
5562 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5564 /* Now, this is not allowed */
5565 error ("Catch requires an event name.");
5568 arg1_end
= ep_find_event_name_end (arg1_start
);
5569 if (arg1_end
== NULL
)
5570 error ("catch requires an event");
5571 arg1_length
= arg1_end
+ 1 - arg1_start
;
5573 /* Try to match what we found against known event names. */
5574 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
5576 error ("Catch of signal not yet implemented");
5578 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
5580 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
5581 tempflag
, from_tty
);
5583 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
5585 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
5586 tempflag
, from_tty
);
5588 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
5590 error ("Catch of thread_start not yet implemented");
5592 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
5594 error ("Catch of thread_exit not yet implemented");
5596 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
5598 error ("Catch of thread_join not yet implemented");
5600 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
5602 error ("Catch of start not yet implemented");
5604 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
5606 error ("Catch of exit not yet implemented");
5608 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
5610 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5611 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
5613 error ("Catch of fork not yet implemented");
5616 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
5618 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5619 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
5621 error ("Catch of vfork not yet implemented");
5624 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
5626 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5627 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5629 error ("Catch of exec not yet implemented");
5632 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
5634 #if defined(SOLIB_ADD)
5635 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5637 error ("Catch of load not implemented");
5640 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
5642 #if defined(SOLIB_ADD)
5643 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5645 error ("Catch of load not implemented");
5648 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
5650 error ("Catch of stop not yet implemented");
5653 /* This doesn't appear to be an event name */
5657 /* Pre-v.4.16 behaviour was to treat the argument
5658 as the name of an exception */
5659 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5660 /* Now this is not allowed */
5661 error ("Unknown event kind specified for catch");
5666 /* Used by the gui, could be made a worker for other things. */
5669 set_breakpoint_sal (sal
)
5670 struct symtab_and_line sal
;
5672 struct breakpoint
*b
;
5673 b
= set_raw_breakpoint (sal
);
5674 set_breakpoint_count (breakpoint_count
+ 1);
5675 b
->number
= breakpoint_count
;
5676 b
->type
= bp_breakpoint
;
5683 /* These aren't used; I don't know what they were for. */
5684 /* Disable breakpoints on all catch clauses described in ARGS. */
5686 disable_catch (args
)
5689 /* Map the disable command to catch clauses described in ARGS. */
5692 /* Enable breakpoints on all catch clauses described in ARGS. */
5697 /* Map the disable command to catch clauses described in ARGS. */
5700 /* Delete breakpoints on all catch clauses in the active scope. */
5705 /* Map the delete command to catch clauses described in ARGS. */
5710 catch_command (arg
, from_tty
)
5714 catch_command_1 (arg
, 0, from_tty
);
5719 tcatch_command (arg
, from_tty
)
5723 catch_command_1 (arg
, 1, from_tty
);
5728 clear_command (arg
, from_tty
)
5732 register struct breakpoint
*b
, *b1
;
5734 struct symtabs_and_lines sals
;
5735 struct symtab_and_line sal
;
5736 register struct breakpoint
*found
;
5741 sals
= decode_line_spec (arg
, 1);
5746 sals
.sals
= (struct symtab_and_line
*)
5747 xmalloc (sizeof (struct symtab_and_line
));
5748 INIT_SAL (&sal
); /* initialize to zeroes */
5749 sal
.line
= default_breakpoint_line
;
5750 sal
.symtab
= default_breakpoint_symtab
;
5751 sal
.pc
= default_breakpoint_address
;
5752 if (sal
.symtab
== 0)
5753 error ("No source file specified.");
5761 /* For each line spec given, delete bps which correspond
5762 to it. We do this in two loops: the first loop looks at
5763 the initial bp(s) in the chain which should be deleted,
5764 the second goes down the rest of the chain looking ahead
5765 one so it can take those bps off the chain without messing
5769 for (i
= 0; i
< sals
.nelts
; i
++)
5771 /* If exact pc given, clear bpts at that pc.
5772 If line given (pc == 0), clear all bpts on specified line.
5773 If defaulting, clear all bpts on default line
5776 defaulting sal.pc != 0 tests to do
5781 1 0 <can't happen> */
5784 found
= (struct breakpoint
*) 0;
5787 while (breakpoint_chain
5788 /* Why don't we check here that this is not
5789 a watchpoint, etc., as we do below?
5790 I can't make it fail, but don't know
5791 what's stopping the failure: a watchpoint
5792 of the same address as "sal.pc" should
5793 wind up being deleted. */
5795 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
5796 (overlay_debugging
== 0 ||
5797 breakpoint_chain
->section
== sal
.section
))
5798 || ((default_match
|| (0 == sal
.pc
))
5799 && breakpoint_chain
->source_file
!= NULL
5800 && sal
.symtab
!= NULL
5801 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
5802 && breakpoint_chain
->line_number
== sal
.line
)))
5805 b1
= breakpoint_chain
;
5806 breakpoint_chain
= b1
->next
;
5814 && b
->next
->type
!= bp_none
5815 && b
->next
->type
!= bp_watchpoint
5816 && b
->next
->type
!= bp_hardware_watchpoint
5817 && b
->next
->type
!= bp_read_watchpoint
5818 && b
->next
->type
!= bp_access_watchpoint
5819 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
5820 (overlay_debugging
== 0 ||
5821 b
->next
->section
== sal
.section
))
5822 || ((default_match
|| (0 == sal
.pc
))
5823 && b
->next
->source_file
!= NULL
5824 && sal
.symtab
!= NULL
5825 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
5826 && b
->next
->line_number
== sal
.line
)))
5839 error ("No breakpoint at %s.", arg
);
5841 error ("No breakpoint at this line.");
5845 from_tty
= 1; /* Always report if deleted more than one */
5847 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
5848 breakpoints_changed ();
5852 printf_unfiltered ("%d ", found
->number
);
5854 delete_breakpoint (found
);
5858 putchar_unfiltered ('\n');
5860 free ((PTR
) sals
.sals
);
5863 /* Delete breakpoint in BS if they are `delete' breakpoints and
5864 all breakpoints that are marked for deletion, whether hit or not.
5865 This is called after any breakpoint is hit, or after errors. */
5868 breakpoint_auto_delete (bs
)
5871 struct breakpoint
*b
, *temp
;
5873 for (; bs
; bs
= bs
->next
)
5874 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
5876 delete_breakpoint (bs
->breakpoint_at
);
5878 ALL_BREAKPOINTS_SAFE (b
, temp
)
5880 if (b
->disposition
== del_at_next_stop
)
5881 delete_breakpoint (b
);
5885 /* Delete a breakpoint and clean up all traces of it in the data
5889 delete_breakpoint (bpt
)
5890 struct breakpoint
*bpt
;
5892 register struct breakpoint
*b
;
5896 error ("Internal error (attempted to delete a NULL breakpoint)");
5899 /* Has this bp already been deleted? This can happen because multiple
5900 lists can hold pointers to bp's. bpstat lists are especial culprits.
5902 One example of this happening is a watchpoint's scope bp. When the
5903 scope bp triggers, we notice that the watchpoint is out of scope, and
5904 delete it. We also delete its scope bp. But the scope bp is marked
5905 "auto-deleting", and is already on a bpstat. That bpstat is then
5906 checked for auto-deleting bp's, which are deleted.
5908 A real solution to this problem might involve reference counts in bp's,
5909 and/or giving them pointers back to their referencing bpstat's, and
5910 teaching delete_breakpoint to only free a bp's storage when no more
5911 references were extent. A cheaper bandaid was chosen. */
5912 if (bpt
->type
== bp_none
)
5915 if (delete_breakpoint_hook
)
5916 delete_breakpoint_hook (bpt
);
5917 breakpoint_delete_event (bpt
->number
);
5920 remove_breakpoint (bpt
, mark_uninserted
);
5922 if (breakpoint_chain
== bpt
)
5923 breakpoint_chain
= bpt
->next
;
5925 /* If we have callback-style exception catchpoints, don't go through
5926 the adjustments to the C++ runtime library etc. if the inferior
5927 isn't actually running. target_enable_exception_callback for a
5928 null target ops vector gives an undesirable error message, so we
5929 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5930 exceptions are supported in this way, it's OK for now. FIXME */
5931 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
5933 static char message1
[] = "Error in deleting catchpoint %d:\n";
5934 static char message
[sizeof (message1
) + 30];
5935 args_for_catchpoint_enable args
;
5937 /* Format possible error msg */
5938 sprintf (message
, message1
, bpt
->number
);
5939 args
.kind
= bpt
->type
== bp_catch_catch
?
5940 EX_EVENT_CATCH
: EX_EVENT_THROW
;
5942 catch_errors (cover_target_enable_exception_callback
, &args
,
5943 message
, RETURN_MASK_ALL
);
5950 b
->next
= bpt
->next
;
5954 /* Before turning off the visuals for the bp, check to see that
5955 there are no other bps at the same address. */
5962 clearIt
= (b
->address
!= bpt
->address
);
5969 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
5970 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
5974 check_duplicates (bpt
->address
, bpt
->section
);
5975 /* If this breakpoint was inserted, and there is another breakpoint
5976 at the same address, we need to insert the other breakpoint. */
5978 && bpt
->type
!= bp_hardware_watchpoint
5979 && bpt
->type
!= bp_read_watchpoint
5980 && bpt
->type
!= bp_access_watchpoint
5981 && bpt
->type
!= bp_catch_fork
5982 && bpt
->type
!= bp_catch_vfork
5983 && bpt
->type
!= bp_catch_exec
)
5986 if (b
->address
== bpt
->address
5987 && b
->section
== bpt
->section
5989 && b
->enable
!= disabled
5990 && b
->enable
!= shlib_disabled
5991 && b
->enable
!= call_disabled
)
5995 /* We should never reach this point if there is a permanent
5996 breakpoint at the same address as the one being deleted.
5997 If there is a permanent breakpoint somewhere, it should
5998 always be the only one inserted. */
5999 if (b
->enable
== permanent
)
6000 internal_error ("another breakpoint was inserted on top of "
6001 "a permanent breakpoint");
6003 if (b
->type
== bp_hardware_breakpoint
)
6004 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6006 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6010 target_terminal_ours_for_output ();
6011 warning ("Cannot insert breakpoint %d:", b
->number
);
6012 memory_error (val
, b
->address
); /* which bombs us out */
6019 free_command_lines (&bpt
->commands
);
6022 if (bpt
->cond_string
!= NULL
)
6023 free (bpt
->cond_string
);
6024 if (bpt
->addr_string
!= NULL
)
6025 free (bpt
->addr_string
);
6026 if (bpt
->exp
!= NULL
)
6028 if (bpt
->exp_string
!= NULL
)
6029 free (bpt
->exp_string
);
6030 if (bpt
->val
!= NULL
)
6031 value_free (bpt
->val
);
6032 if (bpt
->source_file
!= NULL
)
6033 free (bpt
->source_file
);
6034 if (bpt
->dll_pathname
!= NULL
)
6035 free (bpt
->dll_pathname
);
6036 if (bpt
->triggered_dll_pathname
!= NULL
)
6037 free (bpt
->triggered_dll_pathname
);
6038 if (bpt
->exec_pathname
!= NULL
)
6039 free (bpt
->exec_pathname
);
6041 /* Be sure no bpstat's are pointing at it after it's been freed. */
6042 /* FIXME, how can we find all bpstat's?
6043 We just check stop_bpstat for now. */
6044 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6045 if (bs
->breakpoint_at
== bpt
)
6047 bs
->breakpoint_at
= NULL
;
6049 /* we'd call bpstat_clear_actions, but that free's stuff and due
6050 to the multiple pointers pointing to one item with no
6051 reference counts found anywhere through out the bpstat's (how
6052 do you spell fragile?), we don't want to free things twice --
6053 better a memory leak than a corrupt malloc pool! */
6054 bs
->commands
= NULL
;
6057 /* On the chance that someone will soon try again to delete this same
6058 bp, we mark it as deleted before freeing its storage. */
6059 bpt
->type
= bp_none
;
6065 delete_command (arg
, from_tty
)
6069 struct breakpoint
*b
, *temp
;
6073 int breaks_to_delete
= 0;
6075 /* Delete all breakpoints if no argument.
6076 Do not delete internal or call-dummy breakpoints, these
6077 have to be deleted with an explicit breakpoint number argument. */
6080 if (b
->type
!= bp_call_dummy
&&
6081 b
->type
!= bp_shlib_event
&&
6083 breaks_to_delete
= 1;
6086 /* Ask user only if there are some breakpoints to delete. */
6088 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6090 ALL_BREAKPOINTS_SAFE (b
, temp
)
6092 if (b
->type
!= bp_call_dummy
&&
6093 b
->type
!= bp_shlib_event
&&
6095 delete_breakpoint (b
);
6100 map_breakpoint_numbers (arg
, delete_breakpoint
);
6103 /* Reset a breakpoint given it's struct breakpoint * BINT.
6104 The value we return ends up being the return value from catch_errors.
6105 Unused in this case. */
6108 breakpoint_re_set_one (bint
)
6111 /* get past catch_errs */
6112 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6115 struct symtabs_and_lines sals
;
6117 enum enable save_enable
;
6122 warning ("attempted to reset apparently deleted breakpoint #%d?",
6126 case bp_hardware_breakpoint
:
6128 case bp_catch_unload
:
6129 if (b
->addr_string
== NULL
)
6131 /* Anything without a string can't be re-set. */
6132 delete_breakpoint (b
);
6135 /* In case we have a problem, disable this breakpoint. We'll restore
6136 its status if we succeed. */
6137 save_enable
= b
->enable
;
6138 b
->enable
= disabled
;
6140 set_language (b
->language
);
6141 input_radix
= b
->input_radix
;
6143 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
6144 for (i
= 0; i
< sals
.nelts
; i
++)
6146 resolve_sal_pc (&sals
.sals
[i
]);
6148 /* Reparse conditions, they might contain references to the
6150 if (b
->cond_string
!= NULL
)
6154 free ((PTR
) b
->cond
);
6155 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
6158 /* We need to re-set the breakpoint if the address changes... */
6159 if (b
->address
!= sals
.sals
[i
].pc
6160 /* ...or new and old breakpoints both have source files, and
6161 the source file name or the line number changes... */
6162 || (b
->source_file
!= NULL
6163 && sals
.sals
[i
].symtab
!= NULL
6164 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
6165 || b
->line_number
!= sals
.sals
[i
].line
)
6167 /* ...or we switch between having a source file and not having
6169 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
6172 if (b
->source_file
!= NULL
)
6173 free (b
->source_file
);
6174 if (sals
.sals
[i
].symtab
== NULL
)
6175 b
->source_file
= NULL
;
6178 savestring (sals
.sals
[i
].symtab
->filename
,
6179 strlen (sals
.sals
[i
].symtab
->filename
));
6180 b
->line_number
= sals
.sals
[i
].line
;
6181 b
->address
= sals
.sals
[i
].pc
;
6183 /* Used to check for duplicates here, but that can
6184 cause trouble, as it doesn't check for disable
6189 /* Might be better to do this just once per breakpoint_re_set,
6190 rather than once for every breakpoint. */
6191 breakpoints_changed ();
6193 b
->section
= sals
.sals
[i
].section
;
6194 b
->enable
= save_enable
; /* Restore it, this worked. */
6197 /* Now that this is re-enabled, check_duplicates
6199 check_duplicates (b
->address
, b
->section
);
6202 free ((PTR
) sals
.sals
);
6206 case bp_hardware_watchpoint
:
6207 case bp_read_watchpoint
:
6208 case bp_access_watchpoint
:
6209 innermost_block
= NULL
;
6210 /* The issue arises of what context to evaluate this in. The
6211 same one as when it was set, but what does that mean when
6212 symbols have been re-read? We could save the filename and
6213 functionname, but if the context is more local than that, the
6214 best we could do would be something like how many levels deep
6215 and which index at that particular level, but that's going to
6216 be less stable than filenames or function names. */
6218 /* So for now, just use a global context. */
6220 free ((PTR
) b
->exp
);
6221 b
->exp
= parse_expression (b
->exp_string
);
6222 b
->exp_valid_block
= innermost_block
;
6223 mark
= value_mark ();
6225 value_free (b
->val
);
6226 b
->val
= evaluate_expression (b
->exp
);
6227 release_value (b
->val
);
6228 if (VALUE_LAZY (b
->val
))
6229 value_fetch_lazy (b
->val
);
6231 if (b
->cond_string
!= NULL
)
6235 free ((PTR
) b
->cond
);
6236 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
6238 if (b
->enable
== enabled
)
6240 value_free_to_mark (mark
);
6242 case bp_catch_catch
:
6243 case bp_catch_throw
:
6245 /* We needn't really do anything to reset these, since the mask
6246 that requests them is unaffected by e.g., new libraries being
6249 case bp_catch_vfork
:
6254 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
6256 /* Delete longjmp breakpoints, they will be reset later by
6257 breakpoint_re_set. */
6259 case bp_longjmp_resume
:
6260 delete_breakpoint (b
);
6263 /* This breakpoint is special, it's set up when the inferior
6264 starts and we really don't want to touch it. */
6265 case bp_shlib_event
:
6267 /* Keep temporary breakpoints, which can be encountered when we step
6268 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6269 Otherwise these should have been blown away via the cleanup chain
6270 or by breakpoint_init_inferior when we rerun the executable. */
6273 case bp_watchpoint_scope
:
6275 case bp_step_resume
:
6282 /* Re-set all breakpoints after symbols have been re-loaded. */
6284 breakpoint_re_set ()
6286 struct breakpoint
*b
, *temp
;
6287 enum language save_language
;
6288 int save_input_radix
;
6289 static char message1
[] = "Error in re-setting breakpoint %d:\n";
6290 char message
[sizeof (message1
) + 30 /* slop */ ];
6292 save_language
= current_language
->la_language
;
6293 save_input_radix
= input_radix
;
6294 ALL_BREAKPOINTS_SAFE (b
, temp
)
6296 /* Format possible error msg */
6297 sprintf (message
, message1
, b
->number
);
6298 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
6300 set_language (save_language
);
6301 input_radix
= save_input_radix
;
6303 #ifdef GET_LONGJMP_TARGET
6304 create_longjmp_breakpoint ("longjmp");
6305 create_longjmp_breakpoint ("_longjmp");
6306 create_longjmp_breakpoint ("siglongjmp");
6307 create_longjmp_breakpoint ("_siglongjmp");
6308 create_longjmp_breakpoint (NULL
);
6312 /* Took this out (temporarily at least), since it produces an extra
6313 blank line at startup. This messes up the gdbtests. -PB */
6314 /* Blank line to finish off all those mention() messages we just printed. */
6315 printf_filtered ("\n");
6319 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6320 If from_tty is nonzero, it prints a message to that effect,
6321 which ends with a period (no newline). */
6323 /* Reset the thread number of this breakpoint:
6325 - If the breakpoint is for all threads, leave it as-is.
6326 - Else, reset it to the current thread for inferior_pid. */
6328 breakpoint_re_set_thread (b
)
6329 struct breakpoint
*b
;
6331 if (b
->thread
!= -1)
6333 if (in_thread_list (inferior_pid
))
6334 b
->thread
= pid_to_thread_id (inferior_pid
);
6339 set_ignore_count (bptnum
, count
, from_tty
)
6340 int bptnum
, count
, from_tty
;
6342 register struct breakpoint
*b
;
6348 if (b
->number
== bptnum
)
6350 b
->ignore_count
= count
;
6353 else if (count
== 0)
6354 printf_filtered ("Will stop next time breakpoint %d is reached.",
6356 else if (count
== 1)
6357 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6360 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6362 breakpoints_changed ();
6366 error ("No breakpoint number %d.", bptnum
);
6369 /* Clear the ignore counts of all breakpoints. */
6371 breakpoint_clear_ignore_counts ()
6373 struct breakpoint
*b
;
6376 b
->ignore_count
= 0;
6379 /* Command to set ignore-count of breakpoint N to COUNT. */
6382 ignore_command (args
, from_tty
)
6390 error_no_arg ("a breakpoint number");
6392 num
= get_number (&p
);
6395 error ("Second argument (specified ignore-count) is missing.");
6397 set_ignore_count (num
,
6398 longest_to_int (value_as_long (parse_and_eval (p
))),
6400 printf_filtered ("\n");
6401 breakpoints_changed ();
6404 /* Call FUNCTION on each of the breakpoints
6405 whose numbers are given in ARGS. */
6408 map_breakpoint_numbers (args
, function
)
6410 void (*function
) PARAMS ((struct breakpoint
*));
6412 register char *p
= args
;
6415 register struct breakpoint
*b
;
6418 error_no_arg ("one or more breakpoint numbers");
6424 num
= get_number (&p1
);
6427 if (b
->number
== num
)
6429 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
6431 if (related_breakpoint
)
6432 function (related_breakpoint
);
6435 printf_unfiltered ("No breakpoint number %d.\n", num
);
6442 disable_breakpoint (bpt
)
6443 struct breakpoint
*bpt
;
6445 /* Never disable a watchpoint scope breakpoint; we want to
6446 hit them when we leave scope so we can delete both the
6447 watchpoint and its scope breakpoint at that time. */
6448 if (bpt
->type
== bp_watchpoint_scope
)
6451 /* You can't disable permanent breakpoints. */
6452 if (bpt
->enable
== permanent
)
6455 bpt
->enable
= disabled
;
6457 check_duplicates (bpt
->address
, bpt
->section
);
6459 if (modify_breakpoint_hook
)
6460 modify_breakpoint_hook (bpt
);
6461 breakpoint_modify_event (bpt
->number
);
6466 disable_command (args
, from_tty
)
6470 register struct breakpoint
*bpt
;
6472 ALL_BREAKPOINTS (bpt
)
6476 warning ("attempted to disable apparently deleted breakpoint #%d?",
6481 case bp_catch_unload
:
6483 case bp_catch_vfork
:
6485 case bp_catch_catch
:
6486 case bp_catch_throw
:
6487 case bp_hardware_breakpoint
:
6489 case bp_hardware_watchpoint
:
6490 case bp_read_watchpoint
:
6491 case bp_access_watchpoint
:
6492 disable_breakpoint (bpt
);
6497 map_breakpoint_numbers (args
, disable_breakpoint
);
6501 do_enable_breakpoint (bpt
, disposition
)
6502 struct breakpoint
*bpt
;
6503 enum bpdisp disposition
;
6505 struct frame_info
*save_selected_frame
= NULL
;
6506 int save_selected_frame_level
= -1;
6507 int target_resources_ok
, other_type_used
;
6510 if (bpt
->type
== bp_hardware_breakpoint
)
6513 i
= hw_breakpoint_used_count ();
6514 target_resources_ok
=
6515 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
6517 if (target_resources_ok
== 0)
6518 error ("No hardware breakpoint support in the target.");
6519 else if (target_resources_ok
< 0)
6520 error ("Hardware breakpoints used exceeds limit.");
6523 if (bpt
->enable
!= permanent
)
6524 bpt
->enable
= enabled
;
6525 bpt
->disposition
= disposition
;
6526 check_duplicates (bpt
->address
, bpt
->section
);
6527 breakpoints_changed ();
6529 if (bpt
->type
== bp_watchpoint
||
6530 bpt
->type
== bp_hardware_watchpoint
||
6531 bpt
->type
== bp_read_watchpoint
||
6532 bpt
->type
== bp_access_watchpoint
)
6534 if (bpt
->exp_valid_block
!= NULL
)
6536 struct frame_info
*fr
=
6538 /* Ensure that we have the current frame. Else, this
6539 next query may pessimistically be answered as, "No,
6540 not within current scope". */
6541 get_current_frame ();
6542 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
6546 Cannot enable watchpoint %d because the block in which its expression\n\
6547 is valid is not currently in scope.\n", bpt
->number
);
6548 bpt
->enable
= disabled
;
6552 save_selected_frame
= selected_frame
;
6553 save_selected_frame_level
= selected_frame_level
;
6554 select_frame (fr
, -1);
6557 value_free (bpt
->val
);
6558 mark
= value_mark ();
6559 bpt
->val
= evaluate_expression (bpt
->exp
);
6560 release_value (bpt
->val
);
6561 if (VALUE_LAZY (bpt
->val
))
6562 value_fetch_lazy (bpt
->val
);
6564 if (bpt
->type
== bp_hardware_watchpoint
||
6565 bpt
->type
== bp_read_watchpoint
||
6566 bpt
->type
== bp_access_watchpoint
)
6568 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
6569 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
6571 /* Hack around 'unused var' error for some targets here */
6573 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6574 bpt
->type
, i
+ mem_cnt
, other_type_used
);
6575 /* we can consider of type is bp_hardware_watchpoint, convert to
6576 bp_watchpoint in the following condition */
6577 if (target_resources_ok
< 0)
6580 Cannot enable watchpoint %d because target watch resources\n\
6581 have been allocated for other watchpoints.\n", bpt
->number
);
6582 bpt
->enable
= disabled
;
6583 value_free_to_mark (mark
);
6588 if (save_selected_frame_level
>= 0)
6589 select_and_print_frame (save_selected_frame
,
6590 save_selected_frame_level
);
6591 value_free_to_mark (mark
);
6593 if (modify_breakpoint_hook
)
6594 modify_breakpoint_hook (bpt
);
6595 breakpoint_modify_event (bpt
->number
);
6599 enable_breakpoint (bpt
)
6600 struct breakpoint
*bpt
;
6602 do_enable_breakpoint (bpt
, bpt
->disposition
);
6605 /* The enable command enables the specified breakpoints (or all defined
6606 breakpoints) so they once again become (or continue to be) effective
6607 in stopping the inferior. */
6611 enable_command (args
, from_tty
)
6615 register struct breakpoint
*bpt
;
6617 ALL_BREAKPOINTS (bpt
)
6621 warning ("attempted to enable apparently deleted breakpoint #%d?",
6626 case bp_catch_unload
:
6628 case bp_catch_vfork
:
6630 case bp_catch_catch
:
6631 case bp_catch_throw
:
6632 case bp_hardware_breakpoint
:
6634 case bp_hardware_watchpoint
:
6635 case bp_read_watchpoint
:
6636 case bp_access_watchpoint
:
6637 enable_breakpoint (bpt
);
6642 map_breakpoint_numbers (args
, enable_breakpoint
);
6646 enable_once_breakpoint (bpt
)
6647 struct breakpoint
*bpt
;
6649 do_enable_breakpoint (bpt
, disable
);
6654 enable_once_command (args
, from_tty
)
6658 map_breakpoint_numbers (args
, enable_once_breakpoint
);
6662 enable_delete_breakpoint (bpt
)
6663 struct breakpoint
*bpt
;
6665 do_enable_breakpoint (bpt
, del
);
6670 enable_delete_command (args
, from_tty
)
6674 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
6677 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6679 struct symtabs_and_lines
6680 decode_line_spec_1 (string
, funfirstline
)
6684 struct symtabs_and_lines sals
;
6686 error ("Empty line specification.");
6687 if (default_breakpoint_valid
)
6688 sals
= decode_line_1 (&string
, funfirstline
,
6689 default_breakpoint_symtab
,
6690 default_breakpoint_line
,
6693 sals
= decode_line_1 (&string
, funfirstline
,
6694 (struct symtab
*) NULL
, 0, (char ***) NULL
);
6696 error ("Junk at end of line specification: %s", string
);
6701 _initialize_breakpoint ()
6703 struct cmd_list_element
*c
;
6705 breakpoint_chain
= 0;
6706 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6707 before a breakpoint is set. */
6708 breakpoint_count
= 0;
6710 add_com ("ignore", class_breakpoint
, ignore_command
,
6711 "Set ignore-count of breakpoint number N to COUNT.\n\
6712 Usage is `ignore N COUNT'.");
6714 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
6716 add_com ("commands", class_breakpoint
, commands_command
,
6717 "Set commands to be executed when a breakpoint is hit.\n\
6718 Give breakpoint number as argument after \"commands\".\n\
6719 With no argument, the targeted breakpoint is the last one set.\n\
6720 The commands themselves follow starting on the next line.\n\
6721 Type a line containing \"end\" to indicate the end of them.\n\
6722 Give \"silent\" as the first line to make the breakpoint silent;\n\
6723 then no output is printed when it is hit, except what the commands print.");
6725 add_com ("condition", class_breakpoint
, condition_command
,
6726 "Specify breakpoint number N to break only if COND is true.\n\
6727 Usage is `condition N COND', where N is an integer and COND is an\n\
6728 expression to be evaluated whenever breakpoint N is reached. ");
6730 add_com ("tbreak", class_breakpoint
, tbreak_command
,
6731 "Set a temporary breakpoint. Args like \"break\" command.\n\
6732 Like \"break\" except the breakpoint is only temporary,\n\
6733 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6734 by using \"enable delete\" on the breakpoint number.");
6735 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
6736 "Set temporary breakpoint at procedure exit. Either there should\n\
6737 be no argument or the argument must be a depth.\n");
6739 add_com ("hbreak", class_breakpoint
, hbreak_command
,
6740 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6741 Like \"break\" except the breakpoint requires hardware support,\n\
6742 some target hardware may not have this support.");
6744 add_com ("thbreak", class_breakpoint
, thbreak_command
,
6745 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6746 Like \"hbreak\" except the breakpoint is only temporary,\n\
6747 so it will be deleted when hit.");
6749 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
6750 "Enable some breakpoints.\n\
6751 Give breakpoint numbers (separated by spaces) as arguments.\n\
6752 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6753 This is used to cancel the effect of the \"disable\" command.\n\
6754 With a subcommand you can enable temporarily.",
6755 &enablelist
, "enable ", 1, &cmdlist
);
6757 add_com ("ab", class_breakpoint
, enable_command
,
6758 "Enable some breakpoints.\n\
6759 Give breakpoint numbers (separated by spaces) as arguments.\n\
6760 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6761 This is used to cancel the effect of the \"disable\" command.\n\
6762 With a subcommand you can enable temporarily.");
6764 add_com_alias ("en", "enable", class_breakpoint
, 1);
6766 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
6767 "Enable some breakpoints.\n\
6768 Give breakpoint numbers (separated by spaces) as arguments.\n\
6769 This is used to cancel the effect of the \"disable\" command.\n\
6770 May be abbreviated to simply \"enable\".\n",
6771 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
6773 add_cmd ("once", no_class
, enable_once_command
,
6774 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6775 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6778 add_cmd ("delete", no_class
, enable_delete_command
,
6779 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6780 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6783 add_cmd ("delete", no_class
, enable_delete_command
,
6784 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6785 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6788 add_cmd ("once", no_class
, enable_once_command
,
6789 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6790 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6793 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
6794 "Disable some breakpoints.\n\
6795 Arguments are breakpoint numbers with spaces in between.\n\
6796 To disable all breakpoints, give no argument.\n\
6797 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6798 &disablelist
, "disable ", 1, &cmdlist
);
6799 add_com_alias ("dis", "disable", class_breakpoint
, 1);
6800 add_com_alias ("disa", "disable", class_breakpoint
, 1);
6802 add_com ("sb", class_breakpoint
, disable_command
,
6803 "Disable some breakpoints.\n\
6804 Arguments are breakpoint numbers with spaces in between.\n\
6805 To disable all breakpoints, give no argument.\n\
6806 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6808 add_cmd ("breakpoints", class_alias
, disable_command
,
6809 "Disable some breakpoints.\n\
6810 Arguments are breakpoint numbers with spaces in between.\n\
6811 To disable all breakpoints, give no argument.\n\
6812 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6813 This command may be abbreviated \"disable\".",
6816 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
6817 "Delete some breakpoints or auto-display expressions.\n\
6818 Arguments are breakpoint numbers with spaces in between.\n\
6819 To delete all breakpoints, give no argument.\n\
6821 Also a prefix command for deletion of other GDB objects.\n\
6822 The \"unset\" command is also an alias for \"delete\".",
6823 &deletelist
, "delete ", 1, &cmdlist
);
6824 add_com_alias ("d", "delete", class_breakpoint
, 1);
6826 add_com ("db", class_breakpoint
, delete_command
,
6827 "Delete some breakpoints.\n\
6828 Arguments are breakpoint numbers with spaces in between.\n\
6829 To delete all breakpoints, give no argument.\n");
6831 add_cmd ("breakpoints", class_alias
, delete_command
,
6832 "Delete some breakpoints or auto-display expressions.\n\
6833 Arguments are breakpoint numbers with spaces in between.\n\
6834 To delete all breakpoints, give no argument.\n\
6835 This command may be abbreviated \"delete\".",
6838 add_com ("clear", class_breakpoint
, clear_command
,
6839 concat ("Clear breakpoint at specified line or function.\n\
6840 Argument may be line number, function name, or \"*\" and an address.\n\
6841 If line number is specified, all breakpoints in that line are cleared.\n\
6842 If function is specified, breakpoints at beginning of function are cleared.\n\
6843 If an address is specified, breakpoints at that address are cleared.\n\n",
6844 "With no argument, clears all breakpoints in the line that the selected frame\n\
6847 See also the \"delete\" command which clears breakpoints by number.", NULL
));
6849 add_com ("break", class_breakpoint
, break_command
,
6850 concat ("Set breakpoint at specified line or function.\n\
6851 Argument may be line number, function name, or \"*\" and an address.\n\
6852 If line number is specified, break at start of code for that line.\n\
6853 If function is specified, break at start of code for that function.\n\
6854 If an address is specified, break at that exact address.\n",
6855 "With no arg, uses current execution address of selected stack frame.\n\
6856 This is useful for breaking on return to a stack frame.\n\
6858 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6860 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6861 add_com_alias ("b", "break", class_run
, 1);
6862 add_com_alias ("br", "break", class_run
, 1);
6863 add_com_alias ("bre", "break", class_run
, 1);
6864 add_com_alias ("brea", "break", class_run
, 1);
6866 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
6867 concat ("Set breakpoint at procedure exit. \n\
6868 Argument may be function name, or \"*\" and an address.\n\
6869 If function is specified, break at end of code for that function.\n\
6870 If an address is specified, break at the end of the function that contains \n\
6871 that exact address.\n",
6872 "With no arg, uses current execution address of selected stack frame.\n\
6873 This is useful for breaking on return to a stack frame.\n\
6875 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6877 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6878 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
6879 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
6880 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
6881 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
6885 add_com_alias ("ba", "break", class_breakpoint
, 1);
6886 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
6887 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
6888 "Set breakpoint at procedure exit. Either there should\n\
6889 be no argument or the argument must be a depth.\n");
6894 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
6895 "Break in function/address or break at a line in the current file.",
6896 &stoplist
, "stop ", 1, &cmdlist
);
6897 add_cmd ("in", class_breakpoint
, stopin_command
,
6898 "Break in function or address.\n", &stoplist
);
6899 add_cmd ("at", class_breakpoint
, stopat_command
,
6900 "Break at a line in the current file.\n", &stoplist
);
6901 add_com ("status", class_info
, breakpoints_info
,
6902 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6903 The \"Type\" column indicates one of:\n\
6904 \tbreakpoint - normal breakpoint\n\
6905 \twatchpoint - watchpoint\n\
6906 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6907 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6908 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6909 address and file/line number respectively.\n\n",
6910 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6911 are set to the address of the last breakpoint listed.\n\n\
6912 Convenience variable \"$bpnum\" contains the number of the last\n\
6913 breakpoint set.", NULL
));
6916 add_info ("breakpoints", breakpoints_info
,
6917 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6918 The \"Type\" column indicates one of:\n\
6919 \tbreakpoint - normal breakpoint\n\
6920 \twatchpoint - watchpoint\n\
6921 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6922 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6923 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6924 address and file/line number respectively.\n\n",
6925 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6926 are set to the address of the last breakpoint listed.\n\n\
6927 Convenience variable \"$bpnum\" contains the number of the last\n\
6928 breakpoint set.", NULL
));
6931 add_com ("lb", class_breakpoint
, breakpoints_info
,
6932 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6933 The \"Type\" column indicates one of:\n\
6934 \tbreakpoint - normal breakpoint\n\
6935 \twatchpoint - watchpoint\n\
6936 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6937 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6938 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6939 address and file/line number respectively.\n\n",
6940 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6941 are set to the address of the last breakpoint listed.\n\n\
6942 Convenience variable \"$bpnum\" contains the number of the last\n\
6943 breakpoint set.", NULL
));
6945 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
6946 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6947 The \"Type\" column indicates one of:\n\
6948 \tbreakpoint - normal breakpoint\n\
6949 \twatchpoint - watchpoint\n\
6950 \tlongjmp - internal breakpoint used to step through longjmp()\n\
6951 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
6952 \tuntil - internal breakpoint used by the \"until\" command\n\
6953 \tfinish - internal breakpoint used by the \"finish\" command\n",
6954 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6955 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6956 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6957 address and file/line number respectively.\n\n",
6958 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6959 are set to the address of the last breakpoint listed.\n\n\
6960 Convenience variable \"$bpnum\" contains the number of the last\n\
6961 breakpoint set.", NULL
),
6962 &maintenanceinfolist
);
6964 add_com ("catch", class_breakpoint
, catch_command
,
6965 "Set catchpoints to catch events.\n\
6966 Raised signals may be caught:\n\
6967 \tcatch signal - all signals\n\
6968 \tcatch signal <signame> - a particular signal\n\
6969 Raised exceptions may be caught:\n\
6970 \tcatch throw - all exceptions, when thrown\n\
6971 \tcatch throw <exceptname> - a particular exception, when thrown\n\
6972 \tcatch catch - all exceptions, when caught\n\
6973 \tcatch catch <exceptname> - a particular exception, when caught\n\
6974 Thread or process events may be caught:\n\
6975 \tcatch thread_start - any threads, just after creation\n\
6976 \tcatch thread_exit - any threads, just before expiration\n\
6977 \tcatch thread_join - any threads, just after joins\n\
6978 Process events may be caught:\n\
6979 \tcatch start - any processes, just after creation\n\
6980 \tcatch exit - any processes, just before expiration\n\
6981 \tcatch fork - calls to fork()\n\
6982 \tcatch vfork - calls to vfork()\n\
6983 \tcatch exec - calls to exec()\n\
6984 Dynamically-linked library events may be caught:\n\
6985 \tcatch load - loads of any library\n\
6986 \tcatch load <libname> - loads of a particular library\n\
6987 \tcatch unload - unloads of any library\n\
6988 \tcatch unload <libname> - unloads of a particular library\n\
6989 The act of your program's execution stopping may also be caught:\n\
6991 C++ exceptions may be caught:\n\
6992 \tcatch throw - all exceptions, when thrown\n\
6993 \tcatch catch - all exceptions, when caught\n\
6995 Do \"help set follow-fork-mode\" for info on debugging your program\n\
6996 after a fork or vfork is caught.\n\n\
6997 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
6999 add_com ("tcatch", class_breakpoint
, tcatch_command
,
7000 "Set temporary catchpoints to catch events.\n\
7001 Args like \"catch\" command.\n\
7002 Like \"catch\" except the catchpoint is only temporary,\n\
7003 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7004 by using \"enable delete\" on the catchpoint number.");
7006 add_com ("watch", class_breakpoint
, watch_command
,
7007 "Set a watchpoint for an expression.\n\
7008 A watchpoint stops execution of your program whenever the value of\n\
7009 an expression changes.");
7011 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7012 "Set a read watchpoint for an expression.\n\
7013 A watchpoint stops execution of your program whenever the value of\n\
7014 an expression is read.");
7016 add_com ("awatch", class_breakpoint
, awatch_command
,
7017 "Set a watchpoint for an expression.\n\
7018 A watchpoint stops execution of your program whenever the value of\n\
7019 an expression is either read or written.");
7021 add_info ("watchpoints", breakpoints_info
,
7022 "Synonym for ``info breakpoints''.");
7025 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7026 (char *) &can_use_hw_watchpoints
,
7027 "Set debugger's willingness to use watchpoint hardware.\n\
7028 If zero, gdb will not use hardware for new watchpoints, even if\n\
7029 such is available. (However, any hardware watchpoints that were\n\
7030 created before setting this to nonzero, will continue to use watchpoint\n\
7033 add_show_from_set (c
, &showlist
);
7035 can_use_hw_watchpoints
= 1;