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_trailer
PARAMS ((char **, int));
143 set_breakpoint_count
PARAMS ((int));
146 static struct breakpoint
*
147 create_temp_exception_breakpoint
PARAMS ((CORE_ADDR
));
158 remove_breakpoint
PARAMS ((struct breakpoint
*, insertion_state_t
));
160 static enum print_stop_action print_it_typical
PARAMS ((bpstat
));
162 static enum print_stop_action
print_bp_stop_message (bpstat bs
);
166 enum exception_event_kind kind
;
169 args_for_catchpoint_enable
;
171 static int watchpoint_check
PARAMS ((PTR
));
173 static int cover_target_enable_exception_callback
PARAMS ((PTR
));
175 static void maintenance_info_breakpoints
PARAMS ((char *, int));
177 #ifdef GET_LONGJMP_TARGET
178 static void create_longjmp_breakpoint
PARAMS ((char *));
181 static int hw_breakpoint_used_count
PARAMS ((void));
183 static int hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
185 static void hbreak_command
PARAMS ((char *, int));
187 static void thbreak_command
PARAMS ((char *, int));
189 static void watch_command_1
PARAMS ((char *, int, int));
191 static void rwatch_command
PARAMS ((char *, int));
193 static void awatch_command
PARAMS ((char *, int));
195 static void do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
197 static void solib_load_unload_1
PARAMS ((char *hookname
,
201 enum bptype bp_kind
));
203 static void create_fork_vfork_event_catchpoint
PARAMS ((int tempflag
,
205 enum bptype bp_kind
));
207 static void break_at_finish_at_depth_command_1
PARAMS ((char *arg
,
211 static void break_at_finish_command_1
PARAMS ((char *arg
,
215 static void stop_command
PARAMS ((char *arg
, int from_tty
));
217 static void stopin_command
PARAMS ((char *arg
, int from_tty
));
219 static void stopat_command
PARAMS ((char *arg
, int from_tty
));
221 static char *ep_find_event_name_end
PARAMS ((char *arg
));
223 static char *ep_parse_optional_if_clause
PARAMS ((char **arg
));
225 static char *ep_parse_optional_filename
PARAMS ((char **arg
));
227 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
228 static void catch_exec_command_1
PARAMS ((char *arg
, int tempflag
,
232 static void create_exception_catchpoint
233 PARAMS ((int tempflag
, char *cond_string
,
234 enum exception_event_kind ex_event
,
235 struct symtab_and_line
* sal
));
237 static void catch_exception_command_1
238 PARAMS ((enum exception_event_kind ex_event
,
239 char *arg
, int tempflag
, int from_tty
));
241 static void tcatch_command
PARAMS ((char *arg
, int from_tty
));
243 static void ep_skip_leading_whitespace
PARAMS ((char **s
));
245 /* Prototypes for exported functions. */
248 awatch_command
PARAMS ((char *, int));
251 do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
253 /* If FALSE, gdb will not use hardware support for watchpoints, even
254 if such is available. */
255 static int can_use_hw_watchpoints
;
257 void _initialize_breakpoint
PARAMS ((void));
259 void set_breakpoint_count
PARAMS ((int));
261 extern int addressprint
; /* Print machine addresses? */
263 static int internal_breakpoint_number
= -1;
265 /* Are we executing breakpoint commands? */
266 static int executing_breakpoint_commands
;
268 /* Walk the following statement or block through all breakpoints.
269 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
272 #define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
274 #define ALL_BREAKPOINTS_SAFE(B,TMP) \
275 for (B = breakpoint_chain; \
276 B ? (TMP=B->next, 1): 0; \
279 /* True if SHIFT_INST_REGS defined, false otherwise. */
281 int must_shift_inst_regs
=
282 #if defined(SHIFT_INST_REGS)
289 /* True if breakpoint hit counts should be displayed in breakpoint info. */
291 int show_breakpoint_hit_counts
= 1;
293 /* Chain of all breakpoints defined. */
295 struct breakpoint
*breakpoint_chain
;
297 /* Number of last breakpoint made. */
299 int breakpoint_count
;
301 /* Pointer to current exception event record */
302 static struct exception_event_record
*current_exception_event
;
304 /* Indicator of whether exception catchpoints should be nuked
305 between runs of a program */
306 int exception_catchpoints_are_fragile
= 0;
308 /* Indicator of when exception catchpoints set-up should be
309 reinitialized -- e.g. when program is re-run */
310 int exception_support_initialized
= 0;
312 /* This function returns a pointer to the string representation of the
313 pathname of the dynamically-linked library that has just been
316 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
317 or undefined results are guaranteed.
319 This string's contents are only valid immediately after the
320 inferior has stopped in the dynamic linker hook, and becomes
321 invalid as soon as the inferior is continued. Clients should make
322 a copy of this string if they wish to continue the inferior and
323 then access the string. */
325 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
326 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
329 /* This function returns a pointer to the string representation of the
330 pathname of the dynamically-linked library that has just been
333 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
334 TRUE, or undefined results are guaranteed.
336 This string's contents are only valid immediately after the
337 inferior has stopped in the dynamic linker hook, and becomes
338 invalid as soon as the inferior is continued. Clients should make
339 a copy of this string if they wish to continue the inferior and
340 then access the string. */
342 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
343 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
346 /* This function is called by the "catch load" command. It allows the
347 debugger to be notified by the dynamic linker when a specified
348 library file (or any library file, if filename is NULL) is loaded. */
350 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
351 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
352 error ("catch of library loads not yet implemented on this platform")
355 /* This function is called by the "catch unload" command. It allows
356 the debugger to be notified by the dynamic linker when a specified
357 library file (or any library file, if filename is NULL) is
360 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
361 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
362 error ("catch of library unloads not yet implemented on this platform")
365 /* Set breakpoint count to NUM. */
368 set_breakpoint_count (num
)
371 breakpoint_count
= num
;
372 set_internalvar (lookup_internalvar ("bpnum"),
373 value_from_longest (builtin_type_int
, (LONGEST
) num
));
376 /* Used in run_command to zero the hit count when a new run starts. */
379 clear_breakpoint_hit_counts ()
381 struct breakpoint
*b
;
387 /* Default address, symtab and line to put a breakpoint at
388 for "break" command with no arg.
389 if default_breakpoint_valid is zero, the other three are
390 not valid, and "break" with no arg is an error.
392 This set by print_stack_frame, which calls set_default_breakpoint. */
394 int default_breakpoint_valid
;
395 CORE_ADDR default_breakpoint_address
;
396 struct symtab
*default_breakpoint_symtab
;
397 int default_breakpoint_line
;
399 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
400 Advance *PP after the string and any trailing whitespace.
402 Currently the string can either be a number or "$" followed by the name
403 of a convenience variable. Making it an expression wouldn't work well
404 for map_breakpoint_numbers (e.g. "4 + 5 + 6").
406 TRAILER is a character which can be found after the number; most
407 commonly this is `-'. If you don't want a trailer, use \0. */
409 get_number_trailer (pp
, trailer
)
413 int retval
= 0; /* default */
417 /* Empty line means refer to the last breakpoint. */
418 return breakpoint_count
;
421 /* Make a copy of the name, so we can null-terminate it
422 to pass to lookup_internalvar(). */
427 while (isalnum (*p
) || *p
== '_')
429 varname
= (char *) alloca (p
- start
+ 1);
430 strncpy (varname
, start
, p
- start
);
431 varname
[p
- start
] = '\0';
432 val
= value_of_internalvar (lookup_internalvar (varname
));
433 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_INT
)
434 retval
= (int) value_as_long (val
);
437 printf_filtered ("Convenience variable must have integer value.\n");
445 while (*p
>= '0' && *p
<= '9')
448 /* There is no number here. (e.g. "cond a == b"). */
450 /* Skip non-numeric token */
451 while (*p
&& !isspace((int) *p
))
453 /* Return zero, which caller must interpret as error. */
459 if (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
461 /* Trailing junk: return 0 and let caller print error msg. */
462 while (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
473 /* Like get_number_trailer, but don't allow a trailer. */
478 return get_number_trailer (pp
, '\0');
481 /* Parse a number or a range.
482 * A number will be of the form handled by get_number.
483 * A range will be of the form <number1> - <number2>, and
484 * will represent all the integers between number1 and number2,
487 * While processing a range, this fuction is called iteratively;
488 * At each call it will return the next value in the range.
490 * At the beginning of parsing a range, the char pointer PP will
491 * be advanced past <number1> and left pointing at the '-' token.
492 * Subsequent calls will not advance the pointer until the range
493 * is completed. The call that completes the range will advance
494 * pointer PP past <number2>.
498 get_number_or_range (pp
)
501 static int last_retval
, end_value
;
502 static char *end_ptr
;
503 static int in_range
= 0;
507 /* Default case: pp is pointing either to a solo number,
508 or to the first number of a range. */
509 last_retval
= get_number_trailer (pp
, '-');
514 /* This is the start of a range (<number1> - <number2>).
515 Skip the '-', parse and remember the second number,
516 and also remember the end of the final token. */
520 while (isspace ((int) *end_ptr
))
521 end_ptr
++; /* skip white space */
522 end_value
= get_number (temp
);
523 if (end_value
< last_retval
)
525 error ("inverted range");
527 else if (end_value
== last_retval
)
529 /* degenerate range (number1 == number2). Advance the
530 token pointer so that the range will be treated as a
539 error ("negative value");
542 /* pp points to the '-' that betokens a range. All
543 number-parsing has already been done. Return the next
544 integer value (one greater than the saved previous value).
545 Do not advance the token pointer 'pp' until the end of range
548 if (++last_retval
== end_value
)
550 /* End of range reached; advance token pointer. */
560 /* condition N EXP -- set break condition of breakpoint N to EXP. */
563 condition_command (arg
, from_tty
)
567 register struct breakpoint
*b
;
572 error_no_arg ("breakpoint number");
575 bnum
= get_number (&p
);
577 error ("Bad breakpoint argument: '%s'", arg
);
580 if (b
->number
== bnum
)
584 free ((PTR
) b
->cond
);
587 if (b
->cond_string
!= NULL
)
588 free ((PTR
) b
->cond_string
);
593 b
->cond_string
= NULL
;
595 printf_filtered ("Breakpoint %d now unconditional.\n", bnum
);
600 /* I don't know if it matters whether this is the string the user
601 typed in or the decompiled expression. */
602 b
->cond_string
= savestring (arg
, strlen (arg
));
603 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->address
), 0);
605 error ("Junk at end of expression");
607 breakpoints_changed ();
611 error ("No breakpoint number %d.", bnum
);
616 commands_command (arg
, from_tty
)
620 register struct breakpoint
*b
;
623 struct command_line
*l
;
625 /* If we allowed this, we would have problems with when to
626 free the storage, if we change the commands currently
629 if (executing_breakpoint_commands
)
630 error ("Can't use the \"commands\" command among a breakpoint's commands.");
633 bnum
= get_number (&p
);
636 error ("Unexpected extra arguments following breakpoint number.");
639 if (b
->number
== bnum
)
643 "Type commands for when breakpoint %d is hit, one per line.",
645 l
= read_command_lines (tmpbuf
, from_tty
);
646 free_command_lines (&b
->commands
);
648 breakpoints_changed ();
651 error ("No breakpoint number %d.", bnum
);
654 /* Like target_read_memory() but if breakpoints are inserted, return
655 the shadow contents instead of the breakpoints themselves.
657 Read "memory data" from whatever target or inferior we have.
658 Returns zero if successful, errno value if not. EIO is used
659 for address out of bounds. If breakpoints are inserted, returns
660 shadow contents, not the breakpoints themselves. From breakpoint.c. */
663 read_memory_nobpt (memaddr
, myaddr
, len
)
669 struct breakpoint
*b
;
670 CORE_ADDR bp_addr
= 0;
673 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
674 /* No breakpoints on this machine. */
675 return target_read_memory (memaddr
, myaddr
, len
);
679 if (b
->type
== bp_none
)
680 warning ("reading through apparently deleted breakpoint #%d?",
683 /* memory breakpoint? */
684 if (b
->type
== bp_watchpoint
685 || b
->type
== bp_hardware_watchpoint
686 || b
->type
== bp_read_watchpoint
687 || b
->type
== bp_access_watchpoint
)
692 /* Addresses and length of the part of the breakpoint that
694 /* XXXX The m68k, sh and h8300 have different local and remote
695 breakpoint values. BREAKPOINT_FROM_PC still manages to
696 correctly determine the breakpoints memory address and size
697 for these targets. */
698 bp_addr
= b
->address
;
700 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
705 if (bp_addr
+ bp_size
<= memaddr
)
706 /* The breakpoint is entirely before the chunk of memory we
709 if (bp_addr
>= memaddr
+ len
)
710 /* The breakpoint is entirely after the chunk of memory we are
713 /* Copy the breakpoint from the shadow contents, and recurse for
714 the things before and after. */
716 /* Offset within shadow_contents. */
719 if (bp_addr
< memaddr
)
721 /* Only copy the second part of the breakpoint. */
722 bp_size
-= memaddr
- bp_addr
;
723 bptoffset
= memaddr
- bp_addr
;
727 if (bp_addr
+ bp_size
> memaddr
+ len
)
729 /* Only copy the first part of the breakpoint. */
730 bp_size
-= (bp_addr
+ bp_size
) - (memaddr
+ len
);
733 memcpy (myaddr
+ bp_addr
- memaddr
,
734 b
->shadow_contents
+ bptoffset
, bp_size
);
736 if (bp_addr
> memaddr
)
738 /* Copy the section of memory before the breakpoint. */
739 status
= read_memory_nobpt (memaddr
, myaddr
, bp_addr
- memaddr
);
744 if (bp_addr
+ bp_size
< memaddr
+ len
)
746 /* Copy the section of memory after the breakpoint. */
747 status
= read_memory_nobpt
749 myaddr
+ bp_addr
+ bp_size
- memaddr
,
750 memaddr
+ len
- (bp_addr
+ bp_size
));
757 /* Nothing overlaps. Just call read_memory_noerr. */
758 return target_read_memory (memaddr
, myaddr
, len
);
762 /* insert_breakpoints is used when starting or continuing the program.
763 remove_breakpoints is used when the program stops.
764 Both return zero if successful,
765 or an `errno' value if could not write the inferior. */
768 insert_breakpoints ()
770 register struct breakpoint
*b
, *temp
;
771 int return_val
= 0; /* return success code. */
773 int disabled_breaks
= 0;
775 static char message1
[] = "Error inserting catchpoint %d:\n";
776 static char message
[sizeof (message1
) + 30];
779 ALL_BREAKPOINTS_SAFE (b
, temp
)
781 if (b
->enable
== permanent
)
782 /* Permanent breakpoints cannot be inserted or removed. */
784 else if (b
->type
!= bp_watchpoint
785 && b
->type
!= bp_hardware_watchpoint
786 && b
->type
!= bp_read_watchpoint
787 && b
->type
!= bp_access_watchpoint
788 && b
->type
!= bp_catch_fork
789 && b
->type
!= bp_catch_vfork
790 && b
->type
!= bp_catch_exec
791 && b
->type
!= bp_catch_throw
792 && b
->type
!= bp_catch_catch
793 && b
->enable
!= disabled
794 && b
->enable
!= shlib_disabled
795 && b
->enable
!= call_disabled
799 if (b
->type
== bp_hardware_breakpoint
)
800 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
803 /* Check to see if breakpoint is in an overlay section;
804 if so, we should set the breakpoint at the LMA address.
805 Only if the section is currently mapped should we ALSO
806 set a break at the VMA address. */
807 if (overlay_debugging
&& b
->section
&&
808 section_is_overlay (b
->section
))
812 addr
= overlay_unmapped_address (b
->address
, b
->section
);
813 val
= target_insert_breakpoint (addr
, b
->shadow_contents
);
814 /* This would be the time to check val, to see if the
815 breakpoint write to the load address succeeded.
816 However, this might be an ordinary occurrance, eg. if
817 the unmapped overlay is in ROM. */
818 val
= 0; /* in case unmapped address failed */
819 if (section_is_mapped (b
->section
))
820 val
= target_insert_breakpoint (b
->address
,
823 else /* ordinary (non-overlay) address */
824 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
828 /* Can't set the breakpoint. */
829 #if defined (DISABLE_UNSETTABLE_BREAK)
830 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
832 /* See also: disable_breakpoints_in_shlibs. */
834 b
->enable
= shlib_disabled
;
835 if (!disabled_breaks
)
837 target_terminal_ours_for_output ();
838 warning ("Cannot insert breakpoint %d:", b
->number
);
839 warning ("Temporarily disabling shared library breakpoints:");
842 warning ("breakpoint #%d ", b
->number
);
847 target_terminal_ours_for_output ();
848 warning ("Cannot insert breakpoint %d:", b
->number
);
849 #ifdef ONE_PROCESS_WRITETEXT
850 warning ("The same program may be running in another process.");
852 memory_error (val
, b
->address
); /* which bombs us out */
859 return_val
= val
; /* remember failure */
861 else if (ep_is_exception_catchpoint (b
)
862 && b
->enable
!= disabled
863 && b
->enable
!= shlib_disabled
864 && b
->enable
!= call_disabled
869 /* If we get here, we must have a callback mechanism for exception
870 events -- with g++ style embedded label support, we insert
871 ordinary breakpoints and not catchpoints. */
872 /* Format possible error message */
873 sprintf (message
, message1
, b
->number
);
875 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
878 /* Couldn't set breakpoint for some reason */
879 target_terminal_ours_for_output ();
880 warning ("Cannot insert catchpoint %d; disabling it.",
882 b
->enable
= disabled
;
886 /* Bp set, now make sure callbacks are enabled */
888 args_for_catchpoint_enable args
;
889 args
.kind
= b
->type
== bp_catch_catch
?
890 EX_EVENT_CATCH
: EX_EVENT_THROW
;
892 val
= catch_errors (cover_target_enable_exception_callback
,
894 message
, RETURN_MASK_ALL
);
895 if (val
!= 0 && val
!= -1)
899 /* Check if something went wrong; val == 0 can be ignored */
902 /* something went wrong */
903 target_terminal_ours_for_output ();
904 warning ("Cannot insert catchpoint %d; disabling it.",
906 b
->enable
= disabled
;
911 return_val
= val
; /* remember failure */
914 else if ((b
->type
== bp_hardware_watchpoint
||
915 b
->type
== bp_read_watchpoint
||
916 b
->type
== bp_access_watchpoint
)
917 && b
->enable
== enabled
921 struct frame_info
*saved_frame
;
922 int saved_level
, within_current_scope
;
923 value_ptr mark
= value_mark ();
926 /* Save the current frame and level so we can restore it after
927 evaluating the watchpoint expression on its own frame. */
928 saved_frame
= selected_frame
;
929 saved_level
= selected_frame_level
;
931 /* Determine if the watchpoint is within scope. */
932 if (b
->exp_valid_block
== NULL
)
933 within_current_scope
= 1;
936 struct frame_info
*fi
;
938 /* There might be no current frame at this moment if we are
939 resuming from a step over a breakpoint.
940 Set up current frame before trying to find the watchpoint
942 get_current_frame ();
943 fi
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
944 within_current_scope
= (fi
!= NULL
);
945 if (within_current_scope
)
946 select_frame (fi
, -1);
949 if (within_current_scope
)
951 /* Evaluate the expression and cut the chain of values
952 produced off from the value chain.
954 Make sure the value returned isn't lazy; we use
955 laziness to determine what memory GDB actually needed
956 in order to compute the value of the expression. */
957 v
= evaluate_expression (b
->exp
);
959 value_release_to_mark (mark
);
964 /* Look at each value on the value chain. */
965 for (; v
; v
= v
->next
)
967 /* If it's a memory location, and GDB actually needed
968 its contents to evaluate the expression, then we
970 if (VALUE_LVAL (v
) == lval_memory
976 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
977 len
= TYPE_LENGTH (VALUE_TYPE (v
));
979 if (b
->type
== bp_read_watchpoint
)
981 else if (b
->type
== bp_access_watchpoint
)
984 val
= target_insert_watchpoint (addr
, len
, type
);
993 /* Failure to insert a watchpoint on any memory value in the
994 value chain brings us here. */
997 remove_breakpoint (b
, mark_uninserted
);
998 warning ("Could not insert hardware watchpoint %d.",
1005 printf_filtered ("Hardware watchpoint %d deleted", b
->number
);
1006 printf_filtered ("because the program has left the block \n");
1007 printf_filtered ("in which its expression is valid.\n");
1008 if (b
->related_breakpoint
)
1009 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1010 b
->disposition
= del_at_next_stop
;
1013 /* Restore the frame and level. */
1014 if ((saved_frame
!= selected_frame
) ||
1015 (saved_level
!= selected_frame_level
))
1016 select_and_print_frame (saved_frame
, saved_level
);
1019 return_val
= val
; /* remember failure */
1021 else if ((b
->type
== bp_catch_fork
1022 || b
->type
== bp_catch_vfork
1023 || b
->type
== bp_catch_exec
)
1024 && b
->enable
== enabled
1032 val
= target_insert_fork_catchpoint (inferior_pid
);
1034 case bp_catch_vfork
:
1035 val
= target_insert_vfork_catchpoint (inferior_pid
);
1038 val
= target_insert_exec_catchpoint (inferior_pid
);
1041 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1046 target_terminal_ours_for_output ();
1047 warning ("Cannot insert catchpoint %d.", b
->number
);
1053 return_val
= val
; /* remember failure */
1062 remove_breakpoints ()
1064 register struct breakpoint
*b
;
1071 val
= remove_breakpoint (b
, mark_uninserted
);
1080 reattach_breakpoints (pid
)
1083 register struct breakpoint
*b
;
1085 int saved_inferior_pid
= inferior_pid
;
1087 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1088 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1093 remove_breakpoint (b
, mark_inserted
);
1094 if (b
->type
== bp_hardware_breakpoint
)
1095 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
1097 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
1100 inferior_pid
= saved_inferior_pid
;
1105 inferior_pid
= saved_inferior_pid
;
1110 update_breakpoints_after_exec ()
1112 struct breakpoint
*b
;
1113 struct breakpoint
*temp
;
1115 /* Doing this first prevents the badness of having delete_breakpoint()
1116 write a breakpoint's current "shadow contents" to lift the bp. That
1117 shadow is NOT valid after an exec()! */
1118 mark_breakpoints_out ();
1120 ALL_BREAKPOINTS_SAFE (b
, temp
)
1122 /* Solib breakpoints must be explicitly reset after an exec(). */
1123 if (b
->type
== bp_shlib_event
)
1125 delete_breakpoint (b
);
1129 /* Thread event breakpoints must be set anew after an exec(). */
1130 if (b
->type
== bp_thread_event
)
1132 delete_breakpoint (b
);
1136 /* Step-resume breakpoints are meaningless after an exec(). */
1137 if (b
->type
== bp_step_resume
)
1139 delete_breakpoint (b
);
1143 /* Ditto the sigtramp handler breakpoints. */
1144 if (b
->type
== bp_through_sigtramp
)
1146 delete_breakpoint (b
);
1150 /* Ditto the exception-handling catchpoints. */
1151 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1153 delete_breakpoint (b
);
1157 /* Don't delete an exec catchpoint, because else the inferior
1158 won't stop when it ought!
1160 Similarly, we probably ought to keep vfork catchpoints, 'cause
1161 on this target, we may not be able to stop when the vfork is
1162 seen, but only when the subsequent exec is seen. (And because
1163 deleting fork catchpoints here but not vfork catchpoints will
1164 seem mysterious to users, keep those too.)
1166 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1167 target address field, if any, is sufficient to have it be reset
1168 automagically. Certainly on HP-UX that's true. */
1169 if ((b
->type
== bp_catch_exec
) ||
1170 (b
->type
== bp_catch_vfork
) ||
1171 (b
->type
== bp_catch_fork
))
1173 b
->address
= (CORE_ADDR
) NULL
;
1177 /* bp_finish is a special case. The only way we ought to be able
1178 to see one of these when an exec() has happened, is if the user
1179 caught a vfork, and then said "finish". Ordinarily a finish just
1180 carries them to the call-site of the current callee, by setting
1181 a temporary bp there and resuming. But in this case, the finish
1182 will carry them entirely through the vfork & exec.
1184 We don't want to allow a bp_finish to remain inserted now. But
1185 we can't safely delete it, 'cause finish_command has a handle to
1186 the bp on a bpstat, and will later want to delete it. There's a
1187 chance (and I've seen it happen) that if we delete the bp_finish
1188 here, that its storage will get reused by the time finish_command
1189 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1190 We really must allow finish_command to delete a bp_finish.
1192 In the absense of a general solution for the "how do we know
1193 it's safe to delete something others may have handles to?"
1194 problem, what we'll do here is just uninsert the bp_finish, and
1195 let finish_command delete it.
1197 (We know the bp_finish is "doomed" in the sense that it's
1198 momentary, and will be deleted as soon as finish_command sees
1199 the inferior stopped. So it doesn't matter that the bp's
1200 address is probably bogus in the new a.out, unlike e.g., the
1201 solib breakpoints.) */
1203 if (b
->type
== bp_finish
)
1208 /* Without a symbolic address, we have little hope of the
1209 pre-exec() address meaning the same thing in the post-exec()
1211 if (b
->addr_string
== NULL
)
1213 delete_breakpoint (b
);
1217 /* If this breakpoint has survived the above battery of checks, then
1218 it must have a symbolic address. Be sure that it gets reevaluated
1219 to a target address, rather than reusing the old evaluation. */
1220 b
->address
= (CORE_ADDR
) NULL
;
1225 detach_breakpoints (pid
)
1228 register struct breakpoint
*b
;
1230 int saved_inferior_pid
= inferior_pid
;
1232 if (pid
== inferior_pid
)
1233 error ("Cannot detach breakpoints of inferior_pid");
1235 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1236 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1241 val
= remove_breakpoint (b
, mark_inserted
);
1244 inferior_pid
= saved_inferior_pid
;
1249 inferior_pid
= saved_inferior_pid
;
1254 remove_breakpoint (b
, is
)
1255 struct breakpoint
*b
;
1256 insertion_state_t is
;
1260 if (b
->enable
== permanent
)
1261 /* Permanent breakpoints cannot be inserted or removed. */
1264 if (b
->type
== bp_none
)
1265 warning ("attempted to remove apparently deleted breakpoint #%d?",
1268 if (b
->type
!= bp_watchpoint
1269 && b
->type
!= bp_hardware_watchpoint
1270 && b
->type
!= bp_read_watchpoint
1271 && b
->type
!= bp_access_watchpoint
1272 && b
->type
!= bp_catch_fork
1273 && b
->type
!= bp_catch_vfork
1274 && b
->type
!= bp_catch_exec
1275 && b
->type
!= bp_catch_catch
1276 && b
->type
!= bp_catch_throw
)
1278 if (b
->type
== bp_hardware_breakpoint
)
1279 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1282 /* Check to see if breakpoint is in an overlay section;
1283 if so, we should remove the breakpoint at the LMA address.
1284 If that is not equal to the raw address, then we should
1285 presumable remove the breakpoint there as well. */
1286 if (overlay_debugging
&& b
->section
&&
1287 section_is_overlay (b
->section
))
1291 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1292 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1293 /* This would be the time to check val, to see if the
1294 shadow breakpoint write to the load address succeeded.
1295 However, this might be an ordinary occurrance, eg. if
1296 the unmapped overlay is in ROM. */
1297 val
= 0; /* in case unmapped address failed */
1298 if (section_is_mapped (b
->section
))
1299 val
= target_remove_breakpoint (b
->address
,
1300 b
->shadow_contents
);
1302 else /* ordinary (non-overlay) address */
1303 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1307 b
->inserted
= (is
== mark_inserted
);
1309 else if ((b
->type
== bp_hardware_watchpoint
||
1310 b
->type
== bp_read_watchpoint
||
1311 b
->type
== bp_access_watchpoint
)
1312 && b
->enable
== enabled
1317 b
->inserted
= (is
== mark_inserted
);
1318 /* Walk down the saved value chain. */
1319 for (v
= b
->val_chain
; v
; v
= v
->next
)
1321 /* For each memory reference remove the watchpoint
1323 if (VALUE_LVAL (v
) == lval_memory
1324 && ! VALUE_LAZY (v
))
1329 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1330 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1332 if (b
->type
== bp_read_watchpoint
)
1334 else if (b
->type
== bp_access_watchpoint
)
1337 val
= target_remove_watchpoint (addr
, len
, type
);
1343 /* Failure to remove any of the hardware watchpoints comes here. */
1344 if ((is
== mark_uninserted
) && (b
->inserted
))
1345 warning ("Could not remove hardware watchpoint %d.",
1348 /* Free the saved value chain. We will construct a new one
1349 the next time the watchpoint is inserted. */
1350 for (v
= b
->val_chain
; v
; v
= n
)
1355 b
->val_chain
= NULL
;
1357 else if ((b
->type
== bp_catch_fork
||
1358 b
->type
== bp_catch_vfork
||
1359 b
->type
== bp_catch_exec
)
1360 && b
->enable
== enabled
1367 val
= target_remove_fork_catchpoint (inferior_pid
);
1369 case bp_catch_vfork
:
1370 val
= target_remove_vfork_catchpoint (inferior_pid
);
1373 val
= target_remove_exec_catchpoint (inferior_pid
);
1376 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1381 b
->inserted
= (is
== mark_inserted
);
1383 else if ((b
->type
== bp_catch_catch
||
1384 b
->type
== bp_catch_throw
)
1385 && b
->enable
== enabled
1389 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1392 b
->inserted
= (is
== mark_inserted
);
1394 else if (ep_is_exception_catchpoint (b
)
1395 && b
->inserted
/* sometimes previous insert doesn't happen */
1396 && b
->enable
== enabled
1400 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1404 b
->inserted
= (is
== mark_inserted
);
1410 /* Clear the "inserted" flag in all breakpoints. */
1413 mark_breakpoints_out ()
1415 register struct breakpoint
*b
;
1421 /* Clear the "inserted" flag in all breakpoints and delete any
1422 breakpoints which should go away between runs of the program.
1424 Plus other such housekeeping that has to be done for breakpoints
1427 Note: this function gets called at the end of a run (by
1428 generic_mourn_inferior) and when a run begins (by
1429 init_wait_for_inferior). */
1434 breakpoint_init_inferior (context
)
1435 enum inf_context context
;
1437 register struct breakpoint
*b
, *temp
;
1438 static int warning_needed
= 0;
1440 ALL_BREAKPOINTS_SAFE (b
, temp
)
1447 case bp_watchpoint_scope
:
1449 /* If the call dummy breakpoint is at the entry point it will
1450 cause problems when the inferior is rerun, so we better
1453 Also get rid of scope breakpoints. */
1454 delete_breakpoint (b
);
1458 case bp_hardware_watchpoint
:
1459 case bp_read_watchpoint
:
1460 case bp_access_watchpoint
:
1462 /* Likewise for watchpoints on local expressions. */
1463 if (b
->exp_valid_block
!= NULL
)
1464 delete_breakpoint (b
);
1467 /* Likewise for exception catchpoints in dynamic-linked
1468 executables where required */
1469 if (ep_is_exception_catchpoint (b
) &&
1470 exception_catchpoints_are_fragile
)
1473 delete_breakpoint (b
);
1479 if (exception_catchpoints_are_fragile
)
1480 exception_support_initialized
= 0;
1482 /* Don't issue the warning unless it's really needed... */
1483 if (warning_needed
&& (context
!= inf_exited
))
1485 warning ("Exception catchpoints from last run were deleted.");
1486 warning ("You must reinsert them explicitly.");
1491 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1492 exists at PC. It returns ordinary_breakpoint_here if it's an
1493 ordinary breakpoint, or permanent_breakpoint_here if it's a
1494 permanent breakpoint.
1495 - When continuing from a location with an ordinary breakpoint, we
1496 actually single step once before calling insert_breakpoints.
1497 - When continuing from a localion with a permanent breakpoint, we
1498 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1499 the target, to advance the PC past the breakpoint. */
1501 enum breakpoint_here
1502 breakpoint_here_p (pc
)
1505 register struct breakpoint
*b
;
1506 int any_breakpoint_here
= 0;
1509 if ((b
->enable
== enabled
1510 || b
->enable
== permanent
)
1511 && b
->address
== pc
) /* bp is enabled and matches pc */
1513 if (overlay_debugging
&&
1514 section_is_overlay (b
->section
) &&
1515 !section_is_mapped (b
->section
))
1516 continue; /* unmapped overlay -- can't be a match */
1517 else if (b
->enable
== permanent
)
1518 return permanent_breakpoint_here
;
1520 any_breakpoint_here
= 1;
1523 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1527 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1528 but it only returns true if there is actually a breakpoint inserted
1532 breakpoint_inserted_here_p (pc
)
1535 register struct breakpoint
*b
;
1539 && b
->address
== pc
) /* bp is inserted and matches pc */
1541 if (overlay_debugging
&&
1542 section_is_overlay (b
->section
) &&
1543 !section_is_mapped (b
->section
))
1544 continue; /* unmapped overlay -- can't be a match */
1552 /* Return nonzero if FRAME is a dummy frame. We can't use
1553 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1554 much time, at least using get_saved_register on the 68k. This
1555 means that for this function to work right a port must use the
1556 bp_call_dummy breakpoint. */
1559 frame_in_dummy (frame
)
1560 struct frame_info
*frame
;
1562 struct breakpoint
*b
;
1567 if (USE_GENERIC_DUMMY_FRAMES
)
1568 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1572 if (b
->type
== bp_call_dummy
1573 && b
->frame
== frame
->frame
1574 /* We need to check the PC as well as the frame on the sparc,
1575 for signals.exp in the testsuite. */
1578 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1579 && frame
->pc
<= b
->address
)
1585 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1586 is valid for process/thread PID. */
1589 breakpoint_thread_match (pc
, pid
)
1593 struct breakpoint
*b
;
1596 thread
= pid_to_thread_id (pid
);
1599 if (b
->enable
!= disabled
1600 && b
->enable
!= shlib_disabled
1601 && b
->enable
!= call_disabled
1603 && (b
->thread
== -1 || b
->thread
== thread
))
1605 if (overlay_debugging
&&
1606 section_is_overlay (b
->section
) &&
1607 !section_is_mapped (b
->section
))
1608 continue; /* unmapped overlay -- can't be a match */
1617 /* bpstat stuff. External routines' interfaces are documented
1621 ep_is_catchpoint (ep
)
1622 struct breakpoint
*ep
;
1625 (ep
->type
== bp_catch_load
)
1626 || (ep
->type
== bp_catch_unload
)
1627 || (ep
->type
== bp_catch_fork
)
1628 || (ep
->type
== bp_catch_vfork
)
1629 || (ep
->type
== bp_catch_exec
)
1630 || (ep
->type
== bp_catch_catch
)
1631 || (ep
->type
== bp_catch_throw
)
1634 /* ??rehrauer: Add more kinds here, as are implemented... */
1639 ep_is_shlib_catchpoint (ep
)
1640 struct breakpoint
*ep
;
1643 (ep
->type
== bp_catch_load
)
1644 || (ep
->type
== bp_catch_unload
)
1649 ep_is_exception_catchpoint (ep
)
1650 struct breakpoint
*ep
;
1653 (ep
->type
== bp_catch_catch
)
1654 || (ep
->type
== bp_catch_throw
)
1658 /* Clear a bpstat so that it says we are not at any breakpoint.
1659 Also free any storage that is part of a bpstat. */
1674 if (p
->old_val
!= NULL
)
1675 value_free (p
->old_val
);
1682 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1683 is part of the bpstat is copied as well. */
1691 bpstat retval
= NULL
;
1696 for (; bs
!= NULL
; bs
= bs
->next
)
1698 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1699 memcpy (tmp
, bs
, sizeof (*tmp
));
1701 /* This is the first thing in the chain. */
1711 /* Find the bpstat associated with this breakpoint */
1714 bpstat_find_breakpoint (bsp
, breakpoint
)
1716 struct breakpoint
*breakpoint
;
1721 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1723 if (bsp
->breakpoint_at
== breakpoint
)
1729 /* Find a step_resume breakpoint associated with this bpstat.
1730 (If there are multiple step_resume bp's on the list, this function
1731 will arbitrarily pick one.)
1733 It is an error to use this function if BPSTAT doesn't contain a
1734 step_resume breakpoint.
1736 See wait_for_inferior's use of this function. */
1738 bpstat_find_step_resume_breakpoint (bsp
)
1742 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1744 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1746 if ((bsp
->breakpoint_at
!= NULL
) &&
1747 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1748 return bsp
->breakpoint_at
;
1751 error ("Internal error (no step_resume breakpoint found)");
1755 /* Return the breakpoint number of the first breakpoint we are stopped
1756 at. *BSP upon return is a bpstat which points to the remaining
1757 breakpoints stopped at (but which is not guaranteed to be good for
1758 anything but further calls to bpstat_num).
1759 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1765 struct breakpoint
*b
;
1768 return 0; /* No more breakpoint values */
1771 b
= (*bsp
)->breakpoint_at
;
1772 *bsp
= (*bsp
)->next
;
1774 return -1; /* breakpoint that's been deleted since */
1776 return b
->number
; /* We have its number */
1780 /* Modify BS so that the actions will not be performed. */
1783 bpstat_clear_actions (bs
)
1786 for (; bs
!= NULL
; bs
= bs
->next
)
1788 bs
->commands
= NULL
;
1789 if (bs
->old_val
!= NULL
)
1791 value_free (bs
->old_val
);
1797 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1800 cleanup_executing_breakpoints (ignore
)
1803 executing_breakpoint_commands
= 0;
1806 /* Execute all the commands associated with all the breakpoints at this
1807 location. Any of these commands could cause the process to proceed
1808 beyond this point, etc. We look out for such changes by checking
1809 the global "breakpoint_proceeded" after each command. */
1812 bpstat_do_actions (bsp
)
1816 struct cleanup
*old_chain
;
1817 struct command_line
*cmd
;
1819 /* Avoid endless recursion if a `source' command is contained
1821 if (executing_breakpoint_commands
)
1824 executing_breakpoint_commands
= 1;
1825 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1828 /* Note that (as of this writing), our callers all appear to
1829 be passing us the address of global stop_bpstat. And, if
1830 our calls to execute_control_command cause the inferior to
1831 proceed, that global (and hence, *bsp) will change.
1833 We must be careful to not touch *bsp unless the inferior
1834 has not proceeded. */
1836 /* This pointer will iterate over the list of bpstat's. */
1839 breakpoint_proceeded
= 0;
1840 for (; bs
!= NULL
; bs
= bs
->next
)
1845 execute_control_command (cmd
);
1847 if (breakpoint_proceeded
)
1852 if (breakpoint_proceeded
)
1853 /* The inferior is proceeded by the command; bomb out now.
1854 The bpstat chain has been blown away by wait_for_inferior.
1855 But since execution has stopped again, there is a new bpstat
1856 to look at, so start over. */
1859 bs
->commands
= NULL
;
1862 executing_breakpoint_commands
= 0;
1863 discard_cleanups (old_chain
);
1866 /* This is the normal print function for a bpstat. In the future,
1867 much of this logic could (should?) be moved to bpstat_stop_status,
1868 by having it set different print_it values.
1870 Current scheme: When we stop, bpstat_print() is called. It loops
1871 through the bpstat list of things causing this stop, calling the
1872 print_bp_stop_message function on each one. The behavior of the
1873 print_bp_stop_message function depends on the print_it field of
1874 bpstat. If such field so indicates, call this function here.
1876 Return values from this routine (ultimately used by bpstat_print()
1877 and normal_stop() to decide what to do):
1878 PRINT_NOTHING: Means we already printed all we needed to print,
1879 don't print anything else.
1880 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
1881 that something to be followed by a location.
1882 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
1883 that something to be followed by a location.
1884 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
1887 static enum print_stop_action
1888 print_it_typical (bs
)
1891 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1892 which has since been deleted. */
1893 if (bs
->breakpoint_at
== NULL
)
1894 return PRINT_UNKNOWN
;
1896 switch (bs
->breakpoint_at
->type
)
1899 case bp_hardware_breakpoint
:
1900 /* I think the user probably only wants to see one breakpoint
1901 number, not all of them. */
1902 annotate_breakpoint (bs
->breakpoint_at
->number
);
1903 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1904 return PRINT_SRC_AND_LOC
;
1907 case bp_shlib_event
:
1908 /* Did we stop because the user set the stop_on_solib_events
1909 variable? (If so, we report this as a generic, "Stopped due
1910 to shlib event" message.) */
1911 printf_filtered ("Stopped due to shared library event\n");
1912 return PRINT_NOTHING
;
1915 case bp_thread_event
:
1916 /* Not sure how we will get here.
1917 GDB should not stop for these breakpoints. */
1918 printf_filtered ("Thread Event Breakpoint: gdb should not stop!\n");
1919 return PRINT_NOTHING
;
1923 annotate_catchpoint (bs
->breakpoint_at
->number
);
1924 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1925 printf_filtered ("loaded");
1926 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1927 return PRINT_SRC_AND_LOC
;
1930 case bp_catch_unload
:
1931 annotate_catchpoint (bs
->breakpoint_at
->number
);
1932 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1933 printf_filtered ("unloaded");
1934 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1935 return PRINT_SRC_AND_LOC
;
1939 annotate_catchpoint (bs
->breakpoint_at
->number
);
1940 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1941 printf_filtered ("forked");
1942 printf_filtered (" process %d), ",
1943 bs
->breakpoint_at
->forked_inferior_pid
);
1944 return PRINT_SRC_AND_LOC
;
1947 case bp_catch_vfork
:
1948 annotate_catchpoint (bs
->breakpoint_at
->number
);
1949 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1950 printf_filtered ("vforked");
1951 printf_filtered (" process %d), ",
1952 bs
->breakpoint_at
->forked_inferior_pid
);
1953 return PRINT_SRC_AND_LOC
;
1957 annotate_catchpoint (bs
->breakpoint_at
->number
);
1958 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1959 bs
->breakpoint_at
->number
,
1960 bs
->breakpoint_at
->exec_pathname
);
1961 return PRINT_SRC_AND_LOC
;
1964 case bp_catch_catch
:
1965 if (current_exception_event
&&
1966 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1968 annotate_catchpoint (bs
->breakpoint_at
->number
);
1969 printf_filtered ("\nCatchpoint %d (exception caught), ",
1970 bs
->breakpoint_at
->number
);
1971 printf_filtered ("throw location ");
1972 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1973 printf_filtered ("%s:%d",
1974 CURRENT_EXCEPTION_THROW_FILE
,
1975 CURRENT_EXCEPTION_THROW_LINE
);
1977 printf_filtered ("unknown");
1979 printf_filtered (", catch location ");
1980 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1981 printf_filtered ("%s:%d",
1982 CURRENT_EXCEPTION_CATCH_FILE
,
1983 CURRENT_EXCEPTION_CATCH_LINE
);
1985 printf_filtered ("unknown");
1987 printf_filtered ("\n");
1988 /* don't bother to print location frame info */
1989 return PRINT_SRC_ONLY
;
1993 /* really throw, some other bpstat will handle it */
1994 return PRINT_UNKNOWN
;
1998 case bp_catch_throw
:
1999 if (current_exception_event
&&
2000 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
2002 annotate_catchpoint (bs
->breakpoint_at
->number
);
2003 printf_filtered ("\nCatchpoint %d (exception thrown), ",
2004 bs
->breakpoint_at
->number
);
2005 printf_filtered ("throw location ");
2006 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2007 printf_filtered ("%s:%d",
2008 CURRENT_EXCEPTION_THROW_FILE
,
2009 CURRENT_EXCEPTION_THROW_LINE
);
2011 printf_filtered ("unknown");
2013 printf_filtered (", catch location ");
2014 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2015 printf_filtered ("%s:%d",
2016 CURRENT_EXCEPTION_CATCH_FILE
,
2017 CURRENT_EXCEPTION_CATCH_LINE
);
2019 printf_filtered ("unknown");
2021 printf_filtered ("\n");
2022 /* don't bother to print location frame info */
2023 return PRINT_SRC_ONLY
;
2027 /* really catch, some other bpstat will handle it */
2028 return PRINT_UNKNOWN
;
2033 case bp_hardware_watchpoint
:
2034 if (bs
->old_val
!= NULL
)
2036 annotate_watchpoint (bs
->breakpoint_at
->number
);
2037 mention (bs
->breakpoint_at
);
2038 printf_filtered ("\nOld value = ");
2039 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2040 printf_filtered ("\nNew value = ");
2041 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2042 Val_pretty_default
);
2043 printf_filtered ("\n");
2044 value_free (bs
->old_val
);
2047 /* More than one watchpoint may have been triggered. */
2048 return PRINT_UNKNOWN
;
2051 case bp_read_watchpoint
:
2052 mention (bs
->breakpoint_at
);
2053 printf_filtered ("\nValue = ");
2054 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2055 Val_pretty_default
);
2056 printf_filtered ("\n");
2057 return PRINT_UNKNOWN
;
2060 case bp_access_watchpoint
:
2061 if (bs
->old_val
!= NULL
)
2063 annotate_watchpoint (bs
->breakpoint_at
->number
);
2064 mention (bs
->breakpoint_at
);
2065 printf_filtered ("\nOld value = ");
2066 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2067 value_free (bs
->old_val
);
2069 printf_filtered ("\nNew value = ");
2073 mention (bs
->breakpoint_at
);
2074 printf_filtered ("\nValue = ");
2076 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2077 Val_pretty_default
);
2078 printf_filtered ("\n");
2079 return PRINT_UNKNOWN
;
2082 /* Fall through, we don't deal with these types of breakpoints
2089 case bp_longjmp_resume
:
2090 case bp_step_resume
:
2091 case bp_through_sigtramp
:
2092 case bp_watchpoint_scope
:
2095 return PRINT_UNKNOWN
;
2099 /* Generic routine for printing messages indicating why we
2100 stopped. The behavior of this function depends on the value
2101 'print_it' in the bpstat structure. Under some circumstances we
2102 may decide not to print anything here and delegate the task to
2105 static enum print_stop_action
2106 print_bp_stop_message (bpstat bs
)
2108 switch (bs
->print_it
)
2111 /* Nothing should be printed for this bpstat entry. */
2112 return PRINT_UNKNOWN
;
2116 /* We still want to print the frame, but we already printed the
2117 relevant messages. */
2118 return PRINT_SRC_AND_LOC
;
2121 case print_it_normal
:
2122 /* Normal case, we handle everything in print_it_typical. */
2123 return print_it_typical (bs
);
2126 internal_error ("print_bp_stop_message: unrecognized enum value");
2131 /* Print a message indicating what happened. This is called from
2132 normal_stop(). The input to this routine is the head of the bpstat
2133 list - a list of the eventpoints that caused this stop. This
2134 routine calls the generic print routine for printing a message
2135 about reasons for stopping. This will print (for example) the
2136 "Breakpoint n," part of the output. The return value of this
2139 PRINT_UNKNOWN: Means we printed nothing
2140 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2141 code to print the location. An example is
2142 "Breakpoint 1, " which should be followed by
2144 PRINT_SRC_ONLY: Means we printed something, but there is no need
2145 to also print the location part of the message.
2146 An example is the catch/throw messages, which
2147 don't require a location appended to the end.
2148 PRINT_NOTHING: We have done some printing and we don't need any
2149 further info to be printed.*/
2151 enum print_stop_action
2157 /* Maybe another breakpoint in the chain caused us to stop.
2158 (Currently all watchpoints go on the bpstat whether hit or not.
2159 That probably could (should) be changed, provided care is taken
2160 with respect to bpstat_explains_signal). */
2161 for (; bs
; bs
= bs
->next
)
2163 val
= print_bp_stop_message (bs
);
2164 if (val
== PRINT_SRC_ONLY
2165 || val
== PRINT_SRC_AND_LOC
2166 || val
== PRINT_NOTHING
)
2170 /* We reached the end of the chain, or we got a null BS to start
2171 with and nothing was printed. */
2172 return PRINT_UNKNOWN
;
2175 /* Evaluate the expression EXP and return 1 if value is zero.
2176 This is used inside a catch_errors to evaluate the breakpoint condition.
2177 The argument is a "struct expression *" that has been cast to char * to
2178 make it pass through catch_errors. */
2181 breakpoint_cond_eval (exp
)
2184 value_ptr mark
= value_mark ();
2185 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2186 value_free_to_mark (mark
);
2190 /* Allocate a new bpstat and chain it to the current one. */
2193 bpstat_alloc (b
, cbs
)
2194 register struct breakpoint
*b
;
2195 bpstat cbs
; /* Current "bs" value */
2199 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2201 bs
->breakpoint_at
= b
;
2202 /* If the condition is false, etc., don't do the commands. */
2203 bs
->commands
= NULL
;
2205 bs
->print_it
= print_it_normal
;
2209 /* Possible return values for watchpoint_check (this can't be an enum
2210 because of check_errors). */
2211 /* The watchpoint has been deleted. */
2212 #define WP_DELETED 1
2213 /* The value has changed. */
2214 #define WP_VALUE_CHANGED 2
2215 /* The value has not changed. */
2216 #define WP_VALUE_NOT_CHANGED 3
2218 #define BP_TEMPFLAG 1
2219 #define BP_HARDWAREFLAG 2
2221 /* Check watchpoint condition. */
2224 watchpoint_check (p
)
2227 bpstat bs
= (bpstat
) p
;
2228 struct breakpoint
*b
;
2229 struct frame_info
*fr
;
2230 int within_current_scope
;
2232 b
= bs
->breakpoint_at
;
2234 if (b
->exp_valid_block
== NULL
)
2235 within_current_scope
= 1;
2238 /* There is no current frame at this moment. If we're going to have
2239 any chance of handling watchpoints on local variables, we'll need
2240 the frame chain (so we can determine if we're in scope). */
2241 reinit_frame_cache ();
2242 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2243 within_current_scope
= (fr
!= NULL
);
2244 if (within_current_scope
)
2245 /* If we end up stopping, the current frame will get selected
2246 in normal_stop. So this call to select_frame won't affect
2248 select_frame (fr
, -1);
2251 if (within_current_scope
)
2253 /* We use value_{,free_to_}mark because it could be a
2254 *long* time before we return to the command level and
2255 call free_all_values. We can't call free_all_values because
2256 we might be in the middle of evaluating a function call. */
2258 value_ptr mark
= value_mark ();
2259 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2260 if (!value_equal (b
->val
, new_val
))
2262 release_value (new_val
);
2263 value_free_to_mark (mark
);
2264 bs
->old_val
= b
->val
;
2266 /* We will stop here */
2267 return WP_VALUE_CHANGED
;
2271 /* Nothing changed, don't do anything. */
2272 value_free_to_mark (mark
);
2273 /* We won't stop here */
2274 return WP_VALUE_NOT_CHANGED
;
2279 /* This seems like the only logical thing to do because
2280 if we temporarily ignored the watchpoint, then when
2281 we reenter the block in which it is valid it contains
2282 garbage (in the case of a function, it may have two
2283 garbage values, one before and one after the prologue).
2284 So we can't even detect the first assignment to it and
2285 watch after that (since the garbage may or may not equal
2286 the first value assigned). */
2287 /* We print all the stop information in print_it_typical(), but
2288 in this case, by the time we call print_it_typical() this bp
2289 will be deleted already. So we have no choice but print the
2290 information here. */
2292 Watchpoint %d deleted because the program has left the block in\n\
2293 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2295 if (b
->related_breakpoint
)
2296 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2297 b
->disposition
= del_at_next_stop
;
2303 /* Get a bpstat associated with having just stopped at address *PC
2304 and frame address CORE_ADDRESS. Update *PC to point at the
2305 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2306 if this is known to not be a real breakpoint (it could still be a
2307 watchpoint, though). */
2309 /* Determine whether we stopped at a breakpoint, etc, or whether we
2310 don't understand this stop. Result is a chain of bpstat's such that:
2312 if we don't understand the stop, the result is a null pointer.
2314 if we understand why we stopped, the result is not null.
2316 Each element of the chain refers to a particular breakpoint or
2317 watchpoint at which we have stopped. (We may have stopped for
2318 several reasons concurrently.)
2320 Each element of the chain has valid next, breakpoint_at,
2321 commands, FIXME??? fields. */
2324 bpstat_stop_status (pc
, not_a_breakpoint
)
2326 int not_a_breakpoint
;
2328 register struct breakpoint
*b
, *temp
;
2330 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2331 int real_breakpoint
= 0;
2332 /* Root of the chain of bpstat's */
2333 struct bpstats root_bs
[1];
2334 /* Pointer to the last thing in the chain currently. */
2335 bpstat bs
= root_bs
;
2336 static char message1
[] =
2337 "Error evaluating expression for watchpoint %d\n";
2338 char message
[sizeof (message1
) + 30 /* slop */ ];
2340 /* Get the address where the breakpoint would have been. */
2341 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2342 0 : DECR_PC_AFTER_BREAK
);
2344 ALL_BREAKPOINTS_SAFE (b
, temp
)
2346 if (b
->enable
== disabled
2347 || b
->enable
== shlib_disabled
2348 || b
->enable
== call_disabled
)
2351 if (b
->type
!= bp_watchpoint
2352 && b
->type
!= bp_hardware_watchpoint
2353 && b
->type
!= bp_read_watchpoint
2354 && b
->type
!= bp_access_watchpoint
2355 && b
->type
!= bp_hardware_breakpoint
2356 && b
->type
!= bp_catch_fork
2357 && b
->type
!= bp_catch_vfork
2358 && b
->type
!= bp_catch_exec
2359 && b
->type
!= bp_catch_catch
2360 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2361 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2362 (overlay_debugging
&& /* overlay doesn't match */
2363 section_is_overlay (b
->section
) &&
2364 !section_is_mapped (b
->section
)))
2367 if (b
->type
== bp_hardware_breakpoint
2368 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2371 /* Is this a catchpoint of a load or unload? If so, did we
2372 get a load or unload of the specified library? If not,
2374 if ((b
->type
== bp_catch_load
)
2375 #if defined(SOLIB_HAVE_LOAD_EVENT)
2376 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2377 || ((b
->dll_pathname
!= NULL
)
2378 && (strcmp (b
->dll_pathname
,
2379 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2385 if ((b
->type
== bp_catch_unload
)
2386 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2387 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2388 || ((b
->dll_pathname
!= NULL
)
2389 && (strcmp (b
->dll_pathname
,
2390 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2396 if ((b
->type
== bp_catch_fork
)
2397 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2400 if ((b
->type
== bp_catch_vfork
)
2401 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2404 if ((b
->type
== bp_catch_exec
)
2405 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2408 if (ep_is_exception_catchpoint (b
) &&
2409 !(current_exception_event
= target_get_current_exception_event ()))
2412 /* Come here if it's a watchpoint, or if the break address matches */
2414 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2416 /* Watchpoints may change this, if not found to have triggered. */
2420 sprintf (message
, message1
, b
->number
);
2421 if (b
->type
== bp_watchpoint
||
2422 b
->type
== bp_hardware_watchpoint
)
2424 switch (catch_errors (watchpoint_check
, bs
, message
,
2428 /* We've already printed what needs to be printed. */
2429 /* Actually this is superfluous, because by the time we
2430 call print_it_typical() the wp will be already deleted,
2431 and the function will return immediately. */
2432 bs
->print_it
= print_it_done
;
2435 case WP_VALUE_CHANGED
:
2439 case WP_VALUE_NOT_CHANGED
:
2441 bs
->print_it
= print_it_noop
;
2448 /* Error from catch_errors. */
2449 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2450 if (b
->related_breakpoint
)
2451 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2452 b
->disposition
= del_at_next_stop
;
2453 /* We've already printed what needs to be printed. */
2454 bs
->print_it
= print_it_done
;
2460 else if (b
->type
== bp_read_watchpoint
||
2461 b
->type
== bp_access_watchpoint
)
2467 addr
= target_stopped_data_address ();
2470 for (v
= b
->val_chain
; v
; v
= v
->next
)
2472 if (VALUE_LVAL (v
) == lval_memory
2473 && ! VALUE_LAZY (v
))
2477 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2478 /* Exact match not required. Within range is sufficient.
2480 if (addr
>= vaddr
&&
2481 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2486 switch (catch_errors (watchpoint_check
, bs
, message
,
2490 /* We've already printed what needs to be printed. */
2491 bs
->print_it
= print_it_done
;
2494 case WP_VALUE_CHANGED
:
2495 case WP_VALUE_NOT_CHANGED
:
2502 /* Error from catch_errors. */
2503 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2504 if (b
->related_breakpoint
)
2505 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2506 b
->disposition
= del_at_next_stop
;
2507 /* We've already printed what needs to be printed. */
2508 bs
->print_it
= print_it_done
;
2511 else /* found == 0 */
2513 /* This is a case where some watchpoint(s) triggered,
2514 but not at the address of this watchpoint (FOUND
2515 was left zero). So don't print anything for this
2517 bs
->print_it
= print_it_noop
;
2524 /* By definition, an encountered breakpoint is a triggered
2528 real_breakpoint
= 1;
2531 if (b
->frame
&& b
->frame
!= (get_current_frame ())->frame
&&
2532 (b
->type
== bp_step_resume
&&
2533 (INNER_THAN (get_current_frame ()->frame
, b
->frame
))))
2537 int value_is_zero
= 0;
2541 /* Need to select the frame, with all that implies
2542 so that the conditions will have the right context. */
2543 select_frame (get_current_frame (), 0);
2545 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2546 "Error in testing breakpoint condition:\n",
2548 /* FIXME-someday, should give breakpoint # */
2551 if (b
->cond
&& value_is_zero
)
2554 /* Don't consider this a hit. */
2557 else if (b
->ignore_count
> 0)
2560 annotate_ignore_count_change ();
2565 /* We will stop here */
2566 if (b
->disposition
== disable
)
2567 b
->enable
= disabled
;
2568 bs
->commands
= b
->commands
;
2572 (STREQ ("silent", bs
->commands
->line
) ||
2573 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2575 bs
->commands
= bs
->commands
->next
;
2580 /* Print nothing for this entry if we dont stop or if we dont print. */
2581 if (bs
->stop
== 0 || bs
->print
== 0)
2582 bs
->print_it
= print_it_noop
;
2585 bs
->next
= NULL
; /* Terminate the chain */
2586 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2588 if (real_breakpoint
&& bs
)
2590 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2592 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2594 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2600 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2603 #if defined (SHIFT_INST_REGS)
2605 #else /* No SHIFT_INST_REGS. */
2607 #endif /* No SHIFT_INST_REGS. */
2612 /* The value of a hardware watchpoint hasn't changed, but the
2613 intermediate memory locations we are watching may have. */
2614 if (bs
&& !bs
->stop
&&
2615 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2616 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2617 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2619 remove_breakpoints ();
2620 insert_breakpoints ();
2625 /* Tell what to do about this bpstat. */
2630 /* Classify each bpstat as one of the following. */
2633 /* This bpstat element has no effect on the main_action. */
2636 /* There was a watchpoint, stop but don't print. */
2639 /* There was a watchpoint, stop and print. */
2642 /* There was a breakpoint but we're not stopping. */
2645 /* There was a breakpoint, stop but don't print. */
2648 /* There was a breakpoint, stop and print. */
2651 /* We hit the longjmp breakpoint. */
2654 /* We hit the longjmp_resume breakpoint. */
2657 /* We hit the step_resume breakpoint. */
2660 /* We hit the through_sigtramp breakpoint. */
2663 /* We hit the shared library event breakpoint. */
2666 /* We caught a shared library event. */
2669 /* This is just used to count how many enums there are. */
2673 /* Here is the table which drives this routine. So that we can
2674 format it pretty, we define some abbreviations for the
2675 enum bpstat_what codes. */
2676 #define kc BPSTAT_WHAT_KEEP_CHECKING
2677 #define ss BPSTAT_WHAT_STOP_SILENT
2678 #define sn BPSTAT_WHAT_STOP_NOISY
2679 #define sgl BPSTAT_WHAT_SINGLE
2680 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2681 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2682 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2683 #define sr BPSTAT_WHAT_STEP_RESUME
2684 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2685 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2686 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2688 /* "Can't happen." Might want to print an error message.
2689 abort() is not out of the question, but chances are GDB is just
2690 a bit confused, not unusable. */
2691 #define err BPSTAT_WHAT_STOP_NOISY
2693 /* Given an old action and a class, come up with a new action. */
2694 /* One interesting property of this table is that wp_silent is the same
2695 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2696 after stopping, the check for whether to step over a breakpoint
2697 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2698 reference to how we stopped. We retain separate wp_silent and
2699 bp_silent codes in case we want to change that someday.
2701 Another possibly interesting property of this table is that
2702 there's a partial ordering, priority-like, of the actions. Once
2703 you've decided that some action is appropriate, you'll never go
2704 back and decide something of a lower priority is better. The
2707 kc < clr sgl shl slr sn sr ss ts
2708 sgl < clrs shl shlr slr sn sr ss ts
2709 slr < err shl shlr sn sr ss ts
2710 clr < clrs err shl shlr sn sr ss ts
2711 clrs < err shl shlr sn sr ss ts
2712 ss < shl shlr sn sr ts
2719 What I think this means is that we don't need a damned table
2720 here. If you just put the rows and columns in the right order,
2721 it'd look awfully regular. We could simply walk the bpstat list
2722 and choose the highest priority action we find, with a little
2723 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2724 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2725 is messy anyway). */
2727 /* step_resume entries: a step resume breakpoint overrides another
2728 breakpoint of signal handling (see comment in wait_for_inferior
2729 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2730 /* We handle the through_sigtramp_breakpoint the same way; having both
2731 one of those and a step_resume_breakpoint is probably very rare (?). */
2733 static const enum bpstat_what_main_action
2734 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2737 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2740 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2742 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2744 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2746 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2748 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2750 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2752 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2754 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2756 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2758 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2760 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2762 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2777 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2778 struct bpstat_what retval
;
2780 retval
.call_dummy
= 0;
2781 for (; bs
!= NULL
; bs
= bs
->next
)
2783 enum class bs_class
= no_effect
;
2784 if (bs
->breakpoint_at
== NULL
)
2785 /* I suspect this can happen if it was a momentary breakpoint
2786 which has since been deleted. */
2788 switch (bs
->breakpoint_at
->type
)
2794 case bp_hardware_breakpoint
:
2800 bs_class
= bp_noisy
;
2802 bs_class
= bp_silent
;
2805 bs_class
= bp_nostop
;
2808 case bp_hardware_watchpoint
:
2809 case bp_read_watchpoint
:
2810 case bp_access_watchpoint
:
2814 bs_class
= wp_noisy
;
2816 bs_class
= wp_silent
;
2819 /* There was a watchpoint, but we're not stopping.
2820 This requires no further action. */
2821 bs_class
= no_effect
;
2824 bs_class
= long_jump
;
2826 case bp_longjmp_resume
:
2827 bs_class
= long_resume
;
2829 case bp_step_resume
:
2832 bs_class
= step_resume
;
2835 /* It is for the wrong frame. */
2836 bs_class
= bp_nostop
;
2838 case bp_through_sigtramp
:
2839 bs_class
= through_sig
;
2841 case bp_watchpoint_scope
:
2842 bs_class
= bp_nostop
;
2844 case bp_shlib_event
:
2845 bs_class
= shlib_event
;
2847 case bp_thread_event
:
2848 bs_class
= bp_nostop
;
2851 case bp_catch_unload
:
2852 /* Only if this catchpoint triggered should we cause the
2853 step-out-of-dld behaviour. Otherwise, we ignore this
2856 bs_class
= catch_shlib_event
;
2858 bs_class
= no_effect
;
2861 case bp_catch_vfork
:
2866 bs_class
= bp_noisy
;
2868 bs_class
= bp_silent
;
2871 /* There was a catchpoint, but we're not stopping.
2872 This requires no further action. */
2873 bs_class
= no_effect
;
2875 case bp_catch_catch
:
2876 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2877 bs_class
= bp_nostop
;
2879 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2881 case bp_catch_throw
:
2882 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2883 bs_class
= bp_nostop
;
2885 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2888 /* Make sure the action is stop (silent or noisy),
2889 so infrun.c pops the dummy frame. */
2890 bs_class
= bp_silent
;
2891 retval
.call_dummy
= 1;
2894 current_action
= table
[(int) bs_class
][(int) current_action
];
2896 retval
.main_action
= current_action
;
2900 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2901 without hardware support). This isn't related to a specific bpstat,
2902 just to things like whether watchpoints are set. */
2905 bpstat_should_step ()
2907 struct breakpoint
*b
;
2909 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2914 /* Nonzero if there are enabled hardware watchpoints. */
2916 bpstat_have_active_hw_watchpoints ()
2918 struct breakpoint
*b
;
2920 if ((b
->enable
== enabled
) &&
2922 ((b
->type
== bp_hardware_watchpoint
) ||
2923 (b
->type
== bp_read_watchpoint
) ||
2924 (b
->type
== bp_access_watchpoint
)))
2930 /* Given a bpstat that records zero or more triggered eventpoints, this
2931 function returns another bpstat which contains only the catchpoints
2932 on that first list, if any. */
2934 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
2938 struct bpstats root_bs
[1];
2939 bpstat bs
= root_bs
;
2940 struct breakpoint
*ep
;
2943 bpstat_clear (cp_list
);
2944 root_bs
->next
= NULL
;
2946 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
2948 /* Is this eventpoint a catchpoint? If not, ignore it. */
2949 ep
= ep_list
->breakpoint_at
;
2952 if ((ep
->type
!= bp_catch_load
) &&
2953 (ep
->type
!= bp_catch_unload
) &&
2954 (ep
->type
!= bp_catch_catch
) &&
2955 (ep
->type
!= bp_catch_throw
))
2956 /* pai: (temp) ADD fork/vfork here!! */
2959 /* Yes; add it to the list. */
2960 bs
= bpstat_alloc (ep
, bs
);
2965 #if defined(SOLIB_ADD)
2966 /* Also, for each triggered catchpoint, tag it with the name of
2967 the library that caused this trigger. (We copy the name now,
2968 because it's only guaranteed to be available NOW, when the
2969 catchpoint triggers. Clients who may wish to know the name
2970 later must get it from the catchpoint itself.) */
2971 if (ep
->triggered_dll_pathname
!= NULL
)
2972 free (ep
->triggered_dll_pathname
);
2973 if (ep
->type
== bp_catch_load
)
2974 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
2976 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
2978 dll_pathname
= NULL
;
2982 ep
->triggered_dll_pathname
= (char *)
2983 xmalloc (strlen (dll_pathname
) + 1);
2984 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
2987 ep
->triggered_dll_pathname
= NULL
;
2993 /* Print B to gdb_stdout. */
2995 print_one_breakpoint (struct breakpoint
*b
,
2996 CORE_ADDR
*last_addr
)
2998 register struct command_line
*l
;
2999 register struct symbol
*sym
;
3000 struct ep_type_description
3005 static struct ep_type_description bptypes
[] =
3007 {bp_none
, "?deleted?"},
3008 {bp_breakpoint
, "breakpoint"},
3009 {bp_hardware_breakpoint
, "hw breakpoint"},
3010 {bp_until
, "until"},
3011 {bp_finish
, "finish"},
3012 {bp_watchpoint
, "watchpoint"},
3013 {bp_hardware_watchpoint
, "hw watchpoint"},
3014 {bp_read_watchpoint
, "read watchpoint"},
3015 {bp_access_watchpoint
, "acc watchpoint"},
3016 {bp_longjmp
, "longjmp"},
3017 {bp_longjmp_resume
, "longjmp resume"},
3018 {bp_step_resume
, "step resume"},
3019 {bp_through_sigtramp
, "sigtramp"},
3020 {bp_watchpoint_scope
, "watchpoint scope"},
3021 {bp_call_dummy
, "call dummy"},
3022 {bp_shlib_event
, "shlib events"},
3023 {bp_thread_event
, "thread events"},
3024 {bp_catch_load
, "catch load"},
3025 {bp_catch_unload
, "catch unload"},
3026 {bp_catch_fork
, "catch fork"},
3027 {bp_catch_vfork
, "catch vfork"},
3028 {bp_catch_exec
, "catch exec"},
3029 {bp_catch_catch
, "catch catch"},
3030 {bp_catch_throw
, "catch throw"}
3033 static char *bpdisps
[] =
3034 {"del", "dstp", "dis", "keep"};
3035 static char bpenables
[] = "nynny";
3036 char wrap_indent
[80];
3042 printf_filtered ("%-3d ", b
->number
);
3046 if (((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
3047 || ((int) b
->type
!= bptypes
[(int) b
->type
].type
))
3048 internal_error ("bptypes table does not describe type #%d.",
3050 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
3054 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
3058 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
3061 strcpy (wrap_indent
, " ");
3063 strcat (wrap_indent
, " ");
3067 internal_error ("print_one_breakpoint: bp_none encountered\n");
3071 case bp_hardware_watchpoint
:
3072 case bp_read_watchpoint
:
3073 case bp_access_watchpoint
:
3074 /* Field 4, the address, is omitted (which makes the columns
3075 not line up too nicely with the headers, but the effect
3076 is relatively readable). */
3078 print_expression (b
->exp
, gdb_stdout
);
3082 case bp_catch_unload
:
3083 /* Field 4, the address, is omitted (which makes the columns
3084 not line up too nicely with the headers, but the effect
3085 is relatively readable). */
3087 if (b
->dll_pathname
== NULL
)
3088 printf_filtered ("<any library> ");
3090 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
3094 case bp_catch_vfork
:
3095 /* Field 4, the address, is omitted (which makes the columns
3096 not line up too nicely with the headers, but the effect
3097 is relatively readable). */
3099 if (b
->forked_inferior_pid
!= 0)
3100 printf_filtered ("process %d ", b
->forked_inferior_pid
);
3104 /* Field 4, the address, is omitted (which makes the columns
3105 not line up too nicely with the headers, but the effect
3106 is relatively readable). */
3108 if (b
->exec_pathname
!= NULL
)
3109 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
3112 case bp_catch_catch
:
3113 /* Field 4, the address, is omitted (which makes the columns
3114 not line up too nicely with the headers, but the effect
3115 is relatively readable). */
3117 printf_filtered ("exception catch ");
3120 case bp_catch_throw
:
3121 /* Field 4, the address, is omitted (which makes the columns
3122 not line up too nicely with the headers, but the effect
3123 is relatively readable). */
3125 printf_filtered ("exception throw ");
3129 case bp_hardware_breakpoint
:
3133 case bp_longjmp_resume
:
3134 case bp_step_resume
:
3135 case bp_through_sigtramp
:
3136 case bp_watchpoint_scope
:
3138 case bp_shlib_event
:
3139 case bp_thread_event
:
3143 /* FIXME-32x64: need a print_address_numeric with
3147 local_hex_string_custom
3148 ((unsigned long) b
->address
, "08l"));
3151 *last_addr
= b
->address
;
3154 sym
= find_pc_sect_function (b
->address
, b
->section
);
3157 fputs_filtered ("in ", gdb_stdout
);
3158 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3159 wrap_here (wrap_indent
);
3160 fputs_filtered (" at ", gdb_stdout
);
3162 fputs_filtered (b
->source_file
, gdb_stdout
);
3163 printf_filtered (":%d", b
->line_number
);
3166 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3170 if (b
->thread
!= -1)
3172 printf_filtered (" thread %d", b
->thread
);
3175 printf_filtered ("\n");
3180 printf_filtered ("\tstop only in stack frame at ");
3181 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3182 printf_filtered ("\n");
3188 printf_filtered ("\tstop only if ");
3189 print_expression (b
->cond
, gdb_stdout
);
3190 printf_filtered ("\n");
3193 if (b
->thread
!= -1)
3195 /* FIXME should make an annotation for this */
3196 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3199 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3201 /* FIXME should make an annotation for this */
3202 if (ep_is_catchpoint (b
))
3203 printf_filtered ("\tcatchpoint");
3205 printf_filtered ("\tbreakpoint");
3206 printf_filtered (" already hit %d time%s\n",
3207 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3210 if (b
->ignore_count
)
3213 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3216 if ((l
= b
->commands
))
3221 print_command_line (l
, 4, gdb_stdout
);
3227 struct captured_breakpoint_query_args
3233 do_captured_breakpoint_query (void *data
)
3235 struct captured_breakpoint_query_args
*args
= data
;
3236 register struct breakpoint
*b
;
3237 CORE_ADDR dummy_addr
= 0;
3240 if (args
->bnum
== b
->number
)
3242 print_one_breakpoint (b
, &dummy_addr
);
3250 gdb_breakpoint_query (/* output object, */ int bnum
)
3252 struct captured_breakpoint_query_args args
;
3254 /* For the moment we don't trust print_one_breakpoint() to not throw
3256 return catch_errors (do_captured_breakpoint_query
, &args
,
3257 NULL
, RETURN_MASK_ALL
);
3260 /* Print information on breakpoint number BNUM, or -1 if all.
3261 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
3262 is nonzero, process only watchpoints. */
3265 breakpoint_1 (bnum
, allflag
)
3269 register struct breakpoint
*b
;
3270 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
3271 int found_a_breakpoint
= 0;
3275 || bnum
== b
->number
)
3277 /* We only print out user settable breakpoints unless the
3280 && b
->type
!= bp_breakpoint
3281 && b
->type
!= bp_catch_load
3282 && b
->type
!= bp_catch_unload
3283 && b
->type
!= bp_catch_fork
3284 && b
->type
!= bp_catch_vfork
3285 && b
->type
!= bp_catch_exec
3286 && b
->type
!= bp_catch_catch
3287 && b
->type
!= bp_catch_throw
3288 && b
->type
!= bp_hardware_breakpoint
3289 && b
->type
!= bp_watchpoint
3290 && b
->type
!= bp_read_watchpoint
3291 && b
->type
!= bp_access_watchpoint
3292 && b
->type
!= bp_hardware_watchpoint
)
3295 if (!found_a_breakpoint
++)
3297 annotate_breakpoints_headers ();
3299 printf_filtered ("Num ");
3301 printf_filtered ("Type ");
3303 printf_filtered ("Disp ");
3305 printf_filtered ("Enb ");
3309 printf_filtered ("Address ");
3312 printf_filtered ("What\n");
3313 annotate_breakpoints_table ();
3316 print_one_breakpoint (b
, &last_addr
);
3319 if (!found_a_breakpoint
)
3322 printf_filtered ("No breakpoints or watchpoints.\n");
3324 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3328 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3329 that a comparison of an unsigned with -1 is always false. */
3330 if (last_addr
!= (CORE_ADDR
) -1)
3331 set_next_address (last_addr
);
3334 /* FIXME? Should this be moved up so that it is only called when
3335 there have been breakpoints? */
3336 annotate_breakpoints_table_end ();
3341 breakpoints_info (bnum_exp
, from_tty
)
3348 bnum
= parse_and_eval_address (bnum_exp
);
3350 breakpoint_1 (bnum
, 0);
3355 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3362 bnum
= parse_and_eval_address (bnum_exp
);
3364 breakpoint_1 (bnum
, 1);
3367 /* Print a message describing any breakpoints set at PC. */
3370 describe_other_breakpoints (pc
, section
)
3374 register int others
= 0;
3375 register struct breakpoint
*b
;
3378 if (b
->address
== pc
)
3379 if (overlay_debugging
== 0 ||
3380 b
->section
== section
)
3384 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3386 if (b
->address
== pc
)
3387 if (overlay_debugging
== 0 ||
3388 b
->section
== section
)
3394 ((b
->enable
== disabled
||
3395 b
->enable
== shlib_disabled
||
3396 b
->enable
== call_disabled
) ? " (disabled)"
3397 : b
->enable
== permanent
? " (permanent)"
3399 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3401 printf_filtered ("also set at pc ");
3402 print_address_numeric (pc
, 1, gdb_stdout
);
3403 printf_filtered (".\n");
3407 /* Set the default place to put a breakpoint
3408 for the `break' command with no arguments. */
3411 set_default_breakpoint (valid
, addr
, symtab
, line
)
3414 struct symtab
*symtab
;
3417 default_breakpoint_valid
= valid
;
3418 default_breakpoint_address
= addr
;
3419 default_breakpoint_symtab
= symtab
;
3420 default_breakpoint_line
= line
;
3423 /* Rescan breakpoints at address ADDRESS,
3424 marking the first one as "first" and any others as "duplicates".
3425 This is so that the bpt instruction is only inserted once.
3426 If we have a permanent breakpoint at ADDRESS, make that one
3427 the official one, and the rest as duplicates. */
3430 check_duplicates (address
, section
)
3434 register struct breakpoint
*b
;
3435 register int count
= 0;
3436 struct breakpoint
*perm_bp
= 0;
3438 if (address
== 0) /* Watchpoints are uninteresting */
3442 if (b
->enable
!= disabled
3443 && b
->enable
!= shlib_disabled
3444 && b
->enable
!= call_disabled
3445 && b
->address
== address
3446 && (overlay_debugging
== 0 || b
->section
== section
))
3448 /* Have we found a permanent breakpoint? */
3449 if (b
->enable
== permanent
)
3456 b
->duplicate
= count
> 1;
3459 /* If we found a permanent breakpoint at this address, go over the
3460 list again and declare all the other breakpoints there to be the
3464 perm_bp
->duplicate
= 0;
3466 /* Permanent breakpoint should always be inserted. */
3467 if (! perm_bp
->inserted
)
3468 internal_error ("allegedly permanent breakpoint is not "
3469 "actually inserted");
3475 internal_error ("another breakpoint was inserted on top of "
3476 "a permanent breakpoint");
3478 if (b
->enable
!= disabled
3479 && b
->enable
!= shlib_disabled
3480 && b
->enable
!= call_disabled
3481 && b
->address
== address
3482 && (overlay_debugging
== 0 || b
->section
== section
))
3488 /* Low level routine to set a breakpoint.
3489 Takes as args the three things that every breakpoint must have.
3490 Returns the breakpoint object so caller can set other things.
3491 Does not set the breakpoint number!
3492 Does not print anything.
3494 ==> This routine should not be called if there is a chance of later
3495 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3496 your arguments BEFORE calling this routine! */
3499 set_raw_breakpoint (sal
)
3500 struct symtab_and_line sal
;
3502 register struct breakpoint
*b
, *b1
;
3504 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3505 memset (b
, 0, sizeof (*b
));
3506 b
->address
= sal
.pc
;
3507 if (sal
.symtab
== NULL
)
3508 b
->source_file
= NULL
;
3510 b
->source_file
= savestring (sal
.symtab
->filename
,
3511 strlen (sal
.symtab
->filename
));
3512 b
->section
= sal
.section
;
3513 b
->language
= current_language
->la_language
;
3514 b
->input_radix
= input_radix
;
3516 b
->line_number
= sal
.line
;
3517 b
->enable
= enabled
;
3520 b
->ignore_count
= 0;
3523 b
->dll_pathname
= NULL
;
3524 b
->triggered_dll_pathname
= NULL
;
3525 b
->forked_inferior_pid
= 0;
3526 b
->exec_pathname
= NULL
;
3528 /* Add this breakpoint to the end of the chain
3529 so that a list of breakpoints will come out in order
3530 of increasing numbers. */
3532 b1
= breakpoint_chain
;
3534 breakpoint_chain
= b
;
3542 check_duplicates (sal
.pc
, sal
.section
);
3543 breakpoints_changed ();
3549 /* Note that the breakpoint object B describes a permanent breakpoint
3550 instruction, hard-wired into the inferior's code. */
3552 make_breakpoint_permanent (struct breakpoint
*b
)
3554 b
->enable
= permanent
;
3556 /* By definition, permanent breakpoints are already present in the code. */
3560 #ifdef GET_LONGJMP_TARGET
3563 create_longjmp_breakpoint (func_name
)
3566 struct symtab_and_line sal
;
3567 struct breakpoint
*b
;
3569 INIT_SAL (&sal
); /* initialize to zeroes */
3570 if (func_name
!= NULL
)
3572 struct minimal_symbol
*m
;
3574 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3575 (struct objfile
*) NULL
);
3577 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3581 sal
.section
= find_pc_overlay (sal
.pc
);
3582 b
= set_raw_breakpoint (sal
);
3586 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3587 b
->disposition
= donttouch
;
3588 b
->enable
= disabled
;
3591 b
->addr_string
= strsave (func_name
);
3592 b
->number
= internal_breakpoint_number
--;
3595 #endif /* #ifdef GET_LONGJMP_TARGET */
3597 /* Call this routine when stepping and nexting to enable a breakpoint
3598 if we do a longjmp(). When we hit that breakpoint, call
3599 set_longjmp_resume_breakpoint() to figure out where we are going. */
3602 enable_longjmp_breakpoint ()
3604 register struct breakpoint
*b
;
3607 if (b
->type
== bp_longjmp
)
3609 b
->enable
= enabled
;
3610 check_duplicates (b
->address
, b
->section
);
3615 disable_longjmp_breakpoint ()
3617 register struct breakpoint
*b
;
3620 if (b
->type
== bp_longjmp
3621 || b
->type
== bp_longjmp_resume
)
3623 b
->enable
= disabled
;
3624 check_duplicates (b
->address
, b
->section
);
3629 create_thread_event_breakpoint (address
)
3632 struct breakpoint
*b
;
3633 struct symtab_and_line sal
;
3634 char addr_string
[80]; /* Surely an addr can't be longer than that. */
3636 INIT_SAL (&sal
); /* initialize to zeroes */
3638 sal
.section
= find_pc_overlay (sal
.pc
);
3639 if ((b
= set_raw_breakpoint (sal
)) == NULL
)
3642 b
->number
= internal_breakpoint_number
--;
3643 b
->disposition
= donttouch
;
3644 b
->type
= bp_thread_event
; /* XXX: do we need a new type?
3646 b
->enable
= enabled
;
3647 /* addr_string has to be used or breakpoint_re_set will delete me. */
3648 sprintf (addr_string
, "*0x%s", paddr (b
->address
));
3649 b
->addr_string
= strsave (addr_string
);
3655 remove_thread_event_breakpoints (void)
3657 struct breakpoint
*b
, *temp
;
3659 ALL_BREAKPOINTS_SAFE (b
, temp
)
3660 if (b
->type
== bp_thread_event
)
3661 delete_breakpoint (b
);
3666 remove_solib_event_breakpoints ()
3668 register struct breakpoint
*b
, *temp
;
3670 ALL_BREAKPOINTS_SAFE (b
, temp
)
3671 if (b
->type
== bp_shlib_event
)
3672 delete_breakpoint (b
);
3676 create_solib_event_breakpoint (address
)
3679 struct breakpoint
*b
;
3680 struct symtab_and_line sal
;
3682 INIT_SAL (&sal
); /* initialize to zeroes */
3684 sal
.section
= find_pc_overlay (sal
.pc
);
3685 b
= set_raw_breakpoint (sal
);
3686 b
->number
= internal_breakpoint_number
--;
3687 b
->disposition
= donttouch
;
3688 b
->type
= bp_shlib_event
;
3693 /* Disable any breakpoints that are on code in shared libraries. Only
3694 apply to enabled breakpoints, disabled ones can just stay disabled. */
3697 disable_breakpoints_in_shlibs (silent
)
3700 struct breakpoint
*b
;
3701 int disabled_shlib_breaks
= 0;
3703 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3706 #if defined (PC_SOLIB)
3707 if (((b
->type
== bp_breakpoint
) ||
3708 (b
->type
== bp_hardware_breakpoint
)) &&
3709 b
->enable
== enabled
&&
3711 PC_SOLIB (b
->address
))
3713 b
->enable
= shlib_disabled
;
3716 if (!disabled_shlib_breaks
)
3718 target_terminal_ours_for_output ();
3719 warning ("Temporarily disabling shared library breakpoints:");
3721 disabled_shlib_breaks
= 1;
3722 warning ("breakpoint #%d ", b
->number
);
3729 /* Try to reenable any breakpoints in shared libraries. */
3731 re_enable_breakpoints_in_shlibs ()
3733 struct breakpoint
*b
;
3736 if (b
->enable
== shlib_disabled
)
3740 /* Do not reenable the breakpoint if the shared library
3741 is still not mapped in. */
3742 if (target_read_memory (b
->address
, buf
, 1) == 0)
3743 b
->enable
= enabled
;
3750 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
3755 enum bptype bp_kind
;
3757 struct breakpoint
*b
;
3758 struct symtabs_and_lines sals
;
3759 struct cleanup
*old_chain
;
3760 struct cleanup
*canonical_strings_chain
= NULL
;
3761 char *addr_start
= hookname
;
3762 char *addr_end
= NULL
;
3763 char **canonical
= (char **) NULL
;
3764 int thread
= -1; /* All threads. */
3766 /* Set a breakpoint on the specified hook. */
3767 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3768 addr_end
= hookname
;
3770 if (sals
.nelts
== 0)
3772 warning ("Unable to set a breakpoint on dynamic linker callback.");
3773 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3774 warning ("GDB will be unable to track shl_load/shl_unload calls");
3777 if (sals
.nelts
!= 1)
3779 warning ("Unable to set unique breakpoint on dynamic linker callback.");
3780 warning ("GDB will be unable to track shl_load/shl_unload calls");
3784 /* Make sure that all storage allocated in decode_line_1 gets freed
3785 in case the following errors out. */
3786 old_chain
= make_cleanup (free
, sals
.sals
);
3787 if (canonical
!= (char **) NULL
)
3789 make_cleanup (free
, canonical
);
3790 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3791 if (canonical
[0] != NULL
)
3792 make_cleanup (free
, canonical
[0]);
3795 resolve_sal_pc (&sals
.sals
[0]);
3797 /* Remove the canonical strings from the cleanup, they are needed below. */
3798 if (canonical
!= (char **) NULL
)
3799 discard_cleanups (canonical_strings_chain
);
3801 b
= set_raw_breakpoint (sals
.sals
[0]);
3802 set_breakpoint_count (breakpoint_count
+ 1);
3803 b
->number
= breakpoint_count
;
3805 b
->cond_string
= (cond_string
== NULL
) ?
3806 NULL
: savestring (cond_string
, strlen (cond_string
));
3809 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
3810 b
->addr_string
= canonical
[0];
3811 else if (addr_start
)
3812 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
3814 b
->enable
= enabled
;
3815 b
->disposition
= tempflag
? del
: donttouch
;
3817 if (dll_pathname
== NULL
)
3818 b
->dll_pathname
= NULL
;
3821 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
3822 strcpy (b
->dll_pathname
, dll_pathname
);
3827 do_cleanups (old_chain
);
3831 create_solib_load_event_breakpoint (hookname
, tempflag
,
3832 dll_pathname
, cond_string
)
3838 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
3839 cond_string
, bp_catch_load
);
3843 create_solib_unload_event_breakpoint (hookname
, tempflag
,
3844 dll_pathname
, cond_string
)
3850 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
3851 cond_string
, bp_catch_unload
);
3855 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
3858 enum bptype bp_kind
;
3860 struct symtab_and_line sal
;
3861 struct breakpoint
*b
;
3862 int thread
= -1; /* All threads. */
3869 b
= set_raw_breakpoint (sal
);
3870 set_breakpoint_count (breakpoint_count
+ 1);
3871 b
->number
= breakpoint_count
;
3873 b
->cond_string
= (cond_string
== NULL
) ?
3874 NULL
: savestring (cond_string
, strlen (cond_string
));
3876 b
->addr_string
= NULL
;
3877 b
->enable
= enabled
;
3878 b
->disposition
= tempflag
? del
: donttouch
;
3879 b
->forked_inferior_pid
= 0;
3887 create_fork_event_catchpoint (tempflag
, cond_string
)
3891 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
3895 create_vfork_event_catchpoint (tempflag
, cond_string
)
3899 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
3903 create_exec_event_catchpoint (tempflag
, cond_string
)
3907 struct symtab_and_line sal
;
3908 struct breakpoint
*b
;
3909 int thread
= -1; /* All threads. */
3916 b
= set_raw_breakpoint (sal
);
3917 set_breakpoint_count (breakpoint_count
+ 1);
3918 b
->number
= breakpoint_count
;
3920 b
->cond_string
= (cond_string
== NULL
) ?
3921 NULL
: savestring (cond_string
, strlen (cond_string
));
3923 b
->addr_string
= NULL
;
3924 b
->enable
= enabled
;
3925 b
->disposition
= tempflag
? del
: donttouch
;
3927 b
->type
= bp_catch_exec
;
3933 hw_breakpoint_used_count ()
3935 register struct breakpoint
*b
;
3940 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
3948 hw_watchpoint_used_count (type
, other_type_used
)
3950 int *other_type_used
;
3952 register struct breakpoint
*b
;
3955 *other_type_used
= 0;
3958 if (b
->enable
== enabled
)
3960 if (b
->type
== type
)
3962 else if ((b
->type
== bp_hardware_watchpoint
||
3963 b
->type
== bp_read_watchpoint
||
3964 b
->type
== bp_access_watchpoint
)
3965 && b
->enable
== enabled
)
3966 *other_type_used
= 1;
3972 /* Call this after hitting the longjmp() breakpoint. Use this to set
3973 a new breakpoint at the target of the jmp_buf.
3975 FIXME - This ought to be done by setting a temporary breakpoint
3976 that gets deleted automatically... */
3979 set_longjmp_resume_breakpoint (pc
, frame
)
3981 struct frame_info
*frame
;
3983 register struct breakpoint
*b
;
3986 if (b
->type
== bp_longjmp_resume
)
3989 b
->enable
= enabled
;
3991 b
->frame
= frame
->frame
;
3994 check_duplicates (b
->address
, b
->section
);
4000 disable_watchpoints_before_interactive_call_start ()
4002 struct breakpoint
*b
;
4006 if (((b
->type
== bp_watchpoint
)
4007 || (b
->type
== bp_hardware_watchpoint
)
4008 || (b
->type
== bp_read_watchpoint
)
4009 || (b
->type
== bp_access_watchpoint
)
4010 || ep_is_exception_catchpoint (b
))
4011 && (b
->enable
== enabled
))
4013 b
->enable
= call_disabled
;
4014 check_duplicates (b
->address
, b
->section
);
4020 enable_watchpoints_after_interactive_call_stop ()
4022 struct breakpoint
*b
;
4026 if (((b
->type
== bp_watchpoint
)
4027 || (b
->type
== bp_hardware_watchpoint
)
4028 || (b
->type
== bp_read_watchpoint
)
4029 || (b
->type
== bp_access_watchpoint
)
4030 || ep_is_exception_catchpoint (b
))
4031 && (b
->enable
== call_disabled
))
4033 b
->enable
= enabled
;
4034 check_duplicates (b
->address
, b
->section
);
4040 /* Set a breakpoint that will evaporate an end of command
4041 at address specified by SAL.
4042 Restrict it to frame FRAME if FRAME is nonzero. */
4045 set_momentary_breakpoint (sal
, frame
, type
)
4046 struct symtab_and_line sal
;
4047 struct frame_info
*frame
;
4050 register struct breakpoint
*b
;
4051 b
= set_raw_breakpoint (sal
);
4053 b
->enable
= enabled
;
4054 b
->disposition
= donttouch
;
4055 b
->frame
= (frame
? frame
->frame
: 0);
4057 /* If we're debugging a multi-threaded program, then we
4058 want momentary breakpoints to be active in only a
4059 single thread of control. */
4060 if (in_thread_list (inferior_pid
))
4061 b
->thread
= pid_to_thread_id (inferior_pid
);
4067 /* Tell the user we have just set a breakpoint B. */
4071 struct breakpoint
*b
;
4075 /* FIXME: This is misplaced; mention() is called by things (like hitting a
4076 watchpoint) other than breakpoint creation. It should be possible to
4077 clean this up and at the same time replace the random calls to
4078 breakpoint_changed with this hook, as has already been done for
4079 delete_breakpoint_hook and so on. */
4080 if (create_breakpoint_hook
)
4081 create_breakpoint_hook (b
);
4082 breakpoint_create_event (b
->number
);
4087 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
4090 printf_filtered ("Watchpoint %d: ", b
->number
);
4091 print_expression (b
->exp
, gdb_stdout
);
4093 case bp_hardware_watchpoint
:
4094 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
4095 print_expression (b
->exp
, gdb_stdout
);
4097 case bp_read_watchpoint
:
4098 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
4099 print_expression (b
->exp
, gdb_stdout
);
4101 case bp_access_watchpoint
:
4102 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
4104 print_expression (b
->exp
, gdb_stdout
);
4107 printf_filtered ("Breakpoint %d", b
->number
);
4110 case bp_hardware_breakpoint
:
4111 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
4115 case bp_catch_unload
:
4116 printf_filtered ("Catchpoint %d (%s %s)",
4118 (b
->type
== bp_catch_load
) ? "load" : "unload",
4119 (b
->dll_pathname
!= NULL
) ?
4120 b
->dll_pathname
: "<any library>");
4123 case bp_catch_vfork
:
4124 printf_filtered ("Catchpoint %d (%s)",
4126 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
4129 printf_filtered ("Catchpoint %d (exec)",
4132 case bp_catch_catch
:
4133 case bp_catch_throw
:
4134 printf_filtered ("Catchpoint %d (%s)",
4136 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
4142 case bp_longjmp_resume
:
4143 case bp_step_resume
:
4144 case bp_through_sigtramp
:
4146 case bp_watchpoint_scope
:
4147 case bp_shlib_event
:
4148 case bp_thread_event
:
4153 if (addressprint
|| b
->source_file
== NULL
)
4155 printf_filtered (" at ");
4156 print_address_numeric (b
->address
, 1, gdb_stdout
);
4159 printf_filtered (": file %s, line %d.",
4160 b
->source_file
, b
->line_number
);
4161 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
4162 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
4164 printf_filtered ("\n");
4168 /* Set a breakpoint according to ARG (function, linenum or *address)
4169 flag: first bit : 0 non-temporary, 1 temporary.
4170 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
4173 break_command_1 (arg
, flag
, from_tty
)
4177 int tempflag
, hardwareflag
;
4178 struct symtabs_and_lines sals
;
4179 struct symtab_and_line sal
;
4180 register struct expression
*cond
= 0;
4181 register struct breakpoint
*b
;
4183 /* Pointers in arg to the start, and one past the end, of the condition. */
4184 char *cond_start
= NULL
;
4185 char *cond_end
= NULL
;
4186 /* Pointers in arg to the start, and one past the end,
4187 of the address part. */
4188 char *addr_start
= NULL
;
4189 char *addr_end
= NULL
;
4190 struct cleanup
*old_chain
;
4191 struct cleanup
*canonical_strings_chain
= NULL
;
4192 char **canonical
= (char **) NULL
;
4196 hardwareflag
= flag
& BP_HARDWAREFLAG
;
4197 tempflag
= flag
& BP_TEMPFLAG
;
4202 INIT_SAL (&sal
); /* initialize to zeroes */
4204 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
4206 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
4207 && (arg
[2] == ' ' || arg
[2] == '\t')))
4209 if (default_breakpoint_valid
)
4211 sals
.sals
= (struct symtab_and_line
*)
4212 xmalloc (sizeof (struct symtab_and_line
));
4213 sal
.pc
= default_breakpoint_address
;
4214 sal
.line
= default_breakpoint_line
;
4215 sal
.symtab
= default_breakpoint_symtab
;
4216 sal
.section
= find_pc_overlay (sal
.pc
);
4221 error ("No default breakpoint address now.");
4227 /* Force almost all breakpoints to be in terms of the
4228 current_source_symtab (which is decode_line_1's default). This
4229 should produce the results we want almost all of the time while
4230 leaving default_breakpoint_* alone. */
4231 if (default_breakpoint_valid
4232 && (!current_source_symtab
4233 || (arg
&& (*arg
== '+' || *arg
== '-'))))
4234 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
4235 default_breakpoint_line
, &canonical
);
4237 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
, 0, &canonical
);
4245 /* Make sure that all storage allocated in decode_line_1 gets freed
4246 in case the following `for' loop errors out. */
4247 old_chain
= make_cleanup (free
, sals
.sals
);
4248 if (canonical
!= (char **) NULL
)
4250 make_cleanup (free
, canonical
);
4251 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
4252 for (i
= 0; i
< sals
.nelts
; i
++)
4254 if (canonical
[i
] != NULL
)
4255 make_cleanup (free
, canonical
[i
]);
4259 thread
= -1; /* No specific thread yet */
4261 /* Resolve all line numbers to PC's, and verify that conditions
4262 can be parsed, before setting any breakpoints. */
4263 for (i
= 0; i
< sals
.nelts
; i
++)
4265 char *tok
, *end_tok
;
4268 resolve_sal_pc (&sals
.sals
[i
]);
4270 /* It's possible for the PC to be nonzero, but still an illegal
4271 value on some targets.
4273 For example, on HP-UX if you start gdb, and before running the
4274 inferior you try to set a breakpoint on a shared library function
4275 "foo" where the inferior doesn't call "foo" directly but does
4276 pass its address to another function call, then we do find a
4277 minimal symbol for the "foo", but it's address is invalid.
4278 (Appears to be an index into a table that the loader sets up
4279 when the inferior is run.)
4281 Give the target a chance to bless sals.sals[i].pc before we
4282 try to make a breakpoint for it. */
4283 if (PC_REQUIRES_RUN_BEFORE_USE (sals
.sals
[i
].pc
))
4285 error ("Cannot break on %s without a running program.",
4293 while (*tok
== ' ' || *tok
== '\t')
4298 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4301 toklen
= end_tok
- tok
;
4303 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4305 tok
= cond_start
= end_tok
+ 1;
4306 cond
= parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4309 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4315 thread
= strtol (tok
, &tok
, 0);
4317 error ("Junk after thread keyword.");
4318 if (!valid_thread_id (thread
))
4319 error ("Unknown thread %d\n", thread
);
4322 error ("Junk at end of arguments.");
4327 int i
, target_resources_ok
;
4329 i
= hw_breakpoint_used_count ();
4330 target_resources_ok
=
4331 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4333 if (target_resources_ok
== 0)
4334 error ("No hardware breakpoint support in the target.");
4335 else if (target_resources_ok
< 0)
4336 error ("Hardware breakpoints used exceeds limit.");
4339 /* Remove the canonical strings from the cleanup, they are needed below. */
4340 if (canonical
!= (char **) NULL
)
4341 discard_cleanups (canonical_strings_chain
);
4343 /* Now set all the breakpoints. */
4344 for (i
= 0; i
< sals
.nelts
; i
++)
4349 describe_other_breakpoints (sal
.pc
, sal
.section
);
4351 b
= set_raw_breakpoint (sal
);
4352 set_breakpoint_count (breakpoint_count
+ 1);
4353 b
->number
= breakpoint_count
;
4354 b
->type
= hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
;
4358 /* If a canonical line spec is needed use that instead of the
4360 if (canonical
!= (char **) NULL
&& canonical
[i
] != NULL
)
4361 b
->addr_string
= canonical
[i
];
4362 else if (addr_start
)
4363 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4365 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4367 b
->enable
= enabled
;
4368 b
->disposition
= tempflag
? del
: donttouch
;
4374 warning ("Multiple breakpoints were set.");
4375 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4377 do_cleanups (old_chain
);
4381 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4386 struct frame_info
*frame
;
4387 CORE_ADDR low
, high
, selected_pc
= 0;
4388 char *extra_args
, *level_arg
, *addr_string
;
4389 int extra_args_len
= 0, if_arg
= 0;
4392 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4395 if (default_breakpoint_valid
)
4399 selected_pc
= selected_frame
->pc
;
4404 error ("No selected frame.");
4407 error ("No default breakpoint address now.");
4411 extra_args
= strchr (arg
, ' ');
4415 extra_args_len
= strlen (extra_args
);
4416 level_arg
= (char *) xmalloc (extra_args
- arg
);
4417 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4418 level_arg
[extra_args
- arg
- 1] = '\0';
4422 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4423 strcpy (level_arg
, arg
);
4426 frame
= parse_frame_specification (level_arg
);
4428 selected_pc
= frame
->pc
;
4435 extra_args_len
= strlen (arg
);
4440 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4442 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4444 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4446 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4447 break_command_1 (addr_string
, flag
, from_tty
);
4451 error ("No function contains the specified address");
4454 error ("Unable to set breakpoint at procedure exit");
4459 break_at_finish_command_1 (arg
, flag
, from_tty
)
4464 char *addr_string
, *break_string
, *beg_addr_string
;
4465 CORE_ADDR low
, high
;
4466 struct symtabs_and_lines sals
;
4467 struct symtab_and_line sal
;
4468 struct cleanup
*old_chain
;
4470 int extra_args_len
= 0;
4474 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4476 if (default_breakpoint_valid
)
4480 addr_string
= (char *) xmalloc (15);
4481 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
4486 error ("No selected frame.");
4489 error ("No default breakpoint address now.");
4493 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
4494 strcpy (addr_string
, arg
);
4500 extra_args_len
= strlen (arg
);
4504 /* get the stuff after the function name or address */
4505 extra_args
= strchr (arg
, ' ');
4509 extra_args_len
= strlen (extra_args
);
4516 beg_addr_string
= addr_string
;
4517 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
4520 free (beg_addr_string
);
4521 old_chain
= make_cleanup (free
, sals
.sals
);
4522 for (i
= 0; (i
< sals
.nelts
); i
++)
4525 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
4527 break_string
= (char *) xmalloc (extra_args_len
+ 26);
4529 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4531 sprintf (break_string
, "*0x%s", paddr_nz (high
));
4532 break_command_1 (break_string
, flag
, from_tty
);
4533 free (break_string
);
4536 error ("No function contains the specified address");
4540 warning ("Multiple breakpoints were set.\n");
4541 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4543 do_cleanups (old_chain
);
4547 /* Helper function for break_command_1 and disassemble_command. */
4550 resolve_sal_pc (sal
)
4551 struct symtab_and_line
*sal
;
4555 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
4557 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
4558 error ("No line %d in file \"%s\".",
4559 sal
->line
, sal
->symtab
->filename
);
4563 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
4565 struct blockvector
*bv
;
4570 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
4573 b
= BLOCKVECTOR_BLOCK (bv
, index
);
4574 sym
= block_function (b
);
4577 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
4578 sal
->section
= SYMBOL_BFD_SECTION (sym
);
4582 /* It really is worthwhile to have the section, so we'll just
4583 have to look harder. This case can be executed if we have
4584 line numbers but no functions (as can happen in assembly
4587 struct minimal_symbol
*msym
;
4589 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
4591 sal
->section
= SYMBOL_BFD_SECTION (msym
);
4598 break_command (arg
, from_tty
)
4602 break_command_1 (arg
, 0, from_tty
);
4606 break_at_finish_command (arg
, from_tty
)
4610 break_at_finish_command_1 (arg
, 0, from_tty
);
4614 break_at_finish_at_depth_command (arg
, from_tty
)
4618 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
4622 tbreak_command (arg
, from_tty
)
4626 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4630 tbreak_at_finish_command (arg
, from_tty
)
4634 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4638 hbreak_command (arg
, from_tty
)
4642 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
4646 thbreak_command (arg
, from_tty
)
4650 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
4654 stop_command (arg
, from_tty
)
4658 printf_filtered ("Specify the type of breakpoint to set.\n\
4659 Usage: stop in <function | address>\n\
4664 stopin_command (arg
, from_tty
)
4670 if (arg
== (char *) NULL
)
4672 else if (*arg
!= '*')
4677 /* look for a ':'. If this is a line number specification, then
4678 say it is bad, otherwise, it should be an address or
4679 function/method name */
4680 while (*argptr
&& !hasColon
)
4682 hasColon
= (*argptr
== ':');
4687 badInput
= (*argptr
!= ':'); /* Not a class::method */
4689 badInput
= isdigit (*arg
); /* a simple line number */
4693 printf_filtered ("Usage: stop in <function | address>\n");
4695 break_command_1 (arg
, 0, from_tty
);
4699 stopat_command (arg
, from_tty
)
4705 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
4712 /* look for a ':'. If there is a '::' then get out, otherwise
4713 it is probably a line number. */
4714 while (*argptr
&& !hasColon
)
4716 hasColon
= (*argptr
== ':');
4721 badInput
= (*argptr
== ':'); /* we have class::method */
4723 badInput
= !isdigit (*arg
); /* not a line number */
4727 printf_filtered ("Usage: stop at <line>\n");
4729 break_command_1 (arg
, 0, from_tty
);
4733 /* accessflag: hw_write: watch write,
4734 hw_read: watch read,
4735 hw_access: watch access (read or write) */
4737 watch_command_1 (arg
, accessflag
, from_tty
)
4742 struct breakpoint
*b
;
4743 struct symtab_and_line sal
;
4744 struct expression
*exp
;
4745 struct block
*exp_valid_block
;
4746 struct value
*val
, *mark
;
4747 struct frame_info
*frame
;
4748 struct frame_info
*prev_frame
= NULL
;
4749 char *exp_start
= NULL
;
4750 char *exp_end
= NULL
;
4751 char *tok
, *end_tok
;
4753 char *cond_start
= NULL
;
4754 char *cond_end
= NULL
;
4755 struct expression
*cond
= NULL
;
4756 int i
, other_type_used
, target_resources_ok
= 0;
4757 enum bptype bp_type
;
4760 INIT_SAL (&sal
); /* initialize to zeroes */
4762 /* Parse arguments. */
4763 innermost_block
= NULL
;
4765 exp
= parse_exp_1 (&arg
, 0, 0);
4767 exp_valid_block
= innermost_block
;
4768 mark
= value_mark ();
4769 val
= evaluate_expression (exp
);
4770 release_value (val
);
4771 if (VALUE_LAZY (val
))
4772 value_fetch_lazy (val
);
4775 while (*tok
== ' ' || *tok
== '\t')
4779 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4782 toklen
= end_tok
- tok
;
4783 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4785 tok
= cond_start
= end_tok
+ 1;
4786 cond
= parse_exp_1 (&tok
, 0, 0);
4790 error ("Junk at end of command.");
4792 if (accessflag
== hw_read
)
4793 bp_type
= bp_read_watchpoint
;
4794 else if (accessflag
== hw_access
)
4795 bp_type
= bp_access_watchpoint
;
4797 bp_type
= bp_hardware_watchpoint
;
4799 mem_cnt
= can_use_hardware_watchpoint (val
);
4800 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
4801 error ("Expression cannot be implemented with read/access watchpoint.");
4804 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
4805 target_resources_ok
=
4806 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
4808 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
4809 error ("Target does not support this type of hardware watchpoint.");
4811 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
4812 error ("Target can only support one kind of HW watchpoint at a time.");
4815 #if defined(HPUXHPPA)
4816 /* On HP-UX if you set a h/w
4817 watchpoint before the "run" command, the inferior dies with a e.g.,
4818 SIGILL once you start it. I initially believed this was due to a
4819 bad interaction between page protection traps and the initial
4820 startup sequence by the dynamic linker.
4822 However, I tried avoiding that by having HP-UX's implementation of
4823 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4824 yet, which forced slow watches before a "run" or "attach", and it
4825 still fails somewhere in the startup code.
4827 Until I figure out what's happening, I'm disallowing watches altogether
4828 before the "run" or "attach" command. We'll tell the user they must
4829 set watches after getting the program started. */
4830 if (!target_has_execution
)
4832 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4835 #endif /* HPUXHPPA */
4837 /* Now set up the breakpoint. */
4838 b
= set_raw_breakpoint (sal
);
4839 set_breakpoint_count (breakpoint_count
+ 1);
4840 b
->number
= breakpoint_count
;
4841 b
->disposition
= donttouch
;
4843 b
->exp_valid_block
= exp_valid_block
;
4844 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
4848 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
4852 frame
= block_innermost_frame (exp_valid_block
);
4855 prev_frame
= get_prev_frame (frame
);
4856 b
->watchpoint_frame
= frame
->frame
;
4859 b
->watchpoint_frame
= (CORE_ADDR
) 0;
4861 if (mem_cnt
&& target_resources_ok
> 0)
4864 b
->type
= bp_watchpoint
;
4866 /* If the expression is "local", then set up a "watchpoint scope"
4867 breakpoint at the point where we've left the scope of the watchpoint
4869 if (innermost_block
)
4873 struct breakpoint
*scope_breakpoint
;
4874 struct symtab_and_line scope_sal
;
4876 INIT_SAL (&scope_sal
); /* initialize to zeroes */
4877 scope_sal
.pc
= get_frame_pc (prev_frame
);
4878 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
4880 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
4881 set_breakpoint_count (breakpoint_count
+ 1);
4882 scope_breakpoint
->number
= breakpoint_count
;
4884 scope_breakpoint
->type
= bp_watchpoint_scope
;
4885 scope_breakpoint
->enable
= enabled
;
4887 /* Automatically delete the breakpoint when it hits. */
4888 scope_breakpoint
->disposition
= del
;
4890 /* Only break in the proper frame (help with recursion). */
4891 scope_breakpoint
->frame
= prev_frame
->frame
;
4893 /* Set the address at which we will stop. */
4894 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
4896 /* The scope breakpoint is related to the watchpoint. We
4897 will need to act on them together. */
4898 b
->related_breakpoint
= scope_breakpoint
;
4901 value_free_to_mark (mark
);
4905 /* Return count of locations need to be watched and can be handled
4906 in hardware. If the watchpoint can not be handled
4907 in hardware return zero. */
4909 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4910 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
4911 ((BYTE_SIZE) <= (REGISTER_SIZE))
4914 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
4915 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
4916 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
4920 can_use_hardware_watchpoint (v
)
4923 int found_memory_cnt
= 0;
4925 /* Did the user specifically forbid us to use hardware watchpoints? */
4926 if (!can_use_hw_watchpoints
)
4929 /* Make sure that the value of the expression depends only upon
4930 memory contents, and values computed from them within GDB. If we
4931 find any register references or function calls, we can't use a
4932 hardware watchpoint.
4934 The idea here is that evaluating an expression generates a series
4935 of values, one holding the value of every subexpression. (The
4936 expression a*b+c has five subexpressions: a, b, a*b, c, and
4937 a*b+c.) GDB's values hold almost enough information to establish
4938 the criteria given above --- they identify memory lvalues,
4939 register lvalues, computed values, etcetera. So we can evaluate
4940 the expression, and then scan the chain of values that leaves
4941 behind to decide whether we can detect any possible change to the
4942 expression's final value using only hardware watchpoints.
4944 However, I don't think that the values returned by inferior
4945 function calls are special in any way. So this function may not
4946 notice that an expression involving an inferior function call
4947 can't be watched with hardware watchpoints. FIXME. */
4948 for (; v
; v
= v
->next
)
4950 if (VALUE_LVAL (v
) == lval_memory
)
4953 /* A lazy memory lvalue is one that GDB never needed to fetch;
4954 we either just used its address (e.g., `a' in `a.b') or
4955 we never needed it at all (e.g., `a' in `a,b'). */
4959 /* Ahh, memory we actually used! Check if we can cover
4960 it with hardware watchpoints. */
4961 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
4962 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
4964 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
4970 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
4971 return 0; /* ??? What does this represent? */
4972 else if (v
->lval
== lval_register
)
4973 return 0; /* cannot watch a register with a HW watchpoint */
4976 /* The expression itself looks suitable for using a hardware
4977 watchpoint, but give the target machine a chance to reject it. */
4978 return found_memory_cnt
;
4982 watch_command (arg
, from_tty
)
4986 watch_command_1 (arg
, hw_write
, from_tty
);
4990 rwatch_command (arg
, from_tty
)
4994 watch_command_1 (arg
, hw_read
, from_tty
);
4998 awatch_command (arg
, from_tty
)
5002 watch_command_1 (arg
, hw_access
, from_tty
);
5006 /* Helper routines for the until_command routine in infcmd.c. Here
5007 because it uses the mechanisms of breakpoints. */
5009 /* This function is called by fetch_inferior_event via the
5010 cmd_continuation pointer, to complete the until command. It takes
5011 care of cleaning up the temporary breakpoints set up by the until
5014 until_break_command_continuation (struct continuation_arg
*arg
)
5016 /* Do all the exec cleanups, which at this point should only be the
5017 one set up in the first part of the until_break_command
5019 do_exec_cleanups (ALL_CLEANUPS
);
5024 until_break_command (arg
, from_tty
)
5028 struct symtabs_and_lines sals
;
5029 struct symtab_and_line sal
;
5030 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
5031 struct breakpoint
*breakpoint
;
5032 struct cleanup
*old_chain
;
5034 clear_proceed_status ();
5036 /* Set a breakpoint where the user wants it and at return from
5039 if (default_breakpoint_valid
)
5040 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
5041 default_breakpoint_line
, (char ***) NULL
);
5043 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
5044 0, (char ***) NULL
);
5046 if (sals
.nelts
!= 1)
5047 error ("Couldn't get information on specified line.");
5050 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
5053 error ("Junk at end of arguments.");
5055 resolve_sal_pc (&sal
);
5057 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
5059 if (!event_loop_p
|| !target_can_async_p ())
5060 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
5063 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5065 /* If we are running asynchronously, and the target supports async
5066 execution, we are not waiting for the target to stop, in the call
5067 tp proceed, below. This means that we cannot delete the
5068 brekpoints until the target has actually stopped. The only place
5069 where we get a chance to do that is in fetch_inferior_event, so
5070 we must set things up for that. */
5072 if (event_loop_p
&& target_can_async_p ())
5074 /* In this case we don't need args for the continuation, because
5075 all it needs to do is do the cleanups in the
5076 exec_cleanup_chain, which will be only those inserted by this
5077 function. We can get away by using ALL_CLEANUPS. */
5078 add_continuation (until_break_command_continuation
, NULL
);
5081 /* Keep within the current frame */
5085 sal
= find_pc_line (prev_frame
->pc
, 0);
5086 sal
.pc
= prev_frame
->pc
;
5087 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
5088 if (!event_loop_p
|| !target_can_async_p ())
5089 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5091 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5094 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
5095 /* Do the cleanups now, anly if we are not running asynchronously,
5096 of if we are, but the target is still synchronous. */
5097 if (!event_loop_p
|| !target_can_async_p ())
5098 do_cleanups (old_chain
);
5102 /* These aren't used; I don't konw what they were for. */
5103 /* Set a breakpoint at the catch clause for NAME. */
5105 catch_breakpoint (name
)
5111 disable_catch_breakpoint ()
5116 delete_catch_breakpoint ()
5121 enable_catch_breakpoint ()
5128 struct sal_chain
*next
;
5129 struct symtab_and_line sal
;
5133 /* Not really used -- invocation in handle_gnu_4_16_catch_command
5134 had been commented out in the v.4.16 sources, and stays
5135 disabled there now because "catch NAME" syntax isn't allowed.
5137 /* This isn't used; I don't know what it was for. */
5138 /* For each catch clause identified in ARGS, run FUNCTION
5139 with that clause as an argument. */
5140 static struct symtabs_and_lines
5141 map_catch_names (args
, function
)
5145 register char *p
= args
;
5147 struct symtabs_and_lines sals
;
5149 struct sal_chain
*sal_chain
= 0;
5153 error_no_arg ("one or more catch names");
5161 /* Don't swallow conditional part. */
5162 if (p1
[0] == 'i' && p1
[1] == 'f'
5163 && (p1
[2] == ' ' || p1
[2] == '\t'))
5169 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
5173 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
5174 error ("Arguments must be catch names.");
5180 struct sal_chain
*next
= (struct sal_chain
*)
5181 alloca (sizeof (struct sal_chain
));
5182 next
->next
= sal_chain
;
5183 next
->sal
= get_catch_sal (p
);
5188 printf_unfiltered ("No catch clause for exception %s.\n", p
);
5193 while (*p
== ' ' || *p
== '\t')
5199 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
5201 static struct symtabs_and_lines
5202 get_catch_sals (this_level_only
)
5203 int this_level_only
;
5205 register struct blockvector
*bl
;
5206 register struct block
*block
;
5207 int index
, have_default
= 0;
5209 struct symtabs_and_lines sals
;
5210 struct sal_chain
*sal_chain
= 0;
5211 char *blocks_searched
;
5213 /* Not sure whether an error message is always the correct response,
5214 but it's better than a core dump. */
5215 if (selected_frame
== NULL
)
5216 error ("No selected frame.");
5217 block
= get_frame_block (selected_frame
);
5218 pc
= selected_frame
->pc
;
5224 error ("No symbol table info available.\n");
5226 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
5227 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5228 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5232 CORE_ADDR end
= BLOCK_END (block
) - 4;
5235 if (bl
!= blockvector_for_pc (end
, &index
))
5236 error ("blockvector blotch");
5237 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
5238 error ("blockvector botch");
5239 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
5242 /* Don't print out blocks that have gone by. */
5243 while (index
< last_index
5244 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
5247 while (index
< last_index
5248 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
5250 if (blocks_searched
[index
] == 0)
5252 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
5255 register struct symbol
*sym
;
5257 nsyms
= BLOCK_NSYMS (b
);
5259 for (i
= 0; i
< nsyms
; i
++)
5261 sym
= BLOCK_SYM (b
, i
);
5262 if (STREQ (SYMBOL_NAME (sym
), "default"))
5268 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
5270 struct sal_chain
*next
= (struct sal_chain
*)
5271 alloca (sizeof (struct sal_chain
));
5272 next
->next
= sal_chain
;
5273 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
5278 blocks_searched
[index
] = 1;
5284 if (sal_chain
&& this_level_only
)
5287 /* After handling the function's top-level block, stop.
5288 Don't continue to its superblock, the block of
5289 per-file symbols. */
5290 if (BLOCK_FUNCTION (block
))
5292 block
= BLOCK_SUPERBLOCK (block
);
5297 struct sal_chain
*tmp_chain
;
5299 /* Count the number of entries. */
5300 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
5301 tmp_chain
= tmp_chain
->next
)
5305 sals
.sals
= (struct symtab_and_line
*)
5306 xmalloc (index
* sizeof (struct symtab_and_line
));
5307 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5308 sals
.sals
[index
] = sal_chain
->sal
;
5315 ep_skip_leading_whitespace (s
)
5318 if ((s
== NULL
) || (*s
== NULL
))
5320 while (isspace (**s
))
5324 /* This function examines a string, and attempts to find a token
5325 that might be an event name in the leading characters. If a
5326 possible match is found, a pointer to the last character of
5327 the token is returned. Else, NULL is returned. */
5330 ep_find_event_name_end (arg
)
5334 char *event_name_end
= NULL
;
5336 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5340 /* We break out of the loop when we find a token delimiter.
5341 Basically, we're looking for alphanumerics and underscores;
5342 anything else delimites the token. */
5345 if (!isalnum (*s
) && (*s
!= '_'))
5351 return event_name_end
;
5355 /* This function attempts to parse an optional "if <cond>" clause
5356 from the arg string. If one is not found, it returns NULL.
5358 Else, it returns a pointer to the condition string. (It does not
5359 attempt to evaluate the string against a particular block.) And,
5360 it updates arg to point to the first character following the parsed
5361 if clause in the arg string. */
5364 ep_parse_optional_if_clause (arg
)
5369 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5372 /* Skip the "if" keyword. */
5375 /* Skip any extra leading whitespace, and record the start of the
5376 condition string. */
5377 ep_skip_leading_whitespace (arg
);
5380 /* Assume that the condition occupies the remainder of the arg string. */
5381 (*arg
) += strlen (cond_string
);
5386 /* This function attempts to parse an optional filename from the arg
5387 string. If one is not found, it returns NULL.
5389 Else, it returns a pointer to the parsed filename. (This function
5390 makes no attempt to verify that a file of that name exists, or is
5391 accessible.) And, it updates arg to point to the first character
5392 following the parsed filename in the arg string.
5394 Note that clients needing to preserve the returned filename for
5395 future access should copy it to their own buffers. */
5397 ep_parse_optional_filename (arg
)
5400 static char filename
[1024];
5405 if ((*arg_p
== '\0') || isspace (*arg_p
))
5423 /* Commands to deal with catching events, such as signals, exceptions,
5424 process start/exit, etc. */
5428 catch_fork
, catch_vfork
5432 #if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
5433 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
5439 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
5440 catch_fork_kind fork_kind
;
5445 char *cond_string
= NULL
;
5447 ep_skip_leading_whitespace (&arg
);
5449 /* The allowed syntax is:
5451 catch [v]fork if <cond>
5453 First, check if there's an if clause. */
5454 cond_string
= ep_parse_optional_if_clause (&arg
);
5456 if ((*arg
!= '\0') && !isspace (*arg
))
5457 error ("Junk at end of arguments.");
5459 /* If this target supports it, create a fork or vfork catchpoint
5460 and enable reporting of such events. */
5464 create_fork_event_catchpoint (tempflag
, cond_string
);
5467 create_vfork_event_catchpoint (tempflag
, cond_string
);
5470 error ("unsupported or unknown fork kind; cannot catch it");
5476 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5478 catch_exec_command_1 (arg
, tempflag
, from_tty
)
5483 char *cond_string
= NULL
;
5485 ep_skip_leading_whitespace (&arg
);
5487 /* The allowed syntax is:
5489 catch exec if <cond>
5491 First, check if there's an if clause. */
5492 cond_string
= ep_parse_optional_if_clause (&arg
);
5494 if ((*arg
!= '\0') && !isspace (*arg
))
5495 error ("Junk at end of arguments.");
5497 /* If this target supports it, create an exec catchpoint
5498 and enable reporting of such events. */
5499 create_exec_event_catchpoint (tempflag
, cond_string
);
5503 #if defined(SOLIB_ADD)
5505 catch_load_command_1 (arg
, tempflag
, from_tty
)
5510 char *dll_pathname
= NULL
;
5511 char *cond_string
= NULL
;
5513 ep_skip_leading_whitespace (&arg
);
5515 /* The allowed syntax is:
5517 catch load if <cond>
5518 catch load <filename>
5519 catch load <filename> if <cond>
5521 The user is not allowed to specify the <filename> after an
5524 We'll ignore the pathological case of a file named "if".
5526 First, check if there's an if clause. If so, then there
5527 cannot be a filename. */
5528 cond_string
= ep_parse_optional_if_clause (&arg
);
5530 /* If there was an if clause, then there cannot be a filename.
5531 Else, there might be a filename and an if clause. */
5532 if (cond_string
== NULL
)
5534 dll_pathname
= ep_parse_optional_filename (&arg
);
5535 ep_skip_leading_whitespace (&arg
);
5536 cond_string
= ep_parse_optional_if_clause (&arg
);
5539 if ((*arg
!= '\0') && !isspace (*arg
))
5540 error ("Junk at end of arguments.");
5542 /* Create a load breakpoint that only triggers when a load of
5543 the specified dll (or any dll, if no pathname was specified)
5545 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
5546 dll_pathname
, cond_string
);
5550 catch_unload_command_1 (arg
, tempflag
, from_tty
)
5555 char *dll_pathname
= NULL
;
5556 char *cond_string
= NULL
;
5558 ep_skip_leading_whitespace (&arg
);
5560 /* The allowed syntax is:
5562 catch unload if <cond>
5563 catch unload <filename>
5564 catch unload <filename> if <cond>
5566 The user is not allowed to specify the <filename> after an
5569 We'll ignore the pathological case of a file named "if".
5571 First, check if there's an if clause. If so, then there
5572 cannot be a filename. */
5573 cond_string
= ep_parse_optional_if_clause (&arg
);
5575 /* If there was an if clause, then there cannot be a filename.
5576 Else, there might be a filename and an if clause. */
5577 if (cond_string
== NULL
)
5579 dll_pathname
= ep_parse_optional_filename (&arg
);
5580 ep_skip_leading_whitespace (&arg
);
5581 cond_string
= ep_parse_optional_if_clause (&arg
);
5584 if ((*arg
!= '\0') && !isspace (*arg
))
5585 error ("Junk at end of arguments.");
5587 /* Create an unload breakpoint that only triggers when an unload of
5588 the specified dll (or any dll, if no pathname was specified)
5590 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
5591 dll_pathname
, cond_string
);
5593 #endif /* SOLIB_ADD */
5595 /* Commands to deal with catching exceptions. */
5597 /* Set a breakpoint at the specified callback routine for an
5598 exception event callback */
5601 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
5604 enum exception_event_kind ex_event
;
5605 struct symtab_and_line
*sal
;
5607 struct breakpoint
*b
;
5608 int thread
= -1; /* All threads. */
5610 if (!sal
) /* no exception support? */
5613 b
= set_raw_breakpoint (*sal
);
5614 set_breakpoint_count (breakpoint_count
+ 1);
5615 b
->number
= breakpoint_count
;
5617 b
->cond_string
= (cond_string
== NULL
) ?
5618 NULL
: savestring (cond_string
, strlen (cond_string
));
5620 b
->addr_string
= NULL
;
5621 b
->enable
= enabled
;
5622 b
->disposition
= tempflag
? del
: donttouch
;
5625 case EX_EVENT_THROW
:
5626 b
->type
= bp_catch_throw
;
5628 case EX_EVENT_CATCH
:
5629 b
->type
= bp_catch_catch
;
5631 default: /* error condition */
5633 b
->enable
= disabled
;
5634 error ("Internal error -- invalid catchpoint kind");
5639 /* Deal with "catch catch" and "catch throw" commands */
5642 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
5643 enum exception_event_kind ex_event
;
5648 char *cond_string
= NULL
;
5649 struct symtab_and_line
*sal
= NULL
;
5651 ep_skip_leading_whitespace (&arg
);
5653 cond_string
= ep_parse_optional_if_clause (&arg
);
5655 if ((*arg
!= '\0') && !isspace (*arg
))
5656 error ("Junk at end of arguments.");
5658 if ((ex_event
!= EX_EVENT_THROW
) &&
5659 (ex_event
!= EX_EVENT_CATCH
))
5660 error ("Unsupported or unknown exception event; cannot catch it");
5662 /* See if we can find a callback routine */
5663 sal
= target_enable_exception_callback (ex_event
, 1);
5667 /* We have callbacks from the runtime system for exceptions.
5668 Set a breakpoint on the sal found, if no errors */
5669 if (sal
!= (struct symtab_and_line
*) -1)
5670 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
5672 return; /* something went wrong with setting up callbacks */
5676 /* No callbacks from runtime system for exceptions.
5677 Try GNU C++ exception breakpoints using labels in debug info. */
5678 if (ex_event
== EX_EVENT_CATCH
)
5680 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
5682 else if (ex_event
== EX_EVENT_THROW
)
5684 /* Set a breakpoint on __raise_exception () */
5686 warning ("Unsupported with this platform/compiler combination.");
5687 warning ("Perhaps you can achieve the effect you want by setting");
5688 warning ("a breakpoint on __raise_exception().");
5693 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5694 inside a catch_errors */
5697 cover_target_enable_exception_callback (arg
)
5700 args_for_catchpoint_enable
*args
= arg
;
5701 struct symtab_and_line
*sal
;
5702 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
5705 else if (sal
== (struct symtab_and_line
*) -1)
5708 return 1; /*is valid */
5713 /* This is the original v.4.16 and earlier version of the
5714 catch_command_1() function. Now that other flavours of "catch"
5715 have been introduced, and since exception handling can be handled
5716 in other ways (through target ops) also, this is used only for the
5717 GNU C++ exception handling system.
5718 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5719 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5720 there was no code in GDB 4.16 for "catch throw".
5722 Called from catch_exception_command_1 () */
5726 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
5731 /* First, translate ARG into something we can deal with in terms
5734 struct symtabs_and_lines sals
;
5735 struct symtab_and_line sal
;
5736 register struct expression
*cond
= 0;
5737 register struct breakpoint
*b
;
5741 INIT_SAL (&sal
); /* initialize to zeroes */
5743 /* If no arg given, or if first arg is 'if ', all active catch clauses
5744 are breakpointed. */
5746 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
5747 && (arg
[2] == ' ' || arg
[2] == '\t')))
5749 /* Grab all active catch clauses. */
5750 sals
= get_catch_sals (0);
5754 /* Grab selected catch clauses. */
5755 error ("catch NAME not implemented");
5758 /* Not sure why this code has been disabled. I'm leaving
5759 it disabled. We can never come here now anyway
5760 since we don't allow the "catch NAME" syntax.
5763 /* This isn't used; I don't know what it was for. */
5764 sals
= map_catch_names (arg
, catch_breakpoint
);
5772 for (i
= 0; i
< sals
.nelts
; i
++)
5774 resolve_sal_pc (&sals
.sals
[i
]);
5778 if (arg
[0] == 'i' && arg
[1] == 'f'
5779 && (arg
[2] == ' ' || arg
[2] == '\t'))
5780 cond
= parse_exp_1 ((arg
+= 2, &arg
),
5781 block_for_pc (sals
.sals
[i
].pc
), 0);
5783 error ("Junk at end of arguments.");
5788 for (i
= 0; i
< sals
.nelts
; i
++)
5793 describe_other_breakpoints (sal
.pc
, sal
.section
);
5795 b
= set_raw_breakpoint (sal
);
5796 set_breakpoint_count (breakpoint_count
+ 1);
5797 b
->number
= breakpoint_count
;
5799 /* Important -- this is an ordinary breakpoint. For platforms
5800 with callback support for exceptions,
5801 create_exception_catchpoint() will create special bp types
5802 (bp_catch_catch and bp_catch_throw), and there is code in
5803 insert_breakpoints() and elsewhere that depends on that. */
5804 b
->type
= bp_breakpoint
;
5807 b
->enable
= enabled
;
5808 b
->disposition
= tempflag
? del
: donttouch
;
5815 warning ("Multiple breakpoints were set.");
5816 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5818 free ((PTR
) sals
.sals
);
5822 /* This creates a temporary internal breakpoint
5823 just to placate infrun */
5824 static struct breakpoint
*
5825 create_temp_exception_breakpoint (pc
)
5828 struct symtab_and_line sal
;
5829 struct breakpoint
*b
;
5836 b
= set_raw_breakpoint (sal
);
5838 error ("Internal error -- couldn't set temp exception breakpoint");
5840 b
->type
= bp_breakpoint
;
5841 b
->disposition
= del
;
5842 b
->enable
= enabled
;
5844 b
->number
= internal_breakpoint_number
--;
5850 catch_command_1 (arg
, tempflag
, from_tty
)
5856 /* The first argument may be an event name, such as "start" or "load".
5857 If so, then handle it as such. If it doesn't match an event name,
5858 then attempt to interpret it as an exception name. (This latter is
5859 the v4.16-and-earlier GDB meaning of the "catch" command.)
5861 First, try to find the bounds of what might be an event name. */
5862 char *arg1_start
= arg
;
5866 if (arg1_start
== NULL
)
5868 /* Old behaviour was to use pre-v-4.16 syntax */
5869 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5871 /* Now, this is not allowed */
5872 error ("Catch requires an event name.");
5875 arg1_end
= ep_find_event_name_end (arg1_start
);
5876 if (arg1_end
== NULL
)
5877 error ("catch requires an event");
5878 arg1_length
= arg1_end
+ 1 - arg1_start
;
5880 /* Try to match what we found against known event names. */
5881 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
5883 error ("Catch of signal not yet implemented");
5885 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
5887 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
5888 tempflag
, from_tty
);
5890 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
5892 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
5893 tempflag
, from_tty
);
5895 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
5897 error ("Catch of thread_start not yet implemented");
5899 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
5901 error ("Catch of thread_exit not yet implemented");
5903 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
5905 error ("Catch of thread_join not yet implemented");
5907 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
5909 error ("Catch of start not yet implemented");
5911 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
5913 error ("Catch of exit not yet implemented");
5915 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
5917 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5918 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
5920 error ("Catch of fork not yet implemented");
5923 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
5925 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5926 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
5928 error ("Catch of vfork not yet implemented");
5931 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
5933 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5934 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5936 error ("Catch of exec not yet implemented");
5939 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
5941 #if defined(SOLIB_ADD)
5942 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5944 error ("Catch of load not implemented");
5947 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
5949 #if defined(SOLIB_ADD)
5950 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
5952 error ("Catch of load not implemented");
5955 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
5957 error ("Catch of stop not yet implemented");
5960 /* This doesn't appear to be an event name */
5964 /* Pre-v.4.16 behaviour was to treat the argument
5965 as the name of an exception */
5966 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5967 /* Now this is not allowed */
5968 error ("Unknown event kind specified for catch");
5973 /* Used by the gui, could be made a worker for other things. */
5976 set_breakpoint_sal (sal
)
5977 struct symtab_and_line sal
;
5979 struct breakpoint
*b
;
5980 b
= set_raw_breakpoint (sal
);
5981 set_breakpoint_count (breakpoint_count
+ 1);
5982 b
->number
= breakpoint_count
;
5983 b
->type
= bp_breakpoint
;
5990 /* These aren't used; I don't know what they were for. */
5991 /* Disable breakpoints on all catch clauses described in ARGS. */
5993 disable_catch (args
)
5996 /* Map the disable command to catch clauses described in ARGS. */
5999 /* Enable breakpoints on all catch clauses described in ARGS. */
6004 /* Map the disable command to catch clauses described in ARGS. */
6007 /* Delete breakpoints on all catch clauses in the active scope. */
6012 /* Map the delete command to catch clauses described in ARGS. */
6017 catch_command (arg
, from_tty
)
6021 catch_command_1 (arg
, 0, from_tty
);
6026 tcatch_command (arg
, from_tty
)
6030 catch_command_1 (arg
, 1, from_tty
);
6035 clear_command (arg
, from_tty
)
6039 register struct breakpoint
*b
, *b1
;
6041 struct symtabs_and_lines sals
;
6042 struct symtab_and_line sal
;
6043 register struct breakpoint
*found
;
6048 sals
= decode_line_spec (arg
, 1);
6053 sals
.sals
= (struct symtab_and_line
*)
6054 xmalloc (sizeof (struct symtab_and_line
));
6055 INIT_SAL (&sal
); /* initialize to zeroes */
6056 sal
.line
= default_breakpoint_line
;
6057 sal
.symtab
= default_breakpoint_symtab
;
6058 sal
.pc
= default_breakpoint_address
;
6059 if (sal
.symtab
== 0)
6060 error ("No source file specified.");
6068 /* For each line spec given, delete bps which correspond
6069 to it. We do this in two loops: the first loop looks at
6070 the initial bp(s) in the chain which should be deleted,
6071 the second goes down the rest of the chain looking ahead
6072 one so it can take those bps off the chain without messing
6076 for (i
= 0; i
< sals
.nelts
; i
++)
6078 /* If exact pc given, clear bpts at that pc.
6079 If line given (pc == 0), clear all bpts on specified line.
6080 If defaulting, clear all bpts on default line
6083 defaulting sal.pc != 0 tests to do
6088 1 0 <can't happen> */
6091 found
= (struct breakpoint
*) 0;
6094 while (breakpoint_chain
6095 /* Why don't we check here that this is not
6096 a watchpoint, etc., as we do below?
6097 I can't make it fail, but don't know
6098 what's stopping the failure: a watchpoint
6099 of the same address as "sal.pc" should
6100 wind up being deleted. */
6102 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
6103 (overlay_debugging
== 0 ||
6104 breakpoint_chain
->section
== sal
.section
))
6105 || ((default_match
|| (0 == sal
.pc
))
6106 && breakpoint_chain
->source_file
!= NULL
6107 && sal
.symtab
!= NULL
6108 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
6109 && breakpoint_chain
->line_number
== sal
.line
)))
6112 b1
= breakpoint_chain
;
6113 breakpoint_chain
= b1
->next
;
6121 && b
->next
->type
!= bp_none
6122 && b
->next
->type
!= bp_watchpoint
6123 && b
->next
->type
!= bp_hardware_watchpoint
6124 && b
->next
->type
!= bp_read_watchpoint
6125 && b
->next
->type
!= bp_access_watchpoint
6126 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
6127 (overlay_debugging
== 0 ||
6128 b
->next
->section
== sal
.section
))
6129 || ((default_match
|| (0 == sal
.pc
))
6130 && b
->next
->source_file
!= NULL
6131 && sal
.symtab
!= NULL
6132 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
6133 && b
->next
->line_number
== sal
.line
)))
6146 error ("No breakpoint at %s.", arg
);
6148 error ("No breakpoint at this line.");
6152 from_tty
= 1; /* Always report if deleted more than one */
6154 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
6155 breakpoints_changed ();
6159 printf_unfiltered ("%d ", found
->number
);
6161 delete_breakpoint (found
);
6165 putchar_unfiltered ('\n');
6167 free ((PTR
) sals
.sals
);
6170 /* Delete breakpoint in BS if they are `delete' breakpoints and
6171 all breakpoints that are marked for deletion, whether hit or not.
6172 This is called after any breakpoint is hit, or after errors. */
6175 breakpoint_auto_delete (bs
)
6178 struct breakpoint
*b
, *temp
;
6180 for (; bs
; bs
= bs
->next
)
6181 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
6183 delete_breakpoint (bs
->breakpoint_at
);
6185 ALL_BREAKPOINTS_SAFE (b
, temp
)
6187 if (b
->disposition
== del_at_next_stop
)
6188 delete_breakpoint (b
);
6192 /* Delete a breakpoint and clean up all traces of it in the data
6196 delete_breakpoint (bpt
)
6197 struct breakpoint
*bpt
;
6199 register struct breakpoint
*b
;
6203 error ("Internal error (attempted to delete a NULL breakpoint)");
6206 /* Has this bp already been deleted? This can happen because multiple
6207 lists can hold pointers to bp's. bpstat lists are especial culprits.
6209 One example of this happening is a watchpoint's scope bp. When the
6210 scope bp triggers, we notice that the watchpoint is out of scope, and
6211 delete it. We also delete its scope bp. But the scope bp is marked
6212 "auto-deleting", and is already on a bpstat. That bpstat is then
6213 checked for auto-deleting bp's, which are deleted.
6215 A real solution to this problem might involve reference counts in bp's,
6216 and/or giving them pointers back to their referencing bpstat's, and
6217 teaching delete_breakpoint to only free a bp's storage when no more
6218 references were extent. A cheaper bandaid was chosen. */
6219 if (bpt
->type
== bp_none
)
6222 if (delete_breakpoint_hook
)
6223 delete_breakpoint_hook (bpt
);
6224 breakpoint_delete_event (bpt
->number
);
6227 remove_breakpoint (bpt
, mark_uninserted
);
6229 if (breakpoint_chain
== bpt
)
6230 breakpoint_chain
= bpt
->next
;
6232 /* If we have callback-style exception catchpoints, don't go through
6233 the adjustments to the C++ runtime library etc. if the inferior
6234 isn't actually running. target_enable_exception_callback for a
6235 null target ops vector gives an undesirable error message, so we
6236 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
6237 exceptions are supported in this way, it's OK for now. FIXME */
6238 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
6240 static char message1
[] = "Error in deleting catchpoint %d:\n";
6241 static char message
[sizeof (message1
) + 30];
6242 args_for_catchpoint_enable args
;
6244 /* Format possible error msg */
6245 sprintf (message
, message1
, bpt
->number
);
6246 args
.kind
= bpt
->type
== bp_catch_catch
?
6247 EX_EVENT_CATCH
: EX_EVENT_THROW
;
6249 catch_errors (cover_target_enable_exception_callback
, &args
,
6250 message
, RETURN_MASK_ALL
);
6257 b
->next
= bpt
->next
;
6261 /* Before turning off the visuals for the bp, check to see that
6262 there are no other bps at the same address. */
6269 clearIt
= (b
->address
!= bpt
->address
);
6276 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
6277 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
6281 check_duplicates (bpt
->address
, bpt
->section
);
6282 /* If this breakpoint was inserted, and there is another breakpoint
6283 at the same address, we need to insert the other breakpoint. */
6285 && bpt
->type
!= bp_hardware_watchpoint
6286 && bpt
->type
!= bp_read_watchpoint
6287 && bpt
->type
!= bp_access_watchpoint
6288 && bpt
->type
!= bp_catch_fork
6289 && bpt
->type
!= bp_catch_vfork
6290 && bpt
->type
!= bp_catch_exec
)
6293 if (b
->address
== bpt
->address
6294 && b
->section
== bpt
->section
6296 && b
->enable
!= disabled
6297 && b
->enable
!= shlib_disabled
6298 && b
->enable
!= call_disabled
)
6302 /* We should never reach this point if there is a permanent
6303 breakpoint at the same address as the one being deleted.
6304 If there is a permanent breakpoint somewhere, it should
6305 always be the only one inserted. */
6306 if (b
->enable
== permanent
)
6307 internal_error ("another breakpoint was inserted on top of "
6308 "a permanent breakpoint");
6310 if (b
->type
== bp_hardware_breakpoint
)
6311 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6313 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6317 target_terminal_ours_for_output ();
6318 warning ("Cannot insert breakpoint %d:", b
->number
);
6319 memory_error (val
, b
->address
); /* which bombs us out */
6326 free_command_lines (&bpt
->commands
);
6329 if (bpt
->cond_string
!= NULL
)
6330 free (bpt
->cond_string
);
6331 if (bpt
->addr_string
!= NULL
)
6332 free (bpt
->addr_string
);
6333 if (bpt
->exp
!= NULL
)
6335 if (bpt
->exp_string
!= NULL
)
6336 free (bpt
->exp_string
);
6337 if (bpt
->val
!= NULL
)
6338 value_free (bpt
->val
);
6339 if (bpt
->source_file
!= NULL
)
6340 free (bpt
->source_file
);
6341 if (bpt
->dll_pathname
!= NULL
)
6342 free (bpt
->dll_pathname
);
6343 if (bpt
->triggered_dll_pathname
!= NULL
)
6344 free (bpt
->triggered_dll_pathname
);
6345 if (bpt
->exec_pathname
!= NULL
)
6346 free (bpt
->exec_pathname
);
6348 /* Be sure no bpstat's are pointing at it after it's been freed. */
6349 /* FIXME, how can we find all bpstat's?
6350 We just check stop_bpstat for now. */
6351 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6352 if (bs
->breakpoint_at
== bpt
)
6354 bs
->breakpoint_at
= NULL
;
6356 /* we'd call bpstat_clear_actions, but that free's stuff and due
6357 to the multiple pointers pointing to one item with no
6358 reference counts found anywhere through out the bpstat's (how
6359 do you spell fragile?), we don't want to free things twice --
6360 better a memory leak than a corrupt malloc pool! */
6361 bs
->commands
= NULL
;
6364 /* On the chance that someone will soon try again to delete this same
6365 bp, we mark it as deleted before freeing its storage. */
6366 bpt
->type
= bp_none
;
6372 delete_command (arg
, from_tty
)
6376 struct breakpoint
*b
, *temp
;
6380 int breaks_to_delete
= 0;
6382 /* Delete all breakpoints if no argument.
6383 Do not delete internal or call-dummy breakpoints, these
6384 have to be deleted with an explicit breakpoint number argument. */
6387 if (b
->type
!= bp_call_dummy
&&
6388 b
->type
!= bp_shlib_event
&&
6389 b
->type
!= bp_thread_event
&&
6391 breaks_to_delete
= 1;
6394 /* Ask user only if there are some breakpoints to delete. */
6396 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6398 ALL_BREAKPOINTS_SAFE (b
, temp
)
6400 if (b
->type
!= bp_call_dummy
&&
6401 b
->type
!= bp_shlib_event
&&
6402 b
->type
!= bp_thread_event
&&
6404 delete_breakpoint (b
);
6409 map_breakpoint_numbers (arg
, delete_breakpoint
);
6412 /* Reset a breakpoint given it's struct breakpoint * BINT.
6413 The value we return ends up being the return value from catch_errors.
6414 Unused in this case. */
6417 breakpoint_re_set_one (bint
)
6420 /* get past catch_errs */
6421 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6424 struct symtabs_and_lines sals
;
6426 enum enable save_enable
;
6431 warning ("attempted to reset apparently deleted breakpoint #%d?",
6435 case bp_hardware_breakpoint
:
6437 case bp_catch_unload
:
6438 if (b
->addr_string
== NULL
)
6440 /* Anything without a string can't be re-set. */
6441 delete_breakpoint (b
);
6444 /* In case we have a problem, disable this breakpoint. We'll restore
6445 its status if we succeed. */
6446 save_enable
= b
->enable
;
6447 b
->enable
= disabled
;
6449 set_language (b
->language
);
6450 input_radix
= b
->input_radix
;
6452 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
6453 for (i
= 0; i
< sals
.nelts
; i
++)
6455 resolve_sal_pc (&sals
.sals
[i
]);
6457 /* Reparse conditions, they might contain references to the
6459 if (b
->cond_string
!= NULL
)
6463 free ((PTR
) b
->cond
);
6464 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
6467 /* We need to re-set the breakpoint if the address changes... */
6468 if (b
->address
!= sals
.sals
[i
].pc
6469 /* ...or new and old breakpoints both have source files, and
6470 the source file name or the line number changes... */
6471 || (b
->source_file
!= NULL
6472 && sals
.sals
[i
].symtab
!= NULL
6473 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
6474 || b
->line_number
!= sals
.sals
[i
].line
)
6476 /* ...or we switch between having a source file and not having
6478 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
6481 if (b
->source_file
!= NULL
)
6482 free (b
->source_file
);
6483 if (sals
.sals
[i
].symtab
== NULL
)
6484 b
->source_file
= NULL
;
6487 savestring (sals
.sals
[i
].symtab
->filename
,
6488 strlen (sals
.sals
[i
].symtab
->filename
));
6489 b
->line_number
= sals
.sals
[i
].line
;
6490 b
->address
= sals
.sals
[i
].pc
;
6492 /* Used to check for duplicates here, but that can
6493 cause trouble, as it doesn't check for disable
6498 /* Might be better to do this just once per breakpoint_re_set,
6499 rather than once for every breakpoint. */
6500 breakpoints_changed ();
6502 b
->section
= sals
.sals
[i
].section
;
6503 b
->enable
= save_enable
; /* Restore it, this worked. */
6506 /* Now that this is re-enabled, check_duplicates
6508 check_duplicates (b
->address
, b
->section
);
6511 free ((PTR
) sals
.sals
);
6515 case bp_hardware_watchpoint
:
6516 case bp_read_watchpoint
:
6517 case bp_access_watchpoint
:
6518 innermost_block
= NULL
;
6519 /* The issue arises of what context to evaluate this in. The
6520 same one as when it was set, but what does that mean when
6521 symbols have been re-read? We could save the filename and
6522 functionname, but if the context is more local than that, the
6523 best we could do would be something like how many levels deep
6524 and which index at that particular level, but that's going to
6525 be less stable than filenames or function names. */
6527 /* So for now, just use a global context. */
6529 free ((PTR
) b
->exp
);
6530 b
->exp
= parse_expression (b
->exp_string
);
6531 b
->exp_valid_block
= innermost_block
;
6532 mark
= value_mark ();
6534 value_free (b
->val
);
6535 b
->val
= evaluate_expression (b
->exp
);
6536 release_value (b
->val
);
6537 if (VALUE_LAZY (b
->val
))
6538 value_fetch_lazy (b
->val
);
6540 if (b
->cond_string
!= NULL
)
6544 free ((PTR
) b
->cond
);
6545 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
6547 if (b
->enable
== enabled
)
6549 value_free_to_mark (mark
);
6551 case bp_catch_catch
:
6552 case bp_catch_throw
:
6554 /* We needn't really do anything to reset these, since the mask
6555 that requests them is unaffected by e.g., new libraries being
6558 case bp_catch_vfork
:
6563 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
6565 /* Delete longjmp breakpoints, they will be reset later by
6566 breakpoint_re_set. */
6568 case bp_longjmp_resume
:
6569 delete_breakpoint (b
);
6572 /* This breakpoint is special, it's set up when the inferior
6573 starts and we really don't want to touch it. */
6574 case bp_shlib_event
:
6576 /* Like bp_shlib_event, this breakpoint type is special.
6577 Once it is set up, we do not want to touch it. */
6578 case bp_thread_event
:
6580 /* Keep temporary breakpoints, which can be encountered when we step
6581 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6582 Otherwise these should have been blown away via the cleanup chain
6583 or by breakpoint_init_inferior when we rerun the executable. */
6586 case bp_watchpoint_scope
:
6588 case bp_step_resume
:
6595 /* Re-set all breakpoints after symbols have been re-loaded. */
6597 breakpoint_re_set ()
6599 struct breakpoint
*b
, *temp
;
6600 enum language save_language
;
6601 int save_input_radix
;
6602 static char message1
[] = "Error in re-setting breakpoint %d:\n";
6603 char message
[sizeof (message1
) + 30 /* slop */ ];
6605 save_language
= current_language
->la_language
;
6606 save_input_radix
= input_radix
;
6607 ALL_BREAKPOINTS_SAFE (b
, temp
)
6609 /* Format possible error msg */
6610 sprintf (message
, message1
, b
->number
);
6611 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
6613 set_language (save_language
);
6614 input_radix
= save_input_radix
;
6616 #ifdef GET_LONGJMP_TARGET
6617 create_longjmp_breakpoint ("longjmp");
6618 create_longjmp_breakpoint ("_longjmp");
6619 create_longjmp_breakpoint ("siglongjmp");
6620 create_longjmp_breakpoint ("_siglongjmp");
6621 create_longjmp_breakpoint (NULL
);
6625 /* Took this out (temporarily at least), since it produces an extra
6626 blank line at startup. This messes up the gdbtests. -PB */
6627 /* Blank line to finish off all those mention() messages we just printed. */
6628 printf_filtered ("\n");
6632 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6633 If from_tty is nonzero, it prints a message to that effect,
6634 which ends with a period (no newline). */
6636 /* Reset the thread number of this breakpoint:
6638 - If the breakpoint is for all threads, leave it as-is.
6639 - Else, reset it to the current thread for inferior_pid. */
6641 breakpoint_re_set_thread (b
)
6642 struct breakpoint
*b
;
6644 if (b
->thread
!= -1)
6646 if (in_thread_list (inferior_pid
))
6647 b
->thread
= pid_to_thread_id (inferior_pid
);
6652 set_ignore_count (bptnum
, count
, from_tty
)
6653 int bptnum
, count
, from_tty
;
6655 register struct breakpoint
*b
;
6661 if (b
->number
== bptnum
)
6663 b
->ignore_count
= count
;
6666 else if (count
== 0)
6667 printf_filtered ("Will stop next time breakpoint %d is reached.",
6669 else if (count
== 1)
6670 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6673 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6675 breakpoints_changed ();
6679 error ("No breakpoint number %d.", bptnum
);
6682 /* Clear the ignore counts of all breakpoints. */
6684 breakpoint_clear_ignore_counts ()
6686 struct breakpoint
*b
;
6689 b
->ignore_count
= 0;
6692 /* Command to set ignore-count of breakpoint N to COUNT. */
6695 ignore_command (args
, from_tty
)
6703 error_no_arg ("a breakpoint number");
6705 num
= get_number (&p
);
6707 error ("bad breakpoint number: '%s'", args
);
6709 error ("Second argument (specified ignore-count) is missing.");
6711 set_ignore_count (num
,
6712 longest_to_int (value_as_long (parse_and_eval (p
))),
6714 printf_filtered ("\n");
6715 breakpoints_changed ();
6718 /* Call FUNCTION on each of the breakpoints
6719 whose numbers are given in ARGS. */
6722 map_breakpoint_numbers (args
, function
)
6724 void (*function
) PARAMS ((struct breakpoint
*));
6726 register char *p
= args
;
6729 register struct breakpoint
*b
, *tmp
;
6733 error_no_arg ("one or more breakpoint numbers");
6740 num
= get_number_or_range (&p1
);
6743 warning ("bad breakpoint number at or near '%s'", p
);
6747 ALL_BREAKPOINTS_SAFE (b
, tmp
)
6748 if (b
->number
== num
)
6750 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
6753 if (related_breakpoint
)
6754 function (related_breakpoint
);
6758 printf_unfiltered ("No breakpoint number %d.\n", num
);
6765 disable_breakpoint (bpt
)
6766 struct breakpoint
*bpt
;
6768 /* Never disable a watchpoint scope breakpoint; we want to
6769 hit them when we leave scope so we can delete both the
6770 watchpoint and its scope breakpoint at that time. */
6771 if (bpt
->type
== bp_watchpoint_scope
)
6774 /* You can't disable permanent breakpoints. */
6775 if (bpt
->enable
== permanent
)
6778 bpt
->enable
= disabled
;
6780 check_duplicates (bpt
->address
, bpt
->section
);
6782 if (modify_breakpoint_hook
)
6783 modify_breakpoint_hook (bpt
);
6784 breakpoint_modify_event (bpt
->number
);
6789 disable_command (args
, from_tty
)
6793 register struct breakpoint
*bpt
;
6795 ALL_BREAKPOINTS (bpt
)
6799 warning ("attempted to disable apparently deleted breakpoint #%d?",
6804 case bp_catch_unload
:
6806 case bp_catch_vfork
:
6808 case bp_catch_catch
:
6809 case bp_catch_throw
:
6810 case bp_hardware_breakpoint
:
6812 case bp_hardware_watchpoint
:
6813 case bp_read_watchpoint
:
6814 case bp_access_watchpoint
:
6815 disable_breakpoint (bpt
);
6820 map_breakpoint_numbers (args
, disable_breakpoint
);
6824 do_enable_breakpoint (bpt
, disposition
)
6825 struct breakpoint
*bpt
;
6826 enum bpdisp disposition
;
6828 struct frame_info
*save_selected_frame
= NULL
;
6829 int save_selected_frame_level
= -1;
6830 int target_resources_ok
, other_type_used
;
6833 if (bpt
->type
== bp_hardware_breakpoint
)
6836 i
= hw_breakpoint_used_count ();
6837 target_resources_ok
=
6838 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
6840 if (target_resources_ok
== 0)
6841 error ("No hardware breakpoint support in the target.");
6842 else if (target_resources_ok
< 0)
6843 error ("Hardware breakpoints used exceeds limit.");
6846 if (bpt
->enable
!= permanent
)
6847 bpt
->enable
= enabled
;
6848 bpt
->disposition
= disposition
;
6849 check_duplicates (bpt
->address
, bpt
->section
);
6850 breakpoints_changed ();
6852 if (bpt
->type
== bp_watchpoint
||
6853 bpt
->type
== bp_hardware_watchpoint
||
6854 bpt
->type
== bp_read_watchpoint
||
6855 bpt
->type
== bp_access_watchpoint
)
6857 if (bpt
->exp_valid_block
!= NULL
)
6859 struct frame_info
*fr
=
6861 /* Ensure that we have the current frame. Else, this
6862 next query may pessimistically be answered as, "No,
6863 not within current scope". */
6864 get_current_frame ();
6865 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
6869 Cannot enable watchpoint %d because the block in which its expression\n\
6870 is valid is not currently in scope.\n", bpt
->number
);
6871 bpt
->enable
= disabled
;
6875 save_selected_frame
= selected_frame
;
6876 save_selected_frame_level
= selected_frame_level
;
6877 select_frame (fr
, -1);
6880 value_free (bpt
->val
);
6881 mark
= value_mark ();
6882 bpt
->val
= evaluate_expression (bpt
->exp
);
6883 release_value (bpt
->val
);
6884 if (VALUE_LAZY (bpt
->val
))
6885 value_fetch_lazy (bpt
->val
);
6887 if (bpt
->type
== bp_hardware_watchpoint
||
6888 bpt
->type
== bp_read_watchpoint
||
6889 bpt
->type
== bp_access_watchpoint
)
6891 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
6892 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
6894 /* Hack around 'unused var' error for some targets here */
6896 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6897 bpt
->type
, i
+ mem_cnt
, other_type_used
);
6898 /* we can consider of type is bp_hardware_watchpoint, convert to
6899 bp_watchpoint in the following condition */
6900 if (target_resources_ok
< 0)
6903 Cannot enable watchpoint %d because target watch resources\n\
6904 have been allocated for other watchpoints.\n", bpt
->number
);
6905 bpt
->enable
= disabled
;
6906 value_free_to_mark (mark
);
6911 if (save_selected_frame_level
>= 0)
6912 select_and_print_frame (save_selected_frame
,
6913 save_selected_frame_level
);
6914 value_free_to_mark (mark
);
6916 if (modify_breakpoint_hook
)
6917 modify_breakpoint_hook (bpt
);
6918 breakpoint_modify_event (bpt
->number
);
6922 enable_breakpoint (bpt
)
6923 struct breakpoint
*bpt
;
6925 do_enable_breakpoint (bpt
, bpt
->disposition
);
6928 /* The enable command enables the specified breakpoints (or all defined
6929 breakpoints) so they once again become (or continue to be) effective
6930 in stopping the inferior. */
6934 enable_command (args
, from_tty
)
6938 register struct breakpoint
*bpt
;
6940 ALL_BREAKPOINTS (bpt
)
6944 warning ("attempted to enable apparently deleted breakpoint #%d?",
6949 case bp_catch_unload
:
6951 case bp_catch_vfork
:
6953 case bp_catch_catch
:
6954 case bp_catch_throw
:
6955 case bp_hardware_breakpoint
:
6957 case bp_hardware_watchpoint
:
6958 case bp_read_watchpoint
:
6959 case bp_access_watchpoint
:
6960 enable_breakpoint (bpt
);
6965 map_breakpoint_numbers (args
, enable_breakpoint
);
6969 enable_once_breakpoint (bpt
)
6970 struct breakpoint
*bpt
;
6972 do_enable_breakpoint (bpt
, disable
);
6977 enable_once_command (args
, from_tty
)
6981 map_breakpoint_numbers (args
, enable_once_breakpoint
);
6985 enable_delete_breakpoint (bpt
)
6986 struct breakpoint
*bpt
;
6988 do_enable_breakpoint (bpt
, del
);
6993 enable_delete_command (args
, from_tty
)
6997 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
7000 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
7002 struct symtabs_and_lines
7003 decode_line_spec_1 (string
, funfirstline
)
7007 struct symtabs_and_lines sals
;
7009 error ("Empty line specification.");
7010 if (default_breakpoint_valid
)
7011 sals
= decode_line_1 (&string
, funfirstline
,
7012 default_breakpoint_symtab
,
7013 default_breakpoint_line
,
7016 sals
= decode_line_1 (&string
, funfirstline
,
7017 (struct symtab
*) NULL
, 0, (char ***) NULL
);
7019 error ("Junk at end of line specification: %s", string
);
7024 _initialize_breakpoint ()
7026 struct cmd_list_element
*c
;
7028 breakpoint_chain
= 0;
7029 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
7030 before a breakpoint is set. */
7031 breakpoint_count
= 0;
7033 add_com ("ignore", class_breakpoint
, ignore_command
,
7034 "Set ignore-count of breakpoint number N to COUNT.\n\
7035 Usage is `ignore N COUNT'.");
7037 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
7039 add_com ("commands", class_breakpoint
, commands_command
,
7040 "Set commands to be executed when a breakpoint is hit.\n\
7041 Give breakpoint number as argument after \"commands\".\n\
7042 With no argument, the targeted breakpoint is the last one set.\n\
7043 The commands themselves follow starting on the next line.\n\
7044 Type a line containing \"end\" to indicate the end of them.\n\
7045 Give \"silent\" as the first line to make the breakpoint silent;\n\
7046 then no output is printed when it is hit, except what the commands print.");
7048 add_com ("condition", class_breakpoint
, condition_command
,
7049 "Specify breakpoint number N to break only if COND is true.\n\
7050 Usage is `condition N COND', where N is an integer and COND is an\n\
7051 expression to be evaluated whenever breakpoint N is reached. ");
7053 add_com ("tbreak", class_breakpoint
, tbreak_command
,
7054 "Set a temporary breakpoint. Args like \"break\" command.\n\
7055 Like \"break\" except the breakpoint is only temporary,\n\
7056 so it will be deleted when hit. Equivalent to \"break\" followed\n\
7057 by using \"enable delete\" on the breakpoint number.");
7058 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
7059 "Set temporary breakpoint at procedure exit. Either there should\n\
7060 be no argument or the argument must be a depth.\n");
7062 add_com ("hbreak", class_breakpoint
, hbreak_command
,
7063 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
7064 Like \"break\" except the breakpoint requires hardware support,\n\
7065 some target hardware may not have this support.");
7067 add_com ("thbreak", class_breakpoint
, thbreak_command
,
7068 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
7069 Like \"hbreak\" except the breakpoint is only temporary,\n\
7070 so it will be deleted when hit.");
7072 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
7073 "Enable some breakpoints.\n\
7074 Give breakpoint numbers (separated by spaces) as arguments.\n\
7075 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7076 This is used to cancel the effect of the \"disable\" command.\n\
7077 With a subcommand you can enable temporarily.",
7078 &enablelist
, "enable ", 1, &cmdlist
);
7080 add_com ("ab", class_breakpoint
, enable_command
,
7081 "Enable some breakpoints.\n\
7082 Give breakpoint numbers (separated by spaces) as arguments.\n\
7083 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7084 This is used to cancel the effect of the \"disable\" command.\n\
7085 With a subcommand you can enable temporarily.");
7087 add_com_alias ("en", "enable", class_breakpoint
, 1);
7089 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
7090 "Enable some breakpoints.\n\
7091 Give breakpoint numbers (separated by spaces) as arguments.\n\
7092 This is used to cancel the effect of the \"disable\" command.\n\
7093 May be abbreviated to simply \"enable\".\n",
7094 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
7096 add_cmd ("once", no_class
, enable_once_command
,
7097 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7098 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7101 add_cmd ("delete", no_class
, enable_delete_command
,
7102 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7103 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7106 add_cmd ("delete", no_class
, enable_delete_command
,
7107 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7108 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7111 add_cmd ("once", no_class
, enable_once_command
,
7112 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7113 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7116 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
7117 "Disable some breakpoints.\n\
7118 Arguments are breakpoint numbers with spaces in between.\n\
7119 To disable all breakpoints, give no argument.\n\
7120 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
7121 &disablelist
, "disable ", 1, &cmdlist
);
7122 add_com_alias ("dis", "disable", class_breakpoint
, 1);
7123 add_com_alias ("disa", "disable", class_breakpoint
, 1);
7125 add_com ("sb", class_breakpoint
, disable_command
,
7126 "Disable some breakpoints.\n\
7127 Arguments are breakpoint numbers with spaces in between.\n\
7128 To disable all breakpoints, give no argument.\n\
7129 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
7131 add_cmd ("breakpoints", class_alias
, disable_command
,
7132 "Disable some breakpoints.\n\
7133 Arguments are breakpoint numbers with spaces in between.\n\
7134 To disable all breakpoints, give no argument.\n\
7135 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
7136 This command may be abbreviated \"disable\".",
7139 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
7140 "Delete some breakpoints or auto-display expressions.\n\
7141 Arguments are breakpoint numbers with spaces in between.\n\
7142 To delete all breakpoints, give no argument.\n\
7144 Also a prefix command for deletion of other GDB objects.\n\
7145 The \"unset\" command is also an alias for \"delete\".",
7146 &deletelist
, "delete ", 1, &cmdlist
);
7147 add_com_alias ("d", "delete", class_breakpoint
, 1);
7149 add_com ("db", class_breakpoint
, delete_command
,
7150 "Delete some breakpoints.\n\
7151 Arguments are breakpoint numbers with spaces in between.\n\
7152 To delete all breakpoints, give no argument.\n");
7154 add_cmd ("breakpoints", class_alias
, delete_command
,
7155 "Delete some breakpoints or auto-display expressions.\n\
7156 Arguments are breakpoint numbers with spaces in between.\n\
7157 To delete all breakpoints, give no argument.\n\
7158 This command may be abbreviated \"delete\".",
7161 add_com ("clear", class_breakpoint
, clear_command
,
7162 concat ("Clear breakpoint at specified line or function.\n\
7163 Argument may be line number, function name, or \"*\" and an address.\n\
7164 If line number is specified, all breakpoints in that line are cleared.\n\
7165 If function is specified, breakpoints at beginning of function are cleared.\n\
7166 If an address is specified, breakpoints at that address are cleared.\n\n",
7167 "With no argument, clears all breakpoints in the line that the selected frame\n\
7170 See also the \"delete\" command which clears breakpoints by number.", NULL
));
7172 add_com ("break", class_breakpoint
, break_command
,
7173 concat ("Set breakpoint at specified line or function.\n\
7174 Argument may be line number, function name, or \"*\" and an address.\n\
7175 If line number is specified, break at start of code for that line.\n\
7176 If function is specified, break at start of code for that function.\n\
7177 If an address is specified, break at that exact address.\n",
7178 "With no arg, uses current execution address of selected stack frame.\n\
7179 This is useful for breaking on return to a stack frame.\n\
7181 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7183 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7184 add_com_alias ("b", "break", class_run
, 1);
7185 add_com_alias ("br", "break", class_run
, 1);
7186 add_com_alias ("bre", "break", class_run
, 1);
7187 add_com_alias ("brea", "break", class_run
, 1);
7189 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
7190 concat ("Set breakpoint at procedure exit. \n\
7191 Argument may be function name, or \"*\" and an address.\n\
7192 If function is specified, break at end of code for that function.\n\
7193 If an address is specified, break at the end of the function that contains \n\
7194 that exact address.\n",
7195 "With no arg, uses current execution address of selected stack frame.\n\
7196 This is useful for breaking on return to a stack frame.\n\
7198 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7200 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7201 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
7202 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
7203 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
7204 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
7208 add_com_alias ("ba", "break", class_breakpoint
, 1);
7209 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
7210 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
7211 "Set breakpoint at procedure exit. Either there should\n\
7212 be no argument or the argument must be a depth.\n");
7217 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
7218 "Break in function/address or break at a line in the current file.",
7219 &stoplist
, "stop ", 1, &cmdlist
);
7220 add_cmd ("in", class_breakpoint
, stopin_command
,
7221 "Break in function or address.\n", &stoplist
);
7222 add_cmd ("at", class_breakpoint
, stopat_command
,
7223 "Break at a line in the current file.\n", &stoplist
);
7224 add_com ("status", class_info
, breakpoints_info
,
7225 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7226 The \"Type\" column indicates one of:\n\
7227 \tbreakpoint - normal breakpoint\n\
7228 \twatchpoint - watchpoint\n\
7229 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7230 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7231 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7232 address and file/line number respectively.\n\n",
7233 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7234 are set to the address of the last breakpoint listed.\n\n\
7235 Convenience variable \"$bpnum\" contains the number of the last\n\
7236 breakpoint set.", NULL
));
7239 add_info ("breakpoints", breakpoints_info
,
7240 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7241 The \"Type\" column indicates one of:\n\
7242 \tbreakpoint - normal breakpoint\n\
7243 \twatchpoint - watchpoint\n\
7244 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7245 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7246 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7247 address and file/line number respectively.\n\n",
7248 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7249 are set to the address of the last breakpoint listed.\n\n\
7250 Convenience variable \"$bpnum\" contains the number of the last\n\
7251 breakpoint set.", NULL
));
7254 add_com ("lb", class_breakpoint
, breakpoints_info
,
7255 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7256 The \"Type\" column indicates one of:\n\
7257 \tbreakpoint - normal breakpoint\n\
7258 \twatchpoint - watchpoint\n\
7259 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7260 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7261 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7262 address and file/line number respectively.\n\n",
7263 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7264 are set to the address of the last breakpoint listed.\n\n\
7265 Convenience variable \"$bpnum\" contains the number of the last\n\
7266 breakpoint set.", NULL
));
7268 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
7269 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
7270 The \"Type\" column indicates one of:\n\
7271 \tbreakpoint - normal breakpoint\n\
7272 \twatchpoint - watchpoint\n\
7273 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7274 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7275 \tuntil - internal breakpoint used by the \"until\" command\n\
7276 \tfinish - internal breakpoint used by the \"finish\" command\n",
7277 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7278 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7279 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7280 address and file/line number respectively.\n\n",
7281 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7282 are set to the address of the last breakpoint listed.\n\n\
7283 Convenience variable \"$bpnum\" contains the number of the last\n\
7284 breakpoint set.", NULL
),
7285 &maintenanceinfolist
);
7287 add_com ("catch", class_breakpoint
, catch_command
,
7288 "Set catchpoints to catch events.\n\
7289 Raised signals may be caught:\n\
7290 \tcatch signal - all signals\n\
7291 \tcatch signal <signame> - a particular signal\n\
7292 Raised exceptions may be caught:\n\
7293 \tcatch throw - all exceptions, when thrown\n\
7294 \tcatch throw <exceptname> - a particular exception, when thrown\n\
7295 \tcatch catch - all exceptions, when caught\n\
7296 \tcatch catch <exceptname> - a particular exception, when caught\n\
7297 Thread or process events may be caught:\n\
7298 \tcatch thread_start - any threads, just after creation\n\
7299 \tcatch thread_exit - any threads, just before expiration\n\
7300 \tcatch thread_join - any threads, just after joins\n\
7301 Process events may be caught:\n\
7302 \tcatch start - any processes, just after creation\n\
7303 \tcatch exit - any processes, just before expiration\n\
7304 \tcatch fork - calls to fork()\n\
7305 \tcatch vfork - calls to vfork()\n\
7306 \tcatch exec - calls to exec()\n\
7307 Dynamically-linked library events may be caught:\n\
7308 \tcatch load - loads of any library\n\
7309 \tcatch load <libname> - loads of a particular library\n\
7310 \tcatch unload - unloads of any library\n\
7311 \tcatch unload <libname> - unloads of a particular library\n\
7312 The act of your program's execution stopping may also be caught:\n\
7314 C++ exceptions may be caught:\n\
7315 \tcatch throw - all exceptions, when thrown\n\
7316 \tcatch catch - all exceptions, when caught\n\
7318 Do \"help set follow-fork-mode\" for info on debugging your program\n\
7319 after a fork or vfork is caught.\n\n\
7320 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
7322 add_com ("tcatch", class_breakpoint
, tcatch_command
,
7323 "Set temporary catchpoints to catch events.\n\
7324 Args like \"catch\" command.\n\
7325 Like \"catch\" except the catchpoint is only temporary,\n\
7326 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7327 by using \"enable delete\" on the catchpoint number.");
7329 add_com ("watch", class_breakpoint
, watch_command
,
7330 "Set a watchpoint for an expression.\n\
7331 A watchpoint stops execution of your program whenever the value of\n\
7332 an expression changes.");
7334 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7335 "Set a read watchpoint for an expression.\n\
7336 A watchpoint stops execution of your program whenever the value of\n\
7337 an expression is read.");
7339 add_com ("awatch", class_breakpoint
, awatch_command
,
7340 "Set a watchpoint for an expression.\n\
7341 A watchpoint stops execution of your program whenever the value of\n\
7342 an expression is either read or written.");
7344 add_info ("watchpoints", breakpoints_info
,
7345 "Synonym for ``info breakpoints''.");
7348 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7349 (char *) &can_use_hw_watchpoints
,
7350 "Set debugger's willingness to use watchpoint hardware.\n\
7351 If zero, gdb will not use hardware for new watchpoints, even if\n\
7352 such is available. (However, any hardware watchpoints that were\n\
7353 created before setting this to nonzero, will continue to use watchpoint\n\
7356 add_show_from_set (c
, &showlist
);
7358 can_use_hw_watchpoints
= 1;