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 /* Prototypes for local functions. */
46 catch_command_1 PARAMS ((char *, int, int));
49 enable_delete_command PARAMS ((char *, int));
52 enable_delete_breakpoint PARAMS ((struct breakpoint *));
55 enable_once_command PARAMS ((char *, int));
58 enable_once_breakpoint PARAMS ((struct breakpoint *));
61 disable_command PARAMS ((char *, int));
64 enable_command PARAMS ((char *, int));
67 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
70 ignore_command PARAMS ((char *, int));
72 static int breakpoint_re_set_one PARAMS ((PTR));
75 clear_command PARAMS ((char *, int));
78 catch_command PARAMS ((char *, int));
81 handle_gnu_4_16_catch_command PARAMS ((char *, int, int));
83 static struct symtabs_and_lines
84 get_catch_sals PARAMS ((int));
87 watch_command PARAMS ((char *, int));
90 can_use_hardware_watchpoint PARAMS ((struct value *));
92 static void break_at_finish_command PARAMS ((char *, int));
93 static void break_at_finish_at_depth_command PARAMS ((char *, int));
96 tbreak_command PARAMS ((char *, int));
98 static void tbreak_at_finish_command PARAMS ((char *, int));
101 break_command_1 PARAMS ((char *, int, int));
104 mention PARAMS ((struct breakpoint *));
107 set_raw_breakpoint PARAMS ((struct symtab_and_line));
110 check_duplicates PARAMS ((CORE_ADDR, asection *));
113 describe_other_breakpoints PARAMS ((CORE_ADDR, asection *));
116 breakpoints_info PARAMS ((char *, int));
119 breakpoint_1 PARAMS ((int, int));
122 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
124 static int breakpoint_cond_eval PARAMS ((PTR));
127 cleanup_executing_breakpoints PARAMS ((PTR));
130 commands_command PARAMS ((char *, int));
133 condition_command PARAMS ((char *, int));
136 get_number PARAMS ((char **));
139 set_breakpoint_count PARAMS ((int));
142 static struct breakpoint *
143 create_temp_exception_breakpoint PARAMS ((CORE_ADDR));
154 remove_breakpoint PARAMS ((struct breakpoint *, insertion_state_t));
156 static int print_it_normal PARAMS ((bpstat));
160 enum exception_event_kind kind;
163 args_for_catchpoint_enable;
165 static int watchpoint_check PARAMS ((PTR));
167 static int cover_target_enable_exception_callback PARAMS ((PTR));
169 static int print_it_done PARAMS ((bpstat));
171 static int print_it_noop PARAMS ((bpstat));
173 static void maintenance_info_breakpoints PARAMS ((char *, int));
175 #ifdef GET_LONGJMP_TARGET
176 static void create_longjmp_breakpoint PARAMS ((char *));
179 static int hw_breakpoint_used_count PARAMS ((void));
181 static int hw_watchpoint_used_count PARAMS ((enum bptype, int *));
183 static void hbreak_command PARAMS ((char *, int));
185 static void thbreak_command PARAMS ((char *, int));
187 static void watch_command_1 PARAMS ((char *, int, int));
189 static void rwatch_command PARAMS ((char *, int));
191 static void awatch_command PARAMS ((char *, int));
193 static void do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp));
195 static void create_solib_load_unload_event_breakpoint PARAMS ((char *hookname, int tempflag, char *dll_pathname, char *cond_string, enum bptype bp_kind));
197 static void create_fork_vfork_event_catchpoint PARAMS ((int tempflag, char *cond_string, enum bptype bp_kind));
199 static void break_at_finish_at_depth_command_1 PARAMS ((char *arg, int flag, int from_tty));
201 static void break_at_finish_command_1 PARAMS ((char *arg, int flag, int from_tty));
203 static void stop_command PARAMS ((char *arg, int from_tty));
205 static void stopin_command PARAMS ((char *arg, int from_tty));
207 static void stopat_command PARAMS ((char *arg, int from_tty));
209 static char *ep_find_event_name_end PARAMS ((char *arg));
211 static char *ep_parse_optional_if_clause PARAMS ((char **arg));
213 static char *ep_parse_optional_filename PARAMS ((char **arg));
215 static void catch_exec_command_1 PARAMS ((char *arg, int tempflag, int from_tty));
217 static void create_exception_catchpoint PARAMS ((int tempflag, char *cond_string, enum exception_event_kind ex_event, struct symtab_and_line * sal));
219 static void catch_exception_command_1 PARAMS ((enum exception_event_kind ex_event, char *arg, int tempflag, int from_tty));
221 static void tcatch_command PARAMS ((char *arg, int from_tty));
223 static void ep_skip_leading_whitespace PARAMS ((char **s));
225 /* Prototypes for exported functions. */
228 awatch_command PARAMS ((char *, int));
231 do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp));
233 /* If FALSE, gdb will not use hardware support for watchpoints, even
234 if such is available. */
235 static int can_use_hw_watchpoints;
237 void delete_command PARAMS ((char *, int));
239 void _initialize_breakpoint PARAMS ((void));
241 void set_breakpoint_count PARAMS ((int));
243 extern int addressprint; /* Print machine addresses? */
245 #if defined (GET_LONGJMP_TARGET) || defined (SOLIB_ADD)
246 static int internal_breakpoint_number = -1;
249 /* Are we executing breakpoint commands? */
250 static int executing_breakpoint_commands;
252 /* Walk the following statement or block through all breakpoints.
253 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
256 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
258 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
259 for (b = breakpoint_chain; \
260 b? (tmp=b->next, 1): 0; \
263 /* True if SHIFT_INST_REGS defined, false otherwise. */
265 int must_shift_inst_regs =
266 #if defined(SHIFT_INST_REGS)
273 /* True if breakpoint hit counts should be displayed in breakpoint info. */
275 int show_breakpoint_hit_counts = 1;
277 /* Chain of all breakpoints defined. */
279 struct breakpoint *breakpoint_chain;
281 /* Number of last breakpoint made. */
283 int breakpoint_count;
285 /* Pointer to current exception event record */
286 static struct exception_event_record *current_exception_event;
288 /* Indicator of whether exception catchpoints should be nuked
289 between runs of a program */
290 int exception_catchpoints_are_fragile = 0;
292 /* Indicator of when exception catchpoints set-up should be
293 reinitialized -- e.g. when program is re-run */
294 int exception_support_initialized = 0;
296 /* This function returns a pointer to the string representation of the
297 pathname of the dynamically-linked library that has just been
300 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
301 or undefined results are guaranteed.
303 This string's contents are only valid immediately after the
304 inferior has stopped in the dynamic linker hook, and becomes
305 invalid as soon as the inferior is continued. Clients should make
306 a copy of this string if they wish to continue the inferior and
307 then access the string. */
309 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
310 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
313 /* This function returns a pointer to the string representation of the
314 pathname of the dynamically-linked library that has just been
317 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
318 TRUE, or undefined results are guaranteed.
320 This string's contents are only valid immediately after the
321 inferior has stopped in the dynamic linker hook, and becomes
322 invalid as soon as the inferior is continued. Clients should make
323 a copy of this string if they wish to continue the inferior and
324 then access the string. */
326 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
327 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
330 /* This function is called by the "catch load" command. It allows the
331 debugger to be notified by the dynamic linker when a specified
332 library file (or any library file, if filename is NULL) is loaded. */
334 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
335 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
336 error ("catch of library loads not yet implemented on this platform")
339 /* This function is called by the "catch unload" command. It allows
340 the debugger to be notified by the dynamic linker when a specified
341 library file (or any library file, if filename is NULL) is
344 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
345 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
346 error ("catch of library unloads not yet implemented on this platform")
349 /* Set breakpoint count to NUM. */
352 set_breakpoint_count (num)
355 breakpoint_count = num;
356 set_internalvar (lookup_internalvar ("bpnum"),
357 value_from_longest (builtin_type_int, (LONGEST) num));
360 /* Used in run_command to zero the hit count when a new run starts. */
363 clear_breakpoint_hit_counts ()
365 struct breakpoint *b;
371 /* Default address, symtab and line to put a breakpoint at
372 for "break" command with no arg.
373 if default_breakpoint_valid is zero, the other three are
374 not valid, and "break" with no arg is an error.
376 This set by print_stack_frame, which calls set_default_breakpoint. */
378 int default_breakpoint_valid;
379 CORE_ADDR default_breakpoint_address;
380 struct symtab *default_breakpoint_symtab;
381 int default_breakpoint_line;
383 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
384 Advance *PP after the string and any trailing whitespace.
386 Currently the string can either be a number or "$" followed by the name
387 of a convenience variable. Making it an expression wouldn't work well
388 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
397 /* Empty line means refer to the last breakpoint. */
398 return breakpoint_count;
401 /* Make a copy of the name, so we can null-terminate it
402 to pass to lookup_internalvar(). */
407 while (isalnum (*p) || *p == '_')
409 varname = (char *) alloca (p - start + 1);
410 strncpy (varname, start, p - start);
411 varname[p - start] = '\0';
412 val = value_of_internalvar (lookup_internalvar (varname));
413 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
415 "Convenience variables used to specify breakpoints must have integer values."
417 retval = (int) value_as_long (val);
423 while (*p >= '0' && *p <= '9')
426 /* There is no number here. (e.g. "cond a == b"). */
427 error_no_arg ("breakpoint number");
430 if (!(isspace (*p) || *p == '\0'))
431 error ("breakpoint number expected");
438 /* condition N EXP -- set break condition of breakpoint N to EXP. */
441 condition_command (arg, from_tty)
445 register struct breakpoint *b;
450 error_no_arg ("breakpoint number");
453 bnum = get_number (&p);
456 if (b->number == bnum)
460 free ((PTR) b->cond);
463 if (b->cond_string != NULL)
464 free ((PTR) b->cond_string);
469 b->cond_string = NULL;
471 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
476 /* I don't know if it matters whether this is the string the user
477 typed in or the decompiled expression. */
478 b->cond_string = savestring (arg, strlen (arg));
479 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
481 error ("Junk at end of expression");
483 breakpoints_changed ();
487 error ("No breakpoint number %d.", bnum);
492 commands_command (arg, from_tty)
496 register struct breakpoint *b;
499 struct command_line *l;
501 /* If we allowed this, we would have problems with when to
502 free the storage, if we change the commands currently
505 if (executing_breakpoint_commands)
506 error ("Can't use the \"commands\" command among a breakpoint's commands.");
509 bnum = get_number (&p);
511 error ("Unexpected extra arguments following breakpoint number.");
514 if (b->number == bnum)
517 sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum);
518 l = read_command_lines (tmpbuf, from_tty);
519 free_command_lines (&b->commands);
521 breakpoints_changed ();
524 error ("No breakpoint number %d.", bnum);
527 /* Like target_read_memory() but if breakpoints are inserted, return
528 the shadow contents instead of the breakpoints themselves.
530 Read "memory data" from whatever target or inferior we have.
531 Returns zero if successful, errno value if not. EIO is used
532 for address out of bounds. If breakpoints are inserted, returns
533 shadow contents, not the breakpoints themselves. From breakpoint.c. */
536 read_memory_nobpt (memaddr, myaddr, len)
542 struct breakpoint *b;
543 CORE_ADDR bp_addr = 0;
546 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
547 /* No breakpoints on this machine. */
548 return target_read_memory (memaddr, myaddr, len);
552 if (b->type == bp_none)
553 warning ("attempted to read through apparently deleted breakpoint #%d?\n", b->number);
555 /* memory breakpoint? */
556 if (b->type == bp_watchpoint
557 || b->type == bp_hardware_watchpoint
558 || b->type == bp_read_watchpoint
559 || b->type == bp_access_watchpoint)
564 /* Addresses and length of the part of the breakpoint that
566 /* XXXX The m68k, sh and h8300 have different local and remote
567 breakpoint values. BREAKPOINT_FROM_PC still manages to
568 correctly determine the breakpoints memory address and size
569 for these targets. */
570 bp_addr = b->address;
572 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
577 if (bp_addr + bp_size <= memaddr)
578 /* The breakpoint is entirely before the chunk of memory we
581 if (bp_addr >= memaddr + len)
582 /* The breakpoint is entirely after the chunk of memory we are
585 /* Copy the breakpoint from the shadow contents, and recurse for
586 the things before and after. */
588 /* Offset within shadow_contents. */
591 if (bp_addr < memaddr)
593 /* Only copy the second part of the breakpoint. */
594 bp_size -= memaddr - bp_addr;
595 bptoffset = memaddr - bp_addr;
599 if (bp_addr + bp_size > memaddr + len)
601 /* Only copy the first part of the breakpoint. */
602 bp_size -= (bp_addr + bp_size) - (memaddr + len);
605 memcpy (myaddr + bp_addr - memaddr,
606 b->shadow_contents + bptoffset, bp_size);
608 if (bp_addr > memaddr)
610 /* Copy the section of memory before the breakpoint. */
611 status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr);
616 if (bp_addr + bp_size < memaddr + len)
618 /* Copy the section of memory after the breakpoint. */
619 status = read_memory_nobpt
621 myaddr + bp_addr + bp_size - memaddr,
622 memaddr + len - (bp_addr + bp_size));
629 /* Nothing overlaps. Just call read_memory_noerr. */
630 return target_read_memory (memaddr, myaddr, len);
634 /* insert_breakpoints is used when starting or continuing the program.
635 remove_breakpoints is used when the program stops.
636 Both return zero if successful,
637 or an `errno' value if could not write the inferior. */
640 insert_breakpoints ()
642 register struct breakpoint *b, *temp;
644 int disabled_breaks = 0;
646 static char message1[] = "Error inserting catchpoint %d:\n";
647 static char message[sizeof (message1) + 30];
650 ALL_BREAKPOINTS_SAFE (b, temp)
652 if (b->type != bp_watchpoint
653 && b->type != bp_hardware_watchpoint
654 && b->type != bp_read_watchpoint
655 && b->type != bp_access_watchpoint
656 && b->type != bp_catch_fork
657 && b->type != bp_catch_vfork
658 && b->type != bp_catch_exec
659 && b->type != bp_catch_throw
660 && b->type != bp_catch_catch
661 && b->enable != disabled
662 && b->enable != shlib_disabled
663 && b->enable != call_disabled
667 if (b->type == bp_hardware_breakpoint)
668 val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
671 /* Check to see if breakpoint is in an overlay section;
672 if so, we should set the breakpoint at the LMA address.
673 Only if the section is currently mapped should we ALSO
674 set a break at the VMA address. */
675 if (overlay_debugging && b->section &&
676 section_is_overlay (b->section))
680 addr = overlay_unmapped_address (b->address, b->section);
681 val = target_insert_breakpoint (addr, b->shadow_contents);
682 /* This would be the time to check val, to see if the
683 breakpoint write to the load address succeeded.
684 However, this might be an ordinary occurrance, eg. if
685 the unmapped overlay is in ROM. */
686 val = 0; /* in case unmapped address failed */
687 if (section_is_mapped (b->section))
688 val = target_insert_breakpoint (b->address,
691 else /* ordinary (non-overlay) address */
692 val = target_insert_breakpoint (b->address, b->shadow_contents);
696 /* Can't set the breakpoint. */
697 #if defined (DISABLE_UNSETTABLE_BREAK)
698 if (DISABLE_UNSETTABLE_BREAK (b->address))
700 /* See also: disable_breakpoints_in_shlibs. */
702 b->enable = shlib_disabled;
703 if (!disabled_breaks)
705 target_terminal_ours_for_output ();
706 fprintf_unfiltered (gdb_stderr,
707 "Cannot insert breakpoint %d:\n", b->number);
708 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
711 printf_filtered ("%d ", b->number);
716 target_terminal_ours_for_output ();
717 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
718 #ifdef ONE_PROCESS_WRITETEXT
719 fprintf_unfiltered (gdb_stderr,
720 "The same program may be running in another process.\n");
722 memory_error (val, b->address); /* which bombs us out */
728 else if (ep_is_exception_catchpoint (b)
729 && b->enable != disabled
730 && b->enable != shlib_disabled
731 && b->enable != call_disabled
736 /* If we get here, we must have a callback mechanism for exception
737 events -- with g++ style embedded label support, we insert
738 ordinary breakpoints and not catchpoints. */
739 sprintf (message, message1, b->number); /* Format possible error message */
741 val = target_insert_breakpoint (b->address, b->shadow_contents);
744 /* Couldn't set breakpoint for some reason */
745 target_terminal_ours_for_output ();
746 fprintf_unfiltered (gdb_stderr,
747 "Cannot insert catchpoint %d; disabling it\n", b->number);
748 b->enable = disabled;
752 /* Bp set, now make sure callbacks are enabled */
754 args_for_catchpoint_enable args;
755 args.kind = b->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
757 val = catch_errors (cover_target_enable_exception_callback,
759 message, RETURN_MASK_ALL);
760 if (val != 0 && val != -1)
764 /* Check if something went wrong; val == 0 can be ignored */
767 /* something went wrong */
768 target_terminal_ours_for_output ();
769 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d; disabling it\n", b->number);
770 b->enable = disabled;
775 else if ((b->type == bp_hardware_watchpoint ||
776 b->type == bp_read_watchpoint ||
777 b->type == bp_access_watchpoint)
778 && b->enable == enabled
782 struct frame_info *saved_frame;
783 int saved_level, within_current_scope;
784 value_ptr mark = value_mark ();
787 /* Save the current frame and level so we can restore it after
788 evaluating the watchpoint expression on its own frame. */
789 saved_frame = selected_frame;
790 saved_level = selected_frame_level;
792 /* Determine if the watchpoint is within scope. */
793 if (b->exp_valid_block == NULL)
794 within_current_scope = 1;
797 struct frame_info *fi;
799 /* There might be no current frame at this moment if we are
800 resuming from a step over a breakpoint.
801 Set up current frame before trying to find the watchpoint
803 get_current_frame ();
804 fi = find_frame_addr_in_frame_chain (b->watchpoint_frame);
805 within_current_scope = (fi != NULL);
806 if (within_current_scope)
807 select_frame (fi, -1);
810 if (within_current_scope)
812 /* Evaluate the expression and cut the chain of values
813 produced off from the value chain. */
814 v = evaluate_expression (b->exp);
815 value_release_to_mark (mark);
820 /* Look at each value on the value chain. */
821 for (; v; v = v->next)
823 /* If it's a memory location, then we must watch it. */
824 if (v->lval == lval_memory)
828 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
829 len = TYPE_LENGTH (VALUE_TYPE (v));
831 if (b->type == bp_read_watchpoint)
833 else if (b->type == bp_access_watchpoint)
836 val = target_insert_watchpoint (addr, len, type);
845 /* Failure to insert a watchpoint on any memory value in the
846 value chain brings us here. */
848 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
854 Hardware watchpoint %d deleted because the program has left the block in\n\
855 which its expression is valid.\n", b->number);
856 if (b->related_breakpoint)
857 b->related_breakpoint->disposition = del_at_next_stop;
858 b->disposition = del_at_next_stop;
861 /* Restore the frame and level. */
862 if ((saved_frame != selected_frame) ||
863 (saved_level != selected_frame_level))
864 select_and_print_frame (saved_frame, saved_level);
866 else if ((b->type == bp_catch_fork
867 || b->type == bp_catch_vfork
868 || b->type == bp_catch_exec)
869 && b->enable == enabled
877 val = target_insert_fork_catchpoint (inferior_pid);
880 val = target_insert_vfork_catchpoint (inferior_pid);
883 val = target_insert_exec_catchpoint (inferior_pid);
886 warning ("GDB bug: breakpoint.c (insert_breakpoints): enclosing `if' does not protect `switch'");
891 target_terminal_ours_for_output ();
892 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d:\n", b->number);
899 printf_filtered ("\n");
906 remove_breakpoints ()
908 register struct breakpoint *b;
915 val = remove_breakpoint (b, mark_uninserted);
924 reattach_breakpoints (pid)
927 register struct breakpoint *b;
929 int saved_inferior_pid = inferior_pid;
931 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
936 remove_breakpoint (b, mark_inserted);
937 if (b->type == bp_hardware_breakpoint)
938 val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
940 val = target_insert_breakpoint (b->address, b->shadow_contents);
943 inferior_pid = saved_inferior_pid;
948 inferior_pid = saved_inferior_pid;
953 update_breakpoints_after_exec ()
955 struct breakpoint *b;
956 struct breakpoint *temp;
958 /* Doing this first prevents the badness of having delete_breakpoint()
959 write a breakpoint's current "shadow contents" to lift the bp. That
960 shadow is NOT valid after an exec()! */
961 mark_breakpoints_out ();
963 ALL_BREAKPOINTS_SAFE (b, temp)
965 /* Solib breakpoints must be explicitly reset after an exec(). */
966 if (b->type == bp_shlib_event)
968 delete_breakpoint (b);
972 /* Step-resume breakpoints are meaningless after an exec(). */
973 if (b->type == bp_step_resume)
975 delete_breakpoint (b);
979 /* Ditto the sigtramp handler breakpoints. */
980 if (b->type == bp_through_sigtramp)
982 delete_breakpoint (b);
986 /* Ditto the exception-handling catchpoints. */
987 if ((b->type == bp_catch_catch) || (b->type == bp_catch_throw))
989 delete_breakpoint (b);
993 /* Don't delete an exec catchpoint, because else the inferior
994 won't stop when it ought!
996 Similarly, we probably ought to keep vfork catchpoints, 'cause
997 on this target, we may not be able to stop when the vfork is seen,
998 but only when the subsequent exec is seen. (And because deleting
999 fork catchpoints here but not vfork catchpoints will seem mysterious
1000 to users, keep those too.)
1002 ??rehrauer: Let's hope that merely clearing out this catchpoint's
1003 target address field, if any, is sufficient to have it be reset
1004 automagically. Certainly on HP-UX that's true. */
1005 if ((b->type == bp_catch_exec) ||
1006 (b->type == bp_catch_vfork) ||
1007 (b->type == bp_catch_fork))
1009 b->address = (CORE_ADDR) NULL;
1013 /* bp_finish is a special case. The only way we ought to be able
1014 to see one of these when an exec() has happened, is if the user
1015 caught a vfork, and then said "finish". Ordinarily a finish just
1016 carries them to the call-site of the current callee, by setting
1017 a temporary bp there and resuming. But in this case, the finish
1018 will carry them entirely through the vfork & exec.
1020 We don't want to allow a bp_finish to remain inserted now. But
1021 we can't safely delete it, 'cause finish_command has a handle to
1022 the bp on a bpstat, and will later want to delete it. There's a
1023 chance (and I've seen it happen) that if we delete the bp_finish
1024 here, that its storage will get reused by the time finish_command
1025 gets 'round to deleting the "use to be a bp_finish" breakpoint.
1026 We really must allow finish_command to delete a bp_finish.
1028 In the absense of a general solution for the "how do we know it's
1029 safe to delete something others may have handles to?" problem, what
1030 we'll do here is just uninsert the bp_finish, and let finish_command
1033 (We know the bp_finish is "doomed" in the sense that it's momentary,
1034 and will be deleted as soon as finish_command sees the inferior stopped.
1035 So it doesn't matter that the bp's address is probably bogus in the
1036 new a.out, unlike e.g., the solib breakpoints.) */
1037 if (b->type == bp_finish)
1042 /* Without a symbolic address, we have little hope of the
1043 pre-exec() address meaning the same thing in the post-exec()
1045 if (b->addr_string == NULL)
1047 delete_breakpoint (b);
1051 /* If this breakpoint has survived the above battery of checks, then
1052 it must have a symbolic address. Be sure that it gets reevaluated
1053 to a target address, rather than reusing the old evaluation. */
1054 b->address = (CORE_ADDR) NULL;
1059 detach_breakpoints (pid)
1062 register struct breakpoint *b;
1064 int saved_inferior_pid = inferior_pid;
1066 if (pid == inferior_pid)
1067 error ("Cannot detach breakpoints of inferior_pid");
1069 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
1074 val = remove_breakpoint (b, mark_inserted);
1077 inferior_pid = saved_inferior_pid;
1082 inferior_pid = saved_inferior_pid;
1087 remove_breakpoint (b, is)
1088 struct breakpoint *b;
1089 insertion_state_t is;
1093 if (b->type == bp_none)
1094 warning ("attempted to remove apparently deleted breakpoint #%d?\n", b->number);
1096 if (b->type != bp_watchpoint
1097 && b->type != bp_hardware_watchpoint
1098 && b->type != bp_read_watchpoint
1099 && b->type != bp_access_watchpoint
1100 && b->type != bp_catch_fork
1101 && b->type != bp_catch_vfork
1102 && b->type != bp_catch_exec
1103 && b->type != bp_catch_catch
1104 && b->type != bp_catch_throw)
1107 if (b->type == bp_hardware_breakpoint)
1108 val = target_remove_hw_breakpoint (b->address, b->shadow_contents);
1111 /* Check to see if breakpoint is in an overlay section;
1112 if so, we should remove the breakpoint at the LMA address.
1113 If that is not equal to the raw address, then we should
1114 presumable remove the breakpoint there as well. */
1115 if (overlay_debugging && b->section &&
1116 section_is_overlay (b->section))
1120 addr = overlay_unmapped_address (b->address, b->section);
1121 val = target_remove_breakpoint (addr, b->shadow_contents);
1122 /* This would be the time to check val, to see if the
1123 shadow breakpoint write to the load address succeeded.
1124 However, this might be an ordinary occurrance, eg. if
1125 the unmapped overlay is in ROM. */
1126 val = 0; /* in case unmapped address failed */
1127 if (section_is_mapped (b->section))
1128 val = target_remove_breakpoint (b->address,
1129 b->shadow_contents);
1131 else /* ordinary (non-overlay) address */
1132 val = target_remove_breakpoint (b->address, b->shadow_contents);
1136 b->inserted = (is == mark_inserted);
1138 else if ((b->type == bp_hardware_watchpoint ||
1139 b->type == bp_read_watchpoint ||
1140 b->type == bp_access_watchpoint)
1141 && b->enable == enabled
1146 b->inserted = (is == mark_inserted);
1147 /* Walk down the saved value chain. */
1148 for (v = b->val_chain; v; v = v->next)
1150 /* For each memory reference remove the watchpoint
1152 if (v->lval == lval_memory)
1154 int addr, len, type;
1156 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1157 len = TYPE_LENGTH (VALUE_TYPE (v));
1159 if (b->type == bp_read_watchpoint)
1161 else if (b->type == bp_access_watchpoint)
1164 val = target_remove_watchpoint (addr, len, type);
1170 /* Failure to remove any of the hardware watchpoints comes here. */
1171 if ((is == mark_uninserted) && (b->inserted))
1172 warning ("Hardware watchpoint %d: Could not remove watchpoint\n",
1175 /* Free the saved value chain. We will construct a new one
1176 the next time the watchpoint is inserted. */
1177 for (v = b->val_chain; v; v = n)
1182 b->val_chain = NULL;
1184 else if ((b->type == bp_catch_fork ||
1185 b->type == bp_catch_vfork ||
1186 b->type == bp_catch_exec)
1187 && b->enable == enabled
1194 val = target_remove_fork_catchpoint (inferior_pid);
1196 case bp_catch_vfork:
1197 val = target_remove_vfork_catchpoint (inferior_pid);
1200 val = target_remove_exec_catchpoint (inferior_pid);
1203 warning ("GDB bug: breakpoint.c (remove_breakpoint): enclosing `if' does not protect `switch'");
1208 b->inserted = (is == mark_inserted);
1210 else if ((b->type == bp_catch_catch ||
1211 b->type == bp_catch_throw)
1212 && b->enable == enabled
1216 val = target_remove_breakpoint (b->address, b->shadow_contents);
1219 b->inserted = (is == mark_inserted);
1221 else if (ep_is_exception_catchpoint (b)
1222 && b->inserted /* sometimes previous insert doesn't happen */
1223 && b->enable == enabled
1227 val = target_remove_breakpoint (b->address, b->shadow_contents);
1231 b->inserted = (is == mark_inserted);
1237 /* Clear the "inserted" flag in all breakpoints. */
1240 mark_breakpoints_out ()
1242 register struct breakpoint *b;
1248 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
1249 which should go away between runs of the program.
1251 Plus other such housekeeping that has to be done for breakpoints
1254 Note: this function gets called at the end of a run (by generic_mourn_inferior)
1255 and when a run begins (by init_wait_for_inferior). */
1260 breakpoint_init_inferior (context)
1261 enum inf_context context;
1263 register struct breakpoint *b, *temp;
1264 static int warning_needed = 0;
1266 ALL_BREAKPOINTS_SAFE (b, temp)
1273 case bp_watchpoint_scope:
1275 /* If the call dummy breakpoint is at the entry point it will
1276 cause problems when the inferior is rerun, so we better
1279 Also get rid of scope breakpoints. */
1280 delete_breakpoint (b);
1284 case bp_hardware_watchpoint:
1285 case bp_read_watchpoint:
1286 case bp_access_watchpoint:
1288 /* Likewise for watchpoints on local expressions. */
1289 if (b->exp_valid_block != NULL)
1290 delete_breakpoint (b);
1293 /* Likewise for exception catchpoints in dynamic-linked
1294 executables where required */
1295 if (ep_is_exception_catchpoint (b) &&
1296 exception_catchpoints_are_fragile)
1299 delete_breakpoint (b);
1305 if (exception_catchpoints_are_fragile)
1306 exception_support_initialized = 0;
1308 /* Don't issue the warning unless it's really needed... */
1309 if (warning_needed && (context != inf_exited))
1311 warning ("Exception catchpoints from last run were deleted, you must reinsert them explicitly");
1316 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
1317 When continuing from a location with a breakpoint,
1318 we actually single step once before calling insert_breakpoints. */
1321 breakpoint_here_p (pc)
1324 register struct breakpoint *b;
1327 if (b->enable == enabled
1328 && b->enable != shlib_disabled
1329 && b->enable != call_disabled
1330 && b->address == pc) /* bp is enabled and matches pc */
1332 if (overlay_debugging &&
1333 section_is_overlay (b->section) &&
1334 !section_is_mapped (b->section))
1335 continue; /* unmapped overlay -- can't be a match */
1343 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(), but it
1344 only returns true if there is actually a breakpoint inserted at PC. */
1347 breakpoint_inserted_here_p (pc)
1350 register struct breakpoint *b;
1354 && b->address == pc) /* bp is inserted and matches pc */
1356 if (overlay_debugging &&
1357 section_is_overlay (b->section) &&
1358 !section_is_mapped (b->section))
1359 continue; /* unmapped overlay -- can't be a match */
1367 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
1368 because figuring out the saved SP would take too much time, at least using
1369 get_saved_register on the 68k. This means that for this function to
1370 work right a port must use the bp_call_dummy breakpoint. */
1373 frame_in_dummy (frame)
1374 struct frame_info *frame;
1376 struct breakpoint *b;
1381 if (USE_GENERIC_DUMMY_FRAMES)
1382 return generic_pc_in_call_dummy (frame->pc, frame->frame, frame->frame);
1386 if (b->type == bp_call_dummy
1387 && b->frame == frame->frame
1388 /* We need to check the PC as well as the frame on the sparc,
1389 for signals.exp in the testsuite. */
1392 - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
1393 && frame->pc <= b->address)
1399 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1400 is valid for process/thread PID. */
1403 breakpoint_thread_match (pc, pid)
1407 struct breakpoint *b;
1410 thread = pid_to_thread_id (pid);
1413 if (b->enable != disabled
1414 && b->enable != shlib_disabled
1415 && b->enable != call_disabled
1417 && (b->thread == -1 || b->thread == thread))
1419 if (overlay_debugging &&
1420 section_is_overlay (b->section) &&
1421 !section_is_mapped (b->section))
1422 continue; /* unmapped overlay -- can't be a match */
1431 /* bpstat stuff. External routines' interfaces are documented
1435 ep_is_catchpoint (ep)
1436 struct breakpoint *ep;
1439 (ep->type == bp_catch_load)
1440 || (ep->type == bp_catch_unload)
1441 || (ep->type == bp_catch_fork)
1442 || (ep->type == bp_catch_vfork)
1443 || (ep->type == bp_catch_exec)
1444 || (ep->type == bp_catch_catch)
1445 || (ep->type == bp_catch_throw)
1448 /* ??rehrauer: Add more kinds here, as are implemented... */
1453 ep_is_shlib_catchpoint (ep)
1454 struct breakpoint *ep;
1457 (ep->type == bp_catch_load)
1458 || (ep->type == bp_catch_unload)
1463 ep_is_exception_catchpoint (ep)
1464 struct breakpoint *ep;
1467 (ep->type == bp_catch_catch)
1468 || (ep->type == bp_catch_throw)
1472 /* Clear a bpstat so that it says we are not at any breakpoint.
1473 Also free any storage that is part of a bpstat. */
1488 if (p->old_val != NULL)
1489 value_free (p->old_val);
1496 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1497 is part of the bpstat is copied as well. */
1505 bpstat retval = NULL;
1510 for (; bs != NULL; bs = bs->next)
1512 tmp = (bpstat) xmalloc (sizeof (*tmp));
1513 memcpy (tmp, bs, sizeof (*tmp));
1515 /* This is the first thing in the chain. */
1525 /* Find the bpstat associated with this breakpoint */
1528 bpstat_find_breakpoint (bsp, breakpoint)
1530 struct breakpoint *breakpoint;
1535 for (; bsp != NULL; bsp = bsp->next)
1537 if (bsp->breakpoint_at == breakpoint)
1543 /* Find a step_resume breakpoint associated with this bpstat.
1544 (If there are multiple step_resume bp's on the list, this function
1545 will arbitrarily pick one.)
1547 It is an error to use this function if BPSTAT doesn't contain a
1548 step_resume breakpoint.
1550 See wait_for_inferior's use of this function. */
1552 bpstat_find_step_resume_breakpoint (bsp)
1556 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1558 for (; bsp != NULL; bsp = bsp->next)
1560 if ((bsp->breakpoint_at != NULL) &&
1561 (bsp->breakpoint_at->type == bp_step_resume))
1562 return bsp->breakpoint_at;
1565 error ("Internal error (no step_resume breakpoint found)");
1569 /* Return the breakpoint number of the first breakpoint we are stopped
1570 at. *BSP upon return is a bpstat which points to the remaining
1571 breakpoints stopped at (but which is not guaranteed to be good for
1572 anything but further calls to bpstat_num).
1573 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1579 struct breakpoint *b;
1582 return 0; /* No more breakpoint values */
1585 b = (*bsp)->breakpoint_at;
1586 *bsp = (*bsp)->next;
1588 return -1; /* breakpoint that's been deleted since */
1590 return b->number; /* We have its number */
1594 /* Modify BS so that the actions will not be performed. */
1597 bpstat_clear_actions (bs)
1600 for (; bs != NULL; bs = bs->next)
1602 bs->commands = NULL;
1603 if (bs->old_val != NULL)
1605 value_free (bs->old_val);
1611 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1614 cleanup_executing_breakpoints (ignore)
1617 executing_breakpoint_commands = 0;
1620 /* Execute all the commands associated with all the breakpoints at this
1621 location. Any of these commands could cause the process to proceed
1622 beyond this point, etc. We look out for such changes by checking
1623 the global "breakpoint_proceeded" after each command. */
1626 bpstat_do_actions (bsp)
1630 struct cleanup *old_chain;
1631 struct command_line *cmd;
1633 /* Avoid endless recursion if a `source' command is contained
1635 if (executing_breakpoint_commands)
1638 executing_breakpoint_commands = 1;
1639 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
1642 /* Note that (as of this writing), our callers all appear to
1643 be passing us the address of global stop_bpstat. And, if
1644 our calls to execute_control_command cause the inferior to
1645 proceed, that global (and hence, *bsp) will change.
1647 We must be careful to not touch *bsp unless the inferior
1648 has not proceeded. */
1650 /* This pointer will iterate over the list of bpstat's. */
1653 breakpoint_proceeded = 0;
1654 for (; bs != NULL; bs = bs->next)
1659 execute_control_command (cmd);
1661 if (breakpoint_proceeded)
1666 if (breakpoint_proceeded)
1667 /* The inferior is proceeded by the command; bomb out now.
1668 The bpstat chain has been blown away by wait_for_inferior.
1669 But since execution has stopped again, there is a new bpstat
1670 to look at, so start over. */
1673 bs->commands = NULL;
1676 executing_breakpoint_commands = 0;
1677 discard_cleanups (old_chain);
1680 /* This is the normal print_it function for a bpstat. In the future,
1681 much of this logic could (should?) be moved to bpstat_stop_status,
1682 by having it set different print_it functions.
1684 Current scheme: When we stop, bpstat_print() is called.
1685 It loops through the bpstat list of things causing this stop,
1686 calling the print_it function for each one. The default
1687 print_it function, used for breakpoints, is print_it_normal().
1688 (Also see print_it_noop() and print_it_done()).
1690 Return values from this routine (used by bpstat_print() to
1692 1: Means we printed something, and we do *not* desire that
1693 something to be followed by a location.
1694 0: Means we printed something, and we *do* desire that
1695 something to be followed by a location.
1696 -1: Means we printed nothing. */
1699 print_it_normal (bs)
1702 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1703 which has since been deleted. */
1704 if (bs->breakpoint_at == NULL
1705 || (bs->breakpoint_at->type != bp_breakpoint
1706 && bs->breakpoint_at->type != bp_catch_load
1707 && bs->breakpoint_at->type != bp_catch_unload
1708 && bs->breakpoint_at->type != bp_catch_fork
1709 && bs->breakpoint_at->type != bp_catch_vfork
1710 && bs->breakpoint_at->type != bp_catch_exec
1711 && bs->breakpoint_at->type != bp_catch_catch
1712 && bs->breakpoint_at->type != bp_catch_throw
1713 && bs->breakpoint_at->type != bp_hardware_breakpoint
1714 && bs->breakpoint_at->type != bp_watchpoint
1715 && bs->breakpoint_at->type != bp_read_watchpoint
1716 && bs->breakpoint_at->type != bp_access_watchpoint
1717 && bs->breakpoint_at->type != bp_hardware_watchpoint))
1720 if (ep_is_shlib_catchpoint (bs->breakpoint_at))
1722 annotate_catchpoint (bs->breakpoint_at->number);
1723 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1724 if (bs->breakpoint_at->type == bp_catch_load)
1725 printf_filtered ("loaded");
1726 else if (bs->breakpoint_at->type == bp_catch_unload)
1727 printf_filtered ("unloaded");
1728 printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname);
1731 else if (bs->breakpoint_at->type == bp_catch_fork ||
1732 bs->breakpoint_at->type == bp_catch_vfork)
1734 annotate_catchpoint (bs->breakpoint_at->number);
1735 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1736 if (bs->breakpoint_at->type == bp_catch_fork)
1737 printf_filtered ("forked");
1738 else if (bs->breakpoint_at->type == bp_catch_vfork)
1739 printf_filtered ("vforked");
1740 printf_filtered (" process %d), ", bs->breakpoint_at->forked_inferior_pid);
1743 else if (bs->breakpoint_at->type == bp_catch_exec)
1745 annotate_catchpoint (bs->breakpoint_at->number);
1746 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1747 bs->breakpoint_at->number,
1748 bs->breakpoint_at->exec_pathname);
1751 else if (bs->breakpoint_at->type == bp_catch_catch)
1753 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH))
1755 annotate_catchpoint (bs->breakpoint_at->number);
1756 printf_filtered ("\nCatchpoint %d (exception caught), ", bs->breakpoint_at->number);
1757 printf_filtered ("throw location ");
1758 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1759 printf_filtered ("%s:%d",
1760 CURRENT_EXCEPTION_THROW_FILE,
1761 CURRENT_EXCEPTION_THROW_LINE);
1763 printf_filtered ("unknown");
1765 printf_filtered (", catch location ");
1766 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1767 printf_filtered ("%s:%d",
1768 CURRENT_EXCEPTION_CATCH_FILE,
1769 CURRENT_EXCEPTION_CATCH_LINE);
1771 printf_filtered ("unknown");
1773 printf_filtered ("\n");
1774 return 1; /* don't bother to print location frame info */
1778 return -1; /* really throw, some other bpstat will handle it */
1781 else if (bs->breakpoint_at->type == bp_catch_throw)
1783 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW))
1785 annotate_catchpoint (bs->breakpoint_at->number);
1786 printf_filtered ("\nCatchpoint %d (exception thrown), ", bs->breakpoint_at->number);
1787 printf_filtered ("throw location ");
1788 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1789 printf_filtered ("%s:%d",
1790 CURRENT_EXCEPTION_THROW_FILE,
1791 CURRENT_EXCEPTION_THROW_LINE);
1793 printf_filtered ("unknown");
1795 printf_filtered (", catch location ");
1796 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1797 printf_filtered ("%s:%d",
1798 CURRENT_EXCEPTION_CATCH_FILE,
1799 CURRENT_EXCEPTION_CATCH_LINE);
1801 printf_filtered ("unknown");
1803 printf_filtered ("\n");
1804 return 1; /* don't bother to print location frame info */
1808 return -1; /* really catch, some other bpstat willhandle it */
1812 else if (bs->breakpoint_at->type == bp_breakpoint ||
1813 bs->breakpoint_at->type == bp_hardware_breakpoint)
1815 /* I think the user probably only wants to see one breakpoint
1816 number, not all of them. */
1817 annotate_breakpoint (bs->breakpoint_at->number);
1818 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
1821 else if ((bs->old_val != NULL) &&
1822 (bs->breakpoint_at->type == bp_watchpoint ||
1823 bs->breakpoint_at->type == bp_access_watchpoint ||
1824 bs->breakpoint_at->type == bp_hardware_watchpoint))
1826 annotate_watchpoint (bs->breakpoint_at->number);
1827 mention (bs->breakpoint_at);
1828 printf_filtered ("\nOld value = ");
1829 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
1830 printf_filtered ("\nNew value = ");
1831 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1832 Val_pretty_default);
1833 printf_filtered ("\n");
1834 value_free (bs->old_val);
1836 /* More than one watchpoint may have been triggered. */
1839 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
1840 bs->breakpoint_at->type == bp_read_watchpoint)
1842 mention (bs->breakpoint_at);
1843 printf_filtered ("\nValue = ");
1844 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1845 Val_pretty_default);
1846 printf_filtered ("\n");
1849 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1853 /* Print a message indicating what happened.
1854 This is called from normal_stop().
1855 The input to this routine is the head of the bpstat list - a list
1856 of the eventpoints that caused this stop.
1857 This routine calls the "print_it" routine(s) associated
1858 with these eventpoints. This will print (for example)
1859 the "Breakpoint n," part of the output.
1860 The return value of this routine is one of:
1862 -1: Means we printed nothing
1863 0: Means we printed something, and expect subsequent
1864 code to print the location. An example is
1865 "Breakpoint 1, " which should be followed by
1867 1 : Means we printed something, but there is no need
1868 to also print the location part of the message.
1869 An example is the catch/throw messages, which
1870 don't require a location appended to the end. */
1881 val = (*bs->print_it) (bs);
1885 /* Maybe another breakpoint in the chain caused us to stop.
1886 (Currently all watchpoints go on the bpstat whether hit or
1887 not. That probably could (should) be changed, provided care is taken
1888 with respect to bpstat_explains_signal). */
1890 return bpstat_print (bs->next);
1892 /* We reached the end of the chain without printing anything. */
1896 /* Evaluate the expression EXP and return 1 if value is zero.
1897 This is used inside a catch_errors to evaluate the breakpoint condition.
1898 The argument is a "struct expression *" that has been cast to char * to
1899 make it pass through catch_errors. */
1902 breakpoint_cond_eval (exp)
1905 value_ptr mark = value_mark ();
1906 int i = !value_true (evaluate_expression ((struct expression *) exp));
1907 value_free_to_mark (mark);
1911 /* Allocate a new bpstat and chain it to the current one. */
1914 bpstat_alloc (b, cbs)
1915 register struct breakpoint *b;
1916 bpstat cbs; /* Current "bs" value */
1920 bs = (bpstat) xmalloc (sizeof (*bs));
1922 bs->breakpoint_at = b;
1923 /* If the condition is false, etc., don't do the commands. */
1924 bs->commands = NULL;
1926 bs->print_it = print_it_normal;
1930 /* Possible return values for watchpoint_check (this can't be an enum
1931 because of check_errors). */
1932 /* The watchpoint has been deleted. */
1933 #define WP_DELETED 1
1934 /* The value has changed. */
1935 #define WP_VALUE_CHANGED 2
1936 /* The value has not changed. */
1937 #define WP_VALUE_NOT_CHANGED 3
1939 #define BP_TEMPFLAG 1
1940 #define BP_HARDWAREFLAG 2
1942 /* Check watchpoint condition. */
1945 watchpoint_check (p)
1948 bpstat bs = (bpstat) p;
1949 struct breakpoint *b;
1950 struct frame_info *fr;
1951 int within_current_scope;
1953 b = bs->breakpoint_at;
1955 if (b->exp_valid_block == NULL)
1956 within_current_scope = 1;
1959 /* There is no current frame at this moment. If we're going to have
1960 any chance of handling watchpoints on local variables, we'll need
1961 the frame chain (so we can determine if we're in scope). */
1962 reinit_frame_cache ();
1963 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1964 within_current_scope = (fr != NULL);
1965 if (within_current_scope)
1966 /* If we end up stopping, the current frame will get selected
1967 in normal_stop. So this call to select_frame won't affect
1969 select_frame (fr, -1);
1972 if (within_current_scope)
1974 /* We use value_{,free_to_}mark because it could be a
1975 *long* time before we return to the command level and
1976 call free_all_values. We can't call free_all_values because
1977 we might be in the middle of evaluating a function call. */
1979 value_ptr mark = value_mark ();
1980 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1981 if (!value_equal (b->val, new_val))
1983 release_value (new_val);
1984 value_free_to_mark (mark);
1985 bs->old_val = b->val;
1987 /* We will stop here */
1988 return WP_VALUE_CHANGED;
1992 /* Nothing changed, don't do anything. */
1993 value_free_to_mark (mark);
1994 /* We won't stop here */
1995 return WP_VALUE_NOT_CHANGED;
2000 /* This seems like the only logical thing to do because
2001 if we temporarily ignored the watchpoint, then when
2002 we reenter the block in which it is valid it contains
2003 garbage (in the case of a function, it may have two
2004 garbage values, one before and one after the prologue).
2005 So we can't even detect the first assignment to it and
2006 watch after that (since the garbage may or may not equal
2007 the first value assigned). */
2009 Watchpoint %d deleted because the program has left the block in\n\
2010 which its expression is valid.\n", bs->breakpoint_at->number);
2011 if (b->related_breakpoint)
2012 b->related_breakpoint->disposition = del_at_next_stop;
2013 b->disposition = del_at_next_stop;
2019 /* This is used when everything which needs to be printed has
2020 already been printed. But we still want to print the frame. */
2022 /* Background: When we stop, bpstat_print() is called.
2023 It loops through the bpstat list of things causing this stop,
2024 calling the print_it function for each one. The default
2025 print_it function, used for breakpoints, is print_it_normal().
2026 Also see print_it_noop() and print_it_done() are the other
2027 two possibilities. See comments in bpstat_print() and
2028 in header of print_it_normal() for more detail. */
2037 /* This is used when nothing should be printed for this bpstat entry. */
2038 /* Background: When we stop, bpstat_print() is called.
2039 It loops through the bpstat list of things causing this stop,
2040 calling the print_it function for each one. The default
2041 print_it function, used for breakpoints, is print_it_normal().
2042 Also see print_it_noop() and print_it_done() are the other
2043 two possibilities. See comments in bpstat_print() and
2044 in header of print_it_normal() for more detail. */
2053 /* Get a bpstat associated with having just stopped at address *PC
2054 and frame address CORE_ADDRESS. Update *PC to point at the
2055 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2056 if this is known to not be a real breakpoint (it could still be a
2057 watchpoint, though). */
2059 /* Determine whether we stopped at a breakpoint, etc, or whether we
2060 don't understand this stop. Result is a chain of bpstat's such that:
2062 if we don't understand the stop, the result is a null pointer.
2064 if we understand why we stopped, the result is not null.
2066 Each element of the chain refers to a particular breakpoint or
2067 watchpoint at which we have stopped. (We may have stopped for
2068 several reasons concurrently.)
2070 Each element of the chain has valid next, breakpoint_at,
2071 commands, FIXME??? fields. */
2074 bpstat_stop_status (pc, not_a_breakpoint)
2076 int not_a_breakpoint;
2078 register struct breakpoint *b, *temp;
2080 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2081 int real_breakpoint = 0;
2082 /* Root of the chain of bpstat's */
2083 struct bpstats root_bs[1];
2084 /* Pointer to the last thing in the chain currently. */
2085 bpstat bs = root_bs;
2086 static char message1[] =
2087 "Error evaluating expression for watchpoint %d\n";
2088 char message[sizeof (message1) + 30 /* slop */ ];
2090 /* Get the address where the breakpoint would have been. */
2091 bp_addr = *pc - DECR_PC_AFTER_BREAK;
2093 ALL_BREAKPOINTS_SAFE (b, temp)
2095 if (b->enable == disabled
2096 || b->enable == shlib_disabled
2097 || b->enable == call_disabled)
2100 if (b->type != bp_watchpoint
2101 && b->type != bp_hardware_watchpoint
2102 && b->type != bp_read_watchpoint
2103 && b->type != bp_access_watchpoint
2104 && b->type != bp_hardware_breakpoint
2105 && b->type != bp_catch_fork
2106 && b->type != bp_catch_vfork
2107 && b->type != bp_catch_exec
2108 && b->type != bp_catch_catch
2109 && b->type != bp_catch_throw) /* a non-watchpoint bp */
2110 if (b->address != bp_addr || /* address doesn't match or */
2111 (overlay_debugging && /* overlay doesn't match */
2112 section_is_overlay (b->section) &&
2113 !section_is_mapped (b->section)))
2116 if (b->type == bp_hardware_breakpoint
2117 && b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
2120 if (b->type != bp_watchpoint
2121 && b->type != bp_hardware_watchpoint
2122 && b->type != bp_read_watchpoint
2123 && b->type != bp_access_watchpoint
2124 && not_a_breakpoint)
2127 /* Is this a catchpoint of a load or unload? If so, did we
2128 get a load or unload of the specified library? If not,
2130 if ((b->type == bp_catch_load)
2131 #if defined(SOLIB_HAVE_LOAD_EVENT)
2132 && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid)
2133 || ((b->dll_pathname != NULL)
2134 && (strcmp (b->dll_pathname, SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid)) != 0)))
2139 if ((b->type == bp_catch_unload)
2140 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2141 && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid)
2142 || ((b->dll_pathname != NULL)
2143 && (strcmp (b->dll_pathname, SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid)) != 0)))
2148 if ((b->type == bp_catch_fork)
2149 && !target_has_forked (inferior_pid, &b->forked_inferior_pid))
2152 if ((b->type == bp_catch_vfork)
2153 && !target_has_vforked (inferior_pid, &b->forked_inferior_pid))
2156 if ((b->type == bp_catch_exec)
2157 && !target_has_execd (inferior_pid, &b->exec_pathname))
2160 if (ep_is_exception_catchpoint (b) &&
2161 !(current_exception_event = target_get_current_exception_event ()))
2164 /* Come here if it's a watchpoint, or if the break address matches */
2166 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
2168 /* Watchpoints may change this, if not found to have triggered. */
2172 sprintf (message, message1, b->number);
2173 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
2175 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2178 /* We've already printed what needs to be printed. */
2179 bs->print_it = print_it_done;
2182 case WP_VALUE_CHANGED:
2186 case WP_VALUE_NOT_CHANGED:
2188 bs->print_it = print_it_noop;
2190 /* Don't consider this a hit. */
2197 /* Error from catch_errors. */
2198 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2199 if (b->related_breakpoint)
2200 b->related_breakpoint->disposition = del_at_next_stop;
2201 b->disposition = del_at_next_stop;
2202 /* We've already printed what needs to be printed. */
2203 bs->print_it = print_it_done;
2209 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
2215 addr = target_stopped_data_address ();
2218 for (v = b->val_chain; v; v = v->next)
2220 if (v->lval == lval_memory)
2224 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
2230 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2233 /* We've already printed what needs to be printed. */
2234 bs->print_it = print_it_done;
2237 case WP_VALUE_CHANGED:
2238 case WP_VALUE_NOT_CHANGED:
2245 /* Error from catch_errors. */
2246 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2247 if (b->related_breakpoint)
2248 b->related_breakpoint->disposition = del_at_next_stop;
2249 b->disposition = del_at_next_stop;
2250 /* We've already printed what needs to be printed. */
2251 bs->print_it = print_it_done;
2257 /* By definition, an encountered breakpoint is a triggered
2261 real_breakpoint = 1;
2264 if (b->frame && b->frame != (get_current_frame ())->frame &&
2265 (b->type == bp_step_resume &&
2266 (INNER_THAN (get_current_frame ()->frame, b->frame))))
2270 int value_is_zero = 0;
2274 /* Need to select the frame, with all that implies
2275 so that the conditions will have the right context. */
2276 select_frame (get_current_frame (), 0);
2278 = catch_errors (breakpoint_cond_eval, (b->cond),
2279 "Error in testing breakpoint condition:\n",
2281 /* FIXME-someday, should give breakpoint # */
2284 if (b->cond && value_is_zero)
2287 /* Don't consider this a hit. */
2290 else if (b->ignore_count > 0)
2297 /* We will stop here */
2298 if (b->disposition == disable)
2299 b->enable = disabled;
2300 bs->commands = b->commands;
2304 (STREQ ("silent", bs->commands->line) ||
2305 (xdb_commands && STREQ ("Q", bs->commands->line))))
2307 bs->commands = bs->commands->next;
2312 /* Print nothing for this entry if we dont stop or if we dont print. */
2313 if (bs->stop == 0 || bs->print == 0)
2314 bs->print_it = print_it_noop;
2317 bs->next = NULL; /* Terminate the chain */
2318 bs = root_bs->next; /* Re-grab the head of the chain */
2320 if (real_breakpoint && bs)
2322 if (bs->breakpoint_at->type == bp_hardware_breakpoint)
2324 if (DECR_PC_AFTER_HW_BREAK != 0)
2326 *pc = *pc - DECR_PC_AFTER_HW_BREAK;
2332 if (DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs)
2335 #if defined (SHIFT_INST_REGS)
2337 #else /* No SHIFT_INST_REGS. */
2339 #endif /* No SHIFT_INST_REGS. */
2344 /* The value of a hardware watchpoint hasn't changed, but the
2345 intermediate memory locations we are watching may have. */
2346 if (bs && !bs->stop &&
2347 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
2348 bs->breakpoint_at->type == bp_read_watchpoint ||
2349 bs->breakpoint_at->type == bp_access_watchpoint))
2351 remove_breakpoints ();
2352 insert_breakpoints ();
2357 /* Tell what to do about this bpstat. */
2362 /* Classify each bpstat as one of the following. */
2365 /* This bpstat element has no effect on the main_action. */
2368 /* There was a watchpoint, stop but don't print. */
2371 /* There was a watchpoint, stop and print. */
2374 /* There was a breakpoint but we're not stopping. */
2377 /* There was a breakpoint, stop but don't print. */
2380 /* There was a breakpoint, stop and print. */
2383 /* We hit the longjmp breakpoint. */
2386 /* We hit the longjmp_resume breakpoint. */
2389 /* We hit the step_resume breakpoint. */
2392 /* We hit the through_sigtramp breakpoint. */
2395 /* We hit the shared library event breakpoint. */
2398 /* We caught a shared library event. */
2401 /* This is just used to count how many enums there are. */
2405 /* Here is the table which drives this routine. So that we can
2406 format it pretty, we define some abbreviations for the
2407 enum bpstat_what codes. */
2408 #define kc BPSTAT_WHAT_KEEP_CHECKING
2409 #define ss BPSTAT_WHAT_STOP_SILENT
2410 #define sn BPSTAT_WHAT_STOP_NOISY
2411 #define sgl BPSTAT_WHAT_SINGLE
2412 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2413 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2414 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2415 #define sr BPSTAT_WHAT_STEP_RESUME
2416 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2417 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2418 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2420 /* "Can't happen." Might want to print an error message.
2421 abort() is not out of the question, but chances are GDB is just
2422 a bit confused, not unusable. */
2423 #define err BPSTAT_WHAT_STOP_NOISY
2425 /* Given an old action and a class, come up with a new action. */
2426 /* One interesting property of this table is that wp_silent is the same
2427 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2428 after stopping, the check for whether to step over a breakpoint
2429 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2430 reference to how we stopped. We retain separate wp_silent and bp_silent
2431 codes in case we want to change that someday.
2433 Another possibly interesting property of this table is that
2434 there's a partial ordering, priority-like, of the actions. Once
2435 you've decided that some action is appropriate, you'll never go
2436 back and decide something of a lower priority is better. The
2439 kc < clr sgl shl slr sn sr ss ts
2440 sgl < clrs shl shlr slr sn sr ss ts
2441 slr < err shl shlr sn sr ss ts
2442 clr < clrs err shl shlr sn sr ss ts
2443 clrs < err shl shlr sn sr ss ts
2444 ss < shl shlr sn sr ts
2451 What I think this means is that we don't need a damned table
2452 here. If you just put the rows and columns in the right order,
2453 it'd look awfully regular. We could simply walk the bpstat list
2454 and choose the highest priority action we find, with a little
2455 logic to handle the 'err' cases, and the CLEAR_LONGJMP_RESUME/
2456 CLEAR_LONGJMP_RESUME_SINGLE distinction (which breakpoint.h says
2457 is messy anyway). */
2459 /* step_resume entries: a step resume breakpoint overrides another
2460 breakpoint of signal handling (see comment in wait_for_inferior
2461 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2462 /* We handle the through_sigtramp_breakpoint the same way; having both
2463 one of those and a step_resume_breakpoint is probably very rare (?). */
2465 static const enum bpstat_what_main_action
2466 table[(int) class_last][(int) BPSTAT_WHAT_LAST] =
2469 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2472 {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl, shlr},
2474 {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2476 {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2478 {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl, shlr},
2480 {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2482 {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2484 {slr, ss, sn, slr, err, err, err, sr, ts, shl, shlr},
2486 {clr, ss, sn, clrs, err, err, err, sr, ts, shl, shlr},
2488 {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl, shlr},
2490 {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl, shlr},
2492 {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl, shlr},
2494 {shlr, shlr, shlr, shlr, shlr, shlr, shlr, shlr, ts, shlr, shlr}
2509 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
2510 struct bpstat_what retval;
2512 retval.call_dummy = 0;
2513 for (; bs != NULL; bs = bs->next)
2515 enum class bs_class = no_effect;
2516 if (bs->breakpoint_at == NULL)
2517 /* I suspect this can happen if it was a momentary breakpoint
2518 which has since been deleted. */
2520 switch (bs->breakpoint_at->type)
2526 case bp_hardware_breakpoint:
2532 bs_class = bp_noisy;
2534 bs_class = bp_silent;
2537 bs_class = bp_nostop;
2540 case bp_hardware_watchpoint:
2541 case bp_read_watchpoint:
2542 case bp_access_watchpoint:
2546 bs_class = wp_noisy;
2548 bs_class = wp_silent;
2551 /* There was a watchpoint, but we're not stopping. This requires
2552 no further action. */
2553 bs_class = no_effect;
2556 bs_class = long_jump;
2558 case bp_longjmp_resume:
2559 bs_class = long_resume;
2561 case bp_step_resume:
2564 bs_class = step_resume;
2567 /* It is for the wrong frame. */
2568 bs_class = bp_nostop;
2570 case bp_through_sigtramp:
2571 bs_class = through_sig;
2573 case bp_watchpoint_scope:
2574 bs_class = bp_nostop;
2576 case bp_shlib_event:
2577 bs_class = shlib_event;
2580 case bp_catch_unload:
2581 /* Only if this catchpoint triggered should we cause the
2582 step-out-of-dld behaviour. Otherwise, we ignore this
2585 bs_class = catch_shlib_event;
2587 bs_class = no_effect;
2590 case bp_catch_vfork:
2595 bs_class = bp_noisy;
2597 bs_class = bp_silent;
2600 /* There was a catchpoint, but we're not stopping. This requires
2601 no further action. */
2602 bs_class = no_effect;
2604 case bp_catch_catch:
2605 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_CATCH)
2606 bs_class = bp_nostop;
2608 bs_class = bs->print ? bp_noisy : bp_silent;
2610 case bp_catch_throw:
2611 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_THROW)
2612 bs_class = bp_nostop;
2614 bs_class = bs->print ? bp_noisy : bp_silent;
2617 /* Make sure the action is stop (silent or noisy), so infrun.c
2618 pops the dummy frame. */
2619 bs_class = bp_silent;
2620 retval.call_dummy = 1;
2623 current_action = table[(int) bs_class][(int) current_action];
2625 retval.main_action = current_action;
2629 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2630 without hardware support). This isn't related to a specific bpstat,
2631 just to things like whether watchpoints are set. */
2634 bpstat_should_step ()
2636 struct breakpoint *b;
2638 if (b->enable == enabled && b->type == bp_watchpoint)
2643 /* Nonzero if there are enabled hardware watchpoints. */
2645 bpstat_have_active_hw_watchpoints ()
2647 struct breakpoint *b;
2649 if ((b->enable == enabled) &&
2651 ((b->type == bp_hardware_watchpoint) ||
2652 (b->type == bp_read_watchpoint) ||
2653 (b->type == bp_access_watchpoint)))
2659 /* Given a bpstat that records zero or more triggered eventpoints, this
2660 function returns another bpstat which contains only the catchpoints
2661 on that first list, if any. */
2663 bpstat_get_triggered_catchpoints (ep_list, cp_list)
2667 struct bpstats root_bs[1];
2668 bpstat bs = root_bs;
2669 struct breakpoint *ep;
2672 bpstat_clear (cp_list);
2673 root_bs->next = NULL;
2675 for (; ep_list != NULL; ep_list = ep_list->next)
2677 /* Is this eventpoint a catchpoint? If not, ignore it. */
2678 ep = ep_list->breakpoint_at;
2681 if ((ep->type != bp_catch_load) &&
2682 (ep->type != bp_catch_unload) &&
2683 (ep->type != bp_catch_catch) &&
2684 (ep->type != bp_catch_throw)) /* pai: (temp) ADD fork/vfork here!! */
2687 /* Yes; add it to the list. */
2688 bs = bpstat_alloc (ep, bs);
2693 #if defined(SOLIB_ADD)
2694 /* Also, for each triggered catchpoint, tag it with the name of
2695 the library that caused this trigger. (We copy the name now,
2696 because it's only guaranteed to be available NOW, when the
2697 catchpoint triggers. Clients who may wish to know the name
2698 later must get it from the catchpoint itself.) */
2699 if (ep->triggered_dll_pathname != NULL)
2700 free (ep->triggered_dll_pathname);
2701 if (ep->type == bp_catch_load)
2702 dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
2704 dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid);
2706 dll_pathname = NULL;
2710 ep->triggered_dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
2711 strcpy (ep->triggered_dll_pathname, dll_pathname);
2714 ep->triggered_dll_pathname = NULL;
2720 /* Print information on breakpoint number BNUM, or -1 if all.
2721 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2722 is nonzero, process only watchpoints. */
2729 ep_type_description_t;
2732 breakpoint_1 (bnum, allflag)
2736 register struct breakpoint *b;
2737 register struct command_line *l;
2738 register struct symbol *sym;
2739 CORE_ADDR last_addr = (CORE_ADDR) - 1;
2740 int found_a_breakpoint = 0;
2741 static ep_type_description_t bptypes[] =
2743 {bp_none, "?deleted?"},
2744 {bp_breakpoint, "breakpoint"},
2745 {bp_hardware_breakpoint, "hw breakpoint"},
2746 {bp_until, "until"},
2747 {bp_finish, "finish"},
2748 {bp_watchpoint, "watchpoint"},
2749 {bp_hardware_watchpoint, "hw watchpoint"},
2750 {bp_read_watchpoint, "read watchpoint"},
2751 {bp_access_watchpoint, "acc watchpoint"},
2752 {bp_longjmp, "longjmp"},
2753 {bp_longjmp_resume, "longjmp resume"},
2754 {bp_step_resume, "step resume"},
2755 {bp_through_sigtramp, "sigtramp"},
2756 {bp_watchpoint_scope, "watchpoint scope"},
2757 {bp_call_dummy, "call dummy"},
2758 {bp_shlib_event, "shlib events"},
2759 {bp_catch_load, "catch load"},
2760 {bp_catch_unload, "catch unload"},
2761 {bp_catch_fork, "catch fork"},
2762 {bp_catch_vfork, "catch vfork"},
2763 {bp_catch_exec, "catch exec"},
2764 {bp_catch_catch, "catch catch"},
2765 {bp_catch_throw, "catch throw"}
2768 static char *bpdisps[] =
2769 {"del", "dstp", "dis", "keep"};
2770 static char bpenables[] = "nyn";
2771 char wrap_indent[80];
2776 || bnum == b->number)
2778 /* We only print out user settable breakpoints unless the allflag is set. */
2780 && b->type != bp_breakpoint
2781 && b->type != bp_catch_load
2782 && b->type != bp_catch_unload
2783 && b->type != bp_catch_fork
2784 && b->type != bp_catch_vfork
2785 && b->type != bp_catch_exec
2786 && b->type != bp_catch_catch
2787 && b->type != bp_catch_throw
2788 && b->type != bp_hardware_breakpoint
2789 && b->type != bp_watchpoint
2790 && b->type != bp_read_watchpoint
2791 && b->type != bp_access_watchpoint
2792 && b->type != bp_hardware_watchpoint)
2795 if (!found_a_breakpoint++)
2797 annotate_breakpoints_headers ();
2800 printf_filtered ("Num ");
2802 printf_filtered ("Type ");
2804 printf_filtered ("Disp ");
2806 printf_filtered ("Enb ");
2810 printf_filtered ("Address ");
2813 printf_filtered ("What\n");
2815 annotate_breakpoints_table ();
2820 printf_filtered ("%-3d ", b->number);
2822 if ((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0])))
2823 error ("bptypes table does not describe type #%d.", (int) b->type);
2824 if ((int) b->type != bptypes[(int) b->type].type)
2825 error ("bptypes table does not describe type #%d?", (int) b->type);
2826 printf_filtered ("%-14s ", bptypes[(int) b->type].description);
2828 printf_filtered ("%-4s ", bpdisps[(int) b->disposition]);
2830 printf_filtered ("%-3c ", bpenables[(int) b->enable]);
2832 strcpy (wrap_indent, " ");
2834 strcat (wrap_indent, " ");
2838 case bp_hardware_watchpoint:
2839 case bp_read_watchpoint:
2840 case bp_access_watchpoint:
2841 /* Field 4, the address, is omitted (which makes the columns
2842 not line up too nicely with the headers, but the effect
2843 is relatively readable). */
2845 print_expression (b->exp, gdb_stdout);
2849 case bp_catch_unload:
2850 /* Field 4, the address, is omitted (which makes the columns
2851 not line up too nicely with the headers, but the effect
2852 is relatively readable). */
2854 if (b->dll_pathname == NULL)
2855 printf_filtered ("<any library> ");
2857 printf_filtered ("library \"%s\" ", b->dll_pathname);
2861 case bp_catch_vfork:
2862 /* Field 4, the address, is omitted (which makes the columns
2863 not line up too nicely with the headers, but the effect
2864 is relatively readable). */
2866 if (b->forked_inferior_pid != 0)
2867 printf_filtered ("process %d ", b->forked_inferior_pid);
2871 /* Field 4, the address, is omitted (which makes the columns
2872 not line up too nicely with the headers, but the effect
2873 is relatively readable). */
2875 if (b->exec_pathname != NULL)
2876 printf_filtered ("program \"%s\" ", b->exec_pathname);
2878 case bp_catch_catch:
2879 /* Field 4, the address, is omitted (which makes the columns
2880 not line up too nicely with the headers, but the effect
2881 is relatively readable). */
2883 printf_filtered ("exception catch ");
2885 case bp_catch_throw:
2886 /* Field 4, the address, is omitted (which makes the columns
2887 not line up too nicely with the headers, but the effect
2888 is relatively readable). */
2890 printf_filtered ("exception throw ");
2894 case bp_hardware_breakpoint:
2898 case bp_longjmp_resume:
2899 case bp_step_resume:
2900 case bp_through_sigtramp:
2901 case bp_watchpoint_scope:
2903 case bp_shlib_event:
2907 /* FIXME-32x64: need a print_address_numeric with
2911 local_hex_string_custom
2912 ((unsigned long) b->address, "08l"));
2917 last_addr = b->address;
2920 sym = find_pc_sect_function (b->address, b->section);
2923 fputs_filtered ("in ", gdb_stdout);
2924 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
2925 wrap_here (wrap_indent);
2926 fputs_filtered (" at ", gdb_stdout);
2928 fputs_filtered (b->source_file, gdb_stdout);
2929 printf_filtered (":%d", b->line_number);
2932 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
2936 if (b->thread != -1)
2937 printf_filtered (" thread %d", b->thread);
2939 printf_filtered ("\n");
2945 printf_filtered ("\tstop only in stack frame at ");
2946 print_address_numeric (b->frame, 1, gdb_stdout);
2947 printf_filtered ("\n");
2954 printf_filtered ("\tstop only if ");
2955 print_expression (b->cond, gdb_stdout);
2956 printf_filtered ("\n");
2959 if (b->thread != -1)
2961 /* FIXME should make an annotation for this */
2962 printf_filtered ("\tstop only in thread %d\n", b->thread);
2965 if (show_breakpoint_hit_counts && b->hit_count)
2967 /* FIXME should make an annotation for this */
2968 if (ep_is_catchpoint (b))
2969 printf_filtered ("\tcatchpoint");
2971 printf_filtered ("\tbreakpoint");
2972 printf_filtered (" already hit %d time%s\n",
2973 b->hit_count, (b->hit_count == 1 ? "" : "s"));
2976 if (b->ignore_count)
2980 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
2983 if ((l = b->commands))
2989 print_command_line (l, 4, gdb_stdout);
2995 if (!found_a_breakpoint)
2998 printf_filtered ("No breakpoints or watchpoints.\n");
3000 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
3003 /* Compare against (CORE_ADDR)-1 in case some compiler decides
3004 that a comparison of an unsigned with -1 is always false. */
3005 if (last_addr != (CORE_ADDR) - 1)
3006 set_next_address (last_addr);
3008 annotate_breakpoints_table_end ();
3013 breakpoints_info (bnum_exp, from_tty)
3020 bnum = parse_and_eval_address (bnum_exp);
3022 breakpoint_1 (bnum, 0);
3027 maintenance_info_breakpoints (bnum_exp, from_tty)
3034 bnum = parse_and_eval_address (bnum_exp);
3036 breakpoint_1 (bnum, 1);
3039 /* Print a message describing any breakpoints set at PC. */
3042 describe_other_breakpoints (pc, section)
3046 register int others = 0;
3047 register struct breakpoint *b;
3050 if (b->address == pc)
3051 if (overlay_debugging == 0 ||
3052 b->section == section)
3056 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
3058 if (b->address == pc)
3059 if (overlay_debugging == 0 ||
3060 b->section == section)
3066 ((b->enable == disabled || b->enable == shlib_disabled || b->enable == call_disabled)
3067 ? " (disabled)" : ""),
3068 (others > 1) ? "," : ((others == 1) ? " and" : ""));
3070 printf_filtered ("also set at pc ");
3071 print_address_numeric (pc, 1, gdb_stdout);
3072 printf_filtered (".\n");
3076 /* Set the default place to put a breakpoint
3077 for the `break' command with no arguments. */
3080 set_default_breakpoint (valid, addr, symtab, line)
3083 struct symtab *symtab;
3086 default_breakpoint_valid = valid;
3087 default_breakpoint_address = addr;
3088 default_breakpoint_symtab = symtab;
3089 default_breakpoint_line = line;
3092 /* Rescan breakpoints at address ADDRESS,
3093 marking the first one as "first" and any others as "duplicates".
3094 This is so that the bpt instruction is only inserted once. */
3097 check_duplicates (address, section)
3101 register struct breakpoint *b;
3102 register int count = 0;
3104 if (address == 0) /* Watchpoints are uninteresting */
3108 if (b->enable != disabled
3109 && b->enable != shlib_disabled
3110 && b->enable != call_disabled
3111 && b->address == address
3112 && (overlay_debugging == 0 || b->section == section))
3115 b->duplicate = count > 1;
3119 /* Low level routine to set a breakpoint.
3120 Takes as args the three things that every breakpoint must have.
3121 Returns the breakpoint object so caller can set other things.
3122 Does not set the breakpoint number!
3123 Does not print anything.
3125 ==> This routine should not be called if there is a chance of later
3126 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3127 your arguments BEFORE calling this routine! */
3130 set_raw_breakpoint (sal)
3131 struct symtab_and_line sal;
3133 register struct breakpoint *b, *b1;
3135 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
3136 memset (b, 0, sizeof (*b));
3137 b->address = sal.pc;
3138 if (sal.symtab == NULL)
3139 b->source_file = NULL;
3141 b->source_file = savestring (sal.symtab->filename,
3142 strlen (sal.symtab->filename));
3143 b->section = sal.section;
3144 b->language = current_language->la_language;
3145 b->input_radix = input_radix;
3147 b->line_number = sal.line;
3148 b->enable = enabled;
3151 b->ignore_count = 0;
3154 b->dll_pathname = NULL;
3155 b->triggered_dll_pathname = NULL;
3156 b->forked_inferior_pid = 0;
3157 b->exec_pathname = NULL;
3159 /* Add this breakpoint to the end of the chain
3160 so that a list of breakpoints will come out in order
3161 of increasing numbers. */
3163 b1 = breakpoint_chain;
3165 breakpoint_chain = b;
3173 check_duplicates (sal.pc, sal.section);
3174 breakpoints_changed ();
3179 #ifdef GET_LONGJMP_TARGET
3182 create_longjmp_breakpoint (func_name)
3185 struct symtab_and_line sal;
3186 struct breakpoint *b;
3188 INIT_SAL (&sal); /* initialize to zeroes */
3189 if (func_name != NULL)
3191 struct minimal_symbol *m;
3193 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *) NULL);
3195 sal.pc = SYMBOL_VALUE_ADDRESS (m);
3199 sal.section = find_pc_overlay (sal.pc);
3200 b = set_raw_breakpoint (sal);
3204 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
3205 b->disposition = donttouch;
3206 b->enable = disabled;
3209 b->addr_string = strsave (func_name);
3210 b->number = internal_breakpoint_number--;
3213 #endif /* #ifdef GET_LONGJMP_TARGET */
3215 /* Call this routine when stepping and nexting to enable a breakpoint if we do
3216 a longjmp(). When we hit that breakpoint, call
3217 set_longjmp_resume_breakpoint() to figure out where we are going. */
3220 enable_longjmp_breakpoint ()
3222 register struct breakpoint *b;
3225 if (b->type == bp_longjmp)
3227 b->enable = enabled;
3228 check_duplicates (b->address, b->section);
3233 disable_longjmp_breakpoint ()
3235 register struct breakpoint *b;
3238 if (b->type == bp_longjmp
3239 || b->type == bp_longjmp_resume)
3241 b->enable = disabled;
3242 check_duplicates (b->address, b->section);
3248 remove_solib_event_breakpoints ()
3250 register struct breakpoint *b, *temp;
3252 ALL_BREAKPOINTS_SAFE (b, temp)
3253 if (b->type == bp_shlib_event)
3254 delete_breakpoint (b);
3258 create_solib_event_breakpoint (address)
3261 struct breakpoint *b;
3262 struct symtab_and_line sal;
3264 INIT_SAL (&sal); /* initialize to zeroes */
3266 sal.section = find_pc_overlay (sal.pc);
3267 b = set_raw_breakpoint (sal);
3268 b->number = internal_breakpoint_number--;
3269 b->disposition = donttouch;
3270 b->type = bp_shlib_event;
3274 disable_breakpoints_in_shlibs (silent)
3277 struct breakpoint *b;
3278 int disabled_shlib_breaks = 0;
3280 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3283 #if defined (PC_SOLIB)
3284 if (((b->type == bp_breakpoint) ||
3285 (b->type == bp_hardware_breakpoint)) &&
3286 (b->enable != shlib_disabled) &&
3287 (b->enable != call_disabled) &&
3289 PC_SOLIB (b->address))
3291 b->enable = shlib_disabled;
3294 if (!disabled_shlib_breaks)
3296 target_terminal_ours_for_output ();
3297 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
3299 disabled_shlib_breaks = 1;
3300 printf_filtered ("%d ", b->number);
3305 if (disabled_shlib_breaks && !silent)
3306 printf_filtered ("\n");
3309 /* Try to reenable any breakpoints in shared libraries. */
3311 re_enable_breakpoints_in_shlibs ()
3313 struct breakpoint *b;
3316 if (b->enable == shlib_disabled)
3320 /* Do not reenable the breakpoint if the shared library
3321 is still not mapped in. */
3322 if (target_read_memory (b->address, buf, 1) == 0)
3323 b->enable = enabled;
3330 create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string, bp_kind)
3335 enum bptype bp_kind;
3337 struct breakpoint *b;
3338 struct symtabs_and_lines sals;
3339 struct symtab_and_line sal;
3340 struct cleanup *old_chain;
3341 struct cleanup *canonical_strings_chain = NULL;
3343 char *addr_start = hookname;
3344 char *addr_end = NULL;
3345 char **canonical = (char **) NULL;
3346 int thread = -1; /* All threads. */
3348 /* Set a breakpoint on the specified hook. */
3349 sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical);
3350 addr_end = hookname;
3352 if (sals.nelts == 0)
3354 warning ("Unable to set a breakpoint on dynamic linker callback.");
3355 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3356 warning ("GDB will be unable to track shl_load/shl_unload calls");
3359 if (sals.nelts != 1)
3361 warning ("Unable to set a unique breakpoint on dynamic linker callback.");
3362 warning ("GDB will be unable to track shl_load/shl_unload calls");
3366 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3367 the following errors out. */
3368 old_chain = make_cleanup (free, sals.sals);
3369 if (canonical != (char **) NULL)
3371 make_cleanup (free, canonical);
3372 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3373 if (canonical[0] != NULL)
3374 make_cleanup (free, canonical[0]);
3377 resolve_sal_pc (&sals.sals[0]);
3379 /* Remove the canonical strings from the cleanup, they are needed below. */
3380 if (canonical != (char **) NULL)
3381 discard_cleanups (canonical_strings_chain);
3383 b = set_raw_breakpoint (sals.sals[0]);
3384 set_breakpoint_count (breakpoint_count + 1);
3385 b->number = breakpoint_count;
3387 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3390 if (canonical != (char **) NULL && canonical[0] != NULL)
3391 b->addr_string = canonical[0];
3392 else if (addr_start)
3393 b->addr_string = savestring (addr_start, addr_end - addr_start);
3395 b->enable = enabled;
3396 b->disposition = tempflag ? del : donttouch;
3398 if (dll_pathname == NULL)
3399 b->dll_pathname = NULL;
3402 b->dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
3403 strcpy (b->dll_pathname, dll_pathname);
3408 do_cleanups (old_chain);
3412 create_solib_load_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3418 create_solib_load_unload_event_breakpoint (hookname,
3426 create_solib_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3432 create_solib_load_unload_event_breakpoint (hookname,
3440 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_kind)
3443 enum bptype bp_kind;
3445 struct symtab_and_line sal;
3446 struct breakpoint *b;
3447 int thread = -1; /* All threads. */
3454 b = set_raw_breakpoint (sal);
3455 set_breakpoint_count (breakpoint_count + 1);
3456 b->number = breakpoint_count;
3458 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3460 b->addr_string = NULL;
3461 b->enable = enabled;
3462 b->disposition = tempflag ? del : donttouch;
3463 b->forked_inferior_pid = 0;
3471 create_fork_event_catchpoint (tempflag, cond_string)
3475 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_fork);
3479 create_vfork_event_catchpoint (tempflag, cond_string)
3483 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_vfork);
3487 create_exec_event_catchpoint (tempflag, cond_string)
3491 struct symtab_and_line sal;
3492 struct breakpoint *b;
3493 int thread = -1; /* All threads. */
3500 b = set_raw_breakpoint (sal);
3501 set_breakpoint_count (breakpoint_count + 1);
3502 b->number = breakpoint_count;
3504 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3506 b->addr_string = NULL;
3507 b->enable = enabled;
3508 b->disposition = tempflag ? del : donttouch;
3510 b->type = bp_catch_exec;
3516 hw_breakpoint_used_count ()
3518 register struct breakpoint *b;
3523 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
3531 hw_watchpoint_used_count (type, other_type_used)
3533 int *other_type_used;
3535 register struct breakpoint *b;
3538 *other_type_used = 0;
3541 if (b->enable == enabled)
3543 if (b->type == type)
3545 else if ((b->type == bp_hardware_watchpoint ||
3546 b->type == bp_read_watchpoint ||
3547 b->type == bp_access_watchpoint)
3548 && b->enable == enabled)
3549 *other_type_used = 1;
3555 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
3556 breakpoint at the target of the jmp_buf.
3558 FIXME - This ought to be done by setting a temporary breakpoint that gets
3559 deleted automatically... */
3562 set_longjmp_resume_breakpoint (pc, frame)
3564 struct frame_info *frame;
3566 register struct breakpoint *b;
3569 if (b->type == bp_longjmp_resume)
3572 b->enable = enabled;
3574 b->frame = frame->frame;
3577 check_duplicates (b->address, b->section);
3583 disable_watchpoints_before_interactive_call_start ()
3585 struct breakpoint *b;
3589 if (((b->type == bp_watchpoint)
3590 || (b->type == bp_hardware_watchpoint)
3591 || (b->type == bp_read_watchpoint)
3592 || (b->type == bp_access_watchpoint)
3593 || ep_is_exception_catchpoint (b))
3594 && (b->enable == enabled))
3596 b->enable = call_disabled;
3597 check_duplicates (b->address, b->section);
3603 enable_watchpoints_after_interactive_call_stop ()
3605 struct breakpoint *b;
3609 if (((b->type == bp_watchpoint)
3610 || (b->type == bp_hardware_watchpoint)
3611 || (b->type == bp_read_watchpoint)
3612 || (b->type == bp_access_watchpoint)
3613 || ep_is_exception_catchpoint (b))
3614 && (b->enable == call_disabled))
3616 b->enable = enabled;
3617 check_duplicates (b->address, b->section);
3623 /* Set a breakpoint that will evaporate an end of command
3624 at address specified by SAL.
3625 Restrict it to frame FRAME if FRAME is nonzero. */
3628 set_momentary_breakpoint (sal, frame, type)
3629 struct symtab_and_line sal;
3630 struct frame_info *frame;
3633 register struct breakpoint *b;
3634 b = set_raw_breakpoint (sal);
3636 b->enable = enabled;
3637 b->disposition = donttouch;
3638 b->frame = (frame ? frame->frame : 0);
3640 /* If we're debugging a multi-threaded program, then we
3641 want momentary breakpoints to be active in only a
3642 single thread of control. */
3643 if (in_thread_list (inferior_pid))
3644 b->thread = pid_to_thread_id (inferior_pid);
3650 /* Tell the user we have just set a breakpoint B. */
3654 struct breakpoint *b;
3658 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3659 watchpoint) other than breakpoint creation. It should be possible to
3660 clean this up and at the same time replace the random calls to
3661 breakpoint_changed with this hook, as has already been done for
3662 delete_breakpoint_hook and so on. */
3663 if (create_breakpoint_hook)
3664 create_breakpoint_hook (b);
3669 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b->number);
3672 printf_filtered ("Watchpoint %d: ", b->number);
3673 print_expression (b->exp, gdb_stdout);
3675 case bp_hardware_watchpoint:
3676 printf_filtered ("Hardware watchpoint %d: ", b->number);
3677 print_expression (b->exp, gdb_stdout);
3679 case bp_read_watchpoint:
3680 printf_filtered ("Hardware read watchpoint %d: ", b->number);
3681 print_expression (b->exp, gdb_stdout);
3683 case bp_access_watchpoint:
3684 printf_filtered ("Hardware access (read/write) watchpoint %d: ", b->number);
3685 print_expression (b->exp, gdb_stdout);
3688 printf_filtered ("Breakpoint %d", b->number);
3691 case bp_hardware_breakpoint:
3692 printf_filtered ("Hardware assisted breakpoint %d", b->number);
3696 case bp_catch_unload:
3697 printf_filtered ("Catchpoint %d (%s %s)",
3699 (b->type == bp_catch_load) ? "load" : "unload",
3700 (b->dll_pathname != NULL) ? b->dll_pathname : "<any library>");
3703 case bp_catch_vfork:
3704 printf_filtered ("Catchpoint %d (%s)",
3706 (b->type == bp_catch_fork) ? "fork" : "vfork");
3709 printf_filtered ("Catchpoint %d (exec)",
3712 case bp_catch_catch:
3713 case bp_catch_throw:
3714 printf_filtered ("Catchpoint %d (%s)",
3716 (b->type == bp_catch_catch) ? "catch" : "throw");
3722 case bp_longjmp_resume:
3723 case bp_step_resume:
3724 case bp_through_sigtramp:
3726 case bp_watchpoint_scope:
3727 case bp_shlib_event:
3732 if (addressprint || b->source_file == NULL)
3734 printf_filtered (" at ");
3735 print_address_numeric (b->address, 1, gdb_stdout);
3738 printf_filtered (": file %s, line %d.",
3739 b->source_file, b->line_number);
3740 TUIDO (((TuiOpaqueFuncPtr) tui_vAllSetHasBreakAt, b, 1));
3741 TUIDO (((TuiOpaqueFuncPtr) tuiUpdateAllExecInfos));
3743 printf_filtered ("\n");
3747 /* Set a breakpoint according to ARG (function, linenum or *address)
3748 flag: first bit : 0 non-temporary, 1 temporary.
3749 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3752 break_command_1 (arg, flag, from_tty)
3756 int tempflag, hardwareflag;
3757 struct symtabs_and_lines sals;
3758 struct symtab_and_line sal;
3759 register struct expression *cond = 0;
3760 register struct breakpoint *b;
3762 /* Pointers in arg to the start, and one past the end, of the condition. */
3763 char *cond_start = NULL;
3764 char *cond_end = NULL;
3765 /* Pointers in arg to the start, and one past the end,
3766 of the address part. */
3767 char *addr_start = NULL;
3768 char *addr_end = NULL;
3769 struct cleanup *old_chain;
3770 struct cleanup *canonical_strings_chain = NULL;
3771 char **canonical = (char **) NULL;
3775 hardwareflag = flag & BP_HARDWAREFLAG;
3776 tempflag = flag & BP_TEMPFLAG;
3781 INIT_SAL (&sal); /* initialize to zeroes */
3783 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3785 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
3786 && (arg[2] == ' ' || arg[2] == '\t')))
3788 if (default_breakpoint_valid)
3790 sals.sals = (struct symtab_and_line *)
3791 xmalloc (sizeof (struct symtab_and_line));
3792 sal.pc = default_breakpoint_address;
3793 sal.line = default_breakpoint_line;
3794 sal.symtab = default_breakpoint_symtab;
3795 sal.section = find_pc_overlay (sal.pc);
3800 error ("No default breakpoint address now.");
3806 /* Force almost all breakpoints to be in terms of the
3807 current_source_symtab (which is decode_line_1's default). This
3808 should produce the results we want almost all of the time while
3809 leaving default_breakpoint_* alone. */
3810 if (default_breakpoint_valid
3811 && (!current_source_symtab
3812 || (arg && (*arg == '+' || *arg == '-'))))
3813 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
3814 default_breakpoint_line, &canonical);
3816 sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical);
3824 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3825 the following `for' loop errors out. */
3826 old_chain = make_cleanup (free, sals.sals);
3827 if (canonical != (char **) NULL)
3829 make_cleanup (free, canonical);
3830 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3831 for (i = 0; i < sals.nelts; i++)
3833 if (canonical[i] != NULL)
3834 make_cleanup (free, canonical[i]);
3838 thread = -1; /* No specific thread yet */
3840 /* Resolve all line numbers to PC's, and verify that conditions
3841 can be parsed, before setting any breakpoints. */
3842 for (i = 0; i < sals.nelts; i++)
3844 char *tok, *end_tok;
3847 resolve_sal_pc (&sals.sals[i]);
3849 /* It's possible for the PC to be nonzero, but still an illegal
3850 value on some targets.
3852 For example, on HP-UX if you start gdb, and before running the
3853 inferior you try to set a breakpoint on a shared library function
3854 "foo" where the inferior doesn't call "foo" directly but does
3855 pass its address to another function call, then we do find a
3856 minimal symbol for the "foo", but it's address is invalid.
3857 (Appears to be an index into a table that the loader sets up
3858 when the inferior is run.)
3860 Give the target a chance to bless sals.sals[i].pc before we
3861 try to make a breakpoint for it. */
3862 if (PC_REQUIRES_RUN_BEFORE_USE (sals.sals[i].pc))
3864 error ("Cannot break on %s without a running program.", addr_start);
3871 while (*tok == ' ' || *tok == '\t')
3876 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
3879 toklen = end_tok - tok;
3881 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
3883 tok = cond_start = end_tok + 1;
3884 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
3887 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
3893 thread = strtol (tok, &tok, 0);
3895 error ("Junk after thread keyword.");
3896 if (!valid_thread_id (thread))
3897 error ("Unknown thread %d\n", thread);
3900 error ("Junk at end of arguments.");
3905 int i, target_resources_ok;
3907 i = hw_breakpoint_used_count ();
3908 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
3909 bp_hardware_breakpoint, i + sals.nelts, 0);
3910 if (target_resources_ok == 0)
3911 error ("No hardware breakpoint support in the target.");
3912 else if (target_resources_ok < 0)
3913 error ("Hardware breakpoints used exceeds limit.");
3916 /* Remove the canonical strings from the cleanup, they are needed below. */
3917 if (canonical != (char **) NULL)
3918 discard_cleanups (canonical_strings_chain);
3920 /* Now set all the breakpoints. */
3921 for (i = 0; i < sals.nelts; i++)
3926 describe_other_breakpoints (sal.pc, sal.section);
3928 b = set_raw_breakpoint (sal);
3929 set_breakpoint_count (breakpoint_count + 1);
3930 b->number = breakpoint_count;
3931 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
3935 /* If a canonical line spec is needed use that instead of the
3937 if (canonical != (char **) NULL && canonical[i] != NULL)
3938 b->addr_string = canonical[i];
3939 else if (addr_start)
3940 b->addr_string = savestring (addr_start, addr_end - addr_start);
3942 b->cond_string = savestring (cond_start, cond_end - cond_start);
3944 b->enable = enabled;
3945 b->disposition = tempflag ? del : donttouch;
3951 printf_filtered ("Multiple breakpoints were set.\n");
3952 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3954 do_cleanups (old_chain);
3958 break_at_finish_at_depth_command_1 (arg, flag, from_tty)
3963 struct frame_info *frame;
3964 CORE_ADDR low, high, selected_pc = 0;
3965 char *extra_args, *level_arg, *addr_string;
3966 int extra_args_len = 0, if_arg = 0;
3969 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
3972 if (default_breakpoint_valid)
3976 selected_pc = selected_frame->pc;
3981 error ("No selected frame.");
3984 error ("No default breakpoint address now.");
3988 extra_args = strchr (arg, ' ');
3992 extra_args_len = strlen (extra_args);
3993 level_arg = (char *) xmalloc (extra_args - arg);
3994 strncpy (level_arg, arg, extra_args - arg - 1);
3995 level_arg[extra_args - arg - 1] = '\0';
3999 level_arg = (char *) xmalloc (strlen (arg) + 1);
4000 strcpy (level_arg, arg);
4003 frame = parse_frame_specification (level_arg);
4005 selected_pc = frame->pc;
4012 extra_args_len = strlen (arg);
4017 if (find_pc_partial_function (selected_pc, (char **) NULL, &low, &high))
4019 addr_string = (char *) xmalloc (26 + extra_args_len);
4021 sprintf (addr_string, "*0x%x %s", high, extra_args);
4023 sprintf (addr_string, "*0x%x", high);
4024 break_command_1 (addr_string, flag, from_tty);
4028 error ("No function contains the specified address");
4031 error ("Unable to set breakpoint at procedure exit");
4036 break_at_finish_command_1 (arg, flag, from_tty)
4041 char *addr_string, *break_string, *beg_addr_string;
4042 CORE_ADDR low, high;
4043 struct symtabs_and_lines sals;
4044 struct symtab_and_line sal;
4045 struct cleanup *old_chain;
4047 int extra_args_len = 0;
4051 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
4053 if (default_breakpoint_valid)
4057 addr_string = (char *) xmalloc (15);
4058 sprintf (addr_string, "*0x%x", selected_frame->pc);
4063 error ("No selected frame.");
4066 error ("No default breakpoint address now.");
4070 addr_string = (char *) xmalloc (strlen (arg) + 1);
4071 strcpy (addr_string, arg);
4077 extra_args_len = strlen (arg);
4081 /* get the stuff after the function name or address */
4082 extra_args = strchr (arg, ' ');
4086 extra_args_len = strlen (extra_args);
4093 beg_addr_string = addr_string;
4094 sals = decode_line_1 (&addr_string, 1, (struct symtab *) NULL, 0,
4097 free (beg_addr_string);
4098 old_chain = make_cleanup (free, sals.sals);
4099 for (i = 0; (i < sals.nelts); i++)
4102 if (find_pc_partial_function (sal.pc, (char **) NULL, &low, &high))
4104 break_string = (char *) xmalloc (extra_args_len + 26);
4106 sprintf (break_string, "*0x%x %s", high, extra_args);
4108 sprintf (break_string, "*0x%x", high);
4109 break_command_1 (break_string, flag, from_tty);
4110 free (break_string);
4113 error ("No function contains the specified address");
4117 printf_filtered ("Multiple breakpoints were set.\n");
4118 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
4120 do_cleanups (old_chain);
4124 /* Helper function for break_command_1 and disassemble_command. */
4127 resolve_sal_pc (sal)
4128 struct symtab_and_line *sal;
4132 if (sal->pc == 0 && sal->symtab != NULL)
4134 if (!find_line_pc (sal->symtab, sal->line, &pc))
4135 error ("No line %d in file \"%s\".",
4136 sal->line, sal->symtab->filename);
4140 if (sal->section == 0 && sal->symtab != NULL)
4142 struct blockvector *bv;
4147 bv = blockvector_for_pc_sect (sal->pc, 0, &index, sal->symtab);
4150 b = BLOCKVECTOR_BLOCK (bv, index);
4151 sym = block_function (b);
4154 fixup_symbol_section (sym, sal->symtab->objfile);
4155 sal->section = SYMBOL_BFD_SECTION (sym);
4159 /* It really is worthwhile to have the section, so we'll just
4160 have to look harder. This case can be executed if we have
4161 line numbers but no functions (as can happen in assembly
4164 struct minimal_symbol *msym;
4166 msym = lookup_minimal_symbol_by_pc (sal->pc);
4168 sal->section = SYMBOL_BFD_SECTION (msym);
4175 break_command (arg, from_tty)
4179 break_command_1 (arg, 0, from_tty);
4183 break_at_finish_command (arg, from_tty)
4187 break_at_finish_command_1 (arg, 0, from_tty);
4191 break_at_finish_at_depth_command (arg, from_tty)
4195 break_at_finish_at_depth_command_1 (arg, 0, from_tty);
4199 tbreak_command (arg, from_tty)
4203 break_command_1 (arg, BP_TEMPFLAG, from_tty);
4207 tbreak_at_finish_command (arg, from_tty)
4211 break_at_finish_command_1 (arg, BP_TEMPFLAG, from_tty);
4215 hbreak_command (arg, from_tty)
4219 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
4223 thbreak_command (arg, from_tty)
4227 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
4231 stop_command (arg, from_tty)
4235 printf_filtered ("Specify the type of breakpoint to set.\n\
4236 Usage: stop in <function | address>\n\
4241 stopin_command (arg, from_tty)
4247 if (arg == (char *) NULL)
4249 else if (*arg != '*')
4254 /* look for a ':'. If this is a line number specification, then say
4255 it is bad, otherwise, it should be an address or function/method
4257 while (*argptr && !hasColon)
4259 hasColon = (*argptr == ':');
4264 badInput = (*argptr != ':'); /* Not a class::method */
4266 badInput = isdigit (*arg); /* a simple line number */
4270 printf_filtered ("Usage: stop in <function | address>\n");
4272 break_command_1 (arg, 0, from_tty);
4276 stopat_command (arg, from_tty)
4282 if (arg == (char *) NULL || *arg == '*') /* no line number */
4289 /* look for a ':'. If there is a '::' then get out, otherwise
4290 it is probably a line number. */
4291 while (*argptr && !hasColon)
4293 hasColon = (*argptr == ':');
4298 badInput = (*argptr == ':'); /* we have class::method */
4300 badInput = !isdigit (*arg); /* not a line number */
4304 printf_filtered ("Usage: stop at <line>\n");
4306 break_command_1 (arg, 0, from_tty);
4310 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write) */
4312 watch_command_1 (arg, accessflag, from_tty)
4317 struct breakpoint *b;
4318 struct symtab_and_line sal;
4319 struct expression *exp;
4320 struct block *exp_valid_block;
4321 struct value *val, *mark;
4322 struct frame_info *frame;
4323 struct frame_info *prev_frame = NULL;
4324 char *exp_start = NULL;
4325 char *exp_end = NULL;
4326 char *tok, *end_tok;
4328 char *cond_start = NULL;
4329 char *cond_end = NULL;
4330 struct expression *cond = NULL;
4331 int i, other_type_used, target_resources_ok = 0;
4332 enum bptype bp_type;
4335 INIT_SAL (&sal); /* initialize to zeroes */
4337 /* Parse arguments. */
4338 innermost_block = NULL;
4340 exp = parse_exp_1 (&arg, 0, 0);
4342 exp_valid_block = innermost_block;
4343 mark = value_mark ();
4344 val = evaluate_expression (exp);
4345 release_value (val);
4346 if (VALUE_LAZY (val))
4347 value_fetch_lazy (val);
4350 while (*tok == ' ' || *tok == '\t')
4354 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
4357 toklen = end_tok - tok;
4358 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
4360 tok = cond_start = end_tok + 1;
4361 cond = parse_exp_1 (&tok, 0, 0);
4365 error ("Junk at end of command.");
4367 if (accessflag == 1)
4368 bp_type = bp_read_watchpoint;
4369 else if (accessflag == 2)
4370 bp_type = bp_access_watchpoint;
4372 bp_type = bp_hardware_watchpoint;
4374 mem_cnt = can_use_hardware_watchpoint (val);
4375 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
4376 error ("Expression cannot be implemented with read/access watchpoint.");
4379 i = hw_watchpoint_used_count (bp_type, &other_type_used);
4380 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
4381 bp_type, i + mem_cnt, other_type_used);
4382 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
4383 error ("Target does not have this type of hardware watchpoint support.");
4384 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
4385 error ("Target resources have been allocated for other types of watchpoints.");
4388 #if defined(HPUXHPPA)
4389 /* On HP-UX if you set a h/w
4390 watchpoint before the "run" command, the inferior dies with a e.g.,
4391 SIGILL once you start it. I initially believed this was due to a
4392 bad interaction between page protection traps and the initial
4393 startup sequence by the dynamic linker.
4395 However, I tried avoiding that by having HP-UX's implementation of
4396 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4397 yet, which forced slow watches before a "run" or "attach", and it
4398 still fails somewhere in the startup code.
4400 Until I figure out what's happening, I'm disallowing watches altogether
4401 before the "run" or "attach" command. We'll tell the user they must
4402 set watches after getting the program started. */
4403 if (!target_has_execution)
4405 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4408 #endif /* HPUXHPPA */
4410 /* Now set up the breakpoint. */
4411 b = set_raw_breakpoint (sal);
4412 set_breakpoint_count (breakpoint_count + 1);
4413 b->number = breakpoint_count;
4414 b->disposition = donttouch;
4416 b->exp_valid_block = exp_valid_block;
4417 b->exp_string = savestring (exp_start, exp_end - exp_start);
4421 b->cond_string = savestring (cond_start, cond_end - cond_start);
4425 frame = block_innermost_frame (exp_valid_block);
4428 prev_frame = get_prev_frame (frame);
4429 b->watchpoint_frame = frame->frame;
4432 b->watchpoint_frame = (CORE_ADDR) 0;
4434 if (mem_cnt && target_resources_ok > 0)
4437 b->type = bp_watchpoint;
4439 /* If the expression is "local", then set up a "watchpoint scope"
4440 breakpoint at the point where we've left the scope of the watchpoint
4442 if (innermost_block)
4446 struct breakpoint *scope_breakpoint;
4447 struct symtab_and_line scope_sal;
4449 INIT_SAL (&scope_sal); /* initialize to zeroes */
4450 scope_sal.pc = get_frame_pc (prev_frame);
4451 scope_sal.section = find_pc_overlay (scope_sal.pc);
4453 scope_breakpoint = set_raw_breakpoint (scope_sal);
4454 set_breakpoint_count (breakpoint_count + 1);
4455 scope_breakpoint->number = breakpoint_count;
4457 scope_breakpoint->type = bp_watchpoint_scope;
4458 scope_breakpoint->enable = enabled;
4460 /* Automatically delete the breakpoint when it hits. */
4461 scope_breakpoint->disposition = del;
4463 /* Only break in the proper frame (help with recursion). */
4464 scope_breakpoint->frame = prev_frame->frame;
4466 /* Set the address at which we will stop. */
4467 scope_breakpoint->address = get_frame_pc (prev_frame);
4469 /* The scope breakpoint is related to the watchpoint. We
4470 will need to act on them together. */
4471 b->related_breakpoint = scope_breakpoint;
4474 value_free_to_mark (mark);
4478 /* Return count of locations need to be watched and can be handled
4479 in hardware. If the watchpoint can not be handled
4480 in hardware return zero. */
4482 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4483 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_size) \
4484 ((byte_size) <= (REGISTER_SIZE))
4488 can_use_hardware_watchpoint (v)
4491 int found_memory_cnt = 0;
4493 /* Did the user specifically forbid us to use hardware watchpoints? */
4494 if (!can_use_hw_watchpoints)
4497 /* Make sure all the intermediate values are in memory. Also make sure
4498 we found at least one memory expression. Guards against watch 0x12345,
4499 which is meaningless, but could cause errors if one tries to insert a
4500 hardware watchpoint for the constant expression. */
4501 for (; v; v = v->next)
4503 if (v->lval == lval_memory)
4505 if (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (TYPE_LENGTH (VALUE_TYPE (v))))
4508 else if (v->lval != not_lval && v->modifiable == 0)
4512 /* The expression itself looks suitable for using a hardware
4513 watchpoint, but give the target machine a chance to reject it. */
4514 return found_memory_cnt;
4518 watch_command (arg, from_tty)
4522 watch_command_1 (arg, 0, from_tty);
4526 rwatch_command (arg, from_tty)
4530 watch_command_1 (arg, 1, from_tty);
4534 awatch_command (arg, from_tty)
4538 watch_command_1 (arg, 2, from_tty);
4542 /* Helper routines for the until_command routine in infcmd.c. Here
4543 because it uses the mechanisms of breakpoints. */
4545 /* This function is called by fetch_inferior_event via the
4546 cmd_continuation pointer, to complete the until command. It takes
4547 care of cleaning up the temporary breakpoints set up by the until
4550 until_break_command_continuation (arg)
4551 struct continuation_arg *arg;
4553 /* Do all the exec cleanups, which at this point should only be the
4554 one set up in the first part of the until_break_command
4556 do_exec_cleanups (ALL_CLEANUPS);
4561 until_break_command (arg, from_tty)
4565 struct symtabs_and_lines sals;
4566 struct symtab_and_line sal;
4567 struct frame_info *prev_frame = get_prev_frame (selected_frame);
4568 struct breakpoint *breakpoint;
4569 struct cleanup *old_chain;
4570 struct continuation_arg *arg1, *arg2;
4572 clear_proceed_status ();
4574 /* Set a breakpoint where the user wants it and at return from
4577 if (default_breakpoint_valid)
4578 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
4579 default_breakpoint_line, (char ***) NULL);
4581 sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, (char ***) NULL);
4583 if (sals.nelts != 1)
4584 error ("Couldn't get information on specified line.");
4587 free ((PTR) sals.sals); /* malloc'd, so freed */
4590 error ("Junk at end of arguments.");
4592 resolve_sal_pc (&sal);
4594 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
4596 if (!async_p || !target_has_async)
4597 old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4599 make_exec_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4601 /* If we are running asynchronously, and the target supports async
4602 execution, we are not waiting for the target to stop, in the call
4603 tp proceed, below. This means that we cannot delete the
4604 brekpoints until the target has actually stopped. The only place
4605 where we get a chance to do that is in fetch_inferior_event, so
4606 we must set things up for that. */
4608 if (async_p && target_has_async)
4610 /* In this case we don't need args for the continuation, because
4611 all it needs to do is do the cleanups in the
4612 exec_cleanup_chain, which will be only those inserted by this
4613 function. We can get away by using ALL_CLEANUPS. */
4614 add_continuation (until_break_command_continuation, NULL);
4617 /* Keep within the current frame */
4621 sal = find_pc_line (prev_frame->pc, 0);
4622 sal.pc = prev_frame->pc;
4623 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
4624 if (!async_p || !target_has_async)
4625 make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4627 make_exec_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4630 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
4631 /* Do the cleanups now, anly if we are not running asynchronously,
4632 of if we are, but the target is still synchronous. */
4633 if (!async_p || !target_has_async)
4634 do_cleanups (old_chain);
4638 /* These aren't used; I don't konw what they were for. */
4639 /* Set a breakpoint at the catch clause for NAME. */
4641 catch_breakpoint (name)
4647 disable_catch_breakpoint ()
4652 delete_catch_breakpoint ()
4657 enable_catch_breakpoint ()
4664 struct sal_chain *next;
4665 struct symtab_and_line sal;
4669 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4670 had been commented out in the v.4.16 sources, and stays
4671 disabled there now because "catch NAME" syntax isn't allowed.
4673 /* This isn't used; I don't know what it was for. */
4674 /* For each catch clause identified in ARGS, run FUNCTION
4675 with that clause as an argument. */
4676 static struct symtabs_and_lines
4677 map_catch_names (args, function)
4681 register char *p = args;
4683 struct symtabs_and_lines sals;
4685 struct sal_chain *sal_chain = 0;
4689 error_no_arg ("one or more catch names");
4697 /* Don't swallow conditional part. */
4698 if (p1[0] == 'i' && p1[1] == 'f'
4699 && (p1[2] == ' ' || p1[2] == '\t'))
4705 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
4709 if (*p1 && *p1 != ' ' && *p1 != '\t')
4710 error ("Arguments must be catch names.");
4716 struct sal_chain *next = (struct sal_chain *)
4717 alloca (sizeof (struct sal_chain));
4718 next->next = sal_chain;
4719 next->sal = get_catch_sal (p);
4724 printf_unfiltered ("No catch clause for exception %s.\n", p);
4729 while (*p == ' ' || *p == '\t')
4735 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4737 static struct symtabs_and_lines
4738 get_catch_sals (this_level_only)
4739 int this_level_only;
4741 register struct blockvector *bl;
4742 register struct block *block;
4743 int index, have_default = 0;
4745 struct symtabs_and_lines sals;
4746 struct sal_chain *sal_chain = 0;
4747 char *blocks_searched;
4749 /* Not sure whether an error message is always the correct response,
4750 but it's better than a core dump. */
4751 if (selected_frame == NULL)
4752 error ("No selected frame.");
4753 block = get_frame_block (selected_frame);
4754 pc = selected_frame->pc;
4760 error ("No symbol table info available.\n");
4762 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
4763 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4764 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4768 CORE_ADDR end = BLOCK_END (block) - 4;
4771 if (bl != blockvector_for_pc (end, &index))
4772 error ("blockvector blotch");
4773 if (BLOCKVECTOR_BLOCK (bl, index) != block)
4774 error ("blockvector botch");
4775 last_index = BLOCKVECTOR_NBLOCKS (bl);
4778 /* Don't print out blocks that have gone by. */
4779 while (index < last_index
4780 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
4783 while (index < last_index
4784 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
4786 if (blocks_searched[index] == 0)
4788 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
4791 register struct symbol *sym;
4793 nsyms = BLOCK_NSYMS (b);
4795 for (i = 0; i < nsyms; i++)
4797 sym = BLOCK_SYM (b, i);
4798 if (STREQ (SYMBOL_NAME (sym), "default"))
4804 if (SYMBOL_CLASS (sym) == LOC_LABEL)
4806 struct sal_chain *next = (struct sal_chain *)
4807 alloca (sizeof (struct sal_chain));
4808 next->next = sal_chain;
4809 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
4813 blocks_searched[index] = 1;
4819 if (sal_chain && this_level_only)
4822 /* After handling the function's top-level block, stop.
4823 Don't continue to its superblock, the block of
4824 per-file symbols. */
4825 if (BLOCK_FUNCTION (block))
4827 block = BLOCK_SUPERBLOCK (block);
4832 struct sal_chain *tmp_chain;
4834 /* Count the number of entries. */
4835 for (index = 0, tmp_chain = sal_chain; tmp_chain;
4836 tmp_chain = tmp_chain->next)
4840 sals.sals = (struct symtab_and_line *)
4841 xmalloc (index * sizeof (struct symtab_and_line));
4842 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
4843 sals.sals[index] = sal_chain->sal;
4850 ep_skip_leading_whitespace (s)
4853 if ((s == NULL) || (*s == NULL))
4855 while (isspace (**s))
4859 /* This function examines a string, and attempts to find a token
4860 that might be an event name in the leading characters. If a
4861 possible match is found, a pointer to the last character of
4862 the token is returned. Else, NULL is returned. */
4864 ep_find_event_name_end (arg)
4868 char *event_name_end = NULL;
4870 /* If we could depend upon the presense of strrpbrk, we'd use that... */
4874 /* We break out of the loop when we find a token delimiter.
4875 Basically, we're looking for alphanumerics and underscores;
4876 anything else delimites the token. */
4879 if (!isalnum (*s) && (*s != '_'))
4885 return event_name_end;
4889 /* This function attempts to parse an optional "if <cond>" clause
4890 from the arg string. If one is not found, it returns NULL.
4892 Else, it returns a pointer to the condition string. (It does not
4893 attempt to evaluate the string against a particular block.) And,
4894 it updates arg to point to the first character following the parsed
4895 if clause in the arg string. */
4897 ep_parse_optional_if_clause (arg)
4902 if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2]))
4905 /* Skip the "if" keyword. */
4908 /* Skip any extra leading whitespace, and record the start of the
4909 condition string. */
4910 ep_skip_leading_whitespace (arg);
4913 /* Assume that the condition occupies the remainder of the arg string. */
4914 (*arg) += strlen (cond_string);
4919 /* This function attempts to parse an optional filename from the arg
4920 string. If one is not found, it returns NULL.
4922 Else, it returns a pointer to the parsed filename. (This function
4923 makes no attempt to verify that a file of that name exists, or is
4924 accessible.) And, it updates arg to point to the first character
4925 following the parsed filename in the arg string.
4927 Note that clients needing to preserve the returned filename for
4928 future access should copy it to their own buffers. */
4930 ep_parse_optional_filename (arg)
4933 static char filename[1024];
4938 if ((*arg_p == '\0') || isspace (*arg_p))
4956 /* Commands to deal with catching events, such as signals, exceptions,
4957 process start/exit, etc. */
4961 catch_fork, catch_vfork
4965 static void catch_fork_command_1 PARAMS ((catch_fork_kind fork_kind, char *arg, int tempflag, int from_tty));
4968 catch_fork_command_1 (fork_kind, arg, tempflag, from_tty)
4969 catch_fork_kind fork_kind;
4974 char *cond_string = NULL;
4976 ep_skip_leading_whitespace (&arg);
4978 /* The allowed syntax is:
4980 catch [v]fork if <cond>
4982 First, check if there's an if clause. */
4983 cond_string = ep_parse_optional_if_clause (&arg);
4985 if ((*arg != '\0') && !isspace (*arg))
4986 error ("Junk at end of arguments.");
4988 /* If this target supports it, create a fork or vfork catchpoint
4989 and enable reporting of such events. */
4993 create_fork_event_catchpoint (tempflag, cond_string);
4996 create_vfork_event_catchpoint (tempflag, cond_string);
4999 error ("unsupported or unknown fork kind; cannot catch it");
5005 catch_exec_command_1 (arg, tempflag, from_tty)
5010 char *cond_string = NULL;
5012 ep_skip_leading_whitespace (&arg);
5014 /* The allowed syntax is:
5016 catch exec if <cond>
5018 First, check if there's an if clause. */
5019 cond_string = ep_parse_optional_if_clause (&arg);
5021 if ((*arg != '\0') && !isspace (*arg))
5022 error ("Junk at end of arguments.");
5024 /* If this target supports it, create an exec catchpoint
5025 and enable reporting of such events. */
5026 create_exec_event_catchpoint (tempflag, cond_string);
5029 #if defined(SOLIB_ADD)
5031 catch_load_command_1 (arg, tempflag, from_tty)
5036 char *dll_pathname = NULL;
5037 char *cond_string = NULL;
5039 ep_skip_leading_whitespace (&arg);
5041 /* The allowed syntax is:
5043 catch load if <cond>
5044 catch load <filename>
5045 catch load <filename> if <cond>
5047 The user is not allowed to specify the <filename> after an
5050 We'll ignore the pathological case of a file named "if".
5052 First, check if there's an if clause. If so, then there
5053 cannot be a filename. */
5054 cond_string = ep_parse_optional_if_clause (&arg);
5056 /* If there was an if clause, then there cannot be a filename.
5057 Else, there might be a filename and an if clause. */
5058 if (cond_string == NULL)
5060 dll_pathname = ep_parse_optional_filename (&arg);
5061 ep_skip_leading_whitespace (&arg);
5062 cond_string = ep_parse_optional_if_clause (&arg);
5065 if ((*arg != '\0') && !isspace (*arg))
5066 error ("Junk at end of arguments.");
5068 /* Create a load breakpoint that only triggers when a load of
5069 the specified dll (or any dll, if no pathname was specified)
5071 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
5075 catch_unload_command_1 (arg, tempflag, from_tty)
5080 char *dll_pathname = NULL;
5081 char *cond_string = NULL;
5083 ep_skip_leading_whitespace (&arg);
5085 /* The allowed syntax is:
5087 catch unload if <cond>
5088 catch unload <filename>
5089 catch unload <filename> if <cond>
5091 The user is not allowed to specify the <filename> after an
5094 We'll ignore the pathological case of a file named "if".
5096 First, check if there's an if clause. If so, then there
5097 cannot be a filename. */
5098 cond_string = ep_parse_optional_if_clause (&arg);
5100 /* If there was an if clause, then there cannot be a filename.
5101 Else, there might be a filename and an if clause. */
5102 if (cond_string == NULL)
5104 dll_pathname = ep_parse_optional_filename (&arg);
5105 ep_skip_leading_whitespace (&arg);
5106 cond_string = ep_parse_optional_if_clause (&arg);
5109 if ((*arg != '\0') && !isspace (*arg))
5110 error ("Junk at end of arguments.");
5112 /* Create an unload breakpoint that only triggers when an unload of
5113 the specified dll (or any dll, if no pathname was specified)
5115 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
5117 #endif /* SOLIB_ADD */
5119 /* Commands to deal with catching exceptions. */
5121 /* Set a breakpoint at the specified callback routine for an
5122 exception event callback */
5125 create_exception_catchpoint (tempflag, cond_string, ex_event, sal)
5128 enum exception_event_kind ex_event;
5129 struct symtab_and_line *sal;
5131 struct breakpoint *b;
5133 int thread = -1; /* All threads. */
5135 if (!sal) /* no exception support? */
5138 b = set_raw_breakpoint (*sal);
5139 set_breakpoint_count (breakpoint_count + 1);
5140 b->number = breakpoint_count;
5142 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
5144 b->addr_string = NULL;
5145 b->enable = enabled;
5146 b->disposition = tempflag ? del : donttouch;
5149 case EX_EVENT_THROW:
5150 b->type = bp_catch_throw;
5152 case EX_EVENT_CATCH:
5153 b->type = bp_catch_catch;
5155 default: /* error condition */
5157 b->enable = disabled;
5158 error ("Internal error -- invalid catchpoint kind");
5163 /* Deal with "catch catch" and "catch throw" commands */
5166 catch_exception_command_1 (ex_event, arg, tempflag, from_tty)
5167 enum exception_event_kind ex_event;
5172 char *cond_string = NULL;
5173 struct symtab_and_line *sal = NULL;
5175 ep_skip_leading_whitespace (&arg);
5177 cond_string = ep_parse_optional_if_clause (&arg);
5179 if ((*arg != '\0') && !isspace (*arg))
5180 error ("Junk at end of arguments.");
5182 if ((ex_event != EX_EVENT_THROW) &&
5183 (ex_event != EX_EVENT_CATCH))
5184 error ("Unsupported or unknown exception event; cannot catch it");
5186 /* See if we can find a callback routine */
5187 sal = target_enable_exception_callback (ex_event, 1);
5191 /* We have callbacks from the runtime system for exceptions.
5192 Set a breakpoint on the sal found, if no errors */
5193 if (sal != (struct symtab_and_line *) -1)
5194 create_exception_catchpoint (tempflag, cond_string, ex_event, sal);
5196 return; /* something went wrong with setting up callbacks */
5200 /* No callbacks from runtime system for exceptions.
5201 Try GNU C++ exception breakpoints using labels in debug info. */
5202 if (ex_event == EX_EVENT_CATCH)
5204 handle_gnu_4_16_catch_command (arg, tempflag, from_tty);
5206 else if (ex_event == EX_EVENT_THROW)
5208 /* Set a breakpoint on __raise_exception () */
5210 fprintf_filtered (gdb_stderr, "Unsupported with this platform/compiler combination.\n");
5211 fprintf_filtered (gdb_stderr, "Perhaps you can achieve the effect you want by setting\n");
5212 fprintf_filtered (gdb_stderr, "a breakpoint on __raise_exception().\n");
5217 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5218 inside a catch_errors */
5221 cover_target_enable_exception_callback (arg)
5224 args_for_catchpoint_enable *args = arg;
5225 struct symtab_and_line *sal;
5226 sal = target_enable_exception_callback (args->kind, args->enable);
5229 else if (sal == (struct symtab_and_line *) -1)
5232 return 1; /*is valid */
5237 /* This is the original v.4.16 and earlier version of the
5238 catch_command_1() function. Now that other flavours of "catch"
5239 have been introduced, and since exception handling can be handled
5240 in other ways (through target ops) also, this is used only for the
5241 GNU C++ exception handling system.
5242 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5243 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5244 there was no code in GDB 4.16 for "catch throw".
5246 Called from catch_exception_command_1 () */
5250 handle_gnu_4_16_catch_command (arg, tempflag, from_tty)
5255 /* First, translate ARG into something we can deal with in terms
5258 struct symtabs_and_lines sals;
5259 struct symtab_and_line sal;
5260 register struct expression *cond = 0;
5261 register struct breakpoint *b;
5265 INIT_SAL (&sal); /* initialize to zeroes */
5267 /* If no arg given, or if first arg is 'if ', all active catch clauses
5268 are breakpointed. */
5270 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
5271 && (arg[2] == ' ' || arg[2] == '\t')))
5273 /* Grab all active catch clauses. */
5274 sals = get_catch_sals (0);
5278 /* Grab selected catch clauses. */
5279 error ("catch NAME not implemented");
5282 /* Not sure why this code has been disabled. I'm leaving
5283 it disabled. We can never come here now anyway
5284 since we don't allow the "catch NAME" syntax.
5287 /* This isn't used; I don't know what it was for. */
5288 sals = map_catch_names (arg, catch_breakpoint);
5296 for (i = 0; i < sals.nelts; i++)
5298 resolve_sal_pc (&sals.sals[i]);
5302 if (arg[0] == 'i' && arg[1] == 'f'
5303 && (arg[2] == ' ' || arg[2] == '\t'))
5304 cond = parse_exp_1 ((arg += 2, &arg),
5305 block_for_pc (sals.sals[i].pc), 0);
5307 error ("Junk at end of arguments.");
5312 for (i = 0; i < sals.nelts; i++)
5317 describe_other_breakpoints (sal.pc, sal.section);
5319 b = set_raw_breakpoint (sal);
5320 set_breakpoint_count (breakpoint_count + 1);
5321 b->number = breakpoint_count;
5322 b->type = bp_breakpoint; /* Important -- this is an ordinary breakpoint.
5323 For platforms with callback support for exceptions,
5324 create_exception_catchpoint() will create special
5325 bp types (bp_catch_catch and bp_catch_throw), and
5326 there is code in insert_breakpoints() and elsewhere
5327 that depends on that. */
5330 b->enable = enabled;
5331 b->disposition = tempflag ? del : donttouch;
5338 printf_unfiltered ("Multiple breakpoints were set.\n");
5339 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
5341 free ((PTR) sals.sals);
5345 /* This creates a temporary internal breakpoint
5346 just to placate infrun */
5347 static struct breakpoint *
5348 create_temp_exception_breakpoint (pc)
5351 struct symtab_and_line sal;
5352 struct breakpoint *b;
5359 b = set_raw_breakpoint (sal);
5361 error ("Internal error -- couldn't set temp exception breakpoint");
5363 b->type = bp_breakpoint;
5364 b->disposition = del;
5365 b->enable = enabled;
5367 b->number = internal_breakpoint_number--;
5373 catch_command_1 (arg, tempflag, from_tty)
5379 /* The first argument may be an event name, such as "start" or "load".
5380 If so, then handle it as such. If it doesn't match an event name,
5381 then attempt to interpret it as an exception name. (This latter is
5382 the v4.16-and-earlier GDB meaning of the "catch" command.)
5384 First, try to find the bounds of what might be an event name. */
5385 char *arg1_start = arg;
5389 if (arg1_start == NULL)
5391 /* Old behaviour was to use pre-v-4.16 syntax */
5392 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5394 /* Now, this is not allowed */
5395 error ("Catch requires an event name.");
5398 arg1_end = ep_find_event_name_end (arg1_start);
5399 if (arg1_end == NULL)
5400 error ("catch requires an event");
5401 arg1_length = arg1_end + 1 - arg1_start;
5403 /* Try to match what we found against known event names. */
5404 if (strncmp (arg1_start, "signal", arg1_length) == 0)
5406 error ("Catch of signal not yet implemented");
5408 else if (strncmp (arg1_start, "catch", arg1_length) == 0)
5410 catch_exception_command_1 (EX_EVENT_CATCH, arg1_end + 1, tempflag, from_tty);
5412 else if (strncmp (arg1_start, "throw", arg1_length) == 0)
5414 catch_exception_command_1 (EX_EVENT_THROW, arg1_end + 1, tempflag, from_tty);
5416 else if (strncmp (arg1_start, "thread_start", arg1_length) == 0)
5418 error ("Catch of thread_start not yet implemented");
5420 else if (strncmp (arg1_start, "thread_exit", arg1_length) == 0)
5422 error ("Catch of thread_exit not yet implemented");
5424 else if (strncmp (arg1_start, "thread_join", arg1_length) == 0)
5426 error ("Catch of thread_join not yet implemented");
5428 else if (strncmp (arg1_start, "start", arg1_length) == 0)
5430 error ("Catch of start not yet implemented");
5432 else if (strncmp (arg1_start, "exit", arg1_length) == 0)
5434 error ("Catch of exit not yet implemented");
5436 else if (strncmp (arg1_start, "fork", arg1_length) == 0)
5438 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5439 catch_fork_command_1 (catch_fork, arg1_end + 1, tempflag, from_tty);
5441 error ("Catch of fork not yet implemented");
5444 else if (strncmp (arg1_start, "vfork", arg1_length) == 0)
5446 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5447 catch_fork_command_1 (catch_vfork, arg1_end + 1, tempflag, from_tty);
5449 error ("Catch of vfork not yet implemented");
5452 else if (strncmp (arg1_start, "exec", arg1_length) == 0)
5454 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5455 catch_exec_command_1 (arg1_end + 1, tempflag, from_tty);
5457 error ("Catch of exec not yet implemented");
5460 else if (strncmp (arg1_start, "load", arg1_length) == 0)
5462 #if defined(SOLIB_ADD)
5463 catch_load_command_1 (arg1_end + 1, tempflag, from_tty);
5465 error ("Catch of load not implemented");
5468 else if (strncmp (arg1_start, "unload", arg1_length) == 0)
5470 #if defined(SOLIB_ADD)
5471 catch_unload_command_1 (arg1_end + 1, tempflag, from_tty);
5473 error ("Catch of load not implemented");
5476 else if (strncmp (arg1_start, "stop", arg1_length) == 0)
5478 error ("Catch of stop not yet implemented");
5481 /* This doesn't appear to be an event name */
5485 /* Pre-v.4.16 behaviour was to treat the argument
5486 as the name of an exception */
5487 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5488 /* Now this is not allowed */
5489 error ("Unknown event kind specified for catch");
5494 /* Used by the gui, could be made a worker for other things. */
5497 set_breakpoint_sal (sal)
5498 struct symtab_and_line sal;
5500 struct breakpoint *b;
5501 b = set_raw_breakpoint (sal);
5502 set_breakpoint_count (breakpoint_count + 1);
5503 b->number = breakpoint_count;
5504 b->type = bp_breakpoint;
5511 /* These aren't used; I don't know what they were for. */
5512 /* Disable breakpoints on all catch clauses described in ARGS. */
5514 disable_catch (args)
5517 /* Map the disable command to catch clauses described in ARGS. */
5520 /* Enable breakpoints on all catch clauses described in ARGS. */
5525 /* Map the disable command to catch clauses described in ARGS. */
5528 /* Delete breakpoints on all catch clauses in the active scope. */
5533 /* Map the delete command to catch clauses described in ARGS. */
5538 catch_command (arg, from_tty)
5542 catch_command_1 (arg, 0, from_tty);
5547 tcatch_command (arg, from_tty)
5551 catch_command_1 (arg, 1, from_tty);
5556 clear_command (arg, from_tty)
5560 register struct breakpoint *b, *b1;
5562 struct symtabs_and_lines sals;
5563 struct symtab_and_line sal;
5564 register struct breakpoint *found;
5569 sals = decode_line_spec (arg, 1);
5574 sals.sals = (struct symtab_and_line *)
5575 xmalloc (sizeof (struct symtab_and_line));
5576 INIT_SAL (&sal); /* initialize to zeroes */
5577 sal.line = default_breakpoint_line;
5578 sal.symtab = default_breakpoint_symtab;
5579 sal.pc = default_breakpoint_address;
5580 if (sal.symtab == 0)
5581 error ("No source file specified.");
5589 /* For each line spec given, delete bps which correspond
5590 to it. We do this in two loops: the first loop looks at
5591 the initial bp(s) in the chain which should be deleted,
5592 the second goes down the rest of the chain looking ahead
5593 one so it can take those bps off the chain without messing
5597 for (i = 0; i < sals.nelts; i++)
5599 /* If exact pc given, clear bpts at that pc.
5600 If line given (pc == 0), clear all bpts on specified line.
5601 If defaulting, clear all bpts on default line
5604 defaulting sal.pc != 0 tests to do
5609 1 0 <can't happen> */
5612 found = (struct breakpoint *) 0;
5615 while (breakpoint_chain
5616 /* Why don't we check here that this is not
5617 a watchpoint, etc., as we do below?
5618 I can't make it fail, but don't know
5619 what's stopping the failure: a watchpoint
5620 of the same address as "sal.pc" should
5621 wind up being deleted. */
5623 && (((sal.pc && (breakpoint_chain->address == sal.pc)) &&
5624 (overlay_debugging == 0 ||
5625 breakpoint_chain->section == sal.section))
5626 || ((default_match || (0 == sal.pc))
5627 && breakpoint_chain->source_file != NULL
5628 && sal.symtab != NULL
5629 && STREQ (breakpoint_chain->source_file, sal.symtab->filename)
5630 && breakpoint_chain->line_number == sal.line)))
5633 b1 = breakpoint_chain;
5634 breakpoint_chain = b1->next;
5642 && b->next->type != bp_none
5643 && b->next->type != bp_watchpoint
5644 && b->next->type != bp_hardware_watchpoint
5645 && b->next->type != bp_read_watchpoint
5646 && b->next->type != bp_access_watchpoint
5647 && (((sal.pc && (b->next->address == sal.pc)) &&
5648 (overlay_debugging == 0 ||
5649 b->next->section == sal.section))
5650 || ((default_match || (0 == sal.pc))
5651 && b->next->source_file != NULL
5652 && sal.symtab != NULL
5653 && STREQ (b->next->source_file, sal.symtab->filename)
5654 && b->next->line_number == sal.line)))
5667 error ("No breakpoint at %s.", arg);
5669 error ("No breakpoint at this line.");
5673 from_tty = 1; /* Always report if deleted more than one */
5675 printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
5676 breakpoints_changed ();
5680 printf_unfiltered ("%d ", found->number);
5682 delete_breakpoint (found);
5686 putchar_unfiltered ('\n');
5688 free ((PTR) sals.sals);
5691 /* Delete breakpoint in BS if they are `delete' breakpoints and
5692 all breakpoints that are marked for deletion, whether hit or not.
5693 This is called after any breakpoint is hit, or after errors. */
5696 breakpoint_auto_delete (bs)
5699 struct breakpoint *b, *temp;
5701 for (; bs; bs = bs->next)
5702 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
5704 delete_breakpoint (bs->breakpoint_at);
5706 ALL_BREAKPOINTS_SAFE (b, temp)
5708 if (b->disposition == del_at_next_stop)
5709 delete_breakpoint (b);
5713 /* Delete a breakpoint and clean up all traces of it in the data structures. */
5716 delete_breakpoint (bpt)
5717 struct breakpoint *bpt;
5719 register struct breakpoint *b;
5723 error ("Internal error (attempted to delete a NULL breakpoint)");
5726 /* Has this bp already been deleted? This can happen because multiple
5727 lists can hold pointers to bp's. bpstat lists are especial culprits.
5729 One example of this happening is a watchpoint's scope bp. When the
5730 scope bp triggers, we notice that the watchpoint is out of scope, and
5731 delete it. We also delete its scope bp. But the scope bp is marked
5732 "auto-deleting", and is already on a bpstat. That bpstat is then
5733 checked for auto-deleting bp's, which are deleted.
5735 A real solution to this problem might involve reference counts in bp's,
5736 and/or giving them pointers back to their referencing bpstat's, and
5737 teaching delete_breakpoint to only free a bp's storage when no more
5738 references were extent. A cheaper bandaid was chosen. */
5739 if (bpt->type == bp_none)
5742 if (delete_breakpoint_hook)
5743 delete_breakpoint_hook (bpt);
5746 remove_breakpoint (bpt, mark_uninserted);
5748 if (breakpoint_chain == bpt)
5749 breakpoint_chain = bpt->next;
5751 /* If we have callback-style exception catchpoints, don't go through
5752 the adjustments to the C++ runtime library etc. if the inferior
5753 isn't actually running. target_enable_exception_callback for a
5754 null target ops vector gives an undesirable error message, so we
5755 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5756 exceptions are supported in this way, it's OK for now. FIXME */
5757 if (ep_is_exception_catchpoint (bpt) && target_has_execution)
5759 static char message1[] = "Error in deleting catchpoint %d:\n";
5760 static char message[sizeof (message1) + 30];
5761 args_for_catchpoint_enable args;
5763 sprintf (message, message1, bpt->number); /* Format possible error msg */
5764 args.kind = bpt->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
5766 catch_errors (cover_target_enable_exception_callback, &args,
5767 message, RETURN_MASK_ALL);
5774 b->next = bpt->next;
5778 /* Before turning off the visuals for the bp, check to see that
5779 there are no other bps at the same address. */
5786 clearIt = (b->address != bpt->address);
5793 TUIDO (((TuiOpaqueFuncPtr) tui_vAllSetHasBreakAt, bpt, 0));
5794 TUIDO (((TuiOpaqueFuncPtr) tuiUpdateAllExecInfos));
5798 check_duplicates (bpt->address, bpt->section);
5799 /* If this breakpoint was inserted, and there is another breakpoint
5800 at the same address, we need to insert the other breakpoint. */
5802 && bpt->type != bp_hardware_watchpoint
5803 && bpt->type != bp_read_watchpoint
5804 && bpt->type != bp_access_watchpoint
5805 && bpt->type != bp_catch_fork
5806 && bpt->type != bp_catch_vfork
5807 && bpt->type != bp_catch_exec)
5810 if (b->address == bpt->address
5811 && b->section == bpt->section
5813 && b->enable != disabled
5814 && b->enable != shlib_disabled
5815 && b->enable != call_disabled)
5818 val = target_insert_breakpoint (b->address, b->shadow_contents);
5821 target_terminal_ours_for_output ();
5822 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
5823 memory_error (val, b->address); /* which bombs us out */
5830 free_command_lines (&bpt->commands);
5833 if (bpt->cond_string != NULL)
5834 free (bpt->cond_string);
5835 if (bpt->addr_string != NULL)
5836 free (bpt->addr_string);
5837 if (bpt->exp != NULL)
5839 if (bpt->exp_string != NULL)
5840 free (bpt->exp_string);
5841 if (bpt->val != NULL)
5842 value_free (bpt->val);
5843 if (bpt->source_file != NULL)
5844 free (bpt->source_file);
5845 if (bpt->dll_pathname != NULL)
5846 free (bpt->dll_pathname);
5847 if (bpt->triggered_dll_pathname != NULL)
5848 free (bpt->triggered_dll_pathname);
5849 if (bpt->exec_pathname != NULL)
5850 free (bpt->exec_pathname);
5852 /* Be sure no bpstat's are pointing at it after it's been freed. */
5853 /* FIXME, how can we find all bpstat's?
5854 We just check stop_bpstat for now. */
5855 for (bs = stop_bpstat; bs; bs = bs->next)
5856 if (bs->breakpoint_at == bpt)
5858 bs->breakpoint_at = NULL;
5860 /* we'd call bpstat_clear_actions, but that free's stuff and due
5861 to the multiple pointers pointing to one item with no
5862 reference counts found anywhere through out the bpstat's (how
5863 do you spell fragile?), we don't want to free things twice --
5864 better a memory leak than a corrupt malloc pool! */
5865 bs->commands = NULL;
5868 /* On the chance that someone will soon try again to delete this same
5869 bp, we mark it as deleted before freeing its storage. */
5870 bpt->type = bp_none;
5876 delete_command (arg, from_tty)
5880 struct breakpoint *b, *temp;
5884 int breaks_to_delete = 0;
5886 /* Delete all breakpoints if no argument.
5887 Do not delete internal or call-dummy breakpoints, these
5888 have to be deleted with an explicit breakpoint number argument. */
5891 if (b->type != bp_call_dummy &&
5892 b->type != bp_shlib_event &&
5894 breaks_to_delete = 1;
5897 /* Ask user only if there are some breakpoints to delete. */
5899 || (breaks_to_delete && query ("Delete all breakpoints? ")))
5901 ALL_BREAKPOINTS_SAFE (b, temp)
5903 if (b->type != bp_call_dummy &&
5904 b->type != bp_shlib_event &&
5906 delete_breakpoint (b);
5911 map_breakpoint_numbers (arg, delete_breakpoint);
5914 /* Reset a breakpoint given it's struct breakpoint * BINT.
5915 The value we return ends up being the return value from catch_errors.
5916 Unused in this case. */
5919 breakpoint_re_set_one (bint)
5922 struct breakpoint *b = (struct breakpoint *) bint; /* get past catch_errs */
5925 struct symtabs_and_lines sals;
5927 enum enable save_enable;
5932 warning ("attempted to reset apparently deleted breakpoint #%d?\n", b->number);
5935 case bp_hardware_breakpoint:
5937 case bp_catch_unload:
5938 if (b->addr_string == NULL)
5940 /* Anything without a string can't be re-set. */
5941 delete_breakpoint (b);
5944 /* In case we have a problem, disable this breakpoint. We'll restore
5945 its status if we succeed. */
5946 save_enable = b->enable;
5947 b->enable = disabled;
5949 set_language (b->language);
5950 input_radix = b->input_radix;
5952 sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL);
5953 for (i = 0; i < sals.nelts; i++)
5955 resolve_sal_pc (&sals.sals[i]);
5957 /* Reparse conditions, they might contain references to the
5959 if (b->cond_string != NULL)
5963 free ((PTR) b->cond);
5964 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
5967 /* We need to re-set the breakpoint if the address changes... */
5968 if (b->address != sals.sals[i].pc
5969 /* ...or new and old breakpoints both have source files, and
5970 the source file name or the line number changes... */
5971 || (b->source_file != NULL
5972 && sals.sals[i].symtab != NULL
5973 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
5974 || b->line_number != sals.sals[i].line)
5976 /* ...or we switch between having a source file and not having
5978 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
5981 if (b->source_file != NULL)
5982 free (b->source_file);
5983 if (sals.sals[i].symtab == NULL)
5984 b->source_file = NULL;
5987 savestring (sals.sals[i].symtab->filename,
5988 strlen (sals.sals[i].symtab->filename));
5989 b->line_number = sals.sals[i].line;
5990 b->address = sals.sals[i].pc;
5992 /* Used to check for duplicates here, but that can
5993 cause trouble, as it doesn't check for disable
5998 /* Might be better to do this just once per breakpoint_re_set,
5999 rather than once for every breakpoint. */
6000 breakpoints_changed ();
6002 b->section = sals.sals[i].section;
6003 b->enable = save_enable; /* Restore it, this worked. */
6006 /* Now that this is re-enabled, check_duplicates
6008 check_duplicates (b->address, b->section);
6011 free ((PTR) sals.sals);
6015 case bp_hardware_watchpoint:
6016 case bp_read_watchpoint:
6017 case bp_access_watchpoint:
6018 innermost_block = NULL;
6019 /* The issue arises of what context to evaluate this in. The same
6020 one as when it was set, but what does that mean when symbols have
6021 been re-read? We could save the filename and functionname, but
6022 if the context is more local than that, the best we could do would
6023 be something like how many levels deep and which index at that
6024 particular level, but that's going to be less stable than filenames
6025 or functionnames. */
6026 /* So for now, just use a global context. */
6028 free ((PTR) b->exp);
6029 b->exp = parse_expression (b->exp_string);
6030 b->exp_valid_block = innermost_block;
6031 mark = value_mark ();
6033 value_free (b->val);
6034 b->val = evaluate_expression (b->exp);
6035 release_value (b->val);
6036 if (VALUE_LAZY (b->val))
6037 value_fetch_lazy (b->val);
6039 if (b->cond_string != NULL)
6043 free ((PTR) b->cond);
6044 b->cond = parse_exp_1 (&s, (struct block *) 0, 0);
6046 if (b->enable == enabled)
6048 value_free_to_mark (mark);
6050 case bp_catch_catch:
6051 case bp_catch_throw:
6053 /* We needn't really do anything to reset these, since the mask
6054 that requests them is unaffected by e.g., new libraries being
6057 case bp_catch_vfork:
6062 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
6064 /* Delete longjmp breakpoints, they will be reset later by
6065 breakpoint_re_set. */
6067 case bp_longjmp_resume:
6068 delete_breakpoint (b);
6071 /* This breakpoint is special, it's set up when the inferior
6072 starts and we really don't want to touch it. */
6073 case bp_shlib_event:
6075 /* Keep temporary breakpoints, which can be encountered when we step
6076 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
6077 Otherwise these should have been blown away via the cleanup chain
6078 or by breakpoint_init_inferior when we rerun the executable. */
6081 case bp_watchpoint_scope:
6083 case bp_step_resume:
6090 /* Re-set all breakpoints after symbols have been re-loaded. */
6092 breakpoint_re_set ()
6094 struct breakpoint *b, *temp;
6095 enum language save_language;
6096 int save_input_radix;
6097 static char message1[] = "Error in re-setting breakpoint %d:\n";
6098 char message[sizeof (message1) + 30 /* slop */ ];
6100 save_language = current_language->la_language;
6101 save_input_radix = input_radix;
6102 ALL_BREAKPOINTS_SAFE (b, temp)
6104 sprintf (message, message1, b->number); /* Format possible error msg */
6105 catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
6107 set_language (save_language);
6108 input_radix = save_input_radix;
6110 #ifdef GET_LONGJMP_TARGET
6111 create_longjmp_breakpoint ("longjmp");
6112 create_longjmp_breakpoint ("_longjmp");
6113 create_longjmp_breakpoint ("siglongjmp");
6114 create_longjmp_breakpoint ("_siglongjmp");
6115 create_longjmp_breakpoint (NULL);
6119 /* Took this out (temporarily at least), since it produces an extra
6120 blank line at startup. This messes up the gdbtests. -PB */
6121 /* Blank line to finish off all those mention() messages we just printed. */
6122 printf_filtered ("\n");
6126 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
6127 If from_tty is nonzero, it prints a message to that effect,
6128 which ends with a period (no newline). */
6130 /* Reset the thread number of this breakpoint:
6132 - If the breakpoint is for all threads, leave it as-is.
6133 - Else, reset it to the current thread for inferior_pid. */
6135 breakpoint_re_set_thread (b)
6136 struct breakpoint *b;
6138 if (b->thread != -1)
6140 if (in_thread_list (inferior_pid))
6141 b->thread = pid_to_thread_id (inferior_pid);
6146 set_ignore_count (bptnum, count, from_tty)
6147 int bptnum, count, from_tty;
6149 register struct breakpoint *b;
6155 if (b->number == bptnum)
6157 b->ignore_count = count;
6160 else if (count == 0)
6161 printf_filtered ("Will stop next time breakpoint %d is reached.",
6163 else if (count == 1)
6164 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6167 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6169 breakpoints_changed ();
6173 error ("No breakpoint number %d.", bptnum);
6176 /* Clear the ignore counts of all breakpoints. */
6178 breakpoint_clear_ignore_counts ()
6180 struct breakpoint *b;
6183 b->ignore_count = 0;
6186 /* Command to set ignore-count of breakpoint N to COUNT. */
6189 ignore_command (args, from_tty)
6197 error_no_arg ("a breakpoint number");
6199 num = get_number (&p);
6202 error ("Second argument (specified ignore-count) is missing.");
6204 set_ignore_count (num,
6205 longest_to_int (value_as_long (parse_and_eval (p))),
6207 printf_filtered ("\n");
6208 breakpoints_changed ();
6211 /* Call FUNCTION on each of the breakpoints
6212 whose numbers are given in ARGS. */
6215 map_breakpoint_numbers (args, function)
6217 void (*function) PARAMS ((struct breakpoint *));
6219 register char *p = args;
6222 register struct breakpoint *b;
6225 error_no_arg ("one or more breakpoint numbers");
6231 num = get_number (&p1);
6234 if (b->number == num)
6236 struct breakpoint *related_breakpoint = b->related_breakpoint;
6238 if (related_breakpoint)
6239 function (related_breakpoint);
6242 printf_unfiltered ("No breakpoint number %d.\n", num);
6249 disable_breakpoint (bpt)
6250 struct breakpoint *bpt;
6252 /* Never disable a watchpoint scope breakpoint; we want to
6253 hit them when we leave scope so we can delete both the
6254 watchpoint and its scope breakpoint at that time. */
6255 if (bpt->type == bp_watchpoint_scope)
6258 bpt->enable = disabled;
6260 check_duplicates (bpt->address, bpt->section);
6262 if (modify_breakpoint_hook)
6263 modify_breakpoint_hook (bpt);
6268 disable_command (args, from_tty)
6272 register struct breakpoint *bpt;
6274 ALL_BREAKPOINTS (bpt)
6278 warning ("attempted to disable apparently deleted breakpoint #%d?\n", bpt->number);
6282 case bp_catch_unload:
6284 case bp_catch_vfork:
6286 case bp_catch_catch:
6287 case bp_catch_throw:
6288 case bp_hardware_breakpoint:
6290 case bp_hardware_watchpoint:
6291 case bp_read_watchpoint:
6292 case bp_access_watchpoint:
6293 disable_breakpoint (bpt);
6298 map_breakpoint_numbers (args, disable_breakpoint);
6302 do_enable_breakpoint (bpt, disposition)
6303 struct breakpoint *bpt;
6304 enum bpdisp disposition;
6306 struct frame_info *save_selected_frame = NULL;
6307 int save_selected_frame_level = -1;
6308 int target_resources_ok, other_type_used;
6311 if (bpt->type == bp_hardware_breakpoint)
6314 i = hw_breakpoint_used_count ();
6315 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6316 bp_hardware_breakpoint, i + 1, 0);
6317 if (target_resources_ok == 0)
6318 error ("No hardware breakpoint support in the target.");
6319 else if (target_resources_ok < 0)
6320 error ("Hardware breakpoints used exceeds limit.");
6323 bpt->enable = enabled;
6324 bpt->disposition = disposition;
6325 check_duplicates (bpt->address, bpt->section);
6326 breakpoints_changed ();
6328 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
6329 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
6331 if (bpt->exp_valid_block != NULL)
6333 struct frame_info *fr =
6335 /* Ensure that we have the current frame. Else, this
6336 next query may pessimistically be answered as, "No,
6337 not within current scope". */
6338 get_current_frame ();
6339 fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
6343 Cannot enable watchpoint %d because the block in which its expression\n\
6344 is valid is not currently in scope.\n", bpt->number);
6345 bpt->enable = disabled;
6349 save_selected_frame = selected_frame;
6350 save_selected_frame_level = selected_frame_level;
6351 select_frame (fr, -1);
6354 value_free (bpt->val);
6355 mark = value_mark ();
6356 bpt->val = evaluate_expression (bpt->exp);
6357 release_value (bpt->val);
6358 if (VALUE_LAZY (bpt->val))
6359 value_fetch_lazy (bpt->val);
6361 if (bpt->type == bp_hardware_watchpoint ||
6362 bpt->type == bp_read_watchpoint ||
6363 bpt->type == bp_access_watchpoint)
6365 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
6366 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
6368 /* Hack around 'unused var' error for some targets here */
6370 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
6371 bpt->type, i + mem_cnt, other_type_used);
6372 /* we can consider of type is bp_hardware_watchpoint, convert to
6373 bp_watchpoint in the following condition */
6374 if (target_resources_ok < 0)
6377 Cannot enable watchpoint %d because target watch resources\n\
6378 have been allocated for other watchpoints.\n", bpt->number);
6379 bpt->enable = disabled;
6380 value_free_to_mark (mark);
6385 if (save_selected_frame_level >= 0)
6386 select_and_print_frame (save_selected_frame, save_selected_frame_level);
6387 value_free_to_mark (mark);
6389 if (modify_breakpoint_hook)
6390 modify_breakpoint_hook (bpt);
6394 enable_breakpoint (bpt)
6395 struct breakpoint *bpt;
6397 do_enable_breakpoint (bpt, bpt->disposition);
6400 /* The enable command enables the specified breakpoints (or all defined
6401 breakpoints) so they once again become (or continue to be) effective
6402 in stopping the inferior. */
6406 enable_command (args, from_tty)
6410 register struct breakpoint *bpt;
6412 ALL_BREAKPOINTS (bpt)
6416 warning ("attempted to enable apparently deleted breakpoint #%d?\n", bpt->number);
6420 case bp_catch_unload:
6422 case bp_catch_vfork:
6424 case bp_catch_catch:
6425 case bp_catch_throw:
6426 case bp_hardware_breakpoint:
6428 case bp_hardware_watchpoint:
6429 case bp_read_watchpoint:
6430 case bp_access_watchpoint:
6431 enable_breakpoint (bpt);
6436 map_breakpoint_numbers (args, enable_breakpoint);
6440 enable_once_breakpoint (bpt)
6441 struct breakpoint *bpt;
6443 do_enable_breakpoint (bpt, disable);
6448 enable_once_command (args, from_tty)
6452 map_breakpoint_numbers (args, enable_once_breakpoint);
6456 enable_delete_breakpoint (bpt)
6457 struct breakpoint *bpt;
6459 do_enable_breakpoint (bpt, del);
6464 enable_delete_command (args, from_tty)
6468 map_breakpoint_numbers (args, enable_delete_breakpoint);
6471 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6473 struct symtabs_and_lines
6474 decode_line_spec_1 (string, funfirstline)
6478 struct symtabs_and_lines sals;
6480 error ("Empty line specification.");
6481 if (default_breakpoint_valid)
6482 sals = decode_line_1 (&string, funfirstline,
6483 default_breakpoint_symtab, default_breakpoint_line,
6486 sals = decode_line_1 (&string, funfirstline,
6487 (struct symtab *) NULL, 0, (char ***) NULL);
6489 error ("Junk at end of line specification: %s", string);
6494 _initialize_breakpoint ()
6496 struct cmd_list_element *c;
6498 breakpoint_chain = 0;
6499 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6500 before a breakpoint is set. */
6501 breakpoint_count = 0;
6503 add_com ("ignore", class_breakpoint, ignore_command,
6504 "Set ignore-count of breakpoint number N to COUNT.\n\
6505 Usage is `ignore N COUNT'.");
6507 add_com_alias ("bc", "ignore", class_breakpoint, 1);
6509 add_com ("commands", class_breakpoint, commands_command,
6510 "Set commands to be executed when a breakpoint is hit.\n\
6511 Give breakpoint number as argument after \"commands\".\n\
6512 With no argument, the targeted breakpoint is the last one set.\n\
6513 The commands themselves follow starting on the next line.\n\
6514 Type a line containing \"end\" to indicate the end of them.\n\
6515 Give \"silent\" as the first line to make the breakpoint silent;\n\
6516 then no output is printed when it is hit, except what the commands print.");
6518 add_com ("condition", class_breakpoint, condition_command,
6519 "Specify breakpoint number N to break only if COND is true.\n\
6520 Usage is `condition N COND', where N is an integer and COND is an\n\
6521 expression to be evaluated whenever breakpoint N is reached. ");
6523 add_com ("tbreak", class_breakpoint, tbreak_command,
6524 "Set a temporary breakpoint. Args like \"break\" command.\n\
6525 Like \"break\" except the breakpoint is only temporary,\n\
6526 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6527 by using \"enable delete\" on the breakpoint number.");
6528 add_com ("txbreak", class_breakpoint, tbreak_at_finish_command,
6529 "Set temporary breakpoint at procedure exit. Either there should\n\
6530 be no argument or the argument must be a depth.\n");
6532 add_com ("hbreak", class_breakpoint, hbreak_command,
6533 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6534 Like \"break\" except the breakpoint requires hardware support,\n\
6535 some target hardware may not have this support.");
6537 add_com ("thbreak", class_breakpoint, thbreak_command,
6538 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6539 Like \"hbreak\" except the breakpoint is only temporary,\n\
6540 so it will be deleted when hit.");
6542 add_prefix_cmd ("enable", class_breakpoint, enable_command,
6543 "Enable some breakpoints.\n\
6544 Give breakpoint numbers (separated by spaces) as arguments.\n\
6545 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6546 This is used to cancel the effect of the \"disable\" command.\n\
6547 With a subcommand you can enable temporarily.",
6548 &enablelist, "enable ", 1, &cmdlist);
6550 add_com ("ab", class_breakpoint, enable_command,
6551 "Enable some breakpoints.\n\
6552 Give breakpoint numbers (separated by spaces) as arguments.\n\
6553 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6554 This is used to cancel the effect of the \"disable\" command.\n\
6555 With a subcommand you can enable temporarily.");
6557 add_com_alias ("en", "enable", class_breakpoint, 1);
6559 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
6560 "Enable some breakpoints.\n\
6561 Give breakpoint numbers (separated by spaces) as arguments.\n\
6562 This is used to cancel the effect of the \"disable\" command.\n\
6563 May be abbreviated to simply \"enable\".\n",
6564 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
6566 add_cmd ("once", no_class, enable_once_command,
6567 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6568 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6571 add_cmd ("delete", no_class, enable_delete_command,
6572 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6573 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6576 add_cmd ("delete", no_class, enable_delete_command,
6577 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6578 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6581 add_cmd ("once", no_class, enable_once_command,
6582 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6583 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6586 add_prefix_cmd ("disable", class_breakpoint, disable_command,
6587 "Disable some breakpoints.\n\
6588 Arguments are breakpoint numbers with spaces in between.\n\
6589 To disable all breakpoints, give no argument.\n\
6590 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6591 &disablelist, "disable ", 1, &cmdlist);
6592 add_com_alias ("dis", "disable", class_breakpoint, 1);
6593 add_com_alias ("disa", "disable", class_breakpoint, 1);
6595 add_com ("sb", class_breakpoint, disable_command,
6596 "Disable some breakpoints.\n\
6597 Arguments are breakpoint numbers with spaces in between.\n\
6598 To disable all breakpoints, give no argument.\n\
6599 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6601 add_cmd ("breakpoints", class_alias, disable_command,
6602 "Disable some breakpoints.\n\
6603 Arguments are breakpoint numbers with spaces in between.\n\
6604 To disable all breakpoints, give no argument.\n\
6605 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6606 This command may be abbreviated \"disable\".",
6609 add_prefix_cmd ("delete", class_breakpoint, delete_command,
6610 "Delete some breakpoints or auto-display expressions.\n\
6611 Arguments are breakpoint numbers with spaces in between.\n\
6612 To delete all breakpoints, give no argument.\n\
6614 Also a prefix command for deletion of other GDB objects.\n\
6615 The \"unset\" command is also an alias for \"delete\".",
6616 &deletelist, "delete ", 1, &cmdlist);
6617 add_com_alias ("d", "delete", class_breakpoint, 1);
6619 add_com ("db", class_breakpoint, delete_command,
6620 "Delete some breakpoints.\n\
6621 Arguments are breakpoint numbers with spaces in between.\n\
6622 To delete all breakpoints, give no argument.\n");
6624 add_cmd ("breakpoints", class_alias, delete_command,
6625 "Delete some breakpoints or auto-display expressions.\n\
6626 Arguments are breakpoint numbers with spaces in between.\n\
6627 To delete all breakpoints, give no argument.\n\
6628 This command may be abbreviated \"delete\".",
6631 add_com ("clear", class_breakpoint, clear_command,
6632 concat ("Clear breakpoint at specified line or function.\n\
6633 Argument may be line number, function name, or \"*\" and an address.\n\
6634 If line number is specified, all breakpoints in that line are cleared.\n\
6635 If function is specified, breakpoints at beginning of function are cleared.\n\
6636 If an address is specified, breakpoints at that address are cleared.\n\n",
6637 "With no argument, clears all breakpoints in the line that the selected frame\n\
6640 See also the \"delete\" command which clears breakpoints by number.", NULL));
6642 add_com ("break", class_breakpoint, break_command,
6643 concat ("Set breakpoint at specified line or function.\n\
6644 Argument may be line number, function name, or \"*\" and an address.\n\
6645 If line number is specified, break at start of code for that line.\n\
6646 If function is specified, break at start of code for that function.\n\
6647 If an address is specified, break at that exact address.\n",
6648 "With no arg, uses current execution address of selected stack frame.\n\
6649 This is useful for breaking on return to a stack frame.\n\
6651 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6653 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6654 add_com_alias ("b", "break", class_run, 1);
6655 add_com_alias ("br", "break", class_run, 1);
6656 add_com_alias ("bre", "break", class_run, 1);
6657 add_com_alias ("brea", "break", class_run, 1);
6659 add_com ("xbreak", class_breakpoint, break_at_finish_command,
6660 concat ("Set breakpoint at procedure exit. \n\
6661 Argument may be function name, or \"*\" and an address.\n\
6662 If function is specified, break at end of code for that function.\n\
6663 If an address is specified, break at the end of the function that contains \n\
6664 that exact address.\n",
6665 "With no arg, uses current execution address of selected stack frame.\n\
6666 This is useful for breaking on return to a stack frame.\n\
6668 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6670 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6671 add_com_alias ("xb", "xbreak", class_breakpoint, 1);
6672 add_com_alias ("xbr", "xbreak", class_breakpoint, 1);
6673 add_com_alias ("xbre", "xbreak", class_breakpoint, 1);
6674 add_com_alias ("xbrea", "xbreak", class_breakpoint, 1);
6678 add_com_alias ("ba", "break", class_breakpoint, 1);
6679 add_com_alias ("bu", "ubreak", class_breakpoint, 1);
6680 add_com ("bx", class_breakpoint, break_at_finish_at_depth_command,
6681 "Set breakpoint at procedure exit. Either there should\n\
6682 be no argument or the argument must be a depth.\n");
6687 add_abbrev_prefix_cmd ("stop", class_breakpoint, stop_command,
6688 "Break in function/address or break at a line in the current file.",
6689 &stoplist, "stop ", 1, &cmdlist);
6690 add_cmd ("in", class_breakpoint, stopin_command,
6691 "Break in function or address.\n", &stoplist);
6692 add_cmd ("at", class_breakpoint, stopat_command,
6693 "Break at a line in the current file.\n", &stoplist);
6694 add_com ("status", class_info, breakpoints_info,
6695 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6696 The \"Type\" column indicates one of:\n\
6697 \tbreakpoint - normal breakpoint\n\
6698 \twatchpoint - watchpoint\n\
6699 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6700 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6701 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6702 address and file/line number respectively.\n\n",
6703 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6704 are set to the address of the last breakpoint listed.\n\n\
6705 Convenience variable \"$bpnum\" contains the number of the last\n\
6706 breakpoint set.", NULL));
6709 add_info ("breakpoints", breakpoints_info,
6710 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6711 The \"Type\" column indicates one of:\n\
6712 \tbreakpoint - normal breakpoint\n\
6713 \twatchpoint - watchpoint\n\
6714 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6715 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6716 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6717 address and file/line number respectively.\n\n",
6718 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6719 are set to the address of the last breakpoint listed.\n\n\
6720 Convenience variable \"$bpnum\" contains the number of the last\n\
6721 breakpoint set.", NULL));
6724 add_com ("lb", class_breakpoint, breakpoints_info,
6725 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6726 The \"Type\" column indicates one of:\n\
6727 \tbreakpoint - normal breakpoint\n\
6728 \twatchpoint - watchpoint\n\
6729 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6730 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6731 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6732 address and file/line number respectively.\n\n",
6733 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6734 are set to the address of the last breakpoint listed.\n\n\
6735 Convenience variable \"$bpnum\" contains the number of the last\n\
6736 breakpoint set.", NULL));
6738 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
6739 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6740 The \"Type\" column indicates one of:\n\
6741 \tbreakpoint - normal breakpoint\n\
6742 \twatchpoint - watchpoint\n\
6743 \tlongjmp - internal breakpoint used to step through longjmp()\n\
6744 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
6745 \tuntil - internal breakpoint used by the \"until\" command\n\
6746 \tfinish - internal breakpoint used by the \"finish\" command\n",
6747 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6748 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6749 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6750 address and file/line number respectively.\n\n",
6751 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6752 are set to the address of the last breakpoint listed.\n\n\
6753 Convenience variable \"$bpnum\" contains the number of the last\n\
6754 breakpoint set.", NULL),
6755 &maintenanceinfolist);
6757 add_com ("catch", class_breakpoint, catch_command,
6758 "Set catchpoints to catch events.\n\
6759 Raised signals may be caught:\n\
6760 \tcatch signal - all signals\n\
6761 \tcatch signal <signame> - a particular signal\n\
6762 Raised exceptions may be caught:\n\
6763 \tcatch throw - all exceptions, when thrown\n\
6764 \tcatch throw <exceptname> - a particular exception, when thrown\n\
6765 \tcatch catch - all exceptions, when caught\n\
6766 \tcatch catch <exceptname> - a particular exception, when caught\n\
6767 Thread or process events may be caught:\n\
6768 \tcatch thread_start - any threads, just after creation\n\
6769 \tcatch thread_exit - any threads, just before expiration\n\
6770 \tcatch thread_join - any threads, just after joins\n\
6771 Process events may be caught:\n\
6772 \tcatch start - any processes, just after creation\n\
6773 \tcatch exit - any processes, just before expiration\n\
6774 \tcatch fork - calls to fork()\n\
6775 \tcatch vfork - calls to vfork()\n\
6776 \tcatch exec - calls to exec()\n\
6777 Dynamically-linked library events may be caught:\n\
6778 \tcatch load - loads of any library\n\
6779 \tcatch load <libname> - loads of a particular library\n\
6780 \tcatch unload - unloads of any library\n\
6781 \tcatch unload <libname> - unloads of a particular library\n\
6782 The act of your program's execution stopping may also be caught:\n\
6784 C++ exceptions may be caught:\n\
6785 \tcatch throw - all exceptions, when thrown\n\
6786 \tcatch catch - all exceptions, when caught\n\
6788 Do \"help set follow-fork-mode\" for info on debugging your program\n\
6789 after a fork or vfork is caught.\n\n\
6790 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
6792 add_com ("tcatch", class_breakpoint, tcatch_command,
6793 "Set temporary catchpoints to catch events.\n\
6794 Args like \"catch\" command.\n\
6795 Like \"catch\" except the catchpoint is only temporary,\n\
6796 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
6797 by using \"enable delete\" on the catchpoint number.");
6799 add_com ("watch", class_breakpoint, watch_command,
6801 "Set a watchpoint for an expression.\n\
6802 A watchpoint stops execution of your program whenever the value of\n\
6803 an expression changes.");
6805 add_com ("rwatch", class_breakpoint, rwatch_command,
6806 "Set a read watchpoint for an expression.\n\
6807 A watchpoint stops execution of your program whenever the value of\n\
6808 an expression is read.");
6810 add_com ("awatch", class_breakpoint, awatch_command,
6811 "Set a watchpoint for an expression.\n\
6812 A watchpoint stops execution of your program whenever the value of\n\
6813 an expression is either read or written.");
6815 add_info ("watchpoints", breakpoints_info,
6816 "Synonym for ``info breakpoints''.");
6819 c = add_set_cmd ("can-use-hw-watchpoints", class_support, var_zinteger,
6820 (char *) &can_use_hw_watchpoints,
6821 "Set debugger's willingness to use watchpoint hardware.\n\
6822 If zero, gdb will not use hardware for new watchpoints, even if\n\
6823 such is available. (However, any hardware watchpoints that were\n\
6824 created before setting this to nonzero, will continue to use watchpoint\n\
6827 add_show_from_set (c, &showlist);
6829 can_use_hw_watchpoints = 1;