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
)
860 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
861 len
= TYPE_LENGTH (VALUE_TYPE (v
));
863 if (b
->type
== bp_read_watchpoint
)
865 else if (b
->type
== bp_access_watchpoint
)
868 val
= target_insert_watchpoint (addr
, len
, type
);
877 /* Failure to insert a watchpoint on any memory value in the
878 value chain brings us here. */
881 remove_breakpoint (b
, mark_uninserted
);
882 warning ("Could not insert hardware watchpoint %d.",
889 printf_filtered ("Hardware watchpoint %d deleted", b
->number
);
890 printf_filtered ("because the program has left the block \n");
891 printf_filtered ("in which its expression is valid.\n");
892 if (b
->related_breakpoint
)
893 b
->related_breakpoint
->disposition
= del_at_next_stop
;
894 b
->disposition
= del_at_next_stop
;
897 /* Restore the frame and level. */
898 if ((saved_frame
!= selected_frame
) ||
899 (saved_level
!= selected_frame_level
))
900 select_and_print_frame (saved_frame
, saved_level
);
903 return_val
= val
; /* remember failure */
905 else if ((b
->type
== bp_catch_fork
906 || b
->type
== bp_catch_vfork
907 || b
->type
== bp_catch_exec
)
908 && b
->enable
== enabled
916 val
= target_insert_fork_catchpoint (inferior_pid
);
919 val
= target_insert_vfork_catchpoint (inferior_pid
);
922 val
= target_insert_exec_catchpoint (inferior_pid
);
925 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
930 target_terminal_ours_for_output ();
931 warning ("Cannot insert catchpoint %d.", b
->number
);
937 return_val
= val
; /* remember failure */
946 remove_breakpoints ()
948 register struct breakpoint
*b
;
955 val
= remove_breakpoint (b
, mark_uninserted
);
964 reattach_breakpoints (pid
)
967 register struct breakpoint
*b
;
969 int saved_inferior_pid
= inferior_pid
;
971 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
972 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
977 remove_breakpoint (b
, mark_inserted
);
978 if (b
->type
== bp_hardware_breakpoint
)
979 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
981 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
984 inferior_pid
= saved_inferior_pid
;
989 inferior_pid
= saved_inferior_pid
;
994 update_breakpoints_after_exec ()
996 struct breakpoint
*b
;
997 struct breakpoint
*temp
;
999 /* Doing this first prevents the badness of having delete_breakpoint()
1000 write a breakpoint's current "shadow contents" to lift the bp. That
1001 shadow is NOT valid after an exec()! */
1002 mark_breakpoints_out ();
1004 ALL_BREAKPOINTS_SAFE (b
, temp
)
1006 /* Solib breakpoints must be explicitly reset after an exec(). */
1007 if (b
->type
== bp_shlib_event
)
1009 delete_breakpoint (b
);
1013 /* Step-resume breakpoints are meaningless after an exec(). */
1014 if (b
->type
== bp_step_resume
)
1016 delete_breakpoint (b
);
1020 /* Ditto the sigtramp handler breakpoints. */
1021 if (b
->type
== bp_through_sigtramp
)
1023 delete_breakpoint (b
);
1027 /* Ditto the exception-handling catchpoints. */
1028 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1030 delete_breakpoint (b
);
1034 /* Don't delete an exec catchpoint, because else the inferior
1035 won't stop when it ought!
1037 Similarly, we probably ought to keep vfork catchpoints, 'cause
1038 on this target, we may not be able to stop when the vfork is
1039 seen, but only when the subsequent exec is seen. (And because
1040 deleting fork catchpoints here but not vfork catchpoints will
1041 seem mysterious to users, keep those too.)
1043 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1044 target address field, if any, is sufficient to have it be reset
1045 automagically. Certainly on HP-UX that's true. */
1046 if ((b
->type
== bp_catch_exec
) ||
1047 (b
->type
== bp_catch_vfork
) ||
1048 (b
->type
== bp_catch_fork
))
1050 b
->address
= (CORE_ADDR
) NULL
;
1054 /* bp_finish is a special case. The only way we ought to be able
1055 to see one of these when an exec() has happened, is if the user
1056 caught a vfork, and then said "finish". Ordinarily a finish just
1057 carries them to the call-site of the current callee, by setting
1058 a temporary bp there and resuming. But in this case, the finish
1059 will carry them entirely through the vfork & exec.
1061 We don't want to allow a bp_finish to remain inserted now. But
1062 we can't safely delete it, 'cause finish_command has a handle to
1063 the bp on a bpstat, and will later want to delete it. There's a
1064 chance (and I've seen it happen) that if we delete the bp_finish
1065 here, that its storage will get reused by the time finish_command
1066 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1067 We really must allow finish_command to delete a bp_finish.
1069 In the absense of a general solution for the "how do we know
1070 it's safe to delete something others may have handles to?"
1071 problem, what we'll do here is just uninsert the bp_finish, and
1072 let finish_command delete it.
1074 (We know the bp_finish is "doomed" in the sense that it's
1075 momentary, and will be deleted as soon as finish_command sees
1076 the inferior stopped. So it doesn't matter that the bp's
1077 address is probably bogus in the new a.out, unlike e.g., the
1078 solib breakpoints.) */
1080 if (b
->type
== bp_finish
)
1085 /* Without a symbolic address, we have little hope of the
1086 pre-exec() address meaning the same thing in the post-exec()
1088 if (b
->addr_string
== NULL
)
1090 delete_breakpoint (b
);
1094 /* If this breakpoint has survived the above battery of checks, then
1095 it must have a symbolic address. Be sure that it gets reevaluated
1096 to a target address, rather than reusing the old evaluation. */
1097 b
->address
= (CORE_ADDR
) NULL
;
1102 detach_breakpoints (pid
)
1105 register struct breakpoint
*b
;
1107 int saved_inferior_pid
= inferior_pid
;
1109 if (pid
== inferior_pid
)
1110 error ("Cannot detach breakpoints of inferior_pid");
1112 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1113 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1118 val
= remove_breakpoint (b
, mark_inserted
);
1121 inferior_pid
= saved_inferior_pid
;
1126 inferior_pid
= saved_inferior_pid
;
1131 remove_breakpoint (b
, is
)
1132 struct breakpoint
*b
;
1133 insertion_state_t is
;
1137 if (b
->enable
== permanent
)
1138 /* Permanent breakpoints cannot be inserted or removed. */
1141 if (b
->type
== bp_none
)
1142 warning ("attempted to remove apparently deleted breakpoint #%d?",
1145 if (b
->type
!= bp_watchpoint
1146 && b
->type
!= bp_hardware_watchpoint
1147 && b
->type
!= bp_read_watchpoint
1148 && b
->type
!= bp_access_watchpoint
1149 && b
->type
!= bp_catch_fork
1150 && b
->type
!= bp_catch_vfork
1151 && b
->type
!= bp_catch_exec
1152 && b
->type
!= bp_catch_catch
1153 && b
->type
!= bp_catch_throw
)
1155 if (b
->type
== bp_hardware_breakpoint
)
1156 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1159 /* Check to see if breakpoint is in an overlay section;
1160 if so, we should remove the breakpoint at the LMA address.
1161 If that is not equal to the raw address, then we should
1162 presumable remove the breakpoint there as well. */
1163 if (overlay_debugging
&& b
->section
&&
1164 section_is_overlay (b
->section
))
1168 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1169 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1170 /* This would be the time to check val, to see if the
1171 shadow breakpoint write to the load address succeeded.
1172 However, this might be an ordinary occurrance, eg. if
1173 the unmapped overlay is in ROM. */
1174 val
= 0; /* in case unmapped address failed */
1175 if (section_is_mapped (b
->section
))
1176 val
= target_remove_breakpoint (b
->address
,
1177 b
->shadow_contents
);
1179 else /* ordinary (non-overlay) address */
1180 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1184 b
->inserted
= (is
== mark_inserted
);
1186 else if ((b
->type
== bp_hardware_watchpoint
||
1187 b
->type
== bp_read_watchpoint
||
1188 b
->type
== bp_access_watchpoint
)
1189 && b
->enable
== enabled
1194 b
->inserted
= (is
== mark_inserted
);
1195 /* Walk down the saved value chain. */
1196 for (v
= b
->val_chain
; v
; v
= v
->next
)
1198 /* For each memory reference remove the watchpoint
1200 if (v
->lval
== lval_memory
)
1202 int addr
, len
, type
;
1204 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1205 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1207 if (b
->type
== bp_read_watchpoint
)
1209 else if (b
->type
== bp_access_watchpoint
)
1212 val
= target_remove_watchpoint (addr
, len
, type
);
1218 /* Failure to remove any of the hardware watchpoints comes here. */
1219 if ((is
== mark_uninserted
) && (b
->inserted
))
1220 warning ("Could not remove hardware watchpoint %d.",
1223 /* Free the saved value chain. We will construct a new one
1224 the next time the watchpoint is inserted. */
1225 for (v
= b
->val_chain
; v
; v
= n
)
1230 b
->val_chain
= NULL
;
1232 else if ((b
->type
== bp_catch_fork
||
1233 b
->type
== bp_catch_vfork
||
1234 b
->type
== bp_catch_exec
)
1235 && b
->enable
== enabled
1242 val
= target_remove_fork_catchpoint (inferior_pid
);
1244 case bp_catch_vfork
:
1245 val
= target_remove_vfork_catchpoint (inferior_pid
);
1248 val
= target_remove_exec_catchpoint (inferior_pid
);
1251 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1256 b
->inserted
= (is
== mark_inserted
);
1258 else if ((b
->type
== bp_catch_catch
||
1259 b
->type
== bp_catch_throw
)
1260 && b
->enable
== enabled
1264 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1267 b
->inserted
= (is
== mark_inserted
);
1269 else if (ep_is_exception_catchpoint (b
)
1270 && b
->inserted
/* sometimes previous insert doesn't happen */
1271 && b
->enable
== enabled
1275 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1279 b
->inserted
= (is
== mark_inserted
);
1285 /* Clear the "inserted" flag in all breakpoints. */
1288 mark_breakpoints_out ()
1290 register struct breakpoint
*b
;
1296 /* Clear the "inserted" flag in all breakpoints and delete any
1297 breakpoints which should go away between runs of the program.
1299 Plus other such housekeeping that has to be done for breakpoints
1302 Note: this function gets called at the end of a run (by
1303 generic_mourn_inferior) and when a run begins (by
1304 init_wait_for_inferior). */
1309 breakpoint_init_inferior (context
)
1310 enum inf_context context
;
1312 register struct breakpoint
*b
, *temp
;
1313 static int warning_needed
= 0;
1315 ALL_BREAKPOINTS_SAFE (b
, temp
)
1322 case bp_watchpoint_scope
:
1324 /* If the call dummy breakpoint is at the entry point it will
1325 cause problems when the inferior is rerun, so we better
1328 Also get rid of scope breakpoints. */
1329 delete_breakpoint (b
);
1333 case bp_hardware_watchpoint
:
1334 case bp_read_watchpoint
:
1335 case bp_access_watchpoint
:
1337 /* Likewise for watchpoints on local expressions. */
1338 if (b
->exp_valid_block
!= NULL
)
1339 delete_breakpoint (b
);
1342 /* Likewise for exception catchpoints in dynamic-linked
1343 executables where required */
1344 if (ep_is_exception_catchpoint (b
) &&
1345 exception_catchpoints_are_fragile
)
1348 delete_breakpoint (b
);
1354 if (exception_catchpoints_are_fragile
)
1355 exception_support_initialized
= 0;
1357 /* Don't issue the warning unless it's really needed... */
1358 if (warning_needed
&& (context
!= inf_exited
))
1360 warning ("Exception catchpoints from last run were deleted.");
1361 warning ("You must reinsert them explicitly.");
1366 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1367 exists at PC. It returns ordinary_breakpoint_here if it's an
1368 ordinary breakpoint, or permanent_breakpoint_here if it's a
1369 permanent breakpoint.
1370 - When continuing from a location with an ordinary breakpoint, we
1371 actually single step once before calling insert_breakpoints.
1372 - When continuing from a localion with a permanent breakpoint, we
1373 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1374 the target, to advance the PC past the breakpoint. */
1376 enum breakpoint_here
1377 breakpoint_here_p (pc
)
1380 register struct breakpoint
*b
;
1381 int any_breakpoint_here
= 0;
1384 if ((b
->enable
== enabled
1385 || b
->enable
== permanent
)
1386 && b
->address
== pc
) /* bp is enabled and matches pc */
1388 if (overlay_debugging
&&
1389 section_is_overlay (b
->section
) &&
1390 !section_is_mapped (b
->section
))
1391 continue; /* unmapped overlay -- can't be a match */
1392 else if (b
->enable
== permanent
)
1393 return permanent_breakpoint_here
;
1395 any_breakpoint_here
= 1;
1398 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1402 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1403 but it only returns true if there is actually a breakpoint inserted
1407 breakpoint_inserted_here_p (pc
)
1410 register struct breakpoint
*b
;
1414 && b
->address
== pc
) /* bp is inserted and matches pc */
1416 if (overlay_debugging
&&
1417 section_is_overlay (b
->section
) &&
1418 !section_is_mapped (b
->section
))
1419 continue; /* unmapped overlay -- can't be a match */
1427 /* Return nonzero if FRAME is a dummy frame. We can't use
1428 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1429 much time, at least using get_saved_register on the 68k. This
1430 means that for this function to work right a port must use the
1431 bp_call_dummy breakpoint. */
1434 frame_in_dummy (frame
)
1435 struct frame_info
*frame
;
1437 struct breakpoint
*b
;
1442 if (USE_GENERIC_DUMMY_FRAMES
)
1443 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1447 if (b
->type
== bp_call_dummy
1448 && b
->frame
== frame
->frame
1449 /* We need to check the PC as well as the frame on the sparc,
1450 for signals.exp in the testsuite. */
1453 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1454 && frame
->pc
<= b
->address
)
1460 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1461 is valid for process/thread PID. */
1464 breakpoint_thread_match (pc
, pid
)
1468 struct breakpoint
*b
;
1471 thread
= pid_to_thread_id (pid
);
1474 if (b
->enable
!= disabled
1475 && b
->enable
!= shlib_disabled
1476 && b
->enable
!= call_disabled
1478 && (b
->thread
== -1 || b
->thread
== thread
))
1480 if (overlay_debugging
&&
1481 section_is_overlay (b
->section
) &&
1482 !section_is_mapped (b
->section
))
1483 continue; /* unmapped overlay -- can't be a match */
1492 /* bpstat stuff. External routines' interfaces are documented
1496 ep_is_catchpoint (ep
)
1497 struct breakpoint
*ep
;
1500 (ep
->type
== bp_catch_load
)
1501 || (ep
->type
== bp_catch_unload
)
1502 || (ep
->type
== bp_catch_fork
)
1503 || (ep
->type
== bp_catch_vfork
)
1504 || (ep
->type
== bp_catch_exec
)
1505 || (ep
->type
== bp_catch_catch
)
1506 || (ep
->type
== bp_catch_throw
)
1509 /* ??rehrauer: Add more kinds here, as are implemented... */
1514 ep_is_shlib_catchpoint (ep
)
1515 struct breakpoint
*ep
;
1518 (ep
->type
== bp_catch_load
)
1519 || (ep
->type
== bp_catch_unload
)
1524 ep_is_exception_catchpoint (ep
)
1525 struct breakpoint
*ep
;
1528 (ep
->type
== bp_catch_catch
)
1529 || (ep
->type
== bp_catch_throw
)
1533 /* Clear a bpstat so that it says we are not at any breakpoint.
1534 Also free any storage that is part of a bpstat. */
1549 if (p
->old_val
!= NULL
)
1550 value_free (p
->old_val
);
1557 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1558 is part of the bpstat is copied as well. */
1566 bpstat retval
= NULL
;
1571 for (; bs
!= NULL
; bs
= bs
->next
)
1573 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1574 memcpy (tmp
, bs
, sizeof (*tmp
));
1576 /* This is the first thing in the chain. */
1586 /* Find the bpstat associated with this breakpoint */
1589 bpstat_find_breakpoint (bsp
, breakpoint
)
1591 struct breakpoint
*breakpoint
;
1596 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1598 if (bsp
->breakpoint_at
== breakpoint
)
1604 /* Find a step_resume breakpoint associated with this bpstat.
1605 (If there are multiple step_resume bp's on the list, this function
1606 will arbitrarily pick one.)
1608 It is an error to use this function if BPSTAT doesn't contain a
1609 step_resume breakpoint.
1611 See wait_for_inferior's use of this function. */
1613 bpstat_find_step_resume_breakpoint (bsp
)
1617 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1619 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1621 if ((bsp
->breakpoint_at
!= NULL
) &&
1622 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1623 return bsp
->breakpoint_at
;
1626 error ("Internal error (no step_resume breakpoint found)");
1630 /* Return the breakpoint number of the first breakpoint we are stopped
1631 at. *BSP upon return is a bpstat which points to the remaining
1632 breakpoints stopped at (but which is not guaranteed to be good for
1633 anything but further calls to bpstat_num).
1634 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1640 struct breakpoint
*b
;
1643 return 0; /* No more breakpoint values */
1646 b
= (*bsp
)->breakpoint_at
;
1647 *bsp
= (*bsp
)->next
;
1649 return -1; /* breakpoint that's been deleted since */
1651 return b
->number
; /* We have its number */
1655 /* Modify BS so that the actions will not be performed. */
1658 bpstat_clear_actions (bs
)
1661 for (; bs
!= NULL
; bs
= bs
->next
)
1663 bs
->commands
= NULL
;
1664 if (bs
->old_val
!= NULL
)
1666 value_free (bs
->old_val
);
1672 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1675 cleanup_executing_breakpoints (ignore
)
1678 executing_breakpoint_commands
= 0;
1681 /* Execute all the commands associated with all the breakpoints at this
1682 location. Any of these commands could cause the process to proceed
1683 beyond this point, etc. We look out for such changes by checking
1684 the global "breakpoint_proceeded" after each command. */
1687 bpstat_do_actions (bsp
)
1691 struct cleanup
*old_chain
;
1692 struct command_line
*cmd
;
1694 /* Avoid endless recursion if a `source' command is contained
1696 if (executing_breakpoint_commands
)
1699 executing_breakpoint_commands
= 1;
1700 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1703 /* Note that (as of this writing), our callers all appear to
1704 be passing us the address of global stop_bpstat. And, if
1705 our calls to execute_control_command cause the inferior to
1706 proceed, that global (and hence, *bsp) will change.
1708 We must be careful to not touch *bsp unless the inferior
1709 has not proceeded. */
1711 /* This pointer will iterate over the list of bpstat's. */
1714 breakpoint_proceeded
= 0;
1715 for (; bs
!= NULL
; bs
= bs
->next
)
1720 execute_control_command (cmd
);
1722 if (breakpoint_proceeded
)
1727 if (breakpoint_proceeded
)
1728 /* The inferior is proceeded by the command; bomb out now.
1729 The bpstat chain has been blown away by wait_for_inferior.
1730 But since execution has stopped again, there is a new bpstat
1731 to look at, so start over. */
1734 bs
->commands
= NULL
;
1737 executing_breakpoint_commands
= 0;
1738 discard_cleanups (old_chain
);
1741 /* This is the normal print_it function for a bpstat. In the future,
1742 much of this logic could (should?) be moved to bpstat_stop_status,
1743 by having it set different print_it functions.
1745 Current scheme: When we stop, bpstat_print() is called.
1746 It loops through the bpstat list of things causing this stop,
1747 calling the print_it function for each one. The default
1748 print_it function, used for breakpoints, is print_it_normal().
1749 (Also see print_it_noop() and print_it_done()).
1751 Return values from this routine (used by bpstat_print() to
1753 1: Means we printed something, and we do *not* desire that
1754 something to be followed by a location.
1755 0: Means we printed something, and we *do* desire that
1756 something to be followed by a location.
1757 -1: Means we printed nothing. */
1760 print_it_normal (bs
)
1763 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1764 which has since been deleted. */
1765 if (bs
->breakpoint_at
== NULL
1766 || (bs
->breakpoint_at
->type
!= bp_breakpoint
1767 && bs
->breakpoint_at
->type
!= bp_catch_load
1768 && bs
->breakpoint_at
->type
!= bp_catch_unload
1769 && bs
->breakpoint_at
->type
!= bp_catch_fork
1770 && bs
->breakpoint_at
->type
!= bp_catch_vfork
1771 && bs
->breakpoint_at
->type
!= bp_catch_exec
1772 && bs
->breakpoint_at
->type
!= bp_catch_catch
1773 && bs
->breakpoint_at
->type
!= bp_catch_throw
1774 && bs
->breakpoint_at
->type
!= bp_hardware_breakpoint
1775 && bs
->breakpoint_at
->type
!= bp_watchpoint
1776 && bs
->breakpoint_at
->type
!= bp_read_watchpoint
1777 && bs
->breakpoint_at
->type
!= bp_access_watchpoint
1778 && bs
->breakpoint_at
->type
!= bp_hardware_watchpoint
))
1781 if (ep_is_shlib_catchpoint (bs
->breakpoint_at
))
1783 annotate_catchpoint (bs
->breakpoint_at
->number
);
1784 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1785 if (bs
->breakpoint_at
->type
== bp_catch_load
)
1786 printf_filtered ("loaded");
1787 else if (bs
->breakpoint_at
->type
== bp_catch_unload
)
1788 printf_filtered ("unloaded");
1789 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1792 else if (bs
->breakpoint_at
->type
== bp_catch_fork
||
1793 bs
->breakpoint_at
->type
== bp_catch_vfork
)
1795 annotate_catchpoint (bs
->breakpoint_at
->number
);
1796 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1797 if (bs
->breakpoint_at
->type
== bp_catch_fork
)
1798 printf_filtered ("forked");
1799 else if (bs
->breakpoint_at
->type
== bp_catch_vfork
)
1800 printf_filtered ("vforked");
1801 printf_filtered (" process %d), ",
1802 bs
->breakpoint_at
->forked_inferior_pid
);
1805 else if (bs
->breakpoint_at
->type
== bp_catch_exec
)
1807 annotate_catchpoint (bs
->breakpoint_at
->number
);
1808 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1809 bs
->breakpoint_at
->number
,
1810 bs
->breakpoint_at
->exec_pathname
);
1813 else if (bs
->breakpoint_at
->type
== bp_catch_catch
)
1815 if (current_exception_event
&&
1816 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1818 annotate_catchpoint (bs
->breakpoint_at
->number
);
1819 printf_filtered ("\nCatchpoint %d (exception caught), ",
1820 bs
->breakpoint_at
->number
);
1821 printf_filtered ("throw location ");
1822 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1823 printf_filtered ("%s:%d",
1824 CURRENT_EXCEPTION_THROW_FILE
,
1825 CURRENT_EXCEPTION_THROW_LINE
);
1827 printf_filtered ("unknown");
1829 printf_filtered (", catch location ");
1830 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1831 printf_filtered ("%s:%d",
1832 CURRENT_EXCEPTION_CATCH_FILE
,
1833 CURRENT_EXCEPTION_CATCH_LINE
);
1835 printf_filtered ("unknown");
1837 printf_filtered ("\n");
1838 return 1; /* don't bother to print location frame info */
1842 return -1; /* really throw, some other bpstat will handle it */
1845 else if (bs
->breakpoint_at
->type
== bp_catch_throw
)
1847 if (current_exception_event
&&
1848 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
1850 annotate_catchpoint (bs
->breakpoint_at
->number
);
1851 printf_filtered ("\nCatchpoint %d (exception thrown), ",
1852 bs
->breakpoint_at
->number
);
1853 printf_filtered ("throw location ");
1854 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1855 printf_filtered ("%s:%d",
1856 CURRENT_EXCEPTION_THROW_FILE
,
1857 CURRENT_EXCEPTION_THROW_LINE
);
1859 printf_filtered ("unknown");
1861 printf_filtered (", catch location ");
1862 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1863 printf_filtered ("%s:%d",
1864 CURRENT_EXCEPTION_CATCH_FILE
,
1865 CURRENT_EXCEPTION_CATCH_LINE
);
1867 printf_filtered ("unknown");
1869 printf_filtered ("\n");
1870 return 1; /* don't bother to print location frame info */
1874 return -1; /* really catch, some other bpstat willhandle it */
1878 else if (bs
->breakpoint_at
->type
== bp_breakpoint
||
1879 bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
1881 /* I think the user probably only wants to see one breakpoint
1882 number, not all of them. */
1883 annotate_breakpoint (bs
->breakpoint_at
->number
);
1884 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1887 else if ((bs
->old_val
!= NULL
) &&
1888 (bs
->breakpoint_at
->type
== bp_watchpoint
||
1889 bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1890 bs
->breakpoint_at
->type
== bp_hardware_watchpoint
))
1892 annotate_watchpoint (bs
->breakpoint_at
->number
);
1893 mention (bs
->breakpoint_at
);
1894 printf_filtered ("\nOld value = ");
1895 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
1896 printf_filtered ("\nNew value = ");
1897 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1898 Val_pretty_default
);
1899 printf_filtered ("\n");
1900 value_free (bs
->old_val
);
1902 /* More than one watchpoint may have been triggered. */
1905 else if (bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1906 bs
->breakpoint_at
->type
== bp_read_watchpoint
)
1908 mention (bs
->breakpoint_at
);
1909 printf_filtered ("\nValue = ");
1910 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1911 Val_pretty_default
);
1912 printf_filtered ("\n");
1915 /* We can't deal with it.
1916 Maybe another member of the bpstat chain can. */
1920 /* Print a message indicating what happened.
1921 This is called from normal_stop().
1922 The input to this routine is the head of the bpstat list - a list
1923 of the eventpoints that caused this stop.
1924 This routine calls the "print_it" routine(s) associated
1925 with these eventpoints. This will print (for example)
1926 the "Breakpoint n," part of the output.
1927 The return value of this routine is one of:
1929 -1: Means we printed nothing
1930 0: Means we printed something, and expect subsequent
1931 code to print the location. An example is
1932 "Breakpoint 1, " which should be followed by
1934 1 : Means we printed something, but there is no need
1935 to also print the location part of the message.
1936 An example is the catch/throw messages, which
1937 don't require a location appended to the end. */
1948 val
= (*bs
->print_it
) (bs
);
1952 /* Maybe another breakpoint in the chain caused us to stop.
1953 (Currently all watchpoints go on the bpstat whether hit or not.
1954 That probably could (should) be changed, provided care is taken
1955 with respect to bpstat_explains_signal). */
1957 return bpstat_print (bs
->next
);
1959 /* We reached the end of the chain without printing anything. */
1963 /* Evaluate the expression EXP and return 1 if value is zero.
1964 This is used inside a catch_errors to evaluate the breakpoint condition.
1965 The argument is a "struct expression *" that has been cast to char * to
1966 make it pass through catch_errors. */
1969 breakpoint_cond_eval (exp
)
1972 value_ptr mark
= value_mark ();
1973 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
1974 value_free_to_mark (mark
);
1978 /* Allocate a new bpstat and chain it to the current one. */
1981 bpstat_alloc (b
, cbs
)
1982 register struct breakpoint
*b
;
1983 bpstat cbs
; /* Current "bs" value */
1987 bs
= (bpstat
) xmalloc (sizeof (*bs
));
1989 bs
->breakpoint_at
= b
;
1990 /* If the condition is false, etc., don't do the commands. */
1991 bs
->commands
= NULL
;
1993 bs
->print_it
= print_it_normal
;
1997 /* Possible return values for watchpoint_check (this can't be an enum
1998 because of check_errors). */
1999 /* The watchpoint has been deleted. */
2000 #define WP_DELETED 1
2001 /* The value has changed. */
2002 #define WP_VALUE_CHANGED 2
2003 /* The value has not changed. */
2004 #define WP_VALUE_NOT_CHANGED 3
2006 #define BP_TEMPFLAG 1
2007 #define BP_HARDWAREFLAG 2
2009 /* Check watchpoint condition. */
2012 watchpoint_check (p
)
2015 bpstat bs
= (bpstat
) p
;
2016 struct breakpoint
*b
;
2017 struct frame_info
*fr
;
2018 int within_current_scope
;
2020 b
= bs
->breakpoint_at
;
2022 if (b
->exp_valid_block
== NULL
)
2023 within_current_scope
= 1;
2026 /* There is no current frame at this moment. If we're going to have
2027 any chance of handling watchpoints on local variables, we'll need
2028 the frame chain (so we can determine if we're in scope). */
2029 reinit_frame_cache ();
2030 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2031 within_current_scope
= (fr
!= NULL
);
2032 if (within_current_scope
)
2033 /* If we end up stopping, the current frame will get selected
2034 in normal_stop. So this call to select_frame won't affect
2036 select_frame (fr
, -1);
2039 if (within_current_scope
)
2041 /* We use value_{,free_to_}mark because it could be a
2042 *long* time before we return to the command level and
2043 call free_all_values. We can't call free_all_values because
2044 we might be in the middle of evaluating a function call. */
2046 value_ptr mark
= value_mark ();
2047 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2048 if (!value_equal (b
->val
, new_val
))
2050 release_value (new_val
);
2051 value_free_to_mark (mark
);
2052 bs
->old_val
= b
->val
;
2054 /* We will stop here */
2055 return WP_VALUE_CHANGED
;
2059 /* Nothing changed, don't do anything. */
2060 value_free_to_mark (mark
);
2061 /* We won't stop here */
2062 return WP_VALUE_NOT_CHANGED
;
2067 /* This seems like the only logical thing to do because
2068 if we temporarily ignored the watchpoint, then when
2069 we reenter the block in which it is valid it contains
2070 garbage (in the case of a function, it may have two
2071 garbage values, one before and one after the prologue).
2072 So we can't even detect the first assignment to it and
2073 watch after that (since the garbage may or may not equal
2074 the first value assigned). */
2076 Watchpoint %d deleted because the program has left the block in\n\
2077 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2078 if (b
->related_breakpoint
)
2079 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2080 b
->disposition
= del_at_next_stop
;
2086 /* This is used when everything which needs to be printed has
2087 already been printed. But we still want to print the frame. */
2089 /* Background: When we stop, bpstat_print() is called.
2090 It loops through the bpstat list of things causing this stop,
2091 calling the print_it function for each one. The default
2092 print_it function, used for breakpoints, is print_it_normal().
2093 Also see print_it_noop() and print_it_done() are the other
2094 two possibilities. See comments in bpstat_print() and
2095 in header of print_it_normal() for more detail. */
2104 /* This is used when nothing should be printed for this bpstat entry. */
2105 /* Background: When we stop, bpstat_print() is called.
2106 It loops through the bpstat list of things causing this stop,
2107 calling the print_it function for each one. The default
2108 print_it function, used for breakpoints, is print_it_normal().
2109 Also see print_it_noop() and print_it_done() are the other
2110 two possibilities. See comments in bpstat_print() and
2111 in header of print_it_normal() for more detail. */
2120 /* Get a bpstat associated with having just stopped at address *PC
2121 and frame address CORE_ADDRESS. Update *PC to point at the
2122 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2123 if this is known to not be a real breakpoint (it could still be a
2124 watchpoint, though). */
2126 /* Determine whether we stopped at a breakpoint, etc, or whether we
2127 don't understand this stop. Result is a chain of bpstat's such that:
2129 if we don't understand the stop, the result is a null pointer.
2131 if we understand why we stopped, the result is not null.
2133 Each element of the chain refers to a particular breakpoint or
2134 watchpoint at which we have stopped. (We may have stopped for
2135 several reasons concurrently.)
2137 Each element of the chain has valid next, breakpoint_at,
2138 commands, FIXME??? fields. */
2141 bpstat_stop_status (pc
, not_a_breakpoint
)
2143 int not_a_breakpoint
;
2145 register struct breakpoint
*b
, *temp
;
2147 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2148 int real_breakpoint
= 0;
2149 /* Root of the chain of bpstat's */
2150 struct bpstats root_bs
[1];
2151 /* Pointer to the last thing in the chain currently. */
2152 bpstat bs
= root_bs
;
2153 static char message1
[] =
2154 "Error evaluating expression for watchpoint %d\n";
2155 char message
[sizeof (message1
) + 30 /* slop */ ];
2157 /* Get the address where the breakpoint would have been. */
2158 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2159 0 : DECR_PC_AFTER_BREAK
);
2161 ALL_BREAKPOINTS_SAFE (b
, temp
)
2163 if (b
->enable
== disabled
2164 || b
->enable
== shlib_disabled
2165 || b
->enable
== call_disabled
)
2168 if (b
->type
!= bp_watchpoint
2169 && b
->type
!= bp_hardware_watchpoint
2170 && b
->type
!= bp_read_watchpoint
2171 && b
->type
!= bp_access_watchpoint
2172 && b
->type
!= bp_hardware_breakpoint
2173 && b
->type
!= bp_catch_fork
2174 && b
->type
!= bp_catch_vfork
2175 && b
->type
!= bp_catch_exec
2176 && b
->type
!= bp_catch_catch
2177 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2178 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2179 (overlay_debugging
&& /* overlay doesn't match */
2180 section_is_overlay (b
->section
) &&
2181 !section_is_mapped (b
->section
)))
2184 if (b
->type
== bp_hardware_breakpoint
2185 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2188 /* Is this a catchpoint of a load or unload? If so, did we
2189 get a load or unload of the specified library? If not,
2191 if ((b
->type
== bp_catch_load
)
2192 #if defined(SOLIB_HAVE_LOAD_EVENT)
2193 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2194 || ((b
->dll_pathname
!= NULL
)
2195 && (strcmp (b
->dll_pathname
,
2196 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2202 if ((b
->type
== bp_catch_unload
)
2203 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2204 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2205 || ((b
->dll_pathname
!= NULL
)
2206 && (strcmp (b
->dll_pathname
,
2207 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2213 if ((b
->type
== bp_catch_fork
)
2214 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2217 if ((b
->type
== bp_catch_vfork
)
2218 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2221 if ((b
->type
== bp_catch_exec
)
2222 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2225 if (ep_is_exception_catchpoint (b
) &&
2226 !(current_exception_event
= target_get_current_exception_event ()))
2229 /* Come here if it's a watchpoint, or if the break address matches */
2231 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2233 /* Watchpoints may change this, if not found to have triggered. */
2237 sprintf (message
, message1
, b
->number
);
2238 if (b
->type
== bp_watchpoint
||
2239 b
->type
== bp_hardware_watchpoint
)
2241 switch (catch_errors (watchpoint_check
, bs
, message
,
2245 /* We've already printed what needs to be printed. */
2246 bs
->print_it
= print_it_done
;
2249 case WP_VALUE_CHANGED
:
2253 case WP_VALUE_NOT_CHANGED
:
2255 bs
->print_it
= print_it_noop
;
2257 /* Don't consider this a hit. */
2264 /* Error from catch_errors. */
2265 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2266 if (b
->related_breakpoint
)
2267 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2268 b
->disposition
= del_at_next_stop
;
2269 /* We've already printed what needs to be printed. */
2270 bs
->print_it
= print_it_done
;
2276 else if (b
->type
== bp_read_watchpoint
||
2277 b
->type
== bp_access_watchpoint
)
2283 addr
= target_stopped_data_address ();
2286 for (v
= b
->val_chain
; v
; v
= v
->next
)
2288 if (v
->lval
== lval_memory
)
2292 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2293 /* Exact match not required. Within range is sufficient.
2295 if (addr
>= vaddr
&&
2296 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2301 switch (catch_errors (watchpoint_check
, bs
, message
,
2305 /* We've already printed what needs to be printed. */
2306 bs
->print_it
= print_it_done
;
2309 case WP_VALUE_CHANGED
:
2310 case WP_VALUE_NOT_CHANGED
:
2317 /* Error from catch_errors. */
2318 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2319 if (b
->related_breakpoint
)
2320 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2321 b
->disposition
= del_at_next_stop
;
2322 /* We've already printed what needs to be printed. */
2323 bs
->print_it
= print_it_done
;
2326 else /* found == 0 */
2328 /* This is a case where some watchpoint(s) triggered,
2329 but not at the address of this watchpoint (FOUND
2330 was left zero). So don't print anything for this
2332 bs
->print_it
= print_it_noop
;
2339 /* By definition, an encountered breakpoint is a triggered
2343 real_breakpoint
= 1;
2346 if (b
->frame
&& b
->frame
!= (get_current_frame ())->frame
&&
2347 (b
->type
== bp_step_resume
&&
2348 (INNER_THAN (get_current_frame ()->frame
, b
->frame
))))
2352 int value_is_zero
= 0;
2356 /* Need to select the frame, with all that implies
2357 so that the conditions will have the right context. */
2358 select_frame (get_current_frame (), 0);
2360 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2361 "Error in testing breakpoint condition:\n",
2363 /* FIXME-someday, should give breakpoint # */
2366 if (b
->cond
&& value_is_zero
)
2369 /* Don't consider this a hit. */
2372 else if (b
->ignore_count
> 0)
2379 /* We will stop here */
2380 if (b
->disposition
== disable
)
2381 b
->enable
= disabled
;
2382 bs
->commands
= b
->commands
;
2386 (STREQ ("silent", bs
->commands
->line
) ||
2387 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2389 bs
->commands
= bs
->commands
->next
;
2394 /* Print nothing for this entry if we dont stop or if we dont print. */
2395 if (bs
->stop
== 0 || bs
->print
== 0)
2396 bs
->print_it
= print_it_noop
;
2399 bs
->next
= NULL
; /* Terminate the chain */
2400 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2402 if (real_breakpoint
&& bs
)
2404 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2406 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2408 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2414 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2417 #if defined (SHIFT_INST_REGS)
2419 #else /* No SHIFT_INST_REGS. */
2421 #endif /* No SHIFT_INST_REGS. */
2426 /* The value of a hardware watchpoint hasn't changed, but the
2427 intermediate memory locations we are watching may have. */
2428 if (bs
&& !bs
->stop
&&
2429 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2430 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2431 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2433 remove_breakpoints ();
2434 insert_breakpoints ();
2439 /* Tell what to do about this bpstat. */
2444 /* Classify each bpstat as one of the following. */
2447 /* This bpstat element has no effect on the main_action. */
2450 /* There was a watchpoint, stop but don't print. */
2453 /* There was a watchpoint, stop and print. */
2456 /* There was a breakpoint but we're not stopping. */
2459 /* There was a breakpoint, stop but don't print. */
2462 /* There was a breakpoint, stop and print. */
2465 /* We hit the longjmp breakpoint. */
2468 /* We hit the longjmp_resume breakpoint. */
2471 /* We hit the step_resume breakpoint. */
2474 /* We hit the through_sigtramp breakpoint. */
2477 /* We hit the shared library event breakpoint. */
2480 /* We caught a shared library event. */
2483 /* This is just used to count how many enums there are. */
2487 /* Here is the table which drives this routine. So that we can
2488 format it pretty, we define some abbreviations for the
2489 enum bpstat_what codes. */
2490 #define kc BPSTAT_WHAT_KEEP_CHECKING
2491 #define ss BPSTAT_WHAT_STOP_SILENT
2492 #define sn BPSTAT_WHAT_STOP_NOISY
2493 #define sgl BPSTAT_WHAT_SINGLE
2494 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2495 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2496 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2497 #define sr BPSTAT_WHAT_STEP_RESUME
2498 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2499 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2500 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2502 /* "Can't happen." Might want to print an error message.
2503 abort() is not out of the question, but chances are GDB is just
2504 a bit confused, not unusable. */
2505 #define err BPSTAT_WHAT_STOP_NOISY
2507 /* Given an old action and a class, come up with a new action. */
2508 /* One interesting property of this table is that wp_silent is the same
2509 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2510 after stopping, the check for whether to step over a breakpoint
2511 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2512 reference to how we stopped. We retain separate wp_silent and
2513 bp_silent codes in case we want to change that someday.
2515 Another possibly interesting property of this table is that
2516 there's a partial ordering, priority-like, of the actions. Once
2517 you've decided that some action is appropriate, you'll never go
2518 back and decide something of a lower priority is better. The
2521 kc < clr sgl shl slr sn sr ss ts
2522 sgl < clrs shl shlr slr sn sr ss ts
2523 slr < err shl shlr sn sr ss ts
2524 clr < clrs err shl shlr sn sr ss ts
2525 clrs < err shl shlr sn sr ss ts
2526 ss < shl shlr sn sr ts
2533 What I think this means is that we don't need a damned table
2534 here. If you just put the rows and columns in the right order,
2535 it'd look awfully regular. We could simply walk the bpstat list
2536 and choose the highest priority action we find, with a little
2537 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2538 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2539 is messy anyway). */
2541 /* step_resume entries: a step resume breakpoint overrides another
2542 breakpoint of signal handling (see comment in wait_for_inferior
2543 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2544 /* We handle the through_sigtramp_breakpoint the same way; having both
2545 one of those and a step_resume_breakpoint is probably very rare (?). */
2547 static const enum bpstat_what_main_action
2548 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2551 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2554 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2556 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2558 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2560 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2562 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2564 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2566 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2568 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2570 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2572 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2574 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2576 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2591 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2592 struct bpstat_what retval
;
2594 retval
.call_dummy
= 0;
2595 for (; bs
!= NULL
; bs
= bs
->next
)
2597 enum class bs_class
= no_effect
;
2598 if (bs
->breakpoint_at
== NULL
)
2599 /* I suspect this can happen if it was a momentary breakpoint
2600 which has since been deleted. */
2602 switch (bs
->breakpoint_at
->type
)
2608 case bp_hardware_breakpoint
:
2614 bs_class
= bp_noisy
;
2616 bs_class
= bp_silent
;
2619 bs_class
= bp_nostop
;
2622 case bp_hardware_watchpoint
:
2623 case bp_read_watchpoint
:
2624 case bp_access_watchpoint
:
2628 bs_class
= wp_noisy
;
2630 bs_class
= wp_silent
;
2633 /* There was a watchpoint, but we're not stopping.
2634 This requires no further action. */
2635 bs_class
= no_effect
;
2638 bs_class
= long_jump
;
2640 case bp_longjmp_resume
:
2641 bs_class
= long_resume
;
2643 case bp_step_resume
:
2646 bs_class
= step_resume
;
2649 /* It is for the wrong frame. */
2650 bs_class
= bp_nostop
;
2652 case bp_through_sigtramp
:
2653 bs_class
= through_sig
;
2655 case bp_watchpoint_scope
:
2656 bs_class
= bp_nostop
;
2658 case bp_shlib_event
:
2659 bs_class
= shlib_event
;
2662 case bp_catch_unload
:
2663 /* Only if this catchpoint triggered should we cause the
2664 step-out-of-dld behaviour. Otherwise, we ignore this
2667 bs_class
= catch_shlib_event
;
2669 bs_class
= no_effect
;
2672 case bp_catch_vfork
:
2677 bs_class
= bp_noisy
;
2679 bs_class
= bp_silent
;
2682 /* There was a catchpoint, but we're not stopping.
2683 This requires no further action. */
2684 bs_class
= no_effect
;
2686 case bp_catch_catch
:
2687 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2688 bs_class
= bp_nostop
;
2690 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2692 case bp_catch_throw
:
2693 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2694 bs_class
= bp_nostop
;
2696 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2699 /* Make sure the action is stop (silent or noisy),
2700 so infrun.c pops the dummy frame. */
2701 bs_class
= bp_silent
;
2702 retval
.call_dummy
= 1;
2705 current_action
= table
[(int) bs_class
][(int) current_action
];
2707 retval
.main_action
= current_action
;
2711 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2712 without hardware support). This isn't related to a specific bpstat,
2713 just to things like whether watchpoints are set. */
2716 bpstat_should_step ()
2718 struct breakpoint
*b
;
2720 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2725 /* Nonzero if there are enabled hardware watchpoints. */
2727 bpstat_have_active_hw_watchpoints ()
2729 struct breakpoint
*b
;
2731 if ((b
->enable
== enabled
) &&
2733 ((b
->type
== bp_hardware_watchpoint
) ||
2734 (b
->type
== bp_read_watchpoint
) ||
2735 (b
->type
== bp_access_watchpoint
)))
2741 /* Given a bpstat that records zero or more triggered eventpoints, this
2742 function returns another bpstat which contains only the catchpoints
2743 on that first list, if any. */
2745 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
2749 struct bpstats root_bs
[1];
2750 bpstat bs
= root_bs
;
2751 struct breakpoint
*ep
;
2754 bpstat_clear (cp_list
);
2755 root_bs
->next
= NULL
;
2757 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
2759 /* Is this eventpoint a catchpoint? If not, ignore it. */
2760 ep
= ep_list
->breakpoint_at
;
2763 if ((ep
->type
!= bp_catch_load
) &&
2764 (ep
->type
!= bp_catch_unload
) &&
2765 (ep
->type
!= bp_catch_catch
) &&
2766 (ep
->type
!= bp_catch_throw
))
2767 /* pai: (temp) ADD fork/vfork here!! */
2770 /* Yes; add it to the list. */
2771 bs
= bpstat_alloc (ep
, bs
);
2776 #if defined(SOLIB_ADD)
2777 /* Also, for each triggered catchpoint, tag it with the name of
2778 the library that caused this trigger. (We copy the name now,
2779 because it's only guaranteed to be available NOW, when the
2780 catchpoint triggers. Clients who may wish to know the name
2781 later must get it from the catchpoint itself.) */
2782 if (ep
->triggered_dll_pathname
!= NULL
)
2783 free (ep
->triggered_dll_pathname
);
2784 if (ep
->type
== bp_catch_load
)
2785 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
2787 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
2789 dll_pathname
= NULL
;
2793 ep
->triggered_dll_pathname
= (char *)
2794 xmalloc (strlen (dll_pathname
) + 1);
2795 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
2798 ep
->triggered_dll_pathname
= NULL
;
2804 /* Print information on breakpoint number BNUM, or -1 if all.
2805 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2806 is nonzero, process only watchpoints. */
2813 ep_type_description_t
;
2816 breakpoint_1 (bnum
, allflag
)
2820 register struct breakpoint
*b
;
2821 register struct command_line
*l
;
2822 register struct symbol
*sym
;
2823 CORE_ADDR last_addr
= (CORE_ADDR
) - 1;
2824 int found_a_breakpoint
= 0;
2825 static ep_type_description_t bptypes
[] =
2827 {bp_none
, "?deleted?"},
2828 {bp_breakpoint
, "breakpoint"},
2829 {bp_hardware_breakpoint
, "hw breakpoint"},
2830 {bp_until
, "until"},
2831 {bp_finish
, "finish"},
2832 {bp_watchpoint
, "watchpoint"},
2833 {bp_hardware_watchpoint
, "hw watchpoint"},
2834 {bp_read_watchpoint
, "read watchpoint"},
2835 {bp_access_watchpoint
, "acc watchpoint"},
2836 {bp_longjmp
, "longjmp"},
2837 {bp_longjmp_resume
, "longjmp resume"},
2838 {bp_step_resume
, "step resume"},
2839 {bp_through_sigtramp
, "sigtramp"},
2840 {bp_watchpoint_scope
, "watchpoint scope"},
2841 {bp_call_dummy
, "call dummy"},
2842 {bp_shlib_event
, "shlib events"},
2843 {bp_catch_load
, "catch load"},
2844 {bp_catch_unload
, "catch unload"},
2845 {bp_catch_fork
, "catch fork"},
2846 {bp_catch_vfork
, "catch vfork"},
2847 {bp_catch_exec
, "catch exec"},
2848 {bp_catch_catch
, "catch catch"},
2849 {bp_catch_throw
, "catch throw"}
2852 static char *bpdisps
[] =
2853 {"del", "dstp", "dis", "keep"};
2854 static char bpenables
[] = "nynny";
2855 char wrap_indent
[80];
2861 || bnum
== b
->number
)
2863 /* We only print out user settable breakpoints unless the allflag is set. */
2865 && b
->type
!= bp_breakpoint
2866 && b
->type
!= bp_catch_load
2867 && b
->type
!= bp_catch_unload
2868 && b
->type
!= bp_catch_fork
2869 && b
->type
!= bp_catch_vfork
2870 && b
->type
!= bp_catch_exec
2871 && b
->type
!= bp_catch_catch
2872 && b
->type
!= bp_catch_throw
2873 && b
->type
!= bp_hardware_breakpoint
2874 && b
->type
!= bp_watchpoint
2875 && b
->type
!= bp_read_watchpoint
2876 && b
->type
!= bp_access_watchpoint
2877 && b
->type
!= bp_hardware_watchpoint
)
2880 if (!found_a_breakpoint
++)
2882 annotate_breakpoints_headers ();
2885 printf_filtered ("Num ");
2887 printf_filtered ("Type ");
2889 printf_filtered ("Disp ");
2891 printf_filtered ("Enb ");
2895 printf_filtered ("Address ");
2898 printf_filtered ("What\n");
2900 annotate_breakpoints_table ();
2905 printf_filtered ("%-3d ", b
->number
);
2907 if ((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
2908 error ("bptypes table does not describe type #%d.", (int) b
->type
);
2909 if ((int) b
->type
!= bptypes
[(int) b
->type
].type
)
2910 error ("bptypes table does not describe type #%d?", (int) b
->type
);
2911 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
2913 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
2915 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
2917 strcpy (wrap_indent
, " ");
2919 strcat (wrap_indent
, " ");
2923 case bp_hardware_watchpoint
:
2924 case bp_read_watchpoint
:
2925 case bp_access_watchpoint
:
2926 /* Field 4, the address, is omitted (which makes the columns
2927 not line up too nicely with the headers, but the effect
2928 is relatively readable). */
2930 print_expression (b
->exp
, gdb_stdout
);
2934 case bp_catch_unload
:
2935 /* Field 4, the address, is omitted (which makes the columns
2936 not line up too nicely with the headers, but the effect
2937 is relatively readable). */
2939 if (b
->dll_pathname
== NULL
)
2940 printf_filtered ("<any library> ");
2942 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
2946 case bp_catch_vfork
:
2947 /* Field 4, the address, is omitted (which makes the columns
2948 not line up too nicely with the headers, but the effect
2949 is relatively readable). */
2951 if (b
->forked_inferior_pid
!= 0)
2952 printf_filtered ("process %d ", b
->forked_inferior_pid
);
2956 /* Field 4, the address, is omitted (which makes the columns
2957 not line up too nicely with the headers, but the effect
2958 is relatively readable). */
2960 if (b
->exec_pathname
!= NULL
)
2961 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
2963 case bp_catch_catch
:
2964 /* Field 4, the address, is omitted (which makes the columns
2965 not line up too nicely with the headers, but the effect
2966 is relatively readable). */
2968 printf_filtered ("exception catch ");
2970 case bp_catch_throw
:
2971 /* Field 4, the address, is omitted (which makes the columns
2972 not line up too nicely with the headers, but the effect
2973 is relatively readable). */
2975 printf_filtered ("exception throw ");
2979 case bp_hardware_breakpoint
:
2983 case bp_longjmp_resume
:
2984 case bp_step_resume
:
2985 case bp_through_sigtramp
:
2986 case bp_watchpoint_scope
:
2988 case bp_shlib_event
:
2992 /* FIXME-32x64: need a print_address_numeric with
2996 local_hex_string_custom
2997 ((unsigned long) b
->address
, "08l"));
3002 last_addr
= b
->address
;
3005 sym
= find_pc_sect_function (b
->address
, b
->section
);
3008 fputs_filtered ("in ", gdb_stdout
);
3009 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3010 wrap_here (wrap_indent
);
3011 fputs_filtered (" at ", gdb_stdout
);
3013 fputs_filtered (b
->source_file
, gdb_stdout
);
3014 printf_filtered (":%d", b
->line_number
);
3017 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3021 if (b
->thread
!= -1)
3022 printf_filtered (" thread %d", b
->thread
);
3024 printf_filtered ("\n");
3030 printf_filtered ("\tstop only in stack frame at ");
3031 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3032 printf_filtered ("\n");
3039 printf_filtered ("\tstop only if ");
3040 print_expression (b
->cond
, gdb_stdout
);
3041 printf_filtered ("\n");
3044 if (b
->thread
!= -1)
3046 /* FIXME should make an annotation for this */
3047 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3050 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3052 /* FIXME should make an annotation for this */
3053 if (ep_is_catchpoint (b
))
3054 printf_filtered ("\tcatchpoint");
3056 printf_filtered ("\tbreakpoint");
3057 printf_filtered (" already hit %d time%s\n",
3058 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3061 if (b
->ignore_count
)
3065 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3068 if ((l
= b
->commands
))
3074 print_command_line (l
, 4, gdb_stdout
);
3080 if (!found_a_breakpoint
)
3083 printf_filtered ("No breakpoints or watchpoints.\n");
3085 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3088 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3089 that a comparison of an unsigned with -1 is always false. */
3090 if (last_addr
!= (CORE_ADDR
) - 1)
3091 set_next_address (last_addr
);
3093 annotate_breakpoints_table_end ();
3098 breakpoints_info (bnum_exp
, from_tty
)
3105 bnum
= parse_and_eval_address (bnum_exp
);
3107 breakpoint_1 (bnum
, 0);
3112 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3119 bnum
= parse_and_eval_address (bnum_exp
);
3121 breakpoint_1 (bnum
, 1);
3124 /* Print a message describing any breakpoints set at PC. */
3127 describe_other_breakpoints (pc
, section
)
3131 register int others
= 0;
3132 register struct breakpoint
*b
;
3135 if (b
->address
== pc
)
3136 if (overlay_debugging
== 0 ||
3137 b
->section
== section
)
3141 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3143 if (b
->address
== pc
)
3144 if (overlay_debugging
== 0 ||
3145 b
->section
== section
)
3151 ((b
->enable
== disabled
||
3152 b
->enable
== shlib_disabled
||
3153 b
->enable
== call_disabled
) ? " (disabled)"
3154 : b
->enable
== permanent
? " (permanent)"
3156 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3158 printf_filtered ("also set at pc ");
3159 print_address_numeric (pc
, 1, gdb_stdout
);
3160 printf_filtered (".\n");
3164 /* Set the default place to put a breakpoint
3165 for the `break' command with no arguments. */
3168 set_default_breakpoint (valid
, addr
, symtab
, line
)
3171 struct symtab
*symtab
;
3174 default_breakpoint_valid
= valid
;
3175 default_breakpoint_address
= addr
;
3176 default_breakpoint_symtab
= symtab
;
3177 default_breakpoint_line
= line
;
3180 /* Rescan breakpoints at address ADDRESS,
3181 marking the first one as "first" and any others as "duplicates".
3182 This is so that the bpt instruction is only inserted once.
3183 If we have a permanent breakpoint at ADDRESS, make that one
3184 the official one, and the rest as duplicates. */
3187 check_duplicates (address
, section
)
3191 register struct breakpoint
*b
;
3192 register int count
= 0;
3193 struct breakpoint
*perm_bp
= 0;
3195 if (address
== 0) /* Watchpoints are uninteresting */
3199 if (b
->enable
!= disabled
3200 && b
->enable
!= shlib_disabled
3201 && b
->enable
!= call_disabled
3202 && b
->address
== address
3203 && (overlay_debugging
== 0 || b
->section
== section
))
3205 /* Have we found a permanent breakpoint? */
3206 if (b
->enable
== permanent
)
3213 b
->duplicate
= count
> 1;
3216 /* If we found a permanent breakpoint at this address, go over the
3217 list again and declare all the other breakpoints there to be the
3221 perm_bp
->duplicate
= 0;
3223 /* Permanent breakpoint should always be inserted. */
3224 if (! perm_bp
->inserted
)
3225 internal_error ("allegedly permanent breakpoint is not "
3226 "actually inserted");
3232 internal_error ("another breakpoint was inserted on top of "
3233 "a permanent breakpoint");
3235 if (b
->enable
!= disabled
3236 && b
->enable
!= shlib_disabled
3237 && b
->enable
!= call_disabled
3238 && b
->address
== address
3239 && (overlay_debugging
== 0 || b
->section
== section
))
3245 /* Low level routine to set a breakpoint.
3246 Takes as args the three things that every breakpoint must have.
3247 Returns the breakpoint object so caller can set other things.
3248 Does not set the breakpoint number!
3249 Does not print anything.
3251 ==> This routine should not be called if there is a chance of later
3252 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3253 your arguments BEFORE calling this routine! */
3256 set_raw_breakpoint (sal
)
3257 struct symtab_and_line sal
;
3259 register struct breakpoint
*b
, *b1
;
3261 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3262 memset (b
, 0, sizeof (*b
));
3263 b
->address
= sal
.pc
;
3264 if (sal
.symtab
== NULL
)
3265 b
->source_file
= NULL
;
3267 b
->source_file
= savestring (sal
.symtab
->filename
,
3268 strlen (sal
.symtab
->filename
));
3269 b
->section
= sal
.section
;
3270 b
->language
= current_language
->la_language
;
3271 b
->input_radix
= input_radix
;
3273 b
->line_number
= sal
.line
;
3274 b
->enable
= enabled
;
3277 b
->ignore_count
= 0;
3280 b
->dll_pathname
= NULL
;
3281 b
->triggered_dll_pathname
= NULL
;
3282 b
->forked_inferior_pid
= 0;
3283 b
->exec_pathname
= NULL
;
3285 /* Add this breakpoint to the end of the chain
3286 so that a list of breakpoints will come out in order
3287 of increasing numbers. */
3289 b1
= breakpoint_chain
;
3291 breakpoint_chain
= b
;
3299 check_duplicates (sal
.pc
, sal
.section
);
3300 breakpoints_changed ();
3306 /* Note that the breakpoint object B describes a permanent breakpoint
3307 instruction, hard-wired into the inferior's code. */
3309 make_breakpoint_permanent (struct breakpoint
*b
)
3311 b
->enable
= permanent
;
3313 /* By definition, permanent breakpoints are already present in the code. */
3317 #ifdef GET_LONGJMP_TARGET
3320 create_longjmp_breakpoint (func_name
)
3323 struct symtab_and_line sal
;
3324 struct breakpoint
*b
;
3326 INIT_SAL (&sal
); /* initialize to zeroes */
3327 if (func_name
!= NULL
)
3329 struct minimal_symbol
*m
;
3331 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3332 (struct objfile
*) NULL
);
3334 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3338 sal
.section
= find_pc_overlay (sal
.pc
);
3339 b
= set_raw_breakpoint (sal
);
3343 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3344 b
->disposition
= donttouch
;
3345 b
->enable
= disabled
;
3348 b
->addr_string
= strsave (func_name
);
3349 b
->number
= internal_breakpoint_number
--;
3352 #endif /* #ifdef GET_LONGJMP_TARGET */
3354 /* Call this routine when stepping and nexting to enable a breakpoint
3355 if we do a longjmp(). When we hit that breakpoint, call
3356 set_longjmp_resume_breakpoint() to figure out where we are going. */
3359 enable_longjmp_breakpoint ()
3361 register struct breakpoint
*b
;
3364 if (b
->type
== bp_longjmp
)
3366 b
->enable
= enabled
;
3367 check_duplicates (b
->address
, b
->section
);
3372 disable_longjmp_breakpoint ()
3374 register struct breakpoint
*b
;
3377 if (b
->type
== bp_longjmp
3378 || b
->type
== bp_longjmp_resume
)
3380 b
->enable
= disabled
;
3381 check_duplicates (b
->address
, b
->section
);
3387 remove_solib_event_breakpoints ()
3389 register struct breakpoint
*b
, *temp
;
3391 ALL_BREAKPOINTS_SAFE (b
, temp
)
3392 if (b
->type
== bp_shlib_event
)
3393 delete_breakpoint (b
);
3397 create_solib_event_breakpoint (address
)
3400 struct breakpoint
*b
;
3401 struct symtab_and_line sal
;
3403 INIT_SAL (&sal
); /* initialize to zeroes */
3405 sal
.section
= find_pc_overlay (sal
.pc
);
3406 b
= set_raw_breakpoint (sal
);
3407 b
->number
= internal_breakpoint_number
--;
3408 b
->disposition
= donttouch
;
3409 b
->type
= bp_shlib_event
;
3414 /* Disable any breakpoints that are on code in shared libraries. Only
3415 apply to enabled breakpoints, disabled ones can just stay disabled. */
3418 disable_breakpoints_in_shlibs (silent
)
3421 struct breakpoint
*b
;
3422 int disabled_shlib_breaks
= 0;
3424 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3427 #if defined (PC_SOLIB)
3428 if (((b
->type
== bp_breakpoint
) ||
3429 (b
->type
== bp_hardware_breakpoint
)) &&
3430 b
->enable
== enabled
&&
3432 PC_SOLIB (b
->address
))
3434 b
->enable
= shlib_disabled
;
3437 if (!disabled_shlib_breaks
)
3439 target_terminal_ours_for_output ();
3440 warning ("Temporarily disabling shared library breakpoints:");
3442 disabled_shlib_breaks
= 1;
3443 warning ("breakpoint #%d ", b
->number
);
3450 /* Try to reenable any breakpoints in shared libraries. */
3452 re_enable_breakpoints_in_shlibs ()
3454 struct breakpoint
*b
;
3457 if (b
->enable
== shlib_disabled
)
3461 /* Do not reenable the breakpoint if the shared library
3462 is still not mapped in. */
3463 if (target_read_memory (b
->address
, buf
, 1) == 0)
3464 b
->enable
= enabled
;
3471 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
3476 enum bptype bp_kind
;
3478 struct breakpoint
*b
;
3479 struct symtabs_and_lines sals
;
3480 struct cleanup
*old_chain
;
3481 struct cleanup
*canonical_strings_chain
= NULL
;
3482 char *addr_start
= hookname
;
3483 char *addr_end
= NULL
;
3484 char **canonical
= (char **) NULL
;
3485 int thread
= -1; /* All threads. */
3487 /* Set a breakpoint on the specified hook. */
3488 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3489 addr_end
= hookname
;
3491 if (sals
.nelts
== 0)
3493 warning ("Unable to set a breakpoint on dynamic linker callback.");
3494 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3495 warning ("GDB will be unable to track shl_load/shl_unload calls");
3498 if (sals
.nelts
!= 1)
3500 warning ("Unable to set unique breakpoint on dynamic linker callback.");
3501 warning ("GDB will be unable to track shl_load/shl_unload calls");
3505 /* Make sure that all storage allocated in decode_line_1 gets freed
3506 in case the following errors out. */
3507 old_chain
= make_cleanup (free
, sals
.sals
);
3508 if (canonical
!= (char **) NULL
)
3510 make_cleanup (free
, canonical
);
3511 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3512 if (canonical
[0] != NULL
)
3513 make_cleanup (free
, canonical
[0]);
3516 resolve_sal_pc (&sals
.sals
[0]);
3518 /* Remove the canonical strings from the cleanup, they are needed below. */
3519 if (canonical
!= (char **) NULL
)
3520 discard_cleanups (canonical_strings_chain
);
3522 b
= set_raw_breakpoint (sals
.sals
[0]);
3523 set_breakpoint_count (breakpoint_count
+ 1);
3524 b
->number
= breakpoint_count
;
3526 b
->cond_string
= (cond_string
== NULL
) ?
3527 NULL
: savestring (cond_string
, strlen (cond_string
));
3530 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
3531 b
->addr_string
= canonical
[0];
3532 else if (addr_start
)
3533 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
3535 b
->enable
= enabled
;
3536 b
->disposition
= tempflag
? del
: donttouch
;
3538 if (dll_pathname
== NULL
)
3539 b
->dll_pathname
= NULL
;
3542 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
3543 strcpy (b
->dll_pathname
, dll_pathname
);
3548 do_cleanups (old_chain
);
3552 create_solib_load_event_breakpoint (hookname
, tempflag
,
3553 dll_pathname
, cond_string
)
3559 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
3560 cond_string
, bp_catch_load
);
3564 create_solib_unload_event_breakpoint (hookname
, tempflag
,
3565 dll_pathname
, cond_string
)
3571 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
3572 cond_string
, bp_catch_unload
);
3576 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
3579 enum bptype bp_kind
;
3581 struct symtab_and_line sal
;
3582 struct breakpoint
*b
;
3583 int thread
= -1; /* All threads. */
3590 b
= set_raw_breakpoint (sal
);
3591 set_breakpoint_count (breakpoint_count
+ 1);
3592 b
->number
= breakpoint_count
;
3594 b
->cond_string
= (cond_string
== NULL
) ?
3595 NULL
: savestring (cond_string
, strlen (cond_string
));
3597 b
->addr_string
= NULL
;
3598 b
->enable
= enabled
;
3599 b
->disposition
= tempflag
? del
: donttouch
;
3600 b
->forked_inferior_pid
= 0;
3608 create_fork_event_catchpoint (tempflag
, cond_string
)
3612 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
3616 create_vfork_event_catchpoint (tempflag
, cond_string
)
3620 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
3624 create_exec_event_catchpoint (tempflag
, cond_string
)
3628 struct symtab_and_line sal
;
3629 struct breakpoint
*b
;
3630 int thread
= -1; /* All threads. */
3637 b
= set_raw_breakpoint (sal
);
3638 set_breakpoint_count (breakpoint_count
+ 1);
3639 b
->number
= breakpoint_count
;
3641 b
->cond_string
= (cond_string
== NULL
) ?
3642 NULL
: savestring (cond_string
, strlen (cond_string
));
3644 b
->addr_string
= NULL
;
3645 b
->enable
= enabled
;
3646 b
->disposition
= tempflag
? del
: donttouch
;
3648 b
->type
= bp_catch_exec
;
3654 hw_breakpoint_used_count ()
3656 register struct breakpoint
*b
;
3661 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
3669 hw_watchpoint_used_count (type
, other_type_used
)
3671 int *other_type_used
;
3673 register struct breakpoint
*b
;
3676 *other_type_used
= 0;
3679 if (b
->enable
== enabled
)
3681 if (b
->type
== type
)
3683 else if ((b
->type
== bp_hardware_watchpoint
||
3684 b
->type
== bp_read_watchpoint
||
3685 b
->type
== bp_access_watchpoint
)
3686 && b
->enable
== enabled
)
3687 *other_type_used
= 1;
3693 /* Call this after hitting the longjmp() breakpoint. Use this to set
3694 a new breakpoint at the target of the jmp_buf.
3696 FIXME - This ought to be done by setting a temporary breakpoint
3697 that gets deleted automatically... */
3700 set_longjmp_resume_breakpoint (pc
, frame
)
3702 struct frame_info
*frame
;
3704 register struct breakpoint
*b
;
3707 if (b
->type
== bp_longjmp_resume
)
3710 b
->enable
= enabled
;
3712 b
->frame
= frame
->frame
;
3715 check_duplicates (b
->address
, b
->section
);
3721 disable_watchpoints_before_interactive_call_start ()
3723 struct breakpoint
*b
;
3727 if (((b
->type
== bp_watchpoint
)
3728 || (b
->type
== bp_hardware_watchpoint
)
3729 || (b
->type
== bp_read_watchpoint
)
3730 || (b
->type
== bp_access_watchpoint
)
3731 || ep_is_exception_catchpoint (b
))
3732 && (b
->enable
== enabled
))
3734 b
->enable
= call_disabled
;
3735 check_duplicates (b
->address
, b
->section
);
3741 enable_watchpoints_after_interactive_call_stop ()
3743 struct breakpoint
*b
;
3747 if (((b
->type
== bp_watchpoint
)
3748 || (b
->type
== bp_hardware_watchpoint
)
3749 || (b
->type
== bp_read_watchpoint
)
3750 || (b
->type
== bp_access_watchpoint
)
3751 || ep_is_exception_catchpoint (b
))
3752 && (b
->enable
== call_disabled
))
3754 b
->enable
= enabled
;
3755 check_duplicates (b
->address
, b
->section
);
3761 /* Set a breakpoint that will evaporate an end of command
3762 at address specified by SAL.
3763 Restrict it to frame FRAME if FRAME is nonzero. */
3766 set_momentary_breakpoint (sal
, frame
, type
)
3767 struct symtab_and_line sal
;
3768 struct frame_info
*frame
;
3771 register struct breakpoint
*b
;
3772 b
= set_raw_breakpoint (sal
);
3774 b
->enable
= enabled
;
3775 b
->disposition
= donttouch
;
3776 b
->frame
= (frame
? frame
->frame
: 0);
3778 /* If we're debugging a multi-threaded program, then we
3779 want momentary breakpoints to be active in only a
3780 single thread of control. */
3781 if (in_thread_list (inferior_pid
))
3782 b
->thread
= pid_to_thread_id (inferior_pid
);
3788 /* Tell the user we have just set a breakpoint B. */
3792 struct breakpoint
*b
;
3796 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3797 watchpoint) other than breakpoint creation. It should be possible to
3798 clean this up and at the same time replace the random calls to
3799 breakpoint_changed with this hook, as has already been done for
3800 delete_breakpoint_hook and so on. */
3801 if (create_breakpoint_hook
)
3802 create_breakpoint_hook (b
);
3803 breakpoint_create_event (b
->number
);
3808 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
3811 printf_filtered ("Watchpoint %d: ", b
->number
);
3812 print_expression (b
->exp
, gdb_stdout
);
3814 case bp_hardware_watchpoint
:
3815 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
3816 print_expression (b
->exp
, gdb_stdout
);
3818 case bp_read_watchpoint
:
3819 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
3820 print_expression (b
->exp
, gdb_stdout
);
3822 case bp_access_watchpoint
:
3823 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
3825 print_expression (b
->exp
, gdb_stdout
);
3828 printf_filtered ("Breakpoint %d", b
->number
);
3831 case bp_hardware_breakpoint
:
3832 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
3836 case bp_catch_unload
:
3837 printf_filtered ("Catchpoint %d (%s %s)",
3839 (b
->type
== bp_catch_load
) ? "load" : "unload",
3840 (b
->dll_pathname
!= NULL
) ?
3841 b
->dll_pathname
: "<any library>");
3844 case bp_catch_vfork
:
3845 printf_filtered ("Catchpoint %d (%s)",
3847 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
3850 printf_filtered ("Catchpoint %d (exec)",
3853 case bp_catch_catch
:
3854 case bp_catch_throw
:
3855 printf_filtered ("Catchpoint %d (%s)",
3857 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
3863 case bp_longjmp_resume
:
3864 case bp_step_resume
:
3865 case bp_through_sigtramp
:
3867 case bp_watchpoint_scope
:
3868 case bp_shlib_event
:
3873 if (addressprint
|| b
->source_file
== NULL
)
3875 printf_filtered (" at ");
3876 print_address_numeric (b
->address
, 1, gdb_stdout
);
3879 printf_filtered (": file %s, line %d.",
3880 b
->source_file
, b
->line_number
);
3881 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
3882 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
3884 printf_filtered ("\n");
3888 /* Set a breakpoint according to ARG (function, linenum or *address)
3889 flag: first bit : 0 non-temporary, 1 temporary.
3890 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3893 break_command_1 (arg
, flag
, from_tty
)
3897 int tempflag
, hardwareflag
;
3898 struct symtabs_and_lines sals
;
3899 struct symtab_and_line sal
;
3900 register struct expression
*cond
= 0;
3901 register struct breakpoint
*b
;
3903 /* Pointers in arg to the start, and one past the end, of the condition. */
3904 char *cond_start
= NULL
;
3905 char *cond_end
= NULL
;
3906 /* Pointers in arg to the start, and one past the end,
3907 of the address part. */
3908 char *addr_start
= NULL
;
3909 char *addr_end
= NULL
;
3910 struct cleanup
*old_chain
;
3911 struct cleanup
*canonical_strings_chain
= NULL
;
3912 char **canonical
= (char **) NULL
;
3916 hardwareflag
= flag
& BP_HARDWAREFLAG
;
3917 tempflag
= flag
& BP_TEMPFLAG
;
3922 INIT_SAL (&sal
); /* initialize to zeroes */
3924 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3926 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
3927 && (arg
[2] == ' ' || arg
[2] == '\t')))
3929 if (default_breakpoint_valid
)
3931 sals
.sals
= (struct symtab_and_line
*)
3932 xmalloc (sizeof (struct symtab_and_line
));
3933 sal
.pc
= default_breakpoint_address
;
3934 sal
.line
= default_breakpoint_line
;
3935 sal
.symtab
= default_breakpoint_symtab
;
3936 sal
.section
= find_pc_overlay (sal
.pc
);
3941 error ("No default breakpoint address now.");
3947 /* Force almost all breakpoints to be in terms of the
3948 current_source_symtab (which is decode_line_1's default). This
3949 should produce the results we want almost all of the time while
3950 leaving default_breakpoint_* alone. */
3951 if (default_breakpoint_valid
3952 && (!current_source_symtab
3953 || (arg
&& (*arg
== '+' || *arg
== '-'))))
3954 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
3955 default_breakpoint_line
, &canonical
);
3957 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3965 /* Make sure that all storage allocated in decode_line_1 gets freed
3966 in case the following `for' loop errors out. */
3967 old_chain
= make_cleanup (free
, sals
.sals
);
3968 if (canonical
!= (char **) NULL
)
3970 make_cleanup (free
, canonical
);
3971 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3972 for (i
= 0; i
< sals
.nelts
; i
++)
3974 if (canonical
[i
] != NULL
)
3975 make_cleanup (free
, canonical
[i
]);
3979 thread
= -1; /* No specific thread yet */
3981 /* Resolve all line numbers to PC's, and verify that conditions
3982 can be parsed, before setting any breakpoints. */
3983 for (i
= 0; i
< sals
.nelts
; i
++)
3985 char *tok
, *end_tok
;
3988 resolve_sal_pc (&sals
.sals
[i
]);
3990 /* It's possible for the PC to be nonzero, but still an illegal
3991 value on some targets.
3993 For example, on HP-UX if you start gdb, and before running the
3994 inferior you try to set a breakpoint on a shared library function
3995 "foo" where the inferior doesn't call "foo" directly but does
3996 pass its address to another function call, then we do find a
3997 minimal symbol for the "foo", but it's address is invalid.
3998 (Appears to be an index into a table that the loader sets up
3999 when the inferior is run.)
4001 Give the target a chance to bless sals.sals[i].pc before we
4002 try to make a breakpoint for it. */
4003 if (PC_REQUIRES_RUN_BEFORE_USE (sals
.sals
[i
].pc
))
4005 error ("Cannot break on %s without a running program.",
4013 while (*tok
== ' ' || *tok
== '\t')
4018 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4021 toklen
= end_tok
- tok
;
4023 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4025 tok
= cond_start
= end_tok
+ 1;
4026 cond
= parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4029 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4035 thread
= strtol (tok
, &tok
, 0);
4037 error ("Junk after thread keyword.");
4038 if (!valid_thread_id (thread
))
4039 error ("Unknown thread %d\n", thread
);
4042 error ("Junk at end of arguments.");
4047 int i
, target_resources_ok
;
4049 i
= hw_breakpoint_used_count ();
4050 target_resources_ok
=
4051 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4053 if (target_resources_ok
== 0)
4054 error ("No hardware breakpoint support in the target.");
4055 else if (target_resources_ok
< 0)
4056 error ("Hardware breakpoints used exceeds limit.");
4059 /* Remove the canonical strings from the cleanup, they are needed below. */
4060 if (canonical
!= (char **) NULL
)
4061 discard_cleanups (canonical_strings_chain
);
4063 /* Now set all the breakpoints. */
4064 for (i
= 0; i
< sals
.nelts
; i
++)
4069 describe_other_breakpoints (sal
.pc
, sal
.section
);
4071 b
= set_raw_breakpoint (sal
);
4072 set_breakpoint_count (breakpoint_count
+ 1);
4073 b
->number
= breakpoint_count
;
4074 b
->type
= hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
;
4078 /* If a canonical line spec is needed use that instead of the
4080 if (canonical
!= (char **) NULL
&& canonical
[i
] != NULL
)
4081 b
->addr_string
= canonical
[i
];
4082 else if (addr_start
)
4083 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4085 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4087 b
->enable
= enabled
;
4088 b
->disposition
= tempflag
? del
: donttouch
;
4094 warning ("Multiple breakpoints were set.");
4095 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4097 do_cleanups (old_chain
);
4101 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4106 struct frame_info
*frame
;
4107 CORE_ADDR low
, high
, selected_pc
= 0;
4108 char *extra_args
, *level_arg
, *addr_string
;
4109 int extra_args_len
= 0, if_arg
= 0;
4112 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4115 if (default_breakpoint_valid
)
4119 selected_pc
= selected_frame
->pc
;
4124 error ("No selected frame.");
4127 error ("No default breakpoint address now.");
4131 extra_args
= strchr (arg
, ' ');
4135 extra_args_len
= strlen (extra_args
);
4136 level_arg
= (char *) xmalloc (extra_args
- arg
);
4137 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4138 level_arg
[extra_args
- arg
- 1] = '\0';
4142 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4143 strcpy (level_arg
, arg
);
4146 frame
= parse_frame_specification (level_arg
);
4148 selected_pc
= frame
->pc
;
4155 extra_args_len
= strlen (arg
);
4160 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4162 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4164 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4166 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4167 break_command_1 (addr_string
, flag
, from_tty
);
4171 error ("No function contains the specified address");
4174 error ("Unable to set breakpoint at procedure exit");
4179 break_at_finish_command_1 (arg
, flag
, from_tty
)
4184 char *addr_string
, *break_string
, *beg_addr_string
;
4185 CORE_ADDR low
, high
;
4186 struct symtabs_and_lines sals
;
4187 struct symtab_and_line sal
;
4188 struct cleanup
*old_chain
;
4190 int extra_args_len
= 0;
4194 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4196 if (default_breakpoint_valid
)
4200 addr_string
= (char *) xmalloc (15);
4201 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
4206 error ("No selected frame.");
4209 error ("No default breakpoint address now.");
4213 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
4214 strcpy (addr_string
, arg
);
4220 extra_args_len
= strlen (arg
);
4224 /* get the stuff after the function name or address */
4225 extra_args
= strchr (arg
, ' ');
4229 extra_args_len
= strlen (extra_args
);
4236 beg_addr_string
= addr_string
;
4237 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
4240 free (beg_addr_string
);
4241 old_chain
= make_cleanup (free
, sals
.sals
);
4242 for (i
= 0; (i
< sals
.nelts
); i
++)
4245 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
4247 break_string
= (char *) xmalloc (extra_args_len
+ 26);
4249 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4251 sprintf (break_string
, "*0x%s", paddr_nz (high
));
4252 break_command_1 (break_string
, flag
, from_tty
);
4253 free (break_string
);
4256 error ("No function contains the specified address");
4260 warning ("Multiple breakpoints were set.\n");
4261 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4263 do_cleanups (old_chain
);
4267 /* Helper function for break_command_1 and disassemble_command. */
4270 resolve_sal_pc (sal
)
4271 struct symtab_and_line
*sal
;
4275 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
4277 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
4278 error ("No line %d in file \"%s\".",
4279 sal
->line
, sal
->symtab
->filename
);
4283 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
4285 struct blockvector
*bv
;
4290 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
4293 b
= BLOCKVECTOR_BLOCK (bv
, index
);
4294 sym
= block_function (b
);
4297 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
4298 sal
->section
= SYMBOL_BFD_SECTION (sym
);
4302 /* It really is worthwhile to have the section, so we'll just
4303 have to look harder. This case can be executed if we have
4304 line numbers but no functions (as can happen in assembly
4307 struct minimal_symbol
*msym
;
4309 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
4311 sal
->section
= SYMBOL_BFD_SECTION (msym
);
4318 break_command (arg
, from_tty
)
4322 break_command_1 (arg
, 0, from_tty
);
4326 break_at_finish_command (arg
, from_tty
)
4330 break_at_finish_command_1 (arg
, 0, from_tty
);
4334 break_at_finish_at_depth_command (arg
, from_tty
)
4338 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
4342 tbreak_command (arg
, from_tty
)
4346 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4350 tbreak_at_finish_command (arg
, from_tty
)
4354 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4358 hbreak_command (arg
, from_tty
)
4362 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
4366 thbreak_command (arg
, from_tty
)
4370 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
4374 stop_command (arg
, from_tty
)
4378 printf_filtered ("Specify the type of breakpoint to set.\n\
4379 Usage: stop in <function | address>\n\
4384 stopin_command (arg
, from_tty
)
4390 if (arg
== (char *) NULL
)
4392 else if (*arg
!= '*')
4397 /* look for a ':'. If this is a line number specification, then
4398 say it is bad, otherwise, it should be an address or
4399 function/method name */
4400 while (*argptr
&& !hasColon
)
4402 hasColon
= (*argptr
== ':');
4407 badInput
= (*argptr
!= ':'); /* Not a class::method */
4409 badInput
= isdigit (*arg
); /* a simple line number */
4413 printf_filtered ("Usage: stop in <function | address>\n");
4415 break_command_1 (arg
, 0, from_tty
);
4419 stopat_command (arg
, from_tty
)
4425 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
4432 /* look for a ':'. If there is a '::' then get out, otherwise
4433 it is probably a line number. */
4434 while (*argptr
&& !hasColon
)
4436 hasColon
= (*argptr
== ':');
4441 badInput
= (*argptr
== ':'); /* we have class::method */
4443 badInput
= !isdigit (*arg
); /* not a line number */
4447 printf_filtered ("Usage: stop at <line>\n");
4449 break_command_1 (arg
, 0, from_tty
);
4453 /* accessflag: hw_write: watch write,
4454 hw_read: watch read,
4455 hw_access: watch access (read or write) */
4457 watch_command_1 (arg
, accessflag
, from_tty
)
4462 struct breakpoint
*b
;
4463 struct symtab_and_line sal
;
4464 struct expression
*exp
;
4465 struct block
*exp_valid_block
;
4466 struct value
*val
, *mark
;
4467 struct frame_info
*frame
;
4468 struct frame_info
*prev_frame
= NULL
;
4469 char *exp_start
= NULL
;
4470 char *exp_end
= NULL
;
4471 char *tok
, *end_tok
;
4473 char *cond_start
= NULL
;
4474 char *cond_end
= NULL
;
4475 struct expression
*cond
= NULL
;
4476 int i
, other_type_used
, target_resources_ok
= 0;
4477 enum bptype bp_type
;
4480 INIT_SAL (&sal
); /* initialize to zeroes */
4482 /* Parse arguments. */
4483 innermost_block
= NULL
;
4485 exp
= parse_exp_1 (&arg
, 0, 0);
4487 exp_valid_block
= innermost_block
;
4488 mark
= value_mark ();
4489 val
= evaluate_expression (exp
);
4490 release_value (val
);
4491 if (VALUE_LAZY (val
))
4492 value_fetch_lazy (val
);
4495 while (*tok
== ' ' || *tok
== '\t')
4499 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4502 toklen
= end_tok
- tok
;
4503 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4505 tok
= cond_start
= end_tok
+ 1;
4506 cond
= parse_exp_1 (&tok
, 0, 0);
4510 error ("Junk at end of command.");
4512 if (accessflag
== hw_read
)
4513 bp_type
= bp_read_watchpoint
;
4514 else if (accessflag
== hw_access
)
4515 bp_type
= bp_access_watchpoint
;
4517 bp_type
= bp_hardware_watchpoint
;
4519 mem_cnt
= can_use_hardware_watchpoint (val
);
4520 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
4521 error ("Expression cannot be implemented with read/access watchpoint.");
4524 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
4525 target_resources_ok
=
4526 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
4528 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
4529 error ("Target does not support this type of hardware watchpoint.");
4531 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
4532 error ("Target can only support one kind of HW watchpoint at a time.");
4535 #if defined(HPUXHPPA)
4536 /* On HP-UX if you set a h/w
4537 watchpoint before the "run" command, the inferior dies with a e.g.,
4538 SIGILL once you start it. I initially believed this was due to a
4539 bad interaction between page protection traps and the initial
4540 startup sequence by the dynamic linker.
4542 However, I tried avoiding that by having HP-UX's implementation of
4543 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4544 yet, which forced slow watches before a "run" or "attach", and it
4545 still fails somewhere in the startup code.
4547 Until I figure out what's happening, I'm disallowing watches altogether
4548 before the "run" or "attach" command. We'll tell the user they must
4549 set watches after getting the program started. */
4550 if (!target_has_execution
)
4552 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4555 #endif /* HPUXHPPA */
4557 /* Now set up the breakpoint. */
4558 b
= set_raw_breakpoint (sal
);
4559 set_breakpoint_count (breakpoint_count
+ 1);
4560 b
->number
= breakpoint_count
;
4561 b
->disposition
= donttouch
;
4563 b
->exp_valid_block
= exp_valid_block
;
4564 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
4568 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4572 frame
= block_innermost_frame (exp_valid_block
);
4575 prev_frame
= get_prev_frame (frame
);
4576 b
->watchpoint_frame
= frame
->frame
;
4579 b
->watchpoint_frame
= (CORE_ADDR
) 0;
4581 if (mem_cnt
&& target_resources_ok
> 0)
4584 b
->type
= bp_watchpoint
;
4586 /* If the expression is "local", then set up a "watchpoint scope"
4587 breakpoint at the point where we've left the scope of the watchpoint
4589 if (innermost_block
)
4593 struct breakpoint
*scope_breakpoint
;
4594 struct symtab_and_line scope_sal
;
4596 INIT_SAL (&scope_sal
); /* initialize to zeroes */
4597 scope_sal
.pc
= get_frame_pc (prev_frame
);
4598 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
4600 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
4601 set_breakpoint_count (breakpoint_count
+ 1);
4602 scope_breakpoint
->number
= breakpoint_count
;
4604 scope_breakpoint
->type
= bp_watchpoint_scope
;
4605 scope_breakpoint
->enable
= enabled
;
4607 /* Automatically delete the breakpoint when it hits. */
4608 scope_breakpoint
->disposition
= del
;
4610 /* Only break in the proper frame (help with recursion). */
4611 scope_breakpoint
->frame
= prev_frame
->frame
;
4613 /* Set the address at which we will stop. */
4614 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
4616 /* The scope breakpoint is related to the watchpoint. We
4617 will need to act on them together. */
4618 b
->related_breakpoint
= scope_breakpoint
;
4621 value_free_to_mark (mark
);
4625 /* Return count of locations need to be watched and can be handled
4626 in hardware. If the watchpoint can not be handled
4627 in hardware return zero. */
4629 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4630 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
4631 ((BYTE_SIZE) <= (REGISTER_SIZE))
4634 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
4635 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
4636 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
4640 can_use_hardware_watchpoint (v
)
4643 int found_memory_cnt
= 0;
4645 /* Did the user specifically forbid us to use hardware watchpoints? */
4646 if (!can_use_hw_watchpoints
)
4649 /* Make sure all the intermediate values are in memory. Also make sure
4650 we found at least one memory expression. Guards against watch 0x12345,
4651 which is meaningless, but could cause errors if one tries to insert a
4652 hardware watchpoint for the constant expression. */
4653 for (; v
; v
= v
->next
)
4655 if (v
->lval
== lval_memory
)
4657 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
4658 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
4660 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
4665 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
4666 return 0; /* ??? What does this represent? */
4667 else if (v
->lval
== lval_register
)
4668 return 0; /* cannot watch a register with a HW watchpoint */
4671 /* The expression itself looks suitable for using a hardware
4672 watchpoint, but give the target machine a chance to reject it. */
4673 return found_memory_cnt
;
4677 watch_command (arg
, from_tty
)
4681 watch_command_1 (arg
, hw_write
, from_tty
);
4685 rwatch_command (arg
, from_tty
)
4689 watch_command_1 (arg
, hw_read
, from_tty
);
4693 awatch_command (arg
, from_tty
)
4697 watch_command_1 (arg
, hw_access
, from_tty
);
4701 /* Helper routines for the until_command routine in infcmd.c. Here
4702 because it uses the mechanisms of breakpoints. */
4704 /* This function is called by fetch_inferior_event via the
4705 cmd_continuation pointer, to complete the until command. It takes
4706 care of cleaning up the temporary breakpoints set up by the until
4709 until_break_command_continuation (struct continuation_arg
*arg
)
4711 /* Do all the exec cleanups, which at this point should only be the
4712 one set up in the first part of the until_break_command
4714 do_exec_cleanups (ALL_CLEANUPS
);
4719 until_break_command (arg
, from_tty
)
4723 struct symtabs_and_lines sals
;
4724 struct symtab_and_line sal
;
4725 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
4726 struct breakpoint
*breakpoint
;
4727 struct cleanup
*old_chain
;
4729 clear_proceed_status ();
4731 /* Set a breakpoint where the user wants it and at return from
4734 if (default_breakpoint_valid
)
4735 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
4736 default_breakpoint_line
, (char ***) NULL
);
4738 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
4739 0, (char ***) NULL
);
4741 if (sals
.nelts
!= 1)
4742 error ("Couldn't get information on specified line.");
4745 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
4748 error ("Junk at end of arguments.");
4750 resolve_sal_pc (&sal
);
4752 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
4754 if (!event_loop_p
|| !target_can_async_p ())
4755 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
4758 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4760 /* If we are running asynchronously, and the target supports async
4761 execution, we are not waiting for the target to stop, in the call
4762 tp proceed, below. This means that we cannot delete the
4763 brekpoints until the target has actually stopped. The only place
4764 where we get a chance to do that is in fetch_inferior_event, so
4765 we must set things up for that. */
4767 if (event_loop_p
&& target_can_async_p ())
4769 /* In this case we don't need args for the continuation, because
4770 all it needs to do is do the cleanups in the
4771 exec_cleanup_chain, which will be only those inserted by this
4772 function. We can get away by using ALL_CLEANUPS. */
4773 add_continuation (until_break_command_continuation
, NULL
);
4776 /* Keep within the current frame */
4780 sal
= find_pc_line (prev_frame
->pc
, 0);
4781 sal
.pc
= prev_frame
->pc
;
4782 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
4783 if (!event_loop_p
|| !target_can_async_p ())
4784 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4786 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
4789 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
4790 /* Do the cleanups now, anly if we are not running asynchronously,
4791 of if we are, but the target is still synchronous. */
4792 if (!event_loop_p
|| !target_can_async_p ())
4793 do_cleanups (old_chain
);
4797 /* These aren't used; I don't konw what they were for. */
4798 /* Set a breakpoint at the catch clause for NAME. */
4800 catch_breakpoint (name
)
4806 disable_catch_breakpoint ()
4811 delete_catch_breakpoint ()
4816 enable_catch_breakpoint ()
4823 struct sal_chain
*next
;
4824 struct symtab_and_line sal
;
4828 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4829 had been commented out in the v.4.16 sources, and stays
4830 disabled there now because "catch NAME" syntax isn't allowed.
4832 /* This isn't used; I don't know what it was for. */
4833 /* For each catch clause identified in ARGS, run FUNCTION
4834 with that clause as an argument. */
4835 static struct symtabs_and_lines
4836 map_catch_names (args
, function
)
4840 register char *p
= args
;
4842 struct symtabs_and_lines sals
;
4844 struct sal_chain
*sal_chain
= 0;
4848 error_no_arg ("one or more catch names");
4856 /* Don't swallow conditional part. */
4857 if (p1
[0] == 'i' && p1
[1] == 'f'
4858 && (p1
[2] == ' ' || p1
[2] == '\t'))
4864 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
4868 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
4869 error ("Arguments must be catch names.");
4875 struct sal_chain
*next
= (struct sal_chain
*)
4876 alloca (sizeof (struct sal_chain
));
4877 next
->next
= sal_chain
;
4878 next
->sal
= get_catch_sal (p
);
4883 printf_unfiltered ("No catch clause for exception %s.\n", p
);
4888 while (*p
== ' ' || *p
== '\t')
4894 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4896 static struct symtabs_and_lines
4897 get_catch_sals (this_level_only
)
4898 int this_level_only
;
4900 register struct blockvector
*bl
;
4901 register struct block
*block
;
4902 int index
, have_default
= 0;
4904 struct symtabs_and_lines sals
;
4905 struct sal_chain
*sal_chain
= 0;
4906 char *blocks_searched
;
4908 /* Not sure whether an error message is always the correct response,
4909 but it's better than a core dump. */
4910 if (selected_frame
== NULL
)
4911 error ("No selected frame.");
4912 block
= get_frame_block (selected_frame
);
4913 pc
= selected_frame
->pc
;
4919 error ("No symbol table info available.\n");
4921 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
4922 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4923 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
4927 CORE_ADDR end
= BLOCK_END (block
) - 4;
4930 if (bl
!= blockvector_for_pc (end
, &index
))
4931 error ("blockvector blotch");
4932 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
4933 error ("blockvector botch");
4934 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
4937 /* Don't print out blocks that have gone by. */
4938 while (index
< last_index
4939 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
4942 while (index
< last_index
4943 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
4945 if (blocks_searched
[index
] == 0)
4947 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
4950 register struct symbol
*sym
;
4952 nsyms
= BLOCK_NSYMS (b
);
4954 for (i
= 0; i
< nsyms
; i
++)
4956 sym
= BLOCK_SYM (b
, i
);
4957 if (STREQ (SYMBOL_NAME (sym
), "default"))
4963 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
4965 struct sal_chain
*next
= (struct sal_chain
*)
4966 alloca (sizeof (struct sal_chain
));
4967 next
->next
= sal_chain
;
4968 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
4973 blocks_searched
[index
] = 1;
4979 if (sal_chain
&& this_level_only
)
4982 /* After handling the function's top-level block, stop.
4983 Don't continue to its superblock, the block of
4984 per-file symbols. */
4985 if (BLOCK_FUNCTION (block
))
4987 block
= BLOCK_SUPERBLOCK (block
);
4992 struct sal_chain
*tmp_chain
;
4994 /* Count the number of entries. */
4995 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
4996 tmp_chain
= tmp_chain
->next
)
5000 sals
.sals
= (struct symtab_and_line
*)
5001 xmalloc (index
* sizeof (struct symtab_and_line
));
5002 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5003 sals
.sals
[index
] = sal_chain
->sal
;
5010 ep_skip_leading_whitespace (s
)
5013 if ((s
== NULL
) || (*s
== NULL
))
5015 while (isspace (**s
))
5019 /* This function examines a string, and attempts to find a token
5020 that might be an event name in the leading characters. If a
5021 possible match is found, a pointer to the last character of
5022 the token is returned. Else, NULL is returned. */
5025 ep_find_event_name_end (arg
)
5029 char *event_name_end
= NULL
;
5031 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5035 /* We break out of the loop when we find a token delimiter.
5036 Basically, we're looking for alphanumerics and underscores;
5037 anything else delimites the token. */
5040 if (!isalnum (*s
) && (*s
!= '_'))
5046 return event_name_end
;
5050 /* This function attempts to parse an optional "if <cond>" clause
5051 from the arg string. If one is not found, it returns NULL.
5053 Else, it returns a pointer to the condition string. (It does not
5054 attempt to evaluate the string against a particular block.) And,
5055 it updates arg to point to the first character following the parsed
5056 if clause in the arg string. */
5059 ep_parse_optional_if_clause (arg
)
5064 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5067 /* Skip the "if" keyword. */
5070 /* Skip any extra leading whitespace, and record the start of the
5071 condition string. */
5072 ep_skip_leading_whitespace (arg
);
5075 /* Assume that the condition occupies the remainder of the arg string. */
5076 (*arg
) += strlen (cond_string
);
5081 /* This function attempts to parse an optional filename from the arg
5082 string. If one is not found, it returns NULL.
5084 Else, it returns a pointer to the parsed filename. (This function
5085 makes no attempt to verify that a file of that name exists, or is
5086 accessible.) And, it updates arg to point to the first character
5087 following the parsed filename in the arg string.
5089 Note that clients needing to preserve the returned filename for
5090 future access should copy it to their own buffers. */
5092 ep_parse_optional_filename (arg
)
5095 static char filename
[1024];
5100 if ((*arg_p
== '\0') || isspace (*arg_p
))
5118 /* Commands to deal with catching events, such as signals, exceptions,
5119 process start/exit, etc. */
5123 catch_fork
, catch_vfork
5127 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
5133 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
5134 catch_fork_kind fork_kind
;
5139 char *cond_string
= NULL
;
5141 ep_skip_leading_whitespace (&arg
);
5143 /* The allowed syntax is:
5145 catch [v]fork if <cond>
5147 First, check if there's an if clause. */
5148 cond_string
= ep_parse_optional_if_clause (&arg
);
5150 if ((*arg
!= '\0') && !isspace (*arg
))
5151 error ("Junk at end of arguments.");
5153 /* If this target supports it, create a fork or vfork catchpoint
5154 and enable reporting of such events. */
5158 create_fork_event_catchpoint (tempflag
, cond_string
);
5161 create_vfork_event_catchpoint (tempflag
, cond_string
);
5164 error ("unsupported or unknown fork kind; cannot catch it");
5170 catch_exec_command_1 (arg
, tempflag
, from_tty
)
5175 char *cond_string
= NULL
;
5177 ep_skip_leading_whitespace (&arg
);
5179 /* The allowed syntax is:
5181 catch exec if <cond>
5183 First, check if there's an if clause. */
5184 cond_string
= ep_parse_optional_if_clause (&arg
);
5186 if ((*arg
!= '\0') && !isspace (*arg
))
5187 error ("Junk at end of arguments.");
5189 /* If this target supports it, create an exec catchpoint
5190 and enable reporting of such events. */
5191 create_exec_event_catchpoint (tempflag
, cond_string
);
5194 #if defined(SOLIB_ADD)
5196 catch_load_command_1 (arg
, tempflag
, from_tty
)
5201 char *dll_pathname
= NULL
;
5202 char *cond_string
= NULL
;
5204 ep_skip_leading_whitespace (&arg
);
5206 /* The allowed syntax is:
5208 catch load if <cond>
5209 catch load <filename>
5210 catch load <filename> if <cond>
5212 The user is not allowed to specify the <filename> after an
5215 We'll ignore the pathological case of a file named "if".
5217 First, check if there's an if clause. If so, then there
5218 cannot be a filename. */
5219 cond_string
= ep_parse_optional_if_clause (&arg
);
5221 /* If there was an if clause, then there cannot be a filename.
5222 Else, there might be a filename and an if clause. */
5223 if (cond_string
== NULL
)
5225 dll_pathname
= ep_parse_optional_filename (&arg
);
5226 ep_skip_leading_whitespace (&arg
);
5227 cond_string
= ep_parse_optional_if_clause (&arg
);
5230 if ((*arg
!= '\0') && !isspace (*arg
))
5231 error ("Junk at end of arguments.");
5233 /* Create a load breakpoint that only triggers when a load of
5234 the specified dll (or any dll, if no pathname was specified)
5236 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
5237 dll_pathname
, cond_string
);
5241 catch_unload_command_1 (arg
, tempflag
, from_tty
)
5246 char *dll_pathname
= NULL
;
5247 char *cond_string
= NULL
;
5249 ep_skip_leading_whitespace (&arg
);
5251 /* The allowed syntax is:
5253 catch unload if <cond>
5254 catch unload <filename>
5255 catch unload <filename> if <cond>
5257 The user is not allowed to specify the <filename> after an
5260 We'll ignore the pathological case of a file named "if".
5262 First, check if there's an if clause. If so, then there
5263 cannot be a filename. */
5264 cond_string
= ep_parse_optional_if_clause (&arg
);
5266 /* If there was an if clause, then there cannot be a filename.
5267 Else, there might be a filename and an if clause. */
5268 if (cond_string
== NULL
)
5270 dll_pathname
= ep_parse_optional_filename (&arg
);
5271 ep_skip_leading_whitespace (&arg
);
5272 cond_string
= ep_parse_optional_if_clause (&arg
);
5275 if ((*arg
!= '\0') && !isspace (*arg
))
5276 error ("Junk at end of arguments.");
5278 /* Create an unload breakpoint that only triggers when an unload of
5279 the specified dll (or any dll, if no pathname was specified)
5281 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
5282 dll_pathname
, cond_string
);
5284 #endif /* SOLIB_ADD */
5286 /* Commands to deal with catching exceptions. */
5288 /* Set a breakpoint at the specified callback routine for an
5289 exception event callback */
5292 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
5295 enum exception_event_kind ex_event
;
5296 struct symtab_and_line
*sal
;
5298 struct breakpoint
*b
;
5299 int thread
= -1; /* All threads. */
5301 if (!sal
) /* no exception support? */
5304 b
= set_raw_breakpoint (*sal
);
5305 set_breakpoint_count (breakpoint_count
+ 1);
5306 b
->number
= breakpoint_count
;
5308 b
->cond_string
= (cond_string
== NULL
) ?
5309 NULL
: savestring (cond_string
, strlen (cond_string
));
5311 b
->addr_string
= NULL
;
5312 b
->enable
= enabled
;
5313 b
->disposition
= tempflag
? del
: donttouch
;
5316 case EX_EVENT_THROW
:
5317 b
->type
= bp_catch_throw
;
5319 case EX_EVENT_CATCH
:
5320 b
->type
= bp_catch_catch
;
5322 default: /* error condition */
5324 b
->enable
= disabled
;
5325 error ("Internal error -- invalid catchpoint kind");
5330 /* Deal with "catch catch" and "catch throw" commands */
5333 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
5334 enum exception_event_kind ex_event
;
5339 char *cond_string
= NULL
;
5340 struct symtab_and_line
*sal
= NULL
;
5342 ep_skip_leading_whitespace (&arg
);
5344 cond_string
= ep_parse_optional_if_clause (&arg
);
5346 if ((*arg
!= '\0') && !isspace (*arg
))
5347 error ("Junk at end of arguments.");
5349 if ((ex_event
!= EX_EVENT_THROW
) &&
5350 (ex_event
!= EX_EVENT_CATCH
))
5351 error ("Unsupported or unknown exception event; cannot catch it");
5353 /* See if we can find a callback routine */
5354 sal
= target_enable_exception_callback (ex_event
, 1);
5358 /* We have callbacks from the runtime system for exceptions.
5359 Set a breakpoint on the sal found, if no errors */
5360 if (sal
!= (struct symtab_and_line
*) -1)
5361 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
5363 return; /* something went wrong with setting up callbacks */
5367 /* No callbacks from runtime system for exceptions.
5368 Try GNU C++ exception breakpoints using labels in debug info. */
5369 if (ex_event
== EX_EVENT_CATCH
)
5371 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
5373 else if (ex_event
== EX_EVENT_THROW
)
5375 /* Set a breakpoint on __raise_exception () */
5377 warning ("Unsupported with this platform/compiler combination.");
5378 warning ("Perhaps you can achieve the effect you want by setting");
5379 warning ("a breakpoint on __raise_exception().");
5384 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5385 inside a catch_errors */
5388 cover_target_enable_exception_callback (arg
)
5391 args_for_catchpoint_enable
*args
= arg
;
5392 struct symtab_and_line
*sal
;
5393 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
5396 else if (sal
== (struct symtab_and_line
*) -1)
5399 return 1; /*is valid */
5404 /* This is the original v.4.16 and earlier version of the
5405 catch_command_1() function. Now that other flavours of "catch"
5406 have been introduced, and since exception handling can be handled
5407 in other ways (through target ops) also, this is used only for the
5408 GNU C++ exception handling system.
5409 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5410 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5411 there was no code in GDB 4.16 for "catch throw".
5413 Called from catch_exception_command_1 () */
5417 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
5422 /* First, translate ARG into something we can deal with in terms
5425 struct symtabs_and_lines sals
;
5426 struct symtab_and_line sal
;
5427 register struct expression
*cond
= 0;
5428 register struct breakpoint
*b
;
5432 INIT_SAL (&sal
); /* initialize to zeroes */
5434 /* If no arg given, or if first arg is 'if ', all active catch clauses
5435 are breakpointed. */
5437 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
5438 && (arg
[2] == ' ' || arg
[2] == '\t')))
5440 /* Grab all active catch clauses. */
5441 sals
= get_catch_sals (0);
5445 /* Grab selected catch clauses. */
5446 error ("catch NAME not implemented");
5449 /* Not sure why this code has been disabled. I'm leaving
5450 it disabled. We can never come here now anyway
5451 since we don't allow the "catch NAME" syntax.
5454 /* This isn't used; I don't know what it was for. */
5455 sals
= map_catch_names (arg
, catch_breakpoint
);
5463 for (i
= 0; i
< sals
.nelts
; i
++)
5465 resolve_sal_pc (&sals
.sals
[i
]);
5469 if (arg
[0] == 'i' && arg
[1] == 'f'
5470 && (arg
[2] == ' ' || arg
[2] == '\t'))
5471 cond
= parse_exp_1 ((arg
+= 2, &arg
),
5472 block_for_pc (sals
.sals
[i
].pc
), 0);
5474 error ("Junk at end of arguments.");
5479 for (i
= 0; i
< sals
.nelts
; i
++)
5484 describe_other_breakpoints (sal
.pc
, sal
.section
);
5486 b
= set_raw_breakpoint (sal
);
5487 set_breakpoint_count (breakpoint_count
+ 1);
5488 b
->number
= breakpoint_count
;
5490 /* Important -- this is an ordinary breakpoint. For platforms
5491 with callback support for exceptions,
5492 create_exception_catchpoint() will create special bp types
5493 (bp_catch_catch and bp_catch_throw), and there is code in
5494 insert_breakpoints() and elsewhere that depends on that. */
5495 b
->type
= bp_breakpoint
;
5498 b
->enable
= enabled
;
5499 b
->disposition
= tempflag
? del
: donttouch
;
5506 warning ("Multiple breakpoints were set.");
5507 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5509 free ((PTR
) sals
.sals
);
5513 /* This creates a temporary internal breakpoint
5514 just to placate infrun */
5515 static struct breakpoint
*
5516 create_temp_exception_breakpoint (pc
)
5519 struct symtab_and_line sal
;
5520 struct breakpoint
*b
;
5527 b
= set_raw_breakpoint (sal
);
5529 error ("Internal error -- couldn't set temp exception breakpoint");
5531 b
->type
= bp_breakpoint
;
5532 b
->disposition
= del
;
5533 b
->enable
= enabled
;
5535 b
->number
= internal_breakpoint_number
--;
5541 catch_command_1 (arg
, tempflag
, from_tty
)
5547 /* The first argument may be an event name, such as "start" or "load".
5548 If so, then handle it as such. If it doesn't match an event name,
5549 then attempt to interpret it as an exception name. (This latter is
5550 the v4.16-and-earlier GDB meaning of the "catch" command.)
5552 First, try to find the bounds of what might be an event name. */
5553 char *arg1_start
= arg
;
5557 if (arg1_start
== NULL
)
5559 /* Old behaviour was to use pre-v-4.16 syntax */
5560 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5562 /* Now, this is not allowed */
5563 error ("Catch requires an event name.");
5566 arg1_end
= ep_find_event_name_end (arg1_start
);
5567 if (arg1_end
== NULL
)
5568 error ("catch requires an event");
5569 arg1_length
= arg1_end
+ 1 - arg1_start
;
5571 /* Try to match what we found against known event names. */
5572 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
5574 error ("Catch of signal not yet implemented");
5576 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
5578 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
5579 tempflag
, from_tty
);
5581 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
5583 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
5584 tempflag
, from_tty
);
5586 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
5588 error ("Catch of thread_start not yet implemented");
5590 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
5592 error ("Catch of thread_exit not yet implemented");
5594 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
5596 error ("Catch of thread_join not yet implemented");
5598 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
5600 error ("Catch of start not yet implemented");
5602 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
5604 error ("Catch of exit not yet implemented");
5606 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
5608 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5609 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
5611 error ("Catch of fork not yet implemented");
5614 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
5616 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5617 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
5619 error ("Catch of vfork not yet implemented");
5622 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
5624 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5625 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5627 error ("Catch of exec not yet implemented");
5630 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
5632 #if defined(SOLIB_ADD)
5633 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5635 error ("Catch of load not implemented");
5638 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
5640 #if defined(SOLIB_ADD)
5641 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5643 error ("Catch of load not implemented");
5646 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
5648 error ("Catch of stop not yet implemented");
5651 /* This doesn't appear to be an event name */
5655 /* Pre-v.4.16 behaviour was to treat the argument
5656 as the name of an exception */
5657 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5658 /* Now this is not allowed */
5659 error ("Unknown event kind specified for catch");
5664 /* Used by the gui, could be made a worker for other things. */
5667 set_breakpoint_sal (sal
)
5668 struct symtab_and_line sal
;
5670 struct breakpoint
*b
;
5671 b
= set_raw_breakpoint (sal
);
5672 set_breakpoint_count (breakpoint_count
+ 1);
5673 b
->number
= breakpoint_count
;
5674 b
->type
= bp_breakpoint
;
5681 /* These aren't used; I don't know what they were for. */
5682 /* Disable breakpoints on all catch clauses described in ARGS. */
5684 disable_catch (args
)
5687 /* Map the disable command to catch clauses described in ARGS. */
5690 /* Enable breakpoints on all catch clauses described in ARGS. */
5695 /* Map the disable command to catch clauses described in ARGS. */
5698 /* Delete breakpoints on all catch clauses in the active scope. */
5703 /* Map the delete command to catch clauses described in ARGS. */
5708 catch_command (arg
, from_tty
)
5712 catch_command_1 (arg
, 0, from_tty
);
5717 tcatch_command (arg
, from_tty
)
5721 catch_command_1 (arg
, 1, from_tty
);
5726 clear_command (arg
, from_tty
)
5730 register struct breakpoint
*b
, *b1
;
5732 struct symtabs_and_lines sals
;
5733 struct symtab_and_line sal
;
5734 register struct breakpoint
*found
;
5739 sals
= decode_line_spec (arg
, 1);
5744 sals
.sals
= (struct symtab_and_line
*)
5745 xmalloc (sizeof (struct symtab_and_line
));
5746 INIT_SAL (&sal
); /* initialize to zeroes */
5747 sal
.line
= default_breakpoint_line
;
5748 sal
.symtab
= default_breakpoint_symtab
;
5749 sal
.pc
= default_breakpoint_address
;
5750 if (sal
.symtab
== 0)
5751 error ("No source file specified.");
5759 /* For each line spec given, delete bps which correspond
5760 to it. We do this in two loops: the first loop looks at
5761 the initial bp(s) in the chain which should be deleted,
5762 the second goes down the rest of the chain looking ahead
5763 one so it can take those bps off the chain without messing
5767 for (i
= 0; i
< sals
.nelts
; i
++)
5769 /* If exact pc given, clear bpts at that pc.
5770 If line given (pc == 0), clear all bpts on specified line.
5771 If defaulting, clear all bpts on default line
5774 defaulting sal.pc != 0 tests to do
5779 1 0 <can't happen> */
5782 found
= (struct breakpoint
*) 0;
5785 while (breakpoint_chain
5786 /* Why don't we check here that this is not
5787 a watchpoint, etc., as we do below?
5788 I can't make it fail, but don't know
5789 what's stopping the failure: a watchpoint
5790 of the same address as "sal.pc" should
5791 wind up being deleted. */
5793 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
5794 (overlay_debugging
== 0 ||
5795 breakpoint_chain
->section
== sal
.section
))
5796 || ((default_match
|| (0 == sal
.pc
))
5797 && breakpoint_chain
->source_file
!= NULL
5798 && sal
.symtab
!= NULL
5799 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
5800 && breakpoint_chain
->line_number
== sal
.line
)))
5803 b1
= breakpoint_chain
;
5804 breakpoint_chain
= b1
->next
;
5812 && b
->next
->type
!= bp_none
5813 && b
->next
->type
!= bp_watchpoint
5814 && b
->next
->type
!= bp_hardware_watchpoint
5815 && b
->next
->type
!= bp_read_watchpoint
5816 && b
->next
->type
!= bp_access_watchpoint
5817 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
5818 (overlay_debugging
== 0 ||
5819 b
->next
->section
== sal
.section
))
5820 || ((default_match
|| (0 == sal
.pc
))
5821 && b
->next
->source_file
!= NULL
5822 && sal
.symtab
!= NULL
5823 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
5824 && b
->next
->line_number
== sal
.line
)))
5837 error ("No breakpoint at %s.", arg
);
5839 error ("No breakpoint at this line.");
5843 from_tty
= 1; /* Always report if deleted more than one */
5845 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
5846 breakpoints_changed ();
5850 printf_unfiltered ("%d ", found
->number
);
5852 delete_breakpoint (found
);
5856 putchar_unfiltered ('\n');
5858 free ((PTR
) sals
.sals
);
5861 /* Delete breakpoint in BS if they are `delete' breakpoints and
5862 all breakpoints that are marked for deletion, whether hit or not.
5863 This is called after any breakpoint is hit, or after errors. */
5866 breakpoint_auto_delete (bs
)
5869 struct breakpoint
*b
, *temp
;
5871 for (; bs
; bs
= bs
->next
)
5872 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
5874 delete_breakpoint (bs
->breakpoint_at
);
5876 ALL_BREAKPOINTS_SAFE (b
, temp
)
5878 if (b
->disposition
== del_at_next_stop
)
5879 delete_breakpoint (b
);
5883 /* Delete a breakpoint and clean up all traces of it in the data
5887 delete_breakpoint (bpt
)
5888 struct breakpoint
*bpt
;
5890 register struct breakpoint
*b
;
5894 error ("Internal error (attempted to delete a NULL breakpoint)");
5897 /* Has this bp already been deleted? This can happen because multiple
5898 lists can hold pointers to bp's. bpstat lists are especial culprits.
5900 One example of this happening is a watchpoint's scope bp. When the
5901 scope bp triggers, we notice that the watchpoint is out of scope, and
5902 delete it. We also delete its scope bp. But the scope bp is marked
5903 "auto-deleting", and is already on a bpstat. That bpstat is then
5904 checked for auto-deleting bp's, which are deleted.
5906 A real solution to this problem might involve reference counts in bp's,
5907 and/or giving them pointers back to their referencing bpstat's, and
5908 teaching delete_breakpoint to only free a bp's storage when no more
5909 references were extent. A cheaper bandaid was chosen. */
5910 if (bpt
->type
== bp_none
)
5913 if (delete_breakpoint_hook
)
5914 delete_breakpoint_hook (bpt
);
5915 breakpoint_delete_event (bpt
->number
);
5918 remove_breakpoint (bpt
, mark_uninserted
);
5920 if (breakpoint_chain
== bpt
)
5921 breakpoint_chain
= bpt
->next
;
5923 /* If we have callback-style exception catchpoints, don't go through
5924 the adjustments to the C++ runtime library etc. if the inferior
5925 isn't actually running. target_enable_exception_callback for a
5926 null target ops vector gives an undesirable error message, so we
5927 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5928 exceptions are supported in this way, it's OK for now. FIXME */
5929 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
5931 static char message1
[] = "Error in deleting catchpoint %d:\n";
5932 static char message
[sizeof (message1
) + 30];
5933 args_for_catchpoint_enable args
;
5935 /* Format possible error msg */
5936 sprintf (message
, message1
, bpt
->number
);
5937 args
.kind
= bpt
->type
== bp_catch_catch
?
5938 EX_EVENT_CATCH
: EX_EVENT_THROW
;
5940 catch_errors (cover_target_enable_exception_callback
, &args
,
5941 message
, RETURN_MASK_ALL
);
5948 b
->next
= bpt
->next
;
5952 /* Before turning off the visuals for the bp, check to see that
5953 there are no other bps at the same address. */
5960 clearIt
= (b
->address
!= bpt
->address
);
5967 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
5968 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
5972 check_duplicates (bpt
->address
, bpt
->section
);
5973 /* If this breakpoint was inserted, and there is another breakpoint
5974 at the same address, we need to insert the other breakpoint. */
5976 && bpt
->type
!= bp_hardware_watchpoint
5977 && bpt
->type
!= bp_read_watchpoint
5978 && bpt
->type
!= bp_access_watchpoint
5979 && bpt
->type
!= bp_catch_fork
5980 && bpt
->type
!= bp_catch_vfork
5981 && bpt
->type
!= bp_catch_exec
)
5984 if (b
->address
== bpt
->address
5985 && b
->section
== bpt
->section
5987 && b
->enable
!= disabled
5988 && b
->enable
!= shlib_disabled
5989 && b
->enable
!= call_disabled
)
5993 /* We should never reach this point if there is a permanent
5994 breakpoint at the same address as the one being deleted.
5995 If there is a permanent breakpoint somewhere, it should
5996 always be the only one inserted. */
5997 if (b
->enable
== permanent
)
5998 internal_error ("another breakpoint was inserted on top of "
5999 "a permanent breakpoint");
6001 if (b
->type
== bp_hardware_breakpoint
)
6002 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6004 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6008 target_terminal_ours_for_output ();
6009 warning ("Cannot insert breakpoint %d:", b
->number
);
6010 memory_error (val
, b
->address
); /* which bombs us out */
6017 free_command_lines (&bpt
->commands
);
6020 if (bpt
->cond_string
!= NULL
)
6021 free (bpt
->cond_string
);
6022 if (bpt
->addr_string
!= NULL
)
6023 free (bpt
->addr_string
);
6024 if (bpt
->exp
!= NULL
)
6026 if (bpt
->exp_string
!= NULL
)
6027 free (bpt
->exp_string
);
6028 if (bpt
->val
!= NULL
)
6029 value_free (bpt
->val
);
6030 if (bpt
->source_file
!= NULL
)
6031 free (bpt
->source_file
);
6032 if (bpt
->dll_pathname
!= NULL
)
6033 free (bpt
->dll_pathname
);
6034 if (bpt
->triggered_dll_pathname
!= NULL
)
6035 free (bpt
->triggered_dll_pathname
);
6036 if (bpt
->exec_pathname
!= NULL
)
6037 free (bpt
->exec_pathname
);
6039 /* Be sure no bpstat's are pointing at it after it's been freed. */
6040 /* FIXME, how can we find all bpstat's?
6041 We just check stop_bpstat for now. */
6042 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6043 if (bs
->breakpoint_at
== bpt
)
6045 bs
->breakpoint_at
= NULL
;
6047 /* we'd call bpstat_clear_actions, but that free's stuff and due
6048 to the multiple pointers pointing to one item with no
6049 reference counts found anywhere through out the bpstat's (how
6050 do you spell fragile?), we don't want to free things twice --
6051 better a memory leak than a corrupt malloc pool! */
6052 bs
->commands
= NULL
;
6055 /* On the chance that someone will soon try again to delete this same
6056 bp, we mark it as deleted before freeing its storage. */
6057 bpt
->type
= bp_none
;
6063 delete_command (arg
, from_tty
)
6067 struct breakpoint
*b
, *temp
;
6071 int breaks_to_delete
= 0;
6073 /* Delete all breakpoints if no argument.
6074 Do not delete internal or call-dummy breakpoints, these
6075 have to be deleted with an explicit breakpoint number argument. */
6078 if (b
->type
!= bp_call_dummy
&&
6079 b
->type
!= bp_shlib_event
&&
6081 breaks_to_delete
= 1;
6084 /* Ask user only if there are some breakpoints to delete. */
6086 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6088 ALL_BREAKPOINTS_SAFE (b
, temp
)
6090 if (b
->type
!= bp_call_dummy
&&
6091 b
->type
!= bp_shlib_event
&&
6093 delete_breakpoint (b
);
6098 map_breakpoint_numbers (arg
, delete_breakpoint
);
6101 /* Reset a breakpoint given it's struct breakpoint * BINT.
6102 The value we return ends up being the return value from catch_errors.
6103 Unused in this case. */
6106 breakpoint_re_set_one (bint
)
6109 /* get past catch_errs */
6110 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6113 struct symtabs_and_lines sals
;
6115 enum enable save_enable
;
6120 warning ("attempted to reset apparently deleted breakpoint #%d?",
6124 case bp_hardware_breakpoint
:
6126 case bp_catch_unload
:
6127 if (b
->addr_string
== NULL
)
6129 /* Anything without a string can't be re-set. */
6130 delete_breakpoint (b
);
6133 /* In case we have a problem, disable this breakpoint. We'll restore
6134 its status if we succeed. */
6135 save_enable
= b
->enable
;
6136 b
->enable
= disabled
;
6138 set_language (b
->language
);
6139 input_radix
= b
->input_radix
;
6141 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
6142 for (i
= 0; i
< sals
.nelts
; i
++)
6144 resolve_sal_pc (&sals
.sals
[i
]);
6146 /* Reparse conditions, they might contain references to the
6148 if (b
->cond_string
!= NULL
)
6152 free ((PTR
) b
->cond
);
6153 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
6156 /* We need to re-set the breakpoint if the address changes... */
6157 if (b
->address
!= sals
.sals
[i
].pc
6158 /* ...or new and old breakpoints both have source files, and
6159 the source file name or the line number changes... */
6160 || (b
->source_file
!= NULL
6161 && sals
.sals
[i
].symtab
!= NULL
6162 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
6163 || b
->line_number
!= sals
.sals
[i
].line
)
6165 /* ...or we switch between having a source file and not having
6167 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
6170 if (b
->source_file
!= NULL
)
6171 free (b
->source_file
);
6172 if (sals
.sals
[i
].symtab
== NULL
)
6173 b
->source_file
= NULL
;
6176 savestring (sals
.sals
[i
].symtab
->filename
,
6177 strlen (sals
.sals
[i
].symtab
->filename
));
6178 b
->line_number
= sals
.sals
[i
].line
;
6179 b
->address
= sals
.sals
[i
].pc
;
6181 /* Used to check for duplicates here, but that can
6182 cause trouble, as it doesn't check for disable
6187 /* Might be better to do this just once per breakpoint_re_set,
6188 rather than once for every breakpoint. */
6189 breakpoints_changed ();
6191 b
->section
= sals
.sals
[i
].section
;
6192 b
->enable
= save_enable
; /* Restore it, this worked. */
6195 /* Now that this is re-enabled, check_duplicates
6197 check_duplicates (b
->address
, b
->section
);
6200 free ((PTR
) sals
.sals
);
6204 case bp_hardware_watchpoint
:
6205 case bp_read_watchpoint
:
6206 case bp_access_watchpoint
:
6207 innermost_block
= NULL
;
6208 /* The issue arises of what context to evaluate this in. The
6209 same one as when it was set, but what does that mean when
6210 symbols have been re-read? We could save the filename and
6211 functionname, but if the context is more local than that, the
6212 best we could do would be something like how many levels deep
6213 and which index at that particular level, but that's going to
6214 be less stable than filenames or function names. */
6216 /* So for now, just use a global context. */
6218 free ((PTR
) b
->exp
);
6219 b
->exp
= parse_expression (b
->exp_string
);
6220 b
->exp_valid_block
= innermost_block
;
6221 mark
= value_mark ();
6223 value_free (b
->val
);
6224 b
->val
= evaluate_expression (b
->exp
);
6225 release_value (b
->val
);
6226 if (VALUE_LAZY (b
->val
))
6227 value_fetch_lazy (b
->val
);
6229 if (b
->cond_string
!= NULL
)
6233 free ((PTR
) b
->cond
);
6234 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
6236 if (b
->enable
== enabled
)
6238 value_free_to_mark (mark
);
6240 case bp_catch_catch
:
6241 case bp_catch_throw
:
6243 /* We needn't really do anything to reset these, since the mask
6244 that requests them is unaffected by e.g., new libraries being
6247 case bp_catch_vfork
:
6252 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
6254 /* Delete longjmp breakpoints, they will be reset later by
6255 breakpoint_re_set. */
6257 case bp_longjmp_resume
:
6258 delete_breakpoint (b
);
6261 /* This breakpoint is special, it's set up when the inferior
6262 starts and we really don't want to touch it. */
6263 case bp_shlib_event
:
6265 /* Keep temporary breakpoints, which can be encountered when we step
6266 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6267 Otherwise these should have been blown away via the cleanup chain
6268 or by breakpoint_init_inferior when we rerun the executable. */
6271 case bp_watchpoint_scope
:
6273 case bp_step_resume
:
6280 /* Re-set all breakpoints after symbols have been re-loaded. */
6282 breakpoint_re_set ()
6284 struct breakpoint
*b
, *temp
;
6285 enum language save_language
;
6286 int save_input_radix
;
6287 static char message1
[] = "Error in re-setting breakpoint %d:\n";
6288 char message
[sizeof (message1
) + 30 /* slop */ ];
6290 save_language
= current_language
->la_language
;
6291 save_input_radix
= input_radix
;
6292 ALL_BREAKPOINTS_SAFE (b
, temp
)
6294 /* Format possible error msg */
6295 sprintf (message
, message1
, b
->number
);
6296 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
6298 set_language (save_language
);
6299 input_radix
= save_input_radix
;
6301 #ifdef GET_LONGJMP_TARGET
6302 create_longjmp_breakpoint ("longjmp");
6303 create_longjmp_breakpoint ("_longjmp");
6304 create_longjmp_breakpoint ("siglongjmp");
6305 create_longjmp_breakpoint ("_siglongjmp");
6306 create_longjmp_breakpoint (NULL
);
6310 /* Took this out (temporarily at least), since it produces an extra
6311 blank line at startup. This messes up the gdbtests. -PB */
6312 /* Blank line to finish off all those mention() messages we just printed. */
6313 printf_filtered ("\n");
6317 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6318 If from_tty is nonzero, it prints a message to that effect,
6319 which ends with a period (no newline). */
6321 /* Reset the thread number of this breakpoint:
6323 - If the breakpoint is for all threads, leave it as-is.
6324 - Else, reset it to the current thread for inferior_pid. */
6326 breakpoint_re_set_thread (b
)
6327 struct breakpoint
*b
;
6329 if (b
->thread
!= -1)
6331 if (in_thread_list (inferior_pid
))
6332 b
->thread
= pid_to_thread_id (inferior_pid
);
6337 set_ignore_count (bptnum
, count
, from_tty
)
6338 int bptnum
, count
, from_tty
;
6340 register struct breakpoint
*b
;
6346 if (b
->number
== bptnum
)
6348 b
->ignore_count
= count
;
6351 else if (count
== 0)
6352 printf_filtered ("Will stop next time breakpoint %d is reached.",
6354 else if (count
== 1)
6355 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6358 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6360 breakpoints_changed ();
6364 error ("No breakpoint number %d.", bptnum
);
6367 /* Clear the ignore counts of all breakpoints. */
6369 breakpoint_clear_ignore_counts ()
6371 struct breakpoint
*b
;
6374 b
->ignore_count
= 0;
6377 /* Command to set ignore-count of breakpoint N to COUNT. */
6380 ignore_command (args
, from_tty
)
6388 error_no_arg ("a breakpoint number");
6390 num
= get_number (&p
);
6393 error ("Second argument (specified ignore-count) is missing.");
6395 set_ignore_count (num
,
6396 longest_to_int (value_as_long (parse_and_eval (p
))),
6398 printf_filtered ("\n");
6399 breakpoints_changed ();
6402 /* Call FUNCTION on each of the breakpoints
6403 whose numbers are given in ARGS. */
6406 map_breakpoint_numbers (args
, function
)
6408 void (*function
) PARAMS ((struct breakpoint
*));
6410 register char *p
= args
;
6413 register struct breakpoint
*b
;
6416 error_no_arg ("one or more breakpoint numbers");
6422 num
= get_number (&p1
);
6425 if (b
->number
== num
)
6427 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
6429 if (related_breakpoint
)
6430 function (related_breakpoint
);
6433 printf_unfiltered ("No breakpoint number %d.\n", num
);
6440 disable_breakpoint (bpt
)
6441 struct breakpoint
*bpt
;
6443 /* Never disable a watchpoint scope breakpoint; we want to
6444 hit them when we leave scope so we can delete both the
6445 watchpoint and its scope breakpoint at that time. */
6446 if (bpt
->type
== bp_watchpoint_scope
)
6449 /* You can't disable permanent breakpoints. */
6450 if (bpt
->enable
== permanent
)
6453 bpt
->enable
= disabled
;
6455 check_duplicates (bpt
->address
, bpt
->section
);
6457 if (modify_breakpoint_hook
)
6458 modify_breakpoint_hook (bpt
);
6459 breakpoint_modify_event (bpt
->number
);
6464 disable_command (args
, from_tty
)
6468 register struct breakpoint
*bpt
;
6470 ALL_BREAKPOINTS (bpt
)
6474 warning ("attempted to disable apparently deleted breakpoint #%d?",
6479 case bp_catch_unload
:
6481 case bp_catch_vfork
:
6483 case bp_catch_catch
:
6484 case bp_catch_throw
:
6485 case bp_hardware_breakpoint
:
6487 case bp_hardware_watchpoint
:
6488 case bp_read_watchpoint
:
6489 case bp_access_watchpoint
:
6490 disable_breakpoint (bpt
);
6495 map_breakpoint_numbers (args
, disable_breakpoint
);
6499 do_enable_breakpoint (bpt
, disposition
)
6500 struct breakpoint
*bpt
;
6501 enum bpdisp disposition
;
6503 struct frame_info
*save_selected_frame
= NULL
;
6504 int save_selected_frame_level
= -1;
6505 int target_resources_ok
, other_type_used
;
6508 if (bpt
->type
== bp_hardware_breakpoint
)
6511 i
= hw_breakpoint_used_count ();
6512 target_resources_ok
=
6513 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
6515 if (target_resources_ok
== 0)
6516 error ("No hardware breakpoint support in the target.");
6517 else if (target_resources_ok
< 0)
6518 error ("Hardware breakpoints used exceeds limit.");
6521 if (bpt
->enable
!= permanent
)
6522 bpt
->enable
= enabled
;
6523 bpt
->disposition
= disposition
;
6524 check_duplicates (bpt
->address
, bpt
->section
);
6525 breakpoints_changed ();
6527 if (bpt
->type
== bp_watchpoint
||
6528 bpt
->type
== bp_hardware_watchpoint
||
6529 bpt
->type
== bp_read_watchpoint
||
6530 bpt
->type
== bp_access_watchpoint
)
6532 if (bpt
->exp_valid_block
!= NULL
)
6534 struct frame_info
*fr
=
6536 /* Ensure that we have the current frame. Else, this
6537 next query may pessimistically be answered as, "No,
6538 not within current scope". */
6539 get_current_frame ();
6540 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
6544 Cannot enable watchpoint %d because the block in which its expression\n\
6545 is valid is not currently in scope.\n", bpt
->number
);
6546 bpt
->enable
= disabled
;
6550 save_selected_frame
= selected_frame
;
6551 save_selected_frame_level
= selected_frame_level
;
6552 select_frame (fr
, -1);
6555 value_free (bpt
->val
);
6556 mark
= value_mark ();
6557 bpt
->val
= evaluate_expression (bpt
->exp
);
6558 release_value (bpt
->val
);
6559 if (VALUE_LAZY (bpt
->val
))
6560 value_fetch_lazy (bpt
->val
);
6562 if (bpt
->type
== bp_hardware_watchpoint
||
6563 bpt
->type
== bp_read_watchpoint
||
6564 bpt
->type
== bp_access_watchpoint
)
6566 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
6567 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
6569 /* Hack around 'unused var' error for some targets here */
6571 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6572 bpt
->type
, i
+ mem_cnt
, other_type_used
);
6573 /* we can consider of type is bp_hardware_watchpoint, convert to
6574 bp_watchpoint in the following condition */
6575 if (target_resources_ok
< 0)
6578 Cannot enable watchpoint %d because target watch resources\n\
6579 have been allocated for other watchpoints.\n", bpt
->number
);
6580 bpt
->enable
= disabled
;
6581 value_free_to_mark (mark
);
6586 if (save_selected_frame_level
>= 0)
6587 select_and_print_frame (save_selected_frame
,
6588 save_selected_frame_level
);
6589 value_free_to_mark (mark
);
6591 if (modify_breakpoint_hook
)
6592 modify_breakpoint_hook (bpt
);
6593 breakpoint_modify_event (bpt
->number
);
6597 enable_breakpoint (bpt
)
6598 struct breakpoint
*bpt
;
6600 do_enable_breakpoint (bpt
, bpt
->disposition
);
6603 /* The enable command enables the specified breakpoints (or all defined
6604 breakpoints) so they once again become (or continue to be) effective
6605 in stopping the inferior. */
6609 enable_command (args
, from_tty
)
6613 register struct breakpoint
*bpt
;
6615 ALL_BREAKPOINTS (bpt
)
6619 warning ("attempted to enable apparently deleted breakpoint #%d?",
6624 case bp_catch_unload
:
6626 case bp_catch_vfork
:
6628 case bp_catch_catch
:
6629 case bp_catch_throw
:
6630 case bp_hardware_breakpoint
:
6632 case bp_hardware_watchpoint
:
6633 case bp_read_watchpoint
:
6634 case bp_access_watchpoint
:
6635 enable_breakpoint (bpt
);
6640 map_breakpoint_numbers (args
, enable_breakpoint
);
6644 enable_once_breakpoint (bpt
)
6645 struct breakpoint
*bpt
;
6647 do_enable_breakpoint (bpt
, disable
);
6652 enable_once_command (args
, from_tty
)
6656 map_breakpoint_numbers (args
, enable_once_breakpoint
);
6660 enable_delete_breakpoint (bpt
)
6661 struct breakpoint
*bpt
;
6663 do_enable_breakpoint (bpt
, del
);
6668 enable_delete_command (args
, from_tty
)
6672 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
6675 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6677 struct symtabs_and_lines
6678 decode_line_spec_1 (string
, funfirstline
)
6682 struct symtabs_and_lines sals
;
6684 error ("Empty line specification.");
6685 if (default_breakpoint_valid
)
6686 sals
= decode_line_1 (&string
, funfirstline
,
6687 default_breakpoint_symtab
,
6688 default_breakpoint_line
,
6691 sals
= decode_line_1 (&string
, funfirstline
,
6692 (struct symtab
*) NULL
, 0, (char ***) NULL
);
6694 error ("Junk at end of line specification: %s", string
);
6699 _initialize_breakpoint ()
6701 struct cmd_list_element
*c
;
6703 breakpoint_chain
= 0;
6704 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6705 before a breakpoint is set. */
6706 breakpoint_count
= 0;
6708 add_com ("ignore", class_breakpoint
, ignore_command
,
6709 "Set ignore-count of breakpoint number N to COUNT.\n\
6710 Usage is `ignore N COUNT'.");
6712 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
6714 add_com ("commands", class_breakpoint
, commands_command
,
6715 "Set commands to be executed when a breakpoint is hit.\n\
6716 Give breakpoint number as argument after \"commands\".\n\
6717 With no argument, the targeted breakpoint is the last one set.\n\
6718 The commands themselves follow starting on the next line.\n\
6719 Type a line containing \"end\" to indicate the end of them.\n\
6720 Give \"silent\" as the first line to make the breakpoint silent;\n\
6721 then no output is printed when it is hit, except what the commands print.");
6723 add_com ("condition", class_breakpoint
, condition_command
,
6724 "Specify breakpoint number N to break only if COND is true.\n\
6725 Usage is `condition N COND', where N is an integer and COND is an\n\
6726 expression to be evaluated whenever breakpoint N is reached. ");
6728 add_com ("tbreak", class_breakpoint
, tbreak_command
,
6729 "Set a temporary breakpoint. Args like \"break\" command.\n\
6730 Like \"break\" except the breakpoint is only temporary,\n\
6731 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6732 by using \"enable delete\" on the breakpoint number.");
6733 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
6734 "Set temporary breakpoint at procedure exit. Either there should\n\
6735 be no argument or the argument must be a depth.\n");
6737 add_com ("hbreak", class_breakpoint
, hbreak_command
,
6738 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6739 Like \"break\" except the breakpoint requires hardware support,\n\
6740 some target hardware may not have this support.");
6742 add_com ("thbreak", class_breakpoint
, thbreak_command
,
6743 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6744 Like \"hbreak\" except the breakpoint is only temporary,\n\
6745 so it will be deleted when hit.");
6747 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
6748 "Enable some breakpoints.\n\
6749 Give breakpoint numbers (separated by spaces) as arguments.\n\
6750 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6751 This is used to cancel the effect of the \"disable\" command.\n\
6752 With a subcommand you can enable temporarily.",
6753 &enablelist
, "enable ", 1, &cmdlist
);
6755 add_com ("ab", class_breakpoint
, enable_command
,
6756 "Enable some breakpoints.\n\
6757 Give breakpoint numbers (separated by spaces) as arguments.\n\
6758 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6759 This is used to cancel the effect of the \"disable\" command.\n\
6760 With a subcommand you can enable temporarily.");
6762 add_com_alias ("en", "enable", class_breakpoint
, 1);
6764 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
6765 "Enable some breakpoints.\n\
6766 Give breakpoint numbers (separated by spaces) as arguments.\n\
6767 This is used to cancel the effect of the \"disable\" command.\n\
6768 May be abbreviated to simply \"enable\".\n",
6769 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
6771 add_cmd ("once", no_class
, enable_once_command
,
6772 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6773 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6776 add_cmd ("delete", no_class
, enable_delete_command
,
6777 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6778 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6781 add_cmd ("delete", no_class
, enable_delete_command
,
6782 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6783 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6786 add_cmd ("once", no_class
, enable_once_command
,
6787 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6788 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6791 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
6792 "Disable some breakpoints.\n\
6793 Arguments are breakpoint numbers with spaces in between.\n\
6794 To disable all breakpoints, give no argument.\n\
6795 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6796 &disablelist
, "disable ", 1, &cmdlist
);
6797 add_com_alias ("dis", "disable", class_breakpoint
, 1);
6798 add_com_alias ("disa", "disable", class_breakpoint
, 1);
6800 add_com ("sb", class_breakpoint
, disable_command
,
6801 "Disable some breakpoints.\n\
6802 Arguments are breakpoint numbers with spaces in between.\n\
6803 To disable all breakpoints, give no argument.\n\
6804 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6806 add_cmd ("breakpoints", class_alias
, disable_command
,
6807 "Disable some breakpoints.\n\
6808 Arguments are breakpoint numbers with spaces in between.\n\
6809 To disable all breakpoints, give no argument.\n\
6810 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6811 This command may be abbreviated \"disable\".",
6814 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
6815 "Delete some breakpoints or auto-display expressions.\n\
6816 Arguments are breakpoint numbers with spaces in between.\n\
6817 To delete all breakpoints, give no argument.\n\
6819 Also a prefix command for deletion of other GDB objects.\n\
6820 The \"unset\" command is also an alias for \"delete\".",
6821 &deletelist
, "delete ", 1, &cmdlist
);
6822 add_com_alias ("d", "delete", class_breakpoint
, 1);
6824 add_com ("db", class_breakpoint
, delete_command
,
6825 "Delete some breakpoints.\n\
6826 Arguments are breakpoint numbers with spaces in between.\n\
6827 To delete all breakpoints, give no argument.\n");
6829 add_cmd ("breakpoints", class_alias
, delete_command
,
6830 "Delete some breakpoints or auto-display expressions.\n\
6831 Arguments are breakpoint numbers with spaces in between.\n\
6832 To delete all breakpoints, give no argument.\n\
6833 This command may be abbreviated \"delete\".",
6836 add_com ("clear", class_breakpoint
, clear_command
,
6837 concat ("Clear breakpoint at specified line or function.\n\
6838 Argument may be line number, function name, or \"*\" and an address.\n\
6839 If line number is specified, all breakpoints in that line are cleared.\n\
6840 If function is specified, breakpoints at beginning of function are cleared.\n\
6841 If an address is specified, breakpoints at that address are cleared.\n\n",
6842 "With no argument, clears all breakpoints in the line that the selected frame\n\
6845 See also the \"delete\" command which clears breakpoints by number.", NULL
));
6847 add_com ("break", class_breakpoint
, break_command
,
6848 concat ("Set breakpoint at specified line or function.\n\
6849 Argument may be line number, function name, or \"*\" and an address.\n\
6850 If line number is specified, break at start of code for that line.\n\
6851 If function is specified, break at start of code for that function.\n\
6852 If an address is specified, break at that exact address.\n",
6853 "With no arg, uses current execution address of selected stack frame.\n\
6854 This is useful for breaking on return to a stack frame.\n\
6856 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6858 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6859 add_com_alias ("b", "break", class_run
, 1);
6860 add_com_alias ("br", "break", class_run
, 1);
6861 add_com_alias ("bre", "break", class_run
, 1);
6862 add_com_alias ("brea", "break", class_run
, 1);
6864 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
6865 concat ("Set breakpoint at procedure exit. \n\
6866 Argument may be function name, or \"*\" and an address.\n\
6867 If function is specified, break at end of code for that function.\n\
6868 If an address is specified, break at the end of the function that contains \n\
6869 that exact address.\n",
6870 "With no arg, uses current execution address of selected stack frame.\n\
6871 This is useful for breaking on return to a stack frame.\n\
6873 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6875 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
6876 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
6877 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
6878 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
6879 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
6883 add_com_alias ("ba", "break", class_breakpoint
, 1);
6884 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
6885 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
6886 "Set breakpoint at procedure exit. Either there should\n\
6887 be no argument or the argument must be a depth.\n");
6892 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
6893 "Break in function/address or break at a line in the current file.",
6894 &stoplist
, "stop ", 1, &cmdlist
);
6895 add_cmd ("in", class_breakpoint
, stopin_command
,
6896 "Break in function or address.\n", &stoplist
);
6897 add_cmd ("at", class_breakpoint
, stopat_command
,
6898 "Break at a line in the current file.\n", &stoplist
);
6899 add_com ("status", class_info
, breakpoints_info
,
6900 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6901 The \"Type\" column indicates one of:\n\
6902 \tbreakpoint - normal breakpoint\n\
6903 \twatchpoint - watchpoint\n\
6904 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6905 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6906 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6907 address and file/line number respectively.\n\n",
6908 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6909 are set to the address of the last breakpoint listed.\n\n\
6910 Convenience variable \"$bpnum\" contains the number of the last\n\
6911 breakpoint set.", NULL
));
6914 add_info ("breakpoints", breakpoints_info
,
6915 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6916 The \"Type\" column indicates one of:\n\
6917 \tbreakpoint - normal breakpoint\n\
6918 \twatchpoint - watchpoint\n\
6919 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6920 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6921 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6922 address and file/line number respectively.\n\n",
6923 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6924 are set to the address of the last breakpoint listed.\n\n\
6925 Convenience variable \"$bpnum\" contains the number of the last\n\
6926 breakpoint set.", NULL
));
6929 add_com ("lb", class_breakpoint
, breakpoints_info
,
6930 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6931 The \"Type\" column indicates one of:\n\
6932 \tbreakpoint - normal breakpoint\n\
6933 \twatchpoint - watchpoint\n\
6934 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6935 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6936 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6937 address and file/line number respectively.\n\n",
6938 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6939 are set to the address of the last breakpoint listed.\n\n\
6940 Convenience variable \"$bpnum\" contains the number of the last\n\
6941 breakpoint set.", NULL
));
6943 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
6944 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6945 The \"Type\" column indicates one of:\n\
6946 \tbreakpoint - normal breakpoint\n\
6947 \twatchpoint - watchpoint\n\
6948 \tlongjmp - internal breakpoint used to step through longjmp()\n\
6949 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
6950 \tuntil - internal breakpoint used by the \"until\" command\n\
6951 \tfinish - internal breakpoint used by the \"finish\" command\n",
6952 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6953 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6954 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6955 address and file/line number respectively.\n\n",
6956 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6957 are set to the address of the last breakpoint listed.\n\n\
6958 Convenience variable \"$bpnum\" contains the number of the last\n\
6959 breakpoint set.", NULL
),
6960 &maintenanceinfolist
);
6962 add_com ("catch", class_breakpoint
, catch_command
,
6963 "Set catchpoints to catch events.\n\
6964 Raised signals may be caught:\n\
6965 \tcatch signal - all signals\n\
6966 \tcatch signal <signame> - a particular signal\n\
6967 Raised exceptions may be caught:\n\
6968 \tcatch throw - all exceptions, when thrown\n\
6969 \tcatch throw <exceptname> - a particular exception, when thrown\n\
6970 \tcatch catch - all exceptions, when caught\n\
6971 \tcatch catch <exceptname> - a particular exception, when caught\n\
6972 Thread or process events may be caught:\n\
6973 \tcatch thread_start - any threads, just after creation\n\
6974 \tcatch thread_exit - any threads, just before expiration\n\
6975 \tcatch thread_join - any threads, just after joins\n\
6976 Process events may be caught:\n\
6977 \tcatch start - any processes, just after creation\n\
6978 \tcatch exit - any processes, just before expiration\n\
6979 \tcatch fork - calls to fork()\n\
6980 \tcatch vfork - calls to vfork()\n\
6981 \tcatch exec - calls to exec()\n\
6982 Dynamically-linked library events may be caught:\n\
6983 \tcatch load - loads of any library\n\
6984 \tcatch load <libname> - loads of a particular library\n\
6985 \tcatch unload - unloads of any library\n\
6986 \tcatch unload <libname> - unloads of a particular library\n\
6987 The act of your program's execution stopping may also be caught:\n\
6989 C++ exceptions may be caught:\n\
6990 \tcatch throw - all exceptions, when thrown\n\
6991 \tcatch catch - all exceptions, when caught\n\
6993 Do \"help set follow-fork-mode\" for info on debugging your program\n\
6994 after a fork or vfork is caught.\n\n\
6995 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
6997 add_com ("tcatch", class_breakpoint
, tcatch_command
,
6998 "Set temporary catchpoints to catch events.\n\
6999 Args like \"catch\" command.\n\
7000 Like \"catch\" except the catchpoint is only temporary,\n\
7001 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7002 by using \"enable delete\" on the catchpoint number.");
7004 add_com ("watch", class_breakpoint
, watch_command
,
7005 "Set a watchpoint for an expression.\n\
7006 A watchpoint stops execution of your program whenever the value of\n\
7007 an expression changes.");
7009 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7010 "Set a read watchpoint for an expression.\n\
7011 A watchpoint stops execution of your program whenever the value of\n\
7012 an expression is read.");
7014 add_com ("awatch", class_breakpoint
, awatch_command
,
7015 "Set a watchpoint for an expression.\n\
7016 A watchpoint stops execution of your program whenever the value of\n\
7017 an expression is either read or written.");
7019 add_info ("watchpoints", breakpoints_info
,
7020 "Synonym for ``info breakpoints''.");
7023 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7024 (char *) &can_use_hw_watchpoints
,
7025 "Set debugger's willingness to use watchpoint hardware.\n\
7026 If zero, gdb will not use hardware for new watchpoints, even if\n\
7027 such is available. (However, any hardware watchpoints that were\n\
7028 created before setting this to nonzero, will continue to use watchpoint\n\
7031 add_show_from_set (c
, &showlist
);
7033 can_use_hw_watchpoints
= 1;