1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "breakpoint.h"
28 #include "expression.h"
34 #include "gdbthread.h"
37 #include "gdb_string.h"
43 #include "gdb-events.h"
45 /* Prototypes for local functions. */
47 static void until_break_command_continuation (struct continuation_arg
*arg
);
50 catch_command_1
PARAMS ((char *, int, int));
53 enable_delete_command
PARAMS ((char *, int));
56 enable_delete_breakpoint
PARAMS ((struct breakpoint
*));
59 enable_once_command
PARAMS ((char *, int));
62 enable_once_breakpoint
PARAMS ((struct breakpoint
*));
65 disable_command
PARAMS ((char *, int));
68 enable_command
PARAMS ((char *, int));
71 map_breakpoint_numbers
PARAMS ((char *, void (*)(struct breakpoint
*)));
74 ignore_command
PARAMS ((char *, int));
76 static int breakpoint_re_set_one
PARAMS ((PTR
));
79 clear_command
PARAMS ((char *, int));
82 catch_command
PARAMS ((char *, int));
85 handle_gnu_4_16_catch_command
PARAMS ((char *, int, int));
87 static struct symtabs_and_lines
88 get_catch_sals
PARAMS ((int));
91 watch_command
PARAMS ((char *, int));
94 can_use_hardware_watchpoint
PARAMS ((struct value
*));
96 static void break_at_finish_command
PARAMS ((char *, int));
97 static void break_at_finish_at_depth_command
PARAMS ((char *, int));
100 tbreak_command
PARAMS ((char *, int));
102 static void tbreak_at_finish_command
PARAMS ((char *, int));
105 break_command_1
PARAMS ((char *, int, int));
108 mention
PARAMS ((struct breakpoint
*));
111 set_raw_breakpoint
PARAMS ((struct symtab_and_line
));
114 check_duplicates
PARAMS ((CORE_ADDR
, asection
*));
117 describe_other_breakpoints
PARAMS ((CORE_ADDR
, asection
*));
120 breakpoints_info
PARAMS ((char *, int));
123 breakpoint_1
PARAMS ((int, int));
126 bpstat_alloc
PARAMS ((struct breakpoint
*, bpstat
));
128 static int breakpoint_cond_eval
PARAMS ((PTR
));
131 cleanup_executing_breakpoints
PARAMS ((PTR
));
134 commands_command
PARAMS ((char *, int));
137 condition_command
PARAMS ((char *, int));
140 get_number_trailer
PARAMS ((char **, int));
143 set_breakpoint_count
PARAMS ((int));
146 static struct breakpoint
*
147 create_temp_exception_breakpoint
PARAMS ((CORE_ADDR
));
158 remove_breakpoint
PARAMS ((struct breakpoint
*, insertion_state_t
));
160 static enum print_stop_action print_it_typical
PARAMS ((bpstat
));
162 static enum print_stop_action
print_bp_stop_message (bpstat bs
);
166 enum exception_event_kind kind
;
169 args_for_catchpoint_enable
;
171 static int watchpoint_check
PARAMS ((PTR
));
173 static int cover_target_enable_exception_callback
PARAMS ((PTR
));
175 static void maintenance_info_breakpoints
PARAMS ((char *, int));
177 #ifdef GET_LONGJMP_TARGET
178 static void create_longjmp_breakpoint
PARAMS ((char *));
181 static int hw_breakpoint_used_count
PARAMS ((void));
183 static int hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
185 static void hbreak_command
PARAMS ((char *, int));
187 static void thbreak_command
PARAMS ((char *, int));
189 static void watch_command_1
PARAMS ((char *, int, int));
191 static void rwatch_command
PARAMS ((char *, int));
193 static void awatch_command
PARAMS ((char *, int));
195 static void do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
197 static void solib_load_unload_1
PARAMS ((char *hookname
,
201 enum bptype bp_kind
));
203 static void create_fork_vfork_event_catchpoint
PARAMS ((int tempflag
,
205 enum bptype bp_kind
));
207 static void break_at_finish_at_depth_command_1
PARAMS ((char *arg
,
211 static void break_at_finish_command_1
PARAMS ((char *arg
,
215 static void stop_command
PARAMS ((char *arg
, int from_tty
));
217 static void stopin_command
PARAMS ((char *arg
, int from_tty
));
219 static void stopat_command
PARAMS ((char *arg
, int from_tty
));
221 static char *ep_find_event_name_end
PARAMS ((char *arg
));
223 static char *ep_parse_optional_if_clause
PARAMS ((char **arg
));
225 static char *ep_parse_optional_filename
PARAMS ((char **arg
));
227 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
228 static void catch_exec_command_1
PARAMS ((char *arg
, int tempflag
,
232 static void create_exception_catchpoint
233 PARAMS ((int tempflag
, char *cond_string
,
234 enum exception_event_kind ex_event
,
235 struct symtab_and_line
* sal
));
237 static void catch_exception_command_1
238 PARAMS ((enum exception_event_kind ex_event
,
239 char *arg
, int tempflag
, int from_tty
));
241 static void tcatch_command
PARAMS ((char *arg
, int from_tty
));
243 static void ep_skip_leading_whitespace
PARAMS ((char **s
));
245 /* Prototypes for exported functions. */
248 awatch_command
PARAMS ((char *, int));
251 do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
253 /* If FALSE, gdb will not use hardware support for watchpoints, even
254 if such is available. */
255 static int can_use_hw_watchpoints
;
257 void _initialize_breakpoint
PARAMS ((void));
259 void set_breakpoint_count
PARAMS ((int));
261 extern int addressprint
; /* Print machine addresses? */
263 static int internal_breakpoint_number
= -1;
265 /* Are we executing breakpoint commands? */
266 static int executing_breakpoint_commands
;
268 /* Walk the following statement or block through all breakpoints.
269 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
272 #define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
274 #define ALL_BREAKPOINTS_SAFE(B,TMP) \
275 for (B = breakpoint_chain; \
276 B ? (TMP=B->next, 1): 0; \
279 /* True if SHIFT_INST_REGS defined, false otherwise. */
281 int must_shift_inst_regs
=
282 #if defined(SHIFT_INST_REGS)
289 /* True if breakpoint hit counts should be displayed in breakpoint info. */
291 int show_breakpoint_hit_counts
= 1;
293 /* Chain of all breakpoints defined. */
295 struct breakpoint
*breakpoint_chain
;
297 /* Number of last breakpoint made. */
299 int breakpoint_count
;
301 /* Pointer to current exception event record */
302 static struct exception_event_record
*current_exception_event
;
304 /* Indicator of whether exception catchpoints should be nuked
305 between runs of a program */
306 int exception_catchpoints_are_fragile
= 0;
308 /* Indicator of when exception catchpoints set-up should be
309 reinitialized -- e.g. when program is re-run */
310 int exception_support_initialized
= 0;
312 /* This function returns a pointer to the string representation of the
313 pathname of the dynamically-linked library that has just been
316 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
317 or undefined results are guaranteed.
319 This string's contents are only valid immediately after the
320 inferior has stopped in the dynamic linker hook, and becomes
321 invalid as soon as the inferior is continued. Clients should make
322 a copy of this string if they wish to continue the inferior and
323 then access the string. */
325 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
326 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
329 /* This function returns a pointer to the string representation of the
330 pathname of the dynamically-linked library that has just been
333 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
334 TRUE, or undefined results are guaranteed.
336 This string's contents are only valid immediately after the
337 inferior has stopped in the dynamic linker hook, and becomes
338 invalid as soon as the inferior is continued. Clients should make
339 a copy of this string if they wish to continue the inferior and
340 then access the string. */
342 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
343 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
346 /* This function is called by the "catch load" command. It allows the
347 debugger to be notified by the dynamic linker when a specified
348 library file (or any library file, if filename is NULL) is loaded. */
350 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
351 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
352 error ("catch of library loads not yet implemented on this platform")
355 /* This function is called by the "catch unload" command. It allows
356 the debugger to be notified by the dynamic linker when a specified
357 library file (or any library file, if filename is NULL) is
360 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
361 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
362 error ("catch of library unloads not yet implemented on this platform")
365 /* Set breakpoint count to NUM. */
368 set_breakpoint_count (num
)
371 breakpoint_count
= num
;
372 set_internalvar (lookup_internalvar ("bpnum"),
373 value_from_longest (builtin_type_int
, (LONGEST
) num
));
376 /* Used in run_command to zero the hit count when a new run starts. */
379 clear_breakpoint_hit_counts ()
381 struct breakpoint
*b
;
387 /* Default address, symtab and line to put a breakpoint at
388 for "break" command with no arg.
389 if default_breakpoint_valid is zero, the other three are
390 not valid, and "break" with no arg is an error.
392 This set by print_stack_frame, which calls set_default_breakpoint. */
394 int default_breakpoint_valid
;
395 CORE_ADDR default_breakpoint_address
;
396 struct symtab
*default_breakpoint_symtab
;
397 int default_breakpoint_line
;
399 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
400 Advance *PP after the string and any trailing whitespace.
402 Currently the string can either be a number or "$" followed by the name
403 of a convenience variable. Making it an expression wouldn't work well
404 for map_breakpoint_numbers (e.g. "4 + 5 + 6").
406 TRAILER is a character which can be found after the number; most
407 commonly this is `-'. If you don't want a trailer, use \0. */
409 get_number_trailer (pp
, trailer
)
413 int retval
= 0; /* default */
417 /* Empty line means refer to the last breakpoint. */
418 return breakpoint_count
;
421 /* Make a copy of the name, so we can null-terminate it
422 to pass to lookup_internalvar(). */
427 while (isalnum (*p
) || *p
== '_')
429 varname
= (char *) alloca (p
- start
+ 1);
430 strncpy (varname
, start
, p
- start
);
431 varname
[p
- start
] = '\0';
432 val
= value_of_internalvar (lookup_internalvar (varname
));
433 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_INT
)
434 retval
= (int) value_as_long (val
);
437 printf_filtered ("Convenience variable must have integer value.\n");
445 while (*p
>= '0' && *p
<= '9')
448 /* There is no number here. (e.g. "cond a == b"). */
450 /* Skip non-numeric token */
451 while (*p
&& !isspace((int) *p
))
453 /* Return zero, which caller must interpret as error. */
459 if (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
461 /* Trailing junk: return 0 and let caller print error msg. */
462 while (!(isspace (*p
) || *p
== '\0' || *p
== trailer
))
473 /* Like get_number_trailer, but don't allow a trailer. */
478 return get_number_trailer (pp
, '\0');
481 /* Parse a number or a range.
482 * A number will be of the form handled by get_number.
483 * A range will be of the form <number1> - <number2>, and
484 * will represent all the integers between number1 and number2,
487 * While processing a range, this fuction is called iteratively;
488 * At each call it will return the next value in the range.
490 * At the beginning of parsing a range, the char pointer PP will
491 * be advanced past <number1> and left pointing at the '-' token.
492 * Subsequent calls will not advance the pointer until the range
493 * is completed. The call that completes the range will advance
494 * pointer PP past <number2>.
498 get_number_or_range (pp
)
501 static int last_retval
, end_value
;
502 static char *end_ptr
;
503 static int in_range
= 0;
507 /* Default case: pp is pointing either to a solo number,
508 or to the first number of a range. */
509 last_retval
= get_number_trailer (pp
, '-');
514 /* This is the start of a range (<number1> - <number2>).
515 Skip the '-', parse and remember the second number,
516 and also remember the end of the final token. */
520 while (isspace ((int) *end_ptr
))
521 end_ptr
++; /* skip white space */
522 end_value
= get_number (temp
);
523 if (end_value
< last_retval
)
525 error ("inverted range");
527 else if (end_value
== last_retval
)
529 /* degenerate range (number1 == number2). Advance the
530 token pointer so that the range will be treated as a
539 error ("negative value");
542 /* pp points to the '-' that betokens a range. All
543 number-parsing has already been done. Return the next
544 integer value (one greater than the saved previous value).
545 Do not advance the token pointer 'pp' until the end of range
548 if (++last_retval
== end_value
)
550 /* End of range reached; advance token pointer. */
560 /* condition N EXP -- set break condition of breakpoint N to EXP. */
563 condition_command (arg
, from_tty
)
567 register struct breakpoint
*b
;
572 error_no_arg ("breakpoint number");
575 bnum
= get_number (&p
);
577 error ("Bad breakpoint argument: '%s'", arg
);
580 if (b
->number
== bnum
)
584 free ((PTR
) b
->cond
);
587 if (b
->cond_string
!= NULL
)
588 free ((PTR
) b
->cond_string
);
593 b
->cond_string
= NULL
;
595 printf_filtered ("Breakpoint %d now unconditional.\n", bnum
);
600 /* I don't know if it matters whether this is the string the user
601 typed in or the decompiled expression. */
602 b
->cond_string
= savestring (arg
, strlen (arg
));
603 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->address
), 0);
605 error ("Junk at end of expression");
607 breakpoints_changed ();
611 error ("No breakpoint number %d.", bnum
);
616 commands_command (arg
, from_tty
)
620 register struct breakpoint
*b
;
623 struct command_line
*l
;
625 /* If we allowed this, we would have problems with when to
626 free the storage, if we change the commands currently
629 if (executing_breakpoint_commands
)
630 error ("Can't use the \"commands\" command among a breakpoint's commands.");
633 bnum
= get_number (&p
);
636 error ("Unexpected extra arguments following breakpoint number.");
639 if (b
->number
== bnum
)
643 "Type commands for when breakpoint %d is hit, one per line.",
645 l
= read_command_lines (tmpbuf
, from_tty
);
646 free_command_lines (&b
->commands
);
648 breakpoints_changed ();
651 error ("No breakpoint number %d.", bnum
);
654 /* Like target_read_memory() but if breakpoints are inserted, return
655 the shadow contents instead of the breakpoints themselves.
657 Read "memory data" from whatever target or inferior we have.
658 Returns zero if successful, errno value if not. EIO is used
659 for address out of bounds. If breakpoints are inserted, returns
660 shadow contents, not the breakpoints themselves. From breakpoint.c. */
663 read_memory_nobpt (memaddr
, myaddr
, len
)
669 struct breakpoint
*b
;
670 CORE_ADDR bp_addr
= 0;
673 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
674 /* No breakpoints on this machine. */
675 return target_read_memory (memaddr
, myaddr
, len
);
679 if (b
->type
== bp_none
)
680 warning ("reading through apparently deleted breakpoint #%d?",
683 /* memory breakpoint? */
684 if (b
->type
== bp_watchpoint
685 || b
->type
== bp_hardware_watchpoint
686 || b
->type
== bp_read_watchpoint
687 || b
->type
== bp_access_watchpoint
)
692 /* Addresses and length of the part of the breakpoint that
694 /* XXXX The m68k, sh and h8300 have different local and remote
695 breakpoint values. BREAKPOINT_FROM_PC still manages to
696 correctly determine the breakpoints memory address and size
697 for these targets. */
698 bp_addr
= b
->address
;
700 if (BREAKPOINT_FROM_PC (&bp_addr
, &bp_size
) == NULL
)
705 if (bp_addr
+ bp_size
<= memaddr
)
706 /* The breakpoint is entirely before the chunk of memory we
709 if (bp_addr
>= memaddr
+ len
)
710 /* The breakpoint is entirely after the chunk of memory we are
713 /* Copy the breakpoint from the shadow contents, and recurse for
714 the things before and after. */
716 /* Offset within shadow_contents. */
719 if (bp_addr
< memaddr
)
721 /* Only copy the second part of the breakpoint. */
722 bp_size
-= memaddr
- bp_addr
;
723 bptoffset
= memaddr
- bp_addr
;
727 if (bp_addr
+ bp_size
> memaddr
+ len
)
729 /* Only copy the first part of the breakpoint. */
730 bp_size
-= (bp_addr
+ bp_size
) - (memaddr
+ len
);
733 memcpy (myaddr
+ bp_addr
- memaddr
,
734 b
->shadow_contents
+ bptoffset
, bp_size
);
736 if (bp_addr
> memaddr
)
738 /* Copy the section of memory before the breakpoint. */
739 status
= read_memory_nobpt (memaddr
, myaddr
, bp_addr
- memaddr
);
744 if (bp_addr
+ bp_size
< memaddr
+ len
)
746 /* Copy the section of memory after the breakpoint. */
747 status
= read_memory_nobpt
749 myaddr
+ bp_addr
+ bp_size
- memaddr
,
750 memaddr
+ len
- (bp_addr
+ bp_size
));
757 /* Nothing overlaps. Just call read_memory_noerr. */
758 return target_read_memory (memaddr
, myaddr
, len
);
762 /* insert_breakpoints is used when starting or continuing the program.
763 remove_breakpoints is used when the program stops.
764 Both return zero if successful,
765 or an `errno' value if could not write the inferior. */
768 insert_breakpoints ()
770 register struct breakpoint
*b
, *temp
;
771 int return_val
= 0; /* return success code. */
773 int disabled_breaks
= 0;
775 static char message1
[] = "Error inserting catchpoint %d:\n";
776 static char message
[sizeof (message1
) + 30];
779 ALL_BREAKPOINTS_SAFE (b
, temp
)
781 if (b
->enable
== permanent
)
782 /* Permanent breakpoints cannot be inserted or removed. */
784 else if (b
->type
!= bp_watchpoint
785 && b
->type
!= bp_hardware_watchpoint
786 && b
->type
!= bp_read_watchpoint
787 && b
->type
!= bp_access_watchpoint
788 && b
->type
!= bp_catch_fork
789 && b
->type
!= bp_catch_vfork
790 && b
->type
!= bp_catch_exec
791 && b
->type
!= bp_catch_throw
792 && b
->type
!= bp_catch_catch
793 && b
->enable
!= disabled
794 && b
->enable
!= shlib_disabled
795 && b
->enable
!= call_disabled
799 if (b
->type
== bp_hardware_breakpoint
)
800 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
803 /* Check to see if breakpoint is in an overlay section;
804 if so, we should set the breakpoint at the LMA address.
805 Only if the section is currently mapped should we ALSO
806 set a break at the VMA address. */
807 if (overlay_debugging
&& b
->section
&&
808 section_is_overlay (b
->section
))
812 addr
= overlay_unmapped_address (b
->address
, b
->section
);
813 val
= target_insert_breakpoint (addr
, b
->shadow_contents
);
814 /* This would be the time to check val, to see if the
815 breakpoint write to the load address succeeded.
816 However, this might be an ordinary occurrance, eg. if
817 the unmapped overlay is in ROM. */
818 val
= 0; /* in case unmapped address failed */
819 if (section_is_mapped (b
->section
))
820 val
= target_insert_breakpoint (b
->address
,
823 else /* ordinary (non-overlay) address */
824 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
828 /* Can't set the breakpoint. */
829 #if defined (DISABLE_UNSETTABLE_BREAK)
830 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
832 /* See also: disable_breakpoints_in_shlibs. */
834 b
->enable
= shlib_disabled
;
835 if (!disabled_breaks
)
837 target_terminal_ours_for_output ();
838 warning ("Cannot insert breakpoint %d:", b
->number
);
839 warning ("Temporarily disabling shared library breakpoints:");
842 warning ("breakpoint #%d ", b
->number
);
847 target_terminal_ours_for_output ();
848 warning ("Cannot insert breakpoint %d:", b
->number
);
849 #ifdef ONE_PROCESS_WRITETEXT
850 warning ("The same program may be running in another process.");
852 memory_error (val
, b
->address
); /* which bombs us out */
859 return_val
= val
; /* remember failure */
861 else if (ep_is_exception_catchpoint (b
)
862 && b
->enable
!= disabled
863 && b
->enable
!= shlib_disabled
864 && b
->enable
!= call_disabled
869 /* If we get here, we must have a callback mechanism for exception
870 events -- with g++ style embedded label support, we insert
871 ordinary breakpoints and not catchpoints. */
872 /* Format possible error message */
873 sprintf (message
, message1
, b
->number
);
875 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
878 /* Couldn't set breakpoint for some reason */
879 target_terminal_ours_for_output ();
880 warning ("Cannot insert catchpoint %d; disabling it.",
882 b
->enable
= disabled
;
886 /* Bp set, now make sure callbacks are enabled */
888 args_for_catchpoint_enable args
;
889 args
.kind
= b
->type
== bp_catch_catch
?
890 EX_EVENT_CATCH
: EX_EVENT_THROW
;
892 val
= catch_errors (cover_target_enable_exception_callback
,
894 message
, RETURN_MASK_ALL
);
895 if (val
!= 0 && val
!= -1)
899 /* Check if something went wrong; val == 0 can be ignored */
902 /* something went wrong */
903 target_terminal_ours_for_output ();
904 warning ("Cannot insert catchpoint %d; disabling it.",
906 b
->enable
= disabled
;
911 return_val
= val
; /* remember failure */
914 else if ((b
->type
== bp_hardware_watchpoint
||
915 b
->type
== bp_read_watchpoint
||
916 b
->type
== bp_access_watchpoint
)
917 && b
->enable
== enabled
921 struct frame_info
*saved_frame
;
922 int saved_level
, within_current_scope
;
923 value_ptr mark
= value_mark ();
926 /* Save the current frame and level so we can restore it after
927 evaluating the watchpoint expression on its own frame. */
928 saved_frame
= selected_frame
;
929 saved_level
= selected_frame_level
;
931 /* Determine if the watchpoint is within scope. */
932 if (b
->exp_valid_block
== NULL
)
933 within_current_scope
= 1;
936 struct frame_info
*fi
;
938 /* There might be no current frame at this moment if we are
939 resuming from a step over a breakpoint.
940 Set up current frame before trying to find the watchpoint
942 get_current_frame ();
943 fi
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
944 within_current_scope
= (fi
!= NULL
);
945 if (within_current_scope
)
946 select_frame (fi
, -1);
949 if (within_current_scope
)
951 /* Evaluate the expression and cut the chain of values
952 produced off from the value chain.
954 Make sure the value returned isn't lazy; we use
955 laziness to determine what memory GDB actually needed
956 in order to compute the value of the expression. */
957 v
= evaluate_expression (b
->exp
);
959 value_release_to_mark (mark
);
964 /* Look at each value on the value chain. */
965 for (; v
; v
= v
->next
)
967 /* If it's a memory location, and GDB actually needed
968 its contents to evaluate the expression, then we
970 if (VALUE_LVAL (v
) == lval_memory
976 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
977 len
= TYPE_LENGTH (VALUE_TYPE (v
));
979 if (b
->type
== bp_read_watchpoint
)
981 else if (b
->type
== bp_access_watchpoint
)
984 val
= target_insert_watchpoint (addr
, len
, type
);
993 /* Failure to insert a watchpoint on any memory value in the
994 value chain brings us here. */
997 remove_breakpoint (b
, mark_uninserted
);
998 warning ("Could not insert hardware watchpoint %d.",
1005 printf_filtered ("Hardware watchpoint %d deleted", b
->number
);
1006 printf_filtered ("because the program has left the block \n");
1007 printf_filtered ("in which its expression is valid.\n");
1008 if (b
->related_breakpoint
)
1009 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1010 b
->disposition
= del_at_next_stop
;
1013 /* Restore the frame and level. */
1014 if ((saved_frame
!= selected_frame
) ||
1015 (saved_level
!= selected_frame_level
))
1016 select_and_print_frame (saved_frame
, saved_level
);
1019 return_val
= val
; /* remember failure */
1021 else if ((b
->type
== bp_catch_fork
1022 || b
->type
== bp_catch_vfork
1023 || b
->type
== bp_catch_exec
)
1024 && b
->enable
== enabled
1032 val
= target_insert_fork_catchpoint (inferior_pid
);
1034 case bp_catch_vfork
:
1035 val
= target_insert_vfork_catchpoint (inferior_pid
);
1038 val
= target_insert_exec_catchpoint (inferior_pid
);
1041 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1046 target_terminal_ours_for_output ();
1047 warning ("Cannot insert catchpoint %d.", b
->number
);
1053 return_val
= val
; /* remember failure */
1062 remove_breakpoints ()
1064 register struct breakpoint
*b
;
1071 val
= remove_breakpoint (b
, mark_uninserted
);
1080 reattach_breakpoints (pid
)
1083 register struct breakpoint
*b
;
1085 int saved_inferior_pid
= inferior_pid
;
1087 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1088 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1093 remove_breakpoint (b
, mark_inserted
);
1094 if (b
->type
== bp_hardware_breakpoint
)
1095 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
1097 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
1100 inferior_pid
= saved_inferior_pid
;
1105 inferior_pid
= saved_inferior_pid
;
1110 update_breakpoints_after_exec ()
1112 struct breakpoint
*b
;
1113 struct breakpoint
*temp
;
1115 /* Doing this first prevents the badness of having delete_breakpoint()
1116 write a breakpoint's current "shadow contents" to lift the bp. That
1117 shadow is NOT valid after an exec()! */
1118 mark_breakpoints_out ();
1120 ALL_BREAKPOINTS_SAFE (b
, temp
)
1122 /* Solib breakpoints must be explicitly reset after an exec(). */
1123 if (b
->type
== bp_shlib_event
)
1125 delete_breakpoint (b
);
1129 /* Thread event breakpoints must be set anew after an exec(). */
1130 if (b
->type
== bp_thread_event
)
1132 delete_breakpoint (b
);
1136 /* Step-resume breakpoints are meaningless after an exec(). */
1137 if (b
->type
== bp_step_resume
)
1139 delete_breakpoint (b
);
1143 /* Ditto the sigtramp handler breakpoints. */
1144 if (b
->type
== bp_through_sigtramp
)
1146 delete_breakpoint (b
);
1150 /* Ditto the exception-handling catchpoints. */
1151 if ((b
->type
== bp_catch_catch
) || (b
->type
== bp_catch_throw
))
1153 delete_breakpoint (b
);
1157 /* Don't delete an exec catchpoint, because else the inferior
1158 won't stop when it ought!
1160 Similarly, we probably ought to keep vfork catchpoints, 'cause
1161 on this target, we may not be able to stop when the vfork is
1162 seen, but only when the subsequent exec is seen. (And because
1163 deleting fork catchpoints here but not vfork catchpoints will
1164 seem mysterious to users, keep those too.)
1166 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1167 target address field, if any, is sufficient to have it be reset
1168 automagically. Certainly on HP-UX that's true. */
1169 if ((b
->type
== bp_catch_exec
) ||
1170 (b
->type
== bp_catch_vfork
) ||
1171 (b
->type
== bp_catch_fork
))
1173 b
->address
= (CORE_ADDR
) NULL
;
1177 /* bp_finish is a special case. The only way we ought to be able
1178 to see one of these when an exec() has happened, is if the user
1179 caught a vfork, and then said "finish". Ordinarily a finish just
1180 carries them to the call-site of the current callee, by setting
1181 a temporary bp there and resuming. But in this case, the finish
1182 will carry them entirely through the vfork & exec.
1184 We don't want to allow a bp_finish to remain inserted now. But
1185 we can't safely delete it, 'cause finish_command has a handle to
1186 the bp on a bpstat, and will later want to delete it. There's a
1187 chance (and I've seen it happen) that if we delete the bp_finish
1188 here, that its storage will get reused by the time finish_command
1189 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1190 We really must allow finish_command to delete a bp_finish.
1192 In the absense of a general solution for the "how do we know
1193 it's safe to delete something others may have handles to?"
1194 problem, what we'll do here is just uninsert the bp_finish, and
1195 let finish_command delete it.
1197 (We know the bp_finish is "doomed" in the sense that it's
1198 momentary, and will be deleted as soon as finish_command sees
1199 the inferior stopped. So it doesn't matter that the bp's
1200 address is probably bogus in the new a.out, unlike e.g., the
1201 solib breakpoints.) */
1203 if (b
->type
== bp_finish
)
1208 /* Without a symbolic address, we have little hope of the
1209 pre-exec() address meaning the same thing in the post-exec()
1211 if (b
->addr_string
== NULL
)
1213 delete_breakpoint (b
);
1217 /* If this breakpoint has survived the above battery of checks, then
1218 it must have a symbolic address. Be sure that it gets reevaluated
1219 to a target address, rather than reusing the old evaluation. */
1220 b
->address
= (CORE_ADDR
) NULL
;
1225 detach_breakpoints (pid
)
1228 register struct breakpoint
*b
;
1230 int saved_inferior_pid
= inferior_pid
;
1232 if (pid
== inferior_pid
)
1233 error ("Cannot detach breakpoints of inferior_pid");
1235 /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
1236 inferior_pid
= pid
; /* Because remove_breakpoint will use this global. */
1241 val
= remove_breakpoint (b
, mark_inserted
);
1244 inferior_pid
= saved_inferior_pid
;
1249 inferior_pid
= saved_inferior_pid
;
1254 remove_breakpoint (b
, is
)
1255 struct breakpoint
*b
;
1256 insertion_state_t is
;
1260 if (b
->enable
== permanent
)
1261 /* Permanent breakpoints cannot be inserted or removed. */
1264 if (b
->type
== bp_none
)
1265 warning ("attempted to remove apparently deleted breakpoint #%d?",
1268 if (b
->type
!= bp_watchpoint
1269 && b
->type
!= bp_hardware_watchpoint
1270 && b
->type
!= bp_read_watchpoint
1271 && b
->type
!= bp_access_watchpoint
1272 && b
->type
!= bp_catch_fork
1273 && b
->type
!= bp_catch_vfork
1274 && b
->type
!= bp_catch_exec
1275 && b
->type
!= bp_catch_catch
1276 && b
->type
!= bp_catch_throw
)
1278 if (b
->type
== bp_hardware_breakpoint
)
1279 val
= target_remove_hw_breakpoint (b
->address
, b
->shadow_contents
);
1282 /* Check to see if breakpoint is in an overlay section;
1283 if so, we should remove the breakpoint at the LMA address.
1284 If that is not equal to the raw address, then we should
1285 presumable remove the breakpoint there as well. */
1286 if (overlay_debugging
&& b
->section
&&
1287 section_is_overlay (b
->section
))
1291 addr
= overlay_unmapped_address (b
->address
, b
->section
);
1292 val
= target_remove_breakpoint (addr
, b
->shadow_contents
);
1293 /* This would be the time to check val, to see if the
1294 shadow breakpoint write to the load address succeeded.
1295 However, this might be an ordinary occurrance, eg. if
1296 the unmapped overlay is in ROM. */
1297 val
= 0; /* in case unmapped address failed */
1298 if (section_is_mapped (b
->section
))
1299 val
= target_remove_breakpoint (b
->address
,
1300 b
->shadow_contents
);
1302 else /* ordinary (non-overlay) address */
1303 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1307 b
->inserted
= (is
== mark_inserted
);
1309 else if ((b
->type
== bp_hardware_watchpoint
||
1310 b
->type
== bp_read_watchpoint
||
1311 b
->type
== bp_access_watchpoint
)
1312 && b
->enable
== enabled
1317 b
->inserted
= (is
== mark_inserted
);
1318 /* Walk down the saved value chain. */
1319 for (v
= b
->val_chain
; v
; v
= v
->next
)
1321 /* For each memory reference remove the watchpoint
1323 if (VALUE_LVAL (v
) == lval_memory
1324 && ! VALUE_LAZY (v
))
1329 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1330 len
= TYPE_LENGTH (VALUE_TYPE (v
));
1332 if (b
->type
== bp_read_watchpoint
)
1334 else if (b
->type
== bp_access_watchpoint
)
1337 val
= target_remove_watchpoint (addr
, len
, type
);
1343 /* Failure to remove any of the hardware watchpoints comes here. */
1344 if ((is
== mark_uninserted
) && (b
->inserted
))
1345 warning ("Could not remove hardware watchpoint %d.",
1348 /* Free the saved value chain. We will construct a new one
1349 the next time the watchpoint is inserted. */
1350 for (v
= b
->val_chain
; v
; v
= n
)
1355 b
->val_chain
= NULL
;
1357 else if ((b
->type
== bp_catch_fork
||
1358 b
->type
== bp_catch_vfork
||
1359 b
->type
== bp_catch_exec
)
1360 && b
->enable
== enabled
1367 val
= target_remove_fork_catchpoint (inferior_pid
);
1369 case bp_catch_vfork
:
1370 val
= target_remove_vfork_catchpoint (inferior_pid
);
1373 val
= target_remove_exec_catchpoint (inferior_pid
);
1376 warning ("Internal error, %s line %d.", __FILE__
, __LINE__
);
1381 b
->inserted
= (is
== mark_inserted
);
1383 else if ((b
->type
== bp_catch_catch
||
1384 b
->type
== bp_catch_throw
)
1385 && b
->enable
== enabled
1389 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1392 b
->inserted
= (is
== mark_inserted
);
1394 else if (ep_is_exception_catchpoint (b
)
1395 && b
->inserted
/* sometimes previous insert doesn't happen */
1396 && b
->enable
== enabled
1400 val
= target_remove_breakpoint (b
->address
, b
->shadow_contents
);
1404 b
->inserted
= (is
== mark_inserted
);
1410 /* Clear the "inserted" flag in all breakpoints. */
1413 mark_breakpoints_out ()
1415 register struct breakpoint
*b
;
1421 /* Clear the "inserted" flag in all breakpoints and delete any
1422 breakpoints which should go away between runs of the program.
1424 Plus other such housekeeping that has to be done for breakpoints
1427 Note: this function gets called at the end of a run (by
1428 generic_mourn_inferior) and when a run begins (by
1429 init_wait_for_inferior). */
1434 breakpoint_init_inferior (context
)
1435 enum inf_context context
;
1437 register struct breakpoint
*b
, *temp
;
1438 static int warning_needed
= 0;
1440 ALL_BREAKPOINTS_SAFE (b
, temp
)
1447 case bp_watchpoint_scope
:
1449 /* If the call dummy breakpoint is at the entry point it will
1450 cause problems when the inferior is rerun, so we better
1453 Also get rid of scope breakpoints. */
1454 delete_breakpoint (b
);
1458 case bp_hardware_watchpoint
:
1459 case bp_read_watchpoint
:
1460 case bp_access_watchpoint
:
1462 /* Likewise for watchpoints on local expressions. */
1463 if (b
->exp_valid_block
!= NULL
)
1464 delete_breakpoint (b
);
1467 /* Likewise for exception catchpoints in dynamic-linked
1468 executables where required */
1469 if (ep_is_exception_catchpoint (b
) &&
1470 exception_catchpoints_are_fragile
)
1473 delete_breakpoint (b
);
1479 if (exception_catchpoints_are_fragile
)
1480 exception_support_initialized
= 0;
1482 /* Don't issue the warning unless it's really needed... */
1483 if (warning_needed
&& (context
!= inf_exited
))
1485 warning ("Exception catchpoints from last run were deleted.");
1486 warning ("You must reinsert them explicitly.");
1491 /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
1492 exists at PC. It returns ordinary_breakpoint_here if it's an
1493 ordinary breakpoint, or permanent_breakpoint_here if it's a
1494 permanent breakpoint.
1495 - When continuing from a location with an ordinary breakpoint, we
1496 actually single step once before calling insert_breakpoints.
1497 - When continuing from a localion with a permanent breakpoint, we
1498 need to use the `SKIP_PERMANENT_BREAKPOINT' macro, provided by
1499 the target, to advance the PC past the breakpoint. */
1501 enum breakpoint_here
1502 breakpoint_here_p (pc
)
1505 register struct breakpoint
*b
;
1506 int any_breakpoint_here
= 0;
1509 if ((b
->enable
== enabled
1510 || b
->enable
== permanent
)
1511 && b
->address
== pc
) /* bp is enabled and matches pc */
1513 if (overlay_debugging
&&
1514 section_is_overlay (b
->section
) &&
1515 !section_is_mapped (b
->section
))
1516 continue; /* unmapped overlay -- can't be a match */
1517 else if (b
->enable
== permanent
)
1518 return permanent_breakpoint_here
;
1520 any_breakpoint_here
= 1;
1523 return any_breakpoint_here
? ordinary_breakpoint_here
: 0;
1527 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(),
1528 but it only returns true if there is actually a breakpoint inserted
1532 breakpoint_inserted_here_p (pc
)
1535 register struct breakpoint
*b
;
1539 && b
->address
== pc
) /* bp is inserted and matches pc */
1541 if (overlay_debugging
&&
1542 section_is_overlay (b
->section
) &&
1543 !section_is_mapped (b
->section
))
1544 continue; /* unmapped overlay -- can't be a match */
1552 /* Return nonzero if FRAME is a dummy frame. We can't use
1553 PC_IN_CALL_DUMMY because figuring out the saved SP would take too
1554 much time, at least using get_saved_register on the 68k. This
1555 means that for this function to work right a port must use the
1556 bp_call_dummy breakpoint. */
1559 frame_in_dummy (frame
)
1560 struct frame_info
*frame
;
1562 struct breakpoint
*b
;
1567 if (USE_GENERIC_DUMMY_FRAMES
)
1568 return generic_pc_in_call_dummy (frame
->pc
, frame
->frame
, frame
->frame
);
1572 if (b
->type
== bp_call_dummy
1573 && b
->frame
== frame
->frame
1574 /* We need to check the PC as well as the frame on the sparc,
1575 for signals.exp in the testsuite. */
1578 - SIZEOF_CALL_DUMMY_WORDS
/ sizeof (LONGEST
) * REGISTER_SIZE
))
1579 && frame
->pc
<= b
->address
)
1585 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1586 is valid for process/thread PID. */
1589 breakpoint_thread_match (pc
, pid
)
1593 struct breakpoint
*b
;
1596 thread
= pid_to_thread_id (pid
);
1599 if (b
->enable
!= disabled
1600 && b
->enable
!= shlib_disabled
1601 && b
->enable
!= call_disabled
1603 && (b
->thread
== -1 || b
->thread
== thread
))
1605 if (overlay_debugging
&&
1606 section_is_overlay (b
->section
) &&
1607 !section_is_mapped (b
->section
))
1608 continue; /* unmapped overlay -- can't be a match */
1617 /* bpstat stuff. External routines' interfaces are documented
1621 ep_is_catchpoint (ep
)
1622 struct breakpoint
*ep
;
1625 (ep
->type
== bp_catch_load
)
1626 || (ep
->type
== bp_catch_unload
)
1627 || (ep
->type
== bp_catch_fork
)
1628 || (ep
->type
== bp_catch_vfork
)
1629 || (ep
->type
== bp_catch_exec
)
1630 || (ep
->type
== bp_catch_catch
)
1631 || (ep
->type
== bp_catch_throw
)
1634 /* ??rehrauer: Add more kinds here, as are implemented... */
1639 ep_is_shlib_catchpoint (ep
)
1640 struct breakpoint
*ep
;
1643 (ep
->type
== bp_catch_load
)
1644 || (ep
->type
== bp_catch_unload
)
1649 ep_is_exception_catchpoint (ep
)
1650 struct breakpoint
*ep
;
1653 (ep
->type
== bp_catch_catch
)
1654 || (ep
->type
== bp_catch_throw
)
1658 /* Clear a bpstat so that it says we are not at any breakpoint.
1659 Also free any storage that is part of a bpstat. */
1674 if (p
->old_val
!= NULL
)
1675 value_free (p
->old_val
);
1682 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1683 is part of the bpstat is copied as well. */
1691 bpstat retval
= NULL
;
1696 for (; bs
!= NULL
; bs
= bs
->next
)
1698 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
1699 memcpy (tmp
, bs
, sizeof (*tmp
));
1701 /* This is the first thing in the chain. */
1711 /* Find the bpstat associated with this breakpoint */
1714 bpstat_find_breakpoint (bsp
, breakpoint
)
1716 struct breakpoint
*breakpoint
;
1721 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1723 if (bsp
->breakpoint_at
== breakpoint
)
1729 /* Find a step_resume breakpoint associated with this bpstat.
1730 (If there are multiple step_resume bp's on the list, this function
1731 will arbitrarily pick one.)
1733 It is an error to use this function if BPSTAT doesn't contain a
1734 step_resume breakpoint.
1736 See wait_for_inferior's use of this function. */
1738 bpstat_find_step_resume_breakpoint (bsp
)
1742 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1744 for (; bsp
!= NULL
; bsp
= bsp
->next
)
1746 if ((bsp
->breakpoint_at
!= NULL
) &&
1747 (bsp
->breakpoint_at
->type
== bp_step_resume
))
1748 return bsp
->breakpoint_at
;
1751 error ("Internal error (no step_resume breakpoint found)");
1755 /* Return the breakpoint number of the first breakpoint we are stopped
1756 at. *BSP upon return is a bpstat which points to the remaining
1757 breakpoints stopped at (but which is not guaranteed to be good for
1758 anything but further calls to bpstat_num).
1759 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1765 struct breakpoint
*b
;
1768 return 0; /* No more breakpoint values */
1771 b
= (*bsp
)->breakpoint_at
;
1772 *bsp
= (*bsp
)->next
;
1774 return -1; /* breakpoint that's been deleted since */
1776 return b
->number
; /* We have its number */
1780 /* Modify BS so that the actions will not be performed. */
1783 bpstat_clear_actions (bs
)
1786 for (; bs
!= NULL
; bs
= bs
->next
)
1788 bs
->commands
= NULL
;
1789 if (bs
->old_val
!= NULL
)
1791 value_free (bs
->old_val
);
1797 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1800 cleanup_executing_breakpoints (ignore
)
1803 executing_breakpoint_commands
= 0;
1806 /* Execute all the commands associated with all the breakpoints at this
1807 location. Any of these commands could cause the process to proceed
1808 beyond this point, etc. We look out for such changes by checking
1809 the global "breakpoint_proceeded" after each command. */
1812 bpstat_do_actions (bsp
)
1816 struct cleanup
*old_chain
;
1817 struct command_line
*cmd
;
1819 /* Avoid endless recursion if a `source' command is contained
1821 if (executing_breakpoint_commands
)
1824 executing_breakpoint_commands
= 1;
1825 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
1828 /* Note that (as of this writing), our callers all appear to
1829 be passing us the address of global stop_bpstat. And, if
1830 our calls to execute_control_command cause the inferior to
1831 proceed, that global (and hence, *bsp) will change.
1833 We must be careful to not touch *bsp unless the inferior
1834 has not proceeded. */
1836 /* This pointer will iterate over the list of bpstat's. */
1839 breakpoint_proceeded
= 0;
1840 for (; bs
!= NULL
; bs
= bs
->next
)
1845 execute_control_command (cmd
);
1847 if (breakpoint_proceeded
)
1852 if (breakpoint_proceeded
)
1853 /* The inferior is proceeded by the command; bomb out now.
1854 The bpstat chain has been blown away by wait_for_inferior.
1855 But since execution has stopped again, there is a new bpstat
1856 to look at, so start over. */
1859 bs
->commands
= NULL
;
1862 executing_breakpoint_commands
= 0;
1863 discard_cleanups (old_chain
);
1866 /* This is the normal print function for a bpstat. In the future,
1867 much of this logic could (should?) be moved to bpstat_stop_status,
1868 by having it set different print_it values.
1870 Current scheme: When we stop, bpstat_print() is called. It loops
1871 through the bpstat list of things causing this stop, calling the
1872 print_bp_stop_message function on each one. The behavior of the
1873 print_bp_stop_message function depends on the print_it field of
1874 bpstat. If such field so indicates, call this function here.
1876 Return values from this routine (ultimately used by bpstat_print()
1877 and normal_stop() to decide what to do):
1878 PRINT_NOTHING: Means we already printed all we needed to print,
1879 don't print anything else.
1880 PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
1881 that something to be followed by a location.
1882 PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
1883 that something to be followed by a location.
1884 PRINT_UNKNOWN: Means we printed nothing or we need to do some more
1887 static enum print_stop_action
1888 print_it_typical (bs
)
1891 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1892 which has since been deleted. */
1893 if (bs
->breakpoint_at
== NULL
)
1894 return PRINT_UNKNOWN
;
1896 switch (bs
->breakpoint_at
->type
)
1899 case bp_hardware_breakpoint
:
1900 /* I think the user probably only wants to see one breakpoint
1901 number, not all of them. */
1902 annotate_breakpoint (bs
->breakpoint_at
->number
);
1903 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1904 return PRINT_SRC_AND_LOC
;
1907 case bp_shlib_event
:
1908 /* Did we stop because the user set the stop_on_solib_events
1909 variable? (If so, we report this as a generic, "Stopped due
1910 to shlib event" message.) */
1911 printf_filtered ("Stopped due to shared library event\n");
1912 return PRINT_NOTHING
;
1915 case bp_thread_event
:
1916 /* Not sure how we will get here.
1917 GDB should not stop for these breakpoints. */
1918 printf_filtered ("Thread Event Breakpoint: gdb should not stop!\n");
1919 return PRINT_NOTHING
;
1923 annotate_catchpoint (bs
->breakpoint_at
->number
);
1924 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1925 printf_filtered ("loaded");
1926 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1927 return PRINT_SRC_AND_LOC
;
1930 case bp_catch_unload
:
1931 annotate_catchpoint (bs
->breakpoint_at
->number
);
1932 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1933 printf_filtered ("unloaded");
1934 printf_filtered (" %s), ", bs
->breakpoint_at
->triggered_dll_pathname
);
1935 return PRINT_SRC_AND_LOC
;
1939 annotate_catchpoint (bs
->breakpoint_at
->number
);
1940 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1941 printf_filtered ("forked");
1942 printf_filtered (" process %d), ",
1943 bs
->breakpoint_at
->forked_inferior_pid
);
1944 return PRINT_SRC_AND_LOC
;
1947 case bp_catch_vfork
:
1948 annotate_catchpoint (bs
->breakpoint_at
->number
);
1949 printf_filtered ("\nCatchpoint %d (", bs
->breakpoint_at
->number
);
1950 printf_filtered ("vforked");
1951 printf_filtered (" process %d), ",
1952 bs
->breakpoint_at
->forked_inferior_pid
);
1953 return PRINT_SRC_AND_LOC
;
1957 annotate_catchpoint (bs
->breakpoint_at
->number
);
1958 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1959 bs
->breakpoint_at
->number
,
1960 bs
->breakpoint_at
->exec_pathname
);
1961 return PRINT_SRC_AND_LOC
;
1964 case bp_catch_catch
:
1965 if (current_exception_event
&&
1966 (CURRENT_EXCEPTION_KIND
== EX_EVENT_CATCH
))
1968 annotate_catchpoint (bs
->breakpoint_at
->number
);
1969 printf_filtered ("\nCatchpoint %d (exception caught), ",
1970 bs
->breakpoint_at
->number
);
1971 printf_filtered ("throw location ");
1972 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
1973 printf_filtered ("%s:%d",
1974 CURRENT_EXCEPTION_THROW_FILE
,
1975 CURRENT_EXCEPTION_THROW_LINE
);
1977 printf_filtered ("unknown");
1979 printf_filtered (", catch location ");
1980 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
1981 printf_filtered ("%s:%d",
1982 CURRENT_EXCEPTION_CATCH_FILE
,
1983 CURRENT_EXCEPTION_CATCH_LINE
);
1985 printf_filtered ("unknown");
1987 printf_filtered ("\n");
1988 /* don't bother to print location frame info */
1989 return PRINT_SRC_ONLY
;
1993 /* really throw, some other bpstat will handle it */
1994 return PRINT_UNKNOWN
;
1998 case bp_catch_throw
:
1999 if (current_exception_event
&&
2000 (CURRENT_EXCEPTION_KIND
== EX_EVENT_THROW
))
2002 annotate_catchpoint (bs
->breakpoint_at
->number
);
2003 printf_filtered ("\nCatchpoint %d (exception thrown), ",
2004 bs
->breakpoint_at
->number
);
2005 printf_filtered ("throw location ");
2006 if (CURRENT_EXCEPTION_THROW_PC
&& CURRENT_EXCEPTION_THROW_LINE
)
2007 printf_filtered ("%s:%d",
2008 CURRENT_EXCEPTION_THROW_FILE
,
2009 CURRENT_EXCEPTION_THROW_LINE
);
2011 printf_filtered ("unknown");
2013 printf_filtered (", catch location ");
2014 if (CURRENT_EXCEPTION_CATCH_PC
&& CURRENT_EXCEPTION_CATCH_LINE
)
2015 printf_filtered ("%s:%d",
2016 CURRENT_EXCEPTION_CATCH_FILE
,
2017 CURRENT_EXCEPTION_CATCH_LINE
);
2019 printf_filtered ("unknown");
2021 printf_filtered ("\n");
2022 /* don't bother to print location frame info */
2023 return PRINT_SRC_ONLY
;
2027 /* really catch, some other bpstat will handle it */
2028 return PRINT_UNKNOWN
;
2033 case bp_hardware_watchpoint
:
2034 if (bs
->old_val
!= NULL
)
2036 annotate_watchpoint (bs
->breakpoint_at
->number
);
2037 mention (bs
->breakpoint_at
);
2038 printf_filtered ("\nOld value = ");
2039 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2040 printf_filtered ("\nNew value = ");
2041 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2042 Val_pretty_default
);
2043 printf_filtered ("\n");
2044 value_free (bs
->old_val
);
2047 /* More than one watchpoint may have been triggered. */
2048 return PRINT_UNKNOWN
;
2051 case bp_read_watchpoint
:
2052 mention (bs
->breakpoint_at
);
2053 printf_filtered ("\nValue = ");
2054 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2055 Val_pretty_default
);
2056 printf_filtered ("\n");
2057 return PRINT_UNKNOWN
;
2060 case bp_access_watchpoint
:
2061 if (bs
->old_val
!= NULL
)
2063 annotate_watchpoint (bs
->breakpoint_at
->number
);
2064 mention (bs
->breakpoint_at
);
2065 printf_filtered ("\nOld value = ");
2066 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
2067 value_free (bs
->old_val
);
2069 printf_filtered ("\nNew value = ");
2073 mention (bs
->breakpoint_at
);
2074 printf_filtered ("\nValue = ");
2076 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
2077 Val_pretty_default
);
2078 printf_filtered ("\n");
2079 return PRINT_UNKNOWN
;
2082 /* Fall through, we don't deal with these types of breakpoints
2089 case bp_longjmp_resume
:
2090 case bp_step_resume
:
2091 case bp_through_sigtramp
:
2092 case bp_watchpoint_scope
:
2095 return PRINT_UNKNOWN
;
2099 /* Generic routine for printing messages indicating why we
2100 stopped. The behavior of this function depends on the value
2101 'print_it' in the bpstat structure. Under some circumstances we
2102 may decide not to print anything here and delegate the task to
2105 static enum print_stop_action
2106 print_bp_stop_message (bpstat bs
)
2108 switch (bs
->print_it
)
2111 /* Nothing should be printed for this bpstat entry. */
2112 return PRINT_UNKNOWN
;
2116 /* We still want to print the frame, but we already printed the
2117 relevant messages. */
2118 return PRINT_SRC_AND_LOC
;
2121 case print_it_normal
:
2122 /* Normal case, we handle everything in print_it_typical. */
2123 return print_it_typical (bs
);
2126 internal_error ("print_bp_stop_message: unrecognized enum value");
2131 /* Print a message indicating what happened. This is called from
2132 normal_stop(). The input to this routine is the head of the bpstat
2133 list - a list of the eventpoints that caused this stop. This
2134 routine calls the generic print routine for printing a message
2135 about reasons for stopping. This will print (for example) the
2136 "Breakpoint n," part of the output. The return value of this
2139 PRINT_UNKNOWN: Means we printed nothing
2140 PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
2141 code to print the location. An example is
2142 "Breakpoint 1, " which should be followed by
2144 PRINT_SRC_ONLY: Means we printed something, but there is no need
2145 to also print the location part of the message.
2146 An example is the catch/throw messages, which
2147 don't require a location appended to the end.
2148 PRINT_NOTHING: We have done some printing and we don't need any
2149 further info to be printed.*/
2151 enum print_stop_action
2157 /* Maybe another breakpoint in the chain caused us to stop.
2158 (Currently all watchpoints go on the bpstat whether hit or not.
2159 That probably could (should) be changed, provided care is taken
2160 with respect to bpstat_explains_signal). */
2161 for (; bs
; bs
= bs
->next
)
2163 val
= print_bp_stop_message (bs
);
2164 if (val
== PRINT_SRC_ONLY
2165 || val
== PRINT_SRC_AND_LOC
2166 || val
== PRINT_NOTHING
)
2170 /* We reached the end of the chain, or we got a null BS to start
2171 with and nothing was printed. */
2172 return PRINT_UNKNOWN
;
2175 /* Evaluate the expression EXP and return 1 if value is zero.
2176 This is used inside a catch_errors to evaluate the breakpoint condition.
2177 The argument is a "struct expression *" that has been cast to char * to
2178 make it pass through catch_errors. */
2181 breakpoint_cond_eval (exp
)
2184 value_ptr mark
= value_mark ();
2185 int i
= !value_true (evaluate_expression ((struct expression
*) exp
));
2186 value_free_to_mark (mark
);
2190 /* Allocate a new bpstat and chain it to the current one. */
2193 bpstat_alloc (b
, cbs
)
2194 register struct breakpoint
*b
;
2195 bpstat cbs
; /* Current "bs" value */
2199 bs
= (bpstat
) xmalloc (sizeof (*bs
));
2201 bs
->breakpoint_at
= b
;
2202 /* If the condition is false, etc., don't do the commands. */
2203 bs
->commands
= NULL
;
2205 bs
->print_it
= print_it_normal
;
2209 /* Possible return values for watchpoint_check (this can't be an enum
2210 because of check_errors). */
2211 /* The watchpoint has been deleted. */
2212 #define WP_DELETED 1
2213 /* The value has changed. */
2214 #define WP_VALUE_CHANGED 2
2215 /* The value has not changed. */
2216 #define WP_VALUE_NOT_CHANGED 3
2218 #define BP_TEMPFLAG 1
2219 #define BP_HARDWAREFLAG 2
2221 /* Check watchpoint condition. */
2224 watchpoint_check (p
)
2227 bpstat bs
= (bpstat
) p
;
2228 struct breakpoint
*b
;
2229 struct frame_info
*fr
;
2230 int within_current_scope
;
2232 b
= bs
->breakpoint_at
;
2234 if (b
->exp_valid_block
== NULL
)
2235 within_current_scope
= 1;
2238 /* There is no current frame at this moment. If we're going to have
2239 any chance of handling watchpoints on local variables, we'll need
2240 the frame chain (so we can determine if we're in scope). */
2241 reinit_frame_cache ();
2242 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
2243 within_current_scope
= (fr
!= NULL
);
2244 if (within_current_scope
)
2245 /* If we end up stopping, the current frame will get selected
2246 in normal_stop. So this call to select_frame won't affect
2248 select_frame (fr
, -1);
2251 if (within_current_scope
)
2253 /* We use value_{,free_to_}mark because it could be a
2254 *long* time before we return to the command level and
2255 call free_all_values. We can't call free_all_values because
2256 we might be in the middle of evaluating a function call. */
2258 value_ptr mark
= value_mark ();
2259 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
2260 if (!value_equal (b
->val
, new_val
))
2262 release_value (new_val
);
2263 value_free_to_mark (mark
);
2264 bs
->old_val
= b
->val
;
2266 /* We will stop here */
2267 return WP_VALUE_CHANGED
;
2271 /* Nothing changed, don't do anything. */
2272 value_free_to_mark (mark
);
2273 /* We won't stop here */
2274 return WP_VALUE_NOT_CHANGED
;
2279 /* This seems like the only logical thing to do because
2280 if we temporarily ignored the watchpoint, then when
2281 we reenter the block in which it is valid it contains
2282 garbage (in the case of a function, it may have two
2283 garbage values, one before and one after the prologue).
2284 So we can't even detect the first assignment to it and
2285 watch after that (since the garbage may or may not equal
2286 the first value assigned). */
2287 /* We print all the stop information in print_it_typical(), but
2288 in this case, by the time we call print_it_typical() this bp
2289 will be deleted already. So we have no choice but print the
2290 information here. */
2292 Watchpoint %d deleted because the program has left the block in\n\
2293 which its expression is valid.\n", bs
->breakpoint_at
->number
);
2295 if (b
->related_breakpoint
)
2296 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2297 b
->disposition
= del_at_next_stop
;
2303 /* Get a bpstat associated with having just stopped at address *PC
2304 and frame address CORE_ADDRESS. Update *PC to point at the
2305 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2306 if this is known to not be a real breakpoint (it could still be a
2307 watchpoint, though). */
2309 /* Determine whether we stopped at a breakpoint, etc, or whether we
2310 don't understand this stop. Result is a chain of bpstat's such that:
2312 if we don't understand the stop, the result is a null pointer.
2314 if we understand why we stopped, the result is not null.
2316 Each element of the chain refers to a particular breakpoint or
2317 watchpoint at which we have stopped. (We may have stopped for
2318 several reasons concurrently.)
2320 Each element of the chain has valid next, breakpoint_at,
2321 commands, FIXME??? fields. */
2324 bpstat_stop_status (pc
, not_a_breakpoint
)
2326 int not_a_breakpoint
;
2328 register struct breakpoint
*b
, *temp
;
2330 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2331 int real_breakpoint
= 0;
2332 /* Root of the chain of bpstat's */
2333 struct bpstats root_bs
[1];
2334 /* Pointer to the last thing in the chain currently. */
2335 bpstat bs
= root_bs
;
2336 static char message1
[] =
2337 "Error evaluating expression for watchpoint %d\n";
2338 char message
[sizeof (message1
) + 30 /* slop */ ];
2340 /* Get the address where the breakpoint would have been. */
2341 bp_addr
= *pc
- (not_a_breakpoint
&& !SOFTWARE_SINGLE_STEP_P
?
2342 0 : DECR_PC_AFTER_BREAK
);
2344 ALL_BREAKPOINTS_SAFE (b
, temp
)
2346 if (b
->enable
== disabled
2347 || b
->enable
== shlib_disabled
2348 || b
->enable
== call_disabled
)
2351 if (b
->type
!= bp_watchpoint
2352 && b
->type
!= bp_hardware_watchpoint
2353 && b
->type
!= bp_read_watchpoint
2354 && b
->type
!= bp_access_watchpoint
2355 && b
->type
!= bp_hardware_breakpoint
2356 && b
->type
!= bp_catch_fork
2357 && b
->type
!= bp_catch_vfork
2358 && b
->type
!= bp_catch_exec
2359 && b
->type
!= bp_catch_catch
2360 && b
->type
!= bp_catch_throw
) /* a non-watchpoint bp */
2361 if (b
->address
!= bp_addr
|| /* address doesn't match or */
2362 (overlay_debugging
&& /* overlay doesn't match */
2363 section_is_overlay (b
->section
) &&
2364 !section_is_mapped (b
->section
)))
2367 if (b
->type
== bp_hardware_breakpoint
2368 && b
->address
!= (*pc
- DECR_PC_AFTER_HW_BREAK
))
2371 /* Is this a catchpoint of a load or unload? If so, did we
2372 get a load or unload of the specified library? If not,
2374 if ((b
->type
== bp_catch_load
)
2375 #if defined(SOLIB_HAVE_LOAD_EVENT)
2376 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid
)
2377 || ((b
->dll_pathname
!= NULL
)
2378 && (strcmp (b
->dll_pathname
,
2379 SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
))
2385 if ((b
->type
== bp_catch_unload
)
2386 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2387 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid
)
2388 || ((b
->dll_pathname
!= NULL
)
2389 && (strcmp (b
->dll_pathname
,
2390 SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
))
2396 if ((b
->type
== bp_catch_fork
)
2397 && !target_has_forked (inferior_pid
, &b
->forked_inferior_pid
))
2400 if ((b
->type
== bp_catch_vfork
)
2401 && !target_has_vforked (inferior_pid
, &b
->forked_inferior_pid
))
2404 if ((b
->type
== bp_catch_exec
)
2405 && !target_has_execd (inferior_pid
, &b
->exec_pathname
))
2408 if (ep_is_exception_catchpoint (b
) &&
2409 !(current_exception_event
= target_get_current_exception_event ()))
2412 /* Come here if it's a watchpoint, or if the break address matches */
2414 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
2416 /* Watchpoints may change this, if not found to have triggered. */
2420 sprintf (message
, message1
, b
->number
);
2421 if (b
->type
== bp_watchpoint
||
2422 b
->type
== bp_hardware_watchpoint
)
2424 switch (catch_errors (watchpoint_check
, bs
, message
,
2428 /* We've already printed what needs to be printed. */
2429 /* Actually this is superfluous, because by the time we
2430 call print_it_typical() the wp will be already deleted,
2431 and the function will return immediately. */
2432 bs
->print_it
= print_it_done
;
2435 case WP_VALUE_CHANGED
:
2439 case WP_VALUE_NOT_CHANGED
:
2441 bs
->print_it
= print_it_noop
;
2448 /* Error from catch_errors. */
2449 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2450 if (b
->related_breakpoint
)
2451 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2452 b
->disposition
= del_at_next_stop
;
2453 /* We've already printed what needs to be printed. */
2454 bs
->print_it
= print_it_done
;
2460 else if (b
->type
== bp_read_watchpoint
||
2461 b
->type
== bp_access_watchpoint
)
2467 addr
= target_stopped_data_address ();
2470 for (v
= b
->val_chain
; v
; v
= v
->next
)
2472 if (VALUE_LVAL (v
) == lval_memory
2473 && ! VALUE_LAZY (v
))
2477 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
2478 /* Exact match not required. Within range is sufficient.
2480 if (addr
>= vaddr
&&
2481 addr
< vaddr
+ TYPE_LENGTH (VALUE_TYPE (v
)))
2486 switch (catch_errors (watchpoint_check
, bs
, message
,
2490 /* We've already printed what needs to be printed. */
2491 bs
->print_it
= print_it_done
;
2494 case WP_VALUE_CHANGED
:
2495 case WP_VALUE_NOT_CHANGED
:
2502 /* Error from catch_errors. */
2503 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
2504 if (b
->related_breakpoint
)
2505 b
->related_breakpoint
->disposition
= del_at_next_stop
;
2506 b
->disposition
= del_at_next_stop
;
2507 /* We've already printed what needs to be printed. */
2508 bs
->print_it
= print_it_done
;
2511 else /* found == 0 */
2513 /* This is a case where some watchpoint(s) triggered,
2514 but not at the address of this watchpoint (FOUND
2515 was left zero). So don't print anything for this
2517 bs
->print_it
= print_it_noop
;
2524 /* By definition, an encountered breakpoint is a triggered
2528 real_breakpoint
= 1;
2532 b
->frame
!= (get_current_frame ())->frame
)
2536 int value_is_zero
= 0;
2540 /* Need to select the frame, with all that implies
2541 so that the conditions will have the right context. */
2542 select_frame (get_current_frame (), 0);
2544 = catch_errors (breakpoint_cond_eval
, (b
->cond
),
2545 "Error in testing breakpoint condition:\n",
2547 /* FIXME-someday, should give breakpoint # */
2550 if (b
->cond
&& value_is_zero
)
2553 /* Don't consider this a hit. */
2556 else if (b
->ignore_count
> 0)
2559 annotate_ignore_count_change ();
2564 /* We will stop here */
2565 if (b
->disposition
== disable
)
2566 b
->enable
= disabled
;
2567 bs
->commands
= b
->commands
;
2571 (STREQ ("silent", bs
->commands
->line
) ||
2572 (xdb_commands
&& STREQ ("Q", bs
->commands
->line
))))
2574 bs
->commands
= bs
->commands
->next
;
2579 /* Print nothing for this entry if we dont stop or if we dont print. */
2580 if (bs
->stop
== 0 || bs
->print
== 0)
2581 bs
->print_it
= print_it_noop
;
2584 bs
->next
= NULL
; /* Terminate the chain */
2585 bs
= root_bs
->next
; /* Re-grab the head of the chain */
2587 if (real_breakpoint
&& bs
)
2589 if (bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
2591 if (DECR_PC_AFTER_HW_BREAK
!= 0)
2593 *pc
= *pc
- DECR_PC_AFTER_HW_BREAK
;
2599 if (DECR_PC_AFTER_BREAK
!= 0 || must_shift_inst_regs
)
2602 #if defined (SHIFT_INST_REGS)
2604 #else /* No SHIFT_INST_REGS. */
2606 #endif /* No SHIFT_INST_REGS. */
2611 /* The value of a hardware watchpoint hasn't changed, but the
2612 intermediate memory locations we are watching may have. */
2613 if (bs
&& !bs
->stop
&&
2614 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
2615 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
2616 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
2618 remove_breakpoints ();
2619 insert_breakpoints ();
2624 /* Tell what to do about this bpstat. */
2629 /* Classify each bpstat as one of the following. */
2632 /* This bpstat element has no effect on the main_action. */
2635 /* There was a watchpoint, stop but don't print. */
2638 /* There was a watchpoint, stop and print. */
2641 /* There was a breakpoint but we're not stopping. */
2644 /* There was a breakpoint, stop but don't print. */
2647 /* There was a breakpoint, stop and print. */
2650 /* We hit the longjmp breakpoint. */
2653 /* We hit the longjmp_resume breakpoint. */
2656 /* We hit the step_resume breakpoint. */
2659 /* We hit the through_sigtramp breakpoint. */
2662 /* We hit the shared library event breakpoint. */
2665 /* We caught a shared library event. */
2668 /* This is just used to count how many enums there are. */
2672 /* Here is the table which drives this routine. So that we can
2673 format it pretty, we define some abbreviations for the
2674 enum bpstat_what codes. */
2675 #define kc BPSTAT_WHAT_KEEP_CHECKING
2676 #define ss BPSTAT_WHAT_STOP_SILENT
2677 #define sn BPSTAT_WHAT_STOP_NOISY
2678 #define sgl BPSTAT_WHAT_SINGLE
2679 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2680 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2681 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2682 #define sr BPSTAT_WHAT_STEP_RESUME
2683 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2684 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2685 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2687 /* "Can't happen." Might want to print an error message.
2688 abort() is not out of the question, but chances are GDB is just
2689 a bit confused, not unusable. */
2690 #define err BPSTAT_WHAT_STOP_NOISY
2692 /* Given an old action and a class, come up with a new action. */
2693 /* One interesting property of this table is that wp_silent is the same
2694 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2695 after stopping, the check for whether to step over a breakpoint
2696 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2697 reference to how we stopped. We retain separate wp_silent and
2698 bp_silent codes in case we want to change that someday.
2700 Another possibly interesting property of this table is that
2701 there's a partial ordering, priority-like, of the actions. Once
2702 you've decided that some action is appropriate, you'll never go
2703 back and decide something of a lower priority is better. The
2706 kc < clr sgl shl slr sn sr ss ts
2707 sgl < clrs shl shlr slr sn sr ss ts
2708 slr < err shl shlr sn sr ss ts
2709 clr < clrs err shl shlr sn sr ss ts
2710 clrs < err shl shlr sn sr ss ts
2711 ss < shl shlr sn sr ts
2718 What I think this means is that we don't need a damned table
2719 here. If you just put the rows and columns in the right order,
2720 it'd look awfully regular. We could simply walk the bpstat list
2721 and choose the highest priority action we find, with a little
2722 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2723 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2724 is messy anyway). */
2726 /* step_resume entries: a step resume breakpoint overrides another
2727 breakpoint of signal handling (see comment in wait_for_inferior
2728 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2729 /* We handle the through_sigtramp_breakpoint the same way; having both
2730 one of those and a step_resume_breakpoint is probably very rare (?). */
2732 static const enum bpstat_what_main_action
2733 table
[(int) class_last
][(int) BPSTAT_WHAT_LAST
] =
2736 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2739 {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
, shlr
},
2741 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2743 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2745 {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
, shlr
},
2747 {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
, shlr
},
2749 {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
, shlr
},
2751 {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2753 {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
, shlr
},
2755 {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
, shlr
},
2757 {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
, shlr
},
2759 {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
, shlr
},
2761 {shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, shlr
, ts
, shlr
, shlr
}
2776 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
2777 struct bpstat_what retval
;
2779 retval
.call_dummy
= 0;
2780 for (; bs
!= NULL
; bs
= bs
->next
)
2782 enum class bs_class
= no_effect
;
2783 if (bs
->breakpoint_at
== NULL
)
2784 /* I suspect this can happen if it was a momentary breakpoint
2785 which has since been deleted. */
2787 switch (bs
->breakpoint_at
->type
)
2793 case bp_hardware_breakpoint
:
2799 bs_class
= bp_noisy
;
2801 bs_class
= bp_silent
;
2804 bs_class
= bp_nostop
;
2807 case bp_hardware_watchpoint
:
2808 case bp_read_watchpoint
:
2809 case bp_access_watchpoint
:
2813 bs_class
= wp_noisy
;
2815 bs_class
= wp_silent
;
2818 /* There was a watchpoint, but we're not stopping.
2819 This requires no further action. */
2820 bs_class
= no_effect
;
2823 bs_class
= long_jump
;
2825 case bp_longjmp_resume
:
2826 bs_class
= long_resume
;
2828 case bp_step_resume
:
2831 bs_class
= step_resume
;
2834 /* It is for the wrong frame. */
2835 bs_class
= bp_nostop
;
2837 case bp_through_sigtramp
:
2838 bs_class
= through_sig
;
2840 case bp_watchpoint_scope
:
2841 bs_class
= bp_nostop
;
2843 case bp_shlib_event
:
2844 bs_class
= shlib_event
;
2846 case bp_thread_event
:
2847 bs_class
= bp_nostop
;
2850 case bp_catch_unload
:
2851 /* Only if this catchpoint triggered should we cause the
2852 step-out-of-dld behaviour. Otherwise, we ignore this
2855 bs_class
= catch_shlib_event
;
2857 bs_class
= no_effect
;
2860 case bp_catch_vfork
:
2865 bs_class
= bp_noisy
;
2867 bs_class
= bp_silent
;
2870 /* There was a catchpoint, but we're not stopping.
2871 This requires no further action. */
2872 bs_class
= no_effect
;
2874 case bp_catch_catch
:
2875 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_CATCH
)
2876 bs_class
= bp_nostop
;
2878 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2880 case bp_catch_throw
:
2881 if (!bs
->stop
|| CURRENT_EXCEPTION_KIND
!= EX_EVENT_THROW
)
2882 bs_class
= bp_nostop
;
2884 bs_class
= bs
->print
? bp_noisy
: bp_silent
;
2887 /* Make sure the action is stop (silent or noisy),
2888 so infrun.c pops the dummy frame. */
2889 bs_class
= bp_silent
;
2890 retval
.call_dummy
= 1;
2893 current_action
= table
[(int) bs_class
][(int) current_action
];
2895 retval
.main_action
= current_action
;
2899 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2900 without hardware support). This isn't related to a specific bpstat,
2901 just to things like whether watchpoints are set. */
2904 bpstat_should_step ()
2906 struct breakpoint
*b
;
2908 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
2913 /* Nonzero if there are enabled hardware watchpoints. */
2915 bpstat_have_active_hw_watchpoints ()
2917 struct breakpoint
*b
;
2919 if ((b
->enable
== enabled
) &&
2921 ((b
->type
== bp_hardware_watchpoint
) ||
2922 (b
->type
== bp_read_watchpoint
) ||
2923 (b
->type
== bp_access_watchpoint
)))
2929 /* Given a bpstat that records zero or more triggered eventpoints, this
2930 function returns another bpstat which contains only the catchpoints
2931 on that first list, if any. */
2933 bpstat_get_triggered_catchpoints (ep_list
, cp_list
)
2937 struct bpstats root_bs
[1];
2938 bpstat bs
= root_bs
;
2939 struct breakpoint
*ep
;
2942 bpstat_clear (cp_list
);
2943 root_bs
->next
= NULL
;
2945 for (; ep_list
!= NULL
; ep_list
= ep_list
->next
)
2947 /* Is this eventpoint a catchpoint? If not, ignore it. */
2948 ep
= ep_list
->breakpoint_at
;
2951 if ((ep
->type
!= bp_catch_load
) &&
2952 (ep
->type
!= bp_catch_unload
) &&
2953 (ep
->type
!= bp_catch_catch
) &&
2954 (ep
->type
!= bp_catch_throw
))
2955 /* pai: (temp) ADD fork/vfork here!! */
2958 /* Yes; add it to the list. */
2959 bs
= bpstat_alloc (ep
, bs
);
2964 #if defined(SOLIB_ADD)
2965 /* Also, for each triggered catchpoint, tag it with the name of
2966 the library that caused this trigger. (We copy the name now,
2967 because it's only guaranteed to be available NOW, when the
2968 catchpoint triggers. Clients who may wish to know the name
2969 later must get it from the catchpoint itself.) */
2970 if (ep
->triggered_dll_pathname
!= NULL
)
2971 free (ep
->triggered_dll_pathname
);
2972 if (ep
->type
== bp_catch_load
)
2973 dll_pathname
= SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid
);
2975 dll_pathname
= SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid
);
2977 dll_pathname
= NULL
;
2981 ep
->triggered_dll_pathname
= (char *)
2982 xmalloc (strlen (dll_pathname
) + 1);
2983 strcpy (ep
->triggered_dll_pathname
, dll_pathname
);
2986 ep
->triggered_dll_pathname
= NULL
;
2992 /* Print B to gdb_stdout. */
2994 print_one_breakpoint (struct breakpoint
*b
,
2995 CORE_ADDR
*last_addr
)
2997 register struct command_line
*l
;
2998 register struct symbol
*sym
;
2999 struct ep_type_description
3004 static struct ep_type_description bptypes
[] =
3006 {bp_none
, "?deleted?"},
3007 {bp_breakpoint
, "breakpoint"},
3008 {bp_hardware_breakpoint
, "hw breakpoint"},
3009 {bp_until
, "until"},
3010 {bp_finish
, "finish"},
3011 {bp_watchpoint
, "watchpoint"},
3012 {bp_hardware_watchpoint
, "hw watchpoint"},
3013 {bp_read_watchpoint
, "read watchpoint"},
3014 {bp_access_watchpoint
, "acc watchpoint"},
3015 {bp_longjmp
, "longjmp"},
3016 {bp_longjmp_resume
, "longjmp resume"},
3017 {bp_step_resume
, "step resume"},
3018 {bp_through_sigtramp
, "sigtramp"},
3019 {bp_watchpoint_scope
, "watchpoint scope"},
3020 {bp_call_dummy
, "call dummy"},
3021 {bp_shlib_event
, "shlib events"},
3022 {bp_thread_event
, "thread events"},
3023 {bp_catch_load
, "catch load"},
3024 {bp_catch_unload
, "catch unload"},
3025 {bp_catch_fork
, "catch fork"},
3026 {bp_catch_vfork
, "catch vfork"},
3027 {bp_catch_exec
, "catch exec"},
3028 {bp_catch_catch
, "catch catch"},
3029 {bp_catch_throw
, "catch throw"}
3032 static char *bpdisps
[] =
3033 {"del", "dstp", "dis", "keep"};
3034 static char bpenables
[] = "nynny";
3035 char wrap_indent
[80];
3041 printf_filtered ("%-3d ", b
->number
);
3045 if (((int) b
->type
> (sizeof (bptypes
) / sizeof (bptypes
[0])))
3046 || ((int) b
->type
!= bptypes
[(int) b
->type
].type
))
3047 internal_error ("bptypes table does not describe type #%d.",
3049 printf_filtered ("%-14s ", bptypes
[(int) b
->type
].description
);
3053 printf_filtered ("%-4s ", bpdisps
[(int) b
->disposition
]);
3057 printf_filtered ("%-3c ", bpenables
[(int) b
->enable
]);
3060 strcpy (wrap_indent
, " ");
3062 strcat (wrap_indent
, " ");
3066 internal_error ("print_one_breakpoint: bp_none encountered\n");
3070 case bp_hardware_watchpoint
:
3071 case bp_read_watchpoint
:
3072 case bp_access_watchpoint
:
3073 /* Field 4, the address, is omitted (which makes the columns
3074 not line up too nicely with the headers, but the effect
3075 is relatively readable). */
3077 print_expression (b
->exp
, gdb_stdout
);
3081 case bp_catch_unload
:
3082 /* Field 4, the address, is omitted (which makes the columns
3083 not line up too nicely with the headers, but the effect
3084 is relatively readable). */
3086 if (b
->dll_pathname
== NULL
)
3087 printf_filtered ("<any library> ");
3089 printf_filtered ("library \"%s\" ", b
->dll_pathname
);
3093 case bp_catch_vfork
:
3094 /* Field 4, the address, is omitted (which makes the columns
3095 not line up too nicely with the headers, but the effect
3096 is relatively readable). */
3098 if (b
->forked_inferior_pid
!= 0)
3099 printf_filtered ("process %d ", b
->forked_inferior_pid
);
3103 /* Field 4, the address, is omitted (which makes the columns
3104 not line up too nicely with the headers, but the effect
3105 is relatively readable). */
3107 if (b
->exec_pathname
!= NULL
)
3108 printf_filtered ("program \"%s\" ", b
->exec_pathname
);
3111 case bp_catch_catch
:
3112 /* Field 4, the address, is omitted (which makes the columns
3113 not line up too nicely with the headers, but the effect
3114 is relatively readable). */
3116 printf_filtered ("exception catch ");
3119 case bp_catch_throw
:
3120 /* Field 4, the address, is omitted (which makes the columns
3121 not line up too nicely with the headers, but the effect
3122 is relatively readable). */
3124 printf_filtered ("exception throw ");
3128 case bp_hardware_breakpoint
:
3132 case bp_longjmp_resume
:
3133 case bp_step_resume
:
3134 case bp_through_sigtramp
:
3135 case bp_watchpoint_scope
:
3137 case bp_shlib_event
:
3138 case bp_thread_event
:
3142 /* FIXME-32x64: need a print_address_numeric with
3146 local_hex_string_custom
3147 ((unsigned long) b
->address
, "08l"));
3150 *last_addr
= b
->address
;
3153 sym
= find_pc_sect_function (b
->address
, b
->section
);
3156 fputs_filtered ("in ", gdb_stdout
);
3157 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
3158 wrap_here (wrap_indent
);
3159 fputs_filtered (" at ", gdb_stdout
);
3161 fputs_filtered (b
->source_file
, gdb_stdout
);
3162 printf_filtered (":%d", b
->line_number
);
3165 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
3169 if (b
->thread
!= -1)
3171 printf_filtered (" thread %d", b
->thread
);
3174 printf_filtered ("\n");
3179 printf_filtered ("\tstop only in stack frame at ");
3180 print_address_numeric (b
->frame
, 1, gdb_stdout
);
3181 printf_filtered ("\n");
3187 printf_filtered ("\tstop only if ");
3188 print_expression (b
->cond
, gdb_stdout
);
3189 printf_filtered ("\n");
3192 if (b
->thread
!= -1)
3194 /* FIXME should make an annotation for this */
3195 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
3198 if (show_breakpoint_hit_counts
&& b
->hit_count
)
3200 /* FIXME should make an annotation for this */
3201 if (ep_is_catchpoint (b
))
3202 printf_filtered ("\tcatchpoint");
3204 printf_filtered ("\tbreakpoint");
3205 printf_filtered (" already hit %d time%s\n",
3206 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
3209 if (b
->ignore_count
)
3212 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
3215 if ((l
= b
->commands
))
3220 print_command_line (l
, 4, gdb_stdout
);
3226 struct captured_breakpoint_query_args
3232 do_captured_breakpoint_query (void *data
)
3234 struct captured_breakpoint_query_args
*args
= data
;
3235 register struct breakpoint
*b
;
3236 CORE_ADDR dummy_addr
= 0;
3239 if (args
->bnum
== b
->number
)
3241 print_one_breakpoint (b
, &dummy_addr
);
3249 gdb_breakpoint_query (/* output object, */ int bnum
)
3251 struct captured_breakpoint_query_args args
;
3253 /* For the moment we don't trust print_one_breakpoint() to not throw
3255 return catch_errors (do_captured_breakpoint_query
, &args
,
3256 NULL
, RETURN_MASK_ALL
);
3259 /* Print information on breakpoint number BNUM, or -1 if all.
3260 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
3261 is nonzero, process only watchpoints. */
3264 breakpoint_1 (bnum
, allflag
)
3268 register struct breakpoint
*b
;
3269 CORE_ADDR last_addr
= (CORE_ADDR
) -1;
3270 int found_a_breakpoint
= 0;
3274 || bnum
== b
->number
)
3276 /* We only print out user settable breakpoints unless the
3279 && b
->type
!= bp_breakpoint
3280 && b
->type
!= bp_catch_load
3281 && b
->type
!= bp_catch_unload
3282 && b
->type
!= bp_catch_fork
3283 && b
->type
!= bp_catch_vfork
3284 && b
->type
!= bp_catch_exec
3285 && b
->type
!= bp_catch_catch
3286 && b
->type
!= bp_catch_throw
3287 && b
->type
!= bp_hardware_breakpoint
3288 && b
->type
!= bp_watchpoint
3289 && b
->type
!= bp_read_watchpoint
3290 && b
->type
!= bp_access_watchpoint
3291 && b
->type
!= bp_hardware_watchpoint
)
3294 if (!found_a_breakpoint
++)
3296 annotate_breakpoints_headers ();
3298 printf_filtered ("Num ");
3300 printf_filtered ("Type ");
3302 printf_filtered ("Disp ");
3304 printf_filtered ("Enb ");
3308 printf_filtered ("Address ");
3311 printf_filtered ("What\n");
3312 annotate_breakpoints_table ();
3315 print_one_breakpoint (b
, &last_addr
);
3318 if (!found_a_breakpoint
)
3321 printf_filtered ("No breakpoints or watchpoints.\n");
3323 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
3327 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3328 that a comparison of an unsigned with -1 is always false. */
3329 if (last_addr
!= (CORE_ADDR
) -1)
3330 set_next_address (last_addr
);
3333 /* FIXME? Should this be moved up so that it is only called when
3334 there have been breakpoints? */
3335 annotate_breakpoints_table_end ();
3340 breakpoints_info (bnum_exp
, from_tty
)
3347 bnum
= parse_and_eval_address (bnum_exp
);
3349 breakpoint_1 (bnum
, 0);
3354 maintenance_info_breakpoints (bnum_exp
, from_tty
)
3361 bnum
= parse_and_eval_address (bnum_exp
);
3363 breakpoint_1 (bnum
, 1);
3366 /* Print a message describing any breakpoints set at PC. */
3369 describe_other_breakpoints (pc
, section
)
3373 register int others
= 0;
3374 register struct breakpoint
*b
;
3377 if (b
->address
== pc
)
3378 if (overlay_debugging
== 0 ||
3379 b
->section
== section
)
3383 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
3385 if (b
->address
== pc
)
3386 if (overlay_debugging
== 0 ||
3387 b
->section
== section
)
3393 ((b
->enable
== disabled
||
3394 b
->enable
== shlib_disabled
||
3395 b
->enable
== call_disabled
) ? " (disabled)"
3396 : b
->enable
== permanent
? " (permanent)"
3398 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
3400 printf_filtered ("also set at pc ");
3401 print_address_numeric (pc
, 1, gdb_stdout
);
3402 printf_filtered (".\n");
3406 /* Set the default place to put a breakpoint
3407 for the `break' command with no arguments. */
3410 set_default_breakpoint (valid
, addr
, symtab
, line
)
3413 struct symtab
*symtab
;
3416 default_breakpoint_valid
= valid
;
3417 default_breakpoint_address
= addr
;
3418 default_breakpoint_symtab
= symtab
;
3419 default_breakpoint_line
= line
;
3422 /* Rescan breakpoints at address ADDRESS,
3423 marking the first one as "first" and any others as "duplicates".
3424 This is so that the bpt instruction is only inserted once.
3425 If we have a permanent breakpoint at ADDRESS, make that one
3426 the official one, and the rest as duplicates. */
3429 check_duplicates (address
, section
)
3433 register struct breakpoint
*b
;
3434 register int count
= 0;
3435 struct breakpoint
*perm_bp
= 0;
3437 if (address
== 0) /* Watchpoints are uninteresting */
3441 if (b
->enable
!= disabled
3442 && b
->enable
!= shlib_disabled
3443 && b
->enable
!= call_disabled
3444 && b
->address
== address
3445 && (overlay_debugging
== 0 || b
->section
== section
))
3447 /* Have we found a permanent breakpoint? */
3448 if (b
->enable
== permanent
)
3455 b
->duplicate
= count
> 1;
3458 /* If we found a permanent breakpoint at this address, go over the
3459 list again and declare all the other breakpoints there to be the
3463 perm_bp
->duplicate
= 0;
3465 /* Permanent breakpoint should always be inserted. */
3466 if (! perm_bp
->inserted
)
3467 internal_error ("allegedly permanent breakpoint is not "
3468 "actually inserted");
3474 internal_error ("another breakpoint was inserted on top of "
3475 "a permanent breakpoint");
3477 if (b
->enable
!= disabled
3478 && b
->enable
!= shlib_disabled
3479 && b
->enable
!= call_disabled
3480 && b
->address
== address
3481 && (overlay_debugging
== 0 || b
->section
== section
))
3487 /* Low level routine to set a breakpoint.
3488 Takes as args the three things that every breakpoint must have.
3489 Returns the breakpoint object so caller can set other things.
3490 Does not set the breakpoint number!
3491 Does not print anything.
3493 ==> This routine should not be called if there is a chance of later
3494 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3495 your arguments BEFORE calling this routine! */
3498 set_raw_breakpoint (sal
)
3499 struct symtab_and_line sal
;
3501 register struct breakpoint
*b
, *b1
;
3503 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
3504 memset (b
, 0, sizeof (*b
));
3505 b
->address
= sal
.pc
;
3506 if (sal
.symtab
== NULL
)
3507 b
->source_file
= NULL
;
3509 b
->source_file
= savestring (sal
.symtab
->filename
,
3510 strlen (sal
.symtab
->filename
));
3511 b
->section
= sal
.section
;
3512 b
->language
= current_language
->la_language
;
3513 b
->input_radix
= input_radix
;
3515 b
->line_number
= sal
.line
;
3516 b
->enable
= enabled
;
3519 b
->ignore_count
= 0;
3522 b
->dll_pathname
= NULL
;
3523 b
->triggered_dll_pathname
= NULL
;
3524 b
->forked_inferior_pid
= 0;
3525 b
->exec_pathname
= NULL
;
3527 /* Add this breakpoint to the end of the chain
3528 so that a list of breakpoints will come out in order
3529 of increasing numbers. */
3531 b1
= breakpoint_chain
;
3533 breakpoint_chain
= b
;
3541 check_duplicates (sal
.pc
, sal
.section
);
3542 breakpoints_changed ();
3548 /* Note that the breakpoint object B describes a permanent breakpoint
3549 instruction, hard-wired into the inferior's code. */
3551 make_breakpoint_permanent (struct breakpoint
*b
)
3553 b
->enable
= permanent
;
3555 /* By definition, permanent breakpoints are already present in the code. */
3559 #ifdef GET_LONGJMP_TARGET
3562 create_longjmp_breakpoint (func_name
)
3565 struct symtab_and_line sal
;
3566 struct breakpoint
*b
;
3568 INIT_SAL (&sal
); /* initialize to zeroes */
3569 if (func_name
!= NULL
)
3571 struct minimal_symbol
*m
;
3573 m
= lookup_minimal_symbol_text (func_name
, NULL
,
3574 (struct objfile
*) NULL
);
3576 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
3580 sal
.section
= find_pc_overlay (sal
.pc
);
3581 b
= set_raw_breakpoint (sal
);
3585 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
3586 b
->disposition
= donttouch
;
3587 b
->enable
= disabled
;
3590 b
->addr_string
= strsave (func_name
);
3591 b
->number
= internal_breakpoint_number
--;
3594 #endif /* #ifdef GET_LONGJMP_TARGET */
3596 /* Call this routine when stepping and nexting to enable a breakpoint
3597 if we do a longjmp(). When we hit that breakpoint, call
3598 set_longjmp_resume_breakpoint() to figure out where we are going. */
3601 enable_longjmp_breakpoint ()
3603 register struct breakpoint
*b
;
3606 if (b
->type
== bp_longjmp
)
3608 b
->enable
= enabled
;
3609 check_duplicates (b
->address
, b
->section
);
3614 disable_longjmp_breakpoint ()
3616 register struct breakpoint
*b
;
3619 if (b
->type
== bp_longjmp
3620 || b
->type
== bp_longjmp_resume
)
3622 b
->enable
= disabled
;
3623 check_duplicates (b
->address
, b
->section
);
3628 create_thread_event_breakpoint (address
)
3631 struct breakpoint
*b
;
3632 struct symtab_and_line sal
;
3633 char addr_string
[80]; /* Surely an addr can't be longer than that. */
3635 INIT_SAL (&sal
); /* initialize to zeroes */
3637 sal
.section
= find_pc_overlay (sal
.pc
);
3638 if ((b
= set_raw_breakpoint (sal
)) == NULL
)
3641 b
->number
= internal_breakpoint_number
--;
3642 b
->disposition
= donttouch
;
3643 b
->type
= bp_thread_event
; /* XXX: do we need a new type?
3645 b
->enable
= enabled
;
3646 /* addr_string has to be used or breakpoint_re_set will delete me. */
3647 sprintf (addr_string
, "*0x%s", paddr (b
->address
));
3648 b
->addr_string
= strsave (addr_string
);
3654 remove_thread_event_breakpoints (void)
3656 struct breakpoint
*b
, *temp
;
3658 ALL_BREAKPOINTS_SAFE (b
, temp
)
3659 if (b
->type
== bp_thread_event
)
3660 delete_breakpoint (b
);
3665 remove_solib_event_breakpoints ()
3667 register struct breakpoint
*b
, *temp
;
3669 ALL_BREAKPOINTS_SAFE (b
, temp
)
3670 if (b
->type
== bp_shlib_event
)
3671 delete_breakpoint (b
);
3675 create_solib_event_breakpoint (address
)
3678 struct breakpoint
*b
;
3679 struct symtab_and_line sal
;
3681 INIT_SAL (&sal
); /* initialize to zeroes */
3683 sal
.section
= find_pc_overlay (sal
.pc
);
3684 b
= set_raw_breakpoint (sal
);
3685 b
->number
= internal_breakpoint_number
--;
3686 b
->disposition
= donttouch
;
3687 b
->type
= bp_shlib_event
;
3692 /* Disable any breakpoints that are on code in shared libraries. Only
3693 apply to enabled breakpoints, disabled ones can just stay disabled. */
3696 disable_breakpoints_in_shlibs (silent
)
3699 struct breakpoint
*b
;
3700 int disabled_shlib_breaks
= 0;
3702 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3705 #if defined (PC_SOLIB)
3706 if (((b
->type
== bp_breakpoint
) ||
3707 (b
->type
== bp_hardware_breakpoint
)) &&
3708 b
->enable
== enabled
&&
3710 PC_SOLIB (b
->address
))
3712 b
->enable
= shlib_disabled
;
3715 if (!disabled_shlib_breaks
)
3717 target_terminal_ours_for_output ();
3718 warning ("Temporarily disabling shared library breakpoints:");
3720 disabled_shlib_breaks
= 1;
3721 warning ("breakpoint #%d ", b
->number
);
3728 /* Try to reenable any breakpoints in shared libraries. */
3730 re_enable_breakpoints_in_shlibs ()
3732 struct breakpoint
*b
;
3735 if (b
->enable
== shlib_disabled
)
3739 /* Do not reenable the breakpoint if the shared library
3740 is still not mapped in. */
3741 if (target_read_memory (b
->address
, buf
, 1) == 0)
3742 b
->enable
= enabled
;
3749 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
, cond_string
, bp_kind
)
3754 enum bptype bp_kind
;
3756 struct breakpoint
*b
;
3757 struct symtabs_and_lines sals
;
3758 struct cleanup
*old_chain
;
3759 struct cleanup
*canonical_strings_chain
= NULL
;
3760 char *addr_start
= hookname
;
3761 char *addr_end
= NULL
;
3762 char **canonical
= (char **) NULL
;
3763 int thread
= -1; /* All threads. */
3765 /* Set a breakpoint on the specified hook. */
3766 sals
= decode_line_1 (&hookname
, 1, (struct symtab
*) NULL
, 0, &canonical
);
3767 addr_end
= hookname
;
3769 if (sals
.nelts
== 0)
3771 warning ("Unable to set a breakpoint on dynamic linker callback.");
3772 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3773 warning ("GDB will be unable to track shl_load/shl_unload calls");
3776 if (sals
.nelts
!= 1)
3778 warning ("Unable to set unique breakpoint on dynamic linker callback.");
3779 warning ("GDB will be unable to track shl_load/shl_unload calls");
3783 /* Make sure that all storage allocated in decode_line_1 gets freed
3784 in case the following errors out. */
3785 old_chain
= make_cleanup (free
, sals
.sals
);
3786 if (canonical
!= (char **) NULL
)
3788 make_cleanup (free
, canonical
);
3789 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
3790 if (canonical
[0] != NULL
)
3791 make_cleanup (free
, canonical
[0]);
3794 resolve_sal_pc (&sals
.sals
[0]);
3796 /* Remove the canonical strings from the cleanup, they are needed below. */
3797 if (canonical
!= (char **) NULL
)
3798 discard_cleanups (canonical_strings_chain
);
3800 b
= set_raw_breakpoint (sals
.sals
[0]);
3801 set_breakpoint_count (breakpoint_count
+ 1);
3802 b
->number
= breakpoint_count
;
3804 b
->cond_string
= (cond_string
== NULL
) ?
3805 NULL
: savestring (cond_string
, strlen (cond_string
));
3808 if (canonical
!= (char **) NULL
&& canonical
[0] != NULL
)
3809 b
->addr_string
= canonical
[0];
3810 else if (addr_start
)
3811 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
3813 b
->enable
= enabled
;
3814 b
->disposition
= tempflag
? del
: donttouch
;
3816 if (dll_pathname
== NULL
)
3817 b
->dll_pathname
= NULL
;
3820 b
->dll_pathname
= (char *) xmalloc (strlen (dll_pathname
) + 1);
3821 strcpy (b
->dll_pathname
, dll_pathname
);
3826 do_cleanups (old_chain
);
3830 create_solib_load_event_breakpoint (hookname
, tempflag
,
3831 dll_pathname
, cond_string
)
3837 solib_load_unload_1 (hookname
, tempflag
, dll_pathname
,
3838 cond_string
, bp_catch_load
);
3842 create_solib_unload_event_breakpoint (hookname
, tempflag
,
3843 dll_pathname
, cond_string
)
3849 solib_load_unload_1 (hookname
,tempflag
, dll_pathname
,
3850 cond_string
, bp_catch_unload
);
3854 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_kind
)
3857 enum bptype bp_kind
;
3859 struct symtab_and_line sal
;
3860 struct breakpoint
*b
;
3861 int thread
= -1; /* All threads. */
3868 b
= set_raw_breakpoint (sal
);
3869 set_breakpoint_count (breakpoint_count
+ 1);
3870 b
->number
= breakpoint_count
;
3872 b
->cond_string
= (cond_string
== NULL
) ?
3873 NULL
: savestring (cond_string
, strlen (cond_string
));
3875 b
->addr_string
= NULL
;
3876 b
->enable
= enabled
;
3877 b
->disposition
= tempflag
? del
: donttouch
;
3878 b
->forked_inferior_pid
= 0;
3886 create_fork_event_catchpoint (tempflag
, cond_string
)
3890 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_fork
);
3894 create_vfork_event_catchpoint (tempflag
, cond_string
)
3898 create_fork_vfork_event_catchpoint (tempflag
, cond_string
, bp_catch_vfork
);
3902 create_exec_event_catchpoint (tempflag
, cond_string
)
3906 struct symtab_and_line sal
;
3907 struct breakpoint
*b
;
3908 int thread
= -1; /* All threads. */
3915 b
= set_raw_breakpoint (sal
);
3916 set_breakpoint_count (breakpoint_count
+ 1);
3917 b
->number
= breakpoint_count
;
3919 b
->cond_string
= (cond_string
== NULL
) ?
3920 NULL
: savestring (cond_string
, strlen (cond_string
));
3922 b
->addr_string
= NULL
;
3923 b
->enable
= enabled
;
3924 b
->disposition
= tempflag
? del
: donttouch
;
3926 b
->type
= bp_catch_exec
;
3932 hw_breakpoint_used_count ()
3934 register struct breakpoint
*b
;
3939 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
3947 hw_watchpoint_used_count (type
, other_type_used
)
3949 int *other_type_used
;
3951 register struct breakpoint
*b
;
3954 *other_type_used
= 0;
3957 if (b
->enable
== enabled
)
3959 if (b
->type
== type
)
3961 else if ((b
->type
== bp_hardware_watchpoint
||
3962 b
->type
== bp_read_watchpoint
||
3963 b
->type
== bp_access_watchpoint
)
3964 && b
->enable
== enabled
)
3965 *other_type_used
= 1;
3971 /* Call this after hitting the longjmp() breakpoint. Use this to set
3972 a new breakpoint at the target of the jmp_buf.
3974 FIXME - This ought to be done by setting a temporary breakpoint
3975 that gets deleted automatically... */
3978 set_longjmp_resume_breakpoint (pc
, frame
)
3980 struct frame_info
*frame
;
3982 register struct breakpoint
*b
;
3985 if (b
->type
== bp_longjmp_resume
)
3988 b
->enable
= enabled
;
3990 b
->frame
= frame
->frame
;
3993 check_duplicates (b
->address
, b
->section
);
3999 disable_watchpoints_before_interactive_call_start ()
4001 struct breakpoint
*b
;
4005 if (((b
->type
== bp_watchpoint
)
4006 || (b
->type
== bp_hardware_watchpoint
)
4007 || (b
->type
== bp_read_watchpoint
)
4008 || (b
->type
== bp_access_watchpoint
)
4009 || ep_is_exception_catchpoint (b
))
4010 && (b
->enable
== enabled
))
4012 b
->enable
= call_disabled
;
4013 check_duplicates (b
->address
, b
->section
);
4019 enable_watchpoints_after_interactive_call_stop ()
4021 struct breakpoint
*b
;
4025 if (((b
->type
== bp_watchpoint
)
4026 || (b
->type
== bp_hardware_watchpoint
)
4027 || (b
->type
== bp_read_watchpoint
)
4028 || (b
->type
== bp_access_watchpoint
)
4029 || ep_is_exception_catchpoint (b
))
4030 && (b
->enable
== call_disabled
))
4032 b
->enable
= enabled
;
4033 check_duplicates (b
->address
, b
->section
);
4039 /* Set a breakpoint that will evaporate an end of command
4040 at address specified by SAL.
4041 Restrict it to frame FRAME if FRAME is nonzero. */
4044 set_momentary_breakpoint (sal
, frame
, type
)
4045 struct symtab_and_line sal
;
4046 struct frame_info
*frame
;
4049 register struct breakpoint
*b
;
4050 b
= set_raw_breakpoint (sal
);
4052 b
->enable
= enabled
;
4053 b
->disposition
= donttouch
;
4054 b
->frame
= (frame
? frame
->frame
: 0);
4056 /* If we're debugging a multi-threaded program, then we
4057 want momentary breakpoints to be active in only a
4058 single thread of control. */
4059 if (in_thread_list (inferior_pid
))
4060 b
->thread
= pid_to_thread_id (inferior_pid
);
4066 /* Tell the user we have just set a breakpoint B. */
4070 struct breakpoint
*b
;
4074 /* FIXME: This is misplaced; mention() is called by things (like hitting a
4075 watchpoint) other than breakpoint creation. It should be possible to
4076 clean this up and at the same time replace the random calls to
4077 breakpoint_changed with this hook, as has already been done for
4078 delete_breakpoint_hook and so on. */
4079 if (create_breakpoint_hook
)
4080 create_breakpoint_hook (b
);
4081 breakpoint_create_event (b
->number
);
4086 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b
->number
);
4089 printf_filtered ("Watchpoint %d: ", b
->number
);
4090 print_expression (b
->exp
, gdb_stdout
);
4092 case bp_hardware_watchpoint
:
4093 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
4094 print_expression (b
->exp
, gdb_stdout
);
4096 case bp_read_watchpoint
:
4097 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
4098 print_expression (b
->exp
, gdb_stdout
);
4100 case bp_access_watchpoint
:
4101 printf_filtered ("Hardware access (read/write) watchpoint %d: ",
4103 print_expression (b
->exp
, gdb_stdout
);
4106 printf_filtered ("Breakpoint %d", b
->number
);
4109 case bp_hardware_breakpoint
:
4110 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
4114 case bp_catch_unload
:
4115 printf_filtered ("Catchpoint %d (%s %s)",
4117 (b
->type
== bp_catch_load
) ? "load" : "unload",
4118 (b
->dll_pathname
!= NULL
) ?
4119 b
->dll_pathname
: "<any library>");
4122 case bp_catch_vfork
:
4123 printf_filtered ("Catchpoint %d (%s)",
4125 (b
->type
== bp_catch_fork
) ? "fork" : "vfork");
4128 printf_filtered ("Catchpoint %d (exec)",
4131 case bp_catch_catch
:
4132 case bp_catch_throw
:
4133 printf_filtered ("Catchpoint %d (%s)",
4135 (b
->type
== bp_catch_catch
) ? "catch" : "throw");
4141 case bp_longjmp_resume
:
4142 case bp_step_resume
:
4143 case bp_through_sigtramp
:
4145 case bp_watchpoint_scope
:
4146 case bp_shlib_event
:
4147 case bp_thread_event
:
4152 if (addressprint
|| b
->source_file
== NULL
)
4154 printf_filtered (" at ");
4155 print_address_numeric (b
->address
, 1, gdb_stdout
);
4158 printf_filtered (": file %s, line %d.",
4159 b
->source_file
, b
->line_number
);
4160 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, b
, 1));
4161 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
4163 printf_filtered ("\n");
4167 /* Add SALS.nelts breakpoints to the breakpoint table. For each
4168 SALS.sal[i] breakpoint, include the corresponding ADDR_STRING[i],
4169 COND[i] and COND_STRING[i] values.
4171 NOTE: If the function succeeds, the caller is expected to cleanup
4172 the arrays ADDR_STRING, COND_STRING, COND and SALS (but not the
4173 array contents). If the function fails (error() is called), the
4174 caller is expected to cleanups both the ADDR_STRING, COND_STRING,
4175 COND and SALS arrays and each of those arrays contents. */
4178 create_breakpoints (struct symtabs_and_lines sals
, char **addr_string
,
4179 struct expression
**cond
, char **cond_string
,
4180 enum bptype type
, enum bpdisp disposition
,
4181 int thread
, int ignore_count
, int from_tty
)
4183 if (type
== bp_hardware_breakpoint
)
4185 int i
= hw_breakpoint_used_count ();
4186 int target_resources_ok
=
4187 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
4189 if (target_resources_ok
== 0)
4190 error ("No hardware breakpoint support in the target.");
4191 else if (target_resources_ok
< 0)
4192 error ("Hardware breakpoints used exceeds limit.");
4195 /* Now set all the breakpoints. */
4198 for (i
= 0; i
< sals
.nelts
; i
++)
4200 struct breakpoint
*b
;
4201 struct symtab_and_line sal
= sals
.sals
[i
];
4204 describe_other_breakpoints (sal
.pc
, sal
.section
);
4206 b
= set_raw_breakpoint (sal
);
4207 set_breakpoint_count (breakpoint_count
+ 1);
4208 b
->number
= breakpoint_count
;
4212 b
->addr_string
= addr_string
[i
];
4213 b
->cond_string
= cond_string
[i
];
4214 b
->ignore_count
= ignore_count
;
4215 b
->enable
= enabled
;
4216 b
->disposition
= disposition
;
4222 /* Parse ARG which is assumed to be a SAL specification possibly
4223 followed by conditionals. On return, SALS contains an array of SAL
4224 addresses found. ADDR_STRING contains a vector of (canonical)
4225 address strings. ARG points to the end of the SAL. */
4228 parse_breakpoint_sals (char **address
,
4229 struct symtabs_and_lines
*sals
,
4230 char ***addr_string
)
4232 char *addr_start
= *address
;
4233 *addr_string
= NULL
;
4234 /* If no arg given, or if first arg is 'if ', use the default
4236 if ((*address
) == NULL
4237 || (strncmp ((*address
), "if", 2) == 0 && isspace ((*address
)[2])))
4239 if (default_breakpoint_valid
)
4241 struct symtab_and_line sal
;
4242 INIT_SAL (&sal
); /* initialize to zeroes */
4243 sals
->sals
= (struct symtab_and_line
*)
4244 xmalloc (sizeof (struct symtab_and_line
));
4245 sal
.pc
= default_breakpoint_address
;
4246 sal
.line
= default_breakpoint_line
;
4247 sal
.symtab
= default_breakpoint_symtab
;
4248 sal
.section
= find_pc_overlay (sal
.pc
);
4249 sals
->sals
[0] = sal
;
4253 error ("No default breakpoint address now.");
4257 /* Force almost all breakpoints to be in terms of the
4258 current_source_symtab (which is decode_line_1's default). This
4259 should produce the results we want almost all of the time while
4260 leaving default_breakpoint_* alone. */
4261 if (default_breakpoint_valid
4262 && (!current_source_symtab
4263 || (strchr ("+-", (*address
)[0]) != NULL
)))
4264 *sals
= decode_line_1 (address
, 1, default_breakpoint_symtab
,
4265 default_breakpoint_line
, addr_string
);
4267 *sals
= decode_line_1 (address
, 1, (struct symtab
*) NULL
, 0, addr_string
);
4269 /* For any SAL that didn't have a canonical string, fill one in. */
4270 if (sals
->nelts
> 0 && *addr_string
== NULL
)
4271 *addr_string
= xcalloc (sals
->nelts
, sizeof (char **));
4272 if (addr_start
!= (*address
))
4275 for (i
= 0; i
< sals
->nelts
; i
++)
4277 /* Add the string if not present. */
4278 if ((*addr_string
)[i
] == NULL
)
4279 (*addr_string
)[i
] = savestring (addr_start
, (*address
) - addr_start
);
4285 /* Convert each SAL into a real PC. Verify that the PC can be
4286 inserted as a breakpoint. If it can't throw an error. */
4289 breakpoint_sals_to_pc (struct symtabs_and_lines
*sals
,
4293 for (i
= 0; i
< sals
->nelts
; i
++)
4295 resolve_sal_pc (&sals
->sals
[i
]);
4297 /* It's possible for the PC to be nonzero, but still an illegal
4298 value on some targets.
4300 For example, on HP-UX if you start gdb, and before running the
4301 inferior you try to set a breakpoint on a shared library function
4302 "foo" where the inferior doesn't call "foo" directly but does
4303 pass its address to another function call, then we do find a
4304 minimal symbol for the "foo", but it's address is invalid.
4305 (Appears to be an index into a table that the loader sets up
4306 when the inferior is run.)
4308 Give the target a chance to bless sals.sals[i].pc before we
4309 try to make a breakpoint for it. */
4310 if (PC_REQUIRES_RUN_BEFORE_USE (sals
->sals
[i
].pc
))
4312 if (address
== NULL
)
4313 error ("Cannot break without a running program.");
4315 error ("Cannot break on %s without a running program.",
4321 /* Set a breakpoint according to ARG (function, linenum or *address)
4322 flag: first bit : 0 non-temporary, 1 temporary.
4323 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
4326 break_command_1 (arg
, flag
, from_tty
)
4330 int tempflag
, hardwareflag
;
4331 struct symtabs_and_lines sals
;
4332 register struct expression
**cond
= 0;
4333 /* Pointers in arg to the start, and one past the end, of the
4335 char **cond_string
= (char **) NULL
;
4336 char *addr_start
= arg
;
4338 struct cleanup
*old_chain
;
4339 struct cleanup
*breakpoint_chain
= NULL
;
4342 int ignore_count
= 0;
4344 hardwareflag
= flag
& BP_HARDWAREFLAG
;
4345 tempflag
= flag
& BP_TEMPFLAG
;
4350 parse_breakpoint_sals (&arg
, &sals
, &addr_string
);
4355 /* Create a chain of things that always need to be cleaned up. */
4356 old_chain
= make_cleanup (null_cleanup
, 0);
4358 /* Make sure that all storage allocated to SALS gets freed. */
4359 make_cleanup (free
, sals
.sals
);
4361 /* Cleanup the addr_string array but not its contents. */
4362 make_cleanup (free
, addr_string
);
4364 /* Allocate space for all the cond expressions. */
4365 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4366 make_cleanup (free
, cond
);
4368 /* Allocate space for all the cond strings. */
4369 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4370 make_cleanup (free
, cond_string
);
4372 /* ----------------------------- SNIP -----------------------------
4373 Anything added to the cleanup chain beyond this point is assumed
4374 to be part of a breakpoint. If the breakpoint create succeeds
4375 then the memory is not reclaimed. */
4376 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4378 /* Mark the contents of the addr_string for cleanup. These go on
4379 the breakpoint_chain and only occure if the breakpoint create
4381 for (i
= 0; i
< sals
.nelts
; i
++)
4383 if (addr_string
[i
] != NULL
)
4384 make_cleanup (free
, addr_string
[i
]);
4387 /* Resolve all line numbers to PC's and verify that the addresses
4388 are ok for the target. */
4389 breakpoint_sals_to_pc (&sals
, addr_start
);
4391 /* Verify that condition can be parsed, before setting any
4392 breakpoints. Allocate a separate condition expression for each
4394 thread
= -1; /* No specific thread yet */
4395 for (i
= 0; i
< sals
.nelts
; i
++)
4402 char *cond_start
= NULL
;
4403 char *cond_end
= NULL
;
4404 while (*tok
== ' ' || *tok
== '\t')
4409 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4412 toklen
= end_tok
- tok
;
4414 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4416 tok
= cond_start
= end_tok
+ 1;
4417 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4418 make_cleanup (free
, cond
[i
]);
4420 cond_string
[i
] = savestring (cond_start
, cond_end
- cond_start
);
4421 make_cleanup (free
, cond_string
[i
]);
4423 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
4429 thread
= strtol (tok
, &tok
, 0);
4431 error ("Junk after thread keyword.");
4432 if (!valid_thread_id (thread
))
4433 error ("Unknown thread %d\n", thread
);
4436 error ("Junk at end of arguments.");
4440 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
4441 hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
4442 tempflag
? del
: donttouch
,
4443 thread
, ignore_count
, from_tty
);
4447 warning ("Multiple breakpoints were set.");
4448 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4450 /* That's it. Discard the cleanups for data inserted into the
4452 discard_cleanups (breakpoint_chain
);
4453 /* But cleanup everything else. */
4454 do_cleanups (old_chain
);
4457 /* Set a breakpoint of TYPE/DISPOSITION according to ARG (function,
4458 linenum or *address) with COND and IGNORE_COUNT. */
4460 struct captured_breakpoint_args
4471 do_captured_breakpoint (void *data
)
4473 struct captured_breakpoint_args
*args
= data
;
4474 struct symtabs_and_lines sals
;
4475 register struct expression
**cond
;
4476 struct cleanup
*old_chain
;
4477 struct cleanup
*breakpoint_chain
= NULL
;
4484 /* Parse the source and lines spec. Delay check that the expression
4485 didn't contain trailing garbage until after cleanups are in
4489 address_end
= args
->address
;
4491 parse_breakpoint_sals (&address_end
, &sals
, &addr_string
);
4496 /* Create a chain of things at always need to be cleaned up. */
4497 old_chain
= make_cleanup (null_cleanup
, 0);
4499 /* Always have a addr_string array, even if it is empty. */
4500 make_cleanup (free
, addr_string
);
4502 /* Make sure that all storage allocated to SALS gets freed. */
4503 make_cleanup (free
, sals
.sals
);
4505 /* Allocate space for all the cond expressions. */
4506 cond
= xcalloc (sals
.nelts
, sizeof (struct expression
*));
4507 make_cleanup (free
, cond
);
4509 /* Allocate space for all the cond strings. */
4510 cond_string
= xcalloc (sals
.nelts
, sizeof (char **));
4511 make_cleanup (free
, cond_string
);
4513 /* ----------------------------- SNIP -----------------------------
4514 Anything added to the cleanup chain beyond this point is assumed
4515 to be part of a breakpoint. If the breakpoint create goes
4516 through then that memory is not cleaned up. */
4517 breakpoint_chain
= make_cleanup (null_cleanup
, 0);
4519 /* Mark the contents of the addr_string for cleanup. These go on
4520 the breakpoint_chain and only occure if the breakpoint create
4522 for (i
= 0; i
< sals
.nelts
; i
++)
4524 if (addr_string
[i
] != NULL
)
4525 make_cleanup (free
, addr_string
[i
]);
4528 /* Wait until now before checking for garbage at the end of the
4529 address. That way cleanups can take care of freeing any
4531 if (*address_end
!= '\0')
4532 error ("Garbage %s following breakpoint address", address_end
);
4534 /* Resolve all line numbers to PC's. */
4535 breakpoint_sals_to_pc (&sals
, args
->address
);
4537 /* Verify that conditions can be parsed, before setting any
4539 for (i
= 0; i
< sals
.nelts
; i
++)
4541 if (args
->condition
!= NULL
)
4543 char *tok
= args
->condition
;
4544 cond
[i
] = parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
4546 error ("Garbage %s follows condition", tok
);
4547 make_cleanup (free
, cond
[i
]);
4548 cond_string
[i
] = xstrdup (args
->condition
);
4552 create_breakpoints (sals
, addr_string
, cond
, cond_string
,
4553 args
->hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
,
4554 args
->tempflag
? del
: donttouch
,
4555 args
->thread
, args
->ignore_count
, 0/*from-tty*/);
4557 /* That's it. Discard the cleanups for data inserted into the
4559 discard_cleanups (breakpoint_chain
);
4560 /* But cleanup everything else. */
4561 do_cleanups (old_chain
);
4566 gdb_breakpoint (char *address
, char *condition
,
4567 int hardwareflag
, int tempflag
,
4568 int thread
, int ignore_count
)
4570 struct captured_breakpoint_args args
;
4571 args
.address
= address
;
4572 args
.condition
= condition
;
4573 args
.hardwareflag
= hardwareflag
;
4574 args
.tempflag
= tempflag
;
4575 args
.thread
= thread
;
4576 args
.ignore_count
= ignore_count
;
4577 return catch_errors (do_captured_breakpoint
, &args
,
4578 NULL
, RETURN_MASK_ALL
);
4583 break_at_finish_at_depth_command_1 (arg
, flag
, from_tty
)
4588 struct frame_info
*frame
;
4589 CORE_ADDR low
, high
, selected_pc
= 0;
4590 char *extra_args
, *level_arg
, *addr_string
;
4591 int extra_args_len
= 0, if_arg
= 0;
4594 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4597 if (default_breakpoint_valid
)
4601 selected_pc
= selected_frame
->pc
;
4606 error ("No selected frame.");
4609 error ("No default breakpoint address now.");
4613 extra_args
= strchr (arg
, ' ');
4617 extra_args_len
= strlen (extra_args
);
4618 level_arg
= (char *) xmalloc (extra_args
- arg
);
4619 strncpy (level_arg
, arg
, extra_args
- arg
- 1);
4620 level_arg
[extra_args
- arg
- 1] = '\0';
4624 level_arg
= (char *) xmalloc (strlen (arg
) + 1);
4625 strcpy (level_arg
, arg
);
4628 frame
= parse_frame_specification (level_arg
);
4630 selected_pc
= frame
->pc
;
4637 extra_args_len
= strlen (arg
);
4642 if (find_pc_partial_function (selected_pc
, (char **) NULL
, &low
, &high
))
4644 addr_string
= (char *) xmalloc (26 + extra_args_len
);
4646 sprintf (addr_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4648 sprintf (addr_string
, "*0x%s", paddr_nz (high
));
4649 break_command_1 (addr_string
, flag
, from_tty
);
4653 error ("No function contains the specified address");
4656 error ("Unable to set breakpoint at procedure exit");
4661 break_at_finish_command_1 (arg
, flag
, from_tty
)
4666 char *addr_string
, *break_string
, *beg_addr_string
;
4667 CORE_ADDR low
, high
;
4668 struct symtabs_and_lines sals
;
4669 struct symtab_and_line sal
;
4670 struct cleanup
*old_chain
;
4672 int extra_args_len
= 0;
4676 (arg
[0] == 'i' && arg
[1] == 'f' && (arg
[2] == ' ' || arg
[2] == '\t')))
4678 if (default_breakpoint_valid
)
4682 addr_string
= (char *) xmalloc (15);
4683 sprintf (addr_string
, "*0x%s", paddr_nz (selected_frame
->pc
));
4688 error ("No selected frame.");
4691 error ("No default breakpoint address now.");
4695 addr_string
= (char *) xmalloc (strlen (arg
) + 1);
4696 strcpy (addr_string
, arg
);
4702 extra_args_len
= strlen (arg
);
4706 /* get the stuff after the function name or address */
4707 extra_args
= strchr (arg
, ' ');
4711 extra_args_len
= strlen (extra_args
);
4718 beg_addr_string
= addr_string
;
4719 sals
= decode_line_1 (&addr_string
, 1, (struct symtab
*) NULL
, 0,
4722 free (beg_addr_string
);
4723 old_chain
= make_cleanup (free
, sals
.sals
);
4724 for (i
= 0; (i
< sals
.nelts
); i
++)
4727 if (find_pc_partial_function (sal
.pc
, (char **) NULL
, &low
, &high
))
4729 break_string
= (char *) xmalloc (extra_args_len
+ 26);
4731 sprintf (break_string
, "*0x%s %s", paddr_nz (high
), extra_args
);
4733 sprintf (break_string
, "*0x%s", paddr_nz (high
));
4734 break_command_1 (break_string
, flag
, from_tty
);
4735 free (break_string
);
4738 error ("No function contains the specified address");
4742 warning ("Multiple breakpoints were set.\n");
4743 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
4745 do_cleanups (old_chain
);
4749 /* Helper function for break_command_1 and disassemble_command. */
4752 resolve_sal_pc (sal
)
4753 struct symtab_and_line
*sal
;
4757 if (sal
->pc
== 0 && sal
->symtab
!= NULL
)
4759 if (!find_line_pc (sal
->symtab
, sal
->line
, &pc
))
4760 error ("No line %d in file \"%s\".",
4761 sal
->line
, sal
->symtab
->filename
);
4765 if (sal
->section
== 0 && sal
->symtab
!= NULL
)
4767 struct blockvector
*bv
;
4772 bv
= blockvector_for_pc_sect (sal
->pc
, 0, &index
, sal
->symtab
);
4775 b
= BLOCKVECTOR_BLOCK (bv
, index
);
4776 sym
= block_function (b
);
4779 fixup_symbol_section (sym
, sal
->symtab
->objfile
);
4780 sal
->section
= SYMBOL_BFD_SECTION (sym
);
4784 /* It really is worthwhile to have the section, so we'll just
4785 have to look harder. This case can be executed if we have
4786 line numbers but no functions (as can happen in assembly
4789 struct minimal_symbol
*msym
;
4791 msym
= lookup_minimal_symbol_by_pc (sal
->pc
);
4793 sal
->section
= SYMBOL_BFD_SECTION (msym
);
4800 break_command (arg
, from_tty
)
4804 break_command_1 (arg
, 0, from_tty
);
4808 break_at_finish_command (arg
, from_tty
)
4812 break_at_finish_command_1 (arg
, 0, from_tty
);
4816 break_at_finish_at_depth_command (arg
, from_tty
)
4820 break_at_finish_at_depth_command_1 (arg
, 0, from_tty
);
4824 tbreak_command (arg
, from_tty
)
4828 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4832 tbreak_at_finish_command (arg
, from_tty
)
4836 break_at_finish_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
4840 hbreak_command (arg
, from_tty
)
4844 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
4848 thbreak_command (arg
, from_tty
)
4852 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
4856 stop_command (arg
, from_tty
)
4860 printf_filtered ("Specify the type of breakpoint to set.\n\
4861 Usage: stop in <function | address>\n\
4866 stopin_command (arg
, from_tty
)
4872 if (arg
== (char *) NULL
)
4874 else if (*arg
!= '*')
4879 /* look for a ':'. If this is a line number specification, then
4880 say it is bad, otherwise, it should be an address or
4881 function/method name */
4882 while (*argptr
&& !hasColon
)
4884 hasColon
= (*argptr
== ':');
4889 badInput
= (*argptr
!= ':'); /* Not a class::method */
4891 badInput
= isdigit (*arg
); /* a simple line number */
4895 printf_filtered ("Usage: stop in <function | address>\n");
4897 break_command_1 (arg
, 0, from_tty
);
4901 stopat_command (arg
, from_tty
)
4907 if (arg
== (char *) NULL
|| *arg
== '*') /* no line number */
4914 /* look for a ':'. If there is a '::' then get out, otherwise
4915 it is probably a line number. */
4916 while (*argptr
&& !hasColon
)
4918 hasColon
= (*argptr
== ':');
4923 badInput
= (*argptr
== ':'); /* we have class::method */
4925 badInput
= !isdigit (*arg
); /* not a line number */
4929 printf_filtered ("Usage: stop at <line>\n");
4931 break_command_1 (arg
, 0, from_tty
);
4935 /* accessflag: hw_write: watch write,
4936 hw_read: watch read,
4937 hw_access: watch access (read or write) */
4939 watch_command_1 (arg
, accessflag
, from_tty
)
4944 struct breakpoint
*b
;
4945 struct symtab_and_line sal
;
4946 struct expression
*exp
;
4947 struct block
*exp_valid_block
;
4948 struct value
*val
, *mark
;
4949 struct frame_info
*frame
;
4950 struct frame_info
*prev_frame
= NULL
;
4951 char *exp_start
= NULL
;
4952 char *exp_end
= NULL
;
4953 char *tok
, *end_tok
;
4955 char *cond_start
= NULL
;
4956 char *cond_end
= NULL
;
4957 struct expression
*cond
= NULL
;
4958 int i
, other_type_used
, target_resources_ok
= 0;
4959 enum bptype bp_type
;
4962 INIT_SAL (&sal
); /* initialize to zeroes */
4964 /* Parse arguments. */
4965 innermost_block
= NULL
;
4967 exp
= parse_exp_1 (&arg
, 0, 0);
4969 exp_valid_block
= innermost_block
;
4970 mark
= value_mark ();
4971 val
= evaluate_expression (exp
);
4972 release_value (val
);
4973 if (VALUE_LAZY (val
))
4974 value_fetch_lazy (val
);
4977 while (*tok
== ' ' || *tok
== '\t')
4981 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
4984 toklen
= end_tok
- tok
;
4985 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
4987 tok
= cond_start
= end_tok
+ 1;
4988 cond
= parse_exp_1 (&tok
, 0, 0);
4992 error ("Junk at end of command.");
4994 if (accessflag
== hw_read
)
4995 bp_type
= bp_read_watchpoint
;
4996 else if (accessflag
== hw_access
)
4997 bp_type
= bp_access_watchpoint
;
4999 bp_type
= bp_hardware_watchpoint
;
5001 mem_cnt
= can_use_hardware_watchpoint (val
);
5002 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
5003 error ("Expression cannot be implemented with read/access watchpoint.");
5006 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
5007 target_resources_ok
=
5008 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_type
, i
+ mem_cnt
,
5010 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
5011 error ("Target does not support this type of hardware watchpoint.");
5013 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
5014 error ("Target can only support one kind of HW watchpoint at a time.");
5017 #if defined(HPUXHPPA)
5018 /* On HP-UX if you set a h/w
5019 watchpoint before the "run" command, the inferior dies with a e.g.,
5020 SIGILL once you start it. I initially believed this was due to a
5021 bad interaction between page protection traps and the initial
5022 startup sequence by the dynamic linker.
5024 However, I tried avoiding that by having HP-UX's implementation of
5025 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
5026 yet, which forced slow watches before a "run" or "attach", and it
5027 still fails somewhere in the startup code.
5029 Until I figure out what's happening, I'm disallowing watches altogether
5030 before the "run" or "attach" command. We'll tell the user they must
5031 set watches after getting the program started. */
5032 if (!target_has_execution
)
5034 warning ("can't do that without a running program; try \"break main\", \"run\" first");
5037 #endif /* HPUXHPPA */
5039 /* Now set up the breakpoint. */
5040 b
= set_raw_breakpoint (sal
);
5041 set_breakpoint_count (breakpoint_count
+ 1);
5042 b
->number
= breakpoint_count
;
5043 b
->disposition
= donttouch
;
5045 b
->exp_valid_block
= exp_valid_block
;
5046 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
5050 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
5054 frame
= block_innermost_frame (exp_valid_block
);
5057 prev_frame
= get_prev_frame (frame
);
5058 b
->watchpoint_frame
= frame
->frame
;
5061 b
->watchpoint_frame
= (CORE_ADDR
) 0;
5063 if (mem_cnt
&& target_resources_ok
> 0)
5066 b
->type
= bp_watchpoint
;
5068 /* If the expression is "local", then set up a "watchpoint scope"
5069 breakpoint at the point where we've left the scope of the watchpoint
5071 if (innermost_block
)
5075 struct breakpoint
*scope_breakpoint
;
5076 struct symtab_and_line scope_sal
;
5078 INIT_SAL (&scope_sal
); /* initialize to zeroes */
5079 scope_sal
.pc
= get_frame_pc (prev_frame
);
5080 scope_sal
.section
= find_pc_overlay (scope_sal
.pc
);
5082 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
5083 set_breakpoint_count (breakpoint_count
+ 1);
5084 scope_breakpoint
->number
= breakpoint_count
;
5086 scope_breakpoint
->type
= bp_watchpoint_scope
;
5087 scope_breakpoint
->enable
= enabled
;
5089 /* Automatically delete the breakpoint when it hits. */
5090 scope_breakpoint
->disposition
= del
;
5092 /* Only break in the proper frame (help with recursion). */
5093 scope_breakpoint
->frame
= prev_frame
->frame
;
5095 /* Set the address at which we will stop. */
5096 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
5098 /* The scope breakpoint is related to the watchpoint. We
5099 will need to act on them together. */
5100 b
->related_breakpoint
= scope_breakpoint
;
5103 value_free_to_mark (mark
);
5107 /* Return count of locations need to be watched and can be handled
5108 in hardware. If the watchpoint can not be handled
5109 in hardware return zero. */
5111 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
5112 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(BYTE_SIZE) \
5113 ((BYTE_SIZE) <= (REGISTER_SIZE))
5116 #if !defined(TARGET_REGION_OK_FOR_HW_WATCHPOINT)
5117 #define TARGET_REGION_OK_FOR_HW_WATCHPOINT(ADDR,LEN) \
5118 TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(LEN)
5122 can_use_hardware_watchpoint (v
)
5125 int found_memory_cnt
= 0;
5127 /* Did the user specifically forbid us to use hardware watchpoints? */
5128 if (!can_use_hw_watchpoints
)
5131 /* Make sure that the value of the expression depends only upon
5132 memory contents, and values computed from them within GDB. If we
5133 find any register references or function calls, we can't use a
5134 hardware watchpoint.
5136 The idea here is that evaluating an expression generates a series
5137 of values, one holding the value of every subexpression. (The
5138 expression a*b+c has five subexpressions: a, b, a*b, c, and
5139 a*b+c.) GDB's values hold almost enough information to establish
5140 the criteria given above --- they identify memory lvalues,
5141 register lvalues, computed values, etcetera. So we can evaluate
5142 the expression, and then scan the chain of values that leaves
5143 behind to decide whether we can detect any possible change to the
5144 expression's final value using only hardware watchpoints.
5146 However, I don't think that the values returned by inferior
5147 function calls are special in any way. So this function may not
5148 notice that an expression involving an inferior function call
5149 can't be watched with hardware watchpoints. FIXME. */
5150 for (; v
; v
= v
->next
)
5152 if (VALUE_LVAL (v
) == lval_memory
)
5155 /* A lazy memory lvalue is one that GDB never needed to fetch;
5156 we either just used its address (e.g., `a' in `a.b') or
5157 we never needed it at all (e.g., `a' in `a,b'). */
5161 /* Ahh, memory we actually used! Check if we can cover
5162 it with hardware watchpoints. */
5163 CORE_ADDR vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
5164 int len
= TYPE_LENGTH (VALUE_TYPE (v
));
5166 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr
, len
))
5172 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
5173 return 0; /* ??? What does this represent? */
5174 else if (v
->lval
== lval_register
)
5175 return 0; /* cannot watch a register with a HW watchpoint */
5178 /* The expression itself looks suitable for using a hardware
5179 watchpoint, but give the target machine a chance to reject it. */
5180 return found_memory_cnt
;
5184 watch_command (arg
, from_tty
)
5188 watch_command_1 (arg
, hw_write
, from_tty
);
5192 rwatch_command (arg
, from_tty
)
5196 watch_command_1 (arg
, hw_read
, from_tty
);
5200 awatch_command (arg
, from_tty
)
5204 watch_command_1 (arg
, hw_access
, from_tty
);
5208 /* Helper routines for the until_command routine in infcmd.c. Here
5209 because it uses the mechanisms of breakpoints. */
5211 /* This function is called by fetch_inferior_event via the
5212 cmd_continuation pointer, to complete the until command. It takes
5213 care of cleaning up the temporary breakpoints set up by the until
5216 until_break_command_continuation (struct continuation_arg
*arg
)
5218 struct cleanup
*cleanups
;
5220 cleanups
= (struct cleanup
*) arg
->data
;
5221 do_exec_cleanups (cleanups
);
5226 until_break_command (arg
, from_tty
)
5230 struct symtabs_and_lines sals
;
5231 struct symtab_and_line sal
;
5232 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
5233 struct breakpoint
*breakpoint
;
5234 struct cleanup
*old_chain
;
5235 struct continuation_arg
*arg1
;
5238 clear_proceed_status ();
5240 /* Set a breakpoint where the user wants it and at return from
5243 if (default_breakpoint_valid
)
5244 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
5245 default_breakpoint_line
, (char ***) NULL
);
5247 sals
= decode_line_1 (&arg
, 1, (struct symtab
*) NULL
,
5248 0, (char ***) NULL
);
5250 if (sals
.nelts
!= 1)
5251 error ("Couldn't get information on specified line.");
5254 free ((PTR
) sals
.sals
); /* malloc'd, so freed */
5257 error ("Junk at end of arguments.");
5259 resolve_sal_pc (&sal
);
5261 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
5263 if (!event_loop_p
|| !target_can_async_p ())
5264 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
,
5267 old_chain
= make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5269 /* If we are running asynchronously, and the target supports async
5270 execution, we are not waiting for the target to stop, in the call
5271 tp proceed, below. This means that we cannot delete the
5272 brekpoints until the target has actually stopped. The only place
5273 where we get a chance to do that is in fetch_inferior_event, so
5274 we must set things up for that. */
5276 if (event_loop_p
&& target_can_async_p ())
5278 /* In this case the arg for the continuation is just the point
5279 in the exec_cleanups chain from where to start doing
5280 cleanups, because all the continuation does is the cleanups in
5281 the exec_cleanup_chain. */
5283 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
5285 arg1
->data
= (PTR
) old_chain
;
5287 add_continuation (until_break_command_continuation
, arg1
);
5290 /* Keep within the current frame */
5294 sal
= find_pc_line (prev_frame
->pc
, 0);
5295 sal
.pc
= prev_frame
->pc
;
5296 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
5297 if (!event_loop_p
|| !target_can_async_p ())
5298 make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5300 make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
5303 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
5304 /* Do the cleanups now, anly if we are not running asynchronously,
5305 of if we are, but the target is still synchronous. */
5306 if (!event_loop_p
|| !target_can_async_p ())
5307 do_cleanups (old_chain
);
5311 /* These aren't used; I don't konw what they were for. */
5312 /* Set a breakpoint at the catch clause for NAME. */
5314 catch_breakpoint (name
)
5320 disable_catch_breakpoint ()
5325 delete_catch_breakpoint ()
5330 enable_catch_breakpoint ()
5337 struct sal_chain
*next
;
5338 struct symtab_and_line sal
;
5342 /* Not really used -- invocation in handle_gnu_4_16_catch_command
5343 had been commented out in the v.4.16 sources, and stays
5344 disabled there now because "catch NAME" syntax isn't allowed.
5346 /* This isn't used; I don't know what it was for. */
5347 /* For each catch clause identified in ARGS, run FUNCTION
5348 with that clause as an argument. */
5349 static struct symtabs_and_lines
5350 map_catch_names (args
, function
)
5354 register char *p
= args
;
5356 struct symtabs_and_lines sals
;
5358 struct sal_chain
*sal_chain
= 0;
5362 error_no_arg ("one or more catch names");
5370 /* Don't swallow conditional part. */
5371 if (p1
[0] == 'i' && p1
[1] == 'f'
5372 && (p1
[2] == ' ' || p1
[2] == '\t'))
5378 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
5382 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
5383 error ("Arguments must be catch names.");
5389 struct sal_chain
*next
= (struct sal_chain
*)
5390 alloca (sizeof (struct sal_chain
));
5391 next
->next
= sal_chain
;
5392 next
->sal
= get_catch_sal (p
);
5397 printf_unfiltered ("No catch clause for exception %s.\n", p
);
5402 while (*p
== ' ' || *p
== '\t')
5408 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
5410 static struct symtabs_and_lines
5411 get_catch_sals (this_level_only
)
5412 int this_level_only
;
5414 register struct blockvector
*bl
;
5415 register struct block
*block
;
5416 int index
, have_default
= 0;
5418 struct symtabs_and_lines sals
;
5419 struct sal_chain
*sal_chain
= 0;
5420 char *blocks_searched
;
5422 /* Not sure whether an error message is always the correct response,
5423 but it's better than a core dump. */
5424 if (selected_frame
== NULL
)
5425 error ("No selected frame.");
5426 block
= get_frame_block (selected_frame
);
5427 pc
= selected_frame
->pc
;
5433 error ("No symbol table info available.\n");
5435 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
5436 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5437 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
5441 CORE_ADDR end
= BLOCK_END (block
) - 4;
5444 if (bl
!= blockvector_for_pc (end
, &index
))
5445 error ("blockvector blotch");
5446 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
5447 error ("blockvector botch");
5448 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
5451 /* Don't print out blocks that have gone by. */
5452 while (index
< last_index
5453 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
5456 while (index
< last_index
5457 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
5459 if (blocks_searched
[index
] == 0)
5461 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
5464 register struct symbol
*sym
;
5466 nsyms
= BLOCK_NSYMS (b
);
5468 for (i
= 0; i
< nsyms
; i
++)
5470 sym
= BLOCK_SYM (b
, i
);
5471 if (STREQ (SYMBOL_NAME (sym
), "default"))
5477 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
5479 struct sal_chain
*next
= (struct sal_chain
*)
5480 alloca (sizeof (struct sal_chain
));
5481 next
->next
= sal_chain
;
5482 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
),
5487 blocks_searched
[index
] = 1;
5493 if (sal_chain
&& this_level_only
)
5496 /* After handling the function's top-level block, stop.
5497 Don't continue to its superblock, the block of
5498 per-file symbols. */
5499 if (BLOCK_FUNCTION (block
))
5501 block
= BLOCK_SUPERBLOCK (block
);
5506 struct sal_chain
*tmp_chain
;
5508 /* Count the number of entries. */
5509 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
5510 tmp_chain
= tmp_chain
->next
)
5514 sals
.sals
= (struct symtab_and_line
*)
5515 xmalloc (index
* sizeof (struct symtab_and_line
));
5516 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
5517 sals
.sals
[index
] = sal_chain
->sal
;
5524 ep_skip_leading_whitespace (s
)
5527 if ((s
== NULL
) || (*s
== NULL
))
5529 while (isspace (**s
))
5533 /* This function examines a string, and attempts to find a token
5534 that might be an event name in the leading characters. If a
5535 possible match is found, a pointer to the last character of
5536 the token is returned. Else, NULL is returned. */
5539 ep_find_event_name_end (arg
)
5543 char *event_name_end
= NULL
;
5545 /* If we could depend upon the presense of strrpbrk, we'd use that... */
5549 /* We break out of the loop when we find a token delimiter.
5550 Basically, we're looking for alphanumerics and underscores;
5551 anything else delimites the token. */
5554 if (!isalnum (*s
) && (*s
!= '_'))
5560 return event_name_end
;
5564 /* This function attempts to parse an optional "if <cond>" clause
5565 from the arg string. If one is not found, it returns NULL.
5567 Else, it returns a pointer to the condition string. (It does not
5568 attempt to evaluate the string against a particular block.) And,
5569 it updates arg to point to the first character following the parsed
5570 if clause in the arg string. */
5573 ep_parse_optional_if_clause (arg
)
5578 if (((*arg
)[0] != 'i') || ((*arg
)[1] != 'f') || !isspace ((*arg
)[2]))
5581 /* Skip the "if" keyword. */
5584 /* Skip any extra leading whitespace, and record the start of the
5585 condition string. */
5586 ep_skip_leading_whitespace (arg
);
5589 /* Assume that the condition occupies the remainder of the arg string. */
5590 (*arg
) += strlen (cond_string
);
5595 /* This function attempts to parse an optional filename from the arg
5596 string. If one is not found, it returns NULL.
5598 Else, it returns a pointer to the parsed filename. (This function
5599 makes no attempt to verify that a file of that name exists, or is
5600 accessible.) And, it updates arg to point to the first character
5601 following the parsed filename in the arg string.
5603 Note that clients needing to preserve the returned filename for
5604 future access should copy it to their own buffers. */
5606 ep_parse_optional_filename (arg
)
5609 static char filename
[1024];
5614 if ((*arg_p
== '\0') || isspace (*arg_p
))
5632 /* Commands to deal with catching events, such as signals, exceptions,
5633 process start/exit, etc. */
5637 catch_fork
, catch_vfork
5641 #if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
5642 static void catch_fork_command_1
PARAMS ((catch_fork_kind fork_kind
,
5648 catch_fork_command_1 (fork_kind
, arg
, tempflag
, from_tty
)
5649 catch_fork_kind fork_kind
;
5654 char *cond_string
= NULL
;
5656 ep_skip_leading_whitespace (&arg
);
5658 /* The allowed syntax is:
5660 catch [v]fork if <cond>
5662 First, check if there's an if clause. */
5663 cond_string
= ep_parse_optional_if_clause (&arg
);
5665 if ((*arg
!= '\0') && !isspace (*arg
))
5666 error ("Junk at end of arguments.");
5668 /* If this target supports it, create a fork or vfork catchpoint
5669 and enable reporting of such events. */
5673 create_fork_event_catchpoint (tempflag
, cond_string
);
5676 create_vfork_event_catchpoint (tempflag
, cond_string
);
5679 error ("unsupported or unknown fork kind; cannot catch it");
5685 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5687 catch_exec_command_1 (arg
, tempflag
, from_tty
)
5692 char *cond_string
= NULL
;
5694 ep_skip_leading_whitespace (&arg
);
5696 /* The allowed syntax is:
5698 catch exec if <cond>
5700 First, check if there's an if clause. */
5701 cond_string
= ep_parse_optional_if_clause (&arg
);
5703 if ((*arg
!= '\0') && !isspace (*arg
))
5704 error ("Junk at end of arguments.");
5706 /* If this target supports it, create an exec catchpoint
5707 and enable reporting of such events. */
5708 create_exec_event_catchpoint (tempflag
, cond_string
);
5712 #if defined(SOLIB_ADD)
5714 catch_load_command_1 (arg
, tempflag
, from_tty
)
5719 char *dll_pathname
= NULL
;
5720 char *cond_string
= NULL
;
5722 ep_skip_leading_whitespace (&arg
);
5724 /* The allowed syntax is:
5726 catch load if <cond>
5727 catch load <filename>
5728 catch load <filename> if <cond>
5730 The user is not allowed to specify the <filename> after an
5733 We'll ignore the pathological case of a file named "if".
5735 First, check if there's an if clause. If so, then there
5736 cannot be a filename. */
5737 cond_string
= ep_parse_optional_if_clause (&arg
);
5739 /* If there was an if clause, then there cannot be a filename.
5740 Else, there might be a filename and an if clause. */
5741 if (cond_string
== NULL
)
5743 dll_pathname
= ep_parse_optional_filename (&arg
);
5744 ep_skip_leading_whitespace (&arg
);
5745 cond_string
= ep_parse_optional_if_clause (&arg
);
5748 if ((*arg
!= '\0') && !isspace (*arg
))
5749 error ("Junk at end of arguments.");
5751 /* Create a load breakpoint that only triggers when a load of
5752 the specified dll (or any dll, if no pathname was specified)
5754 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid
, tempflag
,
5755 dll_pathname
, cond_string
);
5759 catch_unload_command_1 (arg
, tempflag
, from_tty
)
5764 char *dll_pathname
= NULL
;
5765 char *cond_string
= NULL
;
5767 ep_skip_leading_whitespace (&arg
);
5769 /* The allowed syntax is:
5771 catch unload if <cond>
5772 catch unload <filename>
5773 catch unload <filename> if <cond>
5775 The user is not allowed to specify the <filename> after an
5778 We'll ignore the pathological case of a file named "if".
5780 First, check if there's an if clause. If so, then there
5781 cannot be a filename. */
5782 cond_string
= ep_parse_optional_if_clause (&arg
);
5784 /* If there was an if clause, then there cannot be a filename.
5785 Else, there might be a filename and an if clause. */
5786 if (cond_string
== NULL
)
5788 dll_pathname
= ep_parse_optional_filename (&arg
);
5789 ep_skip_leading_whitespace (&arg
);
5790 cond_string
= ep_parse_optional_if_clause (&arg
);
5793 if ((*arg
!= '\0') && !isspace (*arg
))
5794 error ("Junk at end of arguments.");
5796 /* Create an unload breakpoint that only triggers when an unload of
5797 the specified dll (or any dll, if no pathname was specified)
5799 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid
, tempflag
,
5800 dll_pathname
, cond_string
);
5802 #endif /* SOLIB_ADD */
5804 /* Commands to deal with catching exceptions. */
5806 /* Set a breakpoint at the specified callback routine for an
5807 exception event callback */
5810 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
)
5813 enum exception_event_kind ex_event
;
5814 struct symtab_and_line
*sal
;
5816 struct breakpoint
*b
;
5817 int thread
= -1; /* All threads. */
5819 if (!sal
) /* no exception support? */
5822 b
= set_raw_breakpoint (*sal
);
5823 set_breakpoint_count (breakpoint_count
+ 1);
5824 b
->number
= breakpoint_count
;
5826 b
->cond_string
= (cond_string
== NULL
) ?
5827 NULL
: savestring (cond_string
, strlen (cond_string
));
5829 b
->addr_string
= NULL
;
5830 b
->enable
= enabled
;
5831 b
->disposition
= tempflag
? del
: donttouch
;
5834 case EX_EVENT_THROW
:
5835 b
->type
= bp_catch_throw
;
5837 case EX_EVENT_CATCH
:
5838 b
->type
= bp_catch_catch
;
5840 default: /* error condition */
5842 b
->enable
= disabled
;
5843 error ("Internal error -- invalid catchpoint kind");
5848 /* Deal with "catch catch" and "catch throw" commands */
5851 catch_exception_command_1 (ex_event
, arg
, tempflag
, from_tty
)
5852 enum exception_event_kind ex_event
;
5857 char *cond_string
= NULL
;
5858 struct symtab_and_line
*sal
= NULL
;
5860 ep_skip_leading_whitespace (&arg
);
5862 cond_string
= ep_parse_optional_if_clause (&arg
);
5864 if ((*arg
!= '\0') && !isspace (*arg
))
5865 error ("Junk at end of arguments.");
5867 if ((ex_event
!= EX_EVENT_THROW
) &&
5868 (ex_event
!= EX_EVENT_CATCH
))
5869 error ("Unsupported or unknown exception event; cannot catch it");
5871 /* See if we can find a callback routine */
5872 sal
= target_enable_exception_callback (ex_event
, 1);
5876 /* We have callbacks from the runtime system for exceptions.
5877 Set a breakpoint on the sal found, if no errors */
5878 if (sal
!= (struct symtab_and_line
*) -1)
5879 create_exception_catchpoint (tempflag
, cond_string
, ex_event
, sal
);
5881 return; /* something went wrong with setting up callbacks */
5885 /* No callbacks from runtime system for exceptions.
5886 Try GNU C++ exception breakpoints using labels in debug info. */
5887 if (ex_event
== EX_EVENT_CATCH
)
5889 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
);
5891 else if (ex_event
== EX_EVENT_THROW
)
5893 /* Set a breakpoint on __raise_exception () */
5895 warning ("Unsupported with this platform/compiler combination.");
5896 warning ("Perhaps you can achieve the effect you want by setting");
5897 warning ("a breakpoint on __raise_exception().");
5902 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5903 inside a catch_errors */
5906 cover_target_enable_exception_callback (arg
)
5909 args_for_catchpoint_enable
*args
= arg
;
5910 struct symtab_and_line
*sal
;
5911 sal
= target_enable_exception_callback (args
->kind
, args
->enable
);
5914 else if (sal
== (struct symtab_and_line
*) -1)
5917 return 1; /*is valid */
5922 /* This is the original v.4.16 and earlier version of the
5923 catch_command_1() function. Now that other flavours of "catch"
5924 have been introduced, and since exception handling can be handled
5925 in other ways (through target ops) also, this is used only for the
5926 GNU C++ exception handling system.
5927 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5928 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5929 there was no code in GDB 4.16 for "catch throw".
5931 Called from catch_exception_command_1 () */
5935 handle_gnu_4_16_catch_command (arg
, tempflag
, from_tty
)
5940 /* First, translate ARG into something we can deal with in terms
5943 struct symtabs_and_lines sals
;
5944 struct symtab_and_line sal
;
5945 register struct expression
*cond
= 0;
5946 register struct breakpoint
*b
;
5950 INIT_SAL (&sal
); /* initialize to zeroes */
5952 /* If no arg given, or if first arg is 'if ', all active catch clauses
5953 are breakpointed. */
5955 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
5956 && (arg
[2] == ' ' || arg
[2] == '\t')))
5958 /* Grab all active catch clauses. */
5959 sals
= get_catch_sals (0);
5963 /* Grab selected catch clauses. */
5964 error ("catch NAME not implemented");
5967 /* Not sure why this code has been disabled. I'm leaving
5968 it disabled. We can never come here now anyway
5969 since we don't allow the "catch NAME" syntax.
5972 /* This isn't used; I don't know what it was for. */
5973 sals
= map_catch_names (arg
, catch_breakpoint
);
5981 for (i
= 0; i
< sals
.nelts
; i
++)
5983 resolve_sal_pc (&sals
.sals
[i
]);
5987 if (arg
[0] == 'i' && arg
[1] == 'f'
5988 && (arg
[2] == ' ' || arg
[2] == '\t'))
5989 cond
= parse_exp_1 ((arg
+= 2, &arg
),
5990 block_for_pc (sals
.sals
[i
].pc
), 0);
5992 error ("Junk at end of arguments.");
5997 for (i
= 0; i
< sals
.nelts
; i
++)
6002 describe_other_breakpoints (sal
.pc
, sal
.section
);
6004 b
= set_raw_breakpoint (sal
);
6005 set_breakpoint_count (breakpoint_count
+ 1);
6006 b
->number
= breakpoint_count
;
6008 /* Important -- this is an ordinary breakpoint. For platforms
6009 with callback support for exceptions,
6010 create_exception_catchpoint() will create special bp types
6011 (bp_catch_catch and bp_catch_throw), and there is code in
6012 insert_breakpoints() and elsewhere that depends on that. */
6013 b
->type
= bp_breakpoint
;
6016 b
->enable
= enabled
;
6017 b
->disposition
= tempflag
? del
: donttouch
;
6024 warning ("Multiple breakpoints were set.");
6025 warning ("Use the \"delete\" command to delete unwanted breakpoints.");
6027 free ((PTR
) sals
.sals
);
6031 /* This creates a temporary internal breakpoint
6032 just to placate infrun */
6033 static struct breakpoint
*
6034 create_temp_exception_breakpoint (pc
)
6037 struct symtab_and_line sal
;
6038 struct breakpoint
*b
;
6045 b
= set_raw_breakpoint (sal
);
6047 error ("Internal error -- couldn't set temp exception breakpoint");
6049 b
->type
= bp_breakpoint
;
6050 b
->disposition
= del
;
6051 b
->enable
= enabled
;
6053 b
->number
= internal_breakpoint_number
--;
6059 catch_command_1 (arg
, tempflag
, from_tty
)
6065 /* The first argument may be an event name, such as "start" or "load".
6066 If so, then handle it as such. If it doesn't match an event name,
6067 then attempt to interpret it as an exception name. (This latter is
6068 the v4.16-and-earlier GDB meaning of the "catch" command.)
6070 First, try to find the bounds of what might be an event name. */
6071 char *arg1_start
= arg
;
6075 if (arg1_start
== NULL
)
6077 /* Old behaviour was to use pre-v-4.16 syntax */
6078 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6080 /* Now, this is not allowed */
6081 error ("Catch requires an event name.");
6084 arg1_end
= ep_find_event_name_end (arg1_start
);
6085 if (arg1_end
== NULL
)
6086 error ("catch requires an event");
6087 arg1_length
= arg1_end
+ 1 - arg1_start
;
6089 /* Try to match what we found against known event names. */
6090 if (strncmp (arg1_start
, "signal", arg1_length
) == 0)
6092 error ("Catch of signal not yet implemented");
6094 else if (strncmp (arg1_start
, "catch", arg1_length
) == 0)
6096 catch_exception_command_1 (EX_EVENT_CATCH
, arg1_end
+ 1,
6097 tempflag
, from_tty
);
6099 else if (strncmp (arg1_start
, "throw", arg1_length
) == 0)
6101 catch_exception_command_1 (EX_EVENT_THROW
, arg1_end
+ 1,
6102 tempflag
, from_tty
);
6104 else if (strncmp (arg1_start
, "thread_start", arg1_length
) == 0)
6106 error ("Catch of thread_start not yet implemented");
6108 else if (strncmp (arg1_start
, "thread_exit", arg1_length
) == 0)
6110 error ("Catch of thread_exit not yet implemented");
6112 else if (strncmp (arg1_start
, "thread_join", arg1_length
) == 0)
6114 error ("Catch of thread_join not yet implemented");
6116 else if (strncmp (arg1_start
, "start", arg1_length
) == 0)
6118 error ("Catch of start not yet implemented");
6120 else if (strncmp (arg1_start
, "exit", arg1_length
) == 0)
6122 error ("Catch of exit not yet implemented");
6124 else if (strncmp (arg1_start
, "fork", arg1_length
) == 0)
6126 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
6127 catch_fork_command_1 (catch_fork
, arg1_end
+ 1, tempflag
, from_tty
);
6129 error ("Catch of fork not yet implemented");
6132 else if (strncmp (arg1_start
, "vfork", arg1_length
) == 0)
6134 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
6135 catch_fork_command_1 (catch_vfork
, arg1_end
+ 1, tempflag
, from_tty
);
6137 error ("Catch of vfork not yet implemented");
6140 else if (strncmp (arg1_start
, "exec", arg1_length
) == 0)
6142 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
6143 catch_exec_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6145 error ("Catch of exec not yet implemented");
6148 else if (strncmp (arg1_start
, "load", arg1_length
) == 0)
6150 #if defined(SOLIB_ADD)
6151 catch_load_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6153 error ("Catch of load not implemented");
6156 else if (strncmp (arg1_start
, "unload", arg1_length
) == 0)
6158 #if defined(SOLIB_ADD)
6159 catch_unload_command_1 (arg1_end
+ 1, tempflag
, from_tty
);
6161 error ("Catch of load not implemented");
6164 else if (strncmp (arg1_start
, "stop", arg1_length
) == 0)
6166 error ("Catch of stop not yet implemented");
6169 /* This doesn't appear to be an event name */
6173 /* Pre-v.4.16 behaviour was to treat the argument
6174 as the name of an exception */
6175 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
6176 /* Now this is not allowed */
6177 error ("Unknown event kind specified for catch");
6182 /* Used by the gui, could be made a worker for other things. */
6185 set_breakpoint_sal (sal
)
6186 struct symtab_and_line sal
;
6188 struct breakpoint
*b
;
6189 b
= set_raw_breakpoint (sal
);
6190 set_breakpoint_count (breakpoint_count
+ 1);
6191 b
->number
= breakpoint_count
;
6192 b
->type
= bp_breakpoint
;
6199 /* These aren't used; I don't know what they were for. */
6200 /* Disable breakpoints on all catch clauses described in ARGS. */
6202 disable_catch (args
)
6205 /* Map the disable command to catch clauses described in ARGS. */
6208 /* Enable breakpoints on all catch clauses described in ARGS. */
6213 /* Map the disable command to catch clauses described in ARGS. */
6216 /* Delete breakpoints on all catch clauses in the active scope. */
6221 /* Map the delete command to catch clauses described in ARGS. */
6226 catch_command (arg
, from_tty
)
6230 catch_command_1 (arg
, 0, from_tty
);
6235 tcatch_command (arg
, from_tty
)
6239 catch_command_1 (arg
, 1, from_tty
);
6244 clear_command (arg
, from_tty
)
6248 register struct breakpoint
*b
, *b1
;
6250 struct symtabs_and_lines sals
;
6251 struct symtab_and_line sal
;
6252 register struct breakpoint
*found
;
6257 sals
= decode_line_spec (arg
, 1);
6262 sals
.sals
= (struct symtab_and_line
*)
6263 xmalloc (sizeof (struct symtab_and_line
));
6264 INIT_SAL (&sal
); /* initialize to zeroes */
6265 sal
.line
= default_breakpoint_line
;
6266 sal
.symtab
= default_breakpoint_symtab
;
6267 sal
.pc
= default_breakpoint_address
;
6268 if (sal
.symtab
== 0)
6269 error ("No source file specified.");
6277 /* For each line spec given, delete bps which correspond
6278 to it. We do this in two loops: the first loop looks at
6279 the initial bp(s) in the chain which should be deleted,
6280 the second goes down the rest of the chain looking ahead
6281 one so it can take those bps off the chain without messing
6285 for (i
= 0; i
< sals
.nelts
; i
++)
6287 /* If exact pc given, clear bpts at that pc.
6288 If line given (pc == 0), clear all bpts on specified line.
6289 If defaulting, clear all bpts on default line
6292 defaulting sal.pc != 0 tests to do
6297 1 0 <can't happen> */
6300 found
= (struct breakpoint
*) 0;
6303 while (breakpoint_chain
6304 /* Why don't we check here that this is not
6305 a watchpoint, etc., as we do below?
6306 I can't make it fail, but don't know
6307 what's stopping the failure: a watchpoint
6308 of the same address as "sal.pc" should
6309 wind up being deleted. */
6311 && (((sal
.pc
&& (breakpoint_chain
->address
== sal
.pc
)) &&
6312 (overlay_debugging
== 0 ||
6313 breakpoint_chain
->section
== sal
.section
))
6314 || ((default_match
|| (0 == sal
.pc
))
6315 && breakpoint_chain
->source_file
!= NULL
6316 && sal
.symtab
!= NULL
6317 && STREQ (breakpoint_chain
->source_file
, sal
.symtab
->filename
)
6318 && breakpoint_chain
->line_number
== sal
.line
)))
6321 b1
= breakpoint_chain
;
6322 breakpoint_chain
= b1
->next
;
6330 && b
->next
->type
!= bp_none
6331 && b
->next
->type
!= bp_watchpoint
6332 && b
->next
->type
!= bp_hardware_watchpoint
6333 && b
->next
->type
!= bp_read_watchpoint
6334 && b
->next
->type
!= bp_access_watchpoint
6335 && (((sal
.pc
&& (b
->next
->address
== sal
.pc
)) &&
6336 (overlay_debugging
== 0 ||
6337 b
->next
->section
== sal
.section
))
6338 || ((default_match
|| (0 == sal
.pc
))
6339 && b
->next
->source_file
!= NULL
6340 && sal
.symtab
!= NULL
6341 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
6342 && b
->next
->line_number
== sal
.line
)))
6355 error ("No breakpoint at %s.", arg
);
6357 error ("No breakpoint at this line.");
6361 from_tty
= 1; /* Always report if deleted more than one */
6363 printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
6364 breakpoints_changed ();
6368 printf_unfiltered ("%d ", found
->number
);
6370 delete_breakpoint (found
);
6374 putchar_unfiltered ('\n');
6376 free ((PTR
) sals
.sals
);
6379 /* Delete breakpoint in BS if they are `delete' breakpoints and
6380 all breakpoints that are marked for deletion, whether hit or not.
6381 This is called after any breakpoint is hit, or after errors. */
6384 breakpoint_auto_delete (bs
)
6387 struct breakpoint
*b
, *temp
;
6389 for (; bs
; bs
= bs
->next
)
6390 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
6392 delete_breakpoint (bs
->breakpoint_at
);
6394 ALL_BREAKPOINTS_SAFE (b
, temp
)
6396 if (b
->disposition
== del_at_next_stop
)
6397 delete_breakpoint (b
);
6401 /* Delete a breakpoint and clean up all traces of it in the data
6405 delete_breakpoint (bpt
)
6406 struct breakpoint
*bpt
;
6408 register struct breakpoint
*b
;
6412 error ("Internal error (attempted to delete a NULL breakpoint)");
6415 /* Has this bp already been deleted? This can happen because multiple
6416 lists can hold pointers to bp's. bpstat lists are especial culprits.
6418 One example of this happening is a watchpoint's scope bp. When the
6419 scope bp triggers, we notice that the watchpoint is out of scope, and
6420 delete it. We also delete its scope bp. But the scope bp is marked
6421 "auto-deleting", and is already on a bpstat. That bpstat is then
6422 checked for auto-deleting bp's, which are deleted.
6424 A real solution to this problem might involve reference counts in bp's,
6425 and/or giving them pointers back to their referencing bpstat's, and
6426 teaching delete_breakpoint to only free a bp's storage when no more
6427 references were extent. A cheaper bandaid was chosen. */
6428 if (bpt
->type
== bp_none
)
6431 if (delete_breakpoint_hook
)
6432 delete_breakpoint_hook (bpt
);
6433 breakpoint_delete_event (bpt
->number
);
6436 remove_breakpoint (bpt
, mark_uninserted
);
6438 if (breakpoint_chain
== bpt
)
6439 breakpoint_chain
= bpt
->next
;
6441 /* If we have callback-style exception catchpoints, don't go through
6442 the adjustments to the C++ runtime library etc. if the inferior
6443 isn't actually running. target_enable_exception_callback for a
6444 null target ops vector gives an undesirable error message, so we
6445 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
6446 exceptions are supported in this way, it's OK for now. FIXME */
6447 if (ep_is_exception_catchpoint (bpt
) && target_has_execution
)
6449 static char message1
[] = "Error in deleting catchpoint %d:\n";
6450 static char message
[sizeof (message1
) + 30];
6451 args_for_catchpoint_enable args
;
6453 /* Format possible error msg */
6454 sprintf (message
, message1
, bpt
->number
);
6455 args
.kind
= bpt
->type
== bp_catch_catch
?
6456 EX_EVENT_CATCH
: EX_EVENT_THROW
;
6458 catch_errors (cover_target_enable_exception_callback
, &args
,
6459 message
, RETURN_MASK_ALL
);
6466 b
->next
= bpt
->next
;
6470 /* Before turning off the visuals for the bp, check to see that
6471 there are no other bps at the same address. */
6478 clearIt
= (b
->address
!= bpt
->address
);
6485 TUIDO (((TuiOpaqueFuncPtr
) tui_vAllSetHasBreakAt
, bpt
, 0));
6486 TUIDO (((TuiOpaqueFuncPtr
) tuiUpdateAllExecInfos
));
6490 check_duplicates (bpt
->address
, bpt
->section
);
6491 /* If this breakpoint was inserted, and there is another breakpoint
6492 at the same address, we need to insert the other breakpoint. */
6494 && bpt
->type
!= bp_hardware_watchpoint
6495 && bpt
->type
!= bp_read_watchpoint
6496 && bpt
->type
!= bp_access_watchpoint
6497 && bpt
->type
!= bp_catch_fork
6498 && bpt
->type
!= bp_catch_vfork
6499 && bpt
->type
!= bp_catch_exec
)
6502 if (b
->address
== bpt
->address
6503 && b
->section
== bpt
->section
6505 && b
->enable
!= disabled
6506 && b
->enable
!= shlib_disabled
6507 && b
->enable
!= call_disabled
)
6511 /* We should never reach this point if there is a permanent
6512 breakpoint at the same address as the one being deleted.
6513 If there is a permanent breakpoint somewhere, it should
6514 always be the only one inserted. */
6515 if (b
->enable
== permanent
)
6516 internal_error ("another breakpoint was inserted on top of "
6517 "a permanent breakpoint");
6519 if (b
->type
== bp_hardware_breakpoint
)
6520 val
= target_insert_hw_breakpoint (b
->address
, b
->shadow_contents
);
6522 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
6526 target_terminal_ours_for_output ();
6527 warning ("Cannot insert breakpoint %d:", b
->number
);
6528 memory_error (val
, b
->address
); /* which bombs us out */
6535 free_command_lines (&bpt
->commands
);
6538 if (bpt
->cond_string
!= NULL
)
6539 free (bpt
->cond_string
);
6540 if (bpt
->addr_string
!= NULL
)
6541 free (bpt
->addr_string
);
6542 if (bpt
->exp
!= NULL
)
6544 if (bpt
->exp_string
!= NULL
)
6545 free (bpt
->exp_string
);
6546 if (bpt
->val
!= NULL
)
6547 value_free (bpt
->val
);
6548 if (bpt
->source_file
!= NULL
)
6549 free (bpt
->source_file
);
6550 if (bpt
->dll_pathname
!= NULL
)
6551 free (bpt
->dll_pathname
);
6552 if (bpt
->triggered_dll_pathname
!= NULL
)
6553 free (bpt
->triggered_dll_pathname
);
6554 if (bpt
->exec_pathname
!= NULL
)
6555 free (bpt
->exec_pathname
);
6557 /* Be sure no bpstat's are pointing at it after it's been freed. */
6558 /* FIXME, how can we find all bpstat's?
6559 We just check stop_bpstat for now. */
6560 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
6561 if (bs
->breakpoint_at
== bpt
)
6563 bs
->breakpoint_at
= NULL
;
6565 /* we'd call bpstat_clear_actions, but that free's stuff and due
6566 to the multiple pointers pointing to one item with no
6567 reference counts found anywhere through out the bpstat's (how
6568 do you spell fragile?), we don't want to free things twice --
6569 better a memory leak than a corrupt malloc pool! */
6570 bs
->commands
= NULL
;
6573 /* On the chance that someone will soon try again to delete this same
6574 bp, we mark it as deleted before freeing its storage. */
6575 bpt
->type
= bp_none
;
6581 delete_command (arg
, from_tty
)
6585 struct breakpoint
*b
, *temp
;
6589 int breaks_to_delete
= 0;
6591 /* Delete all breakpoints if no argument.
6592 Do not delete internal or call-dummy breakpoints, these
6593 have to be deleted with an explicit breakpoint number argument. */
6596 if (b
->type
!= bp_call_dummy
&&
6597 b
->type
!= bp_shlib_event
&&
6598 b
->type
!= bp_thread_event
&&
6600 breaks_to_delete
= 1;
6603 /* Ask user only if there are some breakpoints to delete. */
6605 || (breaks_to_delete
&& query ("Delete all breakpoints? ")))
6607 ALL_BREAKPOINTS_SAFE (b
, temp
)
6609 if (b
->type
!= bp_call_dummy
&&
6610 b
->type
!= bp_shlib_event
&&
6611 b
->type
!= bp_thread_event
&&
6613 delete_breakpoint (b
);
6618 map_breakpoint_numbers (arg
, delete_breakpoint
);
6621 /* Reset a breakpoint given it's struct breakpoint * BINT.
6622 The value we return ends up being the return value from catch_errors.
6623 Unused in this case. */
6626 breakpoint_re_set_one (bint
)
6629 /* get past catch_errs */
6630 struct breakpoint
*b
= (struct breakpoint
*) bint
;
6633 struct symtabs_and_lines sals
;
6635 enum enable save_enable
;
6640 warning ("attempted to reset apparently deleted breakpoint #%d?",
6644 case bp_hardware_breakpoint
:
6646 case bp_catch_unload
:
6647 if (b
->addr_string
== NULL
)
6649 /* Anything without a string can't be re-set. */
6650 delete_breakpoint (b
);
6653 /* In case we have a problem, disable this breakpoint. We'll restore
6654 its status if we succeed. */
6655 save_enable
= b
->enable
;
6656 b
->enable
= disabled
;
6658 set_language (b
->language
);
6659 input_radix
= b
->input_radix
;
6661 sals
= decode_line_1 (&s
, 1, (struct symtab
*) NULL
, 0, (char ***) NULL
);
6662 for (i
= 0; i
< sals
.nelts
; i
++)
6664 resolve_sal_pc (&sals
.sals
[i
]);
6666 /* Reparse conditions, they might contain references to the
6668 if (b
->cond_string
!= NULL
)
6672 free ((PTR
) b
->cond
);
6673 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
6676 /* We need to re-set the breakpoint if the address changes... */
6677 if (b
->address
!= sals
.sals
[i
].pc
6678 /* ...or new and old breakpoints both have source files, and
6679 the source file name or the line number changes... */
6680 || (b
->source_file
!= NULL
6681 && sals
.sals
[i
].symtab
!= NULL
6682 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
6683 || b
->line_number
!= sals
.sals
[i
].line
)
6685 /* ...or we switch between having a source file and not having
6687 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
6690 if (b
->source_file
!= NULL
)
6691 free (b
->source_file
);
6692 if (sals
.sals
[i
].symtab
== NULL
)
6693 b
->source_file
= NULL
;
6696 savestring (sals
.sals
[i
].symtab
->filename
,
6697 strlen (sals
.sals
[i
].symtab
->filename
));
6698 b
->line_number
= sals
.sals
[i
].line
;
6699 b
->address
= sals
.sals
[i
].pc
;
6701 /* Used to check for duplicates here, but that can
6702 cause trouble, as it doesn't check for disable
6707 /* Might be better to do this just once per breakpoint_re_set,
6708 rather than once for every breakpoint. */
6709 breakpoints_changed ();
6711 b
->section
= sals
.sals
[i
].section
;
6712 b
->enable
= save_enable
; /* Restore it, this worked. */
6715 /* Now that this is re-enabled, check_duplicates
6717 check_duplicates (b
->address
, b
->section
);
6720 free ((PTR
) sals
.sals
);
6724 case bp_hardware_watchpoint
:
6725 case bp_read_watchpoint
:
6726 case bp_access_watchpoint
:
6727 innermost_block
= NULL
;
6728 /* The issue arises of what context to evaluate this in. The
6729 same one as when it was set, but what does that mean when
6730 symbols have been re-read? We could save the filename and
6731 functionname, but if the context is more local than that, the
6732 best we could do would be something like how many levels deep
6733 and which index at that particular level, but that's going to
6734 be less stable than filenames or function names. */
6736 /* So for now, just use a global context. */
6738 free ((PTR
) b
->exp
);
6739 b
->exp
= parse_expression (b
->exp_string
);
6740 b
->exp_valid_block
= innermost_block
;
6741 mark
= value_mark ();
6743 value_free (b
->val
);
6744 b
->val
= evaluate_expression (b
->exp
);
6745 release_value (b
->val
);
6746 if (VALUE_LAZY (b
->val
))
6747 value_fetch_lazy (b
->val
);
6749 if (b
->cond_string
!= NULL
)
6753 free ((PTR
) b
->cond
);
6754 b
->cond
= parse_exp_1 (&s
, (struct block
*) 0, 0);
6756 if (b
->enable
== enabled
)
6758 value_free_to_mark (mark
);
6760 case bp_catch_catch
:
6761 case bp_catch_throw
:
6763 /* We needn't really do anything to reset these, since the mask
6764 that requests them is unaffected by e.g., new libraries being
6767 case bp_catch_vfork
:
6772 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
6774 /* Delete longjmp breakpoints, they will be reset later by
6775 breakpoint_re_set. */
6777 case bp_longjmp_resume
:
6778 delete_breakpoint (b
);
6781 /* This breakpoint is special, it's set up when the inferior
6782 starts and we really don't want to touch it. */
6783 case bp_shlib_event
:
6785 /* Like bp_shlib_event, this breakpoint type is special.
6786 Once it is set up, we do not want to touch it. */
6787 case bp_thread_event
:
6789 /* Keep temporary breakpoints, which can be encountered when we step
6790 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6791 Otherwise these should have been blown away via the cleanup chain
6792 or by breakpoint_init_inferior when we rerun the executable. */
6795 case bp_watchpoint_scope
:
6797 case bp_step_resume
:
6804 /* Re-set all breakpoints after symbols have been re-loaded. */
6806 breakpoint_re_set ()
6808 struct breakpoint
*b
, *temp
;
6809 enum language save_language
;
6810 int save_input_radix
;
6811 static char message1
[] = "Error in re-setting breakpoint %d:\n";
6812 char message
[sizeof (message1
) + 30 /* slop */ ];
6814 save_language
= current_language
->la_language
;
6815 save_input_radix
= input_radix
;
6816 ALL_BREAKPOINTS_SAFE (b
, temp
)
6818 /* Format possible error msg */
6819 sprintf (message
, message1
, b
->number
);
6820 catch_errors (breakpoint_re_set_one
, b
, message
, RETURN_MASK_ALL
);
6822 set_language (save_language
);
6823 input_radix
= save_input_radix
;
6825 #ifdef GET_LONGJMP_TARGET
6826 create_longjmp_breakpoint ("longjmp");
6827 create_longjmp_breakpoint ("_longjmp");
6828 create_longjmp_breakpoint ("siglongjmp");
6829 create_longjmp_breakpoint ("_siglongjmp");
6830 create_longjmp_breakpoint (NULL
);
6834 /* Took this out (temporarily at least), since it produces an extra
6835 blank line at startup. This messes up the gdbtests. -PB */
6836 /* Blank line to finish off all those mention() messages we just printed. */
6837 printf_filtered ("\n");
6841 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6842 If from_tty is nonzero, it prints a message to that effect,
6843 which ends with a period (no newline). */
6845 /* Reset the thread number of this breakpoint:
6847 - If the breakpoint is for all threads, leave it as-is.
6848 - Else, reset it to the current thread for inferior_pid. */
6850 breakpoint_re_set_thread (b
)
6851 struct breakpoint
*b
;
6853 if (b
->thread
!= -1)
6855 if (in_thread_list (inferior_pid
))
6856 b
->thread
= pid_to_thread_id (inferior_pid
);
6861 set_ignore_count (bptnum
, count
, from_tty
)
6862 int bptnum
, count
, from_tty
;
6864 register struct breakpoint
*b
;
6870 if (b
->number
== bptnum
)
6872 b
->ignore_count
= count
;
6875 else if (count
== 0)
6876 printf_filtered ("Will stop next time breakpoint %d is reached.",
6878 else if (count
== 1)
6879 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6882 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6884 breakpoints_changed ();
6888 error ("No breakpoint number %d.", bptnum
);
6891 /* Clear the ignore counts of all breakpoints. */
6893 breakpoint_clear_ignore_counts ()
6895 struct breakpoint
*b
;
6898 b
->ignore_count
= 0;
6901 /* Command to set ignore-count of breakpoint N to COUNT. */
6904 ignore_command (args
, from_tty
)
6912 error_no_arg ("a breakpoint number");
6914 num
= get_number (&p
);
6916 error ("bad breakpoint number: '%s'", args
);
6918 error ("Second argument (specified ignore-count) is missing.");
6920 set_ignore_count (num
,
6921 longest_to_int (value_as_long (parse_and_eval (p
))),
6923 printf_filtered ("\n");
6924 breakpoints_changed ();
6927 /* Call FUNCTION on each of the breakpoints
6928 whose numbers are given in ARGS. */
6931 map_breakpoint_numbers (args
, function
)
6933 void (*function
) PARAMS ((struct breakpoint
*));
6935 register char *p
= args
;
6938 register struct breakpoint
*b
, *tmp
;
6942 error_no_arg ("one or more breakpoint numbers");
6949 num
= get_number_or_range (&p1
);
6952 warning ("bad breakpoint number at or near '%s'", p
);
6956 ALL_BREAKPOINTS_SAFE (b
, tmp
)
6957 if (b
->number
== num
)
6959 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
6962 if (related_breakpoint
)
6963 function (related_breakpoint
);
6967 printf_unfiltered ("No breakpoint number %d.\n", num
);
6974 disable_breakpoint (bpt
)
6975 struct breakpoint
*bpt
;
6977 /* Never disable a watchpoint scope breakpoint; we want to
6978 hit them when we leave scope so we can delete both the
6979 watchpoint and its scope breakpoint at that time. */
6980 if (bpt
->type
== bp_watchpoint_scope
)
6983 /* You can't disable permanent breakpoints. */
6984 if (bpt
->enable
== permanent
)
6987 bpt
->enable
= disabled
;
6989 check_duplicates (bpt
->address
, bpt
->section
);
6991 if (modify_breakpoint_hook
)
6992 modify_breakpoint_hook (bpt
);
6993 breakpoint_modify_event (bpt
->number
);
6998 disable_command (args
, from_tty
)
7002 register struct breakpoint
*bpt
;
7004 ALL_BREAKPOINTS (bpt
)
7008 warning ("attempted to disable apparently deleted breakpoint #%d?",
7013 case bp_catch_unload
:
7015 case bp_catch_vfork
:
7017 case bp_catch_catch
:
7018 case bp_catch_throw
:
7019 case bp_hardware_breakpoint
:
7021 case bp_hardware_watchpoint
:
7022 case bp_read_watchpoint
:
7023 case bp_access_watchpoint
:
7024 disable_breakpoint (bpt
);
7029 map_breakpoint_numbers (args
, disable_breakpoint
);
7033 do_enable_breakpoint (bpt
, disposition
)
7034 struct breakpoint
*bpt
;
7035 enum bpdisp disposition
;
7037 struct frame_info
*save_selected_frame
= NULL
;
7038 int save_selected_frame_level
= -1;
7039 int target_resources_ok
, other_type_used
;
7042 if (bpt
->type
== bp_hardware_breakpoint
)
7045 i
= hw_breakpoint_used_count ();
7046 target_resources_ok
=
7047 TARGET_CAN_USE_HARDWARE_WATCHPOINT (bp_hardware_breakpoint
,
7049 if (target_resources_ok
== 0)
7050 error ("No hardware breakpoint support in the target.");
7051 else if (target_resources_ok
< 0)
7052 error ("Hardware breakpoints used exceeds limit.");
7055 if (bpt
->enable
!= permanent
)
7056 bpt
->enable
= enabled
;
7057 bpt
->disposition
= disposition
;
7058 check_duplicates (bpt
->address
, bpt
->section
);
7059 breakpoints_changed ();
7061 if (bpt
->type
== bp_watchpoint
||
7062 bpt
->type
== bp_hardware_watchpoint
||
7063 bpt
->type
== bp_read_watchpoint
||
7064 bpt
->type
== bp_access_watchpoint
)
7066 if (bpt
->exp_valid_block
!= NULL
)
7068 struct frame_info
*fr
=
7070 /* Ensure that we have the current frame. Else, this
7071 next query may pessimistically be answered as, "No,
7072 not within current scope". */
7073 get_current_frame ();
7074 fr
= find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
7078 Cannot enable watchpoint %d because the block in which its expression\n\
7079 is valid is not currently in scope.\n", bpt
->number
);
7080 bpt
->enable
= disabled
;
7084 save_selected_frame
= selected_frame
;
7085 save_selected_frame_level
= selected_frame_level
;
7086 select_frame (fr
, -1);
7089 value_free (bpt
->val
);
7090 mark
= value_mark ();
7091 bpt
->val
= evaluate_expression (bpt
->exp
);
7092 release_value (bpt
->val
);
7093 if (VALUE_LAZY (bpt
->val
))
7094 value_fetch_lazy (bpt
->val
);
7096 if (bpt
->type
== bp_hardware_watchpoint
||
7097 bpt
->type
== bp_read_watchpoint
||
7098 bpt
->type
== bp_access_watchpoint
)
7100 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
7101 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
7103 /* Hack around 'unused var' error for some targets here */
7105 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
7106 bpt
->type
, i
+ mem_cnt
, other_type_used
);
7107 /* we can consider of type is bp_hardware_watchpoint, convert to
7108 bp_watchpoint in the following condition */
7109 if (target_resources_ok
< 0)
7112 Cannot enable watchpoint %d because target watch resources\n\
7113 have been allocated for other watchpoints.\n", bpt
->number
);
7114 bpt
->enable
= disabled
;
7115 value_free_to_mark (mark
);
7120 if (save_selected_frame_level
>= 0)
7121 select_and_print_frame (save_selected_frame
,
7122 save_selected_frame_level
);
7123 value_free_to_mark (mark
);
7125 if (modify_breakpoint_hook
)
7126 modify_breakpoint_hook (bpt
);
7127 breakpoint_modify_event (bpt
->number
);
7131 enable_breakpoint (bpt
)
7132 struct breakpoint
*bpt
;
7134 do_enable_breakpoint (bpt
, bpt
->disposition
);
7137 /* The enable command enables the specified breakpoints (or all defined
7138 breakpoints) so they once again become (or continue to be) effective
7139 in stopping the inferior. */
7143 enable_command (args
, from_tty
)
7147 register struct breakpoint
*bpt
;
7149 ALL_BREAKPOINTS (bpt
)
7153 warning ("attempted to enable apparently deleted breakpoint #%d?",
7158 case bp_catch_unload
:
7160 case bp_catch_vfork
:
7162 case bp_catch_catch
:
7163 case bp_catch_throw
:
7164 case bp_hardware_breakpoint
:
7166 case bp_hardware_watchpoint
:
7167 case bp_read_watchpoint
:
7168 case bp_access_watchpoint
:
7169 enable_breakpoint (bpt
);
7174 map_breakpoint_numbers (args
, enable_breakpoint
);
7178 enable_once_breakpoint (bpt
)
7179 struct breakpoint
*bpt
;
7181 do_enable_breakpoint (bpt
, disable
);
7186 enable_once_command (args
, from_tty
)
7190 map_breakpoint_numbers (args
, enable_once_breakpoint
);
7194 enable_delete_breakpoint (bpt
)
7195 struct breakpoint
*bpt
;
7197 do_enable_breakpoint (bpt
, del
);
7202 enable_delete_command (args
, from_tty
)
7206 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
7209 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
7211 struct symtabs_and_lines
7212 decode_line_spec_1 (string
, funfirstline
)
7216 struct symtabs_and_lines sals
;
7218 error ("Empty line specification.");
7219 if (default_breakpoint_valid
)
7220 sals
= decode_line_1 (&string
, funfirstline
,
7221 default_breakpoint_symtab
,
7222 default_breakpoint_line
,
7225 sals
= decode_line_1 (&string
, funfirstline
,
7226 (struct symtab
*) NULL
, 0, (char ***) NULL
);
7228 error ("Junk at end of line specification: %s", string
);
7233 _initialize_breakpoint ()
7235 struct cmd_list_element
*c
;
7237 breakpoint_chain
= 0;
7238 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
7239 before a breakpoint is set. */
7240 breakpoint_count
= 0;
7242 add_com ("ignore", class_breakpoint
, ignore_command
,
7243 "Set ignore-count of breakpoint number N to COUNT.\n\
7244 Usage is `ignore N COUNT'.");
7246 add_com_alias ("bc", "ignore", class_breakpoint
, 1);
7248 add_com ("commands", class_breakpoint
, commands_command
,
7249 "Set commands to be executed when a breakpoint is hit.\n\
7250 Give breakpoint number as argument after \"commands\".\n\
7251 With no argument, the targeted breakpoint is the last one set.\n\
7252 The commands themselves follow starting on the next line.\n\
7253 Type a line containing \"end\" to indicate the end of them.\n\
7254 Give \"silent\" as the first line to make the breakpoint silent;\n\
7255 then no output is printed when it is hit, except what the commands print.");
7257 add_com ("condition", class_breakpoint
, condition_command
,
7258 "Specify breakpoint number N to break only if COND is true.\n\
7259 Usage is `condition N COND', where N is an integer and COND is an\n\
7260 expression to be evaluated whenever breakpoint N is reached. ");
7262 add_com ("tbreak", class_breakpoint
, tbreak_command
,
7263 "Set a temporary breakpoint. Args like \"break\" command.\n\
7264 Like \"break\" except the breakpoint is only temporary,\n\
7265 so it will be deleted when hit. Equivalent to \"break\" followed\n\
7266 by using \"enable delete\" on the breakpoint number.");
7267 add_com ("txbreak", class_breakpoint
, tbreak_at_finish_command
,
7268 "Set temporary breakpoint at procedure exit. Either there should\n\
7269 be no argument or the argument must be a depth.\n");
7271 add_com ("hbreak", class_breakpoint
, hbreak_command
,
7272 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
7273 Like \"break\" except the breakpoint requires hardware support,\n\
7274 some target hardware may not have this support.");
7276 add_com ("thbreak", class_breakpoint
, thbreak_command
,
7277 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
7278 Like \"hbreak\" except the breakpoint is only temporary,\n\
7279 so it will be deleted when hit.");
7281 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
7282 "Enable some breakpoints.\n\
7283 Give breakpoint numbers (separated by spaces) as arguments.\n\
7284 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7285 This is used to cancel the effect of the \"disable\" command.\n\
7286 With a subcommand you can enable temporarily.",
7287 &enablelist
, "enable ", 1, &cmdlist
);
7289 add_com ("ab", class_breakpoint
, enable_command
,
7290 "Enable some breakpoints.\n\
7291 Give breakpoint numbers (separated by spaces) as arguments.\n\
7292 With no subcommand, breakpoints are enabled until you command otherwise.\n\
7293 This is used to cancel the effect of the \"disable\" command.\n\
7294 With a subcommand you can enable temporarily.");
7296 add_com_alias ("en", "enable", class_breakpoint
, 1);
7298 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
7299 "Enable some breakpoints.\n\
7300 Give breakpoint numbers (separated by spaces) as arguments.\n\
7301 This is used to cancel the effect of the \"disable\" command.\n\
7302 May be abbreviated to simply \"enable\".\n",
7303 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
7305 add_cmd ("once", no_class
, enable_once_command
,
7306 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7307 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7310 add_cmd ("delete", no_class
, enable_delete_command
,
7311 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7312 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7315 add_cmd ("delete", no_class
, enable_delete_command
,
7316 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
7317 If a breakpoint is hit while enabled in this fashion, it is deleted.",
7320 add_cmd ("once", no_class
, enable_once_command
,
7321 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
7322 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
7325 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
7326 "Disable some breakpoints.\n\
7327 Arguments are breakpoint numbers with spaces in between.\n\
7328 To disable all breakpoints, give no argument.\n\
7329 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
7330 &disablelist
, "disable ", 1, &cmdlist
);
7331 add_com_alias ("dis", "disable", class_breakpoint
, 1);
7332 add_com_alias ("disa", "disable", class_breakpoint
, 1);
7334 add_com ("sb", class_breakpoint
, disable_command
,
7335 "Disable some breakpoints.\n\
7336 Arguments are breakpoint numbers with spaces in between.\n\
7337 To disable all breakpoints, give no argument.\n\
7338 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
7340 add_cmd ("breakpoints", class_alias
, disable_command
,
7341 "Disable some breakpoints.\n\
7342 Arguments are breakpoint numbers with spaces in between.\n\
7343 To disable all breakpoints, give no argument.\n\
7344 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
7345 This command may be abbreviated \"disable\".",
7348 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
7349 "Delete some breakpoints or auto-display expressions.\n\
7350 Arguments are breakpoint numbers with spaces in between.\n\
7351 To delete all breakpoints, give no argument.\n\
7353 Also a prefix command for deletion of other GDB objects.\n\
7354 The \"unset\" command is also an alias for \"delete\".",
7355 &deletelist
, "delete ", 1, &cmdlist
);
7356 add_com_alias ("d", "delete", class_breakpoint
, 1);
7358 add_com ("db", class_breakpoint
, delete_command
,
7359 "Delete some breakpoints.\n\
7360 Arguments are breakpoint numbers with spaces in between.\n\
7361 To delete all breakpoints, give no argument.\n");
7363 add_cmd ("breakpoints", class_alias
, delete_command
,
7364 "Delete some breakpoints or auto-display expressions.\n\
7365 Arguments are breakpoint numbers with spaces in between.\n\
7366 To delete all breakpoints, give no argument.\n\
7367 This command may be abbreviated \"delete\".",
7370 add_com ("clear", class_breakpoint
, clear_command
,
7371 concat ("Clear breakpoint at specified line or function.\n\
7372 Argument may be line number, function name, or \"*\" and an address.\n\
7373 If line number is specified, all breakpoints in that line are cleared.\n\
7374 If function is specified, breakpoints at beginning of function are cleared.\n\
7375 If an address is specified, breakpoints at that address are cleared.\n\n",
7376 "With no argument, clears all breakpoints in the line that the selected frame\n\
7379 See also the \"delete\" command which clears breakpoints by number.", NULL
));
7381 add_com ("break", class_breakpoint
, break_command
,
7382 concat ("Set breakpoint at specified line or function.\n\
7383 Argument may be line number, function name, or \"*\" and an address.\n\
7384 If line number is specified, break at start of code for that line.\n\
7385 If function is specified, break at start of code for that function.\n\
7386 If an address is specified, break at that exact address.\n",
7387 "With no arg, uses current execution address of selected stack frame.\n\
7388 This is useful for breaking on return to a stack frame.\n\
7390 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7392 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7393 add_com_alias ("b", "break", class_run
, 1);
7394 add_com_alias ("br", "break", class_run
, 1);
7395 add_com_alias ("bre", "break", class_run
, 1);
7396 add_com_alias ("brea", "break", class_run
, 1);
7398 add_com ("xbreak", class_breakpoint
, break_at_finish_command
,
7399 concat ("Set breakpoint at procedure exit. \n\
7400 Argument may be function name, or \"*\" and an address.\n\
7401 If function is specified, break at end of code for that function.\n\
7402 If an address is specified, break at the end of the function that contains \n\
7403 that exact address.\n",
7404 "With no arg, uses current execution address of selected stack frame.\n\
7405 This is useful for breaking on return to a stack frame.\n\
7407 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
7409 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
7410 add_com_alias ("xb", "xbreak", class_breakpoint
, 1);
7411 add_com_alias ("xbr", "xbreak", class_breakpoint
, 1);
7412 add_com_alias ("xbre", "xbreak", class_breakpoint
, 1);
7413 add_com_alias ("xbrea", "xbreak", class_breakpoint
, 1);
7417 add_com_alias ("ba", "break", class_breakpoint
, 1);
7418 add_com_alias ("bu", "ubreak", class_breakpoint
, 1);
7419 add_com ("bx", class_breakpoint
, break_at_finish_at_depth_command
,
7420 "Set breakpoint at procedure exit. Either there should\n\
7421 be no argument or the argument must be a depth.\n");
7426 add_abbrev_prefix_cmd ("stop", class_breakpoint
, stop_command
,
7427 "Break in function/address or break at a line in the current file.",
7428 &stoplist
, "stop ", 1, &cmdlist
);
7429 add_cmd ("in", class_breakpoint
, stopin_command
,
7430 "Break in function or address.\n", &stoplist
);
7431 add_cmd ("at", class_breakpoint
, stopat_command
,
7432 "Break at a line in the current file.\n", &stoplist
);
7433 add_com ("status", class_info
, breakpoints_info
,
7434 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7435 The \"Type\" column indicates one of:\n\
7436 \tbreakpoint - normal breakpoint\n\
7437 \twatchpoint - watchpoint\n\
7438 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7439 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7440 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7441 address and file/line number respectively.\n\n",
7442 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7443 are set to the address of the last breakpoint listed.\n\n\
7444 Convenience variable \"$bpnum\" contains the number of the last\n\
7445 breakpoint set.", NULL
));
7448 add_info ("breakpoints", breakpoints_info
,
7449 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7450 The \"Type\" column indicates one of:\n\
7451 \tbreakpoint - normal breakpoint\n\
7452 \twatchpoint - watchpoint\n\
7453 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7454 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7455 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7456 address and file/line number respectively.\n\n",
7457 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7458 are set to the address of the last breakpoint listed.\n\n\
7459 Convenience variable \"$bpnum\" contains the number of the last\n\
7460 breakpoint set.", NULL
));
7463 add_com ("lb", class_breakpoint
, breakpoints_info
,
7464 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
7465 The \"Type\" column indicates one of:\n\
7466 \tbreakpoint - normal breakpoint\n\
7467 \twatchpoint - watchpoint\n\
7468 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7469 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7470 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7471 address and file/line number respectively.\n\n",
7472 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7473 are set to the address of the last breakpoint listed.\n\n\
7474 Convenience variable \"$bpnum\" contains the number of the last\n\
7475 breakpoint set.", NULL
));
7477 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
7478 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
7479 The \"Type\" column indicates one of:\n\
7480 \tbreakpoint - normal breakpoint\n\
7481 \twatchpoint - watchpoint\n\
7482 \tlongjmp - internal breakpoint used to step through longjmp()\n\
7483 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
7484 \tuntil - internal breakpoint used by the \"until\" command\n\
7485 \tfinish - internal breakpoint used by the \"finish\" command\n",
7486 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
7487 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
7488 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
7489 address and file/line number respectively.\n\n",
7490 "Convenience variable \"$_\" and default examine address for \"x\"\n\
7491 are set to the address of the last breakpoint listed.\n\n\
7492 Convenience variable \"$bpnum\" contains the number of the last\n\
7493 breakpoint set.", NULL
),
7494 &maintenanceinfolist
);
7496 add_com ("catch", class_breakpoint
, catch_command
,
7497 "Set catchpoints to catch events.\n\
7498 Raised signals may be caught:\n\
7499 \tcatch signal - all signals\n\
7500 \tcatch signal <signame> - a particular signal\n\
7501 Raised exceptions may be caught:\n\
7502 \tcatch throw - all exceptions, when thrown\n\
7503 \tcatch throw <exceptname> - a particular exception, when thrown\n\
7504 \tcatch catch - all exceptions, when caught\n\
7505 \tcatch catch <exceptname> - a particular exception, when caught\n\
7506 Thread or process events may be caught:\n\
7507 \tcatch thread_start - any threads, just after creation\n\
7508 \tcatch thread_exit - any threads, just before expiration\n\
7509 \tcatch thread_join - any threads, just after joins\n\
7510 Process events may be caught:\n\
7511 \tcatch start - any processes, just after creation\n\
7512 \tcatch exit - any processes, just before expiration\n\
7513 \tcatch fork - calls to fork()\n\
7514 \tcatch vfork - calls to vfork()\n\
7515 \tcatch exec - calls to exec()\n\
7516 Dynamically-linked library events may be caught:\n\
7517 \tcatch load - loads of any library\n\
7518 \tcatch load <libname> - loads of a particular library\n\
7519 \tcatch unload - unloads of any library\n\
7520 \tcatch unload <libname> - unloads of a particular library\n\
7521 The act of your program's execution stopping may also be caught:\n\
7523 C++ exceptions may be caught:\n\
7524 \tcatch throw - all exceptions, when thrown\n\
7525 \tcatch catch - all exceptions, when caught\n\
7527 Do \"help set follow-fork-mode\" for info on debugging your program\n\
7528 after a fork or vfork is caught.\n\n\
7529 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
7531 add_com ("tcatch", class_breakpoint
, tcatch_command
,
7532 "Set temporary catchpoints to catch events.\n\
7533 Args like \"catch\" command.\n\
7534 Like \"catch\" except the catchpoint is only temporary,\n\
7535 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
7536 by using \"enable delete\" on the catchpoint number.");
7538 add_com ("watch", class_breakpoint
, watch_command
,
7539 "Set a watchpoint for an expression.\n\
7540 A watchpoint stops execution of your program whenever the value of\n\
7541 an expression changes.");
7543 add_com ("rwatch", class_breakpoint
, rwatch_command
,
7544 "Set a read watchpoint for an expression.\n\
7545 A watchpoint stops execution of your program whenever the value of\n\
7546 an expression is read.");
7548 add_com ("awatch", class_breakpoint
, awatch_command
,
7549 "Set a watchpoint for an expression.\n\
7550 A watchpoint stops execution of your program whenever the value of\n\
7551 an expression is either read or written.");
7553 add_info ("watchpoints", breakpoints_info
,
7554 "Synonym for ``info breakpoints''.");
7557 c
= add_set_cmd ("can-use-hw-watchpoints", class_support
, var_zinteger
,
7558 (char *) &can_use_hw_watchpoints
,
7559 "Set debugger's willingness to use watchpoint hardware.\n\
7560 If zero, gdb will not use hardware for new watchpoints, even if\n\
7561 such is available. (However, any hardware watchpoints that were\n\
7562 created before setting this to nonzero, will continue to use watchpoint\n\
7565 add_show_from_set (c
, &showlist
);
7567 can_use_hw_watchpoints
= 1;