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, Boston, MA 02111-1307, USA. */
25 #include "breakpoint.h"
27 #include "expression.h"
33 #include "gdbthread.h"
36 #include "gdb_string.h"
42 /* Prototypes for local functions. */
45 catch_command_1 PARAMS ((char *, int, int));
48 enable_delete_command PARAMS ((char *, int));
51 enable_delete_breakpoint PARAMS ((struct breakpoint *));
54 enable_once_command PARAMS ((char *, int));
57 enable_once_breakpoint PARAMS ((struct breakpoint *));
60 disable_command PARAMS ((char *, int));
63 enable_command PARAMS ((char *, int));
66 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
69 ignore_command PARAMS ((char *, int));
71 static int breakpoint_re_set_one PARAMS ((PTR));
74 clear_command PARAMS ((char *, int));
77 catch_command PARAMS ((char *, int));
80 handle_gnu_4_16_catch_command PARAMS ((char *, int, int));
82 static struct symtabs_and_lines
83 get_catch_sals PARAMS ((int));
86 watch_command PARAMS ((char *, int));
89 can_use_hardware_watchpoint PARAMS ((struct value *));
92 tbreak_command PARAMS ((char *, int));
95 break_command_1 PARAMS ((char *, int, int));
98 mention PARAMS ((struct breakpoint *));
101 set_raw_breakpoint PARAMS ((struct symtab_and_line));
104 check_duplicates PARAMS ((CORE_ADDR, asection *));
107 describe_other_breakpoints PARAMS ((CORE_ADDR, asection *));
110 breakpoints_info PARAMS ((char *, int));
113 breakpoint_1 PARAMS ((int, int));
116 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
118 static int breakpoint_cond_eval PARAMS ((PTR));
121 cleanup_executing_breakpoints PARAMS ((PTR));
124 commands_command PARAMS ((char *, int));
127 condition_command PARAMS ((char *, int));
130 get_number PARAMS ((char **));
133 set_breakpoint_count PARAMS ((int));
136 static struct breakpoint *
137 create_temp_exception_breakpoint PARAMS ((CORE_ADDR));
146 remove_breakpoint PARAMS ((struct breakpoint *, insertion_state_t));
148 static int print_it_normal PARAMS ((bpstat));
151 enum exception_event_kind kind;
153 } args_for_catchpoint_enable;
155 static int watchpoint_check PARAMS ((PTR));
157 static int cover_target_enable_exception_callback PARAMS ((PTR));
159 static int print_it_done PARAMS ((bpstat));
161 static int print_it_noop PARAMS ((bpstat));
163 static void maintenance_info_breakpoints PARAMS ((char *, int));
165 #ifdef GET_LONGJMP_TARGET
166 static void create_longjmp_breakpoint PARAMS ((char *));
169 static int hw_breakpoint_used_count PARAMS ((void));
171 static int hw_watchpoint_used_count PARAMS ((enum bptype, int *));
173 static void hbreak_command PARAMS ((char *, int));
175 static void thbreak_command PARAMS ((char *, int));
177 static void watch_command_1 PARAMS ((char *, int, int));
179 static void rwatch_command PARAMS ((char *, int));
181 static void awatch_command PARAMS ((char *, int));
183 static void do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp));
185 /* Prototypes for exported functions. */
188 awatch_command PARAMS ((char *, int));
191 do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp));
193 /* If FALSE, gdb will not use hardware support for watchpoints, even
194 if such is available. */
195 static int can_use_hw_watchpoints;
197 void delete_command PARAMS ((char *, int));
199 void _initialize_breakpoint PARAMS ((void));
201 void set_breakpoint_count PARAMS ((int));
203 extern int addressprint; /* Print machine addresses? */
205 #if defined (GET_LONGJMP_TARGET) || defined (SOLIB_ADD)
206 static int internal_breakpoint_number = -1;
209 /* Are we executing breakpoint commands? */
210 static int executing_breakpoint_commands;
212 /* Walk the following statement or block through all breakpoints.
213 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
216 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
218 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
219 for (b = breakpoint_chain; \
220 b? (tmp=b->next, 1): 0; \
223 /* True if SHIFT_INST_REGS defined, false otherwise. */
225 int must_shift_inst_regs =
226 #if defined(SHIFT_INST_REGS)
233 /* True if breakpoint hit counts should be displayed in breakpoint info. */
235 int show_breakpoint_hit_counts = 1;
237 /* Chain of all breakpoints defined. */
239 struct breakpoint *breakpoint_chain;
241 /* Number of last breakpoint made. */
243 int breakpoint_count;
245 /* Pointer to current exception event record */
246 static struct exception_event_record * current_exception_event;
248 /* Indicator of whether exception catchpoints should be nuked
249 between runs of a program */
250 int exception_catchpoints_are_fragile = 0;
252 /* Indicator of when exception catchpoints set-up should be
253 reinitialized -- e.g. when program is re-run */
254 int exception_support_initialized = 0;
256 /* This function returns a pointer to the string representation of the
257 pathname of the dynamically-linked library that has just been
260 This function must be used only when SOLIB_HAVE_LOAD_EVENT is TRUE,
261 or undefined results are guaranteed.
263 This string's contents are only valid immediately after the
264 inferior has stopped in the dynamic linker hook, and becomes
265 invalid as soon as the inferior is continued. Clients should make
266 a copy of this string if they wish to continue the inferior and
267 then access the string. */
269 #ifndef SOLIB_LOADED_LIBRARY_PATHNAME
270 #define SOLIB_LOADED_LIBRARY_PATHNAME(pid) ""
273 /* This function returns a pointer to the string representation of the
274 pathname of the dynamically-linked library that has just been
277 This function must be used only when SOLIB_HAVE_UNLOAD_EVENT is
278 TRUE, or undefined results are guaranteed.
280 This string's contents are only valid immediately after the
281 inferior has stopped in the dynamic linker hook, and becomes
282 invalid as soon as the inferior is continued. Clients should make
283 a copy of this string if they wish to continue the inferior and
284 then access the string. */
286 #ifndef SOLIB_UNLOADED_LIBRARY_PATHNAME
287 #define SOLIB_UNLOADED_LIBRARY_PATHNAME(pid) ""
290 /* This function is called by the "catch load" command. It allows the
291 debugger to be notified by the dynamic linker when a specified
292 library file (or any library file, if filename is NULL) is loaded. */
294 #ifndef SOLIB_CREATE_CATCH_LOAD_HOOK
295 #define SOLIB_CREATE_CATCH_LOAD_HOOK(pid,tempflag,filename,cond_string) \
296 error ("catch of library loads not yet implemented on this platform")
299 /* This function is called by the "catch unload" command. It allows
300 the debugger to be notified by the dynamic linker when a specified
301 library file (or any library file, if filename is NULL) is
304 #ifndef SOLIB_CREATE_CATCH_UNLOAD_HOOK
305 #define SOLIB_CREATE_CATCH_UNLOAD_HOOK(pid,tempflag,filename,cond_string) \
306 error ("catch of library unloads not yet implemented on this platform")
309 /* Set breakpoint count to NUM. */
312 set_breakpoint_count (num)
315 breakpoint_count = num;
316 set_internalvar (lookup_internalvar ("bpnum"),
317 value_from_longest (builtin_type_int, (LONGEST) num));
320 /* Used in run_command to zero the hit count when a new run starts. */
323 clear_breakpoint_hit_counts ()
325 struct breakpoint *b;
331 /* Default address, symtab and line to put a breakpoint at
332 for "break" command with no arg.
333 if default_breakpoint_valid is zero, the other three are
334 not valid, and "break" with no arg is an error.
336 This set by print_stack_frame, which calls set_default_breakpoint. */
338 int default_breakpoint_valid;
339 CORE_ADDR default_breakpoint_address;
340 struct symtab *default_breakpoint_symtab;
341 int default_breakpoint_line;
343 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
344 Advance *PP after the string and any trailing whitespace.
346 Currently the string can either be a number or "$" followed by the name
347 of a convenience variable. Making it an expression wouldn't work well
348 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
357 /* Empty line means refer to the last breakpoint. */
358 return breakpoint_count;
361 /* Make a copy of the name, so we can null-terminate it
362 to pass to lookup_internalvar(). */
367 while (isalnum (*p) || *p == '_')
369 varname = (char *) alloca (p - start + 1);
370 strncpy (varname, start, p - start);
371 varname[p - start] = '\0';
372 val = value_of_internalvar (lookup_internalvar (varname));
373 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
375 "Convenience variables used to specify breakpoints must have integer values."
377 retval = (int) value_as_long (val);
383 while (*p >= '0' && *p <= '9')
386 /* There is no number here. (e.g. "cond a == b"). */
387 error_no_arg ("breakpoint number");
390 if (!(isspace (*p) || *p == '\0'))
391 error ("breakpoint number expected");
398 /* condition N EXP -- set break condition of breakpoint N to EXP. */
401 condition_command (arg, from_tty)
405 register struct breakpoint *b;
410 error_no_arg ("breakpoint number");
413 bnum = get_number (&p);
416 if (b->number == bnum)
423 if (b->cond_string != NULL)
424 free ((PTR)b->cond_string);
429 b->cond_string = NULL;
431 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
436 /* I don't know if it matters whether this is the string the user
437 typed in or the decompiled expression. */
438 b->cond_string = savestring (arg, strlen (arg));
439 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
441 error ("Junk at end of expression");
443 breakpoints_changed ();
447 error ("No breakpoint number %d.", bnum);
452 commands_command (arg, from_tty)
456 register struct breakpoint *b;
459 struct command_line *l;
461 /* If we allowed this, we would have problems with when to
462 free the storage, if we change the commands currently
465 if (executing_breakpoint_commands)
466 error ("Can't use the \"commands\" command among a breakpoint's commands.");
469 bnum = get_number (&p);
471 error ("Unexpected extra arguments following breakpoint number.");
474 if (b->number == bnum)
477 sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum);
478 l = read_command_lines (tmpbuf, from_tty);
479 free_command_lines (&b->commands);
481 breakpoints_changed ();
484 error ("No breakpoint number %d.", bnum);
487 /* Like target_read_memory() but if breakpoints are inserted, return
488 the shadow contents instead of the breakpoints themselves.
490 Read "memory data" from whatever target or inferior we have.
491 Returns zero if successful, errno value if not. EIO is used
492 for address out of bounds. If breakpoints are inserted, returns
493 shadow contents, not the breakpoints themselves. From breakpoint.c. */
496 read_memory_nobpt (memaddr, myaddr, len)
502 struct breakpoint *b;
503 CORE_ADDR bp_addr = 0;
506 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
507 /* No breakpoints on this machine. */
508 return target_read_memory (memaddr, myaddr, len);
512 if (b->type == bp_none)
513 warning ("attempted to read through apparently deleted breakpoint #%d?\n", b->number);
515 /* memory breakpoint? */
516 if (b->type == bp_watchpoint
517 || b->type == bp_hardware_watchpoint
518 || b->type == bp_read_watchpoint
519 || b->type == bp_access_watchpoint)
524 /* Addresses and length of the part of the breakpoint that
526 /* XXXX The m68k, sh and h8300 have different local and remote
527 breakpoint values. BREAKPOINT_FROM_PC still manages to
528 correctly determine the breakpoints memory address and size
529 for these targets. */
530 bp_addr = b->address;
532 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
537 if (bp_addr + bp_size <= memaddr)
538 /* The breakpoint is entirely before the chunk of memory we
541 if (bp_addr >= memaddr + len)
542 /* The breakpoint is entirely after the chunk of memory we are
545 /* Copy the breakpoint from the shadow contents, and recurse for
546 the things before and after. */
548 /* Offset within shadow_contents. */
551 if (bp_addr < memaddr)
553 /* Only copy the second part of the breakpoint. */
554 bp_size -= memaddr - bp_addr;
555 bptoffset = memaddr - bp_addr;
559 if (bp_addr + bp_size > memaddr + len)
561 /* Only copy the first part of the breakpoint. */
562 bp_size -= (bp_addr + bp_size) - (memaddr + len);
565 memcpy (myaddr + bp_addr - memaddr,
566 b->shadow_contents + bptoffset, bp_size);
568 if (bp_addr > memaddr)
570 /* Copy the section of memory before the breakpoint. */
571 status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr);
576 if (bp_addr + bp_size < memaddr + len)
578 /* Copy the section of memory after the breakpoint. */
579 status = read_memory_nobpt
581 myaddr + bp_addr + bp_size - memaddr,
582 memaddr + len - (bp_addr + bp_size));
589 /* Nothing overlaps. Just call read_memory_noerr. */
590 return target_read_memory (memaddr, myaddr, len);
594 /* insert_breakpoints is used when starting or continuing the program.
595 remove_breakpoints is used when the program stops.
596 Both return zero if successful,
597 or an `errno' value if could not write the inferior. */
600 insert_breakpoints ()
602 register struct breakpoint *b, *temp;
604 int disabled_breaks = 0;
606 static char message1[] = "Error inserting catchpoint %d:\n";
607 static char message[sizeof (message1) + 30];
610 ALL_BREAKPOINTS_SAFE (b, temp)
612 if (b->type != bp_watchpoint
613 && b->type != bp_hardware_watchpoint
614 && b->type != bp_read_watchpoint
615 && b->type != bp_access_watchpoint
616 && b->type != bp_catch_fork
617 && b->type != bp_catch_vfork
618 && b->type != bp_catch_exec
619 && b->type != bp_catch_throw
620 && b->type != bp_catch_catch
621 && b->enable != disabled
622 && b->enable != shlib_disabled
623 && b->enable != call_disabled
627 if (b->type == bp_hardware_breakpoint)
628 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
631 /* Check to see if breakpoint is in an overlay section;
632 if so, we should set the breakpoint at the LMA address.
633 Only if the section is currently mapped should we ALSO
634 set a break at the VMA address. */
635 if (overlay_debugging && b->section &&
636 section_is_overlay (b->section))
640 addr = overlay_unmapped_address (b->address, b->section);
641 val = target_insert_breakpoint (addr, b->shadow_contents);
642 /* This would be the time to check val, to see if the
643 breakpoint write to the load address succeeded.
644 However, this might be an ordinary occurrance, eg. if
645 the unmapped overlay is in ROM. */
646 val = 0; /* in case unmapped address failed */
647 if (section_is_mapped (b->section))
648 val = target_insert_breakpoint (b->address,
651 else /* ordinary (non-overlay) address */
652 val = target_insert_breakpoint(b->address, b->shadow_contents);
656 /* Can't set the breakpoint. */
657 #if defined (DISABLE_UNSETTABLE_BREAK)
658 if (DISABLE_UNSETTABLE_BREAK (b->address))
660 /* See also: disable_breakpoints_in_shlibs. */
662 b->enable = shlib_disabled;
663 if (!disabled_breaks)
665 target_terminal_ours_for_output ();
666 fprintf_unfiltered (gdb_stderr,
667 "Cannot insert breakpoint %d:\n", b->number);
668 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
671 printf_filtered ("%d ", b->number);
676 target_terminal_ours_for_output ();
677 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
678 #ifdef ONE_PROCESS_WRITETEXT
679 fprintf_unfiltered (gdb_stderr,
680 "The same program may be running in another process.\n");
682 memory_error (val, b->address); /* which bombs us out */
688 else if (ep_is_exception_catchpoint (b)
689 && b->enable != disabled
690 && b->enable != shlib_disabled
691 && b->enable != call_disabled
696 /* If we get here, we must have a callback mechanism for exception
697 events -- with g++ style embedded label support, we insert
698 ordinary breakpoints and not catchpoints. */
699 sprintf (message, message1, b->number); /* Format possible error message */
701 val = target_insert_breakpoint(b->address, b->shadow_contents);
704 /* Couldn't set breakpoint for some reason */
705 target_terminal_ours_for_output ();
706 fprintf_unfiltered (gdb_stderr,
707 "Cannot insert catchpoint %d; disabling it\n", b->number);
708 b->enable = disabled;
712 /* Bp set, now make sure callbacks are enabled */
714 args_for_catchpoint_enable args;
715 args.kind = b->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
717 val = catch_errors (cover_target_enable_exception_callback,
719 message, RETURN_MASK_ALL);
720 if (val != 0 && val != -1)
724 /* Check if something went wrong; val == 0 can be ignored */
727 /* something went wrong */
728 target_terminal_ours_for_output ();
729 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d; disabling it\n", b->number);
730 b->enable = disabled;
735 else if ((b->type == bp_hardware_watchpoint ||
736 b->type == bp_read_watchpoint ||
737 b->type == bp_access_watchpoint)
738 && b->enable == enabled
742 struct frame_info *saved_frame;
743 int saved_level, within_current_scope;
744 value_ptr mark = value_mark ();
747 /* Save the current frame and level so we can restore it after
748 evaluating the watchpoint expression on its own frame. */
749 saved_frame = selected_frame;
750 saved_level = selected_frame_level;
752 /* Determine if the watchpoint is within scope. */
753 if (b->exp_valid_block == NULL)
754 within_current_scope = 1;
757 struct frame_info *fi;
759 /* There might be no current frame at this moment if we are
760 resuming from a step over a breakpoint.
761 Set up current frame before trying to find the watchpoint
763 get_current_frame ();
764 fi = find_frame_addr_in_frame_chain (b->watchpoint_frame);
765 within_current_scope = (fi != NULL);
766 if (within_current_scope)
767 select_frame (fi, -1);
770 if (within_current_scope)
772 /* Evaluate the expression and cut the chain of values
773 produced off from the value chain. */
774 v = evaluate_expression (b->exp);
775 value_release_to_mark (mark);
780 /* Look at each value on the value chain. */
781 for ( ; v; v=v->next)
783 /* If it's a memory location, then we must watch it. */
784 if (v->lval == lval_memory)
788 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
789 len = TYPE_LENGTH (VALUE_TYPE (v));
791 if (b->type == bp_read_watchpoint)
793 else if (b->type == bp_access_watchpoint)
796 val = target_insert_watchpoint (addr, len, type);
805 /* Failure to insert a watchpoint on any memory value in the
806 value chain brings us here. */
808 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
814 Hardware watchpoint %d deleted because the program has left the block in\n\
815 which its expression is valid.\n", b->number);
816 if (b->related_breakpoint)
817 b->related_breakpoint->disposition = del_at_next_stop;
818 b->disposition = del_at_next_stop;
821 /* Restore the frame and level. */
822 if ((saved_frame != selected_frame) ||
823 (saved_level != selected_frame_level))
824 select_and_print_frame (saved_frame, saved_level);
826 else if ((b->type == bp_catch_fork
827 || b->type == bp_catch_vfork
828 || b->type == bp_catch_exec)
829 && b->enable == enabled
837 val = target_insert_fork_catchpoint (inferior_pid);
839 case bp_catch_vfork :
840 val = target_insert_vfork_catchpoint (inferior_pid);
843 val = target_insert_exec_catchpoint (inferior_pid);
848 target_terminal_ours_for_output ();
849 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d:\n", b->number);
856 printf_filtered ("\n");
863 remove_breakpoints ()
865 register struct breakpoint *b;
872 val = remove_breakpoint (b, mark_uninserted);
881 reattach_breakpoints (pid)
884 register struct breakpoint *b;
886 int saved_inferior_pid = inferior_pid;
888 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
893 remove_breakpoint (b, mark_inserted);
894 if (b->type == bp_hardware_breakpoint)
895 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
897 val = target_insert_breakpoint(b->address, b->shadow_contents);
900 inferior_pid = saved_inferior_pid;
905 inferior_pid = saved_inferior_pid;
910 update_breakpoints_after_exec ()
912 struct breakpoint * b;
913 struct breakpoint * temp;
915 /* Doing this first prevents the badness of having delete_breakpoint()
916 write a breakpoint's current "shadow contents" to lift the bp. That
917 shadow is NOT valid after an exec()! */
918 mark_breakpoints_out ();
920 ALL_BREAKPOINTS_SAFE (b, temp)
922 /* Solib breakpoints must be explicitly reset after an exec(). */
923 if (b->type == bp_shlib_event)
925 delete_breakpoint (b);
929 /* Step-resume breakpoints are meaningless after an exec(). */
930 if (b->type == bp_step_resume)
932 delete_breakpoint (b);
936 /* Ditto the sigtramp handler breakpoints. */
937 if (b->type == bp_through_sigtramp)
939 delete_breakpoint (b);
943 /* Ditto the exception-handling catchpoints. */
944 if ((b->type == bp_catch_catch) || (b->type == bp_catch_throw))
946 delete_breakpoint (b);
950 /* Don't delete an exec catchpoint, because else the inferior
951 won't stop when it ought!
953 Similarly, we probably ought to keep vfork catchpoints, 'cause
954 on this target, we may not be able to stop when the vfork is seen,
955 but only when the subsequent exec is seen. (And because deleting
956 fork catchpoints here but not vfork catchpoints will seem mysterious
957 to users, keep those too.)
959 ??rehrauer: Let's hope that merely clearing out this catchpoint's
960 target address field, if any, is sufficient to have it be reset
961 automagically. Certainly on HP-UX that's true. */
962 if ((b->type == bp_catch_exec) ||
963 (b->type == bp_catch_vfork) ||
964 (b->type == bp_catch_fork))
966 b->address = (CORE_ADDR) NULL;
970 /* bp_finish is a special case. The only way we ought to be able
971 to see one of these when an exec() has happened, is if the user
972 caught a vfork, and then said "finish". Ordinarily a finish just
973 carries them to the call-site of the current callee, by setting
974 a temporary bp there and resuming. But in this case, the finish
975 will carry them entirely through the vfork & exec.
977 We don't want to allow a bp_finish to remain inserted now. But
978 we can't safely delete it, 'cause finish_command has a handle to
979 the bp on a bpstat, and will later want to delete it. There's a
980 chance (and I've seen it happen) that if we delete the bp_finish
981 here, that its storage will get reused by the time finish_command
982 gets 'round to deleting the "use to be a bp_finish" breakpoint.
983 We really must allow finish_command to delete a bp_finish.
985 In the absense of a general solution for the "how do we know it's
986 safe to delete something others may have handles to?" problem, what
987 we'll do here is just uninsert the bp_finish, and let finish_command
990 (We know the bp_finish is "doomed" in the sense that it's momentary,
991 and will be deleted as soon as finish_command sees the inferior stopped.
992 So it doesn't matter that the bp's address is probably bogus in the
993 new a.out, unlike e.g., the solib breakpoints.) */
994 if (b->type == bp_finish)
999 /* Without a symbolic address, we have little hope of the
1000 pre-exec() address meaning the same thing in the post-exec()
1002 if (b->addr_string == NULL)
1004 delete_breakpoint (b);
1008 /* If this breakpoint has survived the above battery of checks, then
1009 it must have a symbolic address. Be sure that it gets reevaluated
1010 to a target address, rather than reusing the old evaluation. */
1011 b->address = (CORE_ADDR) NULL;
1016 detach_breakpoints (pid)
1019 register struct breakpoint *b;
1021 int saved_inferior_pid = inferior_pid;
1023 if (pid == inferior_pid)
1024 error ("Cannot detach breakpoints of inferior_pid");
1026 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
1031 val = remove_breakpoint (b, mark_inserted);
1034 inferior_pid = saved_inferior_pid;
1039 inferior_pid = saved_inferior_pid;
1044 remove_breakpoint (b, is)
1045 struct breakpoint *b;
1046 insertion_state_t is;
1050 if (b->type == bp_none)
1051 warning ("attempted to remove apparently deleted breakpoint #%d?\n", b->number);
1053 if (b->type != bp_watchpoint
1054 && b->type != bp_hardware_watchpoint
1055 && b->type != bp_read_watchpoint
1056 && b->type != bp_access_watchpoint
1057 && b->type != bp_catch_fork
1058 && b->type != bp_catch_vfork
1059 && b->type != bp_catch_exec
1060 && b->type != bp_catch_catch
1061 && b->type != bp_catch_throw)
1064 if (b->type == bp_hardware_breakpoint)
1065 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
1068 /* Check to see if breakpoint is in an overlay section;
1069 if so, we should remove the breakpoint at the LMA address.
1070 If that is not equal to the raw address, then we should
1071 presumable remove the breakpoint there as well. */
1072 if (overlay_debugging && b->section &&
1073 section_is_overlay (b->section))
1077 addr = overlay_unmapped_address (b->address, b->section);
1078 val = target_remove_breakpoint (addr, b->shadow_contents);
1079 /* This would be the time to check val, to see if the
1080 shadow breakpoint write to the load address succeeded.
1081 However, this might be an ordinary occurrance, eg. if
1082 the unmapped overlay is in ROM. */
1083 val = 0; /* in case unmapped address failed */
1084 if (section_is_mapped (b->section))
1085 val = target_remove_breakpoint (b->address,
1086 b->shadow_contents);
1088 else /* ordinary (non-overlay) address */
1089 val = target_remove_breakpoint(b->address, b->shadow_contents);
1093 b->inserted = (is == mark_inserted);
1095 else if ((b->type == bp_hardware_watchpoint ||
1096 b->type == bp_read_watchpoint ||
1097 b->type == bp_access_watchpoint)
1098 && b->enable == enabled
1103 b->inserted = (is == mark_inserted);
1104 /* Walk down the saved value chain. */
1105 for (v = b->val_chain; v; v = v->next)
1107 /* For each memory reference remove the watchpoint
1109 if (v->lval == lval_memory)
1111 int addr, len, type;
1113 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1114 len = TYPE_LENGTH (VALUE_TYPE (v));
1116 if (b->type == bp_read_watchpoint)
1118 else if (b->type == bp_access_watchpoint)
1121 val = target_remove_watchpoint (addr, len, type);
1127 /* Failure to remove any of the hardware watchpoints comes here. */
1128 if ((is == mark_uninserted) && (b->inserted))
1129 warning ("Hardware watchpoint %d: Could not remove watchpoint\n",
1132 /* Free the saved value chain. We will construct a new one
1133 the next time the watchpoint is inserted. */
1134 for (v = b->val_chain; v; v = n)
1139 b->val_chain = NULL;
1141 else if ((b->type == bp_catch_fork ||
1142 b->type == bp_catch_vfork ||
1143 b->type == bp_catch_exec)
1144 && b->enable == enabled
1151 val = target_remove_fork_catchpoint (inferior_pid);
1153 case bp_catch_vfork :
1154 val = target_remove_vfork_catchpoint (inferior_pid);
1156 case bp_catch_exec :
1157 val = target_remove_exec_catchpoint (inferior_pid);
1162 b->inserted = (is == mark_inserted);
1164 else if ((b->type == bp_catch_catch ||
1165 b->type == bp_catch_throw)
1166 && b->enable == enabled
1170 val = target_remove_breakpoint(b->address, b->shadow_contents);
1173 b->inserted = (is == mark_inserted);
1175 else if (ep_is_exception_catchpoint (b)
1176 && b->inserted /* sometimes previous insert doesn't happen */
1177 && b->enable == enabled
1181 val = target_remove_breakpoint(b->address, b->shadow_contents);
1185 b->inserted = (is == mark_inserted);
1191 /* Clear the "inserted" flag in all breakpoints. */
1194 mark_breakpoints_out ()
1196 register struct breakpoint *b;
1202 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
1203 which should go away between runs of the program.
1205 Plus other such housekeeping that has to be done for breakpoints
1208 Note: this function gets called at the end of a run (by generic_mourn_inferior)
1209 and when a run begins (by init_wait_for_inferior). */
1214 breakpoint_init_inferior (context)
1215 enum inf_context context;
1217 register struct breakpoint *b, *temp;
1218 static int warning_needed = 0;
1220 ALL_BREAKPOINTS_SAFE (b, temp)
1227 case bp_watchpoint_scope:
1229 /* If the call dummy breakpoint is at the entry point it will
1230 cause problems when the inferior is rerun, so we better
1233 Also get rid of scope breakpoints. */
1234 delete_breakpoint (b);
1238 case bp_hardware_watchpoint:
1239 case bp_read_watchpoint:
1240 case bp_access_watchpoint:
1242 /* Likewise for watchpoints on local expressions. */
1243 if (b->exp_valid_block != NULL)
1244 delete_breakpoint (b);
1247 /* Likewise for exception catchpoints in dynamic-linked
1248 executables where required */
1249 if (ep_is_exception_catchpoint (b) &&
1250 exception_catchpoints_are_fragile)
1253 delete_breakpoint (b);
1259 if (exception_catchpoints_are_fragile)
1260 exception_support_initialized = 0;
1262 /* Don't issue the warning unless it's really needed... */
1263 if (warning_needed && (context != inf_exited))
1265 warning ("Exception catchpoints from last run were deleted, you must reinsert them explicitly");
1270 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
1271 When continuing from a location with a breakpoint,
1272 we actually single step once before calling insert_breakpoints. */
1275 breakpoint_here_p (pc)
1278 register struct breakpoint *b;
1281 if (b->enable == enabled
1282 && b->enable != shlib_disabled
1283 && b->enable != call_disabled
1284 && b->address == pc) /* bp is enabled and matches pc */
1286 if (overlay_debugging &&
1287 section_is_overlay (b->section) &&
1288 !section_is_mapped (b->section))
1289 continue; /* unmapped overlay -- can't be a match */
1297 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(), but it
1298 only returns true if there is actually a breakpoint inserted at PC. */
1301 breakpoint_inserted_here_p (pc)
1304 register struct breakpoint *b;
1308 && b->address == pc) /* bp is inserted and matches pc */
1310 if (overlay_debugging &&
1311 section_is_overlay (b->section) &&
1312 !section_is_mapped (b->section))
1313 continue; /* unmapped overlay -- can't be a match */
1321 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
1322 because figuring out the saved SP would take too much time, at least using
1323 get_saved_register on the 68k. This means that for this function to
1324 work right a port must use the bp_call_dummy breakpoint. */
1327 frame_in_dummy (frame)
1328 struct frame_info *frame;
1331 #ifdef USE_GENERIC_DUMMY_FRAMES
1332 return generic_pc_in_call_dummy (frame->pc, frame->frame);
1334 struct breakpoint *b;
1338 static ULONGEST dummy[] = CALL_DUMMY;
1340 if (b->type == bp_call_dummy
1341 && b->frame == frame->frame
1343 /* We need to check the PC as well as the frame on the sparc,
1344 for signals.exp in the testsuite. */
1347 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
1348 && frame->pc <= b->address)
1351 #endif /* GENERIC_DUMMY_FRAMES */
1352 #endif /* CALL_DUMMY */
1356 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1357 is valid for process/thread PID. */
1360 breakpoint_thread_match (pc, pid)
1364 struct breakpoint *b;
1367 thread = pid_to_thread_id (pid);
1370 if (b->enable != disabled
1371 && b->enable != shlib_disabled
1372 && b->enable != call_disabled
1374 && (b->thread == -1 || b->thread == thread))
1376 if (overlay_debugging &&
1377 section_is_overlay (b->section) &&
1378 !section_is_mapped (b->section))
1379 continue; /* unmapped overlay -- can't be a match */
1388 /* bpstat stuff. External routines' interfaces are documented
1392 ep_is_catchpoint (ep)
1393 struct breakpoint * ep;
1396 (ep->type == bp_catch_load)
1397 || (ep->type == bp_catch_unload)
1398 || (ep->type == bp_catch_fork)
1399 || (ep->type == bp_catch_vfork)
1400 || (ep->type == bp_catch_exec)
1401 || (ep->type == bp_catch_catch)
1402 || (ep->type == bp_catch_throw)
1405 /* ??rehrauer: Add more kinds here, as are implemented... */
1410 ep_is_shlib_catchpoint (ep)
1411 struct breakpoint * ep;
1414 (ep->type == bp_catch_load)
1415 || (ep->type == bp_catch_unload)
1420 ep_is_exception_catchpoint (ep)
1421 struct breakpoint * ep;
1424 (ep->type == bp_catch_catch)
1425 || (ep->type == bp_catch_throw)
1429 /* Clear a bpstat so that it says we are not at any breakpoint.
1430 Also free any storage that is part of a bpstat. */
1445 if (p->old_val != NULL)
1446 value_free (p->old_val);
1453 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1454 is part of the bpstat is copied as well. */
1462 bpstat retval = NULL;
1467 for (; bs != NULL; bs = bs->next)
1469 tmp = (bpstat) xmalloc (sizeof (*tmp));
1470 memcpy (tmp, bs, sizeof (*tmp));
1472 /* This is the first thing in the chain. */
1482 /* Find the bpstat associated with this breakpoint */
1485 bpstat_find_breakpoint(bsp, breakpoint)
1487 struct breakpoint *breakpoint;
1489 if (bsp == NULL) return NULL;
1491 for (;bsp != NULL; bsp = bsp->next) {
1492 if (bsp->breakpoint_at == breakpoint) return bsp;
1497 /* Find a step_resume breakpoint associated with this bpstat.
1498 (If there are multiple step_resume bp's on the list, this function
1499 will arbitrarily pick one.)
1501 It is an error to use this function if BPSTAT doesn't contain a
1502 step_resume breakpoint.
1504 See wait_for_inferior's use of this function. */
1506 bpstat_find_step_resume_breakpoint (bsp)
1510 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1512 for (; bsp != NULL; bsp = bsp->next)
1514 if ((bsp->breakpoint_at != NULL) &&
1515 (bsp->breakpoint_at->type == bp_step_resume))
1516 return bsp->breakpoint_at;
1519 error ("Internal error (no step_resume breakpoint found)");
1523 /* Return the breakpoint number of the first breakpoint we are stopped
1524 at. *BSP upon return is a bpstat which points to the remaining
1525 breakpoints stopped at (but which is not guaranteed to be good for
1526 anything but further calls to bpstat_num).
1527 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1533 struct breakpoint *b;
1536 return 0; /* No more breakpoint values */
1539 b = (*bsp)->breakpoint_at;
1540 *bsp = (*bsp)->next;
1542 return -1; /* breakpoint that's been deleted since */
1544 return b->number; /* We have its number */
1548 /* Modify BS so that the actions will not be performed. */
1551 bpstat_clear_actions (bs)
1554 for (; bs != NULL; bs = bs->next)
1556 bs->commands = NULL;
1557 if (bs->old_val != NULL)
1559 value_free (bs->old_val);
1565 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1568 cleanup_executing_breakpoints (ignore)
1571 executing_breakpoint_commands = 0;
1574 /* Execute all the commands associated with all the breakpoints at this
1575 location. Any of these commands could cause the process to proceed
1576 beyond this point, etc. We look out for such changes by checking
1577 the global "breakpoint_proceeded" after each command. */
1580 bpstat_do_actions (bsp)
1584 struct cleanup *old_chain;
1585 struct command_line *cmd;
1587 /* Avoid endless recursion if a `source' command is contained
1589 if (executing_breakpoint_commands)
1592 executing_breakpoint_commands = 1;
1593 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
1596 /* Note that (as of this writing), our callers all appear to
1597 be passing us the address of global stop_bpstat. And, if
1598 our calls to execute_control_command cause the inferior to
1599 proceed, that global (and hence, *bsp) will change.
1601 We must be careful to not touch *bsp unless the inferior
1602 has not proceeded. */
1604 /* This pointer will iterate over the list of bpstat's. */
1607 breakpoint_proceeded = 0;
1608 for (; bs != NULL; bs = bs->next)
1613 execute_control_command (cmd);
1615 if (breakpoint_proceeded)
1620 if (breakpoint_proceeded)
1621 /* The inferior is proceeded by the command; bomb out now.
1622 The bpstat chain has been blown away by wait_for_inferior.
1623 But since execution has stopped again, there is a new bpstat
1624 to look at, so start over. */
1627 bs->commands = NULL;
1630 executing_breakpoint_commands = 0;
1631 discard_cleanups (old_chain);
1634 /* This is the normal print_it function for a bpstat. In the future,
1635 much of this logic could (should?) be moved to bpstat_stop_status,
1636 by having it set different print_it functions.
1638 Current scheme: When we stop, bpstat_print() is called.
1639 It loops through the bpstat list of things causing this stop,
1640 calling the print_it function for each one. The default
1641 print_it function, used for breakpoints, is print_it_normal().
1642 (Also see print_it_noop() and print_it_done()).
1644 Return values from this routine (used by bpstat_print() to
1646 1: Means we printed something, and we do *not* desire that
1647 something to be followed by a location.
1648 0: Means we printed something, and we *do* desire that
1649 something to be followed by a location.
1650 -1: Means we printed nothing. */
1653 print_it_normal (bs)
1656 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1657 which has since been deleted. */
1658 if (bs->breakpoint_at == NULL
1659 || (bs->breakpoint_at->type != bp_breakpoint
1660 && bs->breakpoint_at->type != bp_catch_load
1661 && bs->breakpoint_at->type != bp_catch_unload
1662 && bs->breakpoint_at->type != bp_catch_fork
1663 && bs->breakpoint_at->type != bp_catch_vfork
1664 && bs->breakpoint_at->type != bp_catch_exec
1665 && bs->breakpoint_at->type != bp_catch_catch
1666 && bs->breakpoint_at->type != bp_catch_throw
1667 && bs->breakpoint_at->type != bp_hardware_breakpoint
1668 && bs->breakpoint_at->type != bp_watchpoint
1669 && bs->breakpoint_at->type != bp_read_watchpoint
1670 && bs->breakpoint_at->type != bp_access_watchpoint
1671 && bs->breakpoint_at->type != bp_hardware_watchpoint))
1674 if (ep_is_shlib_catchpoint (bs->breakpoint_at))
1676 annotate_catchpoint (bs->breakpoint_at->number);
1677 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1678 if (bs->breakpoint_at->type == bp_catch_load)
1679 printf_filtered ("loaded");
1680 else if (bs->breakpoint_at->type == bp_catch_unload)
1681 printf_filtered ("unloaded");
1682 printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname);
1685 else if (bs->breakpoint_at->type == bp_catch_fork ||
1686 bs->breakpoint_at->type == bp_catch_vfork)
1688 annotate_catchpoint (bs->breakpoint_at->number);
1689 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1690 if (bs->breakpoint_at->type == bp_catch_fork)
1691 printf_filtered ("forked");
1692 else if (bs->breakpoint_at->type == bp_catch_vfork)
1693 printf_filtered ("vforked");
1694 printf_filtered (" process %d), ", bs->breakpoint_at->forked_inferior_pid);
1697 else if (bs->breakpoint_at->type == bp_catch_exec)
1699 annotate_catchpoint (bs->breakpoint_at->number);
1700 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1701 bs->breakpoint_at->number,
1702 bs->breakpoint_at->exec_pathname);
1705 else if (bs->breakpoint_at->type == bp_catch_catch)
1707 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH))
1709 annotate_catchpoint (bs->breakpoint_at->number);
1710 printf_filtered ("\nCatchpoint %d (exception caught), ", bs->breakpoint_at->number);
1711 printf_filtered ("throw location ");
1712 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1713 printf_filtered ("%s:%d",
1714 CURRENT_EXCEPTION_THROW_FILE,
1715 CURRENT_EXCEPTION_THROW_LINE);
1717 printf_filtered ("unknown");
1719 printf_filtered (", catch location ");
1720 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1721 printf_filtered ("%s:%d",
1722 CURRENT_EXCEPTION_CATCH_FILE,
1723 CURRENT_EXCEPTION_CATCH_LINE);
1725 printf_filtered ("unknown");
1727 printf_filtered ("\n");
1728 return 1; /* don't bother to print location frame info */
1732 return -1; /* really throw, some other bpstat will handle it */
1735 else if (bs->breakpoint_at->type == bp_catch_throw)
1737 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW))
1739 annotate_catchpoint (bs->breakpoint_at->number);
1740 printf_filtered ("\nCatchpoint %d (exception thrown), ", bs->breakpoint_at->number);
1741 printf_filtered ("throw location ");
1742 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1743 printf_filtered ("%s:%d",
1744 CURRENT_EXCEPTION_THROW_FILE,
1745 CURRENT_EXCEPTION_THROW_LINE);
1747 printf_filtered ("unknown");
1749 printf_filtered (", catch location ");
1750 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1751 printf_filtered ("%s:%d",
1752 CURRENT_EXCEPTION_CATCH_FILE,
1753 CURRENT_EXCEPTION_CATCH_LINE);
1755 printf_filtered ("unknown");
1757 printf_filtered ("\n");
1758 return 1; /* don't bother to print location frame info */
1762 return -1; /* really catch, some other bpstat willhandle it */
1766 else if (bs->breakpoint_at->type == bp_breakpoint ||
1767 bs->breakpoint_at->type == bp_hardware_breakpoint)
1769 /* I think the user probably only wants to see one breakpoint
1770 number, not all of them. */
1771 annotate_breakpoint (bs->breakpoint_at->number);
1772 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
1775 else if ((bs->old_val != NULL) &&
1776 (bs->breakpoint_at->type == bp_watchpoint ||
1777 bs->breakpoint_at->type == bp_access_watchpoint ||
1778 bs->breakpoint_at->type == bp_hardware_watchpoint))
1780 annotate_watchpoint (bs->breakpoint_at->number);
1781 mention (bs->breakpoint_at);
1782 printf_filtered ("\nOld value = ");
1783 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
1784 printf_filtered ("\nNew value = ");
1785 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1786 Val_pretty_default);
1787 printf_filtered ("\n");
1788 value_free (bs->old_val);
1790 /* More than one watchpoint may have been triggered. */
1793 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
1794 bs->breakpoint_at->type == bp_read_watchpoint)
1796 mention (bs->breakpoint_at);
1797 printf_filtered ("\nValue = ");
1798 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1799 Val_pretty_default);
1800 printf_filtered ("\n");
1803 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1807 /* Print a message indicating what happened.
1808 This is called from normal_stop().
1809 The input to this routine is the head of the bpstat list - a list
1810 of the eventpoints that caused this stop.
1811 This routine calls the "print_it" routine(s) associated
1812 with these eventpoints. This will print (for example)
1813 the "Breakpoint n," part of the output.
1814 The return value of this routine is one of:
1816 -1: Means we printed nothing
1817 0: Means we printed something, and expect subsequent
1818 code to print the location. An example is
1819 "Breakpoint 1, " which should be followed by
1821 1 : Means we printed something, but there is no need
1822 to also print the location part of the message.
1823 An example is the catch/throw messages, which
1824 don't require a location appended to the end. */
1835 val = (*bs->print_it) (bs);
1839 /* Maybe another breakpoint in the chain caused us to stop.
1840 (Currently all watchpoints go on the bpstat whether hit or
1841 not. That probably could (should) be changed, provided care is taken
1842 with respect to bpstat_explains_signal). */
1844 return bpstat_print (bs->next);
1846 /* We reached the end of the chain without printing anything. */
1850 /* Evaluate the expression EXP and return 1 if value is zero.
1851 This is used inside a catch_errors to evaluate the breakpoint condition.
1852 The argument is a "struct expression *" that has been cast to char * to
1853 make it pass through catch_errors. */
1856 breakpoint_cond_eval (exp)
1859 value_ptr mark = value_mark ();
1860 int i = !value_true (evaluate_expression ((struct expression *)exp));
1861 value_free_to_mark (mark);
1865 /* Allocate a new bpstat and chain it to the current one. */
1868 bpstat_alloc (b, cbs)
1869 register struct breakpoint *b;
1870 bpstat cbs; /* Current "bs" value */
1874 bs = (bpstat) xmalloc (sizeof (*bs));
1876 bs->breakpoint_at = b;
1877 /* If the condition is false, etc., don't do the commands. */
1878 bs->commands = NULL;
1880 bs->print_it = print_it_normal;
1884 /* Possible return values for watchpoint_check (this can't be an enum
1885 because of check_errors). */
1886 /* The watchpoint has been deleted. */
1887 #define WP_DELETED 1
1888 /* The value has changed. */
1889 #define WP_VALUE_CHANGED 2
1890 /* The value has not changed. */
1891 #define WP_VALUE_NOT_CHANGED 3
1893 #define BP_TEMPFLAG 1
1894 #define BP_HARDWAREFLAG 2
1896 /* Check watchpoint condition. */
1899 watchpoint_check (p)
1902 bpstat bs = (bpstat) p;
1903 struct breakpoint *b;
1904 struct frame_info *fr;
1905 int within_current_scope;
1907 b = bs->breakpoint_at;
1909 if (b->exp_valid_block == NULL)
1910 within_current_scope = 1;
1913 /* There is no current frame at this moment. If we're going to have
1914 any chance of handling watchpoints on local variables, we'll need
1915 the frame chain (so we can determine if we're in scope). */
1916 reinit_frame_cache();
1917 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1918 within_current_scope = (fr != NULL);
1919 if (within_current_scope)
1920 /* If we end up stopping, the current frame will get selected
1921 in normal_stop. So this call to select_frame won't affect
1923 select_frame (fr, -1);
1926 if (within_current_scope)
1928 /* We use value_{,free_to_}mark because it could be a
1929 *long* time before we return to the command level and
1930 call free_all_values. We can't call free_all_values because
1931 we might be in the middle of evaluating a function call. */
1933 value_ptr mark = value_mark ();
1934 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1935 if (!value_equal (b->val, new_val))
1937 release_value (new_val);
1938 value_free_to_mark (mark);
1939 bs->old_val = b->val;
1941 /* We will stop here */
1942 return WP_VALUE_CHANGED;
1946 /* Nothing changed, don't do anything. */
1947 value_free_to_mark (mark);
1948 /* We won't stop here */
1949 return WP_VALUE_NOT_CHANGED;
1954 /* This seems like the only logical thing to do because
1955 if we temporarily ignored the watchpoint, then when
1956 we reenter the block in which it is valid it contains
1957 garbage (in the case of a function, it may have two
1958 garbage values, one before and one after the prologue).
1959 So we can't even detect the first assignment to it and
1960 watch after that (since the garbage may or may not equal
1961 the first value assigned). */
1963 Watchpoint %d deleted because the program has left the block in\n\
1964 which its expression is valid.\n", bs->breakpoint_at->number);
1965 if (b->related_breakpoint)
1966 b->related_breakpoint->disposition = del_at_next_stop;
1967 b->disposition = del_at_next_stop;
1973 /* This is used when everything which needs to be printed has
1974 already been printed. But we still want to print the frame. */
1976 /* Background: When we stop, bpstat_print() is called.
1977 It loops through the bpstat list of things causing this stop,
1978 calling the print_it function for each one. The default
1979 print_it function, used for breakpoints, is print_it_normal().
1980 Also see print_it_noop() and print_it_done() are the other
1981 two possibilities. See comments in bpstat_print() and
1982 in header of print_it_normal() for more detail. */
1991 /* This is used when nothing should be printed for this bpstat entry. */
1992 /* Background: When we stop, bpstat_print() is called.
1993 It loops through the bpstat list of things causing this stop,
1994 calling the print_it function for each one. The default
1995 print_it function, used for breakpoints, is print_it_normal().
1996 Also see print_it_noop() and print_it_done() are the other
1997 two possibilities. See comments in bpstat_print() and
1998 in header of print_it_normal() for more detail. */
2007 /* Get a bpstat associated with having just stopped at address *PC
2008 and frame address CORE_ADDRESS. Update *PC to point at the
2009 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
2010 if this is known to not be a real breakpoint (it could still be a
2011 watchpoint, though). */
2013 /* Determine whether we stopped at a breakpoint, etc, or whether we
2014 don't understand this stop. Result is a chain of bpstat's such that:
2016 if we don't understand the stop, the result is a null pointer.
2018 if we understand why we stopped, the result is not null.
2020 Each element of the chain refers to a particular breakpoint or
2021 watchpoint at which we have stopped. (We may have stopped for
2022 several reasons concurrently.)
2024 Each element of the chain has valid next, breakpoint_at,
2025 commands, FIXME??? fields. */
2028 bpstat_stop_status (pc, not_a_breakpoint)
2030 int not_a_breakpoint;
2032 register struct breakpoint *b, *temp;
2034 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
2035 int real_breakpoint = 0;
2036 /* Root of the chain of bpstat's */
2037 struct bpstats root_bs[1];
2038 /* Pointer to the last thing in the chain currently. */
2039 bpstat bs = root_bs;
2040 static char message1[] =
2041 "Error evaluating expression for watchpoint %d\n";
2042 char message[sizeof (message1) + 30 /* slop */];
2044 /* Get the address where the breakpoint would have been. */
2045 bp_addr = *pc - DECR_PC_AFTER_BREAK;
2047 ALL_BREAKPOINTS_SAFE (b, temp)
2049 if (b->enable == disabled
2050 || b->enable == shlib_disabled
2051 || b->enable == call_disabled)
2054 if (b->type != bp_watchpoint
2055 && b->type != bp_hardware_watchpoint
2056 && b->type != bp_read_watchpoint
2057 && b->type != bp_access_watchpoint
2058 && b->type != bp_hardware_breakpoint
2059 && b->type != bp_catch_fork
2060 && b->type != bp_catch_vfork
2061 && b->type != bp_catch_exec
2062 && b->type != bp_catch_catch
2063 && b->type != bp_catch_throw) /* a non-watchpoint bp */
2064 if (b->address != bp_addr || /* address doesn't match or */
2065 (overlay_debugging && /* overlay doesn't match */
2066 section_is_overlay (b->section) &&
2067 !section_is_mapped (b->section)))
2070 if (b->type == bp_hardware_breakpoint
2071 && b->address != (*pc - DECR_PC_AFTER_HW_BREAK))
2074 if (b->type != bp_watchpoint
2075 && b->type != bp_hardware_watchpoint
2076 && b->type != bp_read_watchpoint
2077 && b->type != bp_access_watchpoint
2078 && not_a_breakpoint)
2081 /* Is this a catchpoint of a load or unload? If so, did we
2082 get a load or unload of the specified library? If not,
2084 if ((b->type == bp_catch_load)
2085 #if defined(SOLIB_HAVE_LOAD_EVENT)
2086 && (!SOLIB_HAVE_LOAD_EVENT(inferior_pid)
2087 || ((b->dll_pathname != NULL)
2088 && (strcmp (b->dll_pathname, SOLIB_LOADED_LIBRARY_PATHNAME(inferior_pid)) != 0)))
2093 if ((b->type == bp_catch_unload)
2094 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2095 && (!SOLIB_HAVE_UNLOAD_EVENT(inferior_pid)
2096 || ((b->dll_pathname != NULL)
2097 && (strcmp (b->dll_pathname, SOLIB_UNLOADED_LIBRARY_PATHNAME(inferior_pid)) != 0)))
2102 if ((b->type == bp_catch_fork)
2103 && ! target_has_forked (inferior_pid, &b->forked_inferior_pid))
2106 if ((b->type == bp_catch_vfork)
2107 && ! target_has_vforked (inferior_pid, &b->forked_inferior_pid))
2110 if ((b->type == bp_catch_exec)
2111 && ! target_has_execd (inferior_pid, &b->exec_pathname))
2114 if (ep_is_exception_catchpoint (b) &&
2115 !(current_exception_event = target_get_current_exception_event ()))
2118 /* Come here if it's a watchpoint, or if the break address matches */
2120 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
2122 /* Watchpoints may change this, if not found to have triggered. */
2126 sprintf (message, message1, b->number);
2127 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
2129 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2132 /* We've already printed what needs to be printed. */
2133 bs->print_it = print_it_done;
2136 case WP_VALUE_CHANGED:
2140 case WP_VALUE_NOT_CHANGED:
2142 bs->print_it = print_it_noop;
2144 /* Don't consider this a hit. */
2151 /* Error from catch_errors. */
2152 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2153 if (b->related_breakpoint)
2154 b->related_breakpoint->disposition = del_at_next_stop;
2155 b->disposition = del_at_next_stop;
2156 /* We've already printed what needs to be printed. */
2157 bs->print_it = print_it_done;
2163 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
2169 addr = target_stopped_data_address();
2170 if (addr == 0) continue;
2171 for (v = b->val_chain; v; v = v->next)
2173 if (v->lval == lval_memory)
2177 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
2183 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2186 /* We've already printed what needs to be printed. */
2187 bs->print_it = print_it_done;
2190 case WP_VALUE_CHANGED:
2191 case WP_VALUE_NOT_CHANGED:
2198 /* Error from catch_errors. */
2199 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2200 if (b->related_breakpoint)
2201 b->related_breakpoint->disposition = del_at_next_stop;
2202 b->disposition = del_at_next_stop;
2203 /* We've already printed what needs to be printed. */
2204 bs->print_it = print_it_done;
2210 /* By definition, an encountered breakpoint is a triggered
2214 real_breakpoint = 1;
2217 if (b->frame && b->frame != (get_current_frame ())->frame &&
2218 (b->type == bp_step_resume &&
2219 (INNER_THAN (get_current_frame ()->frame, b->frame))))
2223 int value_is_zero = 0;
2227 /* Need to select the frame, with all that implies
2228 so that the conditions will have the right context. */
2229 select_frame (get_current_frame (), 0);
2231 = catch_errors (breakpoint_cond_eval, (b->cond),
2232 "Error in testing breakpoint condition:\n",
2234 /* FIXME-someday, should give breakpoint # */
2237 if (b->cond && value_is_zero)
2240 /* Don't consider this a hit. */
2243 else if (b->ignore_count > 0)
2250 /* We will stop here */
2251 if (b->disposition == disable)
2252 b->enable = disabled;
2253 bs->commands = b->commands;
2257 (STREQ ("silent", bs->commands->line) ||
2258 (xdb_commands && STREQ ("Q", bs->commands->line))))
2260 bs->commands = bs->commands->next;
2265 /* Print nothing for this entry if we dont stop or if we dont print. */
2266 if (bs->stop == 0 || bs->print == 0)
2267 bs->print_it = print_it_noop;
2270 bs->next = NULL; /* Terminate the chain */
2271 bs = root_bs->next; /* Re-grab the head of the chain */
2273 if (real_breakpoint && bs)
2275 if (bs->breakpoint_at->type == bp_hardware_breakpoint)
2277 if (DECR_PC_AFTER_HW_BREAK != 0)
2279 *pc = *pc - DECR_PC_AFTER_HW_BREAK;
2285 if (DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs)
2288 #if defined (SHIFT_INST_REGS)
2290 #else /* No SHIFT_INST_REGS. */
2292 #endif /* No SHIFT_INST_REGS. */
2297 /* The value of a hardware watchpoint hasn't changed, but the
2298 intermediate memory locations we are watching may have. */
2299 if (bs && ! bs->stop &&
2300 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
2301 bs->breakpoint_at->type == bp_read_watchpoint ||
2302 bs->breakpoint_at->type == bp_access_watchpoint))
2304 remove_breakpoints ();
2305 insert_breakpoints ();
2310 /* Tell what to do about this bpstat. */
2315 /* Classify each bpstat as one of the following. */
2317 /* This bpstat element has no effect on the main_action. */
2320 /* There was a watchpoint, stop but don't print. */
2323 /* There was a watchpoint, stop and print. */
2326 /* There was a breakpoint but we're not stopping. */
2329 /* There was a breakpoint, stop but don't print. */
2332 /* There was a breakpoint, stop and print. */
2335 /* We hit the longjmp breakpoint. */
2338 /* We hit the longjmp_resume breakpoint. */
2341 /* We hit the step_resume breakpoint. */
2344 /* We hit the through_sigtramp breakpoint. */
2347 /* We hit the shared library event breakpoint. */
2350 /* We caught a shared library event. */
2353 /* This is just used to count how many enums there are. */
2357 /* Here is the table which drives this routine. So that we can
2358 format it pretty, we define some abbreviations for the
2359 enum bpstat_what codes. */
2360 #define kc BPSTAT_WHAT_KEEP_CHECKING
2361 #define ss BPSTAT_WHAT_STOP_SILENT
2362 #define sn BPSTAT_WHAT_STOP_NOISY
2363 #define sgl BPSTAT_WHAT_SINGLE
2364 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2365 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2366 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2367 #define sr BPSTAT_WHAT_STEP_RESUME
2368 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2369 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2370 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2372 /* "Can't happen." Might want to print an error message.
2373 abort() is not out of the question, but chances are GDB is just
2374 a bit confused, not unusable. */
2375 #define err BPSTAT_WHAT_STOP_NOISY
2377 /* Given an old action and a class, come up with a new action. */
2378 /* One interesting property of this table is that wp_silent is the same
2379 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2380 after stopping, the check for whether to step over a breakpoint
2381 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2382 reference to how we stopped. We retain separate wp_silent and bp_silent
2383 codes in case we want to change that someday. */
2385 /* step_resume entries: a step resume breakpoint overrides another
2386 breakpoint of signal handling (see comment in wait_for_inferior
2387 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2388 /* We handle the through_sigtramp_breakpoint the same way; having both
2389 one of those and a step_resume_breakpoint is probably very rare (?). */
2391 static const enum bpstat_what_main_action
2392 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
2395 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2397 /*no_effect*/ {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl, shlr},
2398 /*wp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2399 /*wp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2400 /*bp_nostop*/ {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl, shlr},
2401 /*bp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2402 /*bp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2403 /*long_jump*/ {slr, ss, sn, slr, err, err, err, sr, ts, shl, shlr},
2404 /*long_resume*/ {clr, ss, sn, clrs, err, err, err, sr, ts, shl, shlr},
2405 /*step_resume*/ {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl, shlr},
2406 /*through_sig*/ {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl, shlr},
2407 /*shlib*/ {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl, shlr},
2408 /*catch_shlib*/ {shlr, shlr, shlr, shlr, shlr, shlr, shlr, shlr, ts, shlr, shlr}
2423 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
2424 struct bpstat_what retval;
2426 retval.call_dummy = 0;
2427 for (; bs != NULL; bs = bs->next)
2429 enum class bs_class = no_effect;
2430 if (bs->breakpoint_at == NULL)
2431 /* I suspect this can happen if it was a momentary breakpoint
2432 which has since been deleted. */
2434 switch (bs->breakpoint_at->type)
2440 case bp_hardware_breakpoint:
2446 bs_class = bp_noisy;
2448 bs_class = bp_silent;
2451 bs_class = bp_nostop;
2454 case bp_hardware_watchpoint:
2455 case bp_read_watchpoint:
2456 case bp_access_watchpoint:
2460 bs_class = wp_noisy;
2462 bs_class = wp_silent;
2465 /* There was a watchpoint, but we're not stopping. This requires
2466 no further action. */
2467 bs_class = no_effect;
2470 bs_class = long_jump;
2472 case bp_longjmp_resume:
2473 bs_class = long_resume;
2475 case bp_step_resume:
2478 bs_class = step_resume;
2481 /* It is for the wrong frame. */
2482 bs_class = bp_nostop;
2484 case bp_through_sigtramp:
2485 bs_class = through_sig;
2487 case bp_watchpoint_scope:
2488 bs_class = bp_nostop;
2490 case bp_shlib_event:
2491 bs_class = shlib_event;
2494 case bp_catch_unload:
2495 /* Only if this catchpoint triggered should we cause the
2496 step-out-of-dld behaviour. Otherwise, we ignore this
2499 bs_class = catch_shlib_event;
2501 bs_class = no_effect;
2504 case bp_catch_vfork:
2509 bs_class = bp_noisy;
2511 bs_class = bp_silent;
2514 /* There was a catchpoint, but we're not stopping. This requires
2515 no further action. */
2516 bs_class = no_effect;
2518 case bp_catch_catch:
2519 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_CATCH)
2520 bs_class = bp_nostop;
2522 bs_class = bs->print ? bp_noisy : bp_silent;
2524 case bp_catch_throw:
2525 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_THROW)
2526 bs_class = bp_nostop;
2528 bs_class = bs->print ? bp_noisy : bp_silent;
2531 /* Make sure the action is stop (silent or noisy), so infrun.c
2532 pops the dummy frame. */
2533 bs_class = bp_silent;
2534 retval.call_dummy = 1;
2537 current_action = table[(int)bs_class][(int)current_action];
2539 retval.main_action = current_action;
2543 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2544 without hardware support). This isn't related to a specific bpstat,
2545 just to things like whether watchpoints are set. */
2548 bpstat_should_step ()
2550 struct breakpoint *b;
2552 if (b->enable == enabled && b->type == bp_watchpoint)
2557 /* Nonzero if there are enabled hardware watchpoints. */
2559 bpstat_have_active_hw_watchpoints ()
2561 struct breakpoint *b;
2563 if ((b->enable == enabled) &&
2565 ((b->type == bp_hardware_watchpoint) ||
2566 (b->type == bp_read_watchpoint) ||
2567 (b->type == bp_access_watchpoint)))
2573 /* Given a bpstat that records zero or more triggered eventpoints, this
2574 function returns another bpstat which contains only the catchpoints
2575 on that first list, if any. */
2577 bpstat_get_triggered_catchpoints (ep_list, cp_list)
2581 struct bpstats root_bs[1];
2582 bpstat bs = root_bs;
2583 struct breakpoint * ep;
2584 char * dll_pathname;
2586 bpstat_clear (cp_list);
2587 root_bs->next = NULL;
2589 for (; ep_list != NULL; ep_list = ep_list->next )
2591 /* Is this eventpoint a catchpoint? If not, ignore it. */
2592 ep = ep_list->breakpoint_at;
2595 if ((ep->type != bp_catch_load) &&
2596 (ep->type != bp_catch_unload) &&
2597 (ep->type != bp_catch_catch) &&
2598 (ep->type != bp_catch_throw)) /* pai: (temp) ADD fork/vfork here!! */
2601 /* Yes; add it to the list. */
2602 bs = bpstat_alloc (ep, bs);
2607 #if defined(SOLIB_ADD)
2608 /* Also, for each triggered catchpoint, tag it with the name of
2609 the library that caused this trigger. (We copy the name now,
2610 because it's only guaranteed to be available NOW, when the
2611 catchpoint triggers. Clients who may wish to know the name
2612 later must get it from the catchpoint itself.) */
2613 if (ep->triggered_dll_pathname != NULL)
2614 free (ep->triggered_dll_pathname);
2615 if (ep->type == bp_catch_load)
2616 dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
2618 dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid);
2620 dll_pathname = NULL;
2624 ep->triggered_dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
2625 strcpy (ep->triggered_dll_pathname, dll_pathname);
2628 ep->triggered_dll_pathname = NULL;
2634 /* Print information on breakpoint number BNUM, or -1 if all.
2635 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2636 is nonzero, process only watchpoints. */
2641 } ep_type_description_t;
2644 breakpoint_1 (bnum, allflag)
2648 register struct breakpoint *b;
2649 register struct command_line *l;
2650 register struct symbol *sym;
2651 CORE_ADDR last_addr = (CORE_ADDR)-1;
2652 int found_a_breakpoint = 0;
2653 static ep_type_description_t bptypes[] =
2655 {bp_none, "?deleted?"},
2656 {bp_breakpoint, "breakpoint"},
2657 {bp_hardware_breakpoint, "hw breakpoint"},
2658 {bp_until, "until"},
2659 {bp_finish, "finish"},
2660 {bp_watchpoint, "watchpoint"},
2661 {bp_hardware_watchpoint, "hw watchpoint"},
2662 {bp_read_watchpoint, "read watchpoint"},
2663 {bp_access_watchpoint, "acc watchpoint"},
2664 {bp_longjmp, "longjmp"},
2665 {bp_longjmp_resume, "longjmp resume"},
2666 {bp_step_resume, "step resume"},
2667 {bp_through_sigtramp, "sigtramp"},
2668 {bp_watchpoint_scope, "watchpoint scope"},
2669 {bp_call_dummy, "call dummy"},
2670 {bp_shlib_event, "shlib events"},
2671 {bp_catch_load, "catch load"},
2672 {bp_catch_unload, "catch unload"},
2673 {bp_catch_fork, "catch fork"},
2674 {bp_catch_vfork, "catch vfork"},
2675 {bp_catch_exec, "catch exec"},
2676 {bp_catch_catch, "catch catch"},
2677 {bp_catch_throw, "catch throw"}
2680 static char *bpdisps[] = {"del", "dstp", "dis", "keep"};
2681 static char bpenables[] = "nyn";
2682 char wrap_indent[80];
2686 || bnum == b->number)
2688 /* We only print out user settable breakpoints unless the allflag is set. */
2690 && b->type != bp_breakpoint
2691 && b->type != bp_catch_load
2692 && b->type != bp_catch_unload
2693 && b->type != bp_catch_fork
2694 && b->type != bp_catch_vfork
2695 && b->type != bp_catch_exec
2696 && b->type != bp_catch_catch
2697 && b->type != bp_catch_throw
2698 && b->type != bp_hardware_breakpoint
2699 && b->type != bp_watchpoint
2700 && b->type != bp_read_watchpoint
2701 && b->type != bp_access_watchpoint
2702 && b->type != bp_hardware_watchpoint)
2705 if (!found_a_breakpoint++)
2707 annotate_breakpoints_headers ();
2710 printf_filtered ("Num ");
2712 printf_filtered ("Type ");
2714 printf_filtered ("Disp ");
2716 printf_filtered ("Enb ");
2720 printf_filtered ("Address ");
2723 printf_filtered ("What\n");
2725 annotate_breakpoints_table ();
2730 printf_filtered ("%-3d ", b->number);
2732 if ((int)b->type > (sizeof(bptypes)/sizeof(bptypes[0])))
2733 error ("bptypes table does not describe type #%d.", (int)b->type);
2734 if ((int)b->type != bptypes[(int)b->type].type)
2735 error ("bptypes table does not describe type #%d?", (int)b->type);
2736 printf_filtered ("%-14s ", bptypes[(int)b->type].description);
2738 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
2740 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
2742 strcpy (wrap_indent, " ");
2744 strcat (wrap_indent, " ");
2748 case bp_hardware_watchpoint:
2749 case bp_read_watchpoint:
2750 case bp_access_watchpoint:
2751 /* Field 4, the address, is omitted (which makes the columns
2752 not line up too nicely with the headers, but the effect
2753 is relatively readable). */
2755 print_expression (b->exp, gdb_stdout);
2759 case bp_catch_unload:
2760 /* Field 4, the address, is omitted (which makes the columns
2761 not line up too nicely with the headers, but the effect
2762 is relatively readable). */
2764 if (b->dll_pathname == NULL)
2765 printf_filtered ("<any library> ");
2767 printf_filtered ("library \"%s\" ", b->dll_pathname);
2771 case bp_catch_vfork:
2772 /* Field 4, the address, is omitted (which makes the columns
2773 not line up too nicely with the headers, but the effect
2774 is relatively readable). */
2776 if (b->forked_inferior_pid != 0)
2777 printf_filtered ("process %d ", b->forked_inferior_pid);
2781 /* Field 4, the address, is omitted (which makes the columns
2782 not line up too nicely with the headers, but the effect
2783 is relatively readable). */
2785 if (b->exec_pathname != NULL)
2786 printf_filtered ("program \"%s\" ", b->exec_pathname);
2788 case bp_catch_catch:
2789 /* Field 4, the address, is omitted (which makes the columns
2790 not line up too nicely with the headers, but the effect
2791 is relatively readable). */
2793 printf_filtered ("exception catch ");
2795 case bp_catch_throw:
2796 /* Field 4, the address, is omitted (which makes the columns
2797 not line up too nicely with the headers, but the effect
2798 is relatively readable). */
2800 printf_filtered ("exception throw ");
2804 case bp_hardware_breakpoint:
2808 case bp_longjmp_resume:
2809 case bp_step_resume:
2810 case bp_through_sigtramp:
2811 case bp_watchpoint_scope:
2813 case bp_shlib_event:
2817 /* FIXME-32x64: need a print_address_numeric with
2821 local_hex_string_custom
2822 ((unsigned long) b->address, "08l"));
2827 last_addr = b->address;
2830 sym = find_pc_sect_function (b->address, b->section);
2833 fputs_filtered ("in ", gdb_stdout);
2834 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
2835 wrap_here (wrap_indent);
2836 fputs_filtered (" at ", gdb_stdout);
2838 fputs_filtered (b->source_file, gdb_stdout);
2839 printf_filtered (":%d", b->line_number);
2842 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
2846 if (b->thread != -1)
2847 printf_filtered (" thread %d", b->thread );
2849 printf_filtered ("\n");
2855 printf_filtered ("\tstop only in stack frame at ");
2856 print_address_numeric (b->frame, 1, gdb_stdout);
2857 printf_filtered ("\n");
2864 printf_filtered ("\tstop only if ");
2865 print_expression (b->cond, gdb_stdout);
2866 printf_filtered ("\n");
2869 if (b->thread != -1)
2871 /* FIXME should make an annotation for this */
2872 printf_filtered ("\tstop only in thread %d\n", b->thread);
2875 if (show_breakpoint_hit_counts && b->hit_count)
2877 /* FIXME should make an annotation for this */
2878 if (ep_is_catchpoint (b))
2879 printf_filtered ("\tcatchpoint");
2881 printf_filtered ("\tbreakpoint");
2882 printf_filtered (" already hit %d time%s\n",
2883 b->hit_count, (b->hit_count == 1 ? "" : "s"));
2886 if (b->ignore_count)
2890 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
2893 if ((l = b->commands))
2899 print_command_line (l, 4);
2905 if (!found_a_breakpoint)
2908 printf_filtered ("No breakpoints or watchpoints.\n");
2910 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
2913 /* Compare against (CORE_ADDR)-1 in case some compiler decides
2914 that a comparison of an unsigned with -1 is always false. */
2915 if (last_addr != (CORE_ADDR)-1)
2916 set_next_address (last_addr);
2918 annotate_breakpoints_table_end ();
2923 breakpoints_info (bnum_exp, from_tty)
2930 bnum = parse_and_eval_address (bnum_exp);
2932 breakpoint_1 (bnum, 0);
2935 #if MAINTENANCE_CMDS
2939 maintenance_info_breakpoints (bnum_exp, from_tty)
2946 bnum = parse_and_eval_address (bnum_exp);
2948 breakpoint_1 (bnum, 1);
2953 /* Print a message describing any breakpoints set at PC. */
2956 describe_other_breakpoints (pc, section)
2960 register int others = 0;
2961 register struct breakpoint *b;
2964 if (b->address == pc)
2965 if (overlay_debugging == 0 ||
2966 b->section == section)
2970 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
2972 if (b->address == pc)
2973 if (overlay_debugging == 0 ||
2974 b->section == section)
2980 ((b->enable == disabled || b->enable == shlib_disabled || b->enable == call_disabled)
2981 ? " (disabled)" : ""),
2982 (others > 1) ? "," : ((others == 1) ? " and" : ""));
2984 printf_filtered ("also set at pc ");
2985 print_address_numeric (pc, 1, gdb_stdout);
2986 printf_filtered (".\n");
2990 /* Set the default place to put a breakpoint
2991 for the `break' command with no arguments. */
2994 set_default_breakpoint (valid, addr, symtab, line)
2997 struct symtab *symtab;
3000 default_breakpoint_valid = valid;
3001 default_breakpoint_address = addr;
3002 default_breakpoint_symtab = symtab;
3003 default_breakpoint_line = line;
3006 /* Rescan breakpoints at address ADDRESS,
3007 marking the first one as "first" and any others as "duplicates".
3008 This is so that the bpt instruction is only inserted once. */
3011 check_duplicates (address, section)
3015 register struct breakpoint *b;
3016 register int count = 0;
3018 if (address == 0) /* Watchpoints are uninteresting */
3022 if (b->enable != disabled
3023 && b->enable != shlib_disabled
3024 && b->enable != call_disabled
3025 && b->address == address
3026 && (overlay_debugging == 0 || b->section == section))
3029 b->duplicate = count > 1;
3033 /* Low level routine to set a breakpoint.
3034 Takes as args the three things that every breakpoint must have.
3035 Returns the breakpoint object so caller can set other things.
3036 Does not set the breakpoint number!
3037 Does not print anything.
3039 ==> This routine should not be called if there is a chance of later
3040 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
3041 your arguments BEFORE calling this routine! */
3044 set_raw_breakpoint (sal)
3045 struct symtab_and_line sal;
3047 register struct breakpoint *b, *b1;
3049 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
3050 memset (b, 0, sizeof (*b));
3051 b->address = sal.pc;
3052 if (sal.symtab == NULL)
3053 b->source_file = NULL;
3055 b->source_file = savestring (sal.symtab->filename,
3056 strlen (sal.symtab->filename));
3057 b->section = sal.section;
3058 b->language = current_language->la_language;
3059 b->input_radix = input_radix;
3061 b->line_number = sal.line;
3062 b->enable = enabled;
3065 b->ignore_count = 0;
3068 b->dll_pathname = NULL;
3069 b->triggered_dll_pathname = NULL;
3070 b->forked_inferior_pid = 0;
3071 b->exec_pathname = NULL;
3073 /* Add this breakpoint to the end of the chain
3074 so that a list of breakpoints will come out in order
3075 of increasing numbers. */
3077 b1 = breakpoint_chain;
3079 breakpoint_chain = b;
3087 check_duplicates (sal.pc, sal.section);
3088 breakpoints_changed ();
3093 #ifdef GET_LONGJMP_TARGET
3096 create_longjmp_breakpoint (func_name)
3099 struct symtab_and_line sal;
3100 struct breakpoint *b;
3102 INIT_SAL (&sal); /* initialize to zeroes */
3103 if (func_name != NULL)
3105 struct minimal_symbol *m;
3107 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
3109 sal.pc = SYMBOL_VALUE_ADDRESS (m);
3113 sal.section = find_pc_overlay (sal.pc);
3114 b = set_raw_breakpoint (sal);
3117 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
3118 b->disposition = donttouch;
3119 b->enable = disabled;
3122 b->addr_string = strsave(func_name);
3123 b->number = internal_breakpoint_number--;
3126 #endif /* #ifdef GET_LONGJMP_TARGET */
3128 /* Call this routine when stepping and nexting to enable a breakpoint if we do
3129 a longjmp(). When we hit that breakpoint, call
3130 set_longjmp_resume_breakpoint() to figure out where we are going. */
3133 enable_longjmp_breakpoint()
3135 register struct breakpoint *b;
3138 if (b->type == bp_longjmp)
3140 b->enable = enabled;
3141 check_duplicates (b->address, b->section);
3146 disable_longjmp_breakpoint()
3148 register struct breakpoint *b;
3151 if ( b->type == bp_longjmp
3152 || b->type == bp_longjmp_resume)
3154 b->enable = disabled;
3155 check_duplicates (b->address, b->section);
3161 remove_solib_event_breakpoints ()
3163 register struct breakpoint *b, *temp;
3165 ALL_BREAKPOINTS_SAFE (b, temp)
3166 if (b->type == bp_shlib_event)
3167 delete_breakpoint (b);
3171 create_solib_event_breakpoint (address)
3174 struct breakpoint *b;
3175 struct symtab_and_line sal;
3177 INIT_SAL (&sal); /* initialize to zeroes */
3179 sal.section = find_pc_overlay (sal.pc);
3180 b = set_raw_breakpoint (sal);
3181 b->number = internal_breakpoint_number--;
3182 b->disposition = donttouch;
3183 b->type = bp_shlib_event;
3187 disable_breakpoints_in_shlibs (silent)
3190 struct breakpoint * b;
3191 int disabled_shlib_breaks = 0;
3193 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3196 #if defined (PC_SOLIB)
3197 if (((b->type == bp_breakpoint) ||
3198 (b->type == bp_hardware_breakpoint)) &&
3199 (b->enable != shlib_disabled) &&
3200 (b->enable != call_disabled) &&
3202 PC_SOLIB (b->address))
3204 b->enable = shlib_disabled;
3207 if (!disabled_shlib_breaks)
3209 target_terminal_ours_for_output ();
3210 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
3212 disabled_shlib_breaks = 1;
3213 printf_filtered ("%d ", b->number);
3218 if (disabled_shlib_breaks && !silent)
3219 printf_filtered ("\n");
3222 /* Try to reenable any breakpoints in shared libraries. */
3224 re_enable_breakpoints_in_shlibs ()
3226 struct breakpoint *b;
3229 if (b->enable == shlib_disabled)
3233 /* Do not reenable the breakpoint if the shared library
3234 is still not mapped in. */
3235 if (target_read_memory (b->address, buf, 1) == 0)
3236 b->enable = enabled;
3243 create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string, bp_kind)
3246 char * dll_pathname;
3248 enum bptype bp_kind;
3250 struct breakpoint * b;
3251 struct symtabs_and_lines sals;
3252 struct symtab_and_line sal;
3253 struct cleanup * old_chain;
3254 struct cleanup * canonical_strings_chain = NULL;
3256 char * addr_start = hookname;
3257 char * addr_end = NULL;
3258 char ** canonical = (char **) NULL;
3259 int thread = -1; /* All threads. */
3261 /* Set a breakpoint on the specified hook. */
3262 sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical);
3263 addr_end = hookname;
3265 if (sals.nelts == 0)
3267 warning ("Unable to set a breakpoint on dynamic linker callback.");
3268 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3269 warning ("GDB will be unable to track shl_load/shl_unload calls");
3272 if (sals.nelts != 1)
3274 warning ("Unable to set a unique breakpoint on dynamic linker callback.");
3275 warning ("GDB will be unable to track shl_load/shl_unload calls");
3279 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3280 the following errors out. */
3281 old_chain = make_cleanup (free, sals.sals);
3282 if (canonical != (char **)NULL)
3284 make_cleanup (free, canonical);
3285 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3286 if (canonical[0] != NULL)
3287 make_cleanup (free, canonical[0]);
3290 resolve_sal_pc (&sals.sals[0]);
3292 /* Remove the canonical strings from the cleanup, they are needed below. */
3293 if (canonical != (char **)NULL)
3294 discard_cleanups (canonical_strings_chain);
3296 b = set_raw_breakpoint (sals.sals[0]);
3297 set_breakpoint_count (breakpoint_count + 1);
3298 b->number = breakpoint_count;
3300 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3303 if (canonical != (char **)NULL && canonical[0] != NULL)
3304 b->addr_string = canonical[0];
3305 else if (addr_start)
3306 b->addr_string = savestring (addr_start, addr_end - addr_start);
3308 b->enable = enabled;
3309 b->disposition = tempflag ? del : donttouch;
3311 if (dll_pathname == NULL)
3312 b->dll_pathname = NULL;
3315 b->dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
3316 strcpy (b->dll_pathname, dll_pathname);
3321 do_cleanups (old_chain);
3325 create_solib_load_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3328 char * dll_pathname;
3331 create_solib_load_unload_event_breakpoint (hookname,
3339 create_solib_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3342 char * dll_pathname;
3345 create_solib_load_unload_event_breakpoint (hookname,
3353 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_kind)
3356 enum bptype bp_kind;
3358 struct symtab_and_line sal;
3359 struct breakpoint * b;
3360 int thread = -1; /* All threads. */
3367 b = set_raw_breakpoint (sal);
3368 set_breakpoint_count (breakpoint_count + 1);
3369 b->number = breakpoint_count;
3371 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3373 b->addr_string = NULL;
3374 b->enable = enabled;
3375 b->disposition = tempflag ? del : donttouch;
3376 b->forked_inferior_pid = 0;
3384 create_fork_event_catchpoint (tempflag, cond_string)
3388 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_fork);
3392 create_vfork_event_catchpoint (tempflag, cond_string)
3396 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_vfork);
3400 create_exec_event_catchpoint (tempflag, cond_string)
3404 struct symtab_and_line sal;
3405 struct breakpoint * b;
3406 int thread = -1; /* All threads. */
3413 b = set_raw_breakpoint (sal);
3414 set_breakpoint_count (breakpoint_count + 1);
3415 b->number = breakpoint_count;
3417 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3419 b->addr_string = NULL;
3420 b->enable = enabled;
3421 b->disposition = tempflag ? del : donttouch;
3423 b->type = bp_catch_exec;
3429 hw_breakpoint_used_count()
3431 register struct breakpoint *b;
3436 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
3444 hw_watchpoint_used_count(type, other_type_used)
3446 int *other_type_used;
3448 register struct breakpoint *b;
3451 *other_type_used = 0;
3454 if (b->enable == enabled)
3456 if (b->type == type) i++;
3457 else if ((b->type == bp_hardware_watchpoint ||
3458 b->type == bp_read_watchpoint ||
3459 b->type == bp_access_watchpoint)
3460 && b->enable == enabled)
3461 *other_type_used = 1;
3467 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
3468 breakpoint at the target of the jmp_buf.
3470 FIXME - This ought to be done by setting a temporary breakpoint that gets
3471 deleted automatically... */
3474 set_longjmp_resume_breakpoint(pc, frame)
3476 struct frame_info *frame;
3478 register struct breakpoint *b;
3481 if (b->type == bp_longjmp_resume)
3484 b->enable = enabled;
3486 b->frame = frame->frame;
3489 check_duplicates (b->address, b->section);
3495 disable_watchpoints_before_interactive_call_start ()
3497 struct breakpoint * b;
3501 if (((b->type == bp_watchpoint)
3502 || (b->type == bp_hardware_watchpoint)
3503 || (b->type == bp_read_watchpoint)
3504 || (b->type == bp_access_watchpoint)
3505 || ep_is_exception_catchpoint (b))
3506 && (b->enable == enabled))
3508 b->enable = call_disabled;
3509 check_duplicates (b->address, b->section);
3515 enable_watchpoints_after_interactive_call_stop ()
3517 struct breakpoint * b;
3521 if (((b->type == bp_watchpoint)
3522 || (b->type == bp_hardware_watchpoint)
3523 || (b->type == bp_read_watchpoint)
3524 || (b->type == bp_access_watchpoint)
3525 || ep_is_exception_catchpoint (b))
3526 && (b->enable == call_disabled))
3528 b->enable = enabled;
3529 check_duplicates (b->address, b->section);
3535 /* Set a breakpoint that will evaporate an end of command
3536 at address specified by SAL.
3537 Restrict it to frame FRAME if FRAME is nonzero. */
3540 set_momentary_breakpoint (sal, frame, type)
3541 struct symtab_and_line sal;
3542 struct frame_info *frame;
3545 register struct breakpoint *b;
3546 b = set_raw_breakpoint (sal);
3548 b->enable = enabled;
3549 b->disposition = donttouch;
3550 b->frame = (frame ? frame->frame : 0);
3552 /* If we're debugging a multi-threaded program, then we
3553 want momentary breakpoints to be active in only a
3554 single thread of control. */
3555 if (in_thread_list (inferior_pid))
3556 b->thread = pid_to_thread_id (inferior_pid);
3562 /* Tell the user we have just set a breakpoint B. */
3566 struct breakpoint *b;
3570 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3571 watchpoint) other than breakpoint creation. It should be possible to
3572 clean this up and at the same time replace the random calls to
3573 breakpoint_changed with this hook, as has already been done for
3574 delete_breakpoint_hook and so on. */
3575 if (create_breakpoint_hook)
3576 create_breakpoint_hook (b);
3581 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b->number);
3584 printf_filtered ("Watchpoint %d: ", b->number);
3585 print_expression (b->exp, gdb_stdout);
3587 case bp_hardware_watchpoint:
3588 printf_filtered ("Hardware watchpoint %d: ", b->number);
3589 print_expression (b->exp, gdb_stdout);
3591 case bp_read_watchpoint:
3592 printf_filtered ("Hardware read watchpoint %d: ", b->number);
3593 print_expression (b->exp, gdb_stdout);
3595 case bp_access_watchpoint:
3596 printf_filtered ("Hardware access (read/write) watchpoint %d: ",b->number);
3597 print_expression (b->exp, gdb_stdout);
3600 printf_filtered ("Breakpoint %d", b->number);
3603 case bp_hardware_breakpoint:
3604 printf_filtered ("Hardware assisted breakpoint %d", b->number);
3608 case bp_catch_unload:
3609 printf_filtered ("Catchpoint %d (%s %s)",
3611 (b->type == bp_catch_load) ? "load" : "unload",
3612 (b->dll_pathname != NULL) ? b->dll_pathname : "<any library>");
3615 case bp_catch_vfork:
3616 printf_filtered ("Catchpoint %d (%s)",
3618 (b->type == bp_catch_fork) ? "fork" : "vfork");
3621 printf_filtered ("Catchpoint %d (exec)",
3624 case bp_catch_catch:
3625 case bp_catch_throw:
3626 printf_filtered ("Catchpoint %d (%s)",
3628 (b->type == bp_catch_catch) ? "catch" : "throw");
3634 case bp_longjmp_resume:
3635 case bp_step_resume:
3636 case bp_through_sigtramp:
3638 case bp_watchpoint_scope:
3639 case bp_shlib_event:
3644 if (addressprint || b->source_file == NULL)
3646 printf_filtered (" at ");
3647 print_address_numeric (b->address, 1, gdb_stdout);
3650 printf_filtered (": file %s, line %d.",
3651 b->source_file, b->line_number);
3652 TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, b, 1));
3653 TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos));
3655 printf_filtered ("\n");
3659 /* Set a breakpoint according to ARG (function, linenum or *address)
3660 flag: first bit : 0 non-temporary, 1 temporary.
3661 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3664 break_command_1 (arg, flag, from_tty)
3668 int tempflag, hardwareflag;
3669 struct symtabs_and_lines sals;
3670 struct symtab_and_line sal;
3671 register struct expression *cond = 0;
3672 register struct breakpoint *b;
3674 /* Pointers in arg to the start, and one past the end, of the condition. */
3675 char *cond_start = NULL;
3676 char *cond_end = NULL;
3677 /* Pointers in arg to the start, and one past the end,
3678 of the address part. */
3679 char *addr_start = NULL;
3680 char *addr_end = NULL;
3681 struct cleanup *old_chain;
3682 struct cleanup *canonical_strings_chain = NULL;
3683 char **canonical = (char **)NULL;
3687 hardwareflag = flag & BP_HARDWAREFLAG;
3688 tempflag = flag & BP_TEMPFLAG;
3693 INIT_SAL (&sal); /* initialize to zeroes */
3695 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3697 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
3698 && (arg[2] == ' ' || arg[2] == '\t')))
3700 if (default_breakpoint_valid)
3702 sals.sals = (struct symtab_and_line *)
3703 xmalloc (sizeof (struct symtab_and_line));
3704 sal.pc = default_breakpoint_address;
3705 sal.line = default_breakpoint_line;
3706 sal.symtab = default_breakpoint_symtab;
3707 sal.section = find_pc_overlay (sal.pc);
3712 error ("No default breakpoint address now.");
3718 /* Force almost all breakpoints to be in terms of the
3719 current_source_symtab (which is decode_line_1's default). This
3720 should produce the results we want almost all of the time while
3721 leaving default_breakpoint_* alone. */
3722 if (default_breakpoint_valid
3723 && (!current_source_symtab
3724 || (arg && (*arg == '+' || *arg == '-'))))
3725 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
3726 default_breakpoint_line, &canonical);
3728 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
3736 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3737 the following `for' loop errors out. */
3738 old_chain = make_cleanup (free, sals.sals);
3739 if (canonical != (char **)NULL)
3741 make_cleanup (free, canonical);
3742 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3743 for (i = 0; i < sals.nelts; i++)
3745 if (canonical[i] != NULL)
3746 make_cleanup (free, canonical[i]);
3750 thread = -1; /* No specific thread yet */
3752 /* Resolve all line numbers to PC's, and verify that conditions
3753 can be parsed, before setting any breakpoints. */
3754 for (i = 0; i < sals.nelts; i++)
3756 char *tok, *end_tok;
3759 resolve_sal_pc (&sals.sals[i]);
3761 /* It's possible for the PC to be nonzero, but still an illegal
3762 value on some targets.
3764 For example, on HP-UX if you start gdb, and before running the
3765 inferior you try to set a breakpoint on a shared library function
3766 "foo" where the inferior doesn't call "foo" directly but does
3767 pass its address to another function call, then we do find a
3768 minimal symbol for the "foo", but it's address is invalid.
3769 (Appears to be an index into a table that the loader sets up
3770 when the inferior is run.)
3772 Give the target a chance to bless sals.sals[i].pc before we
3773 try to make a breakpoint for it. */
3774 if (PC_REQUIRES_RUN_BEFORE_USE(sals.sals[i].pc))
3776 error ("Cannot break on %s without a running program.", addr_start);
3783 while (*tok == ' ' || *tok == '\t')
3788 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
3791 toklen = end_tok - tok;
3793 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
3795 tok = cond_start = end_tok + 1;
3796 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
3799 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
3805 thread = strtol (tok, &tok, 0);
3807 error ("Junk after thread keyword.");
3808 if (!valid_thread_id (thread))
3809 error ("Unknown thread %d\n", thread);
3812 error ("Junk at end of arguments.");
3817 int i, target_resources_ok;
3819 i = hw_breakpoint_used_count ();
3820 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
3821 bp_hardware_breakpoint, i + sals.nelts, 0);
3822 if (target_resources_ok == 0)
3823 error ("No hardware breakpoint support in the target.");
3824 else if (target_resources_ok < 0)
3825 error ("Hardware breakpoints used exceeds limit.");
3828 /* Remove the canonical strings from the cleanup, they are needed below. */
3829 if (canonical != (char **)NULL)
3830 discard_cleanups (canonical_strings_chain);
3832 /* Now set all the breakpoints. */
3833 for (i = 0; i < sals.nelts; i++)
3838 describe_other_breakpoints (sal.pc, sal.section);
3840 b = set_raw_breakpoint (sal);
3841 set_breakpoint_count (breakpoint_count + 1);
3842 b->number = breakpoint_count;
3843 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
3847 /* If a canonical line spec is needed use that instead of the
3849 if (canonical != (char **)NULL && canonical[i] != NULL)
3850 b->addr_string = canonical[i];
3851 else if (addr_start)
3852 b->addr_string = savestring (addr_start, addr_end - addr_start);
3854 b->cond_string = savestring (cond_start, cond_end - cond_start);
3856 b->enable = enabled;
3857 b->disposition = tempflag ? del : donttouch;
3863 printf_filtered ("Multiple breakpoints were set.\n");
3864 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3866 do_cleanups (old_chain);
3870 break_at_finish_at_depth_command_1 (arg, flag, from_tty)
3875 struct frame_info *frame;
3876 CORE_ADDR low, high, selected_pc = 0;
3877 char *extra_args, *level_arg, *addr_string;
3878 int extra_args_len = 0, if_arg = 0;
3881 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
3884 if (default_breakpoint_valid)
3888 selected_pc = selected_frame->pc;
3893 error ("No selected frame.");
3896 error ("No default breakpoint address now.");
3900 extra_args = strchr (arg, ' ');
3904 extra_args_len = strlen (extra_args);
3905 level_arg = (char *) xmalloc (extra_args - arg);
3906 strncpy (level_arg, arg, extra_args - arg - 1);
3907 level_arg[extra_args - arg - 1] = '\0';
3911 level_arg = (char *) xmalloc (strlen (arg) + 1);
3912 strcpy (level_arg, arg);
3915 frame = parse_frame_specification (level_arg);
3917 selected_pc = frame->pc;
3924 extra_args_len = strlen (arg);
3929 if (find_pc_partial_function(selected_pc, (char **)NULL, &low, &high))
3931 addr_string = (char *) xmalloc (26 + extra_args_len);
3933 sprintf (addr_string, "*0x%x %s", high, extra_args);
3935 sprintf (addr_string, "*0x%x", high);
3936 break_command_1 (addr_string, flag, from_tty);
3940 error ("No function contains the specified address");
3943 error ("Unable to set breakpoint at procedure exit");
3948 break_at_finish_command_1 (arg, flag, from_tty)
3953 char *addr_string, *break_string, *beg_addr_string;
3954 CORE_ADDR low, high;
3955 struct symtabs_and_lines sals;
3956 struct symtab_and_line sal;
3957 struct cleanup *old_chain;
3959 int extra_args_len = 0;
3963 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
3965 if (default_breakpoint_valid)
3969 addr_string = (char *) xmalloc (15);
3970 sprintf (addr_string, "*0x%x", selected_frame->pc);
3975 error ("No selected frame.");
3978 error ("No default breakpoint address now.");
3982 addr_string = (char *) xmalloc (strlen (arg) + 1);
3983 strcpy (addr_string, arg);
3989 extra_args_len = strlen (arg);
3994 /* get the stuff after the function name or address */
3995 extra_args = strchr (arg, ' ');
3999 extra_args_len = strlen (extra_args);
4006 beg_addr_string = addr_string;
4007 sals = decode_line_1 (&addr_string, 1, (struct symtab *)NULL, 0,
4010 free (beg_addr_string);
4011 old_chain = make_cleanup (free, sals.sals);
4012 for (i = 0; (i < sals.nelts); i++)
4015 if (find_pc_partial_function (sal.pc, (char **)NULL, &low, &high))
4017 break_string = (char *) xmalloc (extra_args_len + 26);
4019 sprintf (break_string, "*0x%x %s", high, extra_args);
4021 sprintf (break_string, "*0x%x", high);
4022 break_command_1 (break_string, flag, from_tty);
4026 error ("No function contains the specified address");
4030 printf_filtered ("Multiple breakpoints were set.\n");
4031 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
4033 do_cleanups(old_chain);
4037 /* Helper function for break_command_1 and disassemble_command. */
4040 resolve_sal_pc (sal)
4041 struct symtab_and_line *sal;
4045 if (sal->pc == 0 && sal->symtab != NULL)
4047 if (!find_line_pc (sal->symtab, sal->line, &pc))
4048 error ("No line %d in file \"%s\".",
4049 sal->line, sal->symtab->filename);
4053 if (sal->section == 0 && sal->symtab != NULL)
4055 struct blockvector *bv;
4060 bv = blockvector_for_pc_sect (sal->pc, 0, &index, sal->symtab);
4063 b = BLOCKVECTOR_BLOCK (bv, index);
4064 sym = block_function (b);
4067 fixup_symbol_section (sym, sal->symtab->objfile);
4068 sal->section = SYMBOL_BFD_SECTION (sym);
4072 /* It really is worthwhile to have the section, so we'll just
4073 have to look harder. This case can be executed if we have
4074 line numbers but no functions (as can happen in assembly
4077 struct minimal_symbol *msym;
4079 msym = lookup_minimal_symbol_by_pc (sal->pc);
4081 sal->section = SYMBOL_BFD_SECTION (msym);
4088 break_command (arg, from_tty)
4092 break_command_1 (arg, 0, from_tty);
4096 break_at_finish_command (arg, from_tty)
4100 break_at_finish_command_1 (arg, 0, from_tty);
4104 break_at_finish_at_depth_command (arg, from_tty)
4108 break_at_finish_at_depth_command_1 (arg, 0, from_tty);
4112 tbreak_command (arg, from_tty)
4116 break_command_1 (arg, BP_TEMPFLAG, from_tty);
4120 tbreak_at_finish_command (arg, from_tty)
4124 break_at_finish_command_1 (arg, BP_TEMPFLAG, from_tty);
4128 hbreak_command (arg, from_tty)
4132 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
4136 thbreak_command (arg, from_tty)
4140 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
4144 stop_command (arg, from_tty)
4148 printf_filtered ("Specify the type of breakpoint to set.\n\
4149 Usage: stop in <function | address>\n\
4154 stopin_command (arg, from_tty)
4160 if (arg == (char *)NULL)
4162 else if (*arg != '*')
4167 /* look for a ':'. If this is a line number specification, then say
4168 it is bad, otherwise, it should be an address or function/method
4170 while (*argptr && !hasColon)
4172 hasColon = (*argptr == ':');
4177 badInput = (*argptr != ':'); /* Not a class::method */
4179 badInput = isdigit(*arg); /* a simple line number */
4183 printf_filtered("Usage: stop in <function | address>\n");
4185 break_command_1 (arg, 0, from_tty);
4189 stopat_command (arg, from_tty)
4195 if (arg == (char *)NULL || *arg == '*') /* no line number */
4202 /* look for a ':'. If there is a '::' then get out, otherwise
4203 it is probably a line number. */
4204 while (*argptr && !hasColon)
4206 hasColon = (*argptr == ':');
4211 badInput = (*argptr == ':'); /* we have class::method */
4213 badInput = !isdigit(*arg); /* not a line number */
4217 printf_filtered("Usage: stop at <line>\n");
4219 break_command_1 (arg, 0, from_tty);
4223 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write) */
4225 watch_command_1 (arg, accessflag, from_tty)
4230 struct breakpoint *b;
4231 struct symtab_and_line sal;
4232 struct expression *exp;
4233 struct block *exp_valid_block;
4234 struct value *val, *mark;
4235 struct frame_info *frame;
4236 struct frame_info *prev_frame = NULL;
4237 char *exp_start = NULL;
4238 char *exp_end = NULL;
4239 char *tok, *end_tok;
4241 char *cond_start = NULL;
4242 char *cond_end = NULL;
4243 struct expression *cond = NULL;
4244 int i, other_type_used, target_resources_ok = 0;
4245 enum bptype bp_type;
4248 INIT_SAL (&sal); /* initialize to zeroes */
4250 /* Parse arguments. */
4251 innermost_block = NULL;
4253 exp = parse_exp_1 (&arg, 0, 0);
4255 exp_valid_block = innermost_block;
4256 mark = value_mark ();
4257 val = evaluate_expression (exp);
4258 release_value (val);
4259 if (VALUE_LAZY (val))
4260 value_fetch_lazy (val);
4263 while (*tok == ' ' || *tok == '\t')
4267 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
4270 toklen = end_tok - tok;
4271 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
4273 tok = cond_start = end_tok + 1;
4274 cond = parse_exp_1 (&tok, 0, 0);
4278 error("Junk at end of command.");
4280 if (accessflag == 1) bp_type = bp_read_watchpoint;
4281 else if (accessflag == 2) bp_type = bp_access_watchpoint;
4282 else bp_type = bp_hardware_watchpoint;
4284 mem_cnt = can_use_hardware_watchpoint (val);
4285 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
4286 error ("Expression cannot be implemented with read/access watchpoint.");
4288 i = hw_watchpoint_used_count (bp_type, &other_type_used);
4289 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
4290 bp_type, i + mem_cnt, other_type_used);
4291 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
4292 error ("Target does not have this type of hardware watchpoint support.");
4293 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
4294 error ("Target resources have been allocated for other types of watchpoints.");
4297 #if defined(HPUXHPPA)
4298 /* On HP-UX if you set a h/w
4299 watchpoint before the "run" command, the inferior dies with a e.g.,
4300 SIGILL once you start it. I initially believed this was due to a
4301 bad interaction between page protection traps and the initial
4302 startup sequence by the dynamic linker.
4304 However, I tried avoiding that by having HP-UX's implementation of
4305 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4306 yet, which forced slow watches before a "run" or "attach", and it
4307 still fails somewhere in the startup code.
4309 Until I figure out what's happening, I'm disallowing watches altogether
4310 before the "run" or "attach" command. We'll tell the user they must
4311 set watches after getting the program started. */
4312 if (! target_has_execution)
4314 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4317 #endif /* HPUXHPPA */
4319 /* Now set up the breakpoint. */
4320 b = set_raw_breakpoint (sal);
4321 set_breakpoint_count (breakpoint_count + 1);
4322 b->number = breakpoint_count;
4323 b->disposition = donttouch;
4325 b->exp_valid_block = exp_valid_block;
4326 b->exp_string = savestring (exp_start, exp_end - exp_start);
4330 b->cond_string = savestring (cond_start, cond_end - cond_start);
4334 frame = block_innermost_frame (exp_valid_block);
4337 prev_frame = get_prev_frame (frame);
4338 b->watchpoint_frame = frame->frame;
4341 b->watchpoint_frame = (CORE_ADDR)0;
4343 if (mem_cnt && target_resources_ok > 0)
4346 b->type = bp_watchpoint;
4348 /* If the expression is "local", then set up a "watchpoint scope"
4349 breakpoint at the point where we've left the scope of the watchpoint
4351 if (innermost_block)
4355 struct breakpoint *scope_breakpoint;
4356 struct symtab_and_line scope_sal;
4358 INIT_SAL (&scope_sal); /* initialize to zeroes */
4359 scope_sal.pc = get_frame_pc (prev_frame);
4360 scope_sal.section = find_pc_overlay (scope_sal.pc);
4362 scope_breakpoint = set_raw_breakpoint (scope_sal);
4363 set_breakpoint_count (breakpoint_count + 1);
4364 scope_breakpoint->number = breakpoint_count;
4366 scope_breakpoint->type = bp_watchpoint_scope;
4367 scope_breakpoint->enable = enabled;
4369 /* Automatically delete the breakpoint when it hits. */
4370 scope_breakpoint->disposition = del;
4372 /* Only break in the proper frame (help with recursion). */
4373 scope_breakpoint->frame = prev_frame->frame;
4375 /* Set the address at which we will stop. */
4376 scope_breakpoint->address = get_frame_pc (prev_frame);
4378 /* The scope breakpoint is related to the watchpoint. We
4379 will need to act on them together. */
4380 b->related_breakpoint = scope_breakpoint;
4383 value_free_to_mark (mark);
4387 /* Return count of locations need to be watched and can be handled
4388 in hardware. If the watchpoint can not be handled
4389 in hardware return zero. */
4391 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4392 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_size) \
4393 ((byte_size) <= (REGISTER_SIZE))
4397 can_use_hardware_watchpoint (v)
4400 int found_memory_cnt = 0;
4402 /* Did the user specifically forbid us to use hardware watchpoints? */
4403 if (! can_use_hw_watchpoints)
4406 /* Make sure all the intermediate values are in memory. Also make sure
4407 we found at least one memory expression. Guards against watch 0x12345,
4408 which is meaningless, but could cause errors if one tries to insert a
4409 hardware watchpoint for the constant expression. */
4410 for ( ; v; v = v->next)
4412 if (v->lval == lval_memory)
4414 if (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (TYPE_LENGTH (VALUE_TYPE (v))))
4417 else if (v->lval != not_lval && v->modifiable == 0)
4421 /* The expression itself looks suitable for using a hardware
4422 watchpoint, but give the target machine a chance to reject it. */
4423 return found_memory_cnt;
4426 static void watch_command (arg, from_tty)
4430 watch_command_1 (arg, 0, from_tty);
4433 static void rwatch_command (arg, from_tty)
4437 watch_command_1 (arg, 1, from_tty);
4440 static void awatch_command (arg, from_tty)
4444 watch_command_1 (arg, 2, from_tty);
4448 /* Helper routine for the until_command routine in infcmd.c. Here
4449 because it uses the mechanisms of breakpoints. */
4453 until_break_command (arg, from_tty)
4457 struct symtabs_and_lines sals;
4458 struct symtab_and_line sal;
4459 struct frame_info *prev_frame = get_prev_frame (selected_frame);
4460 struct breakpoint *breakpoint;
4461 struct cleanup *old_chain;
4463 clear_proceed_status ();
4465 /* Set a breakpoint where the user wants it and at return from
4468 if (default_breakpoint_valid)
4469 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
4470 default_breakpoint_line, (char ***)NULL);
4472 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
4474 if (sals.nelts != 1)
4475 error ("Couldn't get information on specified line.");
4478 free ((PTR)sals.sals); /* malloc'd, so freed */
4481 error ("Junk at end of arguments.");
4483 resolve_sal_pc (&sal);
4485 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
4487 old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4489 /* Keep within the current frame */
4493 sal = find_pc_line (prev_frame->pc, 0);
4494 sal.pc = prev_frame->pc;
4495 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
4496 make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4499 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
4500 do_cleanups(old_chain);
4504 /* These aren't used; I don't konw what they were for. */
4505 /* Set a breakpoint at the catch clause for NAME. */
4507 catch_breakpoint (name)
4513 disable_catch_breakpoint ()
4518 delete_catch_breakpoint ()
4523 enable_catch_breakpoint ()
4530 struct sal_chain *next;
4531 struct symtab_and_line sal;
4534 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4535 had been commented out in the v.4.16 sources, and stays
4536 disabled there now because "catch NAME" syntax isn't allowed.
4538 /* This isn't used; I don't know what it was for. */
4539 /* For each catch clause identified in ARGS, run FUNCTION
4540 with that clause as an argument. */
4541 static struct symtabs_and_lines
4542 map_catch_names (args, function)
4546 register char *p = args;
4548 struct symtabs_and_lines sals;
4550 struct sal_chain *sal_chain = 0;
4554 error_no_arg ("one or more catch names");
4562 /* Don't swallow conditional part. */
4563 if (p1[0] == 'i' && p1[1] == 'f'
4564 && (p1[2] == ' ' || p1[2] == '\t'))
4570 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
4574 if (*p1 && *p1 != ' ' && *p1 != '\t')
4575 error ("Arguments must be catch names.");
4581 struct sal_chain *next = (struct sal_chain *)
4582 alloca (sizeof (struct sal_chain));
4583 next->next = sal_chain;
4584 next->sal = get_catch_sal (p);
4589 printf_unfiltered ("No catch clause for exception %s.\n", p);
4594 while (*p == ' ' || *p == '\t') p++;
4598 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4600 static struct symtabs_and_lines
4601 get_catch_sals (this_level_only)
4602 int this_level_only;
4604 register struct blockvector *bl;
4605 register struct block *block;
4606 int index, have_default = 0;
4608 struct symtabs_and_lines sals;
4609 struct sal_chain *sal_chain = 0;
4610 char *blocks_searched;
4612 /* Not sure whether an error message is always the correct response,
4613 but it's better than a core dump. */
4614 if (selected_frame == NULL)
4615 error ("No selected frame.");
4616 block = get_frame_block (selected_frame);
4617 pc = selected_frame->pc;
4623 error ("No symbol table info available.\n");
4625 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
4626 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4627 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4631 CORE_ADDR end = BLOCK_END (block) - 4;
4634 if (bl != blockvector_for_pc (end, &index))
4635 error ("blockvector blotch");
4636 if (BLOCKVECTOR_BLOCK (bl, index) != block)
4637 error ("blockvector botch");
4638 last_index = BLOCKVECTOR_NBLOCKS (bl);
4641 /* Don't print out blocks that have gone by. */
4642 while (index < last_index
4643 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
4646 while (index < last_index
4647 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
4649 if (blocks_searched[index] == 0)
4651 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
4654 register struct symbol *sym;
4656 nsyms = BLOCK_NSYMS (b);
4658 for (i = 0; i < nsyms; i++)
4660 sym = BLOCK_SYM (b, i);
4661 if (STREQ (SYMBOL_NAME (sym), "default"))
4667 if (SYMBOL_CLASS (sym) == LOC_LABEL)
4669 struct sal_chain *next = (struct sal_chain *)
4670 alloca (sizeof (struct sal_chain));
4671 next->next = sal_chain;
4672 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
4676 blocks_searched[index] = 1;
4682 if (sal_chain && this_level_only)
4685 /* After handling the function's top-level block, stop.
4686 Don't continue to its superblock, the block of
4687 per-file symbols. */
4688 if (BLOCK_FUNCTION (block))
4690 block = BLOCK_SUPERBLOCK (block);
4695 struct sal_chain *tmp_chain;
4697 /* Count the number of entries. */
4698 for (index = 0, tmp_chain = sal_chain; tmp_chain;
4699 tmp_chain = tmp_chain->next)
4703 sals.sals = (struct symtab_and_line *)
4704 xmalloc (index * sizeof (struct symtab_and_line));
4705 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
4706 sals.sals[index] = sal_chain->sal;
4713 ep_skip_leading_whitespace (s)
4716 if ((s == NULL) || (*s == NULL))
4718 while (isspace(**s))
4722 /* This function examines a string, and attempts to find a token
4723 that might be an event name in the leading characters. If a
4724 possible match is found, a pointer to the last character of
4725 the token is returned. Else, NULL is returned. */
4727 ep_find_event_name_end (arg)
4731 char * event_name_end = NULL;
4733 /* If we could depend upon the presense of strrpbrk, we'd use that... */
4737 /* We break out of the loop when we find a token delimiter.
4738 Basically, we're looking for alphanumerics and underscores;
4739 anything else delimites the token. */
4742 if (! isalnum(*s) && (*s != '_'))
4748 return event_name_end;
4752 /* This function attempts to parse an optional "if <cond>" clause
4753 from the arg string. If one is not found, it returns NULL.
4755 Else, it returns a pointer to the condition string. (It does not
4756 attempt to evaluate the string against a particular block.) And,
4757 it updates arg to point to the first character following the parsed
4758 if clause in the arg string. */
4760 ep_parse_optional_if_clause (arg)
4765 if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace((*arg)[2]))
4768 /* Skip the "if" keyword. */
4771 /* Skip any extra leading whitespace, and record the start of the
4772 condition string. */
4773 ep_skip_leading_whitespace (arg);
4776 /* Assume that the condition occupies the remainder of the arg string. */
4777 (*arg) += strlen (cond_string);
4782 /* This function attempts to parse an optional filename from the arg
4783 string. If one is not found, it returns NULL.
4785 Else, it returns a pointer to the parsed filename. (This function
4786 makes no attempt to verify that a file of that name exists, or is
4787 accessible.) And, it updates arg to point to the first character
4788 following the parsed filename in the arg string.
4790 Note that clients needing to preserve the returned filename for
4791 future access should copy it to their own buffers. */
4793 ep_parse_optional_filename (arg)
4796 static char filename [1024];
4797 char * arg_p = *arg;
4801 if ((*arg_p == '\0') || isspace (*arg_p))
4819 /* Commands to deal with catching events, such as signals, exceptions,
4820 process start/exit, etc. */
4822 typedef enum {catch_fork, catch_vfork} catch_fork_kind;
4825 catch_fork_command_1 (fork_kind, arg, tempflag, from_tty)
4826 catch_fork_kind fork_kind;
4831 char * cond_string = NULL;
4833 ep_skip_leading_whitespace (&arg);
4835 /* The allowed syntax is:
4837 catch [v]fork if <cond>
4839 First, check if there's an if clause. */
4840 cond_string = ep_parse_optional_if_clause (&arg);
4842 if ((*arg != '\0') && !isspace (*arg))
4843 error ("Junk at end of arguments.");
4845 /* If this target supports it, create a fork or vfork catchpoint
4846 and enable reporting of such events. */
4847 switch (fork_kind) {
4849 create_fork_event_catchpoint (tempflag, cond_string);
4852 create_vfork_event_catchpoint (tempflag, cond_string);
4855 error ("unsupported or unknown fork kind; cannot catch it");
4861 catch_exec_command_1 (arg, tempflag, from_tty)
4866 char * cond_string = NULL;
4868 ep_skip_leading_whitespace (&arg);
4870 /* The allowed syntax is:
4872 catch exec if <cond>
4874 First, check if there's an if clause. */
4875 cond_string = ep_parse_optional_if_clause (&arg);
4877 if ((*arg != '\0') && !isspace (*arg))
4878 error ("Junk at end of arguments.");
4880 /* If this target supports it, create an exec catchpoint
4881 and enable reporting of such events. */
4882 create_exec_event_catchpoint (tempflag, cond_string);
4885 #if defined(SOLIB_ADD)
4887 catch_load_command_1 (arg, tempflag, from_tty)
4892 char * dll_pathname = NULL;
4893 char * cond_string = NULL;
4895 ep_skip_leading_whitespace (&arg);
4897 /* The allowed syntax is:
4899 catch load if <cond>
4900 catch load <filename>
4901 catch load <filename> if <cond>
4903 The user is not allowed to specify the <filename> after an
4906 We'll ignore the pathological case of a file named "if".
4908 First, check if there's an if clause. If so, then there
4909 cannot be a filename. */
4910 cond_string = ep_parse_optional_if_clause (&arg);
4912 /* If there was an if clause, then there cannot be a filename.
4913 Else, there might be a filename and an if clause. */
4914 if (cond_string == NULL)
4916 dll_pathname = ep_parse_optional_filename (&arg);
4917 ep_skip_leading_whitespace (&arg);
4918 cond_string = ep_parse_optional_if_clause (&arg);
4921 if ((*arg != '\0') && !isspace (*arg))
4922 error ("Junk at end of arguments.");
4924 /* Create a load breakpoint that only triggers when a load of
4925 the specified dll (or any dll, if no pathname was specified)
4927 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
4931 catch_unload_command_1 (arg, tempflag, from_tty)
4936 char * dll_pathname = NULL;
4937 char * cond_string = NULL;
4939 ep_skip_leading_whitespace (&arg);
4941 /* The allowed syntax is:
4943 catch unload if <cond>
4944 catch unload <filename>
4945 catch unload <filename> if <cond>
4947 The user is not allowed to specify the <filename> after an
4950 We'll ignore the pathological case of a file named "if".
4952 First, check if there's an if clause. If so, then there
4953 cannot be a filename. */
4954 cond_string = ep_parse_optional_if_clause (&arg);
4956 /* If there was an if clause, then there cannot be a filename.
4957 Else, there might be a filename and an if clause. */
4958 if (cond_string == NULL)
4960 dll_pathname = ep_parse_optional_filename (&arg);
4961 ep_skip_leading_whitespace (&arg);
4962 cond_string = ep_parse_optional_if_clause (&arg);
4965 if ((*arg != '\0') && !isspace (*arg))
4966 error ("Junk at end of arguments.");
4968 /* Create an unload breakpoint that only triggers when an unload of
4969 the specified dll (or any dll, if no pathname was specified)
4971 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
4973 #endif /* SOLIB_ADD */
4975 /* Commands to deal with catching exceptions. */
4977 /* Set a breakpoint at the specified callback routine for an
4978 exception event callback */
4981 create_exception_catchpoint (tempflag, cond_string, ex_event, sal)
4984 enum exception_event_kind ex_event;
4985 struct symtab_and_line * sal;
4987 struct breakpoint * b;
4989 int thread = -1; /* All threads. */
4991 if (!sal) /* no exception support? */
4994 b = set_raw_breakpoint (*sal);
4995 set_breakpoint_count (breakpoint_count + 1);
4996 b->number = breakpoint_count;
4998 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
5000 b->addr_string = NULL;
5001 b->enable = enabled;
5002 b->disposition = tempflag ? del : donttouch;
5005 case EX_EVENT_THROW:
5006 b->type = bp_catch_throw;
5008 case EX_EVENT_CATCH:
5009 b->type = bp_catch_catch;
5011 default: /* error condition */
5013 b->enable = disabled;
5014 error ("Internal error -- invalid catchpoint kind");
5019 /* Deal with "catch catch" and "catch throw" commands */
5022 catch_exception_command_1 (ex_event, arg, tempflag, from_tty)
5023 enum exception_event_kind ex_event;
5028 char * cond_string = NULL;
5029 struct symtab_and_line * sal = NULL;
5031 ep_skip_leading_whitespace (&arg);
5033 cond_string = ep_parse_optional_if_clause (&arg);
5035 if ((*arg != '\0') && !isspace (*arg))
5036 error ("Junk at end of arguments.");
5038 if ((ex_event != EX_EVENT_THROW) &&
5039 (ex_event != EX_EVENT_CATCH))
5040 error ("Unsupported or unknown exception event; cannot catch it");
5042 /* See if we can find a callback routine */
5043 sal = target_enable_exception_callback (ex_event, 1);
5047 /* We have callbacks from the runtime system for exceptions.
5048 Set a breakpoint on the sal found, if no errors */
5049 if (sal != (struct symtab_and_line *) -1)
5050 create_exception_catchpoint (tempflag, cond_string, ex_event, sal);
5052 return; /* something went wrong with setting up callbacks */
5056 /* No callbacks from runtime system for exceptions.
5057 Try GNU C++ exception breakpoints using labels in debug info. */
5058 if (ex_event == EX_EVENT_CATCH)
5060 handle_gnu_4_16_catch_command (arg, tempflag, from_tty);
5062 else if (ex_event == EX_EVENT_THROW)
5064 /* Set a breakpoint on __raise_exception () */
5066 fprintf_filtered (gdb_stderr, "Unsupported with this platform/compiler combination.\n");
5067 fprintf_filtered (gdb_stderr, "Perhaps you can achieve the effect you want by setting\n");
5068 fprintf_filtered (gdb_stderr, "a breakpoint on __raise_exception().\n");
5073 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5074 inside a catch_errors */
5077 cover_target_enable_exception_callback (arg)
5080 args_for_catchpoint_enable *args = arg;
5081 struct symtab_and_line *sal;
5082 sal = target_enable_exception_callback (args->kind, args->enable);
5085 else if (sal == (struct symtab_and_line *) -1)
5088 return 1; /*is valid*/
5093 /* This is the original v.4.16 and earlier version of the
5094 catch_command_1() function. Now that other flavours of "catch"
5095 have been introduced, and since exception handling can be handled
5096 in other ways (through target ops) also, this is used only for the
5097 GNU C++ exception handling system.
5098 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5099 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5100 there was no code in GDB 4.16 for "catch throw".
5102 Called from catch_exception_command_1 () */
5106 handle_gnu_4_16_catch_command (arg, tempflag, from_tty)
5111 /* First, translate ARG into something we can deal with in terms
5114 struct symtabs_and_lines sals;
5115 struct symtab_and_line sal;
5116 register struct expression *cond = 0;
5117 register struct breakpoint *b;
5121 INIT_SAL (&sal); /* initialize to zeroes */
5123 /* If no arg given, or if first arg is 'if ', all active catch clauses
5124 are breakpointed. */
5126 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
5127 && (arg[2] == ' ' || arg[2] == '\t')))
5129 /* Grab all active catch clauses. */
5130 sals = get_catch_sals (0);
5134 /* Grab selected catch clauses. */
5135 error ("catch NAME not implemented");
5138 /* Not sure why this code has been disabled. I'm leaving
5139 it disabled. We can never come here now anyway
5140 since we don't allow the "catch NAME" syntax.
5143 /* This isn't used; I don't know what it was for. */
5144 sals = map_catch_names (arg, catch_breakpoint);
5152 for (i = 0; i < sals.nelts; i++)
5154 resolve_sal_pc (&sals.sals[i]);
5158 if (arg[0] == 'i' && arg[1] == 'f'
5159 && (arg[2] == ' ' || arg[2] == '\t'))
5160 cond = parse_exp_1 ((arg += 2, &arg),
5161 block_for_pc (sals.sals[i].pc), 0);
5163 error ("Junk at end of arguments.");
5168 for (i = 0; i < sals.nelts; i++)
5173 describe_other_breakpoints (sal.pc, sal.section);
5175 b = set_raw_breakpoint (sal);
5176 set_breakpoint_count (breakpoint_count + 1);
5177 b->number = breakpoint_count;
5178 b->type = bp_breakpoint; /* Important -- this is an ordinary breakpoint.
5179 For platforms with callback support for exceptions,
5180 create_exception_catchpoint() will create special
5181 bp types (bp_catch_catch and bp_catch_throw), and
5182 there is code in insert_breakpoints() and elsewhere
5183 that depends on that. */
5186 b->enable = enabled;
5187 b->disposition = tempflag ? del : donttouch;
5194 printf_unfiltered ("Multiple breakpoints were set.\n");
5195 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
5197 free ((PTR)sals.sals);
5201 /* This creates a temporary internal breakpoint
5202 just to placate infrun */
5203 static struct breakpoint *
5204 create_temp_exception_breakpoint (pc)
5207 struct symtab_and_line sal;
5208 struct breakpoint *b;
5215 b = set_raw_breakpoint (sal);
5217 error ("Internal error -- couldn't set temp exception breakpoint");
5219 b->type = bp_breakpoint;
5220 b->disposition = del;
5221 b->enable = enabled;
5223 b->number = internal_breakpoint_number--;
5229 catch_command_1 (arg, tempflag, from_tty)
5235 /* The first argument may be an event name, such as "start" or "load".
5236 If so, then handle it as such. If it doesn't match an event name,
5237 then attempt to interpret it as an exception name. (This latter is
5238 the v4.16-and-earlier GDB meaning of the "catch" command.)
5240 First, try to find the bounds of what might be an event name. */
5241 char * arg1_start = arg;
5245 if (arg1_start == NULL)
5247 /* Old behaviour was to use pre-v-4.16 syntax */
5248 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5250 /* Now, this is not allowed */
5251 error ("Catch requires an event name.");
5254 arg1_end = ep_find_event_name_end (arg1_start);
5255 if (arg1_end == NULL)
5256 error ("catch requires an event");
5257 arg1_length = arg1_end + 1 - arg1_start;
5259 /* Try to match what we found against known event names. */
5260 if (strncmp (arg1_start, "signal", arg1_length) == 0)
5262 error ("Catch of signal not yet implemented");
5264 else if (strncmp (arg1_start, "catch", arg1_length) == 0)
5266 catch_exception_command_1 (EX_EVENT_CATCH, arg1_end+1, tempflag, from_tty);
5268 else if (strncmp (arg1_start, "throw", arg1_length) == 0)
5270 catch_exception_command_1 (EX_EVENT_THROW, arg1_end+1, tempflag, from_tty);
5272 else if (strncmp (arg1_start, "thread_start", arg1_length) == 0)
5274 error ("Catch of thread_start not yet implemented");
5276 else if (strncmp (arg1_start, "thread_exit", arg1_length) == 0)
5278 error ("Catch of thread_exit not yet implemented");
5280 else if (strncmp (arg1_start, "thread_join", arg1_length) == 0)
5282 error ("Catch of thread_join not yet implemented");
5284 else if (strncmp (arg1_start, "start", arg1_length) == 0)
5286 error ("Catch of start not yet implemented");
5288 else if (strncmp (arg1_start, "exit", arg1_length) == 0)
5290 error ("Catch of exit not yet implemented");
5292 else if (strncmp (arg1_start, "fork", arg1_length) == 0)
5294 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5295 catch_fork_command_1 (catch_fork, arg1_end+1, tempflag, from_tty);
5297 error ("Catch of fork not yet implemented");
5300 else if (strncmp (arg1_start, "vfork", arg1_length) == 0)
5302 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5303 catch_fork_command_1 (catch_vfork, arg1_end+1, tempflag, from_tty);
5305 error ("Catch of vfork not yet implemented");
5308 else if (strncmp (arg1_start, "exec", arg1_length) == 0)
5310 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5311 catch_exec_command_1 (arg1_end+1, tempflag, from_tty);
5313 error ("Catch of exec not yet implemented");
5316 else if (strncmp (arg1_start, "load", arg1_length) == 0)
5318 #if defined(SOLIB_ADD)
5319 catch_load_command_1 (arg1_end+1, tempflag, from_tty);
5321 error ("Catch of load not implemented");
5324 else if (strncmp (arg1_start, "unload", arg1_length) == 0)
5326 #if defined(SOLIB_ADD)
5327 catch_unload_command_1 (arg1_end+1, tempflag, from_tty);
5329 error ("Catch of load not implemented");
5332 else if (strncmp (arg1_start, "stop", arg1_length) == 0)
5334 error ("Catch of stop not yet implemented");
5337 /* This doesn't appear to be an event name */
5341 /* Pre-v.4.16 behaviour was to treat the argument
5342 as the name of an exception */
5343 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5344 /* Now this is not allowed */
5345 error ("Unknown event kind specified for catch");
5350 /* Used by the gui, could be made a worker for other things. */
5353 set_breakpoint_sal (sal)
5354 struct symtab_and_line sal;
5356 struct breakpoint *b;
5357 b = set_raw_breakpoint (sal);
5358 set_breakpoint_count (breakpoint_count + 1);
5359 b->number = breakpoint_count;
5360 b->type = bp_breakpoint;
5367 /* These aren't used; I don't know what they were for. */
5368 /* Disable breakpoints on all catch clauses described in ARGS. */
5370 disable_catch (args)
5373 /* Map the disable command to catch clauses described in ARGS. */
5376 /* Enable breakpoints on all catch clauses described in ARGS. */
5381 /* Map the disable command to catch clauses described in ARGS. */
5384 /* Delete breakpoints on all catch clauses in the active scope. */
5389 /* Map the delete command to catch clauses described in ARGS. */
5394 catch_command (arg, from_tty)
5398 catch_command_1 (arg, 0, from_tty);
5403 tcatch_command (arg, from_tty)
5407 catch_command_1 (arg, 1, from_tty);
5412 clear_command (arg, from_tty)
5416 register struct breakpoint *b, *b1;
5418 struct symtabs_and_lines sals;
5419 struct symtab_and_line sal;
5420 register struct breakpoint *found;
5425 sals = decode_line_spec (arg, 1);
5430 sals.sals = (struct symtab_and_line *)
5431 xmalloc (sizeof (struct symtab_and_line));
5432 INIT_SAL (&sal); /* initialize to zeroes */
5433 sal.line = default_breakpoint_line;
5434 sal.symtab = default_breakpoint_symtab;
5435 sal.pc = default_breakpoint_address;
5436 if (sal.symtab == 0)
5437 error ("No source file specified.");
5445 /* For each line spec given, delete bps which correspond
5446 to it. We do this in two loops: the first loop looks at
5447 the initial bp(s) in the chain which should be deleted,
5448 the second goes down the rest of the chain looking ahead
5449 one so it can take those bps off the chain without messing
5453 for (i = 0; i < sals.nelts; i++)
5455 /* If exact pc given, clear bpts at that pc.
5456 If line given (pc == 0), clear all bpts on specified line.
5457 If defaulting, clear all bpts on default line
5460 defaulting sal.pc != 0 tests to do
5465 1 0 <can't happen> */
5468 found = (struct breakpoint *) 0;
5471 while (breakpoint_chain
5472 /* Why don't we check here that this is not
5473 a watchpoint, etc., as we do below?
5474 I can't make it fail, but don't know
5475 what's stopping the failure: a watchpoint
5476 of the same address as "sal.pc" should
5477 wind up being deleted. */
5479 && ( ((sal.pc && (breakpoint_chain->address == sal.pc)) &&
5480 (overlay_debugging == 0 ||
5481 breakpoint_chain->section == sal.section))
5482 || ((default_match || (0 == sal.pc))
5483 && breakpoint_chain->source_file != NULL
5484 && sal.symtab != NULL
5485 && STREQ (breakpoint_chain->source_file, sal.symtab->filename)
5486 && breakpoint_chain->line_number == sal.line)))
5489 b1 = breakpoint_chain;
5490 breakpoint_chain = b1->next;
5498 && b->next->type != bp_none
5499 && b->next->type != bp_watchpoint
5500 && b->next->type != bp_hardware_watchpoint
5501 && b->next->type != bp_read_watchpoint
5502 && b->next->type != bp_access_watchpoint
5503 && ( ((sal.pc && (b->next->address == sal.pc)) &&
5504 (overlay_debugging == 0 ||
5505 b->next->section == sal.section))
5506 || ((default_match || (0 == sal.pc))
5507 && b->next->source_file != NULL
5508 && sal.symtab != NULL
5509 && STREQ (b->next->source_file, sal.symtab->filename)
5510 && b->next->line_number == sal.line)))
5523 error ("No breakpoint at %s.", arg);
5525 error ("No breakpoint at this line.");
5528 if (found->next) from_tty = 1; /* Always report if deleted more than one */
5529 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
5530 breakpoints_changed ();
5533 if (from_tty) printf_unfiltered ("%d ", found->number);
5535 delete_breakpoint (found);
5538 if (from_tty) putchar_unfiltered ('\n');
5540 free ((PTR)sals.sals);
5543 /* Delete breakpoint in BS if they are `delete' breakpoints and
5544 all breakpoints that are marked for deletion, whether hit or not.
5545 This is called after any breakpoint is hit, or after errors. */
5548 breakpoint_auto_delete (bs)
5551 struct breakpoint *b, *temp;
5553 for (; bs; bs = bs->next)
5554 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
5556 delete_breakpoint (bs->breakpoint_at);
5558 ALL_BREAKPOINTS_SAFE (b, temp)
5560 if (b->disposition == del_at_next_stop)
5561 delete_breakpoint (b);
5565 /* Delete a breakpoint and clean up all traces of it in the data structures. */
5568 delete_breakpoint (bpt)
5569 struct breakpoint *bpt;
5571 register struct breakpoint *b;
5575 error ("Internal error (attempted to delete a NULL breakpoint)");
5578 /* Has this bp already been deleted? This can happen because multiple
5579 lists can hold pointers to bp's. bpstat lists are especial culprits.
5581 One example of this happening is a watchpoint's scope bp. When the
5582 scope bp triggers, we notice that the watchpoint is out of scope, and
5583 delete it. We also delete its scope bp. But the scope bp is marked
5584 "auto-deleting", and is already on a bpstat. That bpstat is then
5585 checked for auto-deleting bp's, which are deleted.
5587 A real solution to this problem might involve reference counts in bp's,
5588 and/or giving them pointers back to their referencing bpstat's, and
5589 teaching delete_breakpoint to only free a bp's storage when no more
5590 references were extent. A cheaper bandaid was chosen. */
5591 if (bpt->type == bp_none)
5594 if (delete_breakpoint_hook)
5595 delete_breakpoint_hook (bpt);
5598 remove_breakpoint (bpt, mark_uninserted);
5600 if (breakpoint_chain == bpt)
5601 breakpoint_chain = bpt->next;
5603 /* If we have callback-style exception catchpoints, don't go through
5604 the adjustments to the C++ runtime library etc. if the inferior
5605 isn't actually running. target_enable_exception_callback for a
5606 null target ops vector gives an undesirable error message, so we
5607 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5608 exceptions are supported in this way, it's OK for now. FIXME */
5609 if (ep_is_exception_catchpoint (bpt) && target_has_execution)
5611 static char message1[] = "Error in deleting catchpoint %d:\n";
5612 static char message[sizeof (message1) + 30];
5613 args_for_catchpoint_enable args;
5615 sprintf (message, message1, bpt->number); /* Format possible error msg */
5616 args.kind = bpt->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
5618 catch_errors (cover_target_enable_exception_callback, &args,
5619 message, RETURN_MASK_ALL);
5626 b->next = bpt->next;
5630 /* Before turning off the visuals for the bp, check to see that
5631 there are no other bps at the same address. */
5638 clearIt = (b->address != bpt->address);
5645 TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, bpt, 0));
5646 TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos));
5650 check_duplicates (bpt->address, bpt->section);
5651 /* If this breakpoint was inserted, and there is another breakpoint
5652 at the same address, we need to insert the other breakpoint. */
5654 && bpt->type != bp_hardware_watchpoint
5655 && bpt->type != bp_read_watchpoint
5656 && bpt->type != bp_access_watchpoint
5657 && bpt->type != bp_catch_fork
5658 && bpt->type != bp_catch_vfork
5659 && bpt->type != bp_catch_exec)
5662 if (b->address == bpt->address
5663 && b->section == bpt->section
5665 && b->enable != disabled
5666 && b->enable != shlib_disabled
5667 && b->enable != call_disabled)
5670 val = target_insert_breakpoint (b->address, b->shadow_contents);
5673 target_terminal_ours_for_output ();
5674 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
5675 memory_error (val, b->address); /* which bombs us out */
5682 free_command_lines (&bpt->commands);
5685 if (bpt->cond_string != NULL)
5686 free (bpt->cond_string);
5687 if (bpt->addr_string != NULL)
5688 free (bpt->addr_string);
5689 if (bpt->exp != NULL)
5691 if (bpt->exp_string != NULL)
5692 free (bpt->exp_string);
5693 if (bpt->val != NULL)
5694 value_free (bpt->val);
5695 if (bpt->source_file != NULL)
5696 free (bpt->source_file);
5697 if (bpt->dll_pathname != NULL)
5698 free (bpt->dll_pathname);
5699 if (bpt->triggered_dll_pathname != NULL)
5700 free (bpt->triggered_dll_pathname);
5701 if (bpt->exec_pathname != NULL)
5702 free (bpt->exec_pathname);
5704 /* Be sure no bpstat's are pointing at it after it's been freed. */
5705 /* FIXME, how can we find all bpstat's?
5706 We just check stop_bpstat for now. */
5707 for (bs = stop_bpstat; bs; bs = bs->next)
5708 if (bs->breakpoint_at == bpt)
5710 bs->breakpoint_at = NULL;
5712 /* we'd call bpstat_clear_actions, but that free's stuff and due
5713 to the multiple pointers pointing to one item with no
5714 reference counts found anywhere through out the bpstat's (how
5715 do you spell fragile?), we don't want to free things twice --
5716 better a memory leak than a corrupt malloc pool! */
5717 bs->commands = NULL;
5720 /* On the chance that someone will soon try again to delete this same
5721 bp, we mark it as deleted before freeing its storage. */
5722 bpt->type = bp_none;
5728 delete_command (arg, from_tty)
5732 struct breakpoint *b, *temp;
5736 int breaks_to_delete = 0;
5738 /* Delete all breakpoints if no argument.
5739 Do not delete internal or call-dummy breakpoints, these
5740 have to be deleted with an explicit breakpoint number argument. */
5743 if (b->type != bp_call_dummy &&
5744 b->type != bp_shlib_event &&
5746 breaks_to_delete = 1;
5749 /* Ask user only if there are some breakpoints to delete. */
5751 || (breaks_to_delete && query ("Delete all breakpoints? ")))
5753 ALL_BREAKPOINTS_SAFE (b, temp)
5755 if (b->type != bp_call_dummy &&
5756 b->type != bp_shlib_event &&
5758 delete_breakpoint (b);
5763 map_breakpoint_numbers (arg, delete_breakpoint);
5766 /* Reset a breakpoint given it's struct breakpoint * BINT.
5767 The value we return ends up being the return value from catch_errors.
5768 Unused in this case. */
5771 breakpoint_re_set_one (bint)
5774 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
5777 struct symtabs_and_lines sals;
5779 enum enable save_enable;
5784 warning ("attempted to reset apparently deleted breakpoint #%d?\n", b->number);
5787 case bp_hardware_breakpoint:
5789 case bp_catch_unload:
5790 if (b->addr_string == NULL)
5792 /* Anything without a string can't be re-set. */
5793 delete_breakpoint (b);
5796 /* In case we have a problem, disable this breakpoint. We'll restore
5797 its status if we succeed. */
5798 save_enable = b->enable;
5799 b->enable = disabled;
5801 set_language (b->language);
5802 input_radix = b->input_radix;
5804 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
5805 for (i = 0; i < sals.nelts; i++)
5807 resolve_sal_pc (&sals.sals[i]);
5809 /* Reparse conditions, they might contain references to the
5811 if (b->cond_string != NULL)
5815 free ((PTR)b->cond);
5816 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
5819 /* We need to re-set the breakpoint if the address changes...*/
5820 if (b->address != sals.sals[i].pc
5821 /* ...or new and old breakpoints both have source files, and
5822 the source file name or the line number changes... */
5823 || (b->source_file != NULL
5824 && sals.sals[i].symtab != NULL
5825 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
5826 || b->line_number != sals.sals[i].line)
5828 /* ...or we switch between having a source file and not having
5830 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
5833 if (b->source_file != NULL)
5834 free (b->source_file);
5835 if (sals.sals[i].symtab == NULL)
5836 b->source_file = NULL;
5839 savestring (sals.sals[i].symtab->filename,
5840 strlen (sals.sals[i].symtab->filename));
5841 b->line_number = sals.sals[i].line;
5842 b->address = sals.sals[i].pc;
5844 /* Used to check for duplicates here, but that can
5845 cause trouble, as it doesn't check for disable
5850 /* Might be better to do this just once per breakpoint_re_set,
5851 rather than once for every breakpoint. */
5852 breakpoints_changed ();
5854 b->section = sals.sals[i].section;
5855 b->enable = save_enable; /* Restore it, this worked. */
5858 /* Now that this is re-enabled, check_duplicates
5860 check_duplicates (b->address, b->section);
5863 free ((PTR)sals.sals);
5867 case bp_hardware_watchpoint:
5868 case bp_read_watchpoint:
5869 case bp_access_watchpoint:
5870 innermost_block = NULL;
5871 /* The issue arises of what context to evaluate this in. The same
5872 one as when it was set, but what does that mean when symbols have
5873 been re-read? We could save the filename and functionname, but
5874 if the context is more local than that, the best we could do would
5875 be something like how many levels deep and which index at that
5876 particular level, but that's going to be less stable than filenames
5877 or functionnames. */
5878 /* So for now, just use a global context. */
5881 b->exp = parse_expression (b->exp_string);
5882 b->exp_valid_block = innermost_block;
5883 mark = value_mark ();
5885 value_free (b->val);
5886 b->val = evaluate_expression (b->exp);
5887 release_value (b->val);
5888 if (VALUE_LAZY (b->val))
5889 value_fetch_lazy (b->val);
5891 if (b->cond_string != NULL)
5895 free ((PTR)b->cond);
5896 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
5898 if (b->enable == enabled)
5900 value_free_to_mark (mark);
5902 case bp_catch_catch:
5903 case bp_catch_throw:
5905 /* We needn't really do anything to reset these, since the mask
5906 that requests them is unaffected by e.g., new libraries being
5909 case bp_catch_vfork:
5914 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
5916 /* Delete longjmp breakpoints, they will be reset later by
5917 breakpoint_re_set. */
5919 case bp_longjmp_resume:
5920 delete_breakpoint (b);
5923 /* This breakpoint is special, it's set up when the inferior
5924 starts and we really don't want to touch it. */
5925 case bp_shlib_event:
5927 /* Keep temporary breakpoints, which can be encountered when we step
5928 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
5929 Otherwise these should have been blown away via the cleanup chain
5930 or by breakpoint_init_inferior when we rerun the executable. */
5933 case bp_watchpoint_scope:
5935 case bp_step_resume:
5942 /* Re-set all breakpoints after symbols have been re-loaded. */
5944 breakpoint_re_set ()
5946 struct breakpoint *b, *temp;
5947 enum language save_language;
5948 int save_input_radix;
5949 static char message1[] = "Error in re-setting breakpoint %d:\n";
5950 char message[sizeof (message1) + 30 /* slop */];
5952 save_language = current_language->la_language;
5953 save_input_radix = input_radix;
5954 ALL_BREAKPOINTS_SAFE (b, temp)
5956 sprintf (message, message1, b->number); /* Format possible error msg */
5957 catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
5959 set_language (save_language);
5960 input_radix = save_input_radix;
5962 #ifdef GET_LONGJMP_TARGET
5963 create_longjmp_breakpoint ("longjmp");
5964 create_longjmp_breakpoint ("_longjmp");
5965 create_longjmp_breakpoint ("siglongjmp");
5966 create_longjmp_breakpoint ("_siglongjmp");
5967 create_longjmp_breakpoint (NULL);
5971 /* Took this out (temporarily at least), since it produces an extra
5972 blank line at startup. This messes up the gdbtests. -PB */
5973 /* Blank line to finish off all those mention() messages we just printed. */
5974 printf_filtered ("\n");
5978 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
5979 If from_tty is nonzero, it prints a message to that effect,
5980 which ends with a period (no newline). */
5982 /* Reset the thread number of this breakpoint:
5984 - If the breakpoint is for all threads, leave it as-is.
5985 - Else, reset it to the current thread for inferior_pid. */
5987 breakpoint_re_set_thread (b)
5988 struct breakpoint * b;
5990 if (b->thread != -1)
5992 if (in_thread_list (inferior_pid))
5993 b->thread = pid_to_thread_id (inferior_pid);
5998 set_ignore_count (bptnum, count, from_tty)
5999 int bptnum, count, from_tty;
6001 register struct breakpoint *b;
6007 if (b->number == bptnum)
6009 b->ignore_count = count;
6012 else if (count == 0)
6013 printf_filtered ("Will stop next time breakpoint %d is reached.",
6015 else if (count == 1)
6016 printf_filtered ("Will ignore next crossing of breakpoint %d.",
6019 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
6021 breakpoints_changed ();
6025 error ("No breakpoint number %d.", bptnum);
6028 /* Clear the ignore counts of all breakpoints. */
6030 breakpoint_clear_ignore_counts ()
6032 struct breakpoint *b;
6035 b->ignore_count = 0;
6038 /* Command to set ignore-count of breakpoint N to COUNT. */
6041 ignore_command (args, from_tty)
6049 error_no_arg ("a breakpoint number");
6051 num = get_number (&p);
6054 error ("Second argument (specified ignore-count) is missing.");
6056 set_ignore_count (num,
6057 longest_to_int (value_as_long (parse_and_eval (p))),
6059 printf_filtered ("\n");
6060 breakpoints_changed ();
6063 /* Call FUNCTION on each of the breakpoints
6064 whose numbers are given in ARGS. */
6067 map_breakpoint_numbers (args, function)
6069 void (*function) PARAMS ((struct breakpoint *));
6071 register char *p = args;
6074 register struct breakpoint *b;
6077 error_no_arg ("one or more breakpoint numbers");
6083 num = get_number (&p1);
6086 if (b->number == num)
6088 struct breakpoint *related_breakpoint = b->related_breakpoint;
6090 if (related_breakpoint)
6091 function (related_breakpoint);
6094 printf_unfiltered ("No breakpoint number %d.\n", num);
6101 disable_breakpoint (bpt)
6102 struct breakpoint *bpt;
6104 /* Never disable a watchpoint scope breakpoint; we want to
6105 hit them when we leave scope so we can delete both the
6106 watchpoint and its scope breakpoint at that time. */
6107 if (bpt->type == bp_watchpoint_scope)
6110 bpt->enable = disabled;
6112 check_duplicates (bpt->address, bpt->section);
6114 if (modify_breakpoint_hook)
6115 modify_breakpoint_hook (bpt);
6120 disable_command (args, from_tty)
6124 register struct breakpoint *bpt;
6126 ALL_BREAKPOINTS (bpt)
6130 warning ("attempted to disable apparently deleted breakpoint #%d?\n", bpt->number);
6134 case bp_catch_unload:
6136 case bp_catch_vfork:
6138 case bp_catch_catch:
6139 case bp_catch_throw:
6140 case bp_hardware_breakpoint:
6142 case bp_hardware_watchpoint:
6143 case bp_read_watchpoint:
6144 case bp_access_watchpoint:
6145 disable_breakpoint (bpt);
6150 map_breakpoint_numbers (args, disable_breakpoint);
6154 do_enable_breakpoint (bpt, disposition)
6155 struct breakpoint *bpt;
6156 enum bpdisp disposition;
6158 struct frame_info *save_selected_frame = NULL;
6159 int save_selected_frame_level = -1;
6160 int target_resources_ok, other_type_used;
6163 if (bpt->type == bp_hardware_breakpoint)
6166 i = hw_breakpoint_used_count();
6167 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
6168 bp_hardware_breakpoint, i+1, 0);
6169 if (target_resources_ok == 0)
6170 error ("No hardware breakpoint support in the target.");
6171 else if (target_resources_ok < 0)
6172 error ("Hardware breakpoints used exceeds limit.");
6175 bpt->enable = enabled;
6176 bpt->disposition = disposition;
6177 check_duplicates (bpt->address, bpt->section);
6178 breakpoints_changed ();
6180 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
6181 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
6183 if (bpt->exp_valid_block != NULL)
6185 struct frame_info *fr =
6187 /* Ensure that we have the current frame. Else, this
6188 next query may pessimistically be answered as, "No,
6189 not within current scope". */
6190 get_current_frame ();
6191 fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
6195 Cannot enable watchpoint %d because the block in which its expression\n\
6196 is valid is not currently in scope.\n", bpt->number);
6197 bpt->enable = disabled;
6201 save_selected_frame = selected_frame;
6202 save_selected_frame_level = selected_frame_level;
6203 select_frame (fr, -1);
6206 value_free (bpt->val);
6207 mark = value_mark ();
6208 bpt->val = evaluate_expression (bpt->exp);
6209 release_value (bpt->val);
6210 if (VALUE_LAZY (bpt->val))
6211 value_fetch_lazy (bpt->val);
6213 if (bpt->type == bp_hardware_watchpoint ||
6214 bpt->type == bp_read_watchpoint ||
6215 bpt->type == bp_access_watchpoint)
6217 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
6218 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
6220 /* Hack around 'unused var' error for some targets here */
6222 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
6223 bpt->type, i + mem_cnt, other_type_used);
6224 /* we can consider of type is bp_hardware_watchpoint, convert to
6225 bp_watchpoint in the following condition */
6226 if (target_resources_ok < 0)
6229 Cannot enable watchpoint %d because target watch resources\n\
6230 have been allocated for other watchpoints.\n", bpt->number);
6231 bpt->enable = disabled;
6232 value_free_to_mark (mark);
6237 if (save_selected_frame_level >= 0)
6238 select_and_print_frame (save_selected_frame, save_selected_frame_level);
6239 value_free_to_mark (mark);
6241 if (modify_breakpoint_hook)
6242 modify_breakpoint_hook (bpt);
6246 enable_breakpoint (bpt)
6247 struct breakpoint *bpt;
6249 do_enable_breakpoint (bpt, bpt->disposition);
6252 /* The enable command enables the specified breakpoints (or all defined
6253 breakpoints) so they once again become (or continue to be) effective
6254 in stopping the inferior. */
6258 enable_command (args, from_tty)
6262 register struct breakpoint *bpt;
6264 ALL_BREAKPOINTS (bpt)
6268 warning ("attempted to enable apparently deleted breakpoint #%d?\n", bpt->number);
6272 case bp_catch_unload:
6274 case bp_catch_vfork:
6276 case bp_catch_catch:
6277 case bp_catch_throw:
6278 case bp_hardware_breakpoint:
6280 case bp_hardware_watchpoint:
6281 case bp_read_watchpoint:
6282 case bp_access_watchpoint:
6283 enable_breakpoint (bpt);
6288 map_breakpoint_numbers (args, enable_breakpoint);
6292 enable_once_breakpoint (bpt)
6293 struct breakpoint *bpt;
6295 do_enable_breakpoint (bpt, disable);
6300 enable_once_command (args, from_tty)
6304 map_breakpoint_numbers (args, enable_once_breakpoint);
6308 enable_delete_breakpoint (bpt)
6309 struct breakpoint *bpt;
6311 do_enable_breakpoint (bpt, del);
6316 enable_delete_command (args, from_tty)
6320 map_breakpoint_numbers (args, enable_delete_breakpoint);
6323 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6325 struct symtabs_and_lines
6326 decode_line_spec_1 (string, funfirstline)
6330 struct symtabs_and_lines sals;
6332 error ("Empty line specification.");
6333 if (default_breakpoint_valid)
6334 sals = decode_line_1 (&string, funfirstline,
6335 default_breakpoint_symtab, default_breakpoint_line,
6338 sals = decode_line_1 (&string, funfirstline,
6339 (struct symtab *)NULL, 0, (char ***)NULL);
6341 error ("Junk at end of line specification: %s", string);
6346 _initialize_breakpoint ()
6348 struct cmd_list_element *c;
6350 breakpoint_chain = 0;
6351 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6352 before a breakpoint is set. */
6353 breakpoint_count = 0;
6355 add_com ("ignore", class_breakpoint, ignore_command,
6356 "Set ignore-count of breakpoint number N to COUNT.\n\
6357 Usage is `ignore N COUNT'.");
6359 add_com_alias("bc", "ignore", class_breakpoint, 1);
6361 add_com ("commands", class_breakpoint, commands_command,
6362 "Set commands to be executed when a breakpoint is hit.\n\
6363 Give breakpoint number as argument after \"commands\".\n\
6364 With no argument, the targeted breakpoint is the last one set.\n\
6365 The commands themselves follow starting on the next line.\n\
6366 Type a line containing \"end\" to indicate the end of them.\n\
6367 Give \"silent\" as the first line to make the breakpoint silent;\n\
6368 then no output is printed when it is hit, except what the commands print.");
6370 add_com ("condition", class_breakpoint, condition_command,
6371 "Specify breakpoint number N to break only if COND is true.\n\
6372 Usage is `condition N COND', where N is an integer and COND is an\n\
6373 expression to be evaluated whenever breakpoint N is reached. ");
6375 add_com ("tbreak", class_breakpoint, tbreak_command,
6376 "Set a temporary breakpoint. Args like \"break\" command.\n\
6377 Like \"break\" except the breakpoint is only temporary,\n\
6378 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6379 by using \"enable delete\" on the breakpoint number.");
6380 add_com("txbreak", class_breakpoint, tbreak_at_finish_command,
6381 "Set temporary breakpoint at procedure exit. Either there should\n\
6382 be no argument or the argument must be a depth.\n");
6384 add_com ("hbreak", class_breakpoint, hbreak_command,
6385 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6386 Like \"break\" except the breakpoint requires hardware support,\n\
6387 some target hardware may not have this support.");
6389 add_com ("thbreak", class_breakpoint, thbreak_command,
6390 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6391 Like \"hbreak\" except the breakpoint is only temporary,\n\
6392 so it will be deleted when hit.");
6394 add_prefix_cmd ("enable", class_breakpoint, enable_command,
6395 "Enable some breakpoints.\n\
6396 Give breakpoint numbers (separated by spaces) as arguments.\n\
6397 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6398 This is used to cancel the effect of the \"disable\" command.\n\
6399 With a subcommand you can enable temporarily.",
6400 &enablelist, "enable ", 1, &cmdlist);
6402 add_com("ab", class_breakpoint, enable_command,
6403 "Enable some breakpoints.\n\
6404 Give breakpoint numbers (separated by spaces) as arguments.\n\
6405 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6406 This is used to cancel the effect of the \"disable\" command.\n\
6407 With a subcommand you can enable temporarily.");
6409 add_com_alias ("en", "enable", class_breakpoint, 1);
6411 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
6412 "Enable some breakpoints.\n\
6413 Give breakpoint numbers (separated by spaces) as arguments.\n\
6414 This is used to cancel the effect of the \"disable\" command.\n\
6415 May be abbreviated to simply \"enable\".\n",
6416 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
6418 add_cmd ("once", no_class, enable_once_command,
6419 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6420 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6423 add_cmd ("delete", no_class, enable_delete_command,
6424 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6425 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6428 add_cmd ("delete", no_class, enable_delete_command,
6429 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6430 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6433 add_cmd ("once", no_class, enable_once_command,
6434 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6435 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6438 add_prefix_cmd ("disable", class_breakpoint, disable_command,
6439 "Disable some breakpoints.\n\
6440 Arguments are breakpoint numbers with spaces in between.\n\
6441 To disable all breakpoints, give no argument.\n\
6442 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6443 &disablelist, "disable ", 1, &cmdlist);
6444 add_com_alias ("dis", "disable", class_breakpoint, 1);
6445 add_com_alias ("disa", "disable", class_breakpoint, 1);
6447 add_com("sb", class_breakpoint, disable_command,
6448 "Disable some breakpoints.\n\
6449 Arguments are breakpoint numbers with spaces in between.\n\
6450 To disable all breakpoints, give no argument.\n\
6451 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6453 add_cmd ("breakpoints", class_alias, disable_command,
6454 "Disable some breakpoints.\n\
6455 Arguments are breakpoint numbers with spaces in between.\n\
6456 To disable all breakpoints, give no argument.\n\
6457 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6458 This command may be abbreviated \"disable\".",
6461 add_prefix_cmd ("delete", class_breakpoint, delete_command,
6462 "Delete some breakpoints or auto-display expressions.\n\
6463 Arguments are breakpoint numbers with spaces in between.\n\
6464 To delete all breakpoints, give no argument.\n\
6466 Also a prefix command for deletion of other GDB objects.\n\
6467 The \"unset\" command is also an alias for \"delete\".",
6468 &deletelist, "delete ", 1, &cmdlist);
6469 add_com_alias ("d", "delete", class_breakpoint, 1);
6471 add_com ("db", class_breakpoint, delete_command,
6472 "Delete some breakpoints.\n\
6473 Arguments are breakpoint numbers with spaces in between.\n\
6474 To delete all breakpoints, give no argument.\n");
6476 add_cmd ("breakpoints", class_alias, delete_command,
6477 "Delete some breakpoints or auto-display expressions.\n\
6478 Arguments are breakpoint numbers with spaces in between.\n\
6479 To delete all breakpoints, give no argument.\n\
6480 This command may be abbreviated \"delete\".",
6483 add_com ("clear", class_breakpoint, clear_command,
6484 concat ("Clear breakpoint at specified line or function.\n\
6485 Argument may be line number, function name, or \"*\" and an address.\n\
6486 If line number is specified, all breakpoints in that line are cleared.\n\
6487 If function is specified, breakpoints at beginning of function are cleared.\n\
6488 If an address is specified, breakpoints at that address are cleared.\n\n",
6489 "With no argument, clears all breakpoints in the line that the selected frame\n\
6492 See also the \"delete\" command which clears breakpoints by number.", NULL));
6494 add_com ("break", class_breakpoint, break_command,
6495 concat ("Set breakpoint at specified line or function.\n\
6496 Argument may be line number, function name, or \"*\" and an address.\n\
6497 If line number is specified, break at start of code for that line.\n\
6498 If function is specified, break at start of code for that function.\n\
6499 If an address is specified, break at that exact address.\n",
6500 "With no arg, uses current execution address of selected stack frame.\n\
6501 This is useful for breaking on return to a stack frame.\n\
6503 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6505 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6506 add_com_alias ("b", "break", class_run, 1);
6507 add_com_alias ("br", "break", class_run, 1);
6508 add_com_alias ("bre", "break", class_run, 1);
6509 add_com_alias ("brea", "break", class_run, 1);
6511 add_com("xbreak", class_breakpoint, break_at_finish_command,
6512 concat("Set breakpoint at procedure exit. \n\
6513 Argument may be function name, or \"*\" and an address.\n\
6514 If function is specified, break at end of code for that function.\n\
6515 If an address is specified, break at the end of the function that contains \n\
6516 that exact address.\n",
6517 "With no arg, uses current execution address of selected stack frame.\n\
6518 This is useful for breaking on return to a stack frame.\n\
6520 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6522 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6523 add_com_alias ("xb", "xbreak", class_breakpoint, 1);
6524 add_com_alias ("xbr", "xbreak", class_breakpoint, 1);
6525 add_com_alias ("xbre", "xbreak", class_breakpoint, 1);
6526 add_com_alias ("xbrea", "xbreak", class_breakpoint, 1);
6530 add_com_alias ("ba", "break", class_breakpoint, 1);
6531 add_com_alias ("bu", "ubreak", class_breakpoint, 1);
6532 add_com ("bx", class_breakpoint, break_at_finish_at_depth_command,
6533 "Set breakpoint at procedure exit. Either there should\n\
6534 be no argument or the argument must be a depth.\n");
6539 add_abbrev_prefix_cmd("stop", class_breakpoint, stop_command,
6540 "Break in function/address or break at a line in the current file.",
6541 &stoplist, "stop ", 1, &cmdlist);
6542 add_cmd("in", class_breakpoint, stopin_command,
6543 "Break in function or address.\n", &stoplist);
6544 add_cmd("at", class_breakpoint, stopat_command,
6545 "Break at a line in the current file.\n", &stoplist);
6546 add_com("status", class_info, breakpoints_info,
6547 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6548 The \"Type\" column indicates one of:\n\
6549 \tbreakpoint - normal breakpoint\n\
6550 \twatchpoint - watchpoint\n\
6551 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6552 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6553 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6554 address and file/line number respectively.\n\n",
6555 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6556 are set to the address of the last breakpoint listed.\n\n\
6557 Convenience variable \"$bpnum\" contains the number of the last\n\
6558 breakpoint set.", NULL));
6561 add_info ("breakpoints", breakpoints_info,
6562 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6563 The \"Type\" column indicates one of:\n\
6564 \tbreakpoint - normal breakpoint\n\
6565 \twatchpoint - watchpoint\n\
6566 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6567 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6568 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6569 address and file/line number respectively.\n\n",
6570 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6571 are set to the address of the last breakpoint listed.\n\n\
6572 Convenience variable \"$bpnum\" contains the number of the last\n\
6573 breakpoint set.", NULL));
6576 add_com("lb", class_breakpoint, breakpoints_info,
6577 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6578 The \"Type\" column indicates one of:\n\
6579 \tbreakpoint - normal breakpoint\n\
6580 \twatchpoint - watchpoint\n\
6581 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6582 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6583 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6584 address and file/line number respectively.\n\n",
6585 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6586 are set to the address of the last breakpoint listed.\n\n\
6587 Convenience variable \"$bpnum\" contains the number of the last\n\
6588 breakpoint set.", NULL));
6590 #if MAINTENANCE_CMDS
6592 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
6593 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6594 The \"Type\" column indicates one of:\n\
6595 \tbreakpoint - normal breakpoint\n\
6596 \twatchpoint - watchpoint\n\
6597 \tlongjmp - internal breakpoint used to step through longjmp()\n\
6598 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
6599 \tuntil - internal breakpoint used by the \"until\" command\n\
6600 \tfinish - internal breakpoint used by the \"finish\" command\n",
6601 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6602 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6603 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6604 address and file/line number respectively.\n\n",
6605 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6606 are set to the address of the last breakpoint listed.\n\n\
6607 Convenience variable \"$bpnum\" contains the number of the last\n\
6608 breakpoint set.", NULL),
6609 &maintenanceinfolist);
6611 #endif /* MAINTENANCE_CMDS */
6613 add_com ("catch", class_breakpoint, catch_command,
6614 "Set catchpoints to catch events.\n\
6615 Raised signals may be caught:\n\
6616 \tcatch signal - all signals\n\
6617 \tcatch signal <signame> - a particular signal\n\
6618 Raised exceptions may be caught:\n\
6619 \tcatch throw - all exceptions, when thrown\n\
6620 \tcatch throw <exceptname> - a particular exception, when thrown\n\
6621 \tcatch catch - all exceptions, when caught\n\
6622 \tcatch catch <exceptname> - a particular exception, when caught\n\
6623 Thread or process events may be caught:\n\
6624 \tcatch thread_start - any threads, just after creation\n\
6625 \tcatch thread_exit - any threads, just before expiration\n\
6626 \tcatch thread_join - any threads, just after joins\n\
6627 Process events may be caught:\n\
6628 \tcatch start - any processes, just after creation\n\
6629 \tcatch exit - any processes, just before expiration\n\
6630 \tcatch fork - calls to fork()\n\
6631 \tcatch vfork - calls to vfork()\n\
6632 \tcatch exec - calls to exec()\n\
6633 Dynamically-linked library events may be caught:\n\
6634 \tcatch load - loads of any library\n\
6635 \tcatch load <libname> - loads of a particular library\n\
6636 \tcatch unload - unloads of any library\n\
6637 \tcatch unload <libname> - unloads of a particular library\n\
6638 The act of your program's execution stopping may also be caught:\n\
6640 C++ exceptions may be caught:\n\
6641 \tcatch throw - all exceptions, when thrown\n\
6642 \tcatch catch - all exceptions, when caught\n\
6644 Do \"help set follow-fork-mode\" for info on debugging your program\n\
6645 after a fork or vfork is caught.\n\n\
6646 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
6648 add_com ("tcatch", class_breakpoint, tcatch_command,
6649 "Set temporary catchpoints to catch events.\n\
6650 Args like \"catch\" command.\n\
6651 Like \"catch\" except the catchpoint is only temporary,\n\
6652 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
6653 by using \"enable delete\" on the catchpoint number.");
6655 add_com ("watch", class_breakpoint, watch_command,
6657 "Set a watchpoint for an expression.\n\
6658 A watchpoint stops execution of your program whenever the value of\n\
6659 an expression changes.");
6661 add_com ("rwatch", class_breakpoint, rwatch_command,
6662 "Set a read watchpoint for an expression.\n\
6663 A watchpoint stops execution of your program whenever the value of\n\
6664 an expression is read.");
6666 add_com ("awatch", class_breakpoint, awatch_command,
6667 "Set a watchpoint for an expression.\n\
6668 A watchpoint stops execution of your program whenever the value of\n\
6669 an expression is either read or written.");
6671 add_info ("watchpoints", breakpoints_info,
6672 "Synonym for ``info breakpoints''.");
6675 c = add_set_cmd ("can-use-hw-watchpoints", class_support, var_zinteger,
6676 (char *) &can_use_hw_watchpoints,
6677 "Set debugger's willingness to use watchpoint hardware.\n\
6678 If zero, gdb will not use hardware for new watchpoints, even if\n\
6679 such is available. (However, any hardware watchpoints that were\n\
6680 created before setting this to nonzero, will continue to use watchpoint\n\
6683 add_show_from_set (c, &showlist);
6685 can_use_hw_watchpoints = 1;