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
921 && b
->disposition
!= del_at_next_stop
925 struct frame_info
*saved_frame
;
926 int saved_level
, within_current_scope
;
927 value_ptr mark
= value_mark ();
930 /* Save the current frame and level so we can restore it after
931 evaluating the watchpoint expression on its own frame. */
932 saved_frame
= selected_frame
;
933 saved_level
= selected_frame_level
;
935 /* Determine if the watchpoint is within scope. */
936 if (b
->exp_valid_block
== NULL
)
937 within_current_scope
= 1;
940 struct frame_info
*fi
;
942 /* There might be no current frame at this moment if we are
943 resuming from a step over a breakpoint.
944 Set up current frame before trying to find the watchpoint
946 get_current_frame ();
947 fi
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
948 within_current_scope
= (fi
!= NULL
);
949 if (within_current_scope
)
950 select_frame (fi
, -1);
953 if (within_current_scope
)
955 /* Evaluate the expression and cut the chain of values
956 produced off from the value chain.
958 Make sure the value returned isn't lazy; we use
959 laziness to determine what memory GDB actually needed
960 in order to compute the value of the expression. */
961 v
= evaluate_expression (b
->exp
);
963 value_release_to_mark (mark
);
968 /* Look at each value on the value chain. */
969 for (; v
; v
= v
->next
)
971 /* If it's a memory location, and GDB actually needed
972 its contents to evaluate the expression, then we
974 if (VALUE_LVAL (v
) == lval_memory
977 struct type
*vtype
= check_typedef (VALUE_TYPE (v
));
979 /* We only watch structs and arrays if user asked
980 for it explicitly, never if they just happen to
981 appear in the middle of some value chain. */
982 if (v
== b
->val_chain
983 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
984 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
989 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
990 len
= TYPE_LENGTH (VALUE_TYPE (v
));
992 if (b
->type
== bp_read_watchpoint
)
994 else if (b
->type
== bp_access_watchpoint
)
997 val
= target_insert_watchpoint (addr
, len
, type
);
1000 /* Don't exit the loop, try to insert
1001 every value on the value chain. That's
1002 because we will be removing all the
1003 watches below, and removing a
1004 watchpoint we didn't insert could have
1012 /* Failure to insert a watchpoint on any memory value in the
1013 value chain brings us here. */
1016 remove_breakpoint (b
, mark_uninserted
);
1017 warning ("Could not insert hardware watchpoint %d.",
1024 printf_filtered ("Hardware watchpoint %d deleted ", b
->number
);
1025 printf_filtered ("because the program has left the block \n");
1026 printf_filtered ("in which its expression is valid.\n");
1027 if (b
->related_breakpoint
)
1028 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1029 b
->disposition
= del_at_next_stop
;
1032 /* Restore the frame and level. */
1033 if ((saved_frame
!= selected_frame
) ||
1034 (saved_level
!= selected_frame_level
))
1035 select_frame (saved_frame
, saved_level
);
1038 return_val
= val
; /* remember failure */
1040 else if ((b
->type
== bp_catch_fork
1041 || b
->type
== bp_catch_vfork
1042 || b
->type
== bp_catch_exec
)
1043 && b
->enable
== enabled
1051 val
= target_insert_fork_catchpoint (inferior_pid
);
1053 case bp_catch_vfork
:
1054 val
= target_insert_vfork_catchpoint (inferior_pid
);
1057 val
= target_insert_exec_catchpoint (inferior_pid
);
1060 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1065 target_terminal_ours_for_output ();
1066 warning ("Cannot insert catchpoint %d.", b
->number
);
1072 return_val
= val
; /* remember failure */
1081 remove_breakpoints ()
1083 register struct breakpoint
*b
;
1090 val
= remove_breakpoint (b
, mark_uninserted
);
1099 remove_hw_watchpoints (void)
1101 register struct breakpoint
*b
;
1107 && (b
->type
== bp_hardware_watchpoint
1108 || b
->type
== bp_read_watchpoint
1109 || b
->type
== bp_access_watchpoint
))
1111 val
= remove_breakpoint (b
, mark_uninserted
);
1120 reattach_breakpoints (pid
)
1123 register struct breakpoint
*b
;
1125 int saved_inferior_pid
= inferior_pid
;
1127 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1128 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1133 remove_breakpoint (b
, mark_inserted
);
1134 if (b
->type
== bp_hardware_breakpoint
)
1135 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
1137 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
1140 inferior_pid
= saved_inferior_pid
;
1145 inferior_pid
= saved_inferior_pid
;
1150 update_breakpoints_after_exec ()
1152 struct breakpoint
*b
;
1153 struct breakpoint
*temp
;
1155 /* Doing this first prevents the badness of having delete_breakpoint()
1156 write a breakpoint's current "shadow contents" to lift the bp. That
1157 shadow is NOT valid after an exec()! */
1158 mark_breakpoints_out ();
1160 ALL_BREAKPOINTS_SAFE (b
, temp
)
1162 /* Solib breakpoints must be explicitly reset after an exec(). */
1163 if (b
->type
== bp_shlib_event
)
1165 delete_breakpoint (b
);
1169 /* Thread event breakpoints must be set anew after an exec(). */
1170 if (b
->type
== bp_thread_event
)
1172 delete_breakpoint (b
);
1176 /* Step-resume breakpoints are meaningless after an exec(). */
1177 if (b
->type
== bp_step_resume
)
1179 delete_breakpoint (b
);
1183 /* Ditto the sigtramp handler breakpoints. */
1184 if (b
->type
== bp_through_sigtramp
)
1186 delete_breakpoint (b
);
1190 /* Ditto the exception-handling catchpoints. */
1191 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1193 delete_breakpoint (b
);
1197 /* Don't delete an exec catchpoint, because else the inferior
1198 won't stop when it ought!
1200 Similarly, we probably ought to keep vfork catchpoints, 'cause
1201 on this target, we may not be able to stop when the vfork is
1202 seen, but only when the subsequent exec is seen. (And because
1203 deleting fork catchpoints here but not vfork catchpoints will
1204 seem mysterious to users, keep those too.)
1206 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1207 target address field, if any, is sufficient to have it be reset
1208 automagically. Certainly on HP-UX that's true. */
1209 if ((b
->type
== bp_catch_exec
) ||
1210 (b
->type
== bp_catch_vfork
) ||
1211 (b
->type
== bp_catch_fork
))
1213 b
->address
= (CORE_ADDR
) NULL
;
1217 /* bp_finish is a special case. The only way we ought to be able
1218 to see one of these when an exec() has happened, is if the user
1219 caught a vfork, and then said "finish". Ordinarily a finish just
1220 carries them to the call-site of the current callee, by setting
1221 a temporary bp there and resuming. But in this case, the finish
1222 will carry them entirely through the vfork & exec.
1224 We don't want to allow a bp_finish to remain inserted now. But
1225 we can't safely delete it, 'cause finish_command has a handle to
1226 the bp on a bpstat, and will later want to delete it. There's a
1227 chance (and I've seen it happen) that if we delete the bp_finish
1228 here, that its storage will get reused by the time finish_command
1229 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1230 We really must allow finish_command to delete a bp_finish.
1232 In the absense of a general solution for the "how do we know
1233 it's safe to delete something others may have handles to?"
1234 problem, what we'll do here is just uninsert the bp_finish, and
1235 let finish_command delete it.
1237 (We know the bp_finish is "doomed" in the sense that it's
1238 momentary, and will be deleted as soon as finish_command sees
1239 the inferior stopped. So it doesn't matter that the bp's
1240 address is probably bogus in the new a.out, unlike e.g., the
1241 solib breakpoints.) */
1243 if (b
->type
== bp_finish
)
1248 /* Without a symbolic address, we have little hope of the
1249 pre-exec() address meaning the same thing in the post-exec()
1251 if (b
->addr_string
== NULL
)
1253 delete_breakpoint (b
);
1257 /* If this breakpoint has survived the above battery of checks, then
1258 it must have a symbolic address. Be sure that it gets reevaluated
1259 to a target address, rather than reusing the old evaluation. */
1260 b
->address
= (CORE_ADDR
) NULL
;
1265 detach_breakpoints (pid
)
1268 register struct breakpoint
*b
;
1270 int saved_inferior_pid
= inferior_pid
;
1272 if (pid
== inferior_pid
)
1273 error ("Cannot detach breakpoints of inferior_pid");
1275 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1276 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1281 val
= remove_breakpoint (b
, mark_inserted
);
1284 inferior_pid
= saved_inferior_pid
;
1289 inferior_pid
= saved_inferior_pid
;
1294 remove_breakpoint (b
, is
)
1295 struct breakpoint
*b
;
1296 insertion_state_t is
;
1300 if (b
->enable
== permanent
)
1301 /* Permanent breakpoints cannot be inserted or removed. */
1304 if (b
->type
== bp_none
)
1305 warning ("attempted to remove apparently deleted breakpoint #%d?",
1308 if (b
->type
!= bp_watchpoint
1309 && b
->type
!= bp_hardware_watchpoint
1310 && b
->type
!= bp_read_watchpoint
1311 && b
->type
!= bp_access_watchpoint
1312 && b
->type
!= bp_catch_fork
1313 && b
->type
!= bp_catch_vfork
1314 && b
->type
!= bp_catch_exec
1315 && b
->type
!= bp_catch_catch
1316 && b
->type
!= bp_catch_throw
)
1318 if (b
->type
== bp_hardware_breakpoint
)
1319 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1322 /* Check to see if breakpoint is in an overlay section;
1323 if so, we should remove the breakpoint at the LMA address.
1324 If that is not equal to the raw address, then we should
1325 presumable remove the breakpoint there as well. */
1326 if (overlay_debugging
&& b
->section
&&
1327 section_is_overlay (b
->section
))
1331 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1332 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1333 /* This would be the time to check val, to see if the
1334 shadow breakpoint write to the load address succeeded.
1335 However, this might be an ordinary occurrance, eg. if
1336 the unmapped overlay is in ROM. */
1337 val
= 0; /* in case unmapped address failed */
1338 if (section_is_mapped (b
->section
))
1339 val
= target_remove_breakpoint (b
->address
,
1340 b
->shadow_contents
);
1342 else /* ordinary (non-overlay) address */
1343 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1347 b
->inserted
= (is
== mark_inserted
);
1349 else if ((b
->type
== bp_hardware_watchpoint
||
1350 b
->type
== bp_read_watchpoint
||
1351 b
->type
== bp_access_watchpoint
)
1352 && b
->enable
== enabled
1357 b
->inserted
= (is
== mark_inserted
);
1358 /* Walk down the saved value chain. */
1359 for (v
= b
->val_chain
; v
; v
= v
->next
)
1361 /* For each memory reference remove the watchpoint
1363 if (VALUE_LVAL (v
) == lval_memory
1364 && ! VALUE_LAZY (v
))
1366 struct type
*vtype
= check_typedef (VALUE_TYPE (v
));
1368 if (v
== b
->val_chain
1369 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
1370 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
1375 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1376 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1378 if (b
->type
== bp_read_watchpoint
)
1380 else if (b
->type
== bp_access_watchpoint
)
1383 val
= target_remove_watchpoint (addr
, len
, type
);
1390 /* Failure to remove any of the hardware watchpoints comes here. */
1391 if ((is
== mark_uninserted
) && (b
->inserted
))
1392 warning ("Could not remove hardware watchpoint %d.",
1395 /* Free the saved value chain. We will construct a new one
1396 the next time the watchpoint is inserted. */
1397 for (v
= b
->val_chain
; v
; v
= n
)
1402 b
->val_chain
= NULL
;
1404 else if ((b
->type
== bp_catch_fork
||
1405 b
->type
== bp_catch_vfork
||
1406 b
->type
== bp_catch_exec
)
1407 && b
->enable
== enabled
1414 val
= target_remove_fork_catchpoint (inferior_pid
);
1416 case bp_catch_vfork
:
1417 val
= target_remove_vfork_catchpoint (inferior_pid
);
1420 val
= target_remove_exec_catchpoint (inferior_pid
);
1423 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1428 b
->inserted
= (is
== mark_inserted
);
1430 else if ((b
->type
== bp_catch_catch
||
1431 b
->type
== bp_catch_throw
)
1432 && b
->enable
== enabled
1436 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1439 b
->inserted
= (is
== mark_inserted
);
1441 else if (ep_is_exception_catchpoint (b
)
1442 && b
->inserted
/* sometimes previous insert doesn't happen */
1443 && b
->enable
== enabled
1447 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1451 b
->inserted
= (is
== mark_inserted
);
1457 /* Clear the "inserted" flag in all breakpoints. */
1460 mark_breakpoints_out ()
1462 register struct breakpoint
*b
;
1468 /* Clear the "inserted" flag in all breakpoints and delete any
1469 breakpoints which should go away between runs of the program.
1471 Plus other such housekeeping that has to be done for breakpoints
1474 Note: this function gets called at the end of a run (by
1475 generic_mourn_inferior) and when a run begins (by
1476 init_wait_for_inferior). */
1481 breakpoint_init_inferior (context
)
1482 enum inf_context context
;
1484 register struct breakpoint
*b
, *temp
;
1485 static int warning_needed
= 0;
1487 ALL_BREAKPOINTS_SAFE (b
, temp
)
1494 case bp_watchpoint_scope
:
1496 /* If the call dummy breakpoint is at the entry point it will
1497 cause problems when the inferior is rerun, so we better
1500 Also get rid of scope breakpoints. */
1501 delete_breakpoint (b
);
1505 case bp_hardware_watchpoint
:
1506 case bp_read_watchpoint
:
1507 case bp_access_watchpoint
:
1509 /* Likewise for watchpoints on local expressions. */
1510 if (b
->exp_valid_block
!= NULL
)
1511 delete_breakpoint (b
);
1514 /* Likewise for exception catchpoints in dynamic-linked
1515 executables where required */
1516 if (ep_is_exception_catchpoint (b
) &&
1517 exception_catchpoints_are_fragile
)
1520 delete_breakpoint (b
);
1526 if (exception_catchpoints_are_fragile
)
1527 exception_support_initialized
= 0;
1529 /* Don't issue the warning unless it's really needed... */
1530 if (warning_needed
&& (context
!= inf_exited
))
1532 warning ("Exception catchpoints from last run were deleted.");
1533 warning ("You must reinsert them explicitly.");
1538 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1539 exists at PC. It returns ordinary_breakpoint_here if it's an
1540 ordinary breakpoint, or permanent_breakpoint_here if it's a
1541 permanent breakpoint.
1542 - When continuing from a location with an ordinary breakpoint, we
1543 actually single step once before calling insert_breakpoints.
1544 - When continuing from a localion with a permanent breakpoint, we
1545 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1546 the target, to advance the PC past the breakpoint. */
1548 enum breakpoint_here
1549 breakpoint_here_p (pc
)
1552 register struct breakpoint
*b
;
1553 int any_breakpoint_here
= 0;
1556 if ((b
->enable
== enabled
1557 || b
->enable
== permanent
)
1558 && b
->address
== pc
) /* bp is enabled and matches pc */
1560 if (overlay_debugging
&&
1561 section_is_overlay (b
->section
) &&
1562 !section_is_mapped (b
->section
))
1563 continue; /* unmapped overlay -- can't be a match */
1564 else if (b
->enable
== permanent
)
1565 return permanent_breakpoint_here
;
1567 any_breakpoint_here
= 1;
1570 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1574 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1575 but it only returns true if there is actually a breakpoint inserted
1579 breakpoint_inserted_here_p (pc
)
1582 register struct breakpoint
*b
;
1586 && b
->address
== pc
) /* bp is inserted and matches pc */
1588 if (overlay_debugging
&&
1589 section_is_overlay (b
->section
) &&
1590 !section_is_mapped (b
->section
))
1591 continue; /* unmapped overlay -- can't be a match */
1599 /* Return nonzero if FRAME is a dummy frame. We can't use
1600 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1601 much time, at least using get_saved_register on the 68k. This
1602 means that for this function to work right a port must use the
1603 bp_call_dummy breakpoint. */
1606 frame_in_dummy (frame
)
1607 struct frame_info
*frame
;
1609 struct breakpoint
*b
;
1614 if (USE_GENERIC_DUMMY_FRAMES
)
1615 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1619 if (b
->type
== bp_call_dummy
1620 && b
->frame
== frame
->frame
1621 /* We need to check the PC as well as the frame on the sparc,
1622 for signals.exp in the testsuite. */
1625 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1626 && frame
->pc
<= b
->address
)
1632 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1633 is valid for process/thread PID. */
1636 breakpoint_thread_match (pc
, pid
)
1640 struct breakpoint
*b
;
1643 thread
= pid_to_thread_id (pid
);
1646 if (b
->enable
!= disabled
1647 && b
->enable
!= shlib_disabled
1648 && b
->enable
!= call_disabled
1650 && (b
->thread
== -1 || b
->thread
== thread
))
1652 if (overlay_debugging
&&
1653 section_is_overlay (b
->section
) &&
1654 !section_is_mapped (b
->section
))
1655 continue; /* unmapped overlay -- can't be a match */
1664 /* bpstat stuff. External routines' interfaces are documented
1668 ep_is_catchpoint (ep
)
1669 struct breakpoint
*ep
;
1672 (ep
->type
== bp_catch_load
)
1673 || (ep
->type
== bp_catch_unload
)
1674 || (ep
->type
== bp_catch_fork
)
1675 || (ep
->type
== bp_catch_vfork
)
1676 || (ep
->type
== bp_catch_exec
)
1677 || (ep
->type
== bp_catch_catch
)
1678 || (ep
->type
== bp_catch_throw
)
1681 /* ??rehrauer: Add more kinds here, as are implemented... */
1686 ep_is_shlib_catchpoint (ep
)
1687 struct breakpoint
*ep
;
1690 (ep
->type
== bp_catch_load
)
1691 || (ep
->type
== bp_catch_unload
)
1696 ep_is_exception_catchpoint (ep
)
1697 struct breakpoint
*ep
;
1700 (ep
->type
== bp_catch_catch
)
1701 || (ep
->type
== bp_catch_throw
)
1705 /* Clear a bpstat so that it says we are not at any breakpoint.
1706 Also free any storage that is part of a bpstat. */
1721 if (p
->old_val
!= NULL
)
1722 value_free (p
->old_val
);
1729 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1730 is part of the bpstat is copied as well. */
1738 bpstat retval
= NULL
;
1743 for (; bs
!= NULL
; bs
= bs
->next
)
1745 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1746 memcpy (tmp
, bs
, sizeof (*tmp
));
1748 /* This is the first thing in the chain. */
1758 /* Find the bpstat associated with this breakpoint */
1761 bpstat_find_breakpoint (bsp
, breakpoint
)
1763 struct breakpoint
*breakpoint
;
1768 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1770 if (bsp
->breakpoint_at
== breakpoint
)
1776 /* Find a step_resume breakpoint associated with this bpstat.
1777 (If there are multiple step_resume bp's on the list, this function
1778 will arbitrarily pick one.)
1780 It is an error to use this function if BPSTAT doesn't contain a
1781 step_resume breakpoint.
1783 See wait_for_inferior's use of this function. */
1785 bpstat_find_step_resume_breakpoint (bsp
)
1789 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1791 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1793 if ((bsp
->breakpoint_at
!= NULL
) &&
1794 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1795 return bsp
->breakpoint_at
;
1798 error ("Internal error (no step_resume breakpoint found)");
1802 /* Return the breakpoint number of the first breakpoint we are stopped
1803 at. *BSP upon return is a bpstat which points to the remaining
1804 breakpoints stopped at (but which is not guaranteed to be good for
1805 anything but further calls to bpstat_num).
1806 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1812 struct breakpoint
*b
;
1815 return 0; /* No more breakpoint values */
1818 b
= (*bsp
)->breakpoint_at
;
1819 *bsp
= (*bsp
)->next
;
1821 return -1; /* breakpoint that's been deleted since */
1823 return b
->number
; /* We have its number */
1827 /* Modify BS so that the actions will not be performed. */
1830 bpstat_clear_actions (bs
)
1833 for (; bs
!= NULL
; bs
= bs
->next
)
1835 bs
->commands
= NULL
;
1836 if (bs
->old_val
!= NULL
)
1838 value_free (bs
->old_val
);
1844 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1847 cleanup_executing_breakpoints (ignore
)
1850 executing_breakpoint_commands
= 0;
1853 /* Execute all the commands associated with all the breakpoints at this
1854 location. Any of these commands could cause the process to proceed
1855 beyond this point, etc. We look out for such changes by checking
1856 the global "breakpoint_proceeded" after each command. */
1859 bpstat_do_actions (bsp
)
1863 struct cleanup
*old_chain
;
1864 struct command_line
*cmd
;
1866 /* Avoid endless recursion if a `source' command is contained
1868 if (executing_breakpoint_commands
)
1871 executing_breakpoint_commands
= 1;
1872 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1875 /* Note that (as of this writing), our callers all appear to
1876 be passing us the address of global stop_bpstat. And, if
1877 our calls to execute_control_command cause the inferior to
1878 proceed, that global (and hence, *bsp) will change.
1880 We must be careful to not touch *bsp unless the inferior
1881 has not proceeded. */
1883 /* This pointer will iterate over the list of bpstat's. */
1886 breakpoint_proceeded
= 0;
1887 for (; bs
!= NULL
; bs
= bs
->next
)
1892 execute_control_command (cmd
);
1894 if (breakpoint_proceeded
)
1899 if (breakpoint_proceeded
)
1900 /* The inferior is proceeded by the command; bomb out now.
1901 The bpstat chain has been blown away by wait_for_inferior.
1902 But since execution has stopped again, there is a new bpstat
1903 to look at, so start over. */
1906 bs
->commands
= NULL
;
1909 executing_breakpoint_commands
= 0;
1910 discard_cleanups (old_chain
);
1913 /* This is the normal print function for a bpstat. In the future,
1914 much of this logic could (should?) be moved to bpstat_stop_status,
1915 by having it set different print_it values.
1917 Current scheme: When we stop, bpstat_print() is called. It loops
1918 through the bpstat list of things causing this stop, calling the
1919 print_bp_stop_message function on each one. The behavior of the
1920 print_bp_stop_message function depends on the print_it field of
1921 bpstat. If such field so indicates, call this function here.
1923 Return values from this routine (ultimately used by bpstat_print()
1924 and normal_stop() to decide what to do):
1925 PRINT_NOTHING: Means we already printed all we needed to print,
1926 don't print anything else.
1927 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
1928 that something to be followed by a location.
1929 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
1930 that something to be followed by a location.
1931 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
1934 static enum print_stop_action
1935 print_it_typical (bs
)
1939 struct cleanup
*old_chain
;
1940 struct ui_stream
*stb
;
1941 stb
= ui_out_stream_new (uiout
);
1942 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
1944 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1945 which has since been deleted. */
1946 if (bs
->breakpoint_at
== NULL
)
1947 return PRINT_UNKNOWN
;
1949 switch (bs
->breakpoint_at
->type
)
1952 case bp_hardware_breakpoint
:
1954 annotate_breakpoint (bs
->breakpoint_at
->number
);
1955 ui_out_text (uiout
, "\nBreakpoint ");
1956 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
1957 ui_out_field_string (uiout
, "reason", "breakpoint-hit");
1958 ui_out_field_int (uiout
, "bkptno", bs
->breakpoint_at
->number
);
1959 ui_out_text (uiout
, ", ");
1960 return PRINT_SRC_AND_LOC
;
1962 /* I think the user probably only wants to see one breakpoint
1963 number, not all of them. */
1964 annotate_breakpoint (bs
->breakpoint_at
->number
);
1965 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1966 return PRINT_SRC_AND_LOC
;
1970 case bp_shlib_event
:
1971 /* Did we stop because the user set the stop_on_solib_events
1972 variable? (If so, we report this as a generic, "Stopped due
1973 to shlib event" message.) */
1974 printf_filtered ("Stopped due to shared library event\n");
1975 return PRINT_NOTHING
;
1978 case bp_thread_event
:
1979 /* Not sure how we will get here.
1980 GDB should not stop for these breakpoints. */
1981 printf_filtered ("Thread Event Breakpoint: gdb should not stop!\n");
1982 return PRINT_NOTHING
;
1986 annotate_catchpoint (bs
->breakpoint_at
->number
);
1987 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1988 printf_filtered ("loaded");
1989 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1990 return PRINT_SRC_AND_LOC
;
1993 case bp_catch_unload
:
1994 annotate_catchpoint (bs
->breakpoint_at
->number
);
1995 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1996 printf_filtered ("unloaded");
1997 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1998 return PRINT_SRC_AND_LOC
;
2002 annotate_catchpoint (bs
->breakpoint_at
->number
);
2003 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
2004 printf_filtered ("forked");
2005 printf_filtered (" process %d), ",
2006 bs
->breakpoint_at
->forked_inferior_pid
);
2007 return PRINT_SRC_AND_LOC
;
2010 case bp_catch_vfork
:
2011 annotate_catchpoint (bs
->breakpoint_at
->number
);
2012 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
2013 printf_filtered ("vforked");
2014 printf_filtered (" process %d), ",
2015 bs
->breakpoint_at
->forked_inferior_pid
);
2016 return PRINT_SRC_AND_LOC
;
2020 annotate_catchpoint (bs
->breakpoint_at
->number
);
2021 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
2022 bs
->breakpoint_at
->number
,
2023 bs
->breakpoint_at
->exec_pathname
);
2024 return PRINT_SRC_AND_LOC
;
2027 case bp_catch_catch
:
2028 if (current_exception_event
&&
2029 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
2031 annotate_catchpoint (bs
->breakpoint_at
->number
);
2032 printf_filtered ("\nCatchpoint %d (exception caught), ",
2033 bs
->breakpoint_at
->number
);
2034 printf_filtered ("throw location ");
2035 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2036 printf_filtered ("%s:%d",
2037 CURRENT_EXCEPTION_THROW_FILE
,
2038 CURRENT_EXCEPTION_THROW_LINE
);
2040 printf_filtered ("unknown");
2042 printf_filtered (", catch location ");
2043 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2044 printf_filtered ("%s:%d",
2045 CURRENT_EXCEPTION_CATCH_FILE
,
2046 CURRENT_EXCEPTION_CATCH_LINE
);
2048 printf_filtered ("unknown");
2050 printf_filtered ("\n");
2051 /* don't bother to print location frame info */
2052 return PRINT_SRC_ONLY
;
2056 /* really throw, some other bpstat will handle it */
2057 return PRINT_UNKNOWN
;
2061 case bp_catch_throw
:
2062 if (current_exception_event
&&
2063 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
2065 annotate_catchpoint (bs
->breakpoint_at
->number
);
2066 printf_filtered ("\nCatchpoint %d (exception thrown), ",
2067 bs
->breakpoint_at
->number
);
2068 printf_filtered ("throw location ");
2069 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2070 printf_filtered ("%s:%d",
2071 CURRENT_EXCEPTION_THROW_FILE
,
2072 CURRENT_EXCEPTION_THROW_LINE
);
2074 printf_filtered ("unknown");
2076 printf_filtered (", catch location ");
2077 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2078 printf_filtered ("%s:%d",
2079 CURRENT_EXCEPTION_CATCH_FILE
,
2080 CURRENT_EXCEPTION_CATCH_LINE
);
2082 printf_filtered ("unknown");
2084 printf_filtered ("\n");
2085 /* don't bother to print location frame info */
2086 return PRINT_SRC_ONLY
;
2090 /* really catch, some other bpstat will handle it */
2091 return PRINT_UNKNOWN
;
2096 case bp_hardware_watchpoint
:
2097 if (bs
->old_val
!= NULL
)
2099 annotate_watchpoint (bs
->breakpoint_at
->number
);
2101 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2102 ui_out_field_string (uiout
, "reason", "watchpoint-trigger");
2103 mention (bs
->breakpoint_at
);
2104 ui_out_list_begin (uiout
, "value");
2105 ui_out_text (uiout
, "\nOld value = ");
2106 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2107 ui_out_field_stream (uiout
, "old", stb
);
2108 ui_out_text (uiout
, "\nNew value = ");
2109 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2110 ui_out_field_stream (uiout
, "new", stb
);
2111 ui_out_list_end (uiout
);
2112 ui_out_text (uiout
, "\n");
2114 mention (bs
->breakpoint_at
);
2115 printf_filtered ("\nOld value = ");
2116 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2117 printf_filtered ("\nNew value = ");
2118 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2119 Val_pretty_default
);
2120 printf_filtered ("\n");
2122 value_free (bs
->old_val
);
2125 /* More than one watchpoint may have been triggered. */
2126 return PRINT_UNKNOWN
;
2129 case bp_read_watchpoint
:
2131 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2132 ui_out_field_string (uiout
, "reason", "read-watchpoint-trigger");
2133 mention (bs
->breakpoint_at
);
2134 ui_out_list_begin (uiout
, "value");
2135 ui_out_text (uiout
, "\nValue = ");
2136 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0, Val_pretty_default
);
2137 ui_out_field_stream (uiout
, "value", stb
);
2138 ui_out_list_end (uiout
);
2139 ui_out_text (uiout
, "\n");
2141 mention (bs
->breakpoint_at
);
2142 printf_filtered ("\nValue = ");
2143 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2144 Val_pretty_default
);
2145 printf_filtered ("\n");
2147 return PRINT_UNKNOWN
;
2150 case bp_access_watchpoint
:
2152 if (bs
->old_val
!= NULL
)
2154 annotate_watchpoint (bs
->breakpoint_at
->number
);
2155 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2156 ui_out_field_string (uiout
, "reason", "access-watchpoint-trigger");
2157 mention (bs
->breakpoint_at
);
2158 ui_out_list_begin (uiout
, "value");
2159 ui_out_text (uiout
, "\nOld value = ");
2160 value_print (bs
->old_val
, stb
->stream
, 0, Val_pretty_default
);
2161 ui_out_field_stream (uiout
, "old", stb
);
2162 value_free (bs
->old_val
);
2164 ui_out_text (uiout
, "\nNew value = ");
2168 mention (bs
->breakpoint_at
);
2169 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2170 ui_out_list_begin (uiout
, "value");
2171 ui_out_field_string (uiout
, "reason", "access-watchpoint-trigger");
2172 ui_out_text (uiout
, "\nValue = ");
2174 value_print (bs
->breakpoint_at
->val
, stb
->stream
, 0,Val_pretty_default
);
2175 ui_out_field_stream (uiout
, "new", stb
);
2176 ui_out_list_end (uiout
);
2177 ui_out_text (uiout
, "\n");
2179 if (bs
->old_val
!= NULL
)
2181 annotate_watchpoint (bs
->breakpoint_at
->number
);
2182 mention (bs
->breakpoint_at
);
2183 printf_filtered ("\nOld value = ");
2184 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2185 value_free (bs
->old_val
);
2187 printf_filtered ("\nNew value = ");
2191 mention (bs
->breakpoint_at
);
2192 printf_filtered ("\nValue = ");
2194 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2195 Val_pretty_default
);
2196 printf_filtered ("\n");
2198 return PRINT_UNKNOWN
;
2201 /* Fall through, we don't deal with these types of breakpoints
2206 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2207 ui_out_field_string (uiout
, "reason", "function-finished");
2209 return PRINT_UNKNOWN
;
2214 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2215 ui_out_field_string (uiout
, "reason", "location-reached");
2217 return PRINT_UNKNOWN
;
2222 case bp_longjmp_resume
:
2223 case bp_step_resume
:
2224 case bp_through_sigtramp
:
2225 case bp_watchpoint_scope
:
2228 return PRINT_UNKNOWN
;
2232 /* Generic routine for printing messages indicating why we
2233 stopped. The behavior of this function depends on the value
2234 'print_it' in the bpstat structure. Under some circumstances we
2235 may decide not to print anything here and delegate the task to
2238 static enum print_stop_action
2239 print_bp_stop_message (bpstat bs
)
2241 switch (bs
->print_it
)
2244 /* Nothing should be printed for this bpstat entry. */
2245 return PRINT_UNKNOWN
;
2249 /* We still want to print the frame, but we already printed the
2250 relevant messages. */
2251 return PRINT_SRC_AND_LOC
;
2254 case print_it_normal
:
2255 /* Normal case, we handle everything in print_it_typical. */
2256 return print_it_typical (bs
);
2259 internal_error ("print_bp_stop_message: unrecognized enum value");
2264 /* Print a message indicating what happened. This is called from
2265 normal_stop(). The input to this routine is the head of the bpstat
2266 list - a list of the eventpoints that caused this stop. This
2267 routine calls the generic print routine for printing a message
2268 about reasons for stopping. This will print (for example) the
2269 "Breakpoint n," part of the output. The return value of this
2272 PRINT_UNKNOWN: Means we printed nothing
2273 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2274 code to print the location. An example is
2275 "Breakpoint 1, " which should be followed by
2277 PRINT_SRC_ONLY: Means we printed something, but there is no need
2278 to also print the location part of the message.
2279 An example is the catch/throw messages, which
2280 don't require a location appended to the end.
2281 PRINT_NOTHING: We have done some printing and we don't need any
2282 further info to be printed.*/
2284 enum print_stop_action
2290 /* Maybe another breakpoint in the chain caused us to stop.
2291 (Currently all watchpoints go on the bpstat whether hit or not.
2292 That probably could (should) be changed, provided care is taken
2293 with respect to bpstat_explains_signal). */
2294 for (; bs
; bs
= bs
->next
)
2296 val
= print_bp_stop_message (bs
);
2297 if (val
== PRINT_SRC_ONLY
2298 || val
== PRINT_SRC_AND_LOC
2299 || val
== PRINT_NOTHING
)
2303 /* We reached the end of the chain, or we got a null BS to start
2304 with and nothing was printed. */
2305 return PRINT_UNKNOWN
;
2308 /* Evaluate the expression EXP and return 1 if value is zero.
2309 This is used inside a catch_errors to evaluate the breakpoint condition.
2310 The argument is a "struct expression *" that has been cast to char * to
2311 make it pass through catch_errors. */
2314 breakpoint_cond_eval (exp
)
2317 value_ptr mark
= value_mark ();
2318 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2319 value_free_to_mark (mark
);
2323 /* Allocate a new bpstat and chain it to the current one. */
2326 bpstat_alloc (b
, cbs
)
2327 register struct breakpoint
*b
;
2328 bpstat cbs
; /* Current "bs" value */
2332 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2334 bs
->breakpoint_at
= b
;
2335 /* If the condition is false, etc., don't do the commands. */
2336 bs
->commands
= NULL
;
2338 bs
->print_it
= print_it_normal
;
2342 /* Possible return values for watchpoint_check (this can't be an enum
2343 because of check_errors). */
2344 /* The watchpoint has been deleted. */
2345 #define WP_DELETED 1
2346 /* The value has changed. */
2347 #define WP_VALUE_CHANGED 2
2348 /* The value has not changed. */
2349 #define WP_VALUE_NOT_CHANGED 3
2351 #define BP_TEMPFLAG 1
2352 #define BP_HARDWAREFLAG 2
2354 /* Check watchpoint condition. */
2357 watchpoint_check (p
)
2360 bpstat bs
= (bpstat
) p
;
2361 struct breakpoint
*b
;
2362 struct frame_info
*fr
;
2363 int within_current_scope
;
2365 b
= bs
->breakpoint_at
;
2367 if (b
->exp_valid_block
== NULL
)
2368 within_current_scope
= 1;
2371 /* There is no current frame at this moment. If we're going to have
2372 any chance of handling watchpoints on local variables, we'll need
2373 the frame chain (so we can determine if we're in scope). */
2374 reinit_frame_cache ();
2375 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2376 within_current_scope
= (fr
!= NULL
);
2377 if (within_current_scope
)
2378 /* If we end up stopping, the current frame will get selected
2379 in normal_stop. So this call to select_frame won't affect
2381 select_frame (fr
, -1);
2384 if (within_current_scope
)
2386 /* We use value_{,free_to_}mark because it could be a
2387 *long* time before we return to the command level and
2388 call free_all_values. We can't call free_all_values because
2389 we might be in the middle of evaluating a function call. */
2391 value_ptr mark
= value_mark ();
2392 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2393 if (!value_equal (b
->val
, new_val
))
2395 release_value (new_val
);
2396 value_free_to_mark (mark
);
2397 bs
->old_val
= b
->val
;
2399 /* We will stop here */
2400 return WP_VALUE_CHANGED
;
2404 /* Nothing changed, don't do anything. */
2405 value_free_to_mark (mark
);
2406 /* We won't stop here */
2407 return WP_VALUE_NOT_CHANGED
;
2412 /* This seems like the only logical thing to do because
2413 if we temporarily ignored the watchpoint, then when
2414 we reenter the block in which it is valid it contains
2415 garbage (in the case of a function, it may have two
2416 garbage values, one before and one after the prologue).
2417 So we can't even detect the first assignment to it and
2418 watch after that (since the garbage may or may not equal
2419 the first value assigned). */
2420 /* We print all the stop information in print_it_typical(), but
2421 in this case, by the time we call print_it_typical() this bp
2422 will be deleted already. So we have no choice but print the
2423 information here. */
2425 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
2426 ui_out_field_string (uiout
, "reason", "watchpoint-scope");
2427 ui_out_text (uiout
, "\nWatchpoint ");
2428 ui_out_field_int (uiout
, "wpnum", bs
->breakpoint_at
->number
);
2429 ui_out_text (uiout
, " deleted because the program has left the block in\n\
2430 which its expression is valid.\n");
2433 Watchpoint %d deleted because the program has left the block in\n\
2434 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2437 if (b
->related_breakpoint
)
2438 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2439 b
->disposition
= del_at_next_stop
;
2445 /* Get a bpstat associated with having just stopped at address *PC
2446 and frame address CORE_ADDRESS. Update *PC to point at the
2447 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2448 if this is known to not be a real breakpoint (it could still be a
2449 watchpoint, though). */
2451 /* Determine whether we stopped at a breakpoint, etc, or whether we
2452 don't understand this stop. Result is a chain of bpstat's such that:
2454 if we don't understand the stop, the result is a null pointer.
2456 if we understand why we stopped, the result is not null.
2458 Each element of the chain refers to a particular breakpoint or
2459 watchpoint at which we have stopped. (We may have stopped for
2460 several reasons concurrently.)
2462 Each element of the chain has valid next, breakpoint_at,
2463 commands, FIXME??? fields. */
2466 bpstat_stop_status (pc
, not_a_breakpoint
)
2468 int not_a_breakpoint
;
2470 register struct breakpoint
*b
, *temp
;
2472 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2473 int real_breakpoint
= 0;
2474 /* Root of the chain of bpstat's */
2475 struct bpstats root_bs
[1];
2476 /* Pointer to the last thing in the chain currently. */
2477 bpstat bs
= root_bs
;
2478 static char message1
[] =
2479 "Error evaluating expression for watchpoint %d\n";
2480 char message
[sizeof (message1
) + 30 /* slop */ ];
2482 /* Get the address where the breakpoint would have been. */
2483 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2484 0 : DECR_PC_AFTER_BREAK
);
2486 ALL_BREAKPOINTS_SAFE (b
, temp
)
2488 if (b
->enable
== disabled
2489 || b
->enable
== shlib_disabled
2490 || b
->enable
== call_disabled
)
2493 if (b
->type
!= bp_watchpoint
2494 && b
->type
!= bp_hardware_watchpoint
2495 && b
->type
!= bp_read_watchpoint
2496 && b
->type
!= bp_access_watchpoint
2497 && b
->type
!= bp_hardware_breakpoint
2498 && b
->type
!= bp_catch_fork
2499 && b
->type
!= bp_catch_vfork
2500 && b
->type
!= bp_catch_exec
2501 && b
->type
!= bp_catch_catch
2502 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2503 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2504 (overlay_debugging
&& /* overlay doesn't match */
2505 section_is_overlay (b
->section
) &&
2506 !section_is_mapped (b
->section
)))
2509 if (b
->type
== bp_hardware_breakpoint
2510 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2513 /* Is this a catchpoint of a load or unload? If so, did we
2514 get a load or unload of the specified library? If not,
2516 if ((b
->type
== bp_catch_load
)
2517 #if defined(SOLIB_HAVE_LOAD_EVENT)
2518 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2519 || ((b
->dll_pathname
!= NULL
)
2520 && (strcmp (b
->dll_pathname
,
2521 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2527 if ((b
->type
== bp_catch_unload
)
2528 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2529 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2530 || ((b
->dll_pathname
!= NULL
)
2531 && (strcmp (b
->dll_pathname
,
2532 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2538 if ((b
->type
== bp_catch_fork
)
2539 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2542 if ((b
->type
== bp_catch_vfork
)
2543 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2546 if ((b
->type
== bp_catch_exec
)
2547 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2550 if (ep_is_exception_catchpoint (b
) &&
2551 !(current_exception_event
= target_get_current_exception_event ()))
2554 /* Come here if it's a watchpoint, or if the break address matches */
2556 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2558 /* Watchpoints may change this, if not found to have triggered. */
2562 sprintf (message
, message1
, b
->number
);
2563 if (b
->type
== bp_watchpoint
||
2564 b
->type
== bp_hardware_watchpoint
)
2566 switch (catch_errors (watchpoint_check
, bs
, message
,
2570 /* We've already printed what needs to be printed. */
2571 /* Actually this is superfluous, because by the time we
2572 call print_it_typical() the wp will be already deleted,
2573 and the function will return immediately. */
2574 bs
->print_it
= print_it_done
;
2577 case WP_VALUE_CHANGED
:
2581 case WP_VALUE_NOT_CHANGED
:
2583 bs
->print_it
= print_it_noop
;
2590 /* Error from catch_errors. */
2591 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2592 if (b
->related_breakpoint
)
2593 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2594 b
->disposition
= del_at_next_stop
;
2595 /* We've already printed what needs to be printed. */
2596 bs
->print_it
= print_it_done
;
2602 else if (b
->type
== bp_read_watchpoint
||
2603 b
->type
== bp_access_watchpoint
)
2609 addr
= target_stopped_data_address ();
2612 for (v
= b
->val_chain
; v
; v
= v
->next
)
2614 if (VALUE_LVAL (v
) == lval_memory
2615 && ! VALUE_LAZY (v
))
2617 struct type
*vtype
= check_typedef (VALUE_TYPE (v
));
2619 if (v
== b
->val_chain
2620 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
2621 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
2625 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2626 /* Exact match not required. Within range is
2628 if (addr
>= vaddr
&&
2629 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2635 switch (catch_errors (watchpoint_check
, bs
, message
,
2639 /* We've already printed what needs to be printed. */
2640 bs
->print_it
= print_it_done
;
2643 case WP_VALUE_CHANGED
:
2644 if (b
->type
== bp_read_watchpoint
)
2646 /* Don't stop: read watchpoints shouldn't fire if
2647 the value has changed. This is for targets which
2648 cannot set read-only watchpoints. */
2649 bs
->print_it
= print_it_noop
;
2655 case WP_VALUE_NOT_CHANGED
:
2662 /* Error from catch_errors. */
2663 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2664 if (b
->related_breakpoint
)
2665 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2666 b
->disposition
= del_at_next_stop
;
2667 /* We've already printed what needs to be printed. */
2668 bs
->print_it
= print_it_done
;
2671 else /* found == 0 */
2673 /* This is a case where some watchpoint(s) triggered,
2674 but not at the address of this watchpoint (FOUND
2675 was left zero). So don't print anything for this
2677 bs
->print_it
= print_it_noop
;
2684 /* By definition, an encountered breakpoint is a triggered
2688 real_breakpoint
= 1;
2692 b
->frame
!= (get_current_frame ())->frame
)
2696 int value_is_zero
= 0;
2700 /* Need to select the frame, with all that implies
2701 so that the conditions will have the right context. */
2702 select_frame (get_current_frame (), 0);
2704 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2705 "Error in testing breakpoint condition:\n",
2707 /* FIXME-someday, should give breakpoint # */
2710 if (b
->cond
&& value_is_zero
)
2713 /* Don't consider this a hit. */
2716 else if (b
->ignore_count
> 0)
2719 annotate_ignore_count_change ();
2724 /* We will stop here */
2725 if (b
->disposition
== disable
)
2726 b
->enable
= disabled
;
2727 bs
->commands
= b
->commands
;
2731 (STREQ ("silent", bs
->commands
->line
) ||
2732 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2734 bs
->commands
= bs
->commands
->next
;
2739 /* Print nothing for this entry if we dont stop or if we dont print. */
2740 if (bs
->stop
== 0 || bs
->print
== 0)
2741 bs
->print_it
= print_it_noop
;
2744 bs
->next
= NULL
; /* Terminate the chain */
2745 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2747 if (real_breakpoint
&& bs
)
2749 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2751 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2753 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2759 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2762 #if defined (SHIFT_INST_REGS)
2764 #else /* No SHIFT_INST_REGS. */
2766 #endif /* No SHIFT_INST_REGS. */
2771 /* The value of a hardware watchpoint hasn't changed, but the
2772 intermediate memory locations we are watching may have. */
2773 if (bs
&& !bs
->stop
&&
2774 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2775 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2776 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2778 remove_breakpoints ();
2779 insert_breakpoints ();
2784 /* Tell what to do about this bpstat. */
2789 /* Classify each bpstat as one of the following. */
2792 /* This bpstat element has no effect on the main_action. */
2795 /* There was a watchpoint, stop but don't print. */
2798 /* There was a watchpoint, stop and print. */
2801 /* There was a breakpoint but we're not stopping. */
2804 /* There was a breakpoint, stop but don't print. */
2807 /* There was a breakpoint, stop and print. */
2810 /* We hit the longjmp breakpoint. */
2813 /* We hit the longjmp_resume breakpoint. */
2816 /* We hit the step_resume breakpoint. */
2819 /* We hit the through_sigtramp breakpoint. */
2822 /* We hit the shared library event breakpoint. */
2825 /* We caught a shared library event. */
2828 /* This is just used to count how many enums there are. */
2832 /* Here is the table which drives this routine. So that we can
2833 format it pretty, we define some abbreviations for the
2834 enum bpstat_what codes. */
2835 #define kc BPSTAT_WHAT_KEEP_CHECKING
2836 #define ss BPSTAT_WHAT_STOP_SILENT
2837 #define sn BPSTAT_WHAT_STOP_NOISY
2838 #define sgl BPSTAT_WHAT_SINGLE
2839 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2840 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2841 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2842 #define sr BPSTAT_WHAT_STEP_RESUME
2843 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2844 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2845 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2847 /* "Can't happen." Might want to print an error message.
2848 abort() is not out of the question, but chances are GDB is just
2849 a bit confused, not unusable. */
2850 #define err BPSTAT_WHAT_STOP_NOISY
2852 /* Given an old action and a class, come up with a new action. */
2853 /* One interesting property of this table is that wp_silent is the same
2854 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2855 after stopping, the check for whether to step over a breakpoint
2856 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2857 reference to how we stopped. We retain separate wp_silent and
2858 bp_silent codes in case we want to change that someday.
2860 Another possibly interesting property of this table is that
2861 there's a partial ordering, priority-like, of the actions. Once
2862 you've decided that some action is appropriate, you'll never go
2863 back and decide something of a lower priority is better. The
2866 kc < clr sgl shl slr sn sr ss ts
2867 sgl < clrs shl shlr slr sn sr ss ts
2868 slr < err shl shlr sn sr ss ts
2869 clr < clrs err shl shlr sn sr ss ts
2870 clrs < err shl shlr sn sr ss ts
2871 ss < shl shlr sn sr ts
2878 What I think this means is that we don't need a damned table
2879 here. If you just put the rows and columns in the right order,
2880 it'd look awfully regular. We could simply walk the bpstat list
2881 and choose the highest priority action we find, with a little
2882 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2883 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2884 is messy anyway). */
2886 /* step_resume entries: a step resume breakpoint overrides another
2887 breakpoint of signal handling (see comment in wait_for_inferior
2888 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2889 /* We handle the through_sigtramp_breakpoint the same way; having both
2890 one of those and a step_resume_breakpoint is probably very rare (?). */
2892 static const enum bpstat_what_main_action
2893 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2896 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2899 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2901 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2903 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2905 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2907 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2909 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2911 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2913 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2915 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2917 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2919 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2921 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2936 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2937 struct bpstat_what retval
;
2939 retval
.call_dummy
= 0;
2940 for (; bs
!= NULL
; bs
= bs
->next
)
2942 enum class bs_class
= no_effect
;
2943 if (bs
->breakpoint_at
== NULL
)
2944 /* I suspect this can happen if it was a momentary breakpoint
2945 which has since been deleted. */
2947 switch (bs
->breakpoint_at
->type
)
2953 case bp_hardware_breakpoint
:
2959 bs_class
= bp_noisy
;
2961 bs_class
= bp_silent
;
2964 bs_class
= bp_nostop
;
2967 case bp_hardware_watchpoint
:
2968 case bp_read_watchpoint
:
2969 case bp_access_watchpoint
:
2973 bs_class
= wp_noisy
;
2975 bs_class
= wp_silent
;
2978 /* There was a watchpoint, but we're not stopping.
2979 This requires no further action. */
2980 bs_class
= no_effect
;
2983 bs_class
= long_jump
;
2985 case bp_longjmp_resume
:
2986 bs_class
= long_resume
;
2988 case bp_step_resume
:
2991 bs_class
= step_resume
;
2994 /* It is for the wrong frame. */
2995 bs_class
= bp_nostop
;
2997 case bp_through_sigtramp
:
2998 bs_class
= through_sig
;
3000 case bp_watchpoint_scope
:
3001 bs_class
= bp_nostop
;
3003 case bp_shlib_event
:
3004 bs_class
= shlib_event
;
3006 case bp_thread_event
:
3007 bs_class
= bp_nostop
;
3010 case bp_catch_unload
:
3011 /* Only if this catchpoint triggered should we cause the
3012 step-out-of-dld behaviour. Otherwise, we ignore this
3015 bs_class
= catch_shlib_event
;
3017 bs_class
= no_effect
;
3020 case bp_catch_vfork
:
3025 bs_class
= bp_noisy
;
3027 bs_class
= bp_silent
;
3030 /* There was a catchpoint, but we're not stopping.
3031 This requires no further action. */
3032 bs_class
= no_effect
;
3034 case bp_catch_catch
:
3035 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
3036 bs_class
= bp_nostop
;
3038 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
3040 case bp_catch_throw
:
3041 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
3042 bs_class
= bp_nostop
;
3044 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
3047 /* Make sure the action is stop (silent or noisy),
3048 so infrun.c pops the dummy frame. */
3049 bs_class
= bp_silent
;
3050 retval
.call_dummy
= 1;
3053 current_action
= table
[(int) bs_class
][(int) current_action
];
3055 retval
.main_action
= current_action
;
3059 /* Nonzero if we should step constantly (e.g. watchpoints on machines
3060 without hardware support). This isn't related to a specific bpstat,
3061 just to things like whether watchpoints are set. */
3064 bpstat_should_step ()
3066 struct breakpoint
*b
;
3068 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
3073 /* Nonzero if there are enabled hardware watchpoints. */
3075 bpstat_have_active_hw_watchpoints ()
3077 struct breakpoint
*b
;
3079 if ((b
->enable
== enabled
) &&
3081 ((b
->type
== bp_hardware_watchpoint
) ||
3082 (b
->type
== bp_read_watchpoint
) ||
3083 (b
->type
== bp_access_watchpoint
)))
3089 /* Given a bpstat that records zero or more triggered eventpoints, this
3090 function returns another bpstat which contains only the catchpoints
3091 on that first list, if any. */
3093 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
3097 struct bpstats root_bs
[1];
3098 bpstat bs
= root_bs
;
3099 struct breakpoint
*ep
;
3102 bpstat_clear (cp_list
);
3103 root_bs
->next
= NULL
;
3105 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
3107 /* Is this eventpoint a catchpoint? If not, ignore it. */
3108 ep
= ep_list
->breakpoint_at
;
3111 if ((ep
->type
!= bp_catch_load
) &&
3112 (ep
->type
!= bp_catch_unload
) &&
3113 (ep
->type
!= bp_catch_catch
) &&
3114 (ep
->type
!= bp_catch_throw
))
3115 /* pai: (temp) ADD fork/vfork here!! */
3118 /* Yes; add it to the list. */
3119 bs
= bpstat_alloc (ep
, bs
);
3124 #if defined(SOLIB_ADD)
3125 /* Also, for each triggered catchpoint, tag it with the name of
3126 the library that caused this trigger. (We copy the name now,
3127 because it's only guaranteed to be available NOW, when the
3128 catchpoint triggers. Clients who may wish to know the name
3129 later must get it from the catchpoint itself.) */
3130 if (ep
->triggered_dll_pathname
!= NULL
)
3131 free (ep
->triggered_dll_pathname
);
3132 if (ep
->type
== bp_catch_load
)
3133 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
3135 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
3137 dll_pathname
= NULL
;
3141 ep
->triggered_dll_pathname
= (char *)
3142 xmalloc (strlen (dll_pathname
) + 1);
3143 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
3146 ep
->triggered_dll_pathname
= NULL
;
3152 /* Print B to gdb_stdout. */
3154 print_one_breakpoint (struct breakpoint
*b
,
3155 CORE_ADDR
*last_addr
)
3157 register struct command_line
*l
;
3158 register struct symbol
*sym
;
3159 struct ep_type_description
3164 static struct ep_type_description bptypes
[] =
3166 {bp_none
, "?deleted?"},
3167 {bp_breakpoint
, "breakpoint"},
3168 {bp_hardware_breakpoint
, "hw breakpoint"},
3169 {bp_until
, "until"},
3170 {bp_finish
, "finish"},
3171 {bp_watchpoint
, "watchpoint"},
3172 {bp_hardware_watchpoint
, "hw watchpoint"},
3173 {bp_read_watchpoint
, "read watchpoint"},
3174 {bp_access_watchpoint
, "acc watchpoint"},
3175 {bp_longjmp
, "longjmp"},
3176 {bp_longjmp_resume
, "longjmp resume"},
3177 {bp_step_resume
, "step resume"},
3178 {bp_through_sigtramp
, "sigtramp"},
3179 {bp_watchpoint_scope
, "watchpoint scope"},
3180 {bp_call_dummy
, "call dummy"},
3181 {bp_shlib_event
, "shlib events"},
3182 {bp_thread_event
, "thread events"},
3183 {bp_catch_load
, "catch load"},
3184 {bp_catch_unload
, "catch unload"},
3185 {bp_catch_fork
, "catch fork"},
3186 {bp_catch_vfork
, "catch vfork"},
3187 {bp_catch_exec
, "catch exec"},
3188 {bp_catch_catch
, "catch catch"},
3189 {bp_catch_throw
, "catch throw"}
3192 static char *bpdisps
[] =
3193 {"del", "dstp", "dis", "keep"};
3194 static char bpenables
[] = "nynny";
3195 char wrap_indent
[80];
3197 struct ui_stream
*stb
= ui_out_stream_new (uiout
);
3198 struct cleanup
*old_chain
= make_cleanup_ui_out_stream_delete (stb
);
3203 ui_out_list_begin (uiout
, "bkpt");
3209 ui_out_field_int (uiout
, "number", b
->number
);
3211 printf_filtered ("%-3d ", b
->number
);
3216 if (((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
3217 || ((int) b
->type
!= bptypes
[(int) b
->type
].type
))
3218 internal_error ("bptypes table does not describe type #%d.",
3221 ui_out_field_string (uiout
, "type", bptypes
[(int) b
->type
].description
);
3223 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
3229 ui_out_field_string (uiout
, "disp", bpdisps
[(int) b
->disposition
]);
3231 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
3237 ui_out_field_fmt (uiout
, "enabled", "%c", bpenables
[(int) b
->enable
]);
3238 ui_out_spaces (uiout
, 2);
3240 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
3244 strcpy (wrap_indent
, " ");
3246 strcat (wrap_indent
, " ");
3250 internal_error ("print_one_breakpoint: bp_none encountered\n");
3254 case bp_hardware_watchpoint
:
3255 case bp_read_watchpoint
:
3256 case bp_access_watchpoint
:
3257 /* Field 4, the address, is omitted (which makes the columns
3258 not line up too nicely with the headers, but the effect
3259 is relatively readable). */
3262 ui_out_field_skip (uiout
, "addr");
3264 print_expression (b
->exp
, stb
->stream
);
3265 ui_out_field_stream (uiout
, "what", stb
);
3268 print_expression (b
->exp
, gdb_stdout
);
3273 case bp_catch_unload
:
3274 /* Field 4, the address, is omitted (which makes the columns
3275 not line up too nicely with the headers, but the effect
3276 is relatively readable). */
3279 ui_out_field_skip (uiout
, "addr");
3281 if (b
->dll_pathname
== NULL
)
3283 ui_out_field_string (uiout
, "what", "<any library>");
3284 ui_out_spaces (uiout
, 1);
3288 ui_out_text (uiout
, "library \"");
3289 ui_out_field_string (uiout
, "what", b
->dll_pathname
);
3290 ui_out_text (uiout
, "\" ");
3294 if (b
->dll_pathname
== NULL
)
3295 printf_filtered ("<any library> ");
3297 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
3302 case bp_catch_vfork
:
3303 /* Field 4, the address, is omitted (which makes the columns
3304 not line up too nicely with the headers, but the effect
3305 is relatively readable). */
3308 ui_out_field_skip (uiout
, "addr");
3310 if (b
->forked_inferior_pid
!= 0)
3312 ui_out_text (uiout
, "process ");
3313 ui_out_field_int (uiout
, "what", b
->forked_inferior_pid
);
3314 ui_out_spaces (uiout
, 1);
3318 if (b
->forked_inferior_pid
!= 0)
3319 printf_filtered ("process %d ", b
->forked_inferior_pid
);
3324 /* Field 4, the address, is omitted (which makes the columns
3325 not line up too nicely with the headers, but the effect
3326 is relatively readable). */
3329 ui_out_field_skip (uiout
, "addr");
3331 if (b
->exec_pathname
!= NULL
)
3333 ui_out_text (uiout
, "program \"");
3334 ui_out_field_string (uiout
, "what", b
->exec_pathname
);
3335 ui_out_text (uiout
, "\" ");
3339 if (b
->exec_pathname
!= NULL
)
3340 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
3344 case bp_catch_catch
:
3345 /* Field 4, the address, is omitted (which makes the columns
3346 not line up too nicely with the headers, but the effect
3347 is relatively readable). */
3350 ui_out_field_skip (uiout
, "addr");
3352 ui_out_field_string (uiout
, "what", "exception catch");
3353 ui_out_spaces (uiout
, 1);
3356 printf_filtered ("exception catch ");
3360 case bp_catch_throw
:
3361 /* Field 4, the address, is omitted (which makes the columns
3362 not line up too nicely with the headers, but the effect
3363 is relatively readable). */
3366 ui_out_field_skip (uiout
, "addr");
3368 ui_out_field_string (uiout
, "what", "exception throw");
3369 ui_out_spaces (uiout
, 1);
3372 printf_filtered ("exception throw ");
3377 case bp_hardware_breakpoint
:
3381 case bp_longjmp_resume
:
3382 case bp_step_resume
:
3383 case bp_through_sigtramp
:
3384 case bp_watchpoint_scope
:
3386 case bp_shlib_event
:
3387 case bp_thread_event
:
3392 ui_out_field_core_addr (uiout
, "addr", b
->address
);
3395 *last_addr
= b
->address
;
3398 sym
= find_pc_sect_function (b
->address
, b
->section
);
3401 ui_out_text (uiout
, "in ");
3402 ui_out_field_string (uiout
, "func",
3403 SYMBOL_SOURCE_NAME (sym
));
3404 ui_out_wrap_hint (uiout
, wrap_indent
);
3405 ui_out_text (uiout
, " at ");
3407 ui_out_field_string (uiout
, "file", b
->source_file
);
3408 ui_out_text (uiout
, ":");
3409 ui_out_field_int (uiout
, "line", b
->line_number
);
3413 print_address_symbolic (b
->address
, stb
->stream
, demangle
, "");
3414 ui_out_field_stream (uiout
, "at", stb
);
3420 /* FIXME-32x64: need a print_address_numeric with
3424 local_hex_string_custom
3425 ((unsigned long) b
->address
, "08l"));
3428 *last_addr
= b
->address
;
3431 sym
= find_pc_sect_function (b
->address
, b
->section
);
3434 fputs_filtered ("in ", gdb_stdout
);
3435 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3436 wrap_here (wrap_indent
);
3437 fputs_filtered (" at ", gdb_stdout
);
3439 fputs_filtered (b
->source_file
, gdb_stdout
);
3440 printf_filtered (":%d", b
->line_number
);
3443 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3448 if (b
->thread
!= -1)
3451 /* FIXME: This seems to be redundant and lost here; see the
3452 "stop only in" line a little further down. */
3453 ui_out_text (uiout
, " thread ");
3454 ui_out_field_int (uiout
, "thread", b
->thread
);
3456 printf_filtered (" thread %d", b
->thread
);
3461 ui_out_text (uiout
, "\n");
3463 printf_filtered ("\n");
3470 ui_out_text (uiout
, "\tstop only in stack frame at ");
3471 ui_out_field_core_addr (uiout
, "frame", b
->frame
);
3472 ui_out_text (uiout
, "\n");
3474 printf_filtered ("\tstop only in stack frame at ");
3475 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3476 printf_filtered ("\n");
3484 ui_out_text (uiout
, "\tstop only if ");
3485 print_expression (b
->cond
, stb
->stream
);
3486 ui_out_field_stream (uiout
, "cond", stb
);
3487 ui_out_text (uiout
, "\n");
3489 printf_filtered ("\tstop only if ");
3490 print_expression (b
->cond
, gdb_stdout
);
3491 printf_filtered ("\n");
3495 if (b
->thread
!= -1)
3497 /* FIXME should make an annotation for this */
3499 ui_out_text (uiout
, "\tstop only in thread ");
3500 ui_out_field_int (uiout
, "thread", b
->thread
);
3501 ui_out_text (uiout
, "\n");
3503 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3507 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3509 /* FIXME should make an annotation for this */
3511 if (ep_is_catchpoint (b
))
3512 ui_out_text (uiout
, "\tcatchpoint");
3514 ui_out_text (uiout
, "\tbreakpoint");
3515 ui_out_text (uiout
, " already hit ");
3516 ui_out_field_int (uiout
, "times", b
->hit_count
);
3517 if (b
->hit_count
== 1)
3518 ui_out_text (uiout
, " time\n");
3520 ui_out_text (uiout
, " times\n");
3522 if (ep_is_catchpoint (b
))
3523 printf_filtered ("\tcatchpoint");
3525 printf_filtered ("\tbreakpoint");
3526 printf_filtered (" already hit %d time%s\n",
3527 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3532 /* Output the count also if it is zero, but only if this is
3533 mi. FIXME: Should have a better test for this. */
3534 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
3535 if (show_breakpoint_hit_counts
&& b
->hit_count
== 0)
3536 ui_out_field_int (uiout
, "times", b
->hit_count
);
3539 if (b
->ignore_count
)
3543 ui_out_text (uiout
, "\tignore next ");
3544 ui_out_field_int (uiout
, "ignore", b
->ignore_count
);
3545 ui_out_text (uiout
, " hits\n");
3547 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3551 if ((l
= b
->commands
))
3555 ui_out_list_begin (uiout
, "script");
3556 print_command_lines (uiout
, l
, 4);
3557 ui_out_list_end (uiout
);
3561 print_command_line (l
, 4, gdb_stdout
);
3567 ui_out_list_end (uiout
);
3568 do_cleanups (old_chain
);
3572 struct captured_breakpoint_query_args
3578 do_captured_breakpoint_query (void *data
)
3580 struct captured_breakpoint_query_args
*args
= data
;
3581 register struct breakpoint
*b
;
3582 CORE_ADDR dummy_addr
= 0;
3585 if (args
->bnum
== b
->number
)
3587 print_one_breakpoint (b
, &dummy_addr
);
3595 gdb_breakpoint_query (/* output object, */ int bnum
)
3597 struct captured_breakpoint_query_args args
;
3599 /* For the moment we don't trust print_one_breakpoint() to not throw
3601 return catch_errors (do_captured_breakpoint_query
, &args
,
3602 NULL
, RETURN_MASK_ALL
);
3605 /* Print information on breakpoint number BNUM, or -1 if all.
3606 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
3607 is nonzero, process only watchpoints. */
3610 breakpoint_1 (bnum
, allflag
)
3614 register struct breakpoint
*b
;
3615 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
3616 int found_a_breakpoint
= 0;
3620 ui_out_table_begin (uiout
, 6, "BreakpointTable");
3622 ui_out_table_begin (uiout
, 5, "BreakpointTable");
3627 || bnum
== b
->number
)
3629 /* We only print out user settable breakpoints unless the
3632 && b
->type
!= bp_breakpoint
3633 && b
->type
!= bp_catch_load
3634 && b
->type
!= bp_catch_unload
3635 && b
->type
!= bp_catch_fork
3636 && b
->type
!= bp_catch_vfork
3637 && b
->type
!= bp_catch_exec
3638 && b
->type
!= bp_catch_catch
3639 && b
->type
!= bp_catch_throw
3640 && b
->type
!= bp_hardware_breakpoint
3641 && b
->type
!= bp_watchpoint
3642 && b
->type
!= bp_read_watchpoint
3643 && b
->type
!= bp_access_watchpoint
3644 && b
->type
!= bp_hardware_watchpoint
)
3647 if (!found_a_breakpoint
++)
3649 annotate_breakpoints_headers ();
3652 ui_out_table_header (uiout
, 3, ui_left
, "Num"); /* 1 */
3654 ui_out_table_header (uiout
, 14, ui_left
, "Type"); /* 2 */
3656 ui_out_table_header (uiout
, 4, ui_left
, "Disp"); /* 3 */
3658 ui_out_table_header (uiout
, 3, ui_left
, "Enb"); /* 4 */
3662 ui_out_table_header (uiout
, 10, ui_left
, "Address"); /* 5 */
3665 ui_out_table_header (uiout
, 40, ui_noalign
, "What"); /* 6 */
3666 ui_out_table_body (uiout
);
3669 printf_filtered ("Num ");
3671 printf_filtered ("Type ");
3673 printf_filtered ("Disp ");
3675 printf_filtered ("Enb ");
3679 printf_filtered ("Address ");
3682 printf_filtered ("What\n");
3684 annotate_breakpoints_table ();
3687 print_one_breakpoint (b
, &last_addr
);
3690 if (!found_a_breakpoint
)
3694 ui_out_message (uiout
, 0, "No breakpoints or watchpoints.\n");
3696 ui_out_message (uiout
, 0, "No breakpoint or watchpoint number %d.\n",
3700 printf_filtered ("No breakpoints or watchpoints.\n");
3702 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3707 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3708 that a comparison of an unsigned with -1 is always false. */
3709 if (last_addr
!= (CORE_ADDR
) -1)
3710 set_next_address (last_addr
);
3714 ui_out_table_end (uiout
);
3716 /* FIXME? Should this be moved up so that it is only called when
3717 there have been breakpoints? */
3718 annotate_breakpoints_table_end ();
3723 breakpoints_info (bnum_exp
, from_tty
)
3730 bnum
= parse_and_eval_address (bnum_exp
);
3732 breakpoint_1 (bnum
, 0);
3737 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3744 bnum
= parse_and_eval_address (bnum_exp
);
3746 breakpoint_1 (bnum
, 1);
3749 /* Print a message describing any breakpoints set at PC. */
3752 describe_other_breakpoints (pc
, section
)
3756 register int others
= 0;
3757 register struct breakpoint
*b
;
3760 if (b
->address
== pc
)
3761 if (overlay_debugging
== 0 ||
3762 b
->section
== section
)
3766 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3768 if (b
->address
== pc
)
3769 if (overlay_debugging
== 0 ||
3770 b
->section
== section
)
3776 ((b
->enable
== disabled
||
3777 b
->enable
== shlib_disabled
||
3778 b
->enable
== call_disabled
) ? " (disabled)"
3779 : b
->enable
== permanent
? " (permanent)"
3781 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3783 printf_filtered ("also set at pc ");
3784 print_address_numeric (pc
, 1, gdb_stdout
);
3785 printf_filtered (".\n");
3789 /* Set the default place to put a breakpoint
3790 for the `break' command with no arguments. */
3793 set_default_breakpoint (valid
, addr
, symtab
, line
)
3796 struct symtab
*symtab
;
3799 default_breakpoint_valid
= valid
;
3800 default_breakpoint_address
= addr
;
3801 default_breakpoint_symtab
= symtab
;
3802 default_breakpoint_line
= line
;
3805 /* Rescan breakpoints at address ADDRESS,
3806 marking the first one as "first" and any others as "duplicates".
3807 This is so that the bpt instruction is only inserted once.
3808 If we have a permanent breakpoint at ADDRESS, make that one
3809 the official one, and the rest as duplicates. */
3812 check_duplicates (address
, section
)
3816 register struct breakpoint
*b
;
3817 register int count
= 0;
3818 struct breakpoint
*perm_bp
= 0;
3820 if (address
== 0) /* Watchpoints are uninteresting */
3824 if (b
->enable
!= disabled
3825 && b
->enable
!= shlib_disabled
3826 && b
->enable
!= call_disabled
3827 && b
->address
== address
3828 && (overlay_debugging
== 0 || b
->section
== section
))
3830 /* Have we found a permanent breakpoint? */
3831 if (b
->enable
== permanent
)
3838 b
->duplicate
= count
> 1;
3841 /* If we found a permanent breakpoint at this address, go over the
3842 list again and declare all the other breakpoints there to be the
3846 perm_bp
->duplicate
= 0;
3848 /* Permanent breakpoint should always be inserted. */
3849 if (! perm_bp
->inserted
)
3850 internal_error ("allegedly permanent breakpoint is not "
3851 "actually inserted");
3857 internal_error ("another breakpoint was inserted on top of "
3858 "a permanent breakpoint");
3860 if (b
->enable
!= disabled
3861 && b
->enable
!= shlib_disabled
3862 && b
->enable
!= call_disabled
3863 && b
->address
== address
3864 && (overlay_debugging
== 0 || b
->section
== section
))
3870 /* Low level routine to set a breakpoint.
3871 Takes as args the three things that every breakpoint must have.
3872 Returns the breakpoint object so caller can set other things.
3873 Does not set the breakpoint number!
3874 Does not print anything.
3876 ==> This routine should not be called if there is a chance of later
3877 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3878 your arguments BEFORE calling this routine! */
3881 set_raw_breakpoint (sal
)
3882 struct symtab_and_line sal
;
3884 register struct breakpoint
*b
, *b1
;
3886 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3887 memset (b
, 0, sizeof (*b
));
3888 b
->address
= sal
.pc
;
3889 if (sal
.symtab
== NULL
)
3890 b
->source_file
= NULL
;
3892 b
->source_file
= savestring (sal
.symtab
->filename
,
3893 strlen (sal
.symtab
->filename
));
3894 b
->section
= sal
.section
;
3895 b
->language
= current_language
->la_language
;
3896 b
->input_radix
= input_radix
;
3898 b
->line_number
= sal
.line
;
3899 b
->enable
= enabled
;
3902 b
->ignore_count
= 0;
3905 b
->dll_pathname
= NULL
;
3906 b
->triggered_dll_pathname
= NULL
;
3907 b
->forked_inferior_pid
= 0;
3908 b
->exec_pathname
= NULL
;
3910 /* Add this breakpoint to the end of the chain
3911 so that a list of breakpoints will come out in order
3912 of increasing numbers. */
3914 b1
= breakpoint_chain
;
3916 breakpoint_chain
= b
;
3924 check_duplicates (sal
.pc
, sal
.section
);
3925 breakpoints_changed ();
3931 /* Note that the breakpoint object B describes a permanent breakpoint
3932 instruction, hard-wired into the inferior's code. */
3934 make_breakpoint_permanent (struct breakpoint
*b
)
3936 b
->enable
= permanent
;
3938 /* By definition, permanent breakpoints are already present in the code. */
3942 #ifdef GET_LONGJMP_TARGET
3945 create_longjmp_breakpoint (func_name
)
3948 struct symtab_and_line sal
;
3949 struct breakpoint
*b
;
3951 INIT_SAL (&sal
); /* initialize to zeroes */
3952 if (func_name
!= NULL
)
3954 struct minimal_symbol
*m
;
3956 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3957 (struct objfile
*) NULL
);
3959 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3963 sal
.section
= find_pc_overlay (sal
.pc
);
3964 b
= set_raw_breakpoint (sal
);
3968 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3969 b
->disposition
= donttouch
;
3970 b
->enable
= disabled
;
3973 b
->addr_string
= strsave (func_name
);
3974 b
->number
= internal_breakpoint_number
--;
3977 #endif /* #ifdef GET_LONGJMP_TARGET */
3979 /* Call this routine when stepping and nexting to enable a breakpoint
3980 if we do a longjmp(). When we hit that breakpoint, call
3981 set_longjmp_resume_breakpoint() to figure out where we are going. */
3984 enable_longjmp_breakpoint ()
3986 register struct breakpoint
*b
;
3989 if (b
->type
== bp_longjmp
)
3991 b
->enable
= enabled
;
3992 check_duplicates (b
->address
, b
->section
);
3997 disable_longjmp_breakpoint ()
3999 register struct breakpoint
*b
;
4002 if (b
->type
== bp_longjmp
4003 || b
->type
== bp_longjmp_resume
)
4005 b
->enable
= disabled
;
4006 check_duplicates (b
->address
, b
->section
);
4011 create_thread_event_breakpoint (address
)
4014 struct breakpoint
*b
;
4015 struct symtab_and_line sal
;
4016 char addr_string
[80]; /* Surely an addr can't be longer than that. */
4018 INIT_SAL (&sal
); /* initialize to zeroes */
4020 sal
.section
= find_pc_overlay (sal
.pc
);
4021 if ((b
= set_raw_breakpoint (sal
)) == NULL
)
4024 b
->number
= internal_breakpoint_number
--;
4025 b
->disposition
= donttouch
;
4026 b
->type
= bp_thread_event
; /* XXX: do we need a new type?
4028 b
->enable
= enabled
;
4029 /* addr_string has to be used or breakpoint_re_set will delete me. */
4030 sprintf (addr_string
, "*0x%s", paddr (b
->address
));
4031 b
->addr_string
= strsave (addr_string
);
4037 remove_thread_event_breakpoints (void)
4039 struct breakpoint
*b
, *temp
;
4041 ALL_BREAKPOINTS_SAFE (b
, temp
)
4042 if (b
->type
== bp_thread_event
)
4043 delete_breakpoint (b
);
4048 remove_solib_event_breakpoints ()
4050 register struct breakpoint
*b
, *temp
;
4052 ALL_BREAKPOINTS_SAFE (b
, temp
)
4053 if (b
->type
== bp_shlib_event
)
4054 delete_breakpoint (b
);
4058 create_solib_event_breakpoint (address
)
4061 struct breakpoint
*b
;
4062 struct symtab_and_line sal
;
4064 INIT_SAL (&sal
); /* initialize to zeroes */
4066 sal
.section
= find_pc_overlay (sal
.pc
);
4067 b
= set_raw_breakpoint (sal
);
4068 b
->number
= internal_breakpoint_number
--;
4069 b
->disposition
= donttouch
;
4070 b
->type
= bp_shlib_event
;
4075 /* Disable any breakpoints that are on code in shared libraries. Only
4076 apply to enabled breakpoints, disabled ones can just stay disabled. */
4079 disable_breakpoints_in_shlibs (silent
)
4082 struct breakpoint
*b
;
4083 int disabled_shlib_breaks
= 0;
4085 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
4088 #if defined (PC_SOLIB)
4089 if (((b
->type
== bp_breakpoint
) ||
4090 (b
->type
== bp_hardware_breakpoint
)) &&
4091 b
->enable
== enabled
&&
4093 PC_SOLIB (b
->address
))
4095 b
->enable
= shlib_disabled
;
4098 if (!disabled_shlib_breaks
)
4100 target_terminal_ours_for_output ();
4101 warning ("Temporarily disabling shared library breakpoints:");
4103 disabled_shlib_breaks
= 1;
4104 warning ("breakpoint #%d ", b
->number
);
4111 /* Try to reenable any breakpoints in shared libraries. */
4113 re_enable_breakpoints_in_shlibs ()
4115 struct breakpoint
*b
;
4118 if (b
->enable
== shlib_disabled
)
4122 /* Do not reenable the breakpoint if the shared library
4123 is still not mapped in. */
4124 if (target_read_memory (b
->address
, buf
, 1) == 0)
4125 b
->enable
= enabled
;
4132 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
4137 enum bptype bp_kind
;
4139 struct breakpoint
*b
;
4140 struct symtabs_and_lines sals
;
4141 struct cleanup
*old_chain
;
4142 struct cleanup
*canonical_strings_chain
= NULL
;
4143 char *addr_start
= hookname
;
4144 char *addr_end
= NULL
;
4145 char **canonical
= (char **) NULL
;
4146 int thread
= -1; /* All threads. */
4148 /* Set a breakpoint on the specified hook. */
4149 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
4150 addr_end
= hookname
;
4152 if (sals
.nelts
== 0)
4154 warning ("Unable to set a breakpoint on dynamic linker callback.");
4155 warning ("Suggest linking with /opt/langtools/lib/end.o.");
4156 warning ("GDB will be unable to track shl_load/shl_unload calls");
4159 if (sals
.nelts
!= 1)
4161 warning ("Unable to set unique breakpoint on dynamic linker callback.");
4162 warning ("GDB will be unable to track shl_load/shl_unload calls");
4166 /* Make sure that all storage allocated in decode_line_1 gets freed
4167 in case the following errors out. */
4168 old_chain
= make_cleanup (free
, sals
.sals
);
4169 if (canonical
!= (char **) NULL
)
4171 make_cleanup (free
, canonical
);
4172 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
4173 if (canonical
[0] != NULL
)
4174 make_cleanup (free
, canonical
[0]);
4177 resolve_sal_pc (&sals
.sals
[0]);
4179 /* Remove the canonical strings from the cleanup, they are needed below. */
4180 if (canonical
!= (char **) NULL
)
4181 discard_cleanups (canonical_strings_chain
);
4183 b
= set_raw_breakpoint (sals
.sals
[0]);
4184 set_breakpoint_count (breakpoint_count
+ 1);
4185 b
->number
= breakpoint_count
;
4187 b
->cond_string
= (cond_string
== NULL
) ?
4188 NULL
: savestring (cond_string
, strlen (cond_string
));
4191 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
4192 b
->addr_string
= canonical
[0];
4193 else if (addr_start
)
4194 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
4196 b
->enable
= enabled
;
4197 b
->disposition
= tempflag
? del
: donttouch
;
4199 if (dll_pathname
== NULL
)
4200 b
->dll_pathname
= NULL
;
4203 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
4204 strcpy (b
->dll_pathname
, dll_pathname
);
4209 do_cleanups (old_chain
);
4213 create_solib_load_event_breakpoint (hookname
, tempflag
,
4214 dll_pathname
, cond_string
)
4220 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
4221 cond_string
, bp_catch_load
);
4225 create_solib_unload_event_breakpoint (hookname
, tempflag
,
4226 dll_pathname
, cond_string
)
4232 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
4233 cond_string
, bp_catch_unload
);
4237 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
4240 enum bptype bp_kind
;
4242 struct symtab_and_line sal
;
4243 struct breakpoint
*b
;
4244 int thread
= -1; /* All threads. */
4251 b
= set_raw_breakpoint (sal
);
4252 set_breakpoint_count (breakpoint_count
+ 1);
4253 b
->number
= breakpoint_count
;
4255 b
->cond_string
= (cond_string
== NULL
) ?
4256 NULL
: savestring (cond_string
, strlen (cond_string
));
4258 b
->addr_string
= NULL
;
4259 b
->enable
= enabled
;
4260 b
->disposition
= tempflag
? del
: donttouch
;
4261 b
->forked_inferior_pid
= 0;
4269 create_fork_event_catchpoint (tempflag
, cond_string
)
4273 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
4277 create_vfork_event_catchpoint (tempflag
, cond_string
)
4281 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
4285 create_exec_event_catchpoint (tempflag
, cond_string
)
4289 struct symtab_and_line sal
;
4290 struct breakpoint
*b
;
4291 int thread
= -1; /* All threads. */
4298 b
= set_raw_breakpoint (sal
);
4299 set_breakpoint_count (breakpoint_count
+ 1);
4300 b
->number
= breakpoint_count
;
4302 b
->cond_string
= (cond_string
== NULL
) ?
4303 NULL
: savestring (cond_string
, strlen (cond_string
));
4305 b
->addr_string
= NULL
;
4306 b
->enable
= enabled
;
4307 b
->disposition
= tempflag
? del
: donttouch
;
4309 b
->type
= bp_catch_exec
;
4315 hw_breakpoint_used_count ()
4317 register struct breakpoint
*b
;
4322 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
4330 hw_watchpoint_used_count (type
, other_type_used
)
4332 int *other_type_used
;
4334 register struct breakpoint
*b
;
4337 *other_type_used
= 0;
4340 if (b
->enable
== enabled
)
4342 if (b
->type
== type
)
4344 else if ((b
->type
== bp_hardware_watchpoint
||
4345 b
->type
== bp_read_watchpoint
||
4346 b
->type
== bp_access_watchpoint
)
4347 && b
->enable
== enabled
)
4348 *other_type_used
= 1;
4354 /* Call this after hitting the longjmp() breakpoint. Use this to set
4355 a new breakpoint at the target of the jmp_buf.
4357 FIXME - This ought to be done by setting a temporary breakpoint
4358 that gets deleted automatically... */
4361 set_longjmp_resume_breakpoint (pc
, frame
)
4363 struct frame_info
*frame
;
4365 register struct breakpoint
*b
;
4368 if (b
->type
== bp_longjmp_resume
)
4371 b
->enable
= enabled
;
4373 b
->frame
= frame
->frame
;
4376 check_duplicates (b
->address
, b
->section
);
4382 disable_watchpoints_before_interactive_call_start ()
4384 struct breakpoint
*b
;
4388 if (((b
->type
== bp_watchpoint
)
4389 || (b
->type
== bp_hardware_watchpoint
)
4390 || (b
->type
== bp_read_watchpoint
)
4391 || (b
->type
== bp_access_watchpoint
)
4392 || ep_is_exception_catchpoint (b
))
4393 && (b
->enable
== enabled
))
4395 b
->enable
= call_disabled
;
4396 check_duplicates (b
->address
, b
->section
);
4402 enable_watchpoints_after_interactive_call_stop ()
4404 struct breakpoint
*b
;
4408 if (((b
->type
== bp_watchpoint
)
4409 || (b
->type
== bp_hardware_watchpoint
)
4410 || (b
->type
== bp_read_watchpoint
)
4411 || (b
->type
== bp_access_watchpoint
)
4412 || ep_is_exception_catchpoint (b
))
4413 && (b
->enable
== call_disabled
))
4415 b
->enable
= enabled
;
4416 check_duplicates (b
->address
, b
->section
);
4422 /* Set a breakpoint that will evaporate an end of command
4423 at address specified by SAL.
4424 Restrict it to frame FRAME if FRAME is nonzero. */
4427 set_momentary_breakpoint (sal
, frame
, type
)
4428 struct symtab_and_line sal
;
4429 struct frame_info
*frame
;
4432 register struct breakpoint
*b
;
4433 b
= set_raw_breakpoint (sal
);
4435 b
->enable
= enabled
;
4436 b
->disposition
= donttouch
;
4437 b
->frame
= (frame
? frame
->frame
: 0);
4439 /* If we're debugging a multi-threaded program, then we
4440 want momentary breakpoints to be active in only a
4441 single thread of control. */
4442 if (in_thread_list (inferior_pid
))
4443 b
->thread
= pid_to_thread_id (inferior_pid
);
4449 /* Tell the user we have just set a breakpoint B. */
4453 struct breakpoint
*b
;
4457 struct cleanup
*old_chain
;
4458 struct ui_stream
*stb
;
4460 stb
= ui_out_stream_new (uiout
);
4461 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
4464 /* FIXME: This is misplaced; mention() is called by things (like hitting a
4465 watchpoint) other than breakpoint creation. It should be possible to
4466 clean this up and at the same time replace the random calls to
4467 breakpoint_changed with this hook, as has already been done for
4468 delete_breakpoint_hook and so on. */
4469 if (create_breakpoint_hook
)
4470 create_breakpoint_hook (b
);
4471 breakpoint_create_event (b
->number
);
4476 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
4480 ui_out_text (uiout
, "Watchpoint ");
4481 ui_out_list_begin (uiout
, "wpt");
4482 ui_out_field_int (uiout
, "number", b
->number
);
4483 ui_out_text (uiout
, ": ");
4484 print_expression (b
->exp
, stb
->stream
);
4485 ui_out_field_stream (uiout
, "exp", stb
);
4486 ui_out_list_end (uiout
);
4488 case bp_hardware_watchpoint
:
4489 ui_out_text (uiout
, "Hardware watchpoint ");
4490 ui_out_list_begin (uiout
, "wpt");
4491 ui_out_field_int (uiout
, "number", b
->number
);
4492 ui_out_text (uiout
, ": ");
4493 print_expression (b
->exp
, stb
->stream
);
4494 ui_out_field_stream (uiout
, "exp", stb
);
4495 ui_out_list_end (uiout
);
4499 printf_filtered ("Watchpoint %d: ", b
->number
);
4500 print_expression (b
->exp
, gdb_stdout
);
4502 case bp_hardware_watchpoint
:
4503 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
4504 print_expression (b
->exp
, gdb_stdout
);
4508 case bp_read_watchpoint
:
4509 ui_out_text (uiout
, "Hardware read watchpoint ");
4510 ui_out_list_begin (uiout
, "hw-rwpt");
4511 ui_out_field_int (uiout
, "number", b
->number
);
4512 ui_out_text (uiout
, ": ");
4513 print_expression (b
->exp
, stb
->stream
);
4514 ui_out_field_stream (uiout
, "exp", stb
);
4515 ui_out_list_end (uiout
);
4517 case bp_access_watchpoint
:
4518 ui_out_text (uiout
, "Hardware access (read/write) watchpoint ");
4519 ui_out_list_begin (uiout
, "hw-awpt");
4520 ui_out_field_int (uiout
, "number", b
->number
);
4521 ui_out_text (uiout
, ": ");
4522 print_expression (b
->exp
, stb
->stream
);
4523 ui_out_field_stream (uiout
, "exp", stb
);
4524 ui_out_list_end (uiout
);
4527 case bp_read_watchpoint
:
4528 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
4529 print_expression (b
->exp
, gdb_stdout
);
4531 case bp_access_watchpoint
:
4532 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
4534 print_expression (b
->exp
, gdb_stdout
);
4539 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
4545 printf_filtered ("Breakpoint %d", b
->number
);
4548 case bp_hardware_breakpoint
:
4550 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
4556 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
4560 case bp_catch_unload
:
4561 printf_filtered ("Catchpoint %d (%s %s)",
4563 (b
->type
== bp_catch_load
) ? "load" : "unload",
4564 (b
->dll_pathname
!= NULL
) ?
4565 b
->dll_pathname
: "<any library>");
4568 case bp_catch_vfork
:
4569 printf_filtered ("Catchpoint %d (%s)",
4571 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
4574 printf_filtered ("Catchpoint %d (exec)",
4577 case bp_catch_catch
:
4578 case bp_catch_throw
:
4579 printf_filtered ("Catchpoint %d (%s)",
4581 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
4587 case bp_longjmp_resume
:
4588 case bp_step_resume
:
4589 case bp_through_sigtramp
:
4591 case bp_watchpoint_scope
:
4592 case bp_shlib_event
:
4593 case bp_thread_event
:
4598 if (addressprint
|| b
->source_file
== NULL
)
4600 printf_filtered (" at ");
4601 print_address_numeric (b
->address
, 1, gdb_stdout
);
4604 printf_filtered (": file %s, line %d.",
4605 b
->source_file
, b
->line_number
);
4606 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
4607 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
4610 do_cleanups (old_chain
);
4613 if (interpreter_p
&& strcmp (interpreter_p
, "mi") == 0)
4616 printf_filtered ("\n");
4620 /* Add SALS.nelts breakpoints to the breakpoint table. For each
4621 SALS.sal[i] breakpoint, include the corresponding ADDR_STRING[i],
4622 COND[i] and COND_STRING[i] values.
4624 NOTE: If the function succeeds, the caller is expected to cleanup
4625 the arrays ADDR_STRING, COND_STRING, COND and SALS (but not the
4626 array contents). If the function fails (error() is called), the
4627 caller is expected to cleanups both the ADDR_STRING, COND_STRING,
4628 COND and SALS arrays and each of those arrays contents. */
4631 create_breakpoints (struct symtabs_and_lines sals
, char **addr_string
,
4632 struct expression
**cond
, char **cond_string
,
4633 enum bptype type
, enum bpdisp disposition
,
4634 int thread
, int ignore_count
, int from_tty
)
4636 if (type
== bp_hardware_breakpoint
)
4638 int i
= hw_breakpoint_used_count ();
4639 int target_resources_ok
=
4640 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4642 if (target_resources_ok
== 0)
4643 error ("No hardware breakpoint support in the target.");
4644 else if (target_resources_ok
< 0)
4645 error ("Hardware breakpoints used exceeds limit.");
4648 /* Now set all the breakpoints. */
4651 for (i
= 0; i
< sals
.nelts
; i
++)
4653 struct breakpoint
*b
;
4654 struct symtab_and_line sal
= sals
.sals
[i
];
4657 describe_other_breakpoints (sal
.pc
, sal
.section
);
4659 b
= set_raw_breakpoint (sal
);
4660 set_breakpoint_count (breakpoint_count
+ 1);
4661 b
->number
= breakpoint_count
;
4665 b
->addr_string
= addr_string
[i
];
4666 b
->cond_string
= cond_string
[i
];
4667 b
->ignore_count
= ignore_count
;
4668 b
->enable
= enabled
;
4669 b
->disposition
= disposition
;
4675 /* Parse ARG which is assumed to be a SAL specification possibly
4676 followed by conditionals. On return, SALS contains an array of SAL
4677 addresses found. ADDR_STRING contains a vector of (canonical)
4678 address strings. ARG points to the end of the SAL. */
4681 parse_breakpoint_sals (char **address
,
4682 struct symtabs_and_lines
*sals
,
4683 char ***addr_string
)
4685 char *addr_start
= *address
;
4686 *addr_string
= NULL
;
4687 /* If no arg given, or if first arg is 'if ', use the default
4689 if ((*address
) == NULL
4690 || (strncmp ((*address
), "if", 2) == 0 && isspace ((*address
)[2])))
4692 if (default_breakpoint_valid
)
4694 struct symtab_and_line sal
;
4695 INIT_SAL (&sal
); /* initialize to zeroes */
4696 sals
->sals
= (struct symtab_and_line
*)
4697 xmalloc (sizeof (struct symtab_and_line
));
4698 sal
.pc
= default_breakpoint_address
;
4699 sal
.line
= default_breakpoint_line
;
4700 sal
.symtab
= default_breakpoint_symtab
;
4701 sal
.section
= find_pc_overlay (sal
.pc
);
4702 sals
->sals
[0] = sal
;
4706 error ("No default breakpoint address now.");
4710 /* Force almost all breakpoints to be in terms of the
4711 current_source_symtab (which is decode_line_1's default). This
4712 should produce the results we want almost all of the time while
4713 leaving default_breakpoint_* alone. */
4714 if (default_breakpoint_valid
4715 && (!current_source_symtab
4716 || (strchr ("+-", (*address
)[0]) != NULL
)))
4717 *sals
= decode_line_1 (address
, 1, default_breakpoint_symtab
,
4718 default_breakpoint_line
, addr_string
);
4720 *sals
= decode_line_1 (address
, 1, (struct symtab
*) NULL
, 0, addr_string
);
4722 /* For any SAL that didn't have a canonical string, fill one in. */
4723 if (sals
->nelts
> 0 && *addr_string
== NULL
)
4724 *addr_string
= xcalloc (sals
->nelts
, sizeof (char **));
4725 if (addr_start
!= (*address
))
4728 for (i
= 0; i
< sals
->nelts
; i
++)
4730 /* Add the string if not present. */
4731 if ((*addr_string
)[i
] == NULL
)
4732 (*addr_string
)[i
] = savestring (addr_start
, (*address
) - addr_start
);
4738 /* Convert each SAL into a real PC. Verify that the PC can be
4739 inserted as a breakpoint. If it can't throw an error. */
4742 breakpoint_sals_to_pc (struct symtabs_and_lines
*sals
,
4746 for (i
= 0; i
< sals
->nelts
; i
++)
4748 resolve_sal_pc (&sals
->sals
[i
]);
4750 /* It's possible for the PC to be nonzero, but still an illegal
4751 value on some targets.
4753 For example, on HP-UX if you start gdb, and before running the
4754 inferior you try to set a breakpoint on a shared library function
4755 "foo" where the inferior doesn't call "foo" directly but does
4756 pass its address to another function call, then we do find a
4757 minimal symbol for the "foo", but it's address is invalid.
4758 (Appears to be an index into a table that the loader sets up
4759 when the inferior is run.)
4761 Give the target a chance to bless sals.sals[i].pc before we
4762 try to make a breakpoint for it. */
4763 if (PC_REQUIRES_RUN_BEFORE_USE (sals
->sals
[i
].pc
))
4765 if (address
== NULL
)
4766 error ("Cannot break without a running program.");
4768 error ("Cannot break on %s without a running program.",
4774 /* Set a breakpoint according to ARG (function, linenum or *address)
4775 flag: first bit : 0 non-temporary, 1 temporary.
4776 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
4779 break_command_1 (arg
, flag
, from_tty
)
4783 int tempflag
, hardwareflag
;
4784 struct symtabs_and_lines sals
;
4785 register struct expression
**cond
= 0;
4786 /* Pointers in arg to the start, and one past the end, of the
4788 char **cond_string
= (char **) NULL
;
4789 char *addr_start
= arg
;
4791 struct cleanup
*old_chain
;
4792 struct cleanup
*breakpoint_chain
= NULL
;
4795 int ignore_count
= 0;
4797 hardwareflag
= flag
& BP_HARDWAREFLAG
;
4798 tempflag
= flag
& BP_TEMPFLAG
;
4803 parse_breakpoint_sals (&arg
, &sals
, &addr_string
);
4808 /* Create a chain of things that always need to be cleaned up. */
4809 old_chain
= make_cleanup (null_cleanup
, 0);
4811 /* Make sure that all storage allocated to SALS gets freed. */
4812 make_cleanup (free
, sals
.sals
);
4814 /* Cleanup the addr_string array but not its contents. */
4815 make_cleanup (free
, addr_string
);
4817 /* Allocate space for all the cond expressions. */
4818 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4819 make_cleanup (free
, cond
);
4821 /* Allocate space for all the cond strings. */
4822 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4823 make_cleanup (free
, cond_string
);
4825 /* ----------------------------- SNIP -----------------------------
4826 Anything added to the cleanup chain beyond this point is assumed
4827 to be part of a breakpoint. If the breakpoint create succeeds
4828 then the memory is not reclaimed. */
4829 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4831 /* Mark the contents of the addr_string for cleanup. These go on
4832 the breakpoint_chain and only occure if the breakpoint create
4834 for (i
= 0; i
< sals
.nelts
; i
++)
4836 if (addr_string
[i
] != NULL
)
4837 make_cleanup (free
, addr_string
[i
]);
4840 /* Resolve all line numbers to PC's and verify that the addresses
4841 are ok for the target. */
4842 breakpoint_sals_to_pc (&sals
, addr_start
);
4844 /* Verify that condition can be parsed, before setting any
4845 breakpoints. Allocate a separate condition expression for each
4847 thread
= -1; /* No specific thread yet */
4848 for (i
= 0; i
< sals
.nelts
; i
++)
4855 char *cond_start
= NULL
;
4856 char *cond_end
= NULL
;
4857 while (*tok
== ' ' || *tok
== '\t')
4862 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4865 toklen
= end_tok
- tok
;
4867 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4869 tok
= cond_start
= end_tok
+ 1;
4870 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4871 make_cleanup (free
, cond
[i
]);
4873 cond_string
[i
] = savestring (cond_start
, cond_end
- cond_start
);
4874 make_cleanup (free
, cond_string
[i
]);
4876 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4882 thread
= strtol (tok
, &tok
, 0);
4884 error ("Junk after thread keyword.");
4885 if (!valid_thread_id (thread
))
4886 error ("Unknown thread %d\n", thread
);
4889 error ("Junk at end of arguments.");
4893 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
4894 hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
4895 tempflag
? del
: donttouch
,
4896 thread
, ignore_count
, from_tty
);
4900 warning ("Multiple breakpoints were set.");
4901 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
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
);
4910 /* Set a breakpoint of TYPE/DISPOSITION according to ARG (function,
4911 linenum or *address) with COND and IGNORE_COUNT. */
4913 struct captured_breakpoint_args
4924 do_captured_breakpoint (void *data
)
4926 struct captured_breakpoint_args
*args
= data
;
4927 struct symtabs_and_lines sals
;
4928 register struct expression
**cond
;
4929 struct cleanup
*old_chain
;
4930 struct cleanup
*breakpoint_chain
= NULL
;
4937 /* Parse the source and lines spec. Delay check that the expression
4938 didn't contain trailing garbage until after cleanups are in
4942 address_end
= args
->address
;
4944 parse_breakpoint_sals (&address_end
, &sals
, &addr_string
);
4949 /* Create a chain of things at always need to be cleaned up. */
4950 old_chain
= make_cleanup (null_cleanup
, 0);
4952 /* Always have a addr_string array, even if it is empty. */
4953 make_cleanup (free
, addr_string
);
4955 /* Make sure that all storage allocated to SALS gets freed. */
4956 make_cleanup (free
, sals
.sals
);
4958 /* Allocate space for all the cond expressions. */
4959 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4960 make_cleanup (free
, cond
);
4962 /* Allocate space for all the cond strings. */
4963 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4964 make_cleanup (free
, cond_string
);
4966 /* ----------------------------- SNIP -----------------------------
4967 Anything added to the cleanup chain beyond this point is assumed
4968 to be part of a breakpoint. If the breakpoint create goes
4969 through then that memory is not cleaned up. */
4970 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4972 /* Mark the contents of the addr_string for cleanup. These go on
4973 the breakpoint_chain and only occure if the breakpoint create
4975 for (i
= 0; i
< sals
.nelts
; i
++)
4977 if (addr_string
[i
] != NULL
)
4978 make_cleanup (free
, addr_string
[i
]);
4981 /* Wait until now before checking for garbage at the end of the
4982 address. That way cleanups can take care of freeing any
4984 if (*address_end
!= '\0')
4985 error ("Garbage %s following breakpoint address", address_end
);
4987 /* Resolve all line numbers to PC's. */
4988 breakpoint_sals_to_pc (&sals
, args
->address
);
4990 /* Verify that conditions can be parsed, before setting any
4992 for (i
= 0; i
< sals
.nelts
; i
++)
4994 if (args
->condition
!= NULL
)
4996 char *tok
= args
->condition
;
4997 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4999 error ("Garbage %s follows condition", tok
);
5000 make_cleanup (free
, cond
[i
]);
5001 cond_string
[i
] = xstrdup (args
->condition
);
5005 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
5006 args
->hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
5007 args
->tempflag
? del
: donttouch
,
5008 args
->thread
, args
->ignore_count
, 0/*from-tty*/);
5010 /* That's it. Discard the cleanups for data inserted into the
5012 discard_cleanups (breakpoint_chain
);
5013 /* But cleanup everything else. */
5014 do_cleanups (old_chain
);
5019 gdb_breakpoint (char *address
, char *condition
,
5020 int hardwareflag
, int tempflag
,
5021 int thread
, int ignore_count
)
5023 struct captured_breakpoint_args args
;
5024 args
.address
= address
;
5025 args
.condition
= condition
;
5026 args
.hardwareflag
= hardwareflag
;
5027 args
.tempflag
= tempflag
;
5028 args
.thread
= thread
;
5029 args
.ignore_count
= ignore_count
;
5030 return catch_errors (do_captured_breakpoint
, &args
,
5031 NULL
, RETURN_MASK_ALL
);
5036 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
5041 struct frame_info
*frame
;
5042 CORE_ADDR low
, high
, selected_pc
= 0;
5043 char *extra_args
, *level_arg
, *addr_string
;
5044 int extra_args_len
= 0, if_arg
= 0;
5047 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
5050 if (default_breakpoint_valid
)
5054 selected_pc
= selected_frame
->pc
;
5059 error ("No selected frame.");
5062 error ("No default breakpoint address now.");
5066 extra_args
= strchr (arg
, ' ');
5070 extra_args_len
= strlen (extra_args
);
5071 level_arg
= (char *) xmalloc (extra_args
- arg
);
5072 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
5073 level_arg
[extra_args
- arg
- 1] = '\0';
5077 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
5078 strcpy (level_arg
, arg
);
5081 frame
= parse_frame_specification (level_arg
);
5083 selected_pc
= frame
->pc
;
5090 extra_args_len
= strlen (arg
);
5095 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
5097 addr_string
= (char *) xmalloc (26 + extra_args_len
);
5099 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
5101 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
5102 break_command_1 (addr_string
, flag
, from_tty
);
5106 error ("No function contains the specified address");
5109 error ("Unable to set breakpoint at procedure exit");
5114 break_at_finish_command_1 (arg
, flag
, from_tty
)
5119 char *addr_string
, *break_string
, *beg_addr_string
;
5120 CORE_ADDR low
, high
;
5121 struct symtabs_and_lines sals
;
5122 struct symtab_and_line sal
;
5123 struct cleanup
*old_chain
;
5125 int extra_args_len
= 0;
5129 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
5131 if (default_breakpoint_valid
)
5135 addr_string
= (char *) xmalloc (15);
5136 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
5141 error ("No selected frame.");
5144 error ("No default breakpoint address now.");
5148 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
5149 strcpy (addr_string
, arg
);
5155 extra_args_len
= strlen (arg
);
5159 /* get the stuff after the function name or address */
5160 extra_args
= strchr (arg
, ' ');
5164 extra_args_len
= strlen (extra_args
);
5171 beg_addr_string
= addr_string
;
5172 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
5175 free (beg_addr_string
);
5176 old_chain
= make_cleanup (free
, sals
.sals
);
5177 for (i
= 0; (i
< sals
.nelts
); i
++)
5180 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
5182 break_string
= (char *) xmalloc (extra_args_len
+ 26);
5184 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
5186 sprintf (break_string
, "*0x%s", paddr_nz (high
));
5187 break_command_1 (break_string
, flag
, from_tty
);
5188 free (break_string
);
5191 error ("No function contains the specified address");
5195 warning ("Multiple breakpoints were set.\n");
5196 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
5198 do_cleanups (old_chain
);
5202 /* Helper function for break_command_1 and disassemble_command. */
5205 resolve_sal_pc (sal
)
5206 struct symtab_and_line
*sal
;
5210 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
5212 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
5213 error ("No line %d in file \"%s\".",
5214 sal
->line
, sal
->symtab
->filename
);
5218 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
5220 struct blockvector
*bv
;
5225 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
5228 b
= BLOCKVECTOR_BLOCK (bv
, index
);
5229 sym
= block_function (b
);
5232 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
5233 sal
->section
= SYMBOL_BFD_SECTION (sym
);
5237 /* It really is worthwhile to have the section, so we'll just
5238 have to look harder. This case can be executed if we have
5239 line numbers but no functions (as can happen in assembly
5242 struct minimal_symbol
*msym
;
5244 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
5246 sal
->section
= SYMBOL_BFD_SECTION (msym
);
5253 break_command (arg
, from_tty
)
5257 break_command_1 (arg
, 0, from_tty
);
5261 break_at_finish_command (arg
, from_tty
)
5265 break_at_finish_command_1 (arg
, 0, from_tty
);
5269 break_at_finish_at_depth_command (arg
, from_tty
)
5273 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
5277 tbreak_command (arg
, from_tty
)
5281 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
5285 tbreak_at_finish_command (arg
, from_tty
)
5289 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
5293 hbreak_command (arg
, from_tty
)
5297 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
5301 thbreak_command (arg
, from_tty
)
5305 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
5309 stop_command (arg
, from_tty
)
5313 printf_filtered ("Specify the type of breakpoint to set.\n\
5314 Usage: stop in <function | address>\n\
5319 stopin_command (arg
, from_tty
)
5325 if (arg
== (char *) NULL
)
5327 else if (*arg
!= '*')
5332 /* look for a ':'. If this is a line number specification, then
5333 say it is bad, otherwise, it should be an address or
5334 function/method name */
5335 while (*argptr
&& !hasColon
)
5337 hasColon
= (*argptr
== ':');
5342 badInput
= (*argptr
!= ':'); /* Not a class::method */
5344 badInput
= isdigit (*arg
); /* a simple line number */
5348 printf_filtered ("Usage: stop in <function | address>\n");
5350 break_command_1 (arg
, 0, from_tty
);
5354 stopat_command (arg
, from_tty
)
5360 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
5367 /* look for a ':'. If there is a '::' then get out, otherwise
5368 it is probably a line number. */
5369 while (*argptr
&& !hasColon
)
5371 hasColon
= (*argptr
== ':');
5376 badInput
= (*argptr
== ':'); /* we have class::method */
5378 badInput
= !isdigit (*arg
); /* not a line number */
5382 printf_filtered ("Usage: stop at <line>\n");
5384 break_command_1 (arg
, 0, from_tty
);
5388 /* accessflag: hw_write: watch write,
5389 hw_read: watch read,
5390 hw_access: watch access (read or write) */
5392 watch_command_1 (arg
, accessflag
, from_tty
)
5397 struct breakpoint
*b
;
5398 struct symtab_and_line sal
;
5399 struct expression
*exp
;
5400 struct block
*exp_valid_block
;
5401 struct value
*val
, *mark
;
5402 struct frame_info
*frame
;
5403 struct frame_info
*prev_frame
= NULL
;
5404 char *exp_start
= NULL
;
5405 char *exp_end
= NULL
;
5406 char *tok
, *end_tok
;
5408 char *cond_start
= NULL
;
5409 char *cond_end
= NULL
;
5410 struct expression
*cond
= NULL
;
5411 int i
, other_type_used
, target_resources_ok
= 0;
5412 enum bptype bp_type
;
5415 INIT_SAL (&sal
); /* initialize to zeroes */
5417 /* Parse arguments. */
5418 innermost_block
= NULL
;
5420 exp
= parse_exp_1 (&arg
, 0, 0);
5422 exp_valid_block
= innermost_block
;
5423 mark
= value_mark ();
5424 val
= evaluate_expression (exp
);
5425 release_value (val
);
5426 if (VALUE_LAZY (val
))
5427 value_fetch_lazy (val
);
5430 while (*tok
== ' ' || *tok
== '\t')
5434 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
5437 toklen
= end_tok
- tok
;
5438 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
5440 tok
= cond_start
= end_tok
+ 1;
5441 cond
= parse_exp_1 (&tok
, 0, 0);
5445 error ("Junk at end of command.");
5447 if (accessflag
== hw_read
)
5448 bp_type
= bp_read_watchpoint
;
5449 else if (accessflag
== hw_access
)
5450 bp_type
= bp_access_watchpoint
;
5452 bp_type
= bp_hardware_watchpoint
;
5454 mem_cnt
= can_use_hardware_watchpoint (val
);
5455 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
5456 error ("Expression cannot be implemented with read/access watchpoint.");
5459 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
5460 target_resources_ok
=
5461 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
5463 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
5464 error ("Target does not support this type of hardware watchpoint.");
5466 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
5467 error ("Target can only support one kind of HW watchpoint at a time.");
5470 #if defined(HPUXHPPA)
5471 /* On HP-UX if you set a h/w
5472 watchpoint before the "run" command, the inferior dies with a e.g.,
5473 SIGILL once you start it. I initially believed this was due to a
5474 bad interaction between page protection traps and the initial
5475 startup sequence by the dynamic linker.
5477 However, I tried avoiding that by having HP-UX's implementation of
5478 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
5479 yet, which forced slow watches before a "run" or "attach", and it
5480 still fails somewhere in the startup code.
5482 Until I figure out what's happening, I'm disallowing watches altogether
5483 before the "run" or "attach" command. We'll tell the user they must
5484 set watches after getting the program started. */
5485 if (!target_has_execution
)
5487 warning ("can't do that without a running program; try \"break main\", \"run\" first");
5490 #endif /* HPUXHPPA */
5492 /* Now set up the breakpoint. */
5493 b
= set_raw_breakpoint (sal
);
5494 set_breakpoint_count (breakpoint_count
+ 1);
5495 b
->number
= breakpoint_count
;
5496 b
->disposition
= donttouch
;
5498 b
->exp_valid_block
= exp_valid_block
;
5499 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
5503 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
5507 frame
= block_innermost_frame (exp_valid_block
);
5510 prev_frame
= get_prev_frame (frame
);
5511 b
->watchpoint_frame
= frame
->frame
;
5514 b
->watchpoint_frame
= (CORE_ADDR
) 0;
5516 if (mem_cnt
&& target_resources_ok
> 0)
5519 b
->type
= bp_watchpoint
;
5521 /* If the expression is "local", then set up a "watchpoint scope"
5522 breakpoint at the point where we've left the scope of the watchpoint
5524 if (innermost_block
)
5528 struct breakpoint
*scope_breakpoint
;
5529 struct symtab_and_line scope_sal
;
5531 INIT_SAL (&scope_sal
); /* initialize to zeroes */
5532 scope_sal
.pc
= get_frame_pc (prev_frame
);
5533 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
5535 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
5536 set_breakpoint_count (breakpoint_count
+ 1);
5537 scope_breakpoint
->number
= breakpoint_count
;
5539 scope_breakpoint
->type
= bp_watchpoint_scope
;
5540 scope_breakpoint
->enable
= enabled
;
5542 /* Automatically delete the breakpoint when it hits. */
5543 scope_breakpoint
->disposition
= del
;
5545 /* Only break in the proper frame (help with recursion). */
5546 scope_breakpoint
->frame
= prev_frame
->frame
;
5548 /* Set the address at which we will stop. */
5549 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
5551 /* The scope breakpoint is related to the watchpoint. We
5552 will need to act on them together. */
5553 b
->related_breakpoint
= scope_breakpoint
;
5556 value_free_to_mark (mark
);
5560 /* Return count of locations need to be watched and can be handled
5561 in hardware. If the watchpoint can not be handled
5562 in hardware return zero. */
5564 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
5565 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
5566 ((BYTE_SIZE) <= (REGISTER_SIZE))
5569 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
5570 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
5571 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
5575 can_use_hardware_watchpoint (v
)
5578 int found_memory_cnt
= 0;
5579 struct value
*head
= v
;
5581 /* Did the user specifically forbid us to use hardware watchpoints? */
5582 if (!can_use_hw_watchpoints
)
5585 /* Make sure that the value of the expression depends only upon
5586 memory contents, and values computed from them within GDB. If we
5587 find any register references or function calls, we can't use a
5588 hardware watchpoint.
5590 The idea here is that evaluating an expression generates a series
5591 of values, one holding the value of every subexpression. (The
5592 expression a*b+c has five subexpressions: a, b, a*b, c, and
5593 a*b+c.) GDB's values hold almost enough information to establish
5594 the criteria given above --- they identify memory lvalues,
5595 register lvalues, computed values, etcetera. So we can evaluate
5596 the expression, and then scan the chain of values that leaves
5597 behind to decide whether we can detect any possible change to the
5598 expression's final value using only hardware watchpoints.
5600 However, I don't think that the values returned by inferior
5601 function calls are special in any way. So this function may not
5602 notice that an expression involving an inferior function call
5603 can't be watched with hardware watchpoints. FIXME. */
5604 for (; v
; v
= v
->next
)
5606 if (VALUE_LVAL (v
) == lval_memory
)
5609 /* A lazy memory lvalue is one that GDB never needed to fetch;
5610 we either just used its address (e.g., `a' in `a.b') or
5611 we never needed it at all (e.g., `a' in `a,b'). */
5615 /* Ahh, memory we actually used! Check if we can cover
5616 it with hardware watchpoints. */
5617 struct type
*vtype
= check_typedef (VALUE_TYPE (v
));
5619 /* We only watch structs and arrays if user asked for it
5620 explicitly, never if they just happen to appear in a
5621 middle of some value chain. */
5623 || (TYPE_CODE (vtype
) != TYPE_CODE_STRUCT
5624 && TYPE_CODE (vtype
) != TYPE_CODE_ARRAY
))
5626 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
5627 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
5629 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
5636 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
5637 return 0; /* ??? What does this represent? */
5638 else if (v
->lval
== lval_register
)
5639 return 0; /* cannot watch a register with a HW watchpoint */
5642 /* The expression itself looks suitable for using a hardware
5643 watchpoint, but give the target machine a chance to reject it. */
5644 return found_memory_cnt
;
5649 watch_command_wrapper (arg
, from_tty
)
5653 watch_command (arg
, from_tty
);
5657 watch_command (arg
, from_tty
)
5661 watch_command_1 (arg
, hw_write
, from_tty
);
5666 rwatch_command_wrapper (arg
, from_tty
)
5670 rwatch_command (arg
, from_tty
);
5674 rwatch_command (arg
, from_tty
)
5678 watch_command_1 (arg
, hw_read
, from_tty
);
5683 awatch_command_wrapper (arg
, from_tty
)
5687 awatch_command (arg
, from_tty
);
5691 awatch_command (arg
, from_tty
)
5695 watch_command_1 (arg
, hw_access
, from_tty
);
5699 /* Helper routines for the until_command routine in infcmd.c. Here
5700 because it uses the mechanisms of breakpoints. */
5702 /* This function is called by fetch_inferior_event via the
5703 cmd_continuation pointer, to complete the until command. It takes
5704 care of cleaning up the temporary breakpoints set up by the until
5707 until_break_command_continuation (struct continuation_arg
*arg
)
5709 struct cleanup
*cleanups
;
5711 cleanups
= (struct cleanup
*) arg
->data
.pointer
;
5712 do_exec_cleanups (cleanups
);
5717 until_break_command (arg
, from_tty
)
5721 struct symtabs_and_lines sals
;
5722 struct symtab_and_line sal
;
5723 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
5724 struct breakpoint
*breakpoint
;
5725 struct cleanup
*old_chain
;
5726 struct continuation_arg
*arg1
;
5729 clear_proceed_status ();
5731 /* Set a breakpoint where the user wants it and at return from
5734 if (default_breakpoint_valid
)
5735 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
5736 default_breakpoint_line
, (char ***) NULL
);
5738 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
5739 0, (char ***) NULL
);
5741 if (sals
.nelts
!= 1)
5742 error ("Couldn't get information on specified line.");
5745 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
5748 error ("Junk at end of arguments.");
5750 resolve_sal_pc (&sal
);
5752 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
5754 if (!event_loop_p
|| !target_can_async_p ())
5755 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
5757 old_chain
= make_exec_cleanup_delete_breakpoint (breakpoint
);
5759 /* If we are running asynchronously, and the target supports async
5760 execution, we are not waiting for the target to stop, in the call
5761 tp proceed, below. This means that we cannot delete the
5762 brekpoints until the target has actually stopped. The only place
5763 where we get a chance to do that is in fetch_inferior_event, so
5764 we must set things up for that. */
5766 if (event_loop_p
&& target_can_async_p ())
5768 /* In this case the arg for the continuation is just the point
5769 in the exec_cleanups chain from where to start doing
5770 cleanups, because all the continuation does is the cleanups in
5771 the exec_cleanup_chain. */
5773 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
5775 arg1
->data
.pointer
= old_chain
;
5777 add_continuation (until_break_command_continuation
, arg1
);
5780 /* Keep within the current frame */
5784 sal
= find_pc_line (prev_frame
->pc
, 0);
5785 sal
.pc
= prev_frame
->pc
;
5786 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
5787 if (!event_loop_p
|| !target_can_async_p ())
5788 make_cleanup_delete_breakpoint (breakpoint
);
5790 make_exec_cleanup_delete_breakpoint (breakpoint
);
5793 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
5794 /* Do the cleanups now, anly if we are not running asynchronously,
5795 of if we are, but the target is still synchronous. */
5796 if (!event_loop_p
|| !target_can_async_p ())
5797 do_cleanups (old_chain
);
5801 /* These aren't used; I don't konw what they were for. */
5802 /* Set a breakpoint at the catch clause for NAME. */
5804 catch_breakpoint (name
)
5810 disable_catch_breakpoint ()
5815 delete_catch_breakpoint ()
5820 enable_catch_breakpoint ()
5827 struct sal_chain
*next
;
5828 struct symtab_and_line sal
;
5832 /* Not really used -- invocation in handle_gnu_4_16_catch_command
5833 had been commented out in the v.4.16 sources, and stays
5834 disabled there now because "catch NAME" syntax isn't allowed.
5836 /* This isn't used; I don't know what it was for. */
5837 /* For each catch clause identified in ARGS, run FUNCTION
5838 with that clause as an argument. */
5839 static struct symtabs_and_lines
5840 map_catch_names (args
, function
)
5844 register char *p
= args
;
5846 struct symtabs_and_lines sals
;
5848 struct sal_chain
*sal_chain
= 0;
5852 error_no_arg ("one or more catch names");
5860 /* Don't swallow conditional part. */
5861 if (p1
[0] == 'i' && p1
[1] == 'f'
5862 && (p1
[2] == ' ' || p1
[2] == '\t'))
5868 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
5872 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
5873 error ("Arguments must be catch names.");
5879 struct sal_chain
*next
= (struct sal_chain
*)
5880 alloca (sizeof (struct sal_chain
));
5881 next
->next
= sal_chain
;
5882 next
->sal
= get_catch_sal (p
);
5887 printf_unfiltered ("No catch clause for exception %s.\n", p
);
5892 while (*p
== ' ' || *p
== '\t')
5898 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
5900 static struct symtabs_and_lines
5901 get_catch_sals (this_level_only
)
5902 int this_level_only
;
5904 register struct blockvector
*bl
;
5905 register struct block
*block
;
5906 int index
, have_default
= 0;
5908 struct symtabs_and_lines sals
;
5909 struct sal_chain
*sal_chain
= 0;
5910 char *blocks_searched
;
5912 /* Not sure whether an error message is always the correct response,
5913 but it's better than a core dump. */
5914 if (selected_frame
== NULL
)
5915 error ("No selected frame.");
5916 block
= get_frame_block (selected_frame
);
5917 pc
= selected_frame
->pc
;
5923 error ("No symbol table info available.\n");
5925 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
5926 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5927 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5931 CORE_ADDR end
= BLOCK_END (block
) - 4;
5934 if (bl
!= blockvector_for_pc (end
, &index
))
5935 error ("blockvector blotch");
5936 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
5937 error ("blockvector botch");
5938 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
5941 /* Don't print out blocks that have gone by. */
5942 while (index
< last_index
5943 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
5946 while (index
< last_index
5947 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
5949 if (blocks_searched
[index
] == 0)
5951 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
5954 register struct symbol
*sym
;
5956 nsyms
= BLOCK_NSYMS (b
);
5958 for (i
= 0; i
< nsyms
; i
++)
5960 sym
= BLOCK_SYM (b
, i
);
5961 if (STREQ (SYMBOL_NAME (sym
), "default"))
5967 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
5969 struct sal_chain
*next
= (struct sal_chain
*)
5970 alloca (sizeof (struct sal_chain
));
5971 next
->next
= sal_chain
;
5972 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
5977 blocks_searched
[index
] = 1;
5983 if (sal_chain
&& this_level_only
)
5986 /* After handling the function's top-level block, stop.
5987 Don't continue to its superblock, the block of
5988 per-file symbols. */
5989 if (BLOCK_FUNCTION (block
))
5991 block
= BLOCK_SUPERBLOCK (block
);
5996 struct sal_chain
*tmp_chain
;
5998 /* Count the number of entries. */
5999 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
6000 tmp_chain
= tmp_chain
->next
)
6004 sals
.sals
= (struct symtab_and_line
*)
6005 xmalloc (index
* sizeof (struct symtab_and_line
));
6006 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
6007 sals
.sals
[index
] = sal_chain
->sal
;
6014 ep_skip_leading_whitespace (s
)
6017 if ((s
== NULL
) || (*s
== NULL
))
6019 while (isspace (**s
))
6023 /* This function examines a string, and attempts to find a token
6024 that might be an event name in the leading characters. If a
6025 possible match is found, a pointer to the last character of
6026 the token is returned. Else, NULL is returned. */
6029 ep_find_event_name_end (arg
)
6033 char *event_name_end
= NULL
;
6035 /* If we could depend upon the presense of strrpbrk, we'd use that... */
6039 /* We break out of the loop when we find a token delimiter.
6040 Basically, we're looking for alphanumerics and underscores;
6041 anything else delimites the token. */
6044 if (!isalnum (*s
) && (*s
!= '_'))
6050 return event_name_end
;
6054 /* This function attempts to parse an optional "if <cond>" clause
6055 from the arg string. If one is not found, it returns NULL.
6057 Else, it returns a pointer to the condition string. (It does not
6058 attempt to evaluate the string against a particular block.) And,
6059 it updates arg to point to the first character following the parsed
6060 if clause in the arg string. */
6063 ep_parse_optional_if_clause (arg
)
6068 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
6071 /* Skip the "if" keyword. */
6074 /* Skip any extra leading whitespace, and record the start of the
6075 condition string. */
6076 ep_skip_leading_whitespace (arg
);
6079 /* Assume that the condition occupies the remainder of the arg string. */
6080 (*arg
) += strlen (cond_string
);
6085 /* This function attempts to parse an optional filename from the arg
6086 string. If one is not found, it returns NULL.
6088 Else, it returns a pointer to the parsed filename. (This function
6089 makes no attempt to verify that a file of that name exists, or is
6090 accessible.) And, it updates arg to point to the first character
6091 following the parsed filename in the arg string.
6093 Note that clients needing to preserve the returned filename for
6094 future access should copy it to their own buffers. */
6096 ep_parse_optional_filename (arg
)
6099 static char filename
[1024];
6104 if ((*arg_p
== '\0') || isspace (*arg_p
))
6122 /* Commands to deal with catching events, such as signals, exceptions,
6123 process start/exit, etc. */
6127 catch_fork
, catch_vfork
6131 #if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
6132 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
6138 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
6139 catch_fork_kind fork_kind
;
6144 char *cond_string
= NULL
;
6146 ep_skip_leading_whitespace (&arg
);
6148 /* The allowed syntax is:
6150 catch [v]fork if <cond>
6152 First, check if there's an if clause. */
6153 cond_string
= ep_parse_optional_if_clause (&arg
);
6155 if ((*arg
!= '\0') && !isspace (*arg
))
6156 error ("Junk at end of arguments.");
6158 /* If this target supports it, create a fork or vfork catchpoint
6159 and enable reporting of such events. */
6163 create_fork_event_catchpoint (tempflag
, cond_string
);
6166 create_vfork_event_catchpoint (tempflag
, cond_string
);
6169 error ("unsupported or unknown fork kind; cannot catch it");
6175 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
6177 catch_exec_command_1 (arg
, tempflag
, from_tty
)
6182 char *cond_string
= NULL
;
6184 ep_skip_leading_whitespace (&arg
);
6186 /* The allowed syntax is:
6188 catch exec if <cond>
6190 First, check if there's an if clause. */
6191 cond_string
= ep_parse_optional_if_clause (&arg
);
6193 if ((*arg
!= '\0') && !isspace (*arg
))
6194 error ("Junk at end of arguments.");
6196 /* If this target supports it, create an exec catchpoint
6197 and enable reporting of such events. */
6198 create_exec_event_catchpoint (tempflag
, cond_string
);
6202 #if defined(SOLIB_ADD)
6204 catch_load_command_1 (arg
, tempflag
, from_tty
)
6209 char *dll_pathname
= NULL
;
6210 char *cond_string
= NULL
;
6212 ep_skip_leading_whitespace (&arg
);
6214 /* The allowed syntax is:
6216 catch load if <cond>
6217 catch load <filename>
6218 catch load <filename> if <cond>
6220 The user is not allowed to specify the <filename> after an
6223 We'll ignore the pathological case of a file named "if".
6225 First, check if there's an if clause. If so, then there
6226 cannot be a filename. */
6227 cond_string
= ep_parse_optional_if_clause (&arg
);
6229 /* If there was an if clause, then there cannot be a filename.
6230 Else, there might be a filename and an if clause. */
6231 if (cond_string
== NULL
)
6233 dll_pathname
= ep_parse_optional_filename (&arg
);
6234 ep_skip_leading_whitespace (&arg
);
6235 cond_string
= ep_parse_optional_if_clause (&arg
);
6238 if ((*arg
!= '\0') && !isspace (*arg
))
6239 error ("Junk at end of arguments.");
6241 /* Create a load breakpoint that only triggers when a load of
6242 the specified dll (or any dll, if no pathname was specified)
6244 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
6245 dll_pathname
, cond_string
);
6249 catch_unload_command_1 (arg
, tempflag
, from_tty
)
6254 char *dll_pathname
= NULL
;
6255 char *cond_string
= NULL
;
6257 ep_skip_leading_whitespace (&arg
);
6259 /* The allowed syntax is:
6261 catch unload if <cond>
6262 catch unload <filename>
6263 catch unload <filename> if <cond>
6265 The user is not allowed to specify the <filename> after an
6268 We'll ignore the pathological case of a file named "if".
6270 First, check if there's an if clause. If so, then there
6271 cannot be a filename. */
6272 cond_string
= ep_parse_optional_if_clause (&arg
);
6274 /* If there was an if clause, then there cannot be a filename.
6275 Else, there might be a filename and an if clause. */
6276 if (cond_string
== NULL
)
6278 dll_pathname
= ep_parse_optional_filename (&arg
);
6279 ep_skip_leading_whitespace (&arg
);
6280 cond_string
= ep_parse_optional_if_clause (&arg
);
6283 if ((*arg
!= '\0') && !isspace (*arg
))
6284 error ("Junk at end of arguments.");
6286 /* Create an unload breakpoint that only triggers when an unload of
6287 the specified dll (or any dll, if no pathname was specified)
6289 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
6290 dll_pathname
, cond_string
);
6292 #endif /* SOLIB_ADD */
6294 /* Commands to deal with catching exceptions. */
6296 /* Set a breakpoint at the specified callback routine for an
6297 exception event callback */
6300 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
6303 enum exception_event_kind ex_event
;
6304 struct symtab_and_line
*sal
;
6306 struct breakpoint
*b
;
6307 int thread
= -1; /* All threads. */
6309 if (!sal
) /* no exception support? */
6312 b
= set_raw_breakpoint (*sal
);
6313 set_breakpoint_count (breakpoint_count
+ 1);
6314 b
->number
= breakpoint_count
;
6316 b
->cond_string
= (cond_string
== NULL
) ?
6317 NULL
: savestring (cond_string
, strlen (cond_string
));
6319 b
->addr_string
= NULL
;
6320 b
->enable
= enabled
;
6321 b
->disposition
= tempflag
? del
: donttouch
;
6324 case EX_EVENT_THROW
:
6325 b
->type
= bp_catch_throw
;
6327 case EX_EVENT_CATCH
:
6328 b
->type
= bp_catch_catch
;
6330 default: /* error condition */
6332 b
->enable
= disabled
;
6333 error ("Internal error -- invalid catchpoint kind");
6338 /* Deal with "catch catch" and "catch throw" commands */
6341 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
6342 enum exception_event_kind ex_event
;
6347 char *cond_string
= NULL
;
6348 struct symtab_and_line
*sal
= NULL
;
6350 ep_skip_leading_whitespace (&arg
);
6352 cond_string
= ep_parse_optional_if_clause (&arg
);
6354 if ((*arg
!= '\0') && !isspace (*arg
))
6355 error ("Junk at end of arguments.");
6357 if ((ex_event
!= EX_EVENT_THROW
) &&
6358 (ex_event
!= EX_EVENT_CATCH
))
6359 error ("Unsupported or unknown exception event; cannot catch it");
6361 /* See if we can find a callback routine */
6362 sal
= target_enable_exception_callback (ex_event
, 1);
6366 /* We have callbacks from the runtime system for exceptions.
6367 Set a breakpoint on the sal found, if no errors */
6368 if (sal
!= (struct symtab_and_line
*) -1)
6369 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
6371 return; /* something went wrong with setting up callbacks */
6375 /* No callbacks from runtime system for exceptions.
6376 Try GNU C++ exception breakpoints using labels in debug info. */
6377 if (ex_event
== EX_EVENT_CATCH
)
6379 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
6381 else if (ex_event
== EX_EVENT_THROW
)
6383 /* Set a breakpoint on __raise_exception () */
6385 warning ("Unsupported with this platform/compiler combination.");
6386 warning ("Perhaps you can achieve the effect you want by setting");
6387 warning ("a breakpoint on __raise_exception().");
6392 /* Cover routine to allow wrapping target_enable_exception_catchpoints
6393 inside a catch_errors */
6396 cover_target_enable_exception_callback (arg
)
6399 args_for_catchpoint_enable
*args
= arg
;
6400 struct symtab_and_line
*sal
;
6401 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
6404 else if (sal
== (struct symtab_and_line
*) -1)
6407 return 1; /*is valid */
6412 /* This is the original v.4.16 and earlier version of the
6413 catch_command_1() function. Now that other flavours of "catch"
6414 have been introduced, and since exception handling can be handled
6415 in other ways (through target ops) also, this is used only for the
6416 GNU C++ exception handling system.
6417 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
6418 "catch NAME" is now no longer allowed in catch_command_1(). Also,
6419 there was no code in GDB 4.16 for "catch throw".
6421 Called from catch_exception_command_1 () */
6425 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
6430 /* First, translate ARG into something we can deal with in terms
6433 struct symtabs_and_lines sals
;
6434 struct symtab_and_line sal
;
6435 register struct expression
*cond
= 0;
6436 register struct breakpoint
*b
;
6440 INIT_SAL (&sal
); /* initialize to zeroes */
6442 /* If no arg given, or if first arg is 'if ', all active catch clauses
6443 are breakpointed. */
6445 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
6446 && (arg
[2] == ' ' || arg
[2] == '\t')))
6448 /* Grab all active catch clauses. */
6449 sals
= get_catch_sals (0);
6453 /* Grab selected catch clauses. */
6454 error ("catch NAME not implemented");
6457 /* Not sure why this code has been disabled. I'm leaving
6458 it disabled. We can never come here now anyway
6459 since we don't allow the "catch NAME" syntax.
6462 /* This isn't used; I don't know what it was for. */
6463 sals
= map_catch_names (arg
, catch_breakpoint
);
6471 for (i
= 0; i
< sals
.nelts
; i
++)
6473 resolve_sal_pc (&sals
.sals
[i
]);
6477 if (arg
[0] == 'i' && arg
[1] == 'f'
6478 && (arg
[2] == ' ' || arg
[2] == '\t'))
6479 cond
= parse_exp_1 ((arg
+= 2, &arg
),
6480 block_for_pc (sals
.sals
[i
].pc
), 0);
6482 error ("Junk at end of arguments.");
6487 for (i
= 0; i
< sals
.nelts
; i
++)
6492 describe_other_breakpoints (sal
.pc
, sal
.section
);
6494 b
= set_raw_breakpoint (sal
);
6495 set_breakpoint_count (breakpoint_count
+ 1);
6496 b
->number
= breakpoint_count
;
6498 /* Important -- this is an ordinary breakpoint. For platforms
6499 with callback support for exceptions,
6500 create_exception_catchpoint() will create special bp types
6501 (bp_catch_catch and bp_catch_throw), and there is code in
6502 insert_breakpoints() and elsewhere that depends on that. */
6503 b
->type
= bp_breakpoint
;
6506 b
->enable
= enabled
;
6507 b
->disposition
= tempflag
? del
: donttouch
;
6514 warning ("Multiple breakpoints were set.");
6515 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
6517 free ((PTR
) sals
.sals
);
6521 /* This creates a temporary internal breakpoint
6522 just to placate infrun */
6523 static struct breakpoint
*
6524 create_temp_exception_breakpoint (pc
)
6527 struct symtab_and_line sal
;
6528 struct breakpoint
*b
;
6535 b
= set_raw_breakpoint (sal
);
6537 error ("Internal error -- couldn't set temp exception breakpoint");
6539 b
->type
= bp_breakpoint
;
6540 b
->disposition
= del
;
6541 b
->enable
= enabled
;
6543 b
->number
= internal_breakpoint_number
--;
6549 catch_command_1 (arg
, tempflag
, from_tty
)
6555 /* The first argument may be an event name, such as "start" or "load".
6556 If so, then handle it as such. If it doesn't match an event name,
6557 then attempt to interpret it as an exception name. (This latter is
6558 the v4.16-and-earlier GDB meaning of the "catch" command.)
6560 First, try to find the bounds of what might be an event name. */
6561 char *arg1_start
= arg
;
6565 if (arg1_start
== NULL
)
6567 /* Old behaviour was to use pre-v-4.16 syntax */
6568 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6570 /* Now, this is not allowed */
6571 error ("Catch requires an event name.");
6574 arg1_end
= ep_find_event_name_end (arg1_start
);
6575 if (arg1_end
== NULL
)
6576 error ("catch requires an event");
6577 arg1_length
= arg1_end
+ 1 - arg1_start
;
6579 /* Try to match what we found against known event names. */
6580 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
6582 error ("Catch of signal not yet implemented");
6584 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
6586 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
6587 tempflag
, from_tty
);
6589 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
6591 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
6592 tempflag
, from_tty
);
6594 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
6596 error ("Catch of thread_start not yet implemented");
6598 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
6600 error ("Catch of thread_exit not yet implemented");
6602 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
6604 error ("Catch of thread_join not yet implemented");
6606 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
6608 error ("Catch of start not yet implemented");
6610 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
6612 error ("Catch of exit not yet implemented");
6614 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
6616 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
6617 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
6619 error ("Catch of fork not yet implemented");
6622 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
6624 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
6625 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
6627 error ("Catch of vfork not yet implemented");
6630 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
6632 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
6633 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6635 error ("Catch of exec not yet implemented");
6638 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
6640 #if defined(SOLIB_ADD)
6641 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6643 error ("Catch of load not implemented");
6646 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
6648 #if defined(SOLIB_ADD)
6649 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6651 error ("Catch of load not implemented");
6654 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
6656 error ("Catch of stop not yet implemented");
6659 /* This doesn't appear to be an event name */
6663 /* Pre-v.4.16 behaviour was to treat the argument
6664 as the name of an exception */
6665 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6666 /* Now this is not allowed */
6667 error ("Unknown event kind specified for catch");
6672 /* Used by the gui, could be made a worker for other things. */
6675 set_breakpoint_sal (sal
)
6676 struct symtab_and_line sal
;
6678 struct breakpoint
*b
;
6679 b
= set_raw_breakpoint (sal
);
6680 set_breakpoint_count (breakpoint_count
+ 1);
6681 b
->number
= breakpoint_count
;
6682 b
->type
= bp_breakpoint
;
6689 /* These aren't used; I don't know what they were for. */
6690 /* Disable breakpoints on all catch clauses described in ARGS. */
6692 disable_catch (args
)
6695 /* Map the disable command to catch clauses described in ARGS. */
6698 /* Enable breakpoints on all catch clauses described in ARGS. */
6703 /* Map the disable command to catch clauses described in ARGS. */
6706 /* Delete breakpoints on all catch clauses in the active scope. */
6711 /* Map the delete command to catch clauses described in ARGS. */
6716 catch_command (arg
, from_tty
)
6720 catch_command_1 (arg
, 0, from_tty
);
6725 tcatch_command (arg
, from_tty
)
6729 catch_command_1 (arg
, 1, from_tty
);
6734 clear_command (arg
, from_tty
)
6738 register struct breakpoint
*b
, *b1
;
6740 struct symtabs_and_lines sals
;
6741 struct symtab_and_line sal
;
6742 register struct breakpoint
*found
;
6747 sals
= decode_line_spec (arg
, 1);
6752 sals
.sals
= (struct symtab_and_line
*)
6753 xmalloc (sizeof (struct symtab_and_line
));
6754 INIT_SAL (&sal
); /* initialize to zeroes */
6755 sal
.line
= default_breakpoint_line
;
6756 sal
.symtab
= default_breakpoint_symtab
;
6757 sal
.pc
= default_breakpoint_address
;
6758 if (sal
.symtab
== 0)
6759 error ("No source file specified.");
6767 /* For each line spec given, delete bps which correspond
6768 to it. We do this in two loops: the first loop looks at
6769 the initial bp(s) in the chain which should be deleted,
6770 the second goes down the rest of the chain looking ahead
6771 one so it can take those bps off the chain without messing
6775 for (i
= 0; i
< sals
.nelts
; i
++)
6777 /* If exact pc given, clear bpts at that pc.
6778 If line given (pc == 0), clear all bpts on specified line.
6779 If defaulting, clear all bpts on default line
6782 defaulting sal.pc != 0 tests to do
6787 1 0 <can't happen> */
6790 found
= (struct breakpoint
*) 0;
6793 while (breakpoint_chain
6794 /* Why don't we check here that this is not
6795 a watchpoint, etc., as we do below?
6796 I can't make it fail, but don't know
6797 what's stopping the failure: a watchpoint
6798 of the same address as "sal.pc" should
6799 wind up being deleted. */
6801 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
6802 (overlay_debugging
== 0 ||
6803 breakpoint_chain
->section
== sal
.section
))
6804 || ((default_match
|| (0 == sal
.pc
))
6805 && breakpoint_chain
->source_file
!= NULL
6806 && sal
.symtab
!= NULL
6807 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
6808 && breakpoint_chain
->line_number
== sal
.line
)))
6811 b1
= breakpoint_chain
;
6812 breakpoint_chain
= b1
->next
;
6820 && b
->next
->type
!= bp_none
6821 && b
->next
->type
!= bp_watchpoint
6822 && b
->next
->type
!= bp_hardware_watchpoint
6823 && b
->next
->type
!= bp_read_watchpoint
6824 && b
->next
->type
!= bp_access_watchpoint
6825 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
6826 (overlay_debugging
== 0 ||
6827 b
->next
->section
== sal
.section
))
6828 || ((default_match
|| (0 == sal
.pc
))
6829 && b
->next
->source_file
!= NULL
6830 && sal
.symtab
!= NULL
6831 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
6832 && b
->next
->line_number
== sal
.line
)))
6845 error ("No breakpoint at %s.", arg
);
6847 error ("No breakpoint at this line.");
6851 from_tty
= 1; /* Always report if deleted more than one */
6853 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
6854 breakpoints_changed ();
6858 printf_unfiltered ("%d ", found
->number
);
6860 delete_breakpoint (found
);
6864 putchar_unfiltered ('\n');
6866 free ((PTR
) sals
.sals
);
6869 /* Delete breakpoint in BS if they are `delete' breakpoints and
6870 all breakpoints that are marked for deletion, whether hit or not.
6871 This is called after any breakpoint is hit, or after errors. */
6874 breakpoint_auto_delete (bs
)
6877 struct breakpoint
*b
, *temp
;
6879 for (; bs
; bs
= bs
->next
)
6880 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
6882 delete_breakpoint (bs
->breakpoint_at
);
6884 ALL_BREAKPOINTS_SAFE (b
, temp
)
6886 if (b
->disposition
== del_at_next_stop
)
6887 delete_breakpoint (b
);
6891 /* Delete a breakpoint and clean up all traces of it in the data
6895 delete_breakpoint (bpt
)
6896 struct breakpoint
*bpt
;
6898 register struct breakpoint
*b
;
6902 error ("Internal error (attempted to delete a NULL breakpoint)");
6905 /* Has this bp already been deleted? This can happen because multiple
6906 lists can hold pointers to bp's. bpstat lists are especial culprits.
6908 One example of this happening is a watchpoint's scope bp. When the
6909 scope bp triggers, we notice that the watchpoint is out of scope, and
6910 delete it. We also delete its scope bp. But the scope bp is marked
6911 "auto-deleting", and is already on a bpstat. That bpstat is then
6912 checked for auto-deleting bp's, which are deleted.
6914 A real solution to this problem might involve reference counts in bp's,
6915 and/or giving them pointers back to their referencing bpstat's, and
6916 teaching delete_breakpoint to only free a bp's storage when no more
6917 references were extent. A cheaper bandaid was chosen. */
6918 if (bpt
->type
== bp_none
)
6921 if (delete_breakpoint_hook
)
6922 delete_breakpoint_hook (bpt
);
6923 breakpoint_delete_event (bpt
->number
);
6926 remove_breakpoint (bpt
, mark_uninserted
);
6928 if (breakpoint_chain
== bpt
)
6929 breakpoint_chain
= bpt
->next
;
6931 /* If we have callback-style exception catchpoints, don't go through
6932 the adjustments to the C++ runtime library etc. if the inferior
6933 isn't actually running. target_enable_exception_callback for a
6934 null target ops vector gives an undesirable error message, so we
6935 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
6936 exceptions are supported in this way, it's OK for now. FIXME */
6937 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
6939 static char message1
[] = "Error in deleting catchpoint %d:\n";
6940 static char message
[sizeof (message1
) + 30];
6941 args_for_catchpoint_enable args
;
6943 /* Format possible error msg */
6944 sprintf (message
, message1
, bpt
->number
);
6945 args
.kind
= bpt
->type
== bp_catch_catch
?
6946 EX_EVENT_CATCH
: EX_EVENT_THROW
;
6948 catch_errors (cover_target_enable_exception_callback
, &args
,
6949 message
, RETURN_MASK_ALL
);
6956 b
->next
= bpt
->next
;
6960 /* Before turning off the visuals for the bp, check to see that
6961 there are no other bps at the same address. */
6968 clearIt
= (b
->address
!= bpt
->address
);
6975 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
6976 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
6980 check_duplicates (bpt
->address
, bpt
->section
);
6981 /* If this breakpoint was inserted, and there is another breakpoint
6982 at the same address, we need to insert the other breakpoint. */
6984 && bpt
->type
!= bp_hardware_watchpoint
6985 && bpt
->type
!= bp_read_watchpoint
6986 && bpt
->type
!= bp_access_watchpoint
6987 && bpt
->type
!= bp_catch_fork
6988 && bpt
->type
!= bp_catch_vfork
6989 && bpt
->type
!= bp_catch_exec
)
6992 if (b
->address
== bpt
->address
6993 && b
->section
== bpt
->section
6995 && b
->enable
!= disabled
6996 && b
->enable
!= shlib_disabled
6997 && b
->enable
!= call_disabled
)
7001 /* We should never reach this point if there is a permanent
7002 breakpoint at the same address as the one being deleted.
7003 If there is a permanent breakpoint somewhere, it should
7004 always be the only one inserted. */
7005 if (b
->enable
== permanent
)
7006 internal_error ("another breakpoint was inserted on top of "
7007 "a permanent breakpoint");
7009 if (b
->type
== bp_hardware_breakpoint
)
7010 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
7012 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
7016 target_terminal_ours_for_output ();
7017 warning ("Cannot insert breakpoint %d:", b
->number
);
7018 memory_error (val
, b
->address
); /* which bombs us out */
7025 free_command_lines (&bpt
->commands
);
7028 if (bpt
->cond_string
!= NULL
)
7029 free (bpt
->cond_string
);
7030 if (bpt
->addr_string
!= NULL
)
7031 free (bpt
->addr_string
);
7032 if (bpt
->exp
!= NULL
)
7034 if (bpt
->exp_string
!= NULL
)
7035 free (bpt
->exp_string
);
7036 if (bpt
->val
!= NULL
)
7037 value_free (bpt
->val
);
7038 if (bpt
->source_file
!= NULL
)
7039 free (bpt
->source_file
);
7040 if (bpt
->dll_pathname
!= NULL
)
7041 free (bpt
->dll_pathname
);
7042 if (bpt
->triggered_dll_pathname
!= NULL
)
7043 free (bpt
->triggered_dll_pathname
);
7044 if (bpt
->exec_pathname
!= NULL
)
7045 free (bpt
->exec_pathname
);
7047 /* Be sure no bpstat's are pointing at it after it's been freed. */
7048 /* FIXME, how can we find all bpstat's?
7049 We just check stop_bpstat for now. */
7050 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
7051 if (bs
->breakpoint_at
== bpt
)
7053 bs
->breakpoint_at
= NULL
;
7055 /* we'd call bpstat_clear_actions, but that free's stuff and due
7056 to the multiple pointers pointing to one item with no
7057 reference counts found anywhere through out the bpstat's (how
7058 do you spell fragile?), we don't want to free things twice --
7059 better a memory leak than a corrupt malloc pool! */
7060 bs
->commands
= NULL
;
7063 /* On the chance that someone will soon try again to delete this same
7064 bp, we mark it as deleted before freeing its storage. */
7065 bpt
->type
= bp_none
;
7071 do_delete_breakpoint_cleanup (void *b
)
7073 delete_breakpoint (b
);
7077 make_cleanup_delete_breakpoint (struct breakpoint
*b
)
7079 return make_cleanup (do_delete_breakpoint_cleanup
, b
);
7083 make_exec_cleanup_delete_breakpoint (struct breakpoint
*b
)
7085 return make_exec_cleanup (do_delete_breakpoint_cleanup
, b
);
7089 delete_command (arg
, from_tty
)
7093 struct breakpoint
*b
, *temp
;
7097 int breaks_to_delete
= 0;
7099 /* Delete all breakpoints if no argument.
7100 Do not delete internal or call-dummy breakpoints, these
7101 have to be deleted with an explicit breakpoint number argument. */
7104 if (b
->type
!= bp_call_dummy
&&
7105 b
->type
!= bp_shlib_event
&&
7106 b
->type
!= bp_thread_event
&&
7108 breaks_to_delete
= 1;
7111 /* Ask user only if there are some breakpoints to delete. */
7113 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
7115 ALL_BREAKPOINTS_SAFE (b
, temp
)
7117 if (b
->type
!= bp_call_dummy
&&
7118 b
->type
!= bp_shlib_event
&&
7119 b
->type
!= bp_thread_event
&&
7121 delete_breakpoint (b
);
7126 map_breakpoint_numbers (arg
, delete_breakpoint
);
7129 /* Reset a breakpoint given it's struct breakpoint * BINT.
7130 The value we return ends up being the return value from catch_errors.
7131 Unused in this case. */
7134 breakpoint_re_set_one (bint
)
7137 /* get past catch_errs */
7138 struct breakpoint
*b
= (struct breakpoint
*) bint
;
7141 struct symtabs_and_lines sals
;
7143 enum enable save_enable
;
7148 warning ("attempted to reset apparently deleted breakpoint #%d?",
7152 case bp_hardware_breakpoint
:
7154 case bp_catch_unload
:
7155 if (b
->addr_string
== NULL
)
7157 /* Anything without a string can't be re-set. */
7158 delete_breakpoint (b
);
7161 /* In case we have a problem, disable this breakpoint. We'll restore
7162 its status if we succeed. */
7163 save_enable
= b
->enable
;
7164 b
->enable
= disabled
;
7166 set_language (b
->language
);
7167 input_radix
= b
->input_radix
;
7169 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
7170 for (i
= 0; i
< sals
.nelts
; i
++)
7172 resolve_sal_pc (&sals
.sals
[i
]);
7174 /* Reparse conditions, they might contain references to the
7176 if (b
->cond_string
!= NULL
)
7180 free ((PTR
) b
->cond
);
7181 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
7184 /* We need to re-set the breakpoint if the address changes... */
7185 if (b
->address
!= sals
.sals
[i
].pc
7186 /* ...or new and old breakpoints both have source files, and
7187 the source file name or the line number changes... */
7188 || (b
->source_file
!= NULL
7189 && sals
.sals
[i
].symtab
!= NULL
7190 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
7191 || b
->line_number
!= sals
.sals
[i
].line
)
7193 /* ...or we switch between having a source file and not having
7195 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
7198 if (b
->source_file
!= NULL
)
7199 free (b
->source_file
);
7200 if (sals
.sals
[i
].symtab
== NULL
)
7201 b
->source_file
= NULL
;
7204 savestring (sals
.sals
[i
].symtab
->filename
,
7205 strlen (sals
.sals
[i
].symtab
->filename
));
7206 b
->line_number
= sals
.sals
[i
].line
;
7207 b
->address
= sals
.sals
[i
].pc
;
7209 /* Used to check for duplicates here, but that can
7210 cause trouble, as it doesn't check for disable
7215 /* Might be better to do this just once per breakpoint_re_set,
7216 rather than once for every breakpoint. */
7217 breakpoints_changed ();
7219 b
->section
= sals
.sals
[i
].section
;
7220 b
->enable
= save_enable
; /* Restore it, this worked. */
7223 /* Now that this is re-enabled, check_duplicates
7225 check_duplicates (b
->address
, b
->section
);
7228 free ((PTR
) sals
.sals
);
7232 case bp_hardware_watchpoint
:
7233 case bp_read_watchpoint
:
7234 case bp_access_watchpoint
:
7235 innermost_block
= NULL
;
7236 /* The issue arises of what context to evaluate this in. The
7237 same one as when it was set, but what does that mean when
7238 symbols have been re-read? We could save the filename and
7239 functionname, but if the context is more local than that, the
7240 best we could do would be something like how many levels deep
7241 and which index at that particular level, but that's going to
7242 be less stable than filenames or function names. */
7244 /* So for now, just use a global context. */
7246 free ((PTR
) b
->exp
);
7247 b
->exp
= parse_expression (b
->exp_string
);
7248 b
->exp_valid_block
= innermost_block
;
7249 mark
= value_mark ();
7251 value_free (b
->val
);
7252 b
->val
= evaluate_expression (b
->exp
);
7253 release_value (b
->val
);
7254 if (VALUE_LAZY (b
->val
))
7255 value_fetch_lazy (b
->val
);
7257 if (b
->cond_string
!= NULL
)
7261 free ((PTR
) b
->cond
);
7262 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
7264 if (b
->enable
== enabled
)
7266 value_free_to_mark (mark
);
7268 case bp_catch_catch
:
7269 case bp_catch_throw
:
7271 /* We needn't really do anything to reset these, since the mask
7272 that requests them is unaffected by e.g., new libraries being
7275 case bp_catch_vfork
:
7280 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
7282 /* Delete longjmp breakpoints, they will be reset later by
7283 breakpoint_re_set. */
7285 case bp_longjmp_resume
:
7286 delete_breakpoint (b
);
7289 /* This breakpoint is special, it's set up when the inferior
7290 starts and we really don't want to touch it. */
7291 case bp_shlib_event
:
7293 /* Like bp_shlib_event, this breakpoint type is special.
7294 Once it is set up, we do not want to touch it. */
7295 case bp_thread_event
:
7297 /* Keep temporary breakpoints, which can be encountered when we step
7298 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
7299 Otherwise these should have been blown away via the cleanup chain
7300 or by breakpoint_init_inferior when we rerun the executable. */
7303 case bp_watchpoint_scope
:
7305 case bp_step_resume
:
7312 /* Re-set all breakpoints after symbols have been re-loaded. */
7314 breakpoint_re_set ()
7316 struct breakpoint
*b
, *temp
;
7317 enum language save_language
;
7318 int save_input_radix
;
7319 static char message1
[] = "Error in re-setting breakpoint %d:\n";
7320 char message
[sizeof (message1
) + 30 /* slop */ ];
7322 save_language
= current_language
->la_language
;
7323 save_input_radix
= input_radix
;
7324 ALL_BREAKPOINTS_SAFE (b
, temp
)
7326 /* Format possible error msg */
7327 sprintf (message
, message1
, b
->number
);
7328 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
7330 set_language (save_language
);
7331 input_radix
= save_input_radix
;
7333 #ifdef GET_LONGJMP_TARGET
7334 create_longjmp_breakpoint ("longjmp");
7335 create_longjmp_breakpoint ("_longjmp");
7336 create_longjmp_breakpoint ("siglongjmp");
7337 create_longjmp_breakpoint ("_siglongjmp");
7338 create_longjmp_breakpoint (NULL
);
7342 /* Took this out (temporarily at least), since it produces an extra
7343 blank line at startup. This messes up the gdbtests. -PB */
7344 /* Blank line to finish off all those mention() messages we just printed. */
7345 printf_filtered ("\n");
7349 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
7350 If from_tty is nonzero, it prints a message to that effect,
7351 which ends with a period (no newline). */
7353 /* Reset the thread number of this breakpoint:
7355 - If the breakpoint is for all threads, leave it as-is.
7356 - Else, reset it to the current thread for inferior_pid. */
7358 breakpoint_re_set_thread (b
)
7359 struct breakpoint
*b
;
7361 if (b
->thread
!= -1)
7363 if (in_thread_list (inferior_pid
))
7364 b
->thread
= pid_to_thread_id (inferior_pid
);
7369 set_ignore_count (bptnum
, count
, from_tty
)
7370 int bptnum
, count
, from_tty
;
7372 register struct breakpoint
*b
;
7378 if (b
->number
== bptnum
)
7380 b
->ignore_count
= count
;
7383 else if (count
== 0)
7384 printf_filtered ("Will stop next time breakpoint %d is reached.",
7386 else if (count
== 1)
7387 printf_filtered ("Will ignore next crossing of breakpoint %d.",
7390 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
7392 breakpoints_changed ();
7396 error ("No breakpoint number %d.", bptnum
);
7399 /* Clear the ignore counts of all breakpoints. */
7401 breakpoint_clear_ignore_counts ()
7403 struct breakpoint
*b
;
7406 b
->ignore_count
= 0;
7409 /* Command to set ignore-count of breakpoint N to COUNT. */
7412 ignore_command (args
, from_tty
)
7420 error_no_arg ("a breakpoint number");
7422 num
= get_number (&p
);
7424 error ("bad breakpoint number: '%s'", args
);
7426 error ("Second argument (specified ignore-count) is missing.");
7428 set_ignore_count (num
,
7429 longest_to_int (value_as_long (parse_and_eval (p
))),
7431 printf_filtered ("\n");
7432 breakpoints_changed ();
7435 /* Call FUNCTION on each of the breakpoints
7436 whose numbers are given in ARGS. */
7439 map_breakpoint_numbers (args
, function
)
7441 void (*function
) PARAMS ((struct breakpoint
*));
7443 register char *p
= args
;
7446 register struct breakpoint
*b
, *tmp
;
7450 error_no_arg ("one or more breakpoint numbers");
7457 num
= get_number_or_range (&p1
);
7460 warning ("bad breakpoint number at or near '%s'", p
);
7464 ALL_BREAKPOINTS_SAFE (b
, tmp
)
7465 if (b
->number
== num
)
7467 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
7470 if (related_breakpoint
)
7471 function (related_breakpoint
);
7475 printf_unfiltered ("No breakpoint number %d.\n", num
);
7482 disable_breakpoint (bpt
)
7483 struct breakpoint
*bpt
;
7485 /* Never disable a watchpoint scope breakpoint; we want to
7486 hit them when we leave scope so we can delete both the
7487 watchpoint and its scope breakpoint at that time. */
7488 if (bpt
->type
== bp_watchpoint_scope
)
7491 /* You can't disable permanent breakpoints. */
7492 if (bpt
->enable
== permanent
)
7495 bpt
->enable
= disabled
;
7497 check_duplicates (bpt
->address
, bpt
->section
);
7499 if (modify_breakpoint_hook
)
7500 modify_breakpoint_hook (bpt
);
7501 breakpoint_modify_event (bpt
->number
);
7506 disable_command (args
, from_tty
)
7510 register struct breakpoint
*bpt
;
7512 ALL_BREAKPOINTS (bpt
)
7516 warning ("attempted to disable apparently deleted breakpoint #%d?",
7521 case bp_catch_unload
:
7523 case bp_catch_vfork
:
7525 case bp_catch_catch
:
7526 case bp_catch_throw
:
7527 case bp_hardware_breakpoint
:
7529 case bp_hardware_watchpoint
:
7530 case bp_read_watchpoint
:
7531 case bp_access_watchpoint
:
7532 disable_breakpoint (bpt
);
7537 map_breakpoint_numbers (args
, disable_breakpoint
);
7541 do_enable_breakpoint (bpt
, disposition
)
7542 struct breakpoint
*bpt
;
7543 enum bpdisp disposition
;
7545 struct frame_info
*save_selected_frame
= NULL
;
7546 int save_selected_frame_level
= -1;
7547 int target_resources_ok
, other_type_used
;
7550 if (bpt
->type
== bp_hardware_breakpoint
)
7553 i
= hw_breakpoint_used_count ();
7554 target_resources_ok
=
7555 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
7557 if (target_resources_ok
== 0)
7558 error ("No hardware breakpoint support in the target.");
7559 else if (target_resources_ok
< 0)
7560 error ("Hardware breakpoints used exceeds limit.");
7563 if (bpt
->enable
!= permanent
)
7564 bpt
->enable
= enabled
;
7565 bpt
->disposition
= disposition
;
7566 check_duplicates (bpt
->address
, bpt
->section
);
7567 breakpoints_changed ();
7569 if (bpt
->type
== bp_watchpoint
||
7570 bpt
->type
== bp_hardware_watchpoint
||
7571 bpt
->type
== bp_read_watchpoint
||
7572 bpt
->type
== bp_access_watchpoint
)
7574 if (bpt
->exp_valid_block
!= NULL
)
7576 struct frame_info
*fr
=
7578 /* Ensure that we have the current frame. Else, this
7579 next query may pessimistically be answered as, "No,
7580 not within current scope". */
7581 get_current_frame ();
7582 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
7586 Cannot enable watchpoint %d because the block in which its expression\n\
7587 is valid is not currently in scope.\n", bpt
->number
);
7588 bpt
->enable
= disabled
;
7592 save_selected_frame
= selected_frame
;
7593 save_selected_frame_level
= selected_frame_level
;
7594 select_frame (fr
, -1);
7597 value_free (bpt
->val
);
7598 mark
= value_mark ();
7599 bpt
->val
= evaluate_expression (bpt
->exp
);
7600 release_value (bpt
->val
);
7601 if (VALUE_LAZY (bpt
->val
))
7602 value_fetch_lazy (bpt
->val
);
7604 if (bpt
->type
== bp_hardware_watchpoint
||
7605 bpt
->type
== bp_read_watchpoint
||
7606 bpt
->type
== bp_access_watchpoint
)
7608 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
7609 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
7611 /* Hack around 'unused var' error for some targets here */
7613 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
7614 bpt
->type
, i
+ mem_cnt
, other_type_used
);
7615 /* we can consider of type is bp_hardware_watchpoint, convert to
7616 bp_watchpoint in the following condition */
7617 if (target_resources_ok
< 0)
7620 Cannot enable watchpoint %d because target watch resources\n\
7621 have been allocated for other watchpoints.\n", bpt
->number
);
7622 bpt
->enable
= disabled
;
7623 value_free_to_mark (mark
);
7628 if (save_selected_frame_level
>= 0)
7629 select_frame (save_selected_frame
, save_selected_frame_level
);
7630 value_free_to_mark (mark
);
7632 if (modify_breakpoint_hook
)
7633 modify_breakpoint_hook (bpt
);
7634 breakpoint_modify_event (bpt
->number
);
7638 enable_breakpoint (bpt
)
7639 struct breakpoint
*bpt
;
7641 do_enable_breakpoint (bpt
, bpt
->disposition
);
7644 /* The enable command enables the specified breakpoints (or all defined
7645 breakpoints) so they once again become (or continue to be) effective
7646 in stopping the inferior. */
7650 enable_command (args
, from_tty
)
7654 register struct breakpoint
*bpt
;
7656 ALL_BREAKPOINTS (bpt
)
7660 warning ("attempted to enable apparently deleted breakpoint #%d?",
7665 case bp_catch_unload
:
7667 case bp_catch_vfork
:
7669 case bp_catch_catch
:
7670 case bp_catch_throw
:
7671 case bp_hardware_breakpoint
:
7673 case bp_hardware_watchpoint
:
7674 case bp_read_watchpoint
:
7675 case bp_access_watchpoint
:
7676 enable_breakpoint (bpt
);
7681 map_breakpoint_numbers (args
, enable_breakpoint
);
7685 enable_once_breakpoint (bpt
)
7686 struct breakpoint
*bpt
;
7688 do_enable_breakpoint (bpt
, disable
);
7693 enable_once_command (args
, from_tty
)
7697 map_breakpoint_numbers (args
, enable_once_breakpoint
);
7701 enable_delete_breakpoint (bpt
)
7702 struct breakpoint
*bpt
;
7704 do_enable_breakpoint (bpt
, del
);
7709 enable_delete_command (args
, from_tty
)
7713 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
7716 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
7718 struct symtabs_and_lines
7719 decode_line_spec_1 (string
, funfirstline
)
7723 struct symtabs_and_lines sals
;
7725 error ("Empty line specification.");
7726 if (default_breakpoint_valid
)
7727 sals
= decode_line_1 (&string
, funfirstline
,
7728 default_breakpoint_symtab
,
7729 default_breakpoint_line
,
7732 sals
= decode_line_1 (&string
, funfirstline
,
7733 (struct symtab
*) NULL
, 0, (char ***) NULL
);
7735 error ("Junk at end of line specification: %s", string
);
7740 _initialize_breakpoint ()
7742 struct cmd_list_element
*c
;
7744 breakpoint_chain
= 0;
7745 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
7746 before a breakpoint is set. */
7747 breakpoint_count
= 0;
7749 add_com ("ignore", class_breakpoint
, ignore_command
,
7750 "Set ignore-count of breakpoint number N to COUNT.\n\
7751 Usage is `ignore N COUNT'.");
7753 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
7755 add_com ("commands", class_breakpoint
, commands_command
,
7756 "Set commands to be executed when a breakpoint is hit.\n\
7757 Give breakpoint number as argument after \"commands\".\n\
7758 With no argument, the targeted breakpoint is the last one set.\n\
7759 The commands themselves follow starting on the next line.\n\
7760 Type a line containing \"end\" to indicate the end of them.\n\
7761 Give \"silent\" as the first line to make the breakpoint silent;\n\
7762 then no output is printed when it is hit, except what the commands print.");
7764 add_com ("condition", class_breakpoint
, condition_command
,
7765 "Specify breakpoint number N to break only if COND is true.\n\
7766 Usage is `condition N COND', where N is an integer and COND is an\n\
7767 expression to be evaluated whenever breakpoint N is reached. ");
7769 add_com ("tbreak", class_breakpoint
, tbreak_command
,
7770 "Set a temporary breakpoint. Args like \"break\" command.\n\
7771 Like \"break\" except the breakpoint is only temporary,\n\
7772 so it will be deleted when hit. Equivalent to \"break\" followed\n\
7773 by using \"enable delete\" on the breakpoint number.");
7774 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
7775 "Set temporary breakpoint at procedure exit. Either there should\n\
7776 be no argument or the argument must be a depth.\n");
7778 add_com ("hbreak", class_breakpoint
, hbreak_command
,
7779 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
7780 Like \"break\" except the breakpoint requires hardware support,\n\
7781 some target hardware may not have this support.");
7783 add_com ("thbreak", class_breakpoint
, thbreak_command
,
7784 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
7785 Like \"hbreak\" except the breakpoint is only temporary,\n\
7786 so it will be deleted when hit.");
7788 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
7789 "Enable some breakpoints.\n\
7790 Give breakpoint numbers (separated by spaces) as arguments.\n\
7791 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7792 This is used to cancel the effect of the \"disable\" command.\n\
7793 With a subcommand you can enable temporarily.",
7794 &enablelist
, "enable ", 1, &cmdlist
);
7796 add_com ("ab", class_breakpoint
, enable_command
,
7797 "Enable some breakpoints.\n\
7798 Give breakpoint numbers (separated by spaces) as arguments.\n\
7799 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7800 This is used to cancel the effect of the \"disable\" command.\n\
7801 With a subcommand you can enable temporarily.");
7803 add_com_alias ("en", "enable", class_breakpoint
, 1);
7805 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
7806 "Enable some breakpoints.\n\
7807 Give breakpoint numbers (separated by spaces) as arguments.\n\
7808 This is used to cancel the effect of the \"disable\" command.\n\
7809 May be abbreviated to simply \"enable\".\n",
7810 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
7812 add_cmd ("once", no_class
, enable_once_command
,
7813 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7814 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7817 add_cmd ("delete", no_class
, enable_delete_command
,
7818 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7819 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7822 add_cmd ("delete", no_class
, enable_delete_command
,
7823 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7824 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7827 add_cmd ("once", no_class
, enable_once_command
,
7828 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7829 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7832 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
7833 "Disable some breakpoints.\n\
7834 Arguments are breakpoint numbers with spaces in between.\n\
7835 To disable all breakpoints, give no argument.\n\
7836 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
7837 &disablelist
, "disable ", 1, &cmdlist
);
7838 add_com_alias ("dis", "disable", class_breakpoint
, 1);
7839 add_com_alias ("disa", "disable", class_breakpoint
, 1);
7841 add_com ("sb", class_breakpoint
, disable_command
,
7842 "Disable some breakpoints.\n\
7843 Arguments are breakpoint numbers with spaces in between.\n\
7844 To disable all breakpoints, give no argument.\n\
7845 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
7847 add_cmd ("breakpoints", class_alias
, disable_command
,
7848 "Disable some breakpoints.\n\
7849 Arguments are breakpoint numbers with spaces in between.\n\
7850 To disable all breakpoints, give no argument.\n\
7851 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
7852 This command may be abbreviated \"disable\".",
7855 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
7856 "Delete some breakpoints or auto-display expressions.\n\
7857 Arguments are breakpoint numbers with spaces in between.\n\
7858 To delete all breakpoints, give no argument.\n\
7860 Also a prefix command for deletion of other GDB objects.\n\
7861 The \"unset\" command is also an alias for \"delete\".",
7862 &deletelist
, "delete ", 1, &cmdlist
);
7863 add_com_alias ("d", "delete", class_breakpoint
, 1);
7865 add_com ("db", class_breakpoint
, delete_command
,
7866 "Delete some breakpoints.\n\
7867 Arguments are breakpoint numbers with spaces in between.\n\
7868 To delete all breakpoints, give no argument.\n");
7870 add_cmd ("breakpoints", class_alias
, delete_command
,
7871 "Delete some breakpoints or auto-display expressions.\n\
7872 Arguments are breakpoint numbers with spaces in between.\n\
7873 To delete all breakpoints, give no argument.\n\
7874 This command may be abbreviated \"delete\".",
7877 add_com ("clear", class_breakpoint
, clear_command
,
7878 concat ("Clear breakpoint at specified line or function.\n\
7879 Argument may be line number, function name, or \"*\" and an address.\n\
7880 If line number is specified, all breakpoints in that line are cleared.\n\
7881 If function is specified, breakpoints at beginning of function are cleared.\n\
7882 If an address is specified, breakpoints at that address are cleared.\n\n",
7883 "With no argument, clears all breakpoints in the line that the selected frame\n\
7886 See also the \"delete\" command which clears breakpoints by number.", NULL
));
7888 add_com ("break", class_breakpoint
, break_command
,
7889 concat ("Set breakpoint at specified line or function.\n\
7890 Argument may be line number, function name, or \"*\" and an address.\n\
7891 If line number is specified, break at start of code for that line.\n\
7892 If function is specified, break at start of code for that function.\n\
7893 If an address is specified, break at that exact address.\n",
7894 "With no arg, uses current execution address of selected stack frame.\n\
7895 This is useful for breaking on return to a stack frame.\n\
7897 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7899 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7900 add_com_alias ("b", "break", class_run
, 1);
7901 add_com_alias ("br", "break", class_run
, 1);
7902 add_com_alias ("bre", "break", class_run
, 1);
7903 add_com_alias ("brea", "break", class_run
, 1);
7905 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
7906 concat ("Set breakpoint at procedure exit. \n\
7907 Argument may be function name, or \"*\" and an address.\n\
7908 If function is specified, break at end of code for that function.\n\
7909 If an address is specified, break at the end of the function that contains \n\
7910 that exact address.\n",
7911 "With no arg, uses current execution address of selected stack frame.\n\
7912 This is useful for breaking on return to a stack frame.\n\
7914 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7916 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7917 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
7918 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
7919 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
7920 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
7924 add_com_alias ("ba", "break", class_breakpoint
, 1);
7925 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
7926 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
7927 "Set breakpoint at procedure exit. Either there should\n\
7928 be no argument or the argument must be a depth.\n");
7933 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
7934 "Break in function/address or break at a line in the current file.",
7935 &stoplist
, "stop ", 1, &cmdlist
);
7936 add_cmd ("in", class_breakpoint
, stopin_command
,
7937 "Break in function or address.\n", &stoplist
);
7938 add_cmd ("at", class_breakpoint
, stopat_command
,
7939 "Break at a line in the current file.\n", &stoplist
);
7940 add_com ("status", class_info
, breakpoints_info
,
7941 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7942 The \"Type\" column indicates one of:\n\
7943 \tbreakpoint - normal breakpoint\n\
7944 \twatchpoint - watchpoint\n\
7945 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7946 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7947 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7948 address and file/line number respectively.\n\n",
7949 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7950 are set to the address of the last breakpoint listed.\n\n\
7951 Convenience variable \"$bpnum\" contains the number of the last\n\
7952 breakpoint set.", NULL
));
7955 add_info ("breakpoints", breakpoints_info
,
7956 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7957 The \"Type\" column indicates one of:\n\
7958 \tbreakpoint - normal breakpoint\n\
7959 \twatchpoint - watchpoint\n\
7960 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7961 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7962 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7963 address and file/line number respectively.\n\n",
7964 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7965 are set to the address of the last breakpoint listed.\n\n\
7966 Convenience variable \"$bpnum\" contains the number of the last\n\
7967 breakpoint set.", NULL
));
7970 add_com ("lb", class_breakpoint
, breakpoints_info
,
7971 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7972 The \"Type\" column indicates one of:\n\
7973 \tbreakpoint - normal breakpoint\n\
7974 \twatchpoint - watchpoint\n\
7975 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7976 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7977 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7978 address and file/line number respectively.\n\n",
7979 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7980 are set to the address of the last breakpoint listed.\n\n\
7981 Convenience variable \"$bpnum\" contains the number of the last\n\
7982 breakpoint set.", NULL
));
7984 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
7985 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
7986 The \"Type\" column indicates one of:\n\
7987 \tbreakpoint - normal breakpoint\n\
7988 \twatchpoint - watchpoint\n\
7989 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7990 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7991 \tuntil - internal breakpoint used by the \"until\" command\n\
7992 \tfinish - internal breakpoint used by the \"finish\" command\n",
7993 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7994 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7995 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7996 address and file/line number respectively.\n\n",
7997 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7998 are set to the address of the last breakpoint listed.\n\n\
7999 Convenience variable \"$bpnum\" contains the number of the last\n\
8000 breakpoint set.", NULL
),
8001 &maintenanceinfolist
);
8003 add_com ("catch", class_breakpoint
, catch_command
,
8004 "Set catchpoints to catch events.\n\
8005 Raised signals may be caught:\n\
8006 \tcatch signal - all signals\n\
8007 \tcatch signal <signame> - a particular signal\n\
8008 Raised exceptions may be caught:\n\
8009 \tcatch throw - all exceptions, when thrown\n\
8010 \tcatch throw <exceptname> - a particular exception, when thrown\n\
8011 \tcatch catch - all exceptions, when caught\n\
8012 \tcatch catch <exceptname> - a particular exception, when caught\n\
8013 Thread or process events may be caught:\n\
8014 \tcatch thread_start - any threads, just after creation\n\
8015 \tcatch thread_exit - any threads, just before expiration\n\
8016 \tcatch thread_join - any threads, just after joins\n\
8017 Process events may be caught:\n\
8018 \tcatch start - any processes, just after creation\n\
8019 \tcatch exit - any processes, just before expiration\n\
8020 \tcatch fork - calls to fork()\n\
8021 \tcatch vfork - calls to vfork()\n\
8022 \tcatch exec - calls to exec()\n\
8023 Dynamically-linked library events may be caught:\n\
8024 \tcatch load - loads of any library\n\
8025 \tcatch load <libname> - loads of a particular library\n\
8026 \tcatch unload - unloads of any library\n\
8027 \tcatch unload <libname> - unloads of a particular library\n\
8028 The act of your program's execution stopping may also be caught:\n\
8030 C++ exceptions may be caught:\n\
8031 \tcatch throw - all exceptions, when thrown\n\
8032 \tcatch catch - all exceptions, when caught\n\
8034 Do \"help set follow-fork-mode\" for info on debugging your program\n\
8035 after a fork or vfork is caught.\n\n\
8036 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
8038 add_com ("tcatch", class_breakpoint
, tcatch_command
,
8039 "Set temporary catchpoints to catch events.\n\
8040 Args like \"catch\" command.\n\
8041 Like \"catch\" except the catchpoint is only temporary,\n\
8042 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
8043 by using \"enable delete\" on the catchpoint number.");
8045 add_com ("watch", class_breakpoint
, watch_command
,
8046 "Set a watchpoint for an expression.\n\
8047 A watchpoint stops execution of your program whenever the value of\n\
8048 an expression changes.");
8050 add_com ("rwatch", class_breakpoint
, rwatch_command
,
8051 "Set a read watchpoint for an expression.\n\
8052 A watchpoint stops execution of your program whenever the value of\n\
8053 an expression is read.");
8055 add_com ("awatch", class_breakpoint
, awatch_command
,
8056 "Set a watchpoint for an expression.\n\
8057 A watchpoint stops execution of your program whenever the value of\n\
8058 an expression is either read or written.");
8060 add_info ("watchpoints", breakpoints_info
,
8061 "Synonym for ``info breakpoints''.");
8064 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
8065 (char *) &can_use_hw_watchpoints
,
8066 "Set debugger's willingness to use watchpoint hardware.\n\
8067 If zero, gdb will not use hardware for new watchpoints, even if\n\
8068 such is available. (However, any hardware watchpoints that were\n\
8069 created before setting this to nonzero, will continue to use watchpoint\n\
8072 add_show_from_set (c
, &showlist
);
8074 can_use_hw_watchpoints
= 1;