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"
46 #include "gdb-events.h"
48 /* Prototypes for local functions. */
50 static void until_break_command_continuation (struct continuation_arg
*arg
);
53 catch_command_1
PARAMS ((char *, int, int));
56 enable_delete_command
PARAMS ((char *, int));
59 enable_delete_breakpoint
PARAMS ((struct breakpoint
*));
62 enable_once_command
PARAMS ((char *, int));
65 enable_once_breakpoint
PARAMS ((struct breakpoint
*));
68 disable_command
PARAMS ((char *, int));
71 enable_command
PARAMS ((char *, int));
74 map_breakpoint_numbers
PARAMS ((char *, void (*)(struct breakpoint
*)));
77 ignore_command
PARAMS ((char *, int));
79 static int breakpoint_re_set_one
PARAMS ((PTR
));
82 clear_command
PARAMS ((char *, int));
85 catch_command
PARAMS ((char *, int));
88 handle_gnu_4_16_catch_command
PARAMS ((char *, int, int));
90 static struct symtabs_and_lines
91 get_catch_sals
PARAMS ((int));
94 watch_command
PARAMS ((char *, int));
97 can_use_hardware_watchpoint
PARAMS ((struct value
*));
99 static void break_at_finish_command
PARAMS ((char *, int));
100 static void break_at_finish_at_depth_command
PARAMS ((char *, int));
103 tbreak_command
PARAMS ((char *, int));
105 static void tbreak_at_finish_command
PARAMS ((char *, int));
108 break_command_1
PARAMS ((char *, int, int));
111 mention
PARAMS ((struct breakpoint
*));
114 set_raw_breakpoint
PARAMS ((struct symtab_and_line
));
117 check_duplicates
PARAMS ((CORE_ADDR
, asection
*));
120 describe_other_breakpoints
PARAMS ((CORE_ADDR
, asection
*));
123 breakpoints_info
PARAMS ((char *, int));
126 breakpoint_1
PARAMS ((int, int));
129 bpstat_alloc
PARAMS ((struct breakpoint
*, bpstat
));
131 static int breakpoint_cond_eval
PARAMS ((PTR
));
134 cleanup_executing_breakpoints
PARAMS ((PTR
));
137 commands_command
PARAMS ((char *, int));
140 condition_command
PARAMS ((char *, int));
143 get_number_trailer
PARAMS ((char **, int));
146 set_breakpoint_count
PARAMS ((int));
149 static struct breakpoint
*
150 create_temp_exception_breakpoint
PARAMS ((CORE_ADDR
));
161 remove_breakpoint
PARAMS ((struct breakpoint
*, insertion_state_t
));
163 static enum print_stop_action print_it_typical
PARAMS ((bpstat
));
165 static enum print_stop_action
print_bp_stop_message (bpstat bs
);
169 enum exception_event_kind kind
;
172 args_for_catchpoint_enable
;
174 static int watchpoint_check
PARAMS ((PTR
));
176 static int cover_target_enable_exception_callback
PARAMS ((PTR
));
178 static void maintenance_info_breakpoints
PARAMS ((char *, int));
180 #ifdef GET_LONGJMP_TARGET
181 static void create_longjmp_breakpoint
PARAMS ((char *));
184 static int hw_breakpoint_used_count
PARAMS ((void));
186 static int hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
188 static void hbreak_command
PARAMS ((char *, int));
190 static void thbreak_command
PARAMS ((char *, int));
192 static void watch_command_1
PARAMS ((char *, int, int));
194 static void rwatch_command
PARAMS ((char *, int));
196 static void awatch_command
PARAMS ((char *, int));
198 static void do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
200 static void solib_load_unload_1
PARAMS ((char *hookname
,
204 enum bptype bp_kind
));
206 static void create_fork_vfork_event_catchpoint
PARAMS ((int tempflag
,
208 enum bptype bp_kind
));
210 static void break_at_finish_at_depth_command_1
PARAMS ((char *arg
,
214 static void break_at_finish_command_1
PARAMS ((char *arg
,
218 static void stop_command
PARAMS ((char *arg
, int from_tty
));
220 static void stopin_command
PARAMS ((char *arg
, int from_tty
));
222 static void stopat_command
PARAMS ((char *arg
, int from_tty
));
224 static char *ep_find_event_name_end
PARAMS ((char *arg
));
226 static char *ep_parse_optional_if_clause
PARAMS ((char **arg
));
228 static char *ep_parse_optional_filename
PARAMS ((char **arg
));
230 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
231 static void catch_exec_command_1
PARAMS ((char *arg
, int tempflag
,
235 static void create_exception_catchpoint
236 PARAMS ((int tempflag
, char *cond_string
,
237 enum exception_event_kind ex_event
,
238 struct symtab_and_line
* sal
));
240 static void catch_exception_command_1
241 PARAMS ((enum exception_event_kind ex_event
,
242 char *arg
, int tempflag
, int from_tty
));
244 static void tcatch_command
PARAMS ((char *arg
, int from_tty
));
246 static void ep_skip_leading_whitespace
PARAMS ((char **s
));
248 /* Prototypes for exported functions. */
251 awatch_command
PARAMS ((char *, int));
254 do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
256 /* If FALSE, gdb will not use hardware support for watchpoints, even
257 if such is available. */
258 static int can_use_hw_watchpoints
;
260 void _initialize_breakpoint
PARAMS ((void));
262 void set_breakpoint_count
PARAMS ((int));
264 extern int addressprint
; /* Print machine addresses? */
266 static int internal_breakpoint_number
= -1;
268 /* Are we executing breakpoint commands? */
269 static int executing_breakpoint_commands
;
271 /* Walk the following statement or block through all breakpoints.
272 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
275 #define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
277 #define ALL_BREAKPOINTS_SAFE(B,TMP) \
278 for (B = breakpoint_chain; \
279 B ? (TMP=B->next, 1): 0; \
282 /* True if SHIFT_INST_REGS defined, false otherwise. */
284 int must_shift_inst_regs
=
285 #if defined(SHIFT_INST_REGS)
292 /* True if breakpoint hit counts should be displayed in breakpoint info. */
294 int show_breakpoint_hit_counts
= 1;
296 /* Chain of all breakpoints defined. */
298 struct breakpoint
*breakpoint_chain
;
300 /* Number of last breakpoint made. */
302 int breakpoint_count
;
304 /* Pointer to current exception event record */
305 static struct exception_event_record
*current_exception_event
;
307 /* Indicator of whether exception catchpoints should be nuked
308 between runs of a program */
309 int exception_catchpoints_are_fragile
= 0;
311 /* Indicator of when exception catchpoints set-up should be
312 reinitialized -- e.g. when program is re-run */
313 int exception_support_initialized
= 0;
315 /* This function returns a pointer to the string representation of the
316 pathname of the dynamically-linked library that has just been
319 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
320 or undefined results are guaranteed.
322 This string's contents are only valid immediately after the
323 inferior has stopped in the dynamic linker hook, and becomes
324 invalid as soon as the inferior is continued. Clients should make
325 a copy of this string if they wish to continue the inferior and
326 then access the string. */
328 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
329 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
332 /* This function returns a pointer to the string representation of the
333 pathname of the dynamically-linked library that has just been
336 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
337 TRUE, or undefined results are guaranteed.
339 This string's contents are only valid immediately after the
340 inferior has stopped in the dynamic linker hook, and becomes
341 invalid as soon as the inferior is continued. Clients should make
342 a copy of this string if they wish to continue the inferior and
343 then access the string. */
345 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
346 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
349 /* This function is called by the "catch load" command. It allows the
350 debugger to be notified by the dynamic linker when a specified
351 library file (or any library file, if filename is NULL) is loaded. */
353 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
354 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
355 error ("catch of library loads not yet implemented on this platform")
358 /* This function is called by the "catch unload" command. It allows
359 the debugger to be notified by the dynamic linker when a specified
360 library file (or any library file, if filename is NULL) is
363 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
364 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
365 error ("catch of library unloads not yet implemented on this platform")
368 /* Set breakpoint count to NUM. */
371 set_breakpoint_count (num
)
374 breakpoint_count
= num
;
375 set_internalvar (lookup_internalvar ("bpnum"),
376 value_from_longest (builtin_type_int
, (LONGEST
) num
));
379 /* Used in run_command to zero the hit count when a new run starts. */
382 clear_breakpoint_hit_counts ()
384 struct breakpoint
*b
;
390 /* Default address, symtab and line to put a breakpoint at
391 for "break" command with no arg.
392 if default_breakpoint_valid is zero, the other three are
393 not valid, and "break" with no arg is an error.
395 This set by print_stack_frame, which calls set_default_breakpoint. */
397 int default_breakpoint_valid
;
398 CORE_ADDR default_breakpoint_address
;
399 struct symtab
*default_breakpoint_symtab
;
400 int default_breakpoint_line
;
402 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
403 Advance *PP after the string and any trailing whitespace.
405 Currently the string can either be a number or "$" followed by the name
406 of a convenience variable. Making it an expression wouldn't work well
407 for map_breakpoint_numbers (e.g. "4 + 5 + 6").
409 TRAILER is a character which can be found after the number; most
410 commonly this is `-'. If you don't want a trailer, use \0. */
412 get_number_trailer (pp
, trailer
)
416 int retval
= 0; /* default */
420 /* Empty line means refer to the last breakpoint. */
421 return breakpoint_count
;
424 /* Make a copy of the name, so we can null-terminate it
425 to pass to lookup_internalvar(). */
430 while (isalnum (*p
) || *p
== '_')
432 varname
= (char *) alloca (p
- start
+ 1);
433 strncpy (varname
, start
, p
- start
);
434 varname
[p
- start
] = '\0';
435 val
= value_of_internalvar (lookup_internalvar (varname
));
436 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_INT
)
437 retval
= (int) value_as_long (val
);
440 printf_filtered ("Convenience variable must have integer value.\n");
448 while (*p
>= '0' && *p
<= '9')
451 /* There is no number here. (e.g. "cond a == b"). */
453 /* Skip non-numeric token */
454 while (*p
&& !isspace((int) *p
))
456 /* Return zero, which caller must interpret as error. */
462 if (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
464 /* Trailing junk: return 0 and let caller print error msg. */
465 while (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
476 /* Like get_number_trailer, but don't allow a trailer. */
481 return get_number_trailer (pp
, '\0');
484 /* Parse a number or a range.
485 * A number will be of the form handled by get_number.
486 * A range will be of the form <number1> - <number2>, and
487 * will represent all the integers between number1 and number2,
490 * While processing a range, this fuction is called iteratively;
491 * At each call it will return the next value in the range.
493 * At the beginning of parsing a range, the char pointer PP will
494 * be advanced past <number1> and left pointing at the '-' token.
495 * Subsequent calls will not advance the pointer until the range
496 * is completed. The call that completes the range will advance
497 * pointer PP past <number2>.
501 get_number_or_range (pp
)
504 static int last_retval
, end_value
;
505 static char *end_ptr
;
506 static int in_range
= 0;
510 /* Default case: pp is pointing either to a solo number,
511 or to the first number of a range. */
512 last_retval
= get_number_trailer (pp
, '-');
517 /* This is the start of a range (<number1> - <number2>).
518 Skip the '-', parse and remember the second number,
519 and also remember the end of the final token. */
523 while (isspace ((int) *end_ptr
))
524 end_ptr
++; /* skip white space */
525 end_value
= get_number (temp
);
526 if (end_value
< last_retval
)
528 error ("inverted range");
530 else if (end_value
== last_retval
)
532 /* degenerate range (number1 == number2). Advance the
533 token pointer so that the range will be treated as a
542 error ("negative value");
545 /* pp points to the '-' that betokens a range. All
546 number-parsing has already been done. Return the next
547 integer value (one greater than the saved previous value).
548 Do not advance the token pointer 'pp' until the end of range
551 if (++last_retval
== end_value
)
553 /* End of range reached; advance token pointer. */
563 /* condition N EXP -- set break condition of breakpoint N to EXP. */
566 condition_command (arg
, from_tty
)
570 register struct breakpoint
*b
;
575 error_no_arg ("breakpoint number");
578 bnum
= get_number (&p
);
580 error ("Bad breakpoint argument: '%s'", arg
);
583 if (b
->number
== bnum
)
587 free ((PTR
) b
->cond
);
590 if (b
->cond_string
!= NULL
)
591 free ((PTR
) b
->cond_string
);
596 b
->cond_string
= NULL
;
598 printf_filtered ("Breakpoint %d now unconditional.\n", bnum
);
603 /* I don't know if it matters whether this is the string the user
604 typed in or the decompiled expression. */
605 b
->cond_string
= savestring (arg
, strlen (arg
));
606 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->address
), 0);
608 error ("Junk at end of expression");
610 breakpoints_changed ();
614 error ("No breakpoint number %d.", bnum
);
619 commands_command (arg
, from_tty
)
623 register struct breakpoint
*b
;
626 struct command_line
*l
;
628 /* If we allowed this, we would have problems with when to
629 free the storage, if we change the commands currently
632 if (executing_breakpoint_commands
)
633 error ("Can't use the \"commands\" command among a breakpoint's commands.");
636 bnum
= get_number (&p
);
639 error ("Unexpected extra arguments following breakpoint number.");
642 if (b
->number
== bnum
)
646 "Type commands for when breakpoint %d is hit, one per line.",
648 l
= read_command_lines (tmpbuf
, from_tty
);
649 free_command_lines (&b
->commands
);
651 breakpoints_changed ();
654 error ("No breakpoint number %d.", bnum
);
657 /* Like target_read_memory() but if breakpoints are inserted, return
658 the shadow contents instead of the breakpoints themselves.
660 Read "memory data" from whatever target or inferior we have.
661 Returns zero if successful, errno value if not. EIO is used
662 for address out of bounds. If breakpoints are inserted, returns
663 shadow contents, not the breakpoints themselves. From breakpoint.c. */
666 read_memory_nobpt (memaddr
, myaddr
, len
)
672 struct breakpoint
*b
;
673 CORE_ADDR bp_addr
= 0;
676 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
677 /* No breakpoints on this machine. */
678 return target_read_memory (memaddr
, myaddr
, len
);
682 if (b
->type
== bp_none
)
683 warning ("reading through apparently deleted breakpoint #%d?",
686 /* memory breakpoint? */
687 if (b
->type
== bp_watchpoint
688 || b
->type
== bp_hardware_watchpoint
689 || b
->type
== bp_read_watchpoint
690 || b
->type
== bp_access_watchpoint
)
695 /* Addresses and length of the part of the breakpoint that
697 /* XXXX The m68k, sh and h8300 have different local and remote
698 breakpoint values. BREAKPOINT_FROM_PC still manages to
699 correctly determine the breakpoints memory address and size
700 for these targets. */
701 bp_addr
= b
->address
;
703 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
708 if (bp_addr
+ bp_size
<= memaddr
)
709 /* The breakpoint is entirely before the chunk of memory we
712 if (bp_addr
>= memaddr
+ len
)
713 /* The breakpoint is entirely after the chunk of memory we are
716 /* Copy the breakpoint from the shadow contents, and recurse for
717 the things before and after. */
719 /* Offset within shadow_contents. */
722 if (bp_addr
< memaddr
)
724 /* Only copy the second part of the breakpoint. */
725 bp_size
-= memaddr
- bp_addr
;
726 bptoffset
= memaddr
- bp_addr
;
730 if (bp_addr
+ bp_size
> memaddr
+ len
)
732 /* Only copy the first part of the breakpoint. */
733 bp_size
-= (bp_addr
+ bp_size
) - (memaddr
+ len
);
736 memcpy (myaddr
+ bp_addr
- memaddr
,
737 b
->shadow_contents
+ bptoffset
, bp_size
);
739 if (bp_addr
> memaddr
)
741 /* Copy the section of memory before the breakpoint. */
742 status
= read_memory_nobpt (memaddr
, myaddr
, bp_addr
- memaddr
);
747 if (bp_addr
+ bp_size
< memaddr
+ len
)
749 /* Copy the section of memory after the breakpoint. */
750 status
= read_memory_nobpt
752 myaddr
+ bp_addr
+ bp_size
- memaddr
,
753 memaddr
+ len
- (bp_addr
+ bp_size
));
760 /* Nothing overlaps. Just call read_memory_noerr. */
761 return target_read_memory (memaddr
, myaddr
, len
);
765 /* insert_breakpoints is used when starting or continuing the program.
766 remove_breakpoints is used when the program stops.
767 Both return zero if successful,
768 or an `errno' value if could not write the inferior. */
771 insert_breakpoints ()
773 register struct breakpoint
*b
, *temp
;
774 int return_val
= 0; /* return success code. */
776 int disabled_breaks
= 0;
778 static char message1
[] = "Error inserting catchpoint %d:\n";
779 static char message
[sizeof (message1
) + 30];
782 ALL_BREAKPOINTS_SAFE (b
, temp
)
784 if (b
->enable
== permanent
)
785 /* Permanent breakpoints cannot be inserted or removed. */
787 else if (b
->type
!= bp_watchpoint
788 && b
->type
!= bp_hardware_watchpoint
789 && b
->type
!= bp_read_watchpoint
790 && b
->type
!= bp_access_watchpoint
791 && b
->type
!= bp_catch_fork
792 && b
->type
!= bp_catch_vfork
793 && b
->type
!= bp_catch_exec
794 && b
->type
!= bp_catch_throw
795 && b
->type
!= bp_catch_catch
796 && b
->enable
!= disabled
797 && b
->enable
!= shlib_disabled
798 && b
->enable
!= call_disabled
802 if (b
->type
== bp_hardware_breakpoint
)
803 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
806 /* Check to see if breakpoint is in an overlay section;
807 if so, we should set the breakpoint at the LMA address.
808 Only if the section is currently mapped should we ALSO
809 set a break at the VMA address. */
810 if (overlay_debugging
&& b
->section
&&
811 section_is_overlay (b
->section
))
815 addr
= overlay_unmapped_address (b
->address
, b
->section
);
816 val
= target_insert_breakpoint (addr
, b
->shadow_contents
);
817 /* This would be the time to check val, to see if the
818 breakpoint write to the load address succeeded.
819 However, this might be an ordinary occurrance, eg. if
820 the unmapped overlay is in ROM. */
821 val
= 0; /* in case unmapped address failed */
822 if (section_is_mapped (b
->section
))
823 val
= target_insert_breakpoint (b
->address
,
826 else /* ordinary (non-overlay) address */
827 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
831 /* Can't set the breakpoint. */
832 #if defined (DISABLE_UNSETTABLE_BREAK)
833 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
835 /* See also: disable_breakpoints_in_shlibs. */
837 b
->enable
= shlib_disabled
;
838 if (!disabled_breaks
)
840 target_terminal_ours_for_output ();
841 warning ("Cannot insert breakpoint %d:", b
->number
);
842 warning ("Temporarily disabling shared library breakpoints:");
845 warning ("breakpoint #%d ", b
->number
);
850 target_terminal_ours_for_output ();
851 warning ("Cannot insert breakpoint %d:", b
->number
);
852 #ifdef ONE_PROCESS_WRITETEXT
853 warning ("The same program may be running in another process.");
855 memory_error (val
, b
->address
); /* which bombs us out */
862 return_val
= val
; /* remember failure */
864 else if (ep_is_exception_catchpoint (b
)
865 && b
->enable
!= disabled
866 && b
->enable
!= shlib_disabled
867 && b
->enable
!= call_disabled
872 /* If we get here, we must have a callback mechanism for exception
873 events -- with g++ style embedded label support, we insert
874 ordinary breakpoints and not catchpoints. */
875 /* Format possible error message */
876 sprintf (message
, message1
, b
->number
);
878 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
881 /* Couldn't set breakpoint for some reason */
882 target_terminal_ours_for_output ();
883 warning ("Cannot insert catchpoint %d; disabling it.",
885 b
->enable
= disabled
;
889 /* Bp set, now make sure callbacks are enabled */
891 args_for_catchpoint_enable args
;
892 args
.kind
= b
->type
== bp_catch_catch
?
893 EX_EVENT_CATCH
: EX_EVENT_THROW
;
895 val
= catch_errors (cover_target_enable_exception_callback
,
897 message
, RETURN_MASK_ALL
);
898 if (val
!= 0 && val
!= -1)
902 /* Check if something went wrong; val == 0 can be ignored */
905 /* something went wrong */
906 target_terminal_ours_for_output ();
907 warning ("Cannot insert catchpoint %d; disabling it.",
909 b
->enable
= disabled
;
914 return_val
= val
; /* remember failure */
917 else if ((b
->type
== bp_hardware_watchpoint
||
918 b
->type
== bp_read_watchpoint
||
919 b
->type
== bp_access_watchpoint
)
920 && b
->enable
== enabled
924 struct frame_info
*saved_frame
;
925 int saved_level
, within_current_scope
;
926 value_ptr mark
= value_mark ();
929 /* Save the current frame and level so we can restore it after
930 evaluating the watchpoint expression on its own frame. */
931 saved_frame
= selected_frame
;
932 saved_level
= selected_frame_level
;
934 /* Determine if the watchpoint is within scope. */
935 if (b
->exp_valid_block
== NULL
)
936 within_current_scope
= 1;
939 struct frame_info
*fi
;
941 /* There might be no current frame at this moment if we are
942 resuming from a step over a breakpoint.
943 Set up current frame before trying to find the watchpoint
945 get_current_frame ();
946 fi
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
947 within_current_scope
= (fi
!= NULL
);
948 if (within_current_scope
)
949 select_frame (fi
, -1);
952 if (within_current_scope
)
954 /* Evaluate the expression and cut the chain of values
955 produced off from the value chain.
957 Make sure the value returned isn't lazy; we use
958 laziness to determine what memory GDB actually needed
959 in order to compute the value of the expression. */
960 v
= evaluate_expression (b
->exp
);
962 value_release_to_mark (mark
);
967 /* Look at each value on the value chain. */
968 for (; v
; v
= v
->next
)
970 /* If it's a memory location, and GDB actually needed
971 its contents to evaluate the expression, then we
973 if (VALUE_LVAL (v
) == lval_memory
979 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
980 len
= TYPE_LENGTH (VALUE_TYPE (v
));
982 if (b
->type
== bp_read_watchpoint
)
984 else if (b
->type
== bp_access_watchpoint
)
987 val
= target_insert_watchpoint (addr
, len
, type
);
996 /* Failure to insert a watchpoint on any memory value in the
997 value chain brings us here. */
1000 remove_breakpoint (b
, mark_uninserted
);
1001 warning ("Could not insert hardware watchpoint %d.",
1008 printf_filtered ("Hardware watchpoint %d deleted", b
->number
);
1009 printf_filtered ("because the program has left the block \n");
1010 printf_filtered ("in which its expression is valid.\n");
1011 if (b
->related_breakpoint
)
1012 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1013 b
->disposition
= del_at_next_stop
;
1016 /* Restore the frame and level. */
1017 if ((saved_frame
!= selected_frame
) ||
1018 (saved_level
!= selected_frame_level
))
1019 select_and_print_frame (saved_frame
, saved_level
);
1022 return_val
= val
; /* remember failure */
1024 else if ((b
->type
== bp_catch_fork
1025 || b
->type
== bp_catch_vfork
1026 || b
->type
== bp_catch_exec
)
1027 && b
->enable
== enabled
1035 val
= target_insert_fork_catchpoint (inferior_pid
);
1037 case bp_catch_vfork
:
1038 val
= target_insert_vfork_catchpoint (inferior_pid
);
1041 val
= target_insert_exec_catchpoint (inferior_pid
);
1044 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1049 target_terminal_ours_for_output ();
1050 warning ("Cannot insert catchpoint %d.", b
->number
);
1056 return_val
= val
; /* remember failure */
1065 remove_breakpoints ()
1067 register struct breakpoint
*b
;
1074 val
= remove_breakpoint (b
, mark_uninserted
);
1083 reattach_breakpoints (pid
)
1086 register struct breakpoint
*b
;
1088 int saved_inferior_pid
= inferior_pid
;
1090 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1091 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1096 remove_breakpoint (b
, mark_inserted
);
1097 if (b
->type
== bp_hardware_breakpoint
)
1098 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
1100 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
1103 inferior_pid
= saved_inferior_pid
;
1108 inferior_pid
= saved_inferior_pid
;
1113 update_breakpoints_after_exec ()
1115 struct breakpoint
*b
;
1116 struct breakpoint
*temp
;
1118 /* Doing this first prevents the badness of having delete_breakpoint()
1119 write a breakpoint's current "shadow contents" to lift the bp. That
1120 shadow is NOT valid after an exec()! */
1121 mark_breakpoints_out ();
1123 ALL_BREAKPOINTS_SAFE (b
, temp
)
1125 /* Solib breakpoints must be explicitly reset after an exec(). */
1126 if (b
->type
== bp_shlib_event
)
1128 delete_breakpoint (b
);
1132 /* Thread event breakpoints must be set anew after an exec(). */
1133 if (b
->type
== bp_thread_event
)
1135 delete_breakpoint (b
);
1139 /* Step-resume breakpoints are meaningless after an exec(). */
1140 if (b
->type
== bp_step_resume
)
1142 delete_breakpoint (b
);
1146 /* Ditto the sigtramp handler breakpoints. */
1147 if (b
->type
== bp_through_sigtramp
)
1149 delete_breakpoint (b
);
1153 /* Ditto the exception-handling catchpoints. */
1154 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1156 delete_breakpoint (b
);
1160 /* Don't delete an exec catchpoint, because else the inferior
1161 won't stop when it ought!
1163 Similarly, we probably ought to keep vfork catchpoints, 'cause
1164 on this target, we may not be able to stop when the vfork is
1165 seen, but only when the subsequent exec is seen. (And because
1166 deleting fork catchpoints here but not vfork catchpoints will
1167 seem mysterious to users, keep those too.)
1169 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1170 target address field, if any, is sufficient to have it be reset
1171 automagically. Certainly on HP-UX that's true. */
1172 if ((b
->type
== bp_catch_exec
) ||
1173 (b
->type
== bp_catch_vfork
) ||
1174 (b
->type
== bp_catch_fork
))
1176 b
->address
= (CORE_ADDR
) NULL
;
1180 /* bp_finish is a special case. The only way we ought to be able
1181 to see one of these when an exec() has happened, is if the user
1182 caught a vfork, and then said "finish". Ordinarily a finish just
1183 carries them to the call-site of the current callee, by setting
1184 a temporary bp there and resuming. But in this case, the finish
1185 will carry them entirely through the vfork & exec.
1187 We don't want to allow a bp_finish to remain inserted now. But
1188 we can't safely delete it, 'cause finish_command has a handle to
1189 the bp on a bpstat, and will later want to delete it. There's a
1190 chance (and I've seen it happen) that if we delete the bp_finish
1191 here, that its storage will get reused by the time finish_command
1192 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1193 We really must allow finish_command to delete a bp_finish.
1195 In the absense of a general solution for the "how do we know
1196 it's safe to delete something others may have handles to?"
1197 problem, what we'll do here is just uninsert the bp_finish, and
1198 let finish_command delete it.
1200 (We know the bp_finish is "doomed" in the sense that it's
1201 momentary, and will be deleted as soon as finish_command sees
1202 the inferior stopped. So it doesn't matter that the bp's
1203 address is probably bogus in the new a.out, unlike e.g., the
1204 solib breakpoints.) */
1206 if (b
->type
== bp_finish
)
1211 /* Without a symbolic address, we have little hope of the
1212 pre-exec() address meaning the same thing in the post-exec()
1214 if (b
->addr_string
== NULL
)
1216 delete_breakpoint (b
);
1220 /* If this breakpoint has survived the above battery of checks, then
1221 it must have a symbolic address. Be sure that it gets reevaluated
1222 to a target address, rather than reusing the old evaluation. */
1223 b
->address
= (CORE_ADDR
) NULL
;
1228 detach_breakpoints (pid
)
1231 register struct breakpoint
*b
;
1233 int saved_inferior_pid
= inferior_pid
;
1235 if (pid
== inferior_pid
)
1236 error ("Cannot detach breakpoints of inferior_pid");
1238 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1239 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1244 val
= remove_breakpoint (b
, mark_inserted
);
1247 inferior_pid
= saved_inferior_pid
;
1252 inferior_pid
= saved_inferior_pid
;
1257 remove_breakpoint (b
, is
)
1258 struct breakpoint
*b
;
1259 insertion_state_t is
;
1263 if (b
->enable
== permanent
)
1264 /* Permanent breakpoints cannot be inserted or removed. */
1267 if (b
->type
== bp_none
)
1268 warning ("attempted to remove apparently deleted breakpoint #%d?",
1271 if (b
->type
!= bp_watchpoint
1272 && b
->type
!= bp_hardware_watchpoint
1273 && b
->type
!= bp_read_watchpoint
1274 && b
->type
!= bp_access_watchpoint
1275 && b
->type
!= bp_catch_fork
1276 && b
->type
!= bp_catch_vfork
1277 && b
->type
!= bp_catch_exec
1278 && b
->type
!= bp_catch_catch
1279 && b
->type
!= bp_catch_throw
)
1281 if (b
->type
== bp_hardware_breakpoint
)
1282 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1285 /* Check to see if breakpoint is in an overlay section;
1286 if so, we should remove the breakpoint at the LMA address.
1287 If that is not equal to the raw address, then we should
1288 presumable remove the breakpoint there as well. */
1289 if (overlay_debugging
&& b
->section
&&
1290 section_is_overlay (b
->section
))
1294 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1295 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1296 /* This would be the time to check val, to see if the
1297 shadow breakpoint write to the load address succeeded.
1298 However, this might be an ordinary occurrance, eg. if
1299 the unmapped overlay is in ROM. */
1300 val
= 0; /* in case unmapped address failed */
1301 if (section_is_mapped (b
->section
))
1302 val
= target_remove_breakpoint (b
->address
,
1303 b
->shadow_contents
);
1305 else /* ordinary (non-overlay) address */
1306 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1310 b
->inserted
= (is
== mark_inserted
);
1312 else if ((b
->type
== bp_hardware_watchpoint
||
1313 b
->type
== bp_read_watchpoint
||
1314 b
->type
== bp_access_watchpoint
)
1315 && b
->enable
== enabled
1320 b
->inserted
= (is
== mark_inserted
);
1321 /* Walk down the saved value chain. */
1322 for (v
= b
->val_chain
; v
; v
= v
->next
)
1324 /* For each memory reference remove the watchpoint
1326 if (VALUE_LVAL (v
) == lval_memory
1327 && ! VALUE_LAZY (v
))
1332 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1333 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1335 if (b
->type
== bp_read_watchpoint
)
1337 else if (b
->type
== bp_access_watchpoint
)
1340 val
= target_remove_watchpoint (addr
, len
, type
);
1346 /* Failure to remove any of the hardware watchpoints comes here. */
1347 if ((is
== mark_uninserted
) && (b
->inserted
))
1348 warning ("Could not remove hardware watchpoint %d.",
1351 /* Free the saved value chain. We will construct a new one
1352 the next time the watchpoint is inserted. */
1353 for (v
= b
->val_chain
; v
; v
= n
)
1358 b
->val_chain
= NULL
;
1360 else if ((b
->type
== bp_catch_fork
||
1361 b
->type
== bp_catch_vfork
||
1362 b
->type
== bp_catch_exec
)
1363 && b
->enable
== enabled
1370 val
= target_remove_fork_catchpoint (inferior_pid
);
1372 case bp_catch_vfork
:
1373 val
= target_remove_vfork_catchpoint (inferior_pid
);
1376 val
= target_remove_exec_catchpoint (inferior_pid
);
1379 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1384 b
->inserted
= (is
== mark_inserted
);
1386 else if ((b
->type
== bp_catch_catch
||
1387 b
->type
== bp_catch_throw
)
1388 && b
->enable
== enabled
1392 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1395 b
->inserted
= (is
== mark_inserted
);
1397 else if (ep_is_exception_catchpoint (b
)
1398 && b
->inserted
/* sometimes previous insert doesn't happen */
1399 && b
->enable
== enabled
1403 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1407 b
->inserted
= (is
== mark_inserted
);
1413 /* Clear the "inserted" flag in all breakpoints. */
1416 mark_breakpoints_out ()
1418 register struct breakpoint
*b
;
1424 /* Clear the "inserted" flag in all breakpoints and delete any
1425 breakpoints which should go away between runs of the program.
1427 Plus other such housekeeping that has to be done for breakpoints
1430 Note: this function gets called at the end of a run (by
1431 generic_mourn_inferior) and when a run begins (by
1432 init_wait_for_inferior). */
1437 breakpoint_init_inferior (context
)
1438 enum inf_context context
;
1440 register struct breakpoint
*b
, *temp
;
1441 static int warning_needed
= 0;
1443 ALL_BREAKPOINTS_SAFE (b
, temp
)
1450 case bp_watchpoint_scope
:
1452 /* If the call dummy breakpoint is at the entry point it will
1453 cause problems when the inferior is rerun, so we better
1456 Also get rid of scope breakpoints. */
1457 delete_breakpoint (b
);
1461 case bp_hardware_watchpoint
:
1462 case bp_read_watchpoint
:
1463 case bp_access_watchpoint
:
1465 /* Likewise for watchpoints on local expressions. */
1466 if (b
->exp_valid_block
!= NULL
)
1467 delete_breakpoint (b
);
1470 /* Likewise for exception catchpoints in dynamic-linked
1471 executables where required */
1472 if (ep_is_exception_catchpoint (b
) &&
1473 exception_catchpoints_are_fragile
)
1476 delete_breakpoint (b
);
1482 if (exception_catchpoints_are_fragile
)
1483 exception_support_initialized
= 0;
1485 /* Don't issue the warning unless it's really needed... */
1486 if (warning_needed
&& (context
!= inf_exited
))
1488 warning ("Exception catchpoints from last run were deleted.");
1489 warning ("You must reinsert them explicitly.");
1494 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1495 exists at PC. It returns ordinary_breakpoint_here if it's an
1496 ordinary breakpoint, or permanent_breakpoint_here if it's a
1497 permanent breakpoint.
1498 - When continuing from a location with an ordinary breakpoint, we
1499 actually single step once before calling insert_breakpoints.
1500 - When continuing from a localion with a permanent breakpoint, we
1501 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1502 the target, to advance the PC past the breakpoint. */
1504 enum breakpoint_here
1505 breakpoint_here_p (pc
)
1508 register struct breakpoint
*b
;
1509 int any_breakpoint_here
= 0;
1512 if ((b
->enable
== enabled
1513 || b
->enable
== permanent
)
1514 && b
->address
== pc
) /* bp is enabled and matches pc */
1516 if (overlay_debugging
&&
1517 section_is_overlay (b
->section
) &&
1518 !section_is_mapped (b
->section
))
1519 continue; /* unmapped overlay -- can't be a match */
1520 else if (b
->enable
== permanent
)
1521 return permanent_breakpoint_here
;
1523 any_breakpoint_here
= 1;
1526 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1530 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1531 but it only returns true if there is actually a breakpoint inserted
1535 breakpoint_inserted_here_p (pc
)
1538 register struct breakpoint
*b
;
1542 && b
->address
== pc
) /* bp is inserted and matches pc */
1544 if (overlay_debugging
&&
1545 section_is_overlay (b
->section
) &&
1546 !section_is_mapped (b
->section
))
1547 continue; /* unmapped overlay -- can't be a match */
1555 /* Return nonzero if FRAME is a dummy frame. We can't use
1556 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1557 much time, at least using get_saved_register on the 68k. This
1558 means that for this function to work right a port must use the
1559 bp_call_dummy breakpoint. */
1562 frame_in_dummy (frame
)
1563 struct frame_info
*frame
;
1565 struct breakpoint
*b
;
1570 if (USE_GENERIC_DUMMY_FRAMES
)
1571 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1575 if (b
->type
== bp_call_dummy
1576 && b
->frame
== frame
->frame
1577 /* We need to check the PC as well as the frame on the sparc,
1578 for signals.exp in the testsuite. */
1581 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1582 && frame
->pc
<= b
->address
)
1588 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1589 is valid for process/thread PID. */
1592 breakpoint_thread_match (pc
, pid
)
1596 struct breakpoint
*b
;
1599 thread
= pid_to_thread_id (pid
);
1602 if (b
->enable
!= disabled
1603 && b
->enable
!= shlib_disabled
1604 && b
->enable
!= call_disabled
1606 && (b
->thread
== -1 || b
->thread
== thread
))
1608 if (overlay_debugging
&&
1609 section_is_overlay (b
->section
) &&
1610 !section_is_mapped (b
->section
))
1611 continue; /* unmapped overlay -- can't be a match */
1620 /* bpstat stuff. External routines' interfaces are documented
1624 ep_is_catchpoint (ep
)
1625 struct breakpoint
*ep
;
1628 (ep
->type
== bp_catch_load
)
1629 || (ep
->type
== bp_catch_unload
)
1630 || (ep
->type
== bp_catch_fork
)
1631 || (ep
->type
== bp_catch_vfork
)
1632 || (ep
->type
== bp_catch_exec
)
1633 || (ep
->type
== bp_catch_catch
)
1634 || (ep
->type
== bp_catch_throw
)
1637 /* ??rehrauer: Add more kinds here, as are implemented... */
1642 ep_is_shlib_catchpoint (ep
)
1643 struct breakpoint
*ep
;
1646 (ep
->type
== bp_catch_load
)
1647 || (ep
->type
== bp_catch_unload
)
1652 ep_is_exception_catchpoint (ep
)
1653 struct breakpoint
*ep
;
1656 (ep
->type
== bp_catch_catch
)
1657 || (ep
->type
== bp_catch_throw
)
1661 /* Clear a bpstat so that it says we are not at any breakpoint.
1662 Also free any storage that is part of a bpstat. */
1677 if (p
->old_val
!= NULL
)
1678 value_free (p
->old_val
);
1685 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1686 is part of the bpstat is copied as well. */
1694 bpstat retval
= NULL
;
1699 for (; bs
!= NULL
; bs
= bs
->next
)
1701 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1702 memcpy (tmp
, bs
, sizeof (*tmp
));
1704 /* This is the first thing in the chain. */
1714 /* Find the bpstat associated with this breakpoint */
1717 bpstat_find_breakpoint (bsp
, breakpoint
)
1719 struct breakpoint
*breakpoint
;
1724 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1726 if (bsp
->breakpoint_at
== breakpoint
)
1732 /* Find a step_resume breakpoint associated with this bpstat.
1733 (If there are multiple step_resume bp's on the list, this function
1734 will arbitrarily pick one.)
1736 It is an error to use this function if BPSTAT doesn't contain a
1737 step_resume breakpoint.
1739 See wait_for_inferior's use of this function. */
1741 bpstat_find_step_resume_breakpoint (bsp
)
1745 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1747 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1749 if ((bsp
->breakpoint_at
!= NULL
) &&
1750 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1751 return bsp
->breakpoint_at
;
1754 error ("Internal error (no step_resume breakpoint found)");
1758 /* Return the breakpoint number of the first breakpoint we are stopped
1759 at. *BSP upon return is a bpstat which points to the remaining
1760 breakpoints stopped at (but which is not guaranteed to be good for
1761 anything but further calls to bpstat_num).
1762 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1768 struct breakpoint
*b
;
1771 return 0; /* No more breakpoint values */
1774 b
= (*bsp
)->breakpoint_at
;
1775 *bsp
= (*bsp
)->next
;
1777 return -1; /* breakpoint that's been deleted since */
1779 return b
->number
; /* We have its number */
1783 /* Modify BS so that the actions will not be performed. */
1786 bpstat_clear_actions (bs
)
1789 for (; bs
!= NULL
; bs
= bs
->next
)
1791 bs
->commands
= NULL
;
1792 if (bs
->old_val
!= NULL
)
1794 value_free (bs
->old_val
);
1800 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1803 cleanup_executing_breakpoints (ignore
)
1806 executing_breakpoint_commands
= 0;
1809 /* Execute all the commands associated with all the breakpoints at this
1810 location. Any of these commands could cause the process to proceed
1811 beyond this point, etc. We look out for such changes by checking
1812 the global "breakpoint_proceeded" after each command. */
1815 bpstat_do_actions (bsp
)
1819 struct cleanup
*old_chain
;
1820 struct command_line
*cmd
;
1822 /* Avoid endless recursion if a `source' command is contained
1824 if (executing_breakpoint_commands
)
1827 executing_breakpoint_commands
= 1;
1828 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1831 /* Note that (as of this writing), our callers all appear to
1832 be passing us the address of global stop_bpstat. And, if
1833 our calls to execute_control_command cause the inferior to
1834 proceed, that global (and hence, *bsp) will change.
1836 We must be careful to not touch *bsp unless the inferior
1837 has not proceeded. */
1839 /* This pointer will iterate over the list of bpstat's. */
1842 breakpoint_proceeded
= 0;
1843 for (; bs
!= NULL
; bs
= bs
->next
)
1848 execute_control_command (cmd
);
1850 if (breakpoint_proceeded
)
1855 if (breakpoint_proceeded
)
1856 /* The inferior is proceeded by the command; bomb out now.
1857 The bpstat chain has been blown away by wait_for_inferior.
1858 But since execution has stopped again, there is a new bpstat
1859 to look at, so start over. */
1862 bs
->commands
= NULL
;
1865 executing_breakpoint_commands
= 0;
1866 discard_cleanups (old_chain
);
1869 /* This is the normal print function for a bpstat. In the future,
1870 much of this logic could (should?) be moved to bpstat_stop_status,
1871 by having it set different print_it values.
1873 Current scheme: When we stop, bpstat_print() is called. It loops
1874 through the bpstat list of things causing this stop, calling the
1875 print_bp_stop_message function on each one. The behavior of the
1876 print_bp_stop_message function depends on the print_it field of
1877 bpstat. If such field so indicates, call this function here.
1879 Return values from this routine (ultimately used by bpstat_print()
1880 and normal_stop() to decide what to do):
1881 PRINT_NOTHING: Means we already printed all we needed to print,
1882 don't print anything else.
1883 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
1884 that something to be followed by a location.
1885 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
1886 that something to be followed by a location.
1887 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
1890 static enum print_stop_action
1891 print_it_typical (bs
)
1895 struct cleanup
*old_chain
;
1896 struct ui_stream
*stb
;
1897 stb
= ui_out_stream_new (uiout
);
1898 old_chain
= make_cleanup ((make_cleanup_func
) ui_out_stream_delete
, stb
);
1900 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1901 which has since been deleted. */
1902 if (bs
->breakpoint_at
== NULL
)
1903 return PRINT_UNKNOWN
;
1905 switch (bs
->breakpoint_at
->type
)
1908 case bp_hardware_breakpoint
:
1910 annotate_breakpoint (bs
->breakpoint_at
->number
);
1911 ui_out_text (uiout
, "\nBreakpoint ");
1912 ui_out_field_int (uiout
, "bkptno", bs
->breakpoint_at
->number
);
1913 ui_out_text (uiout
, ", ");
1914 return PRINT_SRC_AND_LOC
;
1916 /* I think the user probably only wants to see one breakpoint
1917 number, not all of them. */
1918 annotate_breakpoint (bs
->breakpoint_at
->number
);
1919 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1920 return PRINT_SRC_AND_LOC
;
1924 case bp_shlib_event
:
1925 /* Did we stop because the user set the stop_on_solib_events
1926 variable? (If so, we report this as a generic, "Stopped due
1927 to shlib event" message.) */
1928 printf_filtered ("Stopped due to shared library event\n");
1929 return PRINT_NOTHING
;
1932 case bp_thread_event
:
1933 /* Not sure how we will get here.
1934 GDB should not stop for these breakpoints. */
1935 printf_filtered ("Thread Event Breakpoint: gdb should not stop!\n");
1936 return PRINT_NOTHING
;
1940 annotate_catchpoint (bs
->breakpoint_at
->number
);
1941 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1942 printf_filtered ("loaded");
1943 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1944 return PRINT_SRC_AND_LOC
;
1947 case bp_catch_unload
:
1948 annotate_catchpoint (bs
->breakpoint_at
->number
);
1949 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1950 printf_filtered ("unloaded");
1951 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1952 return PRINT_SRC_AND_LOC
;
1956 annotate_catchpoint (bs
->breakpoint_at
->number
);
1957 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1958 printf_filtered ("forked");
1959 printf_filtered (" process %d), ",
1960 bs
->breakpoint_at
->forked_inferior_pid
);
1961 return PRINT_SRC_AND_LOC
;
1964 case bp_catch_vfork
:
1965 annotate_catchpoint (bs
->breakpoint_at
->number
);
1966 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1967 printf_filtered ("vforked");
1968 printf_filtered (" process %d), ",
1969 bs
->breakpoint_at
->forked_inferior_pid
);
1970 return PRINT_SRC_AND_LOC
;
1974 annotate_catchpoint (bs
->breakpoint_at
->number
);
1975 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1976 bs
->breakpoint_at
->number
,
1977 bs
->breakpoint_at
->exec_pathname
);
1978 return PRINT_SRC_AND_LOC
;
1981 case bp_catch_catch
:
1982 if (current_exception_event
&&
1983 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1985 annotate_catchpoint (bs
->breakpoint_at
->number
);
1986 printf_filtered ("\nCatchpoint %d (exception caught), ",
1987 bs
->breakpoint_at
->number
);
1988 printf_filtered ("throw location ");
1989 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1990 printf_filtered ("%s:%d",
1991 CURRENT_EXCEPTION_THROW_FILE
,
1992 CURRENT_EXCEPTION_THROW_LINE
);
1994 printf_filtered ("unknown");
1996 printf_filtered (", catch location ");
1997 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1998 printf_filtered ("%s:%d",
1999 CURRENT_EXCEPTION_CATCH_FILE
,
2000 CURRENT_EXCEPTION_CATCH_LINE
);
2002 printf_filtered ("unknown");
2004 printf_filtered ("\n");
2005 /* don't bother to print location frame info */
2006 return PRINT_SRC_ONLY
;
2010 /* really throw, some other bpstat will handle it */
2011 return PRINT_UNKNOWN
;
2015 case bp_catch_throw
:
2016 if (current_exception_event
&&
2017 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
2019 annotate_catchpoint (bs
->breakpoint_at
->number
);
2020 printf_filtered ("\nCatchpoint %d (exception thrown), ",
2021 bs
->breakpoint_at
->number
);
2022 printf_filtered ("throw location ");
2023 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2024 printf_filtered ("%s:%d",
2025 CURRENT_EXCEPTION_THROW_FILE
,
2026 CURRENT_EXCEPTION_THROW_LINE
);
2028 printf_filtered ("unknown");
2030 printf_filtered (", catch location ");
2031 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2032 printf_filtered ("%s:%d",
2033 CURRENT_EXCEPTION_CATCH_FILE
,
2034 CURRENT_EXCEPTION_CATCH_LINE
);
2036 printf_filtered ("unknown");
2038 printf_filtered ("\n");
2039 /* don't bother to print location frame info */
2040 return PRINT_SRC_ONLY
;
2044 /* really catch, some other bpstat will handle it */
2045 return PRINT_UNKNOWN
;
2050 case bp_hardware_watchpoint
:
2051 if (bs
->old_val
!= NULL
)
2053 annotate_watchpoint (bs
->breakpoint_at
->number
);
2055 mention (bs
->breakpoint_at
);
2056 ui_out_list_begin (uiout
, "value");
2057 ui_out_text (uiout
, "\nOld value = ");
2058 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2059 ui_out_field_stream (uiout
, "old", stb
);
2060 ui_out_text (uiout
, "\nNew value = ");
2061 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2062 ui_out_field_stream (uiout
, "new", stb
);
2063 ui_out_list_end (uiout
);
2064 ui_out_text (uiout
, "\n");
2066 mention (bs
->breakpoint_at
);
2067 printf_filtered ("\nOld value = ");
2068 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2069 printf_filtered ("\nNew value = ");
2070 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2071 Val_pretty_default
);
2072 printf_filtered ("\n");
2074 value_free (bs
->old_val
);
2077 /* More than one watchpoint may have been triggered. */
2078 return PRINT_UNKNOWN
;
2081 case bp_read_watchpoint
:
2083 mention (bs
->breakpoint_at
);
2084 ui_out_list_begin (uiout
, "value");
2085 ui_out_text (uiout
, "\nValue = ");
2086 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2087 ui_out_field_stream (uiout
, "value", stb
);
2088 ui_out_list_end (uiout
);
2089 ui_out_text (uiout
, "\n");
2091 mention (bs
->breakpoint_at
);
2092 printf_filtered ("\nValue = ");
2093 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2094 Val_pretty_default
);
2095 printf_filtered ("\n");
2097 return PRINT_UNKNOWN
;
2100 case bp_access_watchpoint
:
2102 if (bs
->old_val
!= NULL
)
2104 annotate_watchpoint (bs
->breakpoint_at
->number
);
2105 mention (bs
->breakpoint_at
);
2106 ui_out_list_begin (uiout
, "value");
2107 ui_out_text (uiout
, "\nOld value = ");
2108 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2109 ui_out_field_stream (uiout
, "old", stb
);
2110 value_free (bs
->old_val
);
2112 ui_out_text (uiout
, "\nNew value = ");
2116 mention (bs
->breakpoint_at
);
2117 ui_out_field_string (uiout
, "reason", "access-watchpoint-trigger");
2118 ui_out_text (uiout
, "\nValue = ");
2120 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0,Val_pretty_default
);
2121 ui_out_field_stream (uiout
, "new", stb
);
2122 ui_out_list_end (uiout
);
2123 ui_out_text (uiout
, "\n");
2125 if (bs
->old_val
!= NULL
)
2127 annotate_watchpoint (bs
->breakpoint_at
->number
);
2128 mention (bs
->breakpoint_at
);
2129 printf_filtered ("\nOld value = ");
2130 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2131 value_free (bs
->old_val
);
2133 printf_filtered ("\nNew value = ");
2137 mention (bs
->breakpoint_at
);
2138 printf_filtered ("\nValue = ");
2140 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2141 Val_pretty_default
);
2142 printf_filtered ("\n");
2144 return PRINT_UNKNOWN
;
2147 /* Fall through, we don't deal with these types of breakpoints
2151 return PRINT_UNKNOWN
;
2155 return PRINT_UNKNOWN
;
2160 case bp_longjmp_resume
:
2161 case bp_step_resume
:
2162 case bp_through_sigtramp
:
2163 case bp_watchpoint_scope
:
2166 return PRINT_UNKNOWN
;
2170 /* Generic routine for printing messages indicating why we
2171 stopped. The behavior of this function depends on the value
2172 'print_it' in the bpstat structure. Under some circumstances we
2173 may decide not to print anything here and delegate the task to
2176 static enum print_stop_action
2177 print_bp_stop_message (bpstat bs
)
2179 switch (bs
->print_it
)
2182 /* Nothing should be printed for this bpstat entry. */
2183 return PRINT_UNKNOWN
;
2187 /* We still want to print the frame, but we already printed the
2188 relevant messages. */
2189 return PRINT_SRC_AND_LOC
;
2192 case print_it_normal
:
2193 /* Normal case, we handle everything in print_it_typical. */
2194 return print_it_typical (bs
);
2197 internal_error ("print_bp_stop_message: unrecognized enum value");
2202 /* Print a message indicating what happened. This is called from
2203 normal_stop(). The input to this routine is the head of the bpstat
2204 list - a list of the eventpoints that caused this stop. This
2205 routine calls the generic print routine for printing a message
2206 about reasons for stopping. This will print (for example) the
2207 "Breakpoint n," part of the output. The return value of this
2210 PRINT_UNKNOWN: Means we printed nothing
2211 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2212 code to print the location. An example is
2213 "Breakpoint 1, " which should be followed by
2215 PRINT_SRC_ONLY: Means we printed something, but there is no need
2216 to also print the location part of the message.
2217 An example is the catch/throw messages, which
2218 don't require a location appended to the end.
2219 PRINT_NOTHING: We have done some printing and we don't need any
2220 further info to be printed.*/
2222 enum print_stop_action
2228 /* Maybe another breakpoint in the chain caused us to stop.
2229 (Currently all watchpoints go on the bpstat whether hit or not.
2230 That probably could (should) be changed, provided care is taken
2231 with respect to bpstat_explains_signal). */
2232 for (; bs
; bs
= bs
->next
)
2234 val
= print_bp_stop_message (bs
);
2235 if (val
== PRINT_SRC_ONLY
2236 || val
== PRINT_SRC_AND_LOC
2237 || val
== PRINT_NOTHING
)
2241 /* We reached the end of the chain, or we got a null BS to start
2242 with and nothing was printed. */
2243 return PRINT_UNKNOWN
;
2246 /* Evaluate the expression EXP and return 1 if value is zero.
2247 This is used inside a catch_errors to evaluate the breakpoint condition.
2248 The argument is a "struct expression *" that has been cast to char * to
2249 make it pass through catch_errors. */
2252 breakpoint_cond_eval (exp
)
2255 value_ptr mark
= value_mark ();
2256 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2257 value_free_to_mark (mark
);
2261 /* Allocate a new bpstat and chain it to the current one. */
2264 bpstat_alloc (b
, cbs
)
2265 register struct breakpoint
*b
;
2266 bpstat cbs
; /* Current "bs" value */
2270 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2272 bs
->breakpoint_at
= b
;
2273 /* If the condition is false, etc., don't do the commands. */
2274 bs
->commands
= NULL
;
2276 bs
->print_it
= print_it_normal
;
2280 /* Possible return values for watchpoint_check (this can't be an enum
2281 because of check_errors). */
2282 /* The watchpoint has been deleted. */
2283 #define WP_DELETED 1
2284 /* The value has changed. */
2285 #define WP_VALUE_CHANGED 2
2286 /* The value has not changed. */
2287 #define WP_VALUE_NOT_CHANGED 3
2289 #define BP_TEMPFLAG 1
2290 #define BP_HARDWAREFLAG 2
2292 /* Check watchpoint condition. */
2295 watchpoint_check (p
)
2298 bpstat bs
= (bpstat
) p
;
2299 struct breakpoint
*b
;
2300 struct frame_info
*fr
;
2301 int within_current_scope
;
2303 b
= bs
->breakpoint_at
;
2305 if (b
->exp_valid_block
== NULL
)
2306 within_current_scope
= 1;
2309 /* There is no current frame at this moment. If we're going to have
2310 any chance of handling watchpoints on local variables, we'll need
2311 the frame chain (so we can determine if we're in scope). */
2312 reinit_frame_cache ();
2313 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2314 within_current_scope
= (fr
!= NULL
);
2315 if (within_current_scope
)
2316 /* If we end up stopping, the current frame will get selected
2317 in normal_stop. So this call to select_frame won't affect
2319 select_frame (fr
, -1);
2322 if (within_current_scope
)
2324 /* We use value_{,free_to_}mark because it could be a
2325 *long* time before we return to the command level and
2326 call free_all_values. We can't call free_all_values because
2327 we might be in the middle of evaluating a function call. */
2329 value_ptr mark
= value_mark ();
2330 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2331 if (!value_equal (b
->val
, new_val
))
2333 release_value (new_val
);
2334 value_free_to_mark (mark
);
2335 bs
->old_val
= b
->val
;
2337 /* We will stop here */
2338 return WP_VALUE_CHANGED
;
2342 /* Nothing changed, don't do anything. */
2343 value_free_to_mark (mark
);
2344 /* We won't stop here */
2345 return WP_VALUE_NOT_CHANGED
;
2350 /* This seems like the only logical thing to do because
2351 if we temporarily ignored the watchpoint, then when
2352 we reenter the block in which it is valid it contains
2353 garbage (in the case of a function, it may have two
2354 garbage values, one before and one after the prologue).
2355 So we can't even detect the first assignment to it and
2356 watch after that (since the garbage may or may not equal
2357 the first value assigned). */
2358 /* We print all the stop information in print_it_typical(), but
2359 in this case, by the time we call print_it_typical() this bp
2360 will be deleted already. So we have no choice but print the
2361 information here. */
2363 ui_out_text (uiout
, "\nWatchpoint ");
2364 ui_out_field_int (uiout
, "wpnum", bs
->breakpoint_at
->number
);
2365 ui_out_text (uiout
, " deleted because the program has left the block in\n\
2366 which its expression is valid.\n");
2369 Watchpoint %d deleted because the program has left the block in\n\
2370 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2373 if (b
->related_breakpoint
)
2374 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2375 b
->disposition
= del_at_next_stop
;
2381 /* Get a bpstat associated with having just stopped at address *PC
2382 and frame address CORE_ADDRESS. Update *PC to point at the
2383 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2384 if this is known to not be a real breakpoint (it could still be a
2385 watchpoint, though). */
2387 /* Determine whether we stopped at a breakpoint, etc, or whether we
2388 don't understand this stop. Result is a chain of bpstat's such that:
2390 if we don't understand the stop, the result is a null pointer.
2392 if we understand why we stopped, the result is not null.
2394 Each element of the chain refers to a particular breakpoint or
2395 watchpoint at which we have stopped. (We may have stopped for
2396 several reasons concurrently.)
2398 Each element of the chain has valid next, breakpoint_at,
2399 commands, FIXME??? fields. */
2402 bpstat_stop_status (pc
, not_a_breakpoint
)
2404 int not_a_breakpoint
;
2406 register struct breakpoint
*b
, *temp
;
2408 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2409 int real_breakpoint
= 0;
2410 /* Root of the chain of bpstat's */
2411 struct bpstats root_bs
[1];
2412 /* Pointer to the last thing in the chain currently. */
2413 bpstat bs
= root_bs
;
2414 static char message1
[] =
2415 "Error evaluating expression for watchpoint %d\n";
2416 char message
[sizeof (message1
) + 30 /* slop */ ];
2418 /* Get the address where the breakpoint would have been. */
2419 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2420 0 : DECR_PC_AFTER_BREAK
);
2422 ALL_BREAKPOINTS_SAFE (b
, temp
)
2424 if (b
->enable
== disabled
2425 || b
->enable
== shlib_disabled
2426 || b
->enable
== call_disabled
)
2429 if (b
->type
!= bp_watchpoint
2430 && b
->type
!= bp_hardware_watchpoint
2431 && b
->type
!= bp_read_watchpoint
2432 && b
->type
!= bp_access_watchpoint
2433 && b
->type
!= bp_hardware_breakpoint
2434 && b
->type
!= bp_catch_fork
2435 && b
->type
!= bp_catch_vfork
2436 && b
->type
!= bp_catch_exec
2437 && b
->type
!= bp_catch_catch
2438 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2439 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2440 (overlay_debugging
&& /* overlay doesn't match */
2441 section_is_overlay (b
->section
) &&
2442 !section_is_mapped (b
->section
)))
2445 if (b
->type
== bp_hardware_breakpoint
2446 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2449 /* Is this a catchpoint of a load or unload? If so, did we
2450 get a load or unload of the specified library? If not,
2452 if ((b
->type
== bp_catch_load
)
2453 #if defined(SOLIB_HAVE_LOAD_EVENT)
2454 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2455 || ((b
->dll_pathname
!= NULL
)
2456 && (strcmp (b
->dll_pathname
,
2457 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2463 if ((b
->type
== bp_catch_unload
)
2464 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2465 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2466 || ((b
->dll_pathname
!= NULL
)
2467 && (strcmp (b
->dll_pathname
,
2468 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2474 if ((b
->type
== bp_catch_fork
)
2475 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2478 if ((b
->type
== bp_catch_vfork
)
2479 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2482 if ((b
->type
== bp_catch_exec
)
2483 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2486 if (ep_is_exception_catchpoint (b
) &&
2487 !(current_exception_event
= target_get_current_exception_event ()))
2490 /* Come here if it's a watchpoint, or if the break address matches */
2492 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2494 /* Watchpoints may change this, if not found to have triggered. */
2498 sprintf (message
, message1
, b
->number
);
2499 if (b
->type
== bp_watchpoint
||
2500 b
->type
== bp_hardware_watchpoint
)
2502 switch (catch_errors (watchpoint_check
, bs
, message
,
2506 /* We've already printed what needs to be printed. */
2507 /* Actually this is superfluous, because by the time we
2508 call print_it_typical() the wp will be already deleted,
2509 and the function will return immediately. */
2510 bs
->print_it
= print_it_done
;
2513 case WP_VALUE_CHANGED
:
2517 case WP_VALUE_NOT_CHANGED
:
2519 bs
->print_it
= print_it_noop
;
2526 /* Error from catch_errors. */
2527 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2528 if (b
->related_breakpoint
)
2529 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2530 b
->disposition
= del_at_next_stop
;
2531 /* We've already printed what needs to be printed. */
2532 bs
->print_it
= print_it_done
;
2538 else if (b
->type
== bp_read_watchpoint
||
2539 b
->type
== bp_access_watchpoint
)
2545 addr
= target_stopped_data_address ();
2548 for (v
= b
->val_chain
; v
; v
= v
->next
)
2550 if (VALUE_LVAL (v
) == lval_memory
2551 && ! VALUE_LAZY (v
))
2555 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2556 /* Exact match not required. Within range is sufficient.
2558 if (addr
>= vaddr
&&
2559 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2564 switch (catch_errors (watchpoint_check
, bs
, message
,
2568 /* We've already printed what needs to be printed. */
2569 bs
->print_it
= print_it_done
;
2572 case WP_VALUE_CHANGED
:
2573 case WP_VALUE_NOT_CHANGED
:
2580 /* Error from catch_errors. */
2581 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2582 if (b
->related_breakpoint
)
2583 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2584 b
->disposition
= del_at_next_stop
;
2585 /* We've already printed what needs to be printed. */
2586 bs
->print_it
= print_it_done
;
2589 else /* found == 0 */
2591 /* This is a case where some watchpoint(s) triggered,
2592 but not at the address of this watchpoint (FOUND
2593 was left zero). So don't print anything for this
2595 bs
->print_it
= print_it_noop
;
2602 /* By definition, an encountered breakpoint is a triggered
2606 real_breakpoint
= 1;
2610 b
->frame
!= (get_current_frame ())->frame
)
2614 int value_is_zero
= 0;
2618 /* Need to select the frame, with all that implies
2619 so that the conditions will have the right context. */
2620 select_frame (get_current_frame (), 0);
2622 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2623 "Error in testing breakpoint condition:\n",
2625 /* FIXME-someday, should give breakpoint # */
2628 if (b
->cond
&& value_is_zero
)
2631 /* Don't consider this a hit. */
2634 else if (b
->ignore_count
> 0)
2637 annotate_ignore_count_change ();
2642 /* We will stop here */
2643 if (b
->disposition
== disable
)
2644 b
->enable
= disabled
;
2645 bs
->commands
= b
->commands
;
2649 (STREQ ("silent", bs
->commands
->line
) ||
2650 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2652 bs
->commands
= bs
->commands
->next
;
2657 /* Print nothing for this entry if we dont stop or if we dont print. */
2658 if (bs
->stop
== 0 || bs
->print
== 0)
2659 bs
->print_it
= print_it_noop
;
2662 bs
->next
= NULL
; /* Terminate the chain */
2663 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2665 if (real_breakpoint
&& bs
)
2667 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2669 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2671 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2677 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2680 #if defined (SHIFT_INST_REGS)
2682 #else /* No SHIFT_INST_REGS. */
2684 #endif /* No SHIFT_INST_REGS. */
2689 /* The value of a hardware watchpoint hasn't changed, but the
2690 intermediate memory locations we are watching may have. */
2691 if (bs
&& !bs
->stop
&&
2692 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2693 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2694 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2696 remove_breakpoints ();
2697 insert_breakpoints ();
2702 /* Tell what to do about this bpstat. */
2707 /* Classify each bpstat as one of the following. */
2710 /* This bpstat element has no effect on the main_action. */
2713 /* There was a watchpoint, stop but don't print. */
2716 /* There was a watchpoint, stop and print. */
2719 /* There was a breakpoint but we're not stopping. */
2722 /* There was a breakpoint, stop but don't print. */
2725 /* There was a breakpoint, stop and print. */
2728 /* We hit the longjmp breakpoint. */
2731 /* We hit the longjmp_resume breakpoint. */
2734 /* We hit the step_resume breakpoint. */
2737 /* We hit the through_sigtramp breakpoint. */
2740 /* We hit the shared library event breakpoint. */
2743 /* We caught a shared library event. */
2746 /* This is just used to count how many enums there are. */
2750 /* Here is the table which drives this routine. So that we can
2751 format it pretty, we define some abbreviations for the
2752 enum bpstat_what codes. */
2753 #define kc BPSTAT_WHAT_KEEP_CHECKING
2754 #define ss BPSTAT_WHAT_STOP_SILENT
2755 #define sn BPSTAT_WHAT_STOP_NOISY
2756 #define sgl BPSTAT_WHAT_SINGLE
2757 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2758 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2759 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2760 #define sr BPSTAT_WHAT_STEP_RESUME
2761 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2762 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2763 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2765 /* "Can't happen." Might want to print an error message.
2766 abort() is not out of the question, but chances are GDB is just
2767 a bit confused, not unusable. */
2768 #define err BPSTAT_WHAT_STOP_NOISY
2770 /* Given an old action and a class, come up with a new action. */
2771 /* One interesting property of this table is that wp_silent is the same
2772 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2773 after stopping, the check for whether to step over a breakpoint
2774 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2775 reference to how we stopped. We retain separate wp_silent and
2776 bp_silent codes in case we want to change that someday.
2778 Another possibly interesting property of this table is that
2779 there's a partial ordering, priority-like, of the actions. Once
2780 you've decided that some action is appropriate, you'll never go
2781 back and decide something of a lower priority is better. The
2784 kc < clr sgl shl slr sn sr ss ts
2785 sgl < clrs shl shlr slr sn sr ss ts
2786 slr < err shl shlr sn sr ss ts
2787 clr < clrs err shl shlr sn sr ss ts
2788 clrs < err shl shlr sn sr ss ts
2789 ss < shl shlr sn sr ts
2796 What I think this means is that we don't need a damned table
2797 here. If you just put the rows and columns in the right order,
2798 it'd look awfully regular. We could simply walk the bpstat list
2799 and choose the highest priority action we find, with a little
2800 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2801 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2802 is messy anyway). */
2804 /* step_resume entries: a step resume breakpoint overrides another
2805 breakpoint of signal handling (see comment in wait_for_inferior
2806 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2807 /* We handle the through_sigtramp_breakpoint the same way; having both
2808 one of those and a step_resume_breakpoint is probably very rare (?). */
2810 static const enum bpstat_what_main_action
2811 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2814 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2817 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2819 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2821 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2823 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2825 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2827 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2829 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2831 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2833 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2835 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2837 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2839 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2854 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2855 struct bpstat_what retval
;
2857 retval
.call_dummy
= 0;
2858 for (; bs
!= NULL
; bs
= bs
->next
)
2860 enum class bs_class
= no_effect
;
2861 if (bs
->breakpoint_at
== NULL
)
2862 /* I suspect this can happen if it was a momentary breakpoint
2863 which has since been deleted. */
2865 switch (bs
->breakpoint_at
->type
)
2871 case bp_hardware_breakpoint
:
2877 bs_class
= bp_noisy
;
2879 bs_class
= bp_silent
;
2882 bs_class
= bp_nostop
;
2885 case bp_hardware_watchpoint
:
2886 case bp_read_watchpoint
:
2887 case bp_access_watchpoint
:
2891 bs_class
= wp_noisy
;
2893 bs_class
= wp_silent
;
2896 /* There was a watchpoint, but we're not stopping.
2897 This requires no further action. */
2898 bs_class
= no_effect
;
2901 bs_class
= long_jump
;
2903 case bp_longjmp_resume
:
2904 bs_class
= long_resume
;
2906 case bp_step_resume
:
2909 bs_class
= step_resume
;
2912 /* It is for the wrong frame. */
2913 bs_class
= bp_nostop
;
2915 case bp_through_sigtramp
:
2916 bs_class
= through_sig
;
2918 case bp_watchpoint_scope
:
2919 bs_class
= bp_nostop
;
2921 case bp_shlib_event
:
2922 bs_class
= shlib_event
;
2924 case bp_thread_event
:
2925 bs_class
= bp_nostop
;
2928 case bp_catch_unload
:
2929 /* Only if this catchpoint triggered should we cause the
2930 step-out-of-dld behaviour. Otherwise, we ignore this
2933 bs_class
= catch_shlib_event
;
2935 bs_class
= no_effect
;
2938 case bp_catch_vfork
:
2943 bs_class
= bp_noisy
;
2945 bs_class
= bp_silent
;
2948 /* There was a catchpoint, but we're not stopping.
2949 This requires no further action. */
2950 bs_class
= no_effect
;
2952 case bp_catch_catch
:
2953 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2954 bs_class
= bp_nostop
;
2956 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2958 case bp_catch_throw
:
2959 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2960 bs_class
= bp_nostop
;
2962 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2965 /* Make sure the action is stop (silent or noisy),
2966 so infrun.c pops the dummy frame. */
2967 bs_class
= bp_silent
;
2968 retval
.call_dummy
= 1;
2971 current_action
= table
[(int) bs_class
][(int) current_action
];
2973 retval
.main_action
= current_action
;
2977 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2978 without hardware support). This isn't related to a specific bpstat,
2979 just to things like whether watchpoints are set. */
2982 bpstat_should_step ()
2984 struct breakpoint
*b
;
2986 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2991 /* Nonzero if there are enabled hardware watchpoints. */
2993 bpstat_have_active_hw_watchpoints ()
2995 struct breakpoint
*b
;
2997 if ((b
->enable
== enabled
) &&
2999 ((b
->type
== bp_hardware_watchpoint
) ||
3000 (b
->type
== bp_read_watchpoint
) ||
3001 (b
->type
== bp_access_watchpoint
)))
3007 /* Given a bpstat that records zero or more triggered eventpoints, this
3008 function returns another bpstat which contains only the catchpoints
3009 on that first list, if any. */
3011 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
3015 struct bpstats root_bs
[1];
3016 bpstat bs
= root_bs
;
3017 struct breakpoint
*ep
;
3020 bpstat_clear (cp_list
);
3021 root_bs
->next
= NULL
;
3023 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
3025 /* Is this eventpoint a catchpoint? If not, ignore it. */
3026 ep
= ep_list
->breakpoint_at
;
3029 if ((ep
->type
!= bp_catch_load
) &&
3030 (ep
->type
!= bp_catch_unload
) &&
3031 (ep
->type
!= bp_catch_catch
) &&
3032 (ep
->type
!= bp_catch_throw
))
3033 /* pai: (temp) ADD fork/vfork here!! */
3036 /* Yes; add it to the list. */
3037 bs
= bpstat_alloc (ep
, bs
);
3042 #if defined(SOLIB_ADD)
3043 /* Also, for each triggered catchpoint, tag it with the name of
3044 the library that caused this trigger. (We copy the name now,
3045 because it's only guaranteed to be available NOW, when the
3046 catchpoint triggers. Clients who may wish to know the name
3047 later must get it from the catchpoint itself.) */
3048 if (ep
->triggered_dll_pathname
!= NULL
)
3049 free (ep
->triggered_dll_pathname
);
3050 if (ep
->type
== bp_catch_load
)
3051 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
3053 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
3055 dll_pathname
= NULL
;
3059 ep
->triggered_dll_pathname
= (char *)
3060 xmalloc (strlen (dll_pathname
) + 1);
3061 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
3064 ep
->triggered_dll_pathname
= NULL
;
3070 /* Print B to gdb_stdout. */
3072 print_one_breakpoint (struct breakpoint
*b
,
3073 CORE_ADDR
*last_addr
)
3075 register struct command_line
*l
;
3076 register struct symbol
*sym
;
3077 struct ep_type_description
3082 static struct ep_type_description bptypes
[] =
3084 {bp_none
, "?deleted?"},
3085 {bp_breakpoint
, "breakpoint"},
3086 {bp_hardware_breakpoint
, "hw breakpoint"},
3087 {bp_until
, "until"},
3088 {bp_finish
, "finish"},
3089 {bp_watchpoint
, "watchpoint"},
3090 {bp_hardware_watchpoint
, "hw watchpoint"},
3091 {bp_read_watchpoint
, "read watchpoint"},
3092 {bp_access_watchpoint
, "acc watchpoint"},
3093 {bp_longjmp
, "longjmp"},
3094 {bp_longjmp_resume
, "longjmp resume"},
3095 {bp_step_resume
, "step resume"},
3096 {bp_through_sigtramp
, "sigtramp"},
3097 {bp_watchpoint_scope
, "watchpoint scope"},
3098 {bp_call_dummy
, "call dummy"},
3099 {bp_shlib_event
, "shlib events"},
3100 {bp_thread_event
, "thread events"},
3101 {bp_catch_load
, "catch load"},
3102 {bp_catch_unload
, "catch unload"},
3103 {bp_catch_fork
, "catch fork"},
3104 {bp_catch_vfork
, "catch vfork"},
3105 {bp_catch_exec
, "catch exec"},
3106 {bp_catch_catch
, "catch catch"},
3107 {bp_catch_throw
, "catch throw"}
3110 static char *bpdisps
[] =
3111 {"del", "dstp", "dis", "keep"};
3112 static char bpenables
[] = "nynny";
3113 char wrap_indent
[80];
3115 struct ui_stream
*stb
= ui_out_stream_new (uiout
);
3116 struct cleanup
*old_chain
= make_cleanup_ui_out_stream_delete (stb
);
3121 ui_out_list_begin (uiout
, "bkpt");
3127 ui_out_field_int (uiout
, "number", b
->number
);
3129 printf_filtered ("%-3d ", b
->number
);
3134 if (((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
3135 || ((int) b
->type
!= bptypes
[(int) b
->type
].type
))
3136 internal_error ("bptypes table does not describe type #%d.",
3139 ui_out_field_string (uiout
, "type", bptypes
[(int) b
->type
].description
);
3141 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
3147 ui_out_field_string (uiout
, "disp", bpdisps
[(int) b
->disposition
]);
3149 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
3155 ui_out_field_fmt (uiout
, "enabled", "%c", bpenables
[(int) b
->enable
]);
3156 ui_out_spaces (uiout
, 2);
3158 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
3162 strcpy (wrap_indent
, " ");
3164 strcat (wrap_indent
, " ");
3168 internal_error ("print_one_breakpoint: bp_none encountered\n");
3172 case bp_hardware_watchpoint
:
3173 case bp_read_watchpoint
:
3174 case bp_access_watchpoint
:
3175 /* Field 4, the address, is omitted (which makes the columns
3176 not line up too nicely with the headers, but the effect
3177 is relatively readable). */
3180 ui_out_field_skip (uiout
, "addr");
3182 print_expression (b
->exp
, stb
->stream
);
3183 ui_out_field_stream (uiout
, "what", stb
);
3186 print_expression (b
->exp
, gdb_stdout
);
3191 case bp_catch_unload
:
3192 /* Field 4, the address, is omitted (which makes the columns
3193 not line up too nicely with the headers, but the effect
3194 is relatively readable). */
3197 ui_out_field_skip (uiout
, "addr");
3199 if (b
->dll_pathname
== NULL
)
3201 ui_out_field_string (uiout
, "what", "<any library>");
3202 ui_out_spaces (uiout
, 1);
3206 ui_out_text (uiout
, "library \"");
3207 ui_out_field_string (uiout
, "what", b
->dll_pathname
);
3208 ui_out_text (uiout
, "\" ");
3212 if (b
->dll_pathname
== NULL
)
3213 printf_filtered ("<any library> ");
3215 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
3220 case bp_catch_vfork
:
3221 /* Field 4, the address, is omitted (which makes the columns
3222 not line up too nicely with the headers, but the effect
3223 is relatively readable). */
3226 ui_out_field_skip (uiout
, "addr");
3228 if (b
->forked_inferior_pid
!= 0)
3230 ui_out_text (uiout
, "process ");
3231 ui_out_field_int (uiout
, "what", b
->forked_inferior_pid
);
3232 ui_out_spaces (uiout
, 1);
3236 if (b
->forked_inferior_pid
!= 0)
3237 printf_filtered ("process %d ", b
->forked_inferior_pid
);
3242 /* Field 4, the address, is omitted (which makes the columns
3243 not line up too nicely with the headers, but the effect
3244 is relatively readable). */
3247 ui_out_field_skip (uiout
, "addr");
3249 if (b
->exec_pathname
!= NULL
)
3251 ui_out_text (uiout
, "program \"");
3252 ui_out_field_string (uiout
, "what", b
->exec_pathname
);
3253 ui_out_text (uiout
, "\" ");
3257 if (b
->exec_pathname
!= NULL
)
3258 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
3262 case bp_catch_catch
:
3263 /* Field 4, the address, is omitted (which makes the columns
3264 not line up too nicely with the headers, but the effect
3265 is relatively readable). */
3268 ui_out_field_skip (uiout
, "addr");
3270 ui_out_field_string (uiout
, "what", "exception catch");
3271 ui_out_spaces (uiout
, 1);
3274 printf_filtered ("exception catch ");
3278 case bp_catch_throw
:
3279 /* Field 4, the address, is omitted (which makes the columns
3280 not line up too nicely with the headers, but the effect
3281 is relatively readable). */
3284 ui_out_field_skip (uiout
, "addr");
3286 ui_out_field_string (uiout
, "what", "exception throw");
3287 ui_out_spaces (uiout
, 1);
3290 printf_filtered ("exception throw ");
3295 case bp_hardware_breakpoint
:
3299 case bp_longjmp_resume
:
3300 case bp_step_resume
:
3301 case bp_through_sigtramp
:
3302 case bp_watchpoint_scope
:
3304 case bp_shlib_event
:
3305 case bp_thread_event
:
3310 ui_out_field_core_addr (uiout
, "addr", b
->address
);
3313 *last_addr
= b
->address
;
3316 sym
= find_pc_sect_function (b
->address
, b
->section
);
3319 ui_out_text (uiout
, "in ");
3320 ui_out_field_string (uiout
, "func",
3321 SYMBOL_SOURCE_NAME (sym
));
3322 ui_out_wrap_hint (uiout
, wrap_indent
);
3323 ui_out_text (uiout
, " at ");
3325 ui_out_field_string (uiout
, "file", b
->source_file
);
3326 ui_out_text (uiout
, ":");
3327 ui_out_field_int (uiout
, "line", b
->line_number
);
3331 print_address_symbolic (b
->address
, stb
->stream
, demangle
, "");
3332 ui_out_field_stream (uiout
, "at", stb
);
3338 /* FIXME-32x64: need a print_address_numeric with
3342 local_hex_string_custom
3343 ((unsigned long) b
->address
, "08l"));
3346 *last_addr
= b
->address
;
3349 sym
= find_pc_sect_function (b
->address
, b
->section
);
3352 fputs_filtered ("in ", gdb_stdout
);
3353 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3354 wrap_here (wrap_indent
);
3355 fputs_filtered (" at ", gdb_stdout
);
3357 fputs_filtered (b
->source_file
, gdb_stdout
);
3358 printf_filtered (":%d", b
->line_number
);
3361 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3366 if (b
->thread
!= -1)
3369 /* FIXME: This seems to be redundant and lost here; see the
3370 "stop only in" line a little further down. */
3371 ui_out_text (uiout
, " thread ");
3372 ui_out_field_int (uiout
, "thread", b
->thread
);
3374 printf_filtered (" thread %d", b
->thread
);
3379 ui_out_text (uiout
, "\n");
3381 printf_filtered ("\n");
3388 ui_out_text (uiout
, "\tstop only in stack frame at ");
3389 ui_out_field_core_addr (uiout
, "frame", b
->frame
);
3390 ui_out_text (uiout
, "\n");
3392 printf_filtered ("\tstop only in stack frame at ");
3393 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3394 printf_filtered ("\n");
3402 ui_out_text (uiout
, "\tstop only if ");
3403 print_expression (b
->cond
, stb
->stream
);
3404 ui_out_field_stream (uiout
, "cond", stb
);
3405 ui_out_text (uiout
, "\n");
3407 printf_filtered ("\tstop only if ");
3408 print_expression (b
->cond
, gdb_stdout
);
3409 printf_filtered ("\n");
3413 if (b
->thread
!= -1)
3415 /* FIXME should make an annotation for this */
3417 ui_out_text (uiout
, "\tstop only in thread ");
3418 ui_out_field_int (uiout
, "thread", b
->thread
);
3419 ui_out_text (uiout
, "\n");
3421 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3425 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3427 /* FIXME should make an annotation for this */
3429 if (ep_is_catchpoint (b
))
3430 ui_out_text (uiout
, "\tcatchpoint");
3432 ui_out_text (uiout
, "\tbreakpoint");
3433 ui_out_text (uiout
, " already hit ");
3434 ui_out_field_int (uiout
, "times", b
->hit_count
);
3435 if (b
->hit_count
== 1)
3436 ui_out_text (uiout
, " time\n");
3438 ui_out_text (uiout
, " times\n");
3440 if (ep_is_catchpoint (b
))
3441 printf_filtered ("\tcatchpoint");
3443 printf_filtered ("\tbreakpoint");
3444 printf_filtered (" already hit %d time%s\n",
3445 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3450 if (b
->ignore_count
)
3454 ui_out_text (uiout
, "\tignore next ");
3455 ui_out_field_int (uiout
, "ignore", b
->ignore_count
);
3456 ui_out_text (uiout
, " hits\n");
3458 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3462 if ((l
= b
->commands
))
3466 ui_out_list_begin (uiout
, "script");
3467 print_command_lines (uiout
, l
, 4);
3468 ui_out_list_end (uiout
);
3472 print_command_line (l
, 4, gdb_stdout
);
3478 ui_out_list_end (uiout
);
3479 do_cleanups (old_chain
);
3483 struct captured_breakpoint_query_args
3489 do_captured_breakpoint_query (void *data
)
3491 struct captured_breakpoint_query_args
*args
= data
;
3492 register struct breakpoint
*b
;
3493 CORE_ADDR dummy_addr
= 0;
3496 if (args
->bnum
== b
->number
)
3498 print_one_breakpoint (b
, &dummy_addr
);
3506 gdb_breakpoint_query (/* output object, */ int bnum
)
3508 struct captured_breakpoint_query_args args
;
3510 /* For the moment we don't trust print_one_breakpoint() to not throw
3512 return catch_errors (do_captured_breakpoint_query
, &args
,
3513 NULL
, RETURN_MASK_ALL
);
3516 /* Print information on breakpoint number BNUM, or -1 if all.
3517 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
3518 is nonzero, process only watchpoints. */
3521 breakpoint_1 (bnum
, allflag
)
3525 register struct breakpoint
*b
;
3526 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
3527 int found_a_breakpoint
= 0;
3531 ui_out_table_begin (uiout
, 6, "BreakpointTable");
3533 ui_out_table_begin (uiout
, 5, "BreakpointTable");
3538 || bnum
== b
->number
)
3540 /* We only print out user settable breakpoints unless the
3543 && b
->type
!= bp_breakpoint
3544 && b
->type
!= bp_catch_load
3545 && b
->type
!= bp_catch_unload
3546 && b
->type
!= bp_catch_fork
3547 && b
->type
!= bp_catch_vfork
3548 && b
->type
!= bp_catch_exec
3549 && b
->type
!= bp_catch_catch
3550 && b
->type
!= bp_catch_throw
3551 && b
->type
!= bp_hardware_breakpoint
3552 && b
->type
!= bp_watchpoint
3553 && b
->type
!= bp_read_watchpoint
3554 && b
->type
!= bp_access_watchpoint
3555 && b
->type
!= bp_hardware_watchpoint
)
3558 if (!found_a_breakpoint
++)
3560 annotate_breakpoints_headers ();
3563 ui_out_table_header (uiout
, 3, ui_left
, "Num"); /* 1 */
3565 ui_out_table_header (uiout
, 14, ui_left
, "Type"); /* 2 */
3567 ui_out_table_header (uiout
, 4, ui_left
, "Disp"); /* 3 */
3569 ui_out_table_header (uiout
, 3, ui_left
, "Enb"); /* 4 */
3573 ui_out_table_header (uiout
, 10, ui_left
, "Address"); /* 5 */
3576 ui_out_table_header (uiout
, 40, ui_noalign
, "What"); /* 6 */
3577 ui_out_table_body (uiout
);
3580 printf_filtered ("Num ");
3582 printf_filtered ("Type ");
3584 printf_filtered ("Disp ");
3586 printf_filtered ("Enb ");
3590 printf_filtered ("Address ");
3593 printf_filtered ("What\n");
3595 annotate_breakpoints_table ();
3598 print_one_breakpoint (b
, &last_addr
);
3601 if (!found_a_breakpoint
)
3605 ui_out_message (uiout
, 0, "No breakpoints or watchpoints.\n");
3607 ui_out_message (uiout
, 0, "No breakpoint or watchpoint number %d.\n",
3611 printf_filtered ("No breakpoints or watchpoints.\n");
3613 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3618 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3619 that a comparison of an unsigned with -1 is always false. */
3620 if (last_addr
!= (CORE_ADDR
) -1)
3621 set_next_address (last_addr
);
3625 ui_out_table_end (uiout
);
3627 /* FIXME? Should this be moved up so that it is only called when
3628 there have been breakpoints? */
3629 annotate_breakpoints_table_end ();
3634 breakpoints_info (bnum_exp
, from_tty
)
3641 bnum
= parse_and_eval_address (bnum_exp
);
3643 breakpoint_1 (bnum
, 0);
3648 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3655 bnum
= parse_and_eval_address (bnum_exp
);
3657 breakpoint_1 (bnum
, 1);
3660 /* Print a message describing any breakpoints set at PC. */
3663 describe_other_breakpoints (pc
, section
)
3667 register int others
= 0;
3668 register struct breakpoint
*b
;
3671 if (b
->address
== pc
)
3672 if (overlay_debugging
== 0 ||
3673 b
->section
== section
)
3677 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3679 if (b
->address
== pc
)
3680 if (overlay_debugging
== 0 ||
3681 b
->section
== section
)
3687 ((b
->enable
== disabled
||
3688 b
->enable
== shlib_disabled
||
3689 b
->enable
== call_disabled
) ? " (disabled)"
3690 : b
->enable
== permanent
? " (permanent)"
3692 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3694 printf_filtered ("also set at pc ");
3695 print_address_numeric (pc
, 1, gdb_stdout
);
3696 printf_filtered (".\n");
3700 /* Set the default place to put a breakpoint
3701 for the `break' command with no arguments. */
3704 set_default_breakpoint (valid
, addr
, symtab
, line
)
3707 struct symtab
*symtab
;
3710 default_breakpoint_valid
= valid
;
3711 default_breakpoint_address
= addr
;
3712 default_breakpoint_symtab
= symtab
;
3713 default_breakpoint_line
= line
;
3716 /* Rescan breakpoints at address ADDRESS,
3717 marking the first one as "first" and any others as "duplicates".
3718 This is so that the bpt instruction is only inserted once.
3719 If we have a permanent breakpoint at ADDRESS, make that one
3720 the official one, and the rest as duplicates. */
3723 check_duplicates (address
, section
)
3727 register struct breakpoint
*b
;
3728 register int count
= 0;
3729 struct breakpoint
*perm_bp
= 0;
3731 if (address
== 0) /* Watchpoints are uninteresting */
3735 if (b
->enable
!= disabled
3736 && b
->enable
!= shlib_disabled
3737 && b
->enable
!= call_disabled
3738 && b
->address
== address
3739 && (overlay_debugging
== 0 || b
->section
== section
))
3741 /* Have we found a permanent breakpoint? */
3742 if (b
->enable
== permanent
)
3749 b
->duplicate
= count
> 1;
3752 /* If we found a permanent breakpoint at this address, go over the
3753 list again and declare all the other breakpoints there to be the
3757 perm_bp
->duplicate
= 0;
3759 /* Permanent breakpoint should always be inserted. */
3760 if (! perm_bp
->inserted
)
3761 internal_error ("allegedly permanent breakpoint is not "
3762 "actually inserted");
3768 internal_error ("another breakpoint was inserted on top of "
3769 "a permanent breakpoint");
3771 if (b
->enable
!= disabled
3772 && b
->enable
!= shlib_disabled
3773 && b
->enable
!= call_disabled
3774 && b
->address
== address
3775 && (overlay_debugging
== 0 || b
->section
== section
))
3781 /* Low level routine to set a breakpoint.
3782 Takes as args the three things that every breakpoint must have.
3783 Returns the breakpoint object so caller can set other things.
3784 Does not set the breakpoint number!
3785 Does not print anything.
3787 ==> This routine should not be called if there is a chance of later
3788 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3789 your arguments BEFORE calling this routine! */
3792 set_raw_breakpoint (sal
)
3793 struct symtab_and_line sal
;
3795 register struct breakpoint
*b
, *b1
;
3797 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3798 memset (b
, 0, sizeof (*b
));
3799 b
->address
= sal
.pc
;
3800 if (sal
.symtab
== NULL
)
3801 b
->source_file
= NULL
;
3803 b
->source_file
= savestring (sal
.symtab
->filename
,
3804 strlen (sal
.symtab
->filename
));
3805 b
->section
= sal
.section
;
3806 b
->language
= current_language
->la_language
;
3807 b
->input_radix
= input_radix
;
3809 b
->line_number
= sal
.line
;
3810 b
->enable
= enabled
;
3813 b
->ignore_count
= 0;
3816 b
->dll_pathname
= NULL
;
3817 b
->triggered_dll_pathname
= NULL
;
3818 b
->forked_inferior_pid
= 0;
3819 b
->exec_pathname
= NULL
;
3821 /* Add this breakpoint to the end of the chain
3822 so that a list of breakpoints will come out in order
3823 of increasing numbers. */
3825 b1
= breakpoint_chain
;
3827 breakpoint_chain
= b
;
3835 check_duplicates (sal
.pc
, sal
.section
);
3836 breakpoints_changed ();
3842 /* Note that the breakpoint object B describes a permanent breakpoint
3843 instruction, hard-wired into the inferior's code. */
3845 make_breakpoint_permanent (struct breakpoint
*b
)
3847 b
->enable
= permanent
;
3849 /* By definition, permanent breakpoints are already present in the code. */
3853 #ifdef GET_LONGJMP_TARGET
3856 create_longjmp_breakpoint (func_name
)
3859 struct symtab_and_line sal
;
3860 struct breakpoint
*b
;
3862 INIT_SAL (&sal
); /* initialize to zeroes */
3863 if (func_name
!= NULL
)
3865 struct minimal_symbol
*m
;
3867 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3868 (struct objfile
*) NULL
);
3870 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3874 sal
.section
= find_pc_overlay (sal
.pc
);
3875 b
= set_raw_breakpoint (sal
);
3879 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3880 b
->disposition
= donttouch
;
3881 b
->enable
= disabled
;
3884 b
->addr_string
= strsave (func_name
);
3885 b
->number
= internal_breakpoint_number
--;
3888 #endif /* #ifdef GET_LONGJMP_TARGET */
3890 /* Call this routine when stepping and nexting to enable a breakpoint
3891 if we do a longjmp(). When we hit that breakpoint, call
3892 set_longjmp_resume_breakpoint() to figure out where we are going. */
3895 enable_longjmp_breakpoint ()
3897 register struct breakpoint
*b
;
3900 if (b
->type
== bp_longjmp
)
3902 b
->enable
= enabled
;
3903 check_duplicates (b
->address
, b
->section
);
3908 disable_longjmp_breakpoint ()
3910 register struct breakpoint
*b
;
3913 if (b
->type
== bp_longjmp
3914 || b
->type
== bp_longjmp_resume
)
3916 b
->enable
= disabled
;
3917 check_duplicates (b
->address
, b
->section
);
3922 create_thread_event_breakpoint (address
)
3925 struct breakpoint
*b
;
3926 struct symtab_and_line sal
;
3927 char addr_string
[80]; /* Surely an addr can't be longer than that. */
3929 INIT_SAL (&sal
); /* initialize to zeroes */
3931 sal
.section
= find_pc_overlay (sal
.pc
);
3932 if ((b
= set_raw_breakpoint (sal
)) == NULL
)
3935 b
->number
= internal_breakpoint_number
--;
3936 b
->disposition
= donttouch
;
3937 b
->type
= bp_thread_event
; /* XXX: do we need a new type?
3939 b
->enable
= enabled
;
3940 /* addr_string has to be used or breakpoint_re_set will delete me. */
3941 sprintf (addr_string
, "*0x%s", paddr (b
->address
));
3942 b
->addr_string
= strsave (addr_string
);
3948 remove_thread_event_breakpoints (void)
3950 struct breakpoint
*b
, *temp
;
3952 ALL_BREAKPOINTS_SAFE (b
, temp
)
3953 if (b
->type
== bp_thread_event
)
3954 delete_breakpoint (b
);
3959 remove_solib_event_breakpoints ()
3961 register struct breakpoint
*b
, *temp
;
3963 ALL_BREAKPOINTS_SAFE (b
, temp
)
3964 if (b
->type
== bp_shlib_event
)
3965 delete_breakpoint (b
);
3969 create_solib_event_breakpoint (address
)
3972 struct breakpoint
*b
;
3973 struct symtab_and_line sal
;
3975 INIT_SAL (&sal
); /* initialize to zeroes */
3977 sal
.section
= find_pc_overlay (sal
.pc
);
3978 b
= set_raw_breakpoint (sal
);
3979 b
->number
= internal_breakpoint_number
--;
3980 b
->disposition
= donttouch
;
3981 b
->type
= bp_shlib_event
;
3986 /* Disable any breakpoints that are on code in shared libraries. Only
3987 apply to enabled breakpoints, disabled ones can just stay disabled. */
3990 disable_breakpoints_in_shlibs (silent
)
3993 struct breakpoint
*b
;
3994 int disabled_shlib_breaks
= 0;
3996 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3999 #if defined (PC_SOLIB)
4000 if (((b
->type
== bp_breakpoint
) ||
4001 (b
->type
== bp_hardware_breakpoint
)) &&
4002 b
->enable
== enabled
&&
4004 PC_SOLIB (b
->address
))
4006 b
->enable
= shlib_disabled
;
4009 if (!disabled_shlib_breaks
)
4011 target_terminal_ours_for_output ();
4012 warning ("Temporarily disabling shared library breakpoints:");
4014 disabled_shlib_breaks
= 1;
4015 warning ("breakpoint #%d ", b
->number
);
4022 /* Try to reenable any breakpoints in shared libraries. */
4024 re_enable_breakpoints_in_shlibs ()
4026 struct breakpoint
*b
;
4029 if (b
->enable
== shlib_disabled
)
4033 /* Do not reenable the breakpoint if the shared library
4034 is still not mapped in. */
4035 if (target_read_memory (b
->address
, buf
, 1) == 0)
4036 b
->enable
= enabled
;
4043 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
4048 enum bptype bp_kind
;
4050 struct breakpoint
*b
;
4051 struct symtabs_and_lines sals
;
4052 struct cleanup
*old_chain
;
4053 struct cleanup
*canonical_strings_chain
= NULL
;
4054 char *addr_start
= hookname
;
4055 char *addr_end
= NULL
;
4056 char **canonical
= (char **) NULL
;
4057 int thread
= -1; /* All threads. */
4059 /* Set a breakpoint on the specified hook. */
4060 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
4061 addr_end
= hookname
;
4063 if (sals
.nelts
== 0)
4065 warning ("Unable to set a breakpoint on dynamic linker callback.");
4066 warning ("Suggest linking with /opt/langtools/lib/end.o.");
4067 warning ("GDB will be unable to track shl_load/shl_unload calls");
4070 if (sals
.nelts
!= 1)
4072 warning ("Unable to set unique breakpoint on dynamic linker callback.");
4073 warning ("GDB will be unable to track shl_load/shl_unload calls");
4077 /* Make sure that all storage allocated in decode_line_1 gets freed
4078 in case the following errors out. */
4079 old_chain
= make_cleanup (free
, sals
.sals
);
4080 if (canonical
!= (char **) NULL
)
4082 make_cleanup (free
, canonical
);
4083 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
4084 if (canonical
[0] != NULL
)
4085 make_cleanup (free
, canonical
[0]);
4088 resolve_sal_pc (&sals
.sals
[0]);
4090 /* Remove the canonical strings from the cleanup, they are needed below. */
4091 if (canonical
!= (char **) NULL
)
4092 discard_cleanups (canonical_strings_chain
);
4094 b
= set_raw_breakpoint (sals
.sals
[0]);
4095 set_breakpoint_count (breakpoint_count
+ 1);
4096 b
->number
= breakpoint_count
;
4098 b
->cond_string
= (cond_string
== NULL
) ?
4099 NULL
: savestring (cond_string
, strlen (cond_string
));
4102 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
4103 b
->addr_string
= canonical
[0];
4104 else if (addr_start
)
4105 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4107 b
->enable
= enabled
;
4108 b
->disposition
= tempflag
? del
: donttouch
;
4110 if (dll_pathname
== NULL
)
4111 b
->dll_pathname
= NULL
;
4114 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
4115 strcpy (b
->dll_pathname
, dll_pathname
);
4120 do_cleanups (old_chain
);
4124 create_solib_load_event_breakpoint (hookname
, tempflag
,
4125 dll_pathname
, cond_string
)
4131 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
4132 cond_string
, bp_catch_load
);
4136 create_solib_unload_event_breakpoint (hookname
, tempflag
,
4137 dll_pathname
, cond_string
)
4143 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
4144 cond_string
, bp_catch_unload
);
4148 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
4151 enum bptype bp_kind
;
4153 struct symtab_and_line sal
;
4154 struct breakpoint
*b
;
4155 int thread
= -1; /* All threads. */
4162 b
= set_raw_breakpoint (sal
);
4163 set_breakpoint_count (breakpoint_count
+ 1);
4164 b
->number
= breakpoint_count
;
4166 b
->cond_string
= (cond_string
== NULL
) ?
4167 NULL
: savestring (cond_string
, strlen (cond_string
));
4169 b
->addr_string
= NULL
;
4170 b
->enable
= enabled
;
4171 b
->disposition
= tempflag
? del
: donttouch
;
4172 b
->forked_inferior_pid
= 0;
4180 create_fork_event_catchpoint (tempflag
, cond_string
)
4184 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
4188 create_vfork_event_catchpoint (tempflag
, cond_string
)
4192 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
4196 create_exec_event_catchpoint (tempflag
, cond_string
)
4200 struct symtab_and_line sal
;
4201 struct breakpoint
*b
;
4202 int thread
= -1; /* All threads. */
4209 b
= set_raw_breakpoint (sal
);
4210 set_breakpoint_count (breakpoint_count
+ 1);
4211 b
->number
= breakpoint_count
;
4213 b
->cond_string
= (cond_string
== NULL
) ?
4214 NULL
: savestring (cond_string
, strlen (cond_string
));
4216 b
->addr_string
= NULL
;
4217 b
->enable
= enabled
;
4218 b
->disposition
= tempflag
? del
: donttouch
;
4220 b
->type
= bp_catch_exec
;
4226 hw_breakpoint_used_count ()
4228 register struct breakpoint
*b
;
4233 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
4241 hw_watchpoint_used_count (type
, other_type_used
)
4243 int *other_type_used
;
4245 register struct breakpoint
*b
;
4248 *other_type_used
= 0;
4251 if (b
->enable
== enabled
)
4253 if (b
->type
== type
)
4255 else if ((b
->type
== bp_hardware_watchpoint
||
4256 b
->type
== bp_read_watchpoint
||
4257 b
->type
== bp_access_watchpoint
)
4258 && b
->enable
== enabled
)
4259 *other_type_used
= 1;
4265 /* Call this after hitting the longjmp() breakpoint. Use this to set
4266 a new breakpoint at the target of the jmp_buf.
4268 FIXME - This ought to be done by setting a temporary breakpoint
4269 that gets deleted automatically... */
4272 set_longjmp_resume_breakpoint (pc
, frame
)
4274 struct frame_info
*frame
;
4276 register struct breakpoint
*b
;
4279 if (b
->type
== bp_longjmp_resume
)
4282 b
->enable
= enabled
;
4284 b
->frame
= frame
->frame
;
4287 check_duplicates (b
->address
, b
->section
);
4293 disable_watchpoints_before_interactive_call_start ()
4295 struct breakpoint
*b
;
4299 if (((b
->type
== bp_watchpoint
)
4300 || (b
->type
== bp_hardware_watchpoint
)
4301 || (b
->type
== bp_read_watchpoint
)
4302 || (b
->type
== bp_access_watchpoint
)
4303 || ep_is_exception_catchpoint (b
))
4304 && (b
->enable
== enabled
))
4306 b
->enable
= call_disabled
;
4307 check_duplicates (b
->address
, b
->section
);
4313 enable_watchpoints_after_interactive_call_stop ()
4315 struct breakpoint
*b
;
4319 if (((b
->type
== bp_watchpoint
)
4320 || (b
->type
== bp_hardware_watchpoint
)
4321 || (b
->type
== bp_read_watchpoint
)
4322 || (b
->type
== bp_access_watchpoint
)
4323 || ep_is_exception_catchpoint (b
))
4324 && (b
->enable
== call_disabled
))
4326 b
->enable
= enabled
;
4327 check_duplicates (b
->address
, b
->section
);
4333 /* Set a breakpoint that will evaporate an end of command
4334 at address specified by SAL.
4335 Restrict it to frame FRAME if FRAME is nonzero. */
4338 set_momentary_breakpoint (sal
, frame
, type
)
4339 struct symtab_and_line sal
;
4340 struct frame_info
*frame
;
4343 register struct breakpoint
*b
;
4344 b
= set_raw_breakpoint (sal
);
4346 b
->enable
= enabled
;
4347 b
->disposition
= donttouch
;
4348 b
->frame
= (frame
? frame
->frame
: 0);
4350 /* If we're debugging a multi-threaded program, then we
4351 want momentary breakpoints to be active in only a
4352 single thread of control. */
4353 if (in_thread_list (inferior_pid
))
4354 b
->thread
= pid_to_thread_id (inferior_pid
);
4360 /* Tell the user we have just set a breakpoint B. */
4364 struct breakpoint
*b
;
4368 struct cleanup
*old_chain
;
4369 struct ui_stream
*stb
;
4371 stb
= ui_out_stream_new (uiout
);
4372 old_chain
= make_cleanup ((make_cleanup_func
) ui_out_stream_delete
, stb
);
4375 /* FIXME: This is misplaced; mention() is called by things (like hitting a
4376 watchpoint) other than breakpoint creation. It should be possible to
4377 clean this up and at the same time replace the random calls to
4378 breakpoint_changed with this hook, as has already been done for
4379 delete_breakpoint_hook and so on. */
4380 if (create_breakpoint_hook
)
4381 create_breakpoint_hook (b
);
4382 breakpoint_create_event (b
->number
);
4387 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
4391 ui_out_text (uiout
, "Watchpoint ");
4392 ui_out_list_begin (uiout
, "wpt");
4393 ui_out_field_int (uiout
, "number", b
->number
);
4394 ui_out_text (uiout
, ": ");
4395 print_expression (b
->exp
, stb
->stream
);
4396 ui_out_field_stream (uiout
, "exp", stb
);
4397 ui_out_list_end (uiout
);
4399 case bp_hardware_watchpoint
:
4400 ui_out_text (uiout
, "Hardware watchpoint ");
4401 ui_out_list_begin (uiout
, "wpt");
4402 ui_out_field_int (uiout
, "number", b
->number
);
4403 ui_out_text (uiout
, ": ");
4404 print_expression (b
->exp
, stb
->stream
);
4405 ui_out_field_stream (uiout
, "exp", stb
);
4406 ui_out_list_end (uiout
);
4410 printf_filtered ("Watchpoint %d: ", b
->number
);
4411 print_expression (b
->exp
, gdb_stdout
);
4413 case bp_hardware_watchpoint
:
4414 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
4415 print_expression (b
->exp
, gdb_stdout
);
4419 case bp_read_watchpoint
:
4420 ui_out_text (uiout
, "Hardware read watchpoint ");
4421 ui_out_list_begin (uiout
, "hw-rwpt");
4422 ui_out_field_int (uiout
, "number", b
->number
);
4423 ui_out_text (uiout
, ": ");
4424 print_expression (b
->exp
, stb
->stream
);
4425 ui_out_field_stream (uiout
, "exp", stb
);
4426 ui_out_list_end (uiout
);
4428 case bp_access_watchpoint
:
4429 ui_out_text (uiout
, "Hardware access (read/write) watchpoint ");
4430 ui_out_list_begin (uiout
, "hw-awpt");
4431 ui_out_field_int (uiout
, "number", b
->number
);
4432 ui_out_text (uiout
, ": ");
4433 print_expression (b
->exp
, stb
->stream
);
4434 ui_out_field_stream (uiout
, "exp", stb
);
4435 ui_out_list_end (uiout
);
4438 case bp_read_watchpoint
:
4439 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
4440 print_expression (b
->exp
, gdb_stdout
);
4442 case bp_access_watchpoint
:
4443 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
4445 print_expression (b
->exp
, gdb_stdout
);
4449 printf_filtered ("Breakpoint %d", b
->number
);
4452 case bp_hardware_breakpoint
:
4453 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
4457 case bp_catch_unload
:
4458 printf_filtered ("Catchpoint %d (%s %s)",
4460 (b
->type
== bp_catch_load
) ? "load" : "unload",
4461 (b
->dll_pathname
!= NULL
) ?
4462 b
->dll_pathname
: "<any library>");
4465 case bp_catch_vfork
:
4466 printf_filtered ("Catchpoint %d (%s)",
4468 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
4471 printf_filtered ("Catchpoint %d (exec)",
4474 case bp_catch_catch
:
4475 case bp_catch_throw
:
4476 printf_filtered ("Catchpoint %d (%s)",
4478 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
4484 case bp_longjmp_resume
:
4485 case bp_step_resume
:
4486 case bp_through_sigtramp
:
4488 case bp_watchpoint_scope
:
4489 case bp_shlib_event
:
4490 case bp_thread_event
:
4495 if (addressprint
|| b
->source_file
== NULL
)
4497 printf_filtered (" at ");
4498 print_address_numeric (b
->address
, 1, gdb_stdout
);
4501 printf_filtered (": file %s, line %d.",
4502 b
->source_file
, b
->line_number
);
4503 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
4504 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
4507 do_cleanups (old_chain
);
4509 printf_filtered ("\n");
4513 /* Add SALS.nelts breakpoints to the breakpoint table. For each
4514 SALS.sal[i] breakpoint, include the corresponding ADDR_STRING[i],
4515 COND[i] and COND_STRING[i] values.
4517 NOTE: If the function succeeds, the caller is expected to cleanup
4518 the arrays ADDR_STRING, COND_STRING, COND and SALS (but not the
4519 array contents). If the function fails (error() is called), the
4520 caller is expected to cleanups both the ADDR_STRING, COND_STRING,
4521 COND and SALS arrays and each of those arrays contents. */
4524 create_breakpoints (struct symtabs_and_lines sals
, char **addr_string
,
4525 struct expression
**cond
, char **cond_string
,
4526 enum bptype type
, enum bpdisp disposition
,
4527 int thread
, int ignore_count
, int from_tty
)
4529 if (type
== bp_hardware_breakpoint
)
4531 int i
= hw_breakpoint_used_count ();
4532 int target_resources_ok
=
4533 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4535 if (target_resources_ok
== 0)
4536 error ("No hardware breakpoint support in the target.");
4537 else if (target_resources_ok
< 0)
4538 error ("Hardware breakpoints used exceeds limit.");
4541 /* Now set all the breakpoints. */
4544 for (i
= 0; i
< sals
.nelts
; i
++)
4546 struct breakpoint
*b
;
4547 struct symtab_and_line sal
= sals
.sals
[i
];
4550 describe_other_breakpoints (sal
.pc
, sal
.section
);
4552 b
= set_raw_breakpoint (sal
);
4553 set_breakpoint_count (breakpoint_count
+ 1);
4554 b
->number
= breakpoint_count
;
4558 b
->addr_string
= addr_string
[i
];
4559 b
->cond_string
= cond_string
[i
];
4560 b
->ignore_count
= ignore_count
;
4561 b
->enable
= enabled
;
4562 b
->disposition
= disposition
;
4568 /* Parse ARG which is assumed to be a SAL specification possibly
4569 followed by conditionals. On return, SALS contains an array of SAL
4570 addresses found. ADDR_STRING contains a vector of (canonical)
4571 address strings. ARG points to the end of the SAL. */
4574 parse_breakpoint_sals (char **address
,
4575 struct symtabs_and_lines
*sals
,
4576 char ***addr_string
)
4578 char *addr_start
= *address
;
4579 *addr_string
= NULL
;
4580 /* If no arg given, or if first arg is 'if ', use the default
4582 if ((*address
) == NULL
4583 || (strncmp ((*address
), "if", 2) == 0 && isspace ((*address
)[2])))
4585 if (default_breakpoint_valid
)
4587 struct symtab_and_line sal
;
4588 INIT_SAL (&sal
); /* initialize to zeroes */
4589 sals
->sals
= (struct symtab_and_line
*)
4590 xmalloc (sizeof (struct symtab_and_line
));
4591 sal
.pc
= default_breakpoint_address
;
4592 sal
.line
= default_breakpoint_line
;
4593 sal
.symtab
= default_breakpoint_symtab
;
4594 sal
.section
= find_pc_overlay (sal
.pc
);
4595 sals
->sals
[0] = sal
;
4599 error ("No default breakpoint address now.");
4603 /* Force almost all breakpoints to be in terms of the
4604 current_source_symtab (which is decode_line_1's default). This
4605 should produce the results we want almost all of the time while
4606 leaving default_breakpoint_* alone. */
4607 if (default_breakpoint_valid
4608 && (!current_source_symtab
4609 || (strchr ("+-", (*address
)[0]) != NULL
)))
4610 *sals
= decode_line_1 (address
, 1, default_breakpoint_symtab
,
4611 default_breakpoint_line
, addr_string
);
4613 *sals
= decode_line_1 (address
, 1, (struct symtab
*) NULL
, 0, addr_string
);
4615 /* For any SAL that didn't have a canonical string, fill one in. */
4616 if (sals
->nelts
> 0 && *addr_string
== NULL
)
4617 *addr_string
= xcalloc (sals
->nelts
, sizeof (char **));
4618 if (addr_start
!= (*address
))
4621 for (i
= 0; i
< sals
->nelts
; i
++)
4623 /* Add the string if not present. */
4624 if ((*addr_string
)[i
] == NULL
)
4625 (*addr_string
)[i
] = savestring (addr_start
, (*address
) - addr_start
);
4631 /* Convert each SAL into a real PC. Verify that the PC can be
4632 inserted as a breakpoint. If it can't throw an error. */
4635 breakpoint_sals_to_pc (struct symtabs_and_lines
*sals
,
4639 for (i
= 0; i
< sals
->nelts
; i
++)
4641 resolve_sal_pc (&sals
->sals
[i
]);
4643 /* It's possible for the PC to be nonzero, but still an illegal
4644 value on some targets.
4646 For example, on HP-UX if you start gdb, and before running the
4647 inferior you try to set a breakpoint on a shared library function
4648 "foo" where the inferior doesn't call "foo" directly but does
4649 pass its address to another function call, then we do find a
4650 minimal symbol for the "foo", but it's address is invalid.
4651 (Appears to be an index into a table that the loader sets up
4652 when the inferior is run.)
4654 Give the target a chance to bless sals.sals[i].pc before we
4655 try to make a breakpoint for it. */
4656 if (PC_REQUIRES_RUN_BEFORE_USE (sals
->sals
[i
].pc
))
4658 if (address
== NULL
)
4659 error ("Cannot break without a running program.");
4661 error ("Cannot break on %s without a running program.",
4667 /* Set a breakpoint according to ARG (function, linenum or *address)
4668 flag: first bit : 0 non-temporary, 1 temporary.
4669 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
4672 break_command_1 (arg
, flag
, from_tty
)
4676 int tempflag
, hardwareflag
;
4677 struct symtabs_and_lines sals
;
4678 register struct expression
**cond
= 0;
4679 /* Pointers in arg to the start, and one past the end, of the
4681 char **cond_string
= (char **) NULL
;
4682 char *addr_start
= arg
;
4684 struct cleanup
*old_chain
;
4685 struct cleanup
*breakpoint_chain
= NULL
;
4688 int ignore_count
= 0;
4690 hardwareflag
= flag
& BP_HARDWAREFLAG
;
4691 tempflag
= flag
& BP_TEMPFLAG
;
4696 parse_breakpoint_sals (&arg
, &sals
, &addr_string
);
4701 /* Create a chain of things that always need to be cleaned up. */
4702 old_chain
= make_cleanup (null_cleanup
, 0);
4704 /* Make sure that all storage allocated to SALS gets freed. */
4705 make_cleanup (free
, sals
.sals
);
4707 /* Cleanup the addr_string array but not its contents. */
4708 make_cleanup (free
, addr_string
);
4710 /* Allocate space for all the cond expressions. */
4711 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4712 make_cleanup (free
, cond
);
4714 /* Allocate space for all the cond strings. */
4715 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4716 make_cleanup (free
, cond_string
);
4718 /* ----------------------------- SNIP -----------------------------
4719 Anything added to the cleanup chain beyond this point is assumed
4720 to be part of a breakpoint. If the breakpoint create succeeds
4721 then the memory is not reclaimed. */
4722 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4724 /* Mark the contents of the addr_string for cleanup. These go on
4725 the breakpoint_chain and only occure if the breakpoint create
4727 for (i
= 0; i
< sals
.nelts
; i
++)
4729 if (addr_string
[i
] != NULL
)
4730 make_cleanup (free
, addr_string
[i
]);
4733 /* Resolve all line numbers to PC's and verify that the addresses
4734 are ok for the target. */
4735 breakpoint_sals_to_pc (&sals
, addr_start
);
4737 /* Verify that condition can be parsed, before setting any
4738 breakpoints. Allocate a separate condition expression for each
4740 thread
= -1; /* No specific thread yet */
4741 for (i
= 0; i
< sals
.nelts
; i
++)
4748 char *cond_start
= NULL
;
4749 char *cond_end
= NULL
;
4750 while (*tok
== ' ' || *tok
== '\t')
4755 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4758 toklen
= end_tok
- tok
;
4760 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4762 tok
= cond_start
= end_tok
+ 1;
4763 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4764 make_cleanup (free
, cond
[i
]);
4766 cond_string
[i
] = savestring (cond_start
, cond_end
- cond_start
);
4767 make_cleanup (free
, cond_string
[i
]);
4769 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4775 thread
= strtol (tok
, &tok
, 0);
4777 error ("Junk after thread keyword.");
4778 if (!valid_thread_id (thread
))
4779 error ("Unknown thread %d\n", thread
);
4782 error ("Junk at end of arguments.");
4786 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
4787 hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
4788 tempflag
? del
: donttouch
,
4789 thread
, ignore_count
, from_tty
);
4793 warning ("Multiple breakpoints were set.");
4794 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4796 /* That's it. Discard the cleanups for data inserted into the
4798 discard_cleanups (breakpoint_chain
);
4799 /* But cleanup everything else. */
4800 do_cleanups (old_chain
);
4803 /* Set a breakpoint of TYPE/DISPOSITION according to ARG (function,
4804 linenum or *address) with COND and IGNORE_COUNT. */
4806 struct captured_breakpoint_args
4817 do_captured_breakpoint (void *data
)
4819 struct captured_breakpoint_args
*args
= data
;
4820 struct symtabs_and_lines sals
;
4821 register struct expression
**cond
;
4822 struct cleanup
*old_chain
;
4823 struct cleanup
*breakpoint_chain
= NULL
;
4830 /* Parse the source and lines spec. Delay check that the expression
4831 didn't contain trailing garbage until after cleanups are in
4835 address_end
= args
->address
;
4837 parse_breakpoint_sals (&address_end
, &sals
, &addr_string
);
4842 /* Create a chain of things at always need to be cleaned up. */
4843 old_chain
= make_cleanup (null_cleanup
, 0);
4845 /* Always have a addr_string array, even if it is empty. */
4846 make_cleanup (free
, addr_string
);
4848 /* Make sure that all storage allocated to SALS gets freed. */
4849 make_cleanup (free
, sals
.sals
);
4851 /* Allocate space for all the cond expressions. */
4852 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4853 make_cleanup (free
, cond
);
4855 /* Allocate space for all the cond strings. */
4856 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4857 make_cleanup (free
, cond_string
);
4859 /* ----------------------------- SNIP -----------------------------
4860 Anything added to the cleanup chain beyond this point is assumed
4861 to be part of a breakpoint. If the breakpoint create goes
4862 through then that memory is not cleaned up. */
4863 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4865 /* Mark the contents of the addr_string for cleanup. These go on
4866 the breakpoint_chain and only occure if the breakpoint create
4868 for (i
= 0; i
< sals
.nelts
; i
++)
4870 if (addr_string
[i
] != NULL
)
4871 make_cleanup (free
, addr_string
[i
]);
4874 /* Wait until now before checking for garbage at the end of the
4875 address. That way cleanups can take care of freeing any
4877 if (*address_end
!= '\0')
4878 error ("Garbage %s following breakpoint address", address_end
);
4880 /* Resolve all line numbers to PC's. */
4881 breakpoint_sals_to_pc (&sals
, args
->address
);
4883 /* Verify that conditions can be parsed, before setting any
4885 for (i
= 0; i
< sals
.nelts
; i
++)
4887 if (args
->condition
!= NULL
)
4889 char *tok
= args
->condition
;
4890 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4892 error ("Garbage %s follows condition", tok
);
4893 make_cleanup (free
, cond
[i
]);
4894 cond_string
[i
] = xstrdup (args
->condition
);
4898 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
4899 args
->hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
4900 args
->tempflag
? del
: donttouch
,
4901 args
->thread
, args
->ignore_count
, 0/*from-tty*/);
4903 /* That's it. Discard the cleanups for data inserted into the
4905 discard_cleanups (breakpoint_chain
);
4906 /* But cleanup everything else. */
4907 do_cleanups (old_chain
);
4912 gdb_breakpoint (char *address
, char *condition
,
4913 int hardwareflag
, int tempflag
,
4914 int thread
, int ignore_count
)
4916 struct captured_breakpoint_args args
;
4917 args
.address
= address
;
4918 args
.condition
= condition
;
4919 args
.hardwareflag
= hardwareflag
;
4920 args
.tempflag
= tempflag
;
4921 args
.thread
= thread
;
4922 args
.ignore_count
= ignore_count
;
4923 return catch_errors (do_captured_breakpoint
, &args
,
4924 NULL
, RETURN_MASK_ALL
);
4929 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4934 struct frame_info
*frame
;
4935 CORE_ADDR low
, high
, selected_pc
= 0;
4936 char *extra_args
, *level_arg
, *addr_string
;
4937 int extra_args_len
= 0, if_arg
= 0;
4940 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4943 if (default_breakpoint_valid
)
4947 selected_pc
= selected_frame
->pc
;
4952 error ("No selected frame.");
4955 error ("No default breakpoint address now.");
4959 extra_args
= strchr (arg
, ' ');
4963 extra_args_len
= strlen (extra_args
);
4964 level_arg
= (char *) xmalloc (extra_args
- arg
);
4965 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4966 level_arg
[extra_args
- arg
- 1] = '\0';
4970 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4971 strcpy (level_arg
, arg
);
4974 frame
= parse_frame_specification (level_arg
);
4976 selected_pc
= frame
->pc
;
4983 extra_args_len
= strlen (arg
);
4988 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4990 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4992 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4994 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4995 break_command_1 (addr_string
, flag
, from_tty
);
4999 error ("No function contains the specified address");
5002 error ("Unable to set breakpoint at procedure exit");
5007 break_at_finish_command_1 (arg
, flag
, from_tty
)
5012 char *addr_string
, *break_string
, *beg_addr_string
;
5013 CORE_ADDR low
, high
;
5014 struct symtabs_and_lines sals
;
5015 struct symtab_and_line sal
;
5016 struct cleanup
*old_chain
;
5018 int extra_args_len
= 0;
5022 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
5024 if (default_breakpoint_valid
)
5028 addr_string
= (char *) xmalloc (15);
5029 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
5034 error ("No selected frame.");
5037 error ("No default breakpoint address now.");
5041 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
5042 strcpy (addr_string
, arg
);
5048 extra_args_len
= strlen (arg
);
5052 /* get the stuff after the function name or address */
5053 extra_args
= strchr (arg
, ' ');
5057 extra_args_len
= strlen (extra_args
);
5064 beg_addr_string
= addr_string
;
5065 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
5068 free (beg_addr_string
);
5069 old_chain
= make_cleanup (free
, sals
.sals
);
5070 for (i
= 0; (i
< sals
.nelts
); i
++)
5073 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
5075 break_string
= (char *) xmalloc (extra_args_len
+ 26);
5077 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
5079 sprintf (break_string
, "*0x%s", paddr_nz (high
));
5080 break_command_1 (break_string
, flag
, from_tty
);
5081 free (break_string
);
5084 error ("No function contains the specified address");
5088 warning ("Multiple breakpoints were set.\n");
5089 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5091 do_cleanups (old_chain
);
5095 /* Helper function for break_command_1 and disassemble_command. */
5098 resolve_sal_pc (sal
)
5099 struct symtab_and_line
*sal
;
5103 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
5105 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
5106 error ("No line %d in file \"%s\".",
5107 sal
->line
, sal
->symtab
->filename
);
5111 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
5113 struct blockvector
*bv
;
5118 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
5121 b
= BLOCKVECTOR_BLOCK (bv
, index
);
5122 sym
= block_function (b
);
5125 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
5126 sal
->section
= SYMBOL_BFD_SECTION (sym
);
5130 /* It really is worthwhile to have the section, so we'll just
5131 have to look harder. This case can be executed if we have
5132 line numbers but no functions (as can happen in assembly
5135 struct minimal_symbol
*msym
;
5137 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
5139 sal
->section
= SYMBOL_BFD_SECTION (msym
);
5146 break_command (arg
, from_tty
)
5150 break_command_1 (arg
, 0, from_tty
);
5154 break_at_finish_command (arg
, from_tty
)
5158 break_at_finish_command_1 (arg
, 0, from_tty
);
5162 break_at_finish_at_depth_command (arg
, from_tty
)
5166 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
5170 tbreak_command (arg
, from_tty
)
5174 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
5178 tbreak_at_finish_command (arg
, from_tty
)
5182 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
5186 hbreak_command (arg
, from_tty
)
5190 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
5194 thbreak_command (arg
, from_tty
)
5198 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
5202 stop_command (arg
, from_tty
)
5206 printf_filtered ("Specify the type of breakpoint to set.\n\
5207 Usage: stop in <function | address>\n\
5212 stopin_command (arg
, from_tty
)
5218 if (arg
== (char *) NULL
)
5220 else if (*arg
!= '*')
5225 /* look for a ':'. If this is a line number specification, then
5226 say it is bad, otherwise, it should be an address or
5227 function/method name */
5228 while (*argptr
&& !hasColon
)
5230 hasColon
= (*argptr
== ':');
5235 badInput
= (*argptr
!= ':'); /* Not a class::method */
5237 badInput
= isdigit (*arg
); /* a simple line number */
5241 printf_filtered ("Usage: stop in <function | address>\n");
5243 break_command_1 (arg
, 0, from_tty
);
5247 stopat_command (arg
, from_tty
)
5253 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
5260 /* look for a ':'. If there is a '::' then get out, otherwise
5261 it is probably a line number. */
5262 while (*argptr
&& !hasColon
)
5264 hasColon
= (*argptr
== ':');
5269 badInput
= (*argptr
== ':'); /* we have class::method */
5271 badInput
= !isdigit (*arg
); /* not a line number */
5275 printf_filtered ("Usage: stop at <line>\n");
5277 break_command_1 (arg
, 0, from_tty
);
5281 /* accessflag: hw_write: watch write,
5282 hw_read: watch read,
5283 hw_access: watch access (read or write) */
5285 watch_command_1 (arg
, accessflag
, from_tty
)
5290 struct breakpoint
*b
;
5291 struct symtab_and_line sal
;
5292 struct expression
*exp
;
5293 struct block
*exp_valid_block
;
5294 struct value
*val
, *mark
;
5295 struct frame_info
*frame
;
5296 struct frame_info
*prev_frame
= NULL
;
5297 char *exp_start
= NULL
;
5298 char *exp_end
= NULL
;
5299 char *tok
, *end_tok
;
5301 char *cond_start
= NULL
;
5302 char *cond_end
= NULL
;
5303 struct expression
*cond
= NULL
;
5304 int i
, other_type_used
, target_resources_ok
= 0;
5305 enum bptype bp_type
;
5308 INIT_SAL (&sal
); /* initialize to zeroes */
5310 /* Parse arguments. */
5311 innermost_block
= NULL
;
5313 exp
= parse_exp_1 (&arg
, 0, 0);
5315 exp_valid_block
= innermost_block
;
5316 mark
= value_mark ();
5317 val
= evaluate_expression (exp
);
5318 release_value (val
);
5319 if (VALUE_LAZY (val
))
5320 value_fetch_lazy (val
);
5323 while (*tok
== ' ' || *tok
== '\t')
5327 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
5330 toklen
= end_tok
- tok
;
5331 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
5333 tok
= cond_start
= end_tok
+ 1;
5334 cond
= parse_exp_1 (&tok
, 0, 0);
5338 error ("Junk at end of command.");
5340 if (accessflag
== hw_read
)
5341 bp_type
= bp_read_watchpoint
;
5342 else if (accessflag
== hw_access
)
5343 bp_type
= bp_access_watchpoint
;
5345 bp_type
= bp_hardware_watchpoint
;
5347 mem_cnt
= can_use_hardware_watchpoint (val
);
5348 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
5349 error ("Expression cannot be implemented with read/access watchpoint.");
5352 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
5353 target_resources_ok
=
5354 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
5356 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
5357 error ("Target does not support this type of hardware watchpoint.");
5359 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
5360 error ("Target can only support one kind of HW watchpoint at a time.");
5363 #if defined(HPUXHPPA)
5364 /* On HP-UX if you set a h/w
5365 watchpoint before the "run" command, the inferior dies with a e.g.,
5366 SIGILL once you start it. I initially believed this was due to a
5367 bad interaction between page protection traps and the initial
5368 startup sequence by the dynamic linker.
5370 However, I tried avoiding that by having HP-UX's implementation of
5371 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
5372 yet, which forced slow watches before a "run" or "attach", and it
5373 still fails somewhere in the startup code.
5375 Until I figure out what's happening, I'm disallowing watches altogether
5376 before the "run" or "attach" command. We'll tell the user they must
5377 set watches after getting the program started. */
5378 if (!target_has_execution
)
5380 warning ("can't do that without a running program; try \"break main\", \"run\" first");
5383 #endif /* HPUXHPPA */
5385 /* Now set up the breakpoint. */
5386 b
= set_raw_breakpoint (sal
);
5387 set_breakpoint_count (breakpoint_count
+ 1);
5388 b
->number
= breakpoint_count
;
5389 b
->disposition
= donttouch
;
5391 b
->exp_valid_block
= exp_valid_block
;
5392 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
5396 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
5400 frame
= block_innermost_frame (exp_valid_block
);
5403 prev_frame
= get_prev_frame (frame
);
5404 b
->watchpoint_frame
= frame
->frame
;
5407 b
->watchpoint_frame
= (CORE_ADDR
) 0;
5409 if (mem_cnt
&& target_resources_ok
> 0)
5412 b
->type
= bp_watchpoint
;
5414 /* If the expression is "local", then set up a "watchpoint scope"
5415 breakpoint at the point where we've left the scope of the watchpoint
5417 if (innermost_block
)
5421 struct breakpoint
*scope_breakpoint
;
5422 struct symtab_and_line scope_sal
;
5424 INIT_SAL (&scope_sal
); /* initialize to zeroes */
5425 scope_sal
.pc
= get_frame_pc (prev_frame
);
5426 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
5428 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
5429 set_breakpoint_count (breakpoint_count
+ 1);
5430 scope_breakpoint
->number
= breakpoint_count
;
5432 scope_breakpoint
->type
= bp_watchpoint_scope
;
5433 scope_breakpoint
->enable
= enabled
;
5435 /* Automatically delete the breakpoint when it hits. */
5436 scope_breakpoint
->disposition
= del
;
5438 /* Only break in the proper frame (help with recursion). */
5439 scope_breakpoint
->frame
= prev_frame
->frame
;
5441 /* Set the address at which we will stop. */
5442 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
5444 /* The scope breakpoint is related to the watchpoint. We
5445 will need to act on them together. */
5446 b
->related_breakpoint
= scope_breakpoint
;
5449 value_free_to_mark (mark
);
5453 /* Return count of locations need to be watched and can be handled
5454 in hardware. If the watchpoint can not be handled
5455 in hardware return zero. */
5457 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
5458 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
5459 ((BYTE_SIZE) <= (REGISTER_SIZE))
5462 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
5463 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
5464 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
5468 can_use_hardware_watchpoint (v
)
5471 int found_memory_cnt
= 0;
5473 /* Did the user specifically forbid us to use hardware watchpoints? */
5474 if (!can_use_hw_watchpoints
)
5477 /* Make sure that the value of the expression depends only upon
5478 memory contents, and values computed from them within GDB. If we
5479 find any register references or function calls, we can't use a
5480 hardware watchpoint.
5482 The idea here is that evaluating an expression generates a series
5483 of values, one holding the value of every subexpression. (The
5484 expression a*b+c has five subexpressions: a, b, a*b, c, and
5485 a*b+c.) GDB's values hold almost enough information to establish
5486 the criteria given above --- they identify memory lvalues,
5487 register lvalues, computed values, etcetera. So we can evaluate
5488 the expression, and then scan the chain of values that leaves
5489 behind to decide whether we can detect any possible change to the
5490 expression's final value using only hardware watchpoints.
5492 However, I don't think that the values returned by inferior
5493 function calls are special in any way. So this function may not
5494 notice that an expression involving an inferior function call
5495 can't be watched with hardware watchpoints. FIXME. */
5496 for (; v
; v
= v
->next
)
5498 if (VALUE_LVAL (v
) == lval_memory
)
5501 /* A lazy memory lvalue is one that GDB never needed to fetch;
5502 we either just used its address (e.g., `a' in `a.b') or
5503 we never needed it at all (e.g., `a' in `a,b'). */
5507 /* Ahh, memory we actually used! Check if we can cover
5508 it with hardware watchpoints. */
5509 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
5510 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
5512 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
5518 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
5519 return 0; /* ??? What does this represent? */
5520 else if (v
->lval
== lval_register
)
5521 return 0; /* cannot watch a register with a HW watchpoint */
5524 /* The expression itself looks suitable for using a hardware
5525 watchpoint, but give the target machine a chance to reject it. */
5526 return found_memory_cnt
;
5531 watch_command_wrapper (arg
, from_tty
)
5535 watch_command (arg
, from_tty
);
5539 watch_command (arg
, from_tty
)
5543 watch_command_1 (arg
, hw_write
, from_tty
);
5548 rwatch_command_wrapper (arg
, from_tty
)
5552 rwatch_command (arg
, from_tty
);
5556 rwatch_command (arg
, from_tty
)
5560 watch_command_1 (arg
, hw_read
, from_tty
);
5565 awatch_command_wrapper (arg
, from_tty
)
5569 awatch_command (arg
, from_tty
);
5573 awatch_command (arg
, from_tty
)
5577 watch_command_1 (arg
, hw_access
, from_tty
);
5581 /* Helper routines for the until_command routine in infcmd.c. Here
5582 because it uses the mechanisms of breakpoints. */
5584 /* This function is called by fetch_inferior_event via the
5585 cmd_continuation pointer, to complete the until command. It takes
5586 care of cleaning up the temporary breakpoints set up by the until
5589 until_break_command_continuation (struct continuation_arg
*arg
)
5591 struct cleanup
*cleanups
;
5593 cleanups
= (struct cleanup
*) arg
->data
;
5594 do_exec_cleanups (cleanups
);
5599 until_break_command (arg
, from_tty
)
5603 struct symtabs_and_lines sals
;
5604 struct symtab_and_line sal
;
5605 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
5606 struct breakpoint
*breakpoint
;
5607 struct cleanup
*old_chain
;
5608 struct continuation_arg
*arg1
;
5611 clear_proceed_status ();
5613 /* Set a breakpoint where the user wants it and at return from
5616 if (default_breakpoint_valid
)
5617 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
5618 default_breakpoint_line
, (char ***) NULL
);
5620 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
5621 0, (char ***) NULL
);
5623 if (sals
.nelts
!= 1)
5624 error ("Couldn't get information on specified line.");
5627 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
5630 error ("Junk at end of arguments.");
5632 resolve_sal_pc (&sal
);
5634 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
5636 if (!event_loop_p
|| !target_can_async_p ())
5637 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
5640 old_chain
= make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5642 /* If we are running asynchronously, and the target supports async
5643 execution, we are not waiting for the target to stop, in the call
5644 tp proceed, below. This means that we cannot delete the
5645 brekpoints until the target has actually stopped. The only place
5646 where we get a chance to do that is in fetch_inferior_event, so
5647 we must set things up for that. */
5649 if (event_loop_p
&& target_can_async_p ())
5651 /* In this case the arg for the continuation is just the point
5652 in the exec_cleanups chain from where to start doing
5653 cleanups, because all the continuation does is the cleanups in
5654 the exec_cleanup_chain. */
5656 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
5658 arg1
->data
= (PTR
) old_chain
;
5660 add_continuation (until_break_command_continuation
, arg1
);
5663 /* Keep within the current frame */
5667 sal
= find_pc_line (prev_frame
->pc
, 0);
5668 sal
.pc
= prev_frame
->pc
;
5669 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
5670 if (!event_loop_p
|| !target_can_async_p ())
5671 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5673 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5676 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
5677 /* Do the cleanups now, anly if we are not running asynchronously,
5678 of if we are, but the target is still synchronous. */
5679 if (!event_loop_p
|| !target_can_async_p ())
5680 do_cleanups (old_chain
);
5684 /* These aren't used; I don't konw what they were for. */
5685 /* Set a breakpoint at the catch clause for NAME. */
5687 catch_breakpoint (name
)
5693 disable_catch_breakpoint ()
5698 delete_catch_breakpoint ()
5703 enable_catch_breakpoint ()
5710 struct sal_chain
*next
;
5711 struct symtab_and_line sal
;
5715 /* Not really used -- invocation in handle_gnu_4_16_catch_command
5716 had been commented out in the v.4.16 sources, and stays
5717 disabled there now because "catch NAME" syntax isn't allowed.
5719 /* This isn't used; I don't know what it was for. */
5720 /* For each catch clause identified in ARGS, run FUNCTION
5721 with that clause as an argument. */
5722 static struct symtabs_and_lines
5723 map_catch_names (args
, function
)
5727 register char *p
= args
;
5729 struct symtabs_and_lines sals
;
5731 struct sal_chain
*sal_chain
= 0;
5735 error_no_arg ("one or more catch names");
5743 /* Don't swallow conditional part. */
5744 if (p1
[0] == 'i' && p1
[1] == 'f'
5745 && (p1
[2] == ' ' || p1
[2] == '\t'))
5751 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
5755 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
5756 error ("Arguments must be catch names.");
5762 struct sal_chain
*next
= (struct sal_chain
*)
5763 alloca (sizeof (struct sal_chain
));
5764 next
->next
= sal_chain
;
5765 next
->sal
= get_catch_sal (p
);
5770 printf_unfiltered ("No catch clause for exception %s.\n", p
);
5775 while (*p
== ' ' || *p
== '\t')
5781 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
5783 static struct symtabs_and_lines
5784 get_catch_sals (this_level_only
)
5785 int this_level_only
;
5787 register struct blockvector
*bl
;
5788 register struct block
*block
;
5789 int index
, have_default
= 0;
5791 struct symtabs_and_lines sals
;
5792 struct sal_chain
*sal_chain
= 0;
5793 char *blocks_searched
;
5795 /* Not sure whether an error message is always the correct response,
5796 but it's better than a core dump. */
5797 if (selected_frame
== NULL
)
5798 error ("No selected frame.");
5799 block
= get_frame_block (selected_frame
);
5800 pc
= selected_frame
->pc
;
5806 error ("No symbol table info available.\n");
5808 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
5809 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5810 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5814 CORE_ADDR end
= BLOCK_END (block
) - 4;
5817 if (bl
!= blockvector_for_pc (end
, &index
))
5818 error ("blockvector blotch");
5819 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
5820 error ("blockvector botch");
5821 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
5824 /* Don't print out blocks that have gone by. */
5825 while (index
< last_index
5826 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
5829 while (index
< last_index
5830 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
5832 if (blocks_searched
[index
] == 0)
5834 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
5837 register struct symbol
*sym
;
5839 nsyms
= BLOCK_NSYMS (b
);
5841 for (i
= 0; i
< nsyms
; i
++)
5843 sym
= BLOCK_SYM (b
, i
);
5844 if (STREQ (SYMBOL_NAME (sym
), "default"))
5850 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
5852 struct sal_chain
*next
= (struct sal_chain
*)
5853 alloca (sizeof (struct sal_chain
));
5854 next
->next
= sal_chain
;
5855 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
5860 blocks_searched
[index
] = 1;
5866 if (sal_chain
&& this_level_only
)
5869 /* After handling the function's top-level block, stop.
5870 Don't continue to its superblock, the block of
5871 per-file symbols. */
5872 if (BLOCK_FUNCTION (block
))
5874 block
= BLOCK_SUPERBLOCK (block
);
5879 struct sal_chain
*tmp_chain
;
5881 /* Count the number of entries. */
5882 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
5883 tmp_chain
= tmp_chain
->next
)
5887 sals
.sals
= (struct symtab_and_line
*)
5888 xmalloc (index
* sizeof (struct symtab_and_line
));
5889 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5890 sals
.sals
[index
] = sal_chain
->sal
;
5897 ep_skip_leading_whitespace (s
)
5900 if ((s
== NULL
) || (*s
== NULL
))
5902 while (isspace (**s
))
5906 /* This function examines a string, and attempts to find a token
5907 that might be an event name in the leading characters. If a
5908 possible match is found, a pointer to the last character of
5909 the token is returned. Else, NULL is returned. */
5912 ep_find_event_name_end (arg
)
5916 char *event_name_end
= NULL
;
5918 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5922 /* We break out of the loop when we find a token delimiter.
5923 Basically, we're looking for alphanumerics and underscores;
5924 anything else delimites the token. */
5927 if (!isalnum (*s
) && (*s
!= '_'))
5933 return event_name_end
;
5937 /* This function attempts to parse an optional "if <cond>" clause
5938 from the arg string. If one is not found, it returns NULL.
5940 Else, it returns a pointer to the condition string. (It does not
5941 attempt to evaluate the string against a particular block.) And,
5942 it updates arg to point to the first character following the parsed
5943 if clause in the arg string. */
5946 ep_parse_optional_if_clause (arg
)
5951 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5954 /* Skip the "if" keyword. */
5957 /* Skip any extra leading whitespace, and record the start of the
5958 condition string. */
5959 ep_skip_leading_whitespace (arg
);
5962 /* Assume that the condition occupies the remainder of the arg string. */
5963 (*arg
) += strlen (cond_string
);
5968 /* This function attempts to parse an optional filename from the arg
5969 string. If one is not found, it returns NULL.
5971 Else, it returns a pointer to the parsed filename. (This function
5972 makes no attempt to verify that a file of that name exists, or is
5973 accessible.) And, it updates arg to point to the first character
5974 following the parsed filename in the arg string.
5976 Note that clients needing to preserve the returned filename for
5977 future access should copy it to their own buffers. */
5979 ep_parse_optional_filename (arg
)
5982 static char filename
[1024];
5987 if ((*arg_p
== '\0') || isspace (*arg_p
))
6005 /* Commands to deal with catching events, such as signals, exceptions,
6006 process start/exit, etc. */
6010 catch_fork
, catch_vfork
6014 #if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
6015 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
6021 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
6022 catch_fork_kind fork_kind
;
6027 char *cond_string
= NULL
;
6029 ep_skip_leading_whitespace (&arg
);
6031 /* The allowed syntax is:
6033 catch [v]fork if <cond>
6035 First, check if there's an if clause. */
6036 cond_string
= ep_parse_optional_if_clause (&arg
);
6038 if ((*arg
!= '\0') && !isspace (*arg
))
6039 error ("Junk at end of arguments.");
6041 /* If this target supports it, create a fork or vfork catchpoint
6042 and enable reporting of such events. */
6046 create_fork_event_catchpoint (tempflag
, cond_string
);
6049 create_vfork_event_catchpoint (tempflag
, cond_string
);
6052 error ("unsupported or unknown fork kind; cannot catch it");
6058 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
6060 catch_exec_command_1 (arg
, tempflag
, from_tty
)
6065 char *cond_string
= NULL
;
6067 ep_skip_leading_whitespace (&arg
);
6069 /* The allowed syntax is:
6071 catch exec if <cond>
6073 First, check if there's an if clause. */
6074 cond_string
= ep_parse_optional_if_clause (&arg
);
6076 if ((*arg
!= '\0') && !isspace (*arg
))
6077 error ("Junk at end of arguments.");
6079 /* If this target supports it, create an exec catchpoint
6080 and enable reporting of such events. */
6081 create_exec_event_catchpoint (tempflag
, cond_string
);
6085 #if defined(SOLIB_ADD)
6087 catch_load_command_1 (arg
, tempflag
, from_tty
)
6092 char *dll_pathname
= NULL
;
6093 char *cond_string
= NULL
;
6095 ep_skip_leading_whitespace (&arg
);
6097 /* The allowed syntax is:
6099 catch load if <cond>
6100 catch load <filename>
6101 catch load <filename> if <cond>
6103 The user is not allowed to specify the <filename> after an
6106 We'll ignore the pathological case of a file named "if".
6108 First, check if there's an if clause. If so, then there
6109 cannot be a filename. */
6110 cond_string
= ep_parse_optional_if_clause (&arg
);
6112 /* If there was an if clause, then there cannot be a filename.
6113 Else, there might be a filename and an if clause. */
6114 if (cond_string
== NULL
)
6116 dll_pathname
= ep_parse_optional_filename (&arg
);
6117 ep_skip_leading_whitespace (&arg
);
6118 cond_string
= ep_parse_optional_if_clause (&arg
);
6121 if ((*arg
!= '\0') && !isspace (*arg
))
6122 error ("Junk at end of arguments.");
6124 /* Create a load breakpoint that only triggers when a load of
6125 the specified dll (or any dll, if no pathname was specified)
6127 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
6128 dll_pathname
, cond_string
);
6132 catch_unload_command_1 (arg
, tempflag
, from_tty
)
6137 char *dll_pathname
= NULL
;
6138 char *cond_string
= NULL
;
6140 ep_skip_leading_whitespace (&arg
);
6142 /* The allowed syntax is:
6144 catch unload if <cond>
6145 catch unload <filename>
6146 catch unload <filename> if <cond>
6148 The user is not allowed to specify the <filename> after an
6151 We'll ignore the pathological case of a file named "if".
6153 First, check if there's an if clause. If so, then there
6154 cannot be a filename. */
6155 cond_string
= ep_parse_optional_if_clause (&arg
);
6157 /* If there was an if clause, then there cannot be a filename.
6158 Else, there might be a filename and an if clause. */
6159 if (cond_string
== NULL
)
6161 dll_pathname
= ep_parse_optional_filename (&arg
);
6162 ep_skip_leading_whitespace (&arg
);
6163 cond_string
= ep_parse_optional_if_clause (&arg
);
6166 if ((*arg
!= '\0') && !isspace (*arg
))
6167 error ("Junk at end of arguments.");
6169 /* Create an unload breakpoint that only triggers when an unload of
6170 the specified dll (or any dll, if no pathname was specified)
6172 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
6173 dll_pathname
, cond_string
);
6175 #endif /* SOLIB_ADD */
6177 /* Commands to deal with catching exceptions. */
6179 /* Set a breakpoint at the specified callback routine for an
6180 exception event callback */
6183 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
6186 enum exception_event_kind ex_event
;
6187 struct symtab_and_line
*sal
;
6189 struct breakpoint
*b
;
6190 int thread
= -1; /* All threads. */
6192 if (!sal
) /* no exception support? */
6195 b
= set_raw_breakpoint (*sal
);
6196 set_breakpoint_count (breakpoint_count
+ 1);
6197 b
->number
= breakpoint_count
;
6199 b
->cond_string
= (cond_string
== NULL
) ?
6200 NULL
: savestring (cond_string
, strlen (cond_string
));
6202 b
->addr_string
= NULL
;
6203 b
->enable
= enabled
;
6204 b
->disposition
= tempflag
? del
: donttouch
;
6207 case EX_EVENT_THROW
:
6208 b
->type
= bp_catch_throw
;
6210 case EX_EVENT_CATCH
:
6211 b
->type
= bp_catch_catch
;
6213 default: /* error condition */
6215 b
->enable
= disabled
;
6216 error ("Internal error -- invalid catchpoint kind");
6221 /* Deal with "catch catch" and "catch throw" commands */
6224 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
6225 enum exception_event_kind ex_event
;
6230 char *cond_string
= NULL
;
6231 struct symtab_and_line
*sal
= NULL
;
6233 ep_skip_leading_whitespace (&arg
);
6235 cond_string
= ep_parse_optional_if_clause (&arg
);
6237 if ((*arg
!= '\0') && !isspace (*arg
))
6238 error ("Junk at end of arguments.");
6240 if ((ex_event
!= EX_EVENT_THROW
) &&
6241 (ex_event
!= EX_EVENT_CATCH
))
6242 error ("Unsupported or unknown exception event; cannot catch it");
6244 /* See if we can find a callback routine */
6245 sal
= target_enable_exception_callback (ex_event
, 1);
6249 /* We have callbacks from the runtime system for exceptions.
6250 Set a breakpoint on the sal found, if no errors */
6251 if (sal
!= (struct symtab_and_line
*) -1)
6252 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
6254 return; /* something went wrong with setting up callbacks */
6258 /* No callbacks from runtime system for exceptions.
6259 Try GNU C++ exception breakpoints using labels in debug info. */
6260 if (ex_event
== EX_EVENT_CATCH
)
6262 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
6264 else if (ex_event
== EX_EVENT_THROW
)
6266 /* Set a breakpoint on __raise_exception () */
6268 warning ("Unsupported with this platform/compiler combination.");
6269 warning ("Perhaps you can achieve the effect you want by setting");
6270 warning ("a breakpoint on __raise_exception().");
6275 /* Cover routine to allow wrapping target_enable_exception_catchpoints
6276 inside a catch_errors */
6279 cover_target_enable_exception_callback (arg
)
6282 args_for_catchpoint_enable
*args
= arg
;
6283 struct symtab_and_line
*sal
;
6284 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
6287 else if (sal
== (struct symtab_and_line
*) -1)
6290 return 1; /*is valid */
6295 /* This is the original v.4.16 and earlier version of the
6296 catch_command_1() function. Now that other flavours of "catch"
6297 have been introduced, and since exception handling can be handled
6298 in other ways (through target ops) also, this is used only for the
6299 GNU C++ exception handling system.
6300 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
6301 "catch NAME" is now no longer allowed in catch_command_1(). Also,
6302 there was no code in GDB 4.16 for "catch throw".
6304 Called from catch_exception_command_1 () */
6308 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
6313 /* First, translate ARG into something we can deal with in terms
6316 struct symtabs_and_lines sals
;
6317 struct symtab_and_line sal
;
6318 register struct expression
*cond
= 0;
6319 register struct breakpoint
*b
;
6323 INIT_SAL (&sal
); /* initialize to zeroes */
6325 /* If no arg given, or if first arg is 'if ', all active catch clauses
6326 are breakpointed. */
6328 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
6329 && (arg
[2] == ' ' || arg
[2] == '\t')))
6331 /* Grab all active catch clauses. */
6332 sals
= get_catch_sals (0);
6336 /* Grab selected catch clauses. */
6337 error ("catch NAME not implemented");
6340 /* Not sure why this code has been disabled. I'm leaving
6341 it disabled. We can never come here now anyway
6342 since we don't allow the "catch NAME" syntax.
6345 /* This isn't used; I don't know what it was for. */
6346 sals
= map_catch_names (arg
, catch_breakpoint
);
6354 for (i
= 0; i
< sals
.nelts
; i
++)
6356 resolve_sal_pc (&sals
.sals
[i
]);
6360 if (arg
[0] == 'i' && arg
[1] == 'f'
6361 && (arg
[2] == ' ' || arg
[2] == '\t'))
6362 cond
= parse_exp_1 ((arg
+= 2, &arg
),
6363 block_for_pc (sals
.sals
[i
].pc
), 0);
6365 error ("Junk at end of arguments.");
6370 for (i
= 0; i
< sals
.nelts
; i
++)
6375 describe_other_breakpoints (sal
.pc
, sal
.section
);
6377 b
= set_raw_breakpoint (sal
);
6378 set_breakpoint_count (breakpoint_count
+ 1);
6379 b
->number
= breakpoint_count
;
6381 /* Important -- this is an ordinary breakpoint. For platforms
6382 with callback support for exceptions,
6383 create_exception_catchpoint() will create special bp types
6384 (bp_catch_catch and bp_catch_throw), and there is code in
6385 insert_breakpoints() and elsewhere that depends on that. */
6386 b
->type
= bp_breakpoint
;
6389 b
->enable
= enabled
;
6390 b
->disposition
= tempflag
? del
: donttouch
;
6397 warning ("Multiple breakpoints were set.");
6398 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
6400 free ((PTR
) sals
.sals
);
6404 /* This creates a temporary internal breakpoint
6405 just to placate infrun */
6406 static struct breakpoint
*
6407 create_temp_exception_breakpoint (pc
)
6410 struct symtab_and_line sal
;
6411 struct breakpoint
*b
;
6418 b
= set_raw_breakpoint (sal
);
6420 error ("Internal error -- couldn't set temp exception breakpoint");
6422 b
->type
= bp_breakpoint
;
6423 b
->disposition
= del
;
6424 b
->enable
= enabled
;
6426 b
->number
= internal_breakpoint_number
--;
6432 catch_command_1 (arg
, tempflag
, from_tty
)
6438 /* The first argument may be an event name, such as "start" or "load".
6439 If so, then handle it as such. If it doesn't match an event name,
6440 then attempt to interpret it as an exception name. (This latter is
6441 the v4.16-and-earlier GDB meaning of the "catch" command.)
6443 First, try to find the bounds of what might be an event name. */
6444 char *arg1_start
= arg
;
6448 if (arg1_start
== NULL
)
6450 /* Old behaviour was to use pre-v-4.16 syntax */
6451 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6453 /* Now, this is not allowed */
6454 error ("Catch requires an event name.");
6457 arg1_end
= ep_find_event_name_end (arg1_start
);
6458 if (arg1_end
== NULL
)
6459 error ("catch requires an event");
6460 arg1_length
= arg1_end
+ 1 - arg1_start
;
6462 /* Try to match what we found against known event names. */
6463 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
6465 error ("Catch of signal not yet implemented");
6467 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
6469 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
6470 tempflag
, from_tty
);
6472 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
6474 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
6475 tempflag
, from_tty
);
6477 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
6479 error ("Catch of thread_start not yet implemented");
6481 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
6483 error ("Catch of thread_exit not yet implemented");
6485 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
6487 error ("Catch of thread_join not yet implemented");
6489 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
6491 error ("Catch of start not yet implemented");
6493 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
6495 error ("Catch of exit not yet implemented");
6497 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
6499 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
6500 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
6502 error ("Catch of fork not yet implemented");
6505 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
6507 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
6508 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
6510 error ("Catch of vfork not yet implemented");
6513 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
6515 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
6516 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6518 error ("Catch of exec not yet implemented");
6521 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
6523 #if defined(SOLIB_ADD)
6524 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6526 error ("Catch of load not implemented");
6529 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
6531 #if defined(SOLIB_ADD)
6532 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6534 error ("Catch of load not implemented");
6537 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
6539 error ("Catch of stop not yet implemented");
6542 /* This doesn't appear to be an event name */
6546 /* Pre-v.4.16 behaviour was to treat the argument
6547 as the name of an exception */
6548 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6549 /* Now this is not allowed */
6550 error ("Unknown event kind specified for catch");
6555 /* Used by the gui, could be made a worker for other things. */
6558 set_breakpoint_sal (sal
)
6559 struct symtab_and_line sal
;
6561 struct breakpoint
*b
;
6562 b
= set_raw_breakpoint (sal
);
6563 set_breakpoint_count (breakpoint_count
+ 1);
6564 b
->number
= breakpoint_count
;
6565 b
->type
= bp_breakpoint
;
6572 /* These aren't used; I don't know what they were for. */
6573 /* Disable breakpoints on all catch clauses described in ARGS. */
6575 disable_catch (args
)
6578 /* Map the disable command to catch clauses described in ARGS. */
6581 /* Enable breakpoints on all catch clauses described in ARGS. */
6586 /* Map the disable command to catch clauses described in ARGS. */
6589 /* Delete breakpoints on all catch clauses in the active scope. */
6594 /* Map the delete command to catch clauses described in ARGS. */
6599 catch_command (arg
, from_tty
)
6603 catch_command_1 (arg
, 0, from_tty
);
6608 tcatch_command (arg
, from_tty
)
6612 catch_command_1 (arg
, 1, from_tty
);
6617 clear_command (arg
, from_tty
)
6621 register struct breakpoint
*b
, *b1
;
6623 struct symtabs_and_lines sals
;
6624 struct symtab_and_line sal
;
6625 register struct breakpoint
*found
;
6630 sals
= decode_line_spec (arg
, 1);
6635 sals
.sals
= (struct symtab_and_line
*)
6636 xmalloc (sizeof (struct symtab_and_line
));
6637 INIT_SAL (&sal
); /* initialize to zeroes */
6638 sal
.line
= default_breakpoint_line
;
6639 sal
.symtab
= default_breakpoint_symtab
;
6640 sal
.pc
= default_breakpoint_address
;
6641 if (sal
.symtab
== 0)
6642 error ("No source file specified.");
6650 /* For each line spec given, delete bps which correspond
6651 to it. We do this in two loops: the first loop looks at
6652 the initial bp(s) in the chain which should be deleted,
6653 the second goes down the rest of the chain looking ahead
6654 one so it can take those bps off the chain without messing
6658 for (i
= 0; i
< sals
.nelts
; i
++)
6660 /* If exact pc given, clear bpts at that pc.
6661 If line given (pc == 0), clear all bpts on specified line.
6662 If defaulting, clear all bpts on default line
6665 defaulting sal.pc != 0 tests to do
6670 1 0 <can't happen> */
6673 found
= (struct breakpoint
*) 0;
6676 while (breakpoint_chain
6677 /* Why don't we check here that this is not
6678 a watchpoint, etc., as we do below?
6679 I can't make it fail, but don't know
6680 what's stopping the failure: a watchpoint
6681 of the same address as "sal.pc" should
6682 wind up being deleted. */
6684 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
6685 (overlay_debugging
== 0 ||
6686 breakpoint_chain
->section
== sal
.section
))
6687 || ((default_match
|| (0 == sal
.pc
))
6688 && breakpoint_chain
->source_file
!= NULL
6689 && sal
.symtab
!= NULL
6690 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
6691 && breakpoint_chain
->line_number
== sal
.line
)))
6694 b1
= breakpoint_chain
;
6695 breakpoint_chain
= b1
->next
;
6703 && b
->next
->type
!= bp_none
6704 && b
->next
->type
!= bp_watchpoint
6705 && b
->next
->type
!= bp_hardware_watchpoint
6706 && b
->next
->type
!= bp_read_watchpoint
6707 && b
->next
->type
!= bp_access_watchpoint
6708 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
6709 (overlay_debugging
== 0 ||
6710 b
->next
->section
== sal
.section
))
6711 || ((default_match
|| (0 == sal
.pc
))
6712 && b
->next
->source_file
!= NULL
6713 && sal
.symtab
!= NULL
6714 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
6715 && b
->next
->line_number
== sal
.line
)))
6728 error ("No breakpoint at %s.", arg
);
6730 error ("No breakpoint at this line.");
6734 from_tty
= 1; /* Always report if deleted more than one */
6736 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
6737 breakpoints_changed ();
6741 printf_unfiltered ("%d ", found
->number
);
6743 delete_breakpoint (found
);
6747 putchar_unfiltered ('\n');
6749 free ((PTR
) sals
.sals
);
6752 /* Delete breakpoint in BS if they are `delete' breakpoints and
6753 all breakpoints that are marked for deletion, whether hit or not.
6754 This is called after any breakpoint is hit, or after errors. */
6757 breakpoint_auto_delete (bs
)
6760 struct breakpoint
*b
, *temp
;
6762 for (; bs
; bs
= bs
->next
)
6763 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
6765 delete_breakpoint (bs
->breakpoint_at
);
6767 ALL_BREAKPOINTS_SAFE (b
, temp
)
6769 if (b
->disposition
== del_at_next_stop
)
6770 delete_breakpoint (b
);
6774 /* Delete a breakpoint and clean up all traces of it in the data
6778 delete_breakpoint (bpt
)
6779 struct breakpoint
*bpt
;
6781 register struct breakpoint
*b
;
6785 error ("Internal error (attempted to delete a NULL breakpoint)");
6788 /* Has this bp already been deleted? This can happen because multiple
6789 lists can hold pointers to bp's. bpstat lists are especial culprits.
6791 One example of this happening is a watchpoint's scope bp. When the
6792 scope bp triggers, we notice that the watchpoint is out of scope, and
6793 delete it. We also delete its scope bp. But the scope bp is marked
6794 "auto-deleting", and is already on a bpstat. That bpstat is then
6795 checked for auto-deleting bp's, which are deleted.
6797 A real solution to this problem might involve reference counts in bp's,
6798 and/or giving them pointers back to their referencing bpstat's, and
6799 teaching delete_breakpoint to only free a bp's storage when no more
6800 references were extent. A cheaper bandaid was chosen. */
6801 if (bpt
->type
== bp_none
)
6804 if (delete_breakpoint_hook
)
6805 delete_breakpoint_hook (bpt
);
6806 breakpoint_delete_event (bpt
->number
);
6809 remove_breakpoint (bpt
, mark_uninserted
);
6811 if (breakpoint_chain
== bpt
)
6812 breakpoint_chain
= bpt
->next
;
6814 /* If we have callback-style exception catchpoints, don't go through
6815 the adjustments to the C++ runtime library etc. if the inferior
6816 isn't actually running. target_enable_exception_callback for a
6817 null target ops vector gives an undesirable error message, so we
6818 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
6819 exceptions are supported in this way, it's OK for now. FIXME */
6820 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
6822 static char message1
[] = "Error in deleting catchpoint %d:\n";
6823 static char message
[sizeof (message1
) + 30];
6824 args_for_catchpoint_enable args
;
6826 /* Format possible error msg */
6827 sprintf (message
, message1
, bpt
->number
);
6828 args
.kind
= bpt
->type
== bp_catch_catch
?
6829 EX_EVENT_CATCH
: EX_EVENT_THROW
;
6831 catch_errors (cover_target_enable_exception_callback
, &args
,
6832 message
, RETURN_MASK_ALL
);
6839 b
->next
= bpt
->next
;
6843 /* Before turning off the visuals for the bp, check to see that
6844 there are no other bps at the same address. */
6851 clearIt
= (b
->address
!= bpt
->address
);
6858 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
6859 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
6863 check_duplicates (bpt
->address
, bpt
->section
);
6864 /* If this breakpoint was inserted, and there is another breakpoint
6865 at the same address, we need to insert the other breakpoint. */
6867 && bpt
->type
!= bp_hardware_watchpoint
6868 && bpt
->type
!= bp_read_watchpoint
6869 && bpt
->type
!= bp_access_watchpoint
6870 && bpt
->type
!= bp_catch_fork
6871 && bpt
->type
!= bp_catch_vfork
6872 && bpt
->type
!= bp_catch_exec
)
6875 if (b
->address
== bpt
->address
6876 && b
->section
== bpt
->section
6878 && b
->enable
!= disabled
6879 && b
->enable
!= shlib_disabled
6880 && b
->enable
!= call_disabled
)
6884 /* We should never reach this point if there is a permanent
6885 breakpoint at the same address as the one being deleted.
6886 If there is a permanent breakpoint somewhere, it should
6887 always be the only one inserted. */
6888 if (b
->enable
== permanent
)
6889 internal_error ("another breakpoint was inserted on top of "
6890 "a permanent breakpoint");
6892 if (b
->type
== bp_hardware_breakpoint
)
6893 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6895 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6899 target_terminal_ours_for_output ();
6900 warning ("Cannot insert breakpoint %d:", b
->number
);
6901 memory_error (val
, b
->address
); /* which bombs us out */
6908 free_command_lines (&bpt
->commands
);
6911 if (bpt
->cond_string
!= NULL
)
6912 free (bpt
->cond_string
);
6913 if (bpt
->addr_string
!= NULL
)
6914 free (bpt
->addr_string
);
6915 if (bpt
->exp
!= NULL
)
6917 if (bpt
->exp_string
!= NULL
)
6918 free (bpt
->exp_string
);
6919 if (bpt
->val
!= NULL
)
6920 value_free (bpt
->val
);
6921 if (bpt
->source_file
!= NULL
)
6922 free (bpt
->source_file
);
6923 if (bpt
->dll_pathname
!= NULL
)
6924 free (bpt
->dll_pathname
);
6925 if (bpt
->triggered_dll_pathname
!= NULL
)
6926 free (bpt
->triggered_dll_pathname
);
6927 if (bpt
->exec_pathname
!= NULL
)
6928 free (bpt
->exec_pathname
);
6930 /* Be sure no bpstat's are pointing at it after it's been freed. */
6931 /* FIXME, how can we find all bpstat's?
6932 We just check stop_bpstat for now. */
6933 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6934 if (bs
->breakpoint_at
== bpt
)
6936 bs
->breakpoint_at
= NULL
;
6938 /* we'd call bpstat_clear_actions, but that free's stuff and due
6939 to the multiple pointers pointing to one item with no
6940 reference counts found anywhere through out the bpstat's (how
6941 do you spell fragile?), we don't want to free things twice --
6942 better a memory leak than a corrupt malloc pool! */
6943 bs
->commands
= NULL
;
6946 /* On the chance that someone will soon try again to delete this same
6947 bp, we mark it as deleted before freeing its storage. */
6948 bpt
->type
= bp_none
;
6954 delete_command (arg
, from_tty
)
6958 struct breakpoint
*b
, *temp
;
6962 int breaks_to_delete
= 0;
6964 /* Delete all breakpoints if no argument.
6965 Do not delete internal or call-dummy breakpoints, these
6966 have to be deleted with an explicit breakpoint number argument. */
6969 if (b
->type
!= bp_call_dummy
&&
6970 b
->type
!= bp_shlib_event
&&
6971 b
->type
!= bp_thread_event
&&
6973 breaks_to_delete
= 1;
6976 /* Ask user only if there are some breakpoints to delete. */
6978 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6980 ALL_BREAKPOINTS_SAFE (b
, temp
)
6982 if (b
->type
!= bp_call_dummy
&&
6983 b
->type
!= bp_shlib_event
&&
6984 b
->type
!= bp_thread_event
&&
6986 delete_breakpoint (b
);
6991 map_breakpoint_numbers (arg
, delete_breakpoint
);
6994 /* Reset a breakpoint given it's struct breakpoint * BINT.
6995 The value we return ends up being the return value from catch_errors.
6996 Unused in this case. */
6999 breakpoint_re_set_one (bint
)
7002 /* get past catch_errs */
7003 struct breakpoint
*b
= (struct breakpoint
*) bint
;
7006 struct symtabs_and_lines sals
;
7008 enum enable save_enable
;
7013 warning ("attempted to reset apparently deleted breakpoint #%d?",
7017 case bp_hardware_breakpoint
:
7019 case bp_catch_unload
:
7020 if (b
->addr_string
== NULL
)
7022 /* Anything without a string can't be re-set. */
7023 delete_breakpoint (b
);
7026 /* In case we have a problem, disable this breakpoint. We'll restore
7027 its status if we succeed. */
7028 save_enable
= b
->enable
;
7029 b
->enable
= disabled
;
7031 set_language (b
->language
);
7032 input_radix
= b
->input_radix
;
7034 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
7035 for (i
= 0; i
< sals
.nelts
; i
++)
7037 resolve_sal_pc (&sals
.sals
[i
]);
7039 /* Reparse conditions, they might contain references to the
7041 if (b
->cond_string
!= NULL
)
7045 free ((PTR
) b
->cond
);
7046 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
7049 /* We need to re-set the breakpoint if the address changes... */
7050 if (b
->address
!= sals
.sals
[i
].pc
7051 /* ...or new and old breakpoints both have source files, and
7052 the source file name or the line number changes... */
7053 || (b
->source_file
!= NULL
7054 && sals
.sals
[i
].symtab
!= NULL
7055 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
7056 || b
->line_number
!= sals
.sals
[i
].line
)
7058 /* ...or we switch between having a source file and not having
7060 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
7063 if (b
->source_file
!= NULL
)
7064 free (b
->source_file
);
7065 if (sals
.sals
[i
].symtab
== NULL
)
7066 b
->source_file
= NULL
;
7069 savestring (sals
.sals
[i
].symtab
->filename
,
7070 strlen (sals
.sals
[i
].symtab
->filename
));
7071 b
->line_number
= sals
.sals
[i
].line
;
7072 b
->address
= sals
.sals
[i
].pc
;
7074 /* Used to check for duplicates here, but that can
7075 cause trouble, as it doesn't check for disable
7080 /* Might be better to do this just once per breakpoint_re_set,
7081 rather than once for every breakpoint. */
7082 breakpoints_changed ();
7084 b
->section
= sals
.sals
[i
].section
;
7085 b
->enable
= save_enable
; /* Restore it, this worked. */
7088 /* Now that this is re-enabled, check_duplicates
7090 check_duplicates (b
->address
, b
->section
);
7093 free ((PTR
) sals
.sals
);
7097 case bp_hardware_watchpoint
:
7098 case bp_read_watchpoint
:
7099 case bp_access_watchpoint
:
7100 innermost_block
= NULL
;
7101 /* The issue arises of what context to evaluate this in. The
7102 same one as when it was set, but what does that mean when
7103 symbols have been re-read? We could save the filename and
7104 functionname, but if the context is more local than that, the
7105 best we could do would be something like how many levels deep
7106 and which index at that particular level, but that's going to
7107 be less stable than filenames or function names. */
7109 /* So for now, just use a global context. */
7111 free ((PTR
) b
->exp
);
7112 b
->exp
= parse_expression (b
->exp_string
);
7113 b
->exp_valid_block
= innermost_block
;
7114 mark
= value_mark ();
7116 value_free (b
->val
);
7117 b
->val
= evaluate_expression (b
->exp
);
7118 release_value (b
->val
);
7119 if (VALUE_LAZY (b
->val
))
7120 value_fetch_lazy (b
->val
);
7122 if (b
->cond_string
!= NULL
)
7126 free ((PTR
) b
->cond
);
7127 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
7129 if (b
->enable
== enabled
)
7131 value_free_to_mark (mark
);
7133 case bp_catch_catch
:
7134 case bp_catch_throw
:
7136 /* We needn't really do anything to reset these, since the mask
7137 that requests them is unaffected by e.g., new libraries being
7140 case bp_catch_vfork
:
7145 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
7147 /* Delete longjmp breakpoints, they will be reset later by
7148 breakpoint_re_set. */
7150 case bp_longjmp_resume
:
7151 delete_breakpoint (b
);
7154 /* This breakpoint is special, it's set up when the inferior
7155 starts and we really don't want to touch it. */
7156 case bp_shlib_event
:
7158 /* Like bp_shlib_event, this breakpoint type is special.
7159 Once it is set up, we do not want to touch it. */
7160 case bp_thread_event
:
7162 /* Keep temporary breakpoints, which can be encountered when we step
7163 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
7164 Otherwise these should have been blown away via the cleanup chain
7165 or by breakpoint_init_inferior when we rerun the executable. */
7168 case bp_watchpoint_scope
:
7170 case bp_step_resume
:
7177 /* Re-set all breakpoints after symbols have been re-loaded. */
7179 breakpoint_re_set ()
7181 struct breakpoint
*b
, *temp
;
7182 enum language save_language
;
7183 int save_input_radix
;
7184 static char message1
[] = "Error in re-setting breakpoint %d:\n";
7185 char message
[sizeof (message1
) + 30 /* slop */ ];
7187 save_language
= current_language
->la_language
;
7188 save_input_radix
= input_radix
;
7189 ALL_BREAKPOINTS_SAFE (b
, temp
)
7191 /* Format possible error msg */
7192 sprintf (message
, message1
, b
->number
);
7193 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
7195 set_language (save_language
);
7196 input_radix
= save_input_radix
;
7198 #ifdef GET_LONGJMP_TARGET
7199 create_longjmp_breakpoint ("longjmp");
7200 create_longjmp_breakpoint ("_longjmp");
7201 create_longjmp_breakpoint ("siglongjmp");
7202 create_longjmp_breakpoint ("_siglongjmp");
7203 create_longjmp_breakpoint (NULL
);
7207 /* Took this out (temporarily at least), since it produces an extra
7208 blank line at startup. This messes up the gdbtests. -PB */
7209 /* Blank line to finish off all those mention() messages we just printed. */
7210 printf_filtered ("\n");
7214 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
7215 If from_tty is nonzero, it prints a message to that effect,
7216 which ends with a period (no newline). */
7218 /* Reset the thread number of this breakpoint:
7220 - If the breakpoint is for all threads, leave it as-is.
7221 - Else, reset it to the current thread for inferior_pid. */
7223 breakpoint_re_set_thread (b
)
7224 struct breakpoint
*b
;
7226 if (b
->thread
!= -1)
7228 if (in_thread_list (inferior_pid
))
7229 b
->thread
= pid_to_thread_id (inferior_pid
);
7234 set_ignore_count (bptnum
, count
, from_tty
)
7235 int bptnum
, count
, from_tty
;
7237 register struct breakpoint
*b
;
7243 if (b
->number
== bptnum
)
7245 b
->ignore_count
= count
;
7248 else if (count
== 0)
7249 printf_filtered ("Will stop next time breakpoint %d is reached.",
7251 else if (count
== 1)
7252 printf_filtered ("Will ignore next crossing of breakpoint %d.",
7255 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
7257 breakpoints_changed ();
7261 error ("No breakpoint number %d.", bptnum
);
7264 /* Clear the ignore counts of all breakpoints. */
7266 breakpoint_clear_ignore_counts ()
7268 struct breakpoint
*b
;
7271 b
->ignore_count
= 0;
7274 /* Command to set ignore-count of breakpoint N to COUNT. */
7277 ignore_command (args
, from_tty
)
7285 error_no_arg ("a breakpoint number");
7287 num
= get_number (&p
);
7289 error ("bad breakpoint number: '%s'", args
);
7291 error ("Second argument (specified ignore-count) is missing.");
7293 set_ignore_count (num
,
7294 longest_to_int (value_as_long (parse_and_eval (p
))),
7296 printf_filtered ("\n");
7297 breakpoints_changed ();
7300 /* Call FUNCTION on each of the breakpoints
7301 whose numbers are given in ARGS. */
7304 map_breakpoint_numbers (args
, function
)
7306 void (*function
) PARAMS ((struct breakpoint
*));
7308 register char *p
= args
;
7311 register struct breakpoint
*b
, *tmp
;
7315 error_no_arg ("one or more breakpoint numbers");
7322 num
= get_number_or_range (&p1
);
7325 warning ("bad breakpoint number at or near '%s'", p
);
7329 ALL_BREAKPOINTS_SAFE (b
, tmp
)
7330 if (b
->number
== num
)
7332 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
7335 if (related_breakpoint
)
7336 function (related_breakpoint
);
7340 printf_unfiltered ("No breakpoint number %d.\n", num
);
7347 disable_breakpoint (bpt
)
7348 struct breakpoint
*bpt
;
7350 /* Never disable a watchpoint scope breakpoint; we want to
7351 hit them when we leave scope so we can delete both the
7352 watchpoint and its scope breakpoint at that time. */
7353 if (bpt
->type
== bp_watchpoint_scope
)
7356 /* You can't disable permanent breakpoints. */
7357 if (bpt
->enable
== permanent
)
7360 bpt
->enable
= disabled
;
7362 check_duplicates (bpt
->address
, bpt
->section
);
7364 if (modify_breakpoint_hook
)
7365 modify_breakpoint_hook (bpt
);
7366 breakpoint_modify_event (bpt
->number
);
7371 disable_command (args
, from_tty
)
7375 register struct breakpoint
*bpt
;
7377 ALL_BREAKPOINTS (bpt
)
7381 warning ("attempted to disable apparently deleted breakpoint #%d?",
7386 case bp_catch_unload
:
7388 case bp_catch_vfork
:
7390 case bp_catch_catch
:
7391 case bp_catch_throw
:
7392 case bp_hardware_breakpoint
:
7394 case bp_hardware_watchpoint
:
7395 case bp_read_watchpoint
:
7396 case bp_access_watchpoint
:
7397 disable_breakpoint (bpt
);
7402 map_breakpoint_numbers (args
, disable_breakpoint
);
7406 do_enable_breakpoint (bpt
, disposition
)
7407 struct breakpoint
*bpt
;
7408 enum bpdisp disposition
;
7410 struct frame_info
*save_selected_frame
= NULL
;
7411 int save_selected_frame_level
= -1;
7412 int target_resources_ok
, other_type_used
;
7415 if (bpt
->type
== bp_hardware_breakpoint
)
7418 i
= hw_breakpoint_used_count ();
7419 target_resources_ok
=
7420 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
7422 if (target_resources_ok
== 0)
7423 error ("No hardware breakpoint support in the target.");
7424 else if (target_resources_ok
< 0)
7425 error ("Hardware breakpoints used exceeds limit.");
7428 if (bpt
->enable
!= permanent
)
7429 bpt
->enable
= enabled
;
7430 bpt
->disposition
= disposition
;
7431 check_duplicates (bpt
->address
, bpt
->section
);
7432 breakpoints_changed ();
7434 if (bpt
->type
== bp_watchpoint
||
7435 bpt
->type
== bp_hardware_watchpoint
||
7436 bpt
->type
== bp_read_watchpoint
||
7437 bpt
->type
== bp_access_watchpoint
)
7439 if (bpt
->exp_valid_block
!= NULL
)
7441 struct frame_info
*fr
=
7443 /* Ensure that we have the current frame. Else, this
7444 next query may pessimistically be answered as, "No,
7445 not within current scope". */
7446 get_current_frame ();
7447 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
7451 Cannot enable watchpoint %d because the block in which its expression\n\
7452 is valid is not currently in scope.\n", bpt
->number
);
7453 bpt
->enable
= disabled
;
7457 save_selected_frame
= selected_frame
;
7458 save_selected_frame_level
= selected_frame_level
;
7459 select_frame (fr
, -1);
7462 value_free (bpt
->val
);
7463 mark
= value_mark ();
7464 bpt
->val
= evaluate_expression (bpt
->exp
);
7465 release_value (bpt
->val
);
7466 if (VALUE_LAZY (bpt
->val
))
7467 value_fetch_lazy (bpt
->val
);
7469 if (bpt
->type
== bp_hardware_watchpoint
||
7470 bpt
->type
== bp_read_watchpoint
||
7471 bpt
->type
== bp_access_watchpoint
)
7473 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
7474 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
7476 /* Hack around 'unused var' error for some targets here */
7478 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
7479 bpt
->type
, i
+ mem_cnt
, other_type_used
);
7480 /* we can consider of type is bp_hardware_watchpoint, convert to
7481 bp_watchpoint in the following condition */
7482 if (target_resources_ok
< 0)
7485 Cannot enable watchpoint %d because target watch resources\n\
7486 have been allocated for other watchpoints.\n", bpt
->number
);
7487 bpt
->enable
= disabled
;
7488 value_free_to_mark (mark
);
7493 if (save_selected_frame_level
>= 0)
7494 select_and_print_frame (save_selected_frame
,
7495 save_selected_frame_level
);
7496 value_free_to_mark (mark
);
7498 if (modify_breakpoint_hook
)
7499 modify_breakpoint_hook (bpt
);
7500 breakpoint_modify_event (bpt
->number
);
7504 enable_breakpoint (bpt
)
7505 struct breakpoint
*bpt
;
7507 do_enable_breakpoint (bpt
, bpt
->disposition
);
7510 /* The enable command enables the specified breakpoints (or all defined
7511 breakpoints) so they once again become (or continue to be) effective
7512 in stopping the inferior. */
7516 enable_command (args
, from_tty
)
7520 register struct breakpoint
*bpt
;
7522 ALL_BREAKPOINTS (bpt
)
7526 warning ("attempted to enable apparently deleted breakpoint #%d?",
7531 case bp_catch_unload
:
7533 case bp_catch_vfork
:
7535 case bp_catch_catch
:
7536 case bp_catch_throw
:
7537 case bp_hardware_breakpoint
:
7539 case bp_hardware_watchpoint
:
7540 case bp_read_watchpoint
:
7541 case bp_access_watchpoint
:
7542 enable_breakpoint (bpt
);
7547 map_breakpoint_numbers (args
, enable_breakpoint
);
7551 enable_once_breakpoint (bpt
)
7552 struct breakpoint
*bpt
;
7554 do_enable_breakpoint (bpt
, disable
);
7559 enable_once_command (args
, from_tty
)
7563 map_breakpoint_numbers (args
, enable_once_breakpoint
);
7567 enable_delete_breakpoint (bpt
)
7568 struct breakpoint
*bpt
;
7570 do_enable_breakpoint (bpt
, del
);
7575 enable_delete_command (args
, from_tty
)
7579 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
7582 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
7584 struct symtabs_and_lines
7585 decode_line_spec_1 (string
, funfirstline
)
7589 struct symtabs_and_lines sals
;
7591 error ("Empty line specification.");
7592 if (default_breakpoint_valid
)
7593 sals
= decode_line_1 (&string
, funfirstline
,
7594 default_breakpoint_symtab
,
7595 default_breakpoint_line
,
7598 sals
= decode_line_1 (&string
, funfirstline
,
7599 (struct symtab
*) NULL
, 0, (char ***) NULL
);
7601 error ("Junk at end of line specification: %s", string
);
7606 _initialize_breakpoint ()
7608 struct cmd_list_element
*c
;
7610 breakpoint_chain
= 0;
7611 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
7612 before a breakpoint is set. */
7613 breakpoint_count
= 0;
7615 add_com ("ignore", class_breakpoint
, ignore_command
,
7616 "Set ignore-count of breakpoint number N to COUNT.\n\
7617 Usage is `ignore N COUNT'.");
7619 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
7621 add_com ("commands", class_breakpoint
, commands_command
,
7622 "Set commands to be executed when a breakpoint is hit.\n\
7623 Give breakpoint number as argument after \"commands\".\n\
7624 With no argument, the targeted breakpoint is the last one set.\n\
7625 The commands themselves follow starting on the next line.\n\
7626 Type a line containing \"end\" to indicate the end of them.\n\
7627 Give \"silent\" as the first line to make the breakpoint silent;\n\
7628 then no output is printed when it is hit, except what the commands print.");
7630 add_com ("condition", class_breakpoint
, condition_command
,
7631 "Specify breakpoint number N to break only if COND is true.\n\
7632 Usage is `condition N COND', where N is an integer and COND is an\n\
7633 expression to be evaluated whenever breakpoint N is reached. ");
7635 add_com ("tbreak", class_breakpoint
, tbreak_command
,
7636 "Set a temporary breakpoint. Args like \"break\" command.\n\
7637 Like \"break\" except the breakpoint is only temporary,\n\
7638 so it will be deleted when hit. Equivalent to \"break\" followed\n\
7639 by using \"enable delete\" on the breakpoint number.");
7640 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
7641 "Set temporary breakpoint at procedure exit. Either there should\n\
7642 be no argument or the argument must be a depth.\n");
7644 add_com ("hbreak", class_breakpoint
, hbreak_command
,
7645 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
7646 Like \"break\" except the breakpoint requires hardware support,\n\
7647 some target hardware may not have this support.");
7649 add_com ("thbreak", class_breakpoint
, thbreak_command
,
7650 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
7651 Like \"hbreak\" except the breakpoint is only temporary,\n\
7652 so it will be deleted when hit.");
7654 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
7655 "Enable some breakpoints.\n\
7656 Give breakpoint numbers (separated by spaces) as arguments.\n\
7657 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7658 This is used to cancel the effect of the \"disable\" command.\n\
7659 With a subcommand you can enable temporarily.",
7660 &enablelist
, "enable ", 1, &cmdlist
);
7662 add_com ("ab", class_breakpoint
, enable_command
,
7663 "Enable some breakpoints.\n\
7664 Give breakpoint numbers (separated by spaces) as arguments.\n\
7665 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7666 This is used to cancel the effect of the \"disable\" command.\n\
7667 With a subcommand you can enable temporarily.");
7669 add_com_alias ("en", "enable", class_breakpoint
, 1);
7671 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
7672 "Enable some breakpoints.\n\
7673 Give breakpoint numbers (separated by spaces) as arguments.\n\
7674 This is used to cancel the effect of the \"disable\" command.\n\
7675 May be abbreviated to simply \"enable\".\n",
7676 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
7678 add_cmd ("once", no_class
, enable_once_command
,
7679 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7680 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7683 add_cmd ("delete", no_class
, enable_delete_command
,
7684 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7685 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7688 add_cmd ("delete", no_class
, enable_delete_command
,
7689 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7690 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7693 add_cmd ("once", no_class
, enable_once_command
,
7694 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7695 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7698 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
7699 "Disable some breakpoints.\n\
7700 Arguments are breakpoint numbers with spaces in between.\n\
7701 To disable all breakpoints, give no argument.\n\
7702 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
7703 &disablelist
, "disable ", 1, &cmdlist
);
7704 add_com_alias ("dis", "disable", class_breakpoint
, 1);
7705 add_com_alias ("disa", "disable", class_breakpoint
, 1);
7707 add_com ("sb", class_breakpoint
, disable_command
,
7708 "Disable some breakpoints.\n\
7709 Arguments are breakpoint numbers with spaces in between.\n\
7710 To disable all breakpoints, give no argument.\n\
7711 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
7713 add_cmd ("breakpoints", class_alias
, disable_command
,
7714 "Disable some breakpoints.\n\
7715 Arguments are breakpoint numbers with spaces in between.\n\
7716 To disable all breakpoints, give no argument.\n\
7717 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
7718 This command may be abbreviated \"disable\".",
7721 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
7722 "Delete some breakpoints or auto-display expressions.\n\
7723 Arguments are breakpoint numbers with spaces in between.\n\
7724 To delete all breakpoints, give no argument.\n\
7726 Also a prefix command for deletion of other GDB objects.\n\
7727 The \"unset\" command is also an alias for \"delete\".",
7728 &deletelist
, "delete ", 1, &cmdlist
);
7729 add_com_alias ("d", "delete", class_breakpoint
, 1);
7731 add_com ("db", class_breakpoint
, delete_command
,
7732 "Delete some breakpoints.\n\
7733 Arguments are breakpoint numbers with spaces in between.\n\
7734 To delete all breakpoints, give no argument.\n");
7736 add_cmd ("breakpoints", class_alias
, delete_command
,
7737 "Delete some breakpoints or auto-display expressions.\n\
7738 Arguments are breakpoint numbers with spaces in between.\n\
7739 To delete all breakpoints, give no argument.\n\
7740 This command may be abbreviated \"delete\".",
7743 add_com ("clear", class_breakpoint
, clear_command
,
7744 concat ("Clear breakpoint at specified line or function.\n\
7745 Argument may be line number, function name, or \"*\" and an address.\n\
7746 If line number is specified, all breakpoints in that line are cleared.\n\
7747 If function is specified, breakpoints at beginning of function are cleared.\n\
7748 If an address is specified, breakpoints at that address are cleared.\n\n",
7749 "With no argument, clears all breakpoints in the line that the selected frame\n\
7752 See also the \"delete\" command which clears breakpoints by number.", NULL
));
7754 add_com ("break", class_breakpoint
, break_command
,
7755 concat ("Set breakpoint at specified line or function.\n\
7756 Argument may be line number, function name, or \"*\" and an address.\n\
7757 If line number is specified, break at start of code for that line.\n\
7758 If function is specified, break at start of code for that function.\n\
7759 If an address is specified, break at that exact address.\n",
7760 "With no arg, uses current execution address of selected stack frame.\n\
7761 This is useful for breaking on return to a stack frame.\n\
7763 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7765 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7766 add_com_alias ("b", "break", class_run
, 1);
7767 add_com_alias ("br", "break", class_run
, 1);
7768 add_com_alias ("bre", "break", class_run
, 1);
7769 add_com_alias ("brea", "break", class_run
, 1);
7771 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
7772 concat ("Set breakpoint at procedure exit. \n\
7773 Argument may be function name, or \"*\" and an address.\n\
7774 If function is specified, break at end of code for that function.\n\
7775 If an address is specified, break at the end of the function that contains \n\
7776 that exact address.\n",
7777 "With no arg, uses current execution address of selected stack frame.\n\
7778 This is useful for breaking on return to a stack frame.\n\
7780 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7782 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7783 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
7784 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
7785 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
7786 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
7790 add_com_alias ("ba", "break", class_breakpoint
, 1);
7791 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
7792 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
7793 "Set breakpoint at procedure exit. Either there should\n\
7794 be no argument or the argument must be a depth.\n");
7799 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
7800 "Break in function/address or break at a line in the current file.",
7801 &stoplist
, "stop ", 1, &cmdlist
);
7802 add_cmd ("in", class_breakpoint
, stopin_command
,
7803 "Break in function or address.\n", &stoplist
);
7804 add_cmd ("at", class_breakpoint
, stopat_command
,
7805 "Break at a line in the current file.\n", &stoplist
);
7806 add_com ("status", class_info
, breakpoints_info
,
7807 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7808 The \"Type\" column indicates one of:\n\
7809 \tbreakpoint - normal breakpoint\n\
7810 \twatchpoint - watchpoint\n\
7811 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7812 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7813 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7814 address and file/line number respectively.\n\n",
7815 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7816 are set to the address of the last breakpoint listed.\n\n\
7817 Convenience variable \"$bpnum\" contains the number of the last\n\
7818 breakpoint set.", NULL
));
7821 add_info ("breakpoints", breakpoints_info
,
7822 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7823 The \"Type\" column indicates one of:\n\
7824 \tbreakpoint - normal breakpoint\n\
7825 \twatchpoint - watchpoint\n\
7826 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7827 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7828 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7829 address and file/line number respectively.\n\n",
7830 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7831 are set to the address of the last breakpoint listed.\n\n\
7832 Convenience variable \"$bpnum\" contains the number of the last\n\
7833 breakpoint set.", NULL
));
7836 add_com ("lb", class_breakpoint
, breakpoints_info
,
7837 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7838 The \"Type\" column indicates one of:\n\
7839 \tbreakpoint - normal breakpoint\n\
7840 \twatchpoint - watchpoint\n\
7841 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7842 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7843 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7844 address and file/line number respectively.\n\n",
7845 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7846 are set to the address of the last breakpoint listed.\n\n\
7847 Convenience variable \"$bpnum\" contains the number of the last\n\
7848 breakpoint set.", NULL
));
7850 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
7851 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
7852 The \"Type\" column indicates one of:\n\
7853 \tbreakpoint - normal breakpoint\n\
7854 \twatchpoint - watchpoint\n\
7855 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7856 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7857 \tuntil - internal breakpoint used by the \"until\" command\n\
7858 \tfinish - internal breakpoint used by the \"finish\" command\n",
7859 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7860 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7861 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7862 address and file/line number respectively.\n\n",
7863 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7864 are set to the address of the last breakpoint listed.\n\n\
7865 Convenience variable \"$bpnum\" contains the number of the last\n\
7866 breakpoint set.", NULL
),
7867 &maintenanceinfolist
);
7869 add_com ("catch", class_breakpoint
, catch_command
,
7870 "Set catchpoints to catch events.\n\
7871 Raised signals may be caught:\n\
7872 \tcatch signal - all signals\n\
7873 \tcatch signal <signame> - a particular signal\n\
7874 Raised exceptions may be caught:\n\
7875 \tcatch throw - all exceptions, when thrown\n\
7876 \tcatch throw <exceptname> - a particular exception, when thrown\n\
7877 \tcatch catch - all exceptions, when caught\n\
7878 \tcatch catch <exceptname> - a particular exception, when caught\n\
7879 Thread or process events may be caught:\n\
7880 \tcatch thread_start - any threads, just after creation\n\
7881 \tcatch thread_exit - any threads, just before expiration\n\
7882 \tcatch thread_join - any threads, just after joins\n\
7883 Process events may be caught:\n\
7884 \tcatch start - any processes, just after creation\n\
7885 \tcatch exit - any processes, just before expiration\n\
7886 \tcatch fork - calls to fork()\n\
7887 \tcatch vfork - calls to vfork()\n\
7888 \tcatch exec - calls to exec()\n\
7889 Dynamically-linked library events may be caught:\n\
7890 \tcatch load - loads of any library\n\
7891 \tcatch load <libname> - loads of a particular library\n\
7892 \tcatch unload - unloads of any library\n\
7893 \tcatch unload <libname> - unloads of a particular library\n\
7894 The act of your program's execution stopping may also be caught:\n\
7896 C++ exceptions may be caught:\n\
7897 \tcatch throw - all exceptions, when thrown\n\
7898 \tcatch catch - all exceptions, when caught\n\
7900 Do \"help set follow-fork-mode\" for info on debugging your program\n\
7901 after a fork or vfork is caught.\n\n\
7902 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
7904 add_com ("tcatch", class_breakpoint
, tcatch_command
,
7905 "Set temporary catchpoints to catch events.\n\
7906 Args like \"catch\" command.\n\
7907 Like \"catch\" except the catchpoint is only temporary,\n\
7908 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7909 by using \"enable delete\" on the catchpoint number.");
7911 add_com ("watch", class_breakpoint
, watch_command
,
7912 "Set a watchpoint for an expression.\n\
7913 A watchpoint stops execution of your program whenever the value of\n\
7914 an expression changes.");
7916 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7917 "Set a read watchpoint for an expression.\n\
7918 A watchpoint stops execution of your program whenever the value of\n\
7919 an expression is read.");
7921 add_com ("awatch", class_breakpoint
, awatch_command
,
7922 "Set a watchpoint for an expression.\n\
7923 A watchpoint stops execution of your program whenever the value of\n\
7924 an expression is either read or written.");
7926 add_info ("watchpoints", breakpoints_info
,
7927 "Synonym for ``info breakpoints''.");
7930 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7931 (char *) &can_use_hw_watchpoints
,
7932 "Set debugger's willingness to use watchpoint hardware.\n\
7933 If zero, gdb will not use hardware for new watchpoints, even if\n\
7934 such is available. (However, any hardware watchpoints that were\n\
7935 created before setting this to nonzero, will continue to use watchpoint\n\
7938 add_show_from_set (c
, &showlist
);
7940 can_use_hw_watchpoints
= 1;