1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
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;
257 /* Set breakpoint count to NUM. */
260 set_breakpoint_count (num)
263 breakpoint_count = num;
264 set_internalvar (lookup_internalvar ("bpnum"),
265 value_from_longest (builtin_type_int, (LONGEST) num));
268 /* Used in run_command to zero the hit count when a new run starts. */
271 clear_breakpoint_hit_counts ()
273 struct breakpoint *b;
279 /* Default address, symtab and line to put a breakpoint at
280 for "break" command with no arg.
281 if default_breakpoint_valid is zero, the other three are
282 not valid, and "break" with no arg is an error.
284 This set by print_stack_frame, which calls set_default_breakpoint. */
286 int default_breakpoint_valid;
287 CORE_ADDR default_breakpoint_address;
288 struct symtab *default_breakpoint_symtab;
289 int default_breakpoint_line;
291 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
292 Advance *PP after the string and any trailing whitespace.
294 Currently the string can either be a number or "$" followed by the name
295 of a convenience variable. Making it an expression wouldn't work well
296 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
305 /* Empty line means refer to the last breakpoint. */
306 return breakpoint_count;
309 /* Make a copy of the name, so we can null-terminate it
310 to pass to lookup_internalvar(). */
315 while (isalnum (*p) || *p == '_')
317 varname = (char *) alloca (p - start + 1);
318 strncpy (varname, start, p - start);
319 varname[p - start] = '\0';
320 val = value_of_internalvar (lookup_internalvar (varname));
321 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
323 "Convenience variables used to specify breakpoints must have integer values."
325 retval = (int) value_as_long (val);
331 while (*p >= '0' && *p <= '9')
334 /* There is no number here. (e.g. "cond a == b"). */
335 error_no_arg ("breakpoint number");
338 if (!(isspace (*p) || *p == '\0'))
339 error ("breakpoint number expected");
346 /* condition N EXP -- set break condition of breakpoint N to EXP. */
349 condition_command (arg, from_tty)
353 register struct breakpoint *b;
358 error_no_arg ("breakpoint number");
361 bnum = get_number (&p);
364 if (b->number == bnum)
371 if (b->cond_string != NULL)
372 free ((PTR)b->cond_string);
377 b->cond_string = NULL;
379 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
384 /* I don't know if it matters whether this is the string the user
385 typed in or the decompiled expression. */
386 b->cond_string = savestring (arg, strlen (arg));
387 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
389 error ("Junk at end of expression");
391 breakpoints_changed ();
395 error ("No breakpoint number %d.", bnum);
400 commands_command (arg, from_tty)
404 register struct breakpoint *b;
407 struct command_line *l;
409 /* If we allowed this, we would have problems with when to
410 free the storage, if we change the commands currently
413 if (executing_breakpoint_commands)
414 error ("Can't use the \"commands\" command among a breakpoint's commands.");
417 bnum = get_number (&p);
419 error ("Unexpected extra arguments following breakpoint number.");
422 if (b->number == bnum)
425 sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum);
426 l = read_command_lines (tmpbuf, from_tty);
427 free_command_lines (&b->commands);
429 breakpoints_changed ();
432 error ("No breakpoint number %d.", bnum);
435 /* Like target_read_memory() but if breakpoints are inserted, return
436 the shadow contents instead of the breakpoints themselves.
438 Read "memory data" from whatever target or inferior we have.
439 Returns zero if successful, errno value if not. EIO is used
440 for address out of bounds. If breakpoints are inserted, returns
441 shadow contents, not the breakpoints themselves. From breakpoint.c. */
444 read_memory_nobpt (memaddr, myaddr, len)
450 struct breakpoint *b;
451 CORE_ADDR bp_addr = 0;
454 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
455 /* No breakpoints on this machine. */
456 return target_read_memory (memaddr, myaddr, len);
460 if (b->type == bp_none)
461 warning ("attempted to read through apparently deleted breakpoint #%d?\n", b->number);
463 /* memory breakpoint? */
464 if (b->type == bp_watchpoint
465 || b->type == bp_hardware_watchpoint
466 || b->type == bp_read_watchpoint
467 || b->type == bp_access_watchpoint)
472 /* Addresses and length of the part of the breakpoint that
474 /* XXXX The m68k, sh and h8300 have different local and remote
475 breakpoint values. BREAKPOINT_FROM_PC still manages to
476 correctly determine the breakpoints memory address and size
477 for these targets. */
478 bp_addr = b->address;
480 if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
485 if (bp_addr + bp_size <= memaddr)
486 /* The breakpoint is entirely before the chunk of memory we
489 if (bp_addr >= memaddr + len)
490 /* The breakpoint is entirely after the chunk of memory we are
493 /* Copy the breakpoint from the shadow contents, and recurse for
494 the things before and after. */
496 /* Offset within shadow_contents. */
499 if (bp_addr < memaddr)
501 /* Only copy the second part of the breakpoint. */
502 bp_size -= memaddr - bp_addr;
503 bptoffset = memaddr - bp_addr;
507 if (bp_addr + bp_size > memaddr + len)
509 /* Only copy the first part of the breakpoint. */
510 bp_size -= (bp_addr + bp_size) - (memaddr + len);
513 memcpy (myaddr + bp_addr - memaddr,
514 b->shadow_contents + bptoffset, bp_size);
516 if (bp_addr > memaddr)
518 /* Copy the section of memory before the breakpoint. */
519 status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr);
524 if (bp_addr + bp_size < memaddr + len)
526 /* Copy the section of memory after the breakpoint. */
527 status = read_memory_nobpt
529 myaddr + bp_addr + bp_size - memaddr,
530 memaddr + len - (bp_addr + bp_size));
537 /* Nothing overlaps. Just call read_memory_noerr. */
538 return target_read_memory (memaddr, myaddr, len);
542 /* insert_breakpoints is used when starting or continuing the program.
543 remove_breakpoints is used when the program stops.
544 Both return zero if successful,
545 or an `errno' value if could not write the inferior. */
548 insert_breakpoints ()
550 register struct breakpoint *b, *temp;
552 int disabled_breaks = 0;
554 static char message1[] = "Error inserting catchpoint %d:\n";
555 static char message[sizeof (message1) + 30];
558 ALL_BREAKPOINTS_SAFE (b, temp)
560 if (b->type != bp_watchpoint
561 && b->type != bp_hardware_watchpoint
562 && b->type != bp_read_watchpoint
563 && b->type != bp_access_watchpoint
564 && b->type != bp_catch_fork
565 && b->type != bp_catch_vfork
566 && b->type != bp_catch_exec
567 && b->type != bp_catch_throw
568 && b->type != bp_catch_catch
569 && b->enable != disabled
570 && b->enable != shlib_disabled
571 && b->enable != call_disabled
575 if (b->type == bp_hardware_breakpoint)
576 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
579 /* Check to see if breakpoint is in an overlay section;
580 if so, we should set the breakpoint at the LMA address.
581 Only if the section is currently mapped should we ALSO
582 set a break at the VMA address. */
583 if (overlay_debugging && b->section &&
584 section_is_overlay (b->section))
588 addr = overlay_unmapped_address (b->address, b->section);
589 val = target_insert_breakpoint (addr, b->shadow_contents);
590 /* This would be the time to check val, to see if the
591 breakpoint write to the load address succeeded.
592 However, this might be an ordinary occurrance, eg. if
593 the unmapped overlay is in ROM. */
594 val = 0; /* in case unmapped address failed */
595 if (section_is_mapped (b->section))
596 val = target_insert_breakpoint (b->address,
599 else /* ordinary (non-overlay) address */
600 val = target_insert_breakpoint(b->address, b->shadow_contents);
604 /* Can't set the breakpoint. */
605 #if defined (DISABLE_UNSETTABLE_BREAK)
606 if (DISABLE_UNSETTABLE_BREAK (b->address))
608 /* See also: disable_breakpoints_in_shlibs. */
610 b->enable = shlib_disabled;
611 if (!disabled_breaks)
613 target_terminal_ours_for_output ();
614 fprintf_unfiltered (gdb_stderr,
615 "Cannot insert breakpoint %d:\n", b->number);
616 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
619 printf_filtered ("%d ", b->number);
624 target_terminal_ours_for_output ();
625 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
626 #ifdef ONE_PROCESS_WRITETEXT
627 fprintf_unfiltered (gdb_stderr,
628 "The same program may be running in another process.\n");
630 memory_error (val, b->address); /* which bombs us out */
636 else if (ep_is_exception_catchpoint (b)
637 && b->enable != disabled
638 && b->enable != shlib_disabled
639 && b->enable != call_disabled
644 /* If we get here, we must have a callback mechanism for exception
645 events -- with g++ style embedded label support, we insert
646 ordinary breakpoints and not catchpoints. */
647 sprintf (message, message1, b->number); /* Format possible error message */
649 val = target_insert_breakpoint(b->address, b->shadow_contents);
652 /* Couldn't set breakpoint for some reason */
653 target_terminal_ours_for_output ();
654 fprintf_unfiltered (gdb_stderr,
655 "Cannot insert catchpoint %d; disabling it\n", b->number);
656 b->enable = disabled;
660 /* Bp set, now make sure callbacks are enabled */
662 args_for_catchpoint_enable args;
663 args.kind = b->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
665 val = catch_errors (cover_target_enable_exception_callback,
667 message, RETURN_MASK_ALL);
668 if (val != 0 && val != -1)
672 /* Check if something went wrong; val == 0 can be ignored */
675 /* something went wrong */
676 target_terminal_ours_for_output ();
677 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d; disabling it\n", b->number);
678 b->enable = disabled;
683 else if ((b->type == bp_hardware_watchpoint ||
684 b->type == bp_read_watchpoint ||
685 b->type == bp_access_watchpoint)
686 && b->enable == enabled
690 struct frame_info *saved_frame;
691 int saved_level, within_current_scope;
692 value_ptr mark = value_mark ();
695 /* Save the current frame and level so we can restore it after
696 evaluating the watchpoint expression on its own frame. */
697 saved_frame = selected_frame;
698 saved_level = selected_frame_level;
700 /* Determine if the watchpoint is within scope. */
701 if (b->exp_valid_block == NULL)
702 within_current_scope = 1;
705 struct frame_info *fi;
707 /* There might be no current frame at this moment if we are
708 resuming from a step over a breakpoint.
709 Set up current frame before trying to find the watchpoint
711 get_current_frame ();
712 fi = find_frame_addr_in_frame_chain (b->watchpoint_frame);
713 within_current_scope = (fi != NULL);
714 if (within_current_scope)
715 select_frame (fi, -1);
718 if (within_current_scope)
720 /* Evaluate the expression and cut the chain of values
721 produced off from the value chain. */
722 v = evaluate_expression (b->exp);
723 value_release_to_mark (mark);
728 /* Look at each value on the value chain. */
729 for ( ; v; v=v->next)
731 /* If it's a memory location, then we must watch it. */
732 if (v->lval == lval_memory)
736 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
737 len = TYPE_LENGTH (VALUE_TYPE (v));
739 if (b->type == bp_read_watchpoint)
741 else if (b->type == bp_access_watchpoint)
744 val = target_insert_watchpoint (addr, len, type);
753 /* Failure to insert a watchpoint on any memory value in the
754 value chain brings us here. */
756 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
762 Hardware watchpoint %d deleted because the program has left the block in\n\
763 which its expression is valid.\n", b->number);
764 if (b->related_breakpoint)
765 b->related_breakpoint->disposition = del_at_next_stop;
766 b->disposition = del_at_next_stop;
769 /* Restore the frame and level. */
770 if ((saved_frame != selected_frame) ||
771 (saved_level != selected_frame_level))
772 select_and_print_frame (saved_frame, saved_level);
774 else if ((b->type == bp_catch_fork
775 || b->type == bp_catch_vfork
776 || b->type == bp_catch_exec)
777 && b->enable == enabled
785 val = target_insert_fork_catchpoint (inferior_pid);
787 case bp_catch_vfork :
788 val = target_insert_vfork_catchpoint (inferior_pid);
791 val = target_insert_exec_catchpoint (inferior_pid);
796 target_terminal_ours_for_output ();
797 fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d:\n", b->number);
804 printf_filtered ("\n");
811 remove_breakpoints ()
813 register struct breakpoint *b;
820 val = remove_breakpoint (b, mark_uninserted);
829 reattach_breakpoints (pid)
832 register struct breakpoint *b;
834 int saved_inferior_pid = inferior_pid;
836 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
841 remove_breakpoint (b, mark_inserted);
842 if (b->type == bp_hardware_breakpoint)
843 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
845 val = target_insert_breakpoint(b->address, b->shadow_contents);
848 inferior_pid = saved_inferior_pid;
853 inferior_pid = saved_inferior_pid;
858 update_breakpoints_after_exec ()
860 struct breakpoint * b;
861 struct breakpoint * temp;
863 /* Doing this first prevents the badness of having delete_breakpoint()
864 write a breakpoint's current "shadow contents" to lift the bp. That
865 shadow is NOT valid after an exec()! */
866 mark_breakpoints_out ();
868 ALL_BREAKPOINTS_SAFE (b, temp)
870 /* Solib breakpoints must be explicitly reset after an exec(). */
871 if (b->type == bp_shlib_event)
873 delete_breakpoint (b);
877 /* Step-resume breakpoints are meaningless after an exec(). */
878 if (b->type == bp_step_resume)
880 delete_breakpoint (b);
884 /* Ditto the sigtramp handler breakpoints. */
885 if (b->type == bp_through_sigtramp)
887 delete_breakpoint (b);
891 /* Ditto the exception-handling catchpoints. */
892 if ((b->type == bp_catch_catch) || (b->type == bp_catch_throw))
894 delete_breakpoint (b);
898 /* Don't delete an exec catchpoint, because else the inferior
899 won't stop when it ought!
901 Similarly, we probably ought to keep vfork catchpoints, 'cause
902 on this target, we may not be able to stop when the vfork is seen,
903 but only when the subsequent exec is seen. (And because deleting
904 fork catchpoints here but not vfork catchpoints will seem mysterious
905 to users, keep those too.)
907 ??rehrauer: Let's hope that merely clearing out this catchpoint's
908 target address field, if any, is sufficient to have it be reset
909 automagically. Certainly on HP-UX that's true. */
910 if ((b->type == bp_catch_exec) ||
911 (b->type == bp_catch_vfork) ||
912 (b->type == bp_catch_fork))
914 b->address = (CORE_ADDR) NULL;
918 /* bp_finish is a special case. The only way we ought to be able
919 to see one of these when an exec() has happened, is if the user
920 caught a vfork, and then said "finish". Ordinarily a finish just
921 carries them to the call-site of the current callee, by setting
922 a temporary bp there and resuming. But in this case, the finish
923 will carry them entirely through the vfork & exec.
925 We don't want to allow a bp_finish to remain inserted now. But
926 we can't safely delete it, 'cause finish_command has a handle to
927 the bp on a bpstat, and will later want to delete it. There's a
928 chance (and I've seen it happen) that if we delete the bp_finish
929 here, that its storage will get reused by the time finish_command
930 gets 'round to deleting the "use to be a bp_finish" breakpoint.
931 We really must allow finish_command to delete a bp_finish.
933 In the absense of a general solution for the "how do we know it's
934 safe to delete something others may have handles to?" problem, what
935 we'll do here is just uninsert the bp_finish, and let finish_command
938 (We know the bp_finish is "doomed" in the sense that it's momentary,
939 and will be deleted as soon as finish_command sees the inferior stopped.
940 So it doesn't matter that the bp's address is probably bogus in the
941 new a.out, unlike e.g., the solib breakpoints.) */
942 if (b->type == bp_finish)
947 /* Without a symbolic address, we have little hope of the
948 pre-exec() address meaning the same thing in the post-exec()
950 if (b->addr_string == NULL)
952 delete_breakpoint (b);
956 /* If this breakpoint has survived the above battery of checks, then
957 it must have a symbolic address. Be sure that it gets reevaluated
958 to a target address, rather than reusing the old evaluation. */
959 b->address = (CORE_ADDR) NULL;
964 detach_breakpoints (pid)
967 register struct breakpoint *b;
969 int saved_inferior_pid = inferior_pid;
971 if (pid == inferior_pid)
972 error ("Cannot detach breakpoints of inferior_pid");
974 inferior_pid = pid; /* Because remove_breakpoint will use this global. */
979 val = remove_breakpoint (b, mark_inserted);
982 inferior_pid = saved_inferior_pid;
987 inferior_pid = saved_inferior_pid;
992 remove_breakpoint (b, is)
993 struct breakpoint *b;
994 insertion_state_t is;
998 if (b->type == bp_none)
999 warning ("attempted to remove apparently deleted breakpoint #%d?\n", b->number);
1001 if (b->type != bp_watchpoint
1002 && b->type != bp_hardware_watchpoint
1003 && b->type != bp_read_watchpoint
1004 && b->type != bp_access_watchpoint
1005 && b->type != bp_catch_fork
1006 && b->type != bp_catch_vfork
1007 && b->type != bp_catch_exec
1008 && b->type != bp_catch_catch
1009 && b->type != bp_catch_throw)
1012 if (b->type == bp_hardware_breakpoint)
1013 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
1016 /* Check to see if breakpoint is in an overlay section;
1017 if so, we should remove the breakpoint at the LMA address.
1018 If that is not equal to the raw address, then we should
1019 presumable remove the breakpoint there as well. */
1020 if (overlay_debugging && b->section &&
1021 section_is_overlay (b->section))
1025 addr = overlay_unmapped_address (b->address, b->section);
1026 val = target_remove_breakpoint (addr, b->shadow_contents);
1027 /* This would be the time to check val, to see if the
1028 shadow breakpoint write to the load address succeeded.
1029 However, this might be an ordinary occurrance, eg. if
1030 the unmapped overlay is in ROM. */
1031 val = 0; /* in case unmapped address failed */
1032 if (section_is_mapped (b->section))
1033 val = target_remove_breakpoint (b->address,
1034 b->shadow_contents);
1036 else /* ordinary (non-overlay) address */
1037 val = target_remove_breakpoint(b->address, b->shadow_contents);
1041 b->inserted = (is == mark_inserted);
1043 else if ((b->type == bp_hardware_watchpoint ||
1044 b->type == bp_read_watchpoint ||
1045 b->type == bp_access_watchpoint)
1046 && b->enable == enabled
1051 b->inserted = (is == mark_inserted);
1052 /* Walk down the saved value chain. */
1053 for (v = b->val_chain; v; v = v->next)
1055 /* For each memory reference remove the watchpoint
1057 if (v->lval == lval_memory)
1059 int addr, len, type;
1061 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1062 len = TYPE_LENGTH (VALUE_TYPE (v));
1064 if (b->type == bp_read_watchpoint)
1066 else if (b->type == bp_access_watchpoint)
1069 val = target_remove_watchpoint (addr, len, type);
1075 /* Failure to remove any of the hardware watchpoints comes here. */
1076 if ((is == mark_uninserted) && (b->inserted))
1077 warning ("Hardware watchpoint %d: Could not remove watchpoint\n",
1080 /* Free the saved value chain. We will construct a new one
1081 the next time the watchpoint is inserted. */
1082 for (v = b->val_chain; v; v = n)
1087 b->val_chain = NULL;
1089 else if ((b->type == bp_catch_fork ||
1090 b->type == bp_catch_vfork ||
1091 b->type == bp_catch_exec)
1092 && b->enable == enabled
1099 val = target_remove_fork_catchpoint (inferior_pid);
1101 case bp_catch_vfork :
1102 val = target_remove_vfork_catchpoint (inferior_pid);
1104 case bp_catch_exec :
1105 val = target_remove_exec_catchpoint (inferior_pid);
1110 b->inserted = (is == mark_inserted);
1112 else if ((b->type == bp_catch_catch ||
1113 b->type == bp_catch_throw)
1114 && b->enable == enabled
1118 val = target_remove_breakpoint(b->address, b->shadow_contents);
1121 b->inserted = (is == mark_inserted);
1123 else if (ep_is_exception_catchpoint (b)
1124 && b->inserted /* sometimes previous insert doesn't happen */
1125 && b->enable == enabled
1129 val = target_remove_breakpoint(b->address, b->shadow_contents);
1133 b->inserted = (is == mark_inserted);
1139 /* Clear the "inserted" flag in all breakpoints. */
1142 mark_breakpoints_out ()
1144 register struct breakpoint *b;
1150 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
1151 which should go away between runs of the program.
1153 Plus other such housekeeping that has to be done for breakpoints
1156 Note: this function gets called at the end of a run (by generic_mourn_inferior)
1157 and when a run begins (by init_wait_for_inferior). */
1162 breakpoint_init_inferior (context)
1163 enum inf_context context;
1165 register struct breakpoint *b, *temp;
1166 static int warning_needed = 0;
1168 ALL_BREAKPOINTS_SAFE (b, temp)
1175 case bp_watchpoint_scope:
1177 /* If the call dummy breakpoint is at the entry point it will
1178 cause problems when the inferior is rerun, so we better
1181 Also get rid of scope breakpoints. */
1182 delete_breakpoint (b);
1186 case bp_hardware_watchpoint:
1187 case bp_read_watchpoint:
1188 case bp_access_watchpoint:
1190 /* Likewise for watchpoints on local expressions. */
1191 if (b->exp_valid_block != NULL)
1192 delete_breakpoint (b);
1195 /* Likewise for exception catchpoints in dynamic-linked
1196 executables where required */
1197 if (ep_is_exception_catchpoint (b) &&
1198 exception_catchpoints_are_fragile)
1201 delete_breakpoint (b);
1207 if (exception_catchpoints_are_fragile)
1208 exception_support_initialized = 0;
1210 /* Don't issue the warning unless it's really needed... */
1211 if (warning_needed && (context != inf_exited))
1213 warning ("Exception catchpoints from last run were deleted, you must reinsert them explicitly");
1218 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
1219 When continuing from a location with a breakpoint,
1220 we actually single step once before calling insert_breakpoints. */
1223 breakpoint_here_p (pc)
1226 register struct breakpoint *b;
1229 if (b->enable == enabled
1230 && b->enable != shlib_disabled
1231 && b->enable != call_disabled
1232 && b->address == pc) /* bp is enabled and matches pc */
1234 if (overlay_debugging &&
1235 section_is_overlay (b->section) &&
1236 !section_is_mapped (b->section))
1237 continue; /* unmapped overlay -- can't be a match */
1245 /* breakpoint_inserted_here_p (PC) is just like breakpoint_here_p(), but it
1246 only returns true if there is actually a breakpoint inserted at PC. */
1249 breakpoint_inserted_here_p (pc)
1252 register struct breakpoint *b;
1256 && b->address == pc) /* bp is inserted and matches pc */
1258 if (overlay_debugging &&
1259 section_is_overlay (b->section) &&
1260 !section_is_mapped (b->section))
1261 continue; /* unmapped overlay -- can't be a match */
1269 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
1270 because figuring out the saved SP would take too much time, at least using
1271 get_saved_register on the 68k. This means that for this function to
1272 work right a port must use the bp_call_dummy breakpoint. */
1275 frame_in_dummy (frame)
1276 struct frame_info *frame;
1279 #ifdef USE_GENERIC_DUMMY_FRAMES
1280 return generic_pc_in_call_dummy (frame->pc, frame->frame);
1282 struct breakpoint *b;
1286 static ULONGEST dummy[] = CALL_DUMMY;
1288 if (b->type == bp_call_dummy
1289 && b->frame == frame->frame
1291 /* We need to check the PC as well as the frame on the sparc,
1292 for signals.exp in the testsuite. */
1295 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
1296 && frame->pc <= b->address)
1299 #endif /* GENERIC_DUMMY_FRAMES */
1300 #endif /* CALL_DUMMY */
1304 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
1305 is valid for process/thread PID. */
1308 breakpoint_thread_match (pc, pid)
1312 struct breakpoint *b;
1315 thread = pid_to_thread_id (pid);
1318 if (b->enable != disabled
1319 && b->enable != shlib_disabled
1320 && b->enable != call_disabled
1322 && (b->thread == -1 || b->thread == thread))
1324 if (overlay_debugging &&
1325 section_is_overlay (b->section) &&
1326 !section_is_mapped (b->section))
1327 continue; /* unmapped overlay -- can't be a match */
1336 /* bpstat stuff. External routines' interfaces are documented
1340 ep_is_catchpoint (ep)
1341 struct breakpoint * ep;
1344 (ep->type == bp_catch_load)
1345 || (ep->type == bp_catch_unload)
1346 || (ep->type == bp_catch_fork)
1347 || (ep->type == bp_catch_vfork)
1348 || (ep->type == bp_catch_exec)
1349 || (ep->type == bp_catch_catch)
1350 || (ep->type == bp_catch_throw)
1353 /* ??rehrauer: Add more kinds here, as are implemented... */
1358 ep_is_shlib_catchpoint (ep)
1359 struct breakpoint * ep;
1362 (ep->type == bp_catch_load)
1363 || (ep->type == bp_catch_unload)
1368 ep_is_exception_catchpoint (ep)
1369 struct breakpoint * ep;
1372 (ep->type == bp_catch_catch)
1373 || (ep->type == bp_catch_throw)
1377 /* Clear a bpstat so that it says we are not at any breakpoint.
1378 Also free any storage that is part of a bpstat. */
1393 if (p->old_val != NULL)
1394 value_free (p->old_val);
1401 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
1402 is part of the bpstat is copied as well. */
1410 bpstat retval = NULL;
1415 for (; bs != NULL; bs = bs->next)
1417 tmp = (bpstat) xmalloc (sizeof (*tmp));
1418 memcpy (tmp, bs, sizeof (*tmp));
1420 /* This is the first thing in the chain. */
1430 /* Find the bpstat associated with this breakpoint */
1433 bpstat_find_breakpoint(bsp, breakpoint)
1435 struct breakpoint *breakpoint;
1437 if (bsp == NULL) return NULL;
1439 for (;bsp != NULL; bsp = bsp->next) {
1440 if (bsp->breakpoint_at == breakpoint) return bsp;
1445 /* Find a step_resume breakpoint associated with this bpstat.
1446 (If there are multiple step_resume bp's on the list, this function
1447 will arbitrarily pick one.)
1449 It is an error to use this function if BPSTAT doesn't contain a
1450 step_resume breakpoint.
1452 See wait_for_inferior's use of this function. */
1454 bpstat_find_step_resume_breakpoint (bsp)
1458 error ("Internal error (bpstat_find_step_resume_breakpoint)");
1460 for (; bsp != NULL; bsp = bsp->next)
1462 if ((bsp->breakpoint_at != NULL) &&
1463 (bsp->breakpoint_at->type == bp_step_resume))
1464 return bsp->breakpoint_at;
1467 error ("Internal error (no step_resume breakpoint found)");
1471 /* Return the breakpoint number of the first breakpoint we are stopped
1472 at. *BSP upon return is a bpstat which points to the remaining
1473 breakpoints stopped at (but which is not guaranteed to be good for
1474 anything but further calls to bpstat_num).
1475 Return 0 if passed a bpstat which does not indicate any breakpoints. */
1481 struct breakpoint *b;
1484 return 0; /* No more breakpoint values */
1487 b = (*bsp)->breakpoint_at;
1488 *bsp = (*bsp)->next;
1490 return -1; /* breakpoint that's been deleted since */
1492 return b->number; /* We have its number */
1496 /* Modify BS so that the actions will not be performed. */
1499 bpstat_clear_actions (bs)
1502 for (; bs != NULL; bs = bs->next)
1504 bs->commands = NULL;
1505 if (bs->old_val != NULL)
1507 value_free (bs->old_val);
1513 /* Stub for cleaning up our state if we error-out of a breakpoint command */
1516 cleanup_executing_breakpoints (ignore)
1519 executing_breakpoint_commands = 0;
1522 /* Execute all the commands associated with all the breakpoints at this
1523 location. Any of these commands could cause the process to proceed
1524 beyond this point, etc. We look out for such changes by checking
1525 the global "breakpoint_proceeded" after each command. */
1528 bpstat_do_actions (bsp)
1532 struct cleanup *old_chain;
1533 struct command_line *cmd;
1535 /* Avoid endless recursion if a `source' command is contained
1537 if (executing_breakpoint_commands)
1540 executing_breakpoint_commands = 1;
1541 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
1544 /* Note that (as of this writing), our callers all appear to
1545 be passing us the address of global stop_bpstat. And, if
1546 our calls to execute_control_command cause the inferior to
1547 proceed, that global (and hence, *bsp) will change.
1549 We must be careful to not touch *bsp unless the inferior
1550 has not proceeded. */
1552 /* This pointer will iterate over the list of bpstat's. */
1555 breakpoint_proceeded = 0;
1556 for (; bs != NULL; bs = bs->next)
1561 execute_control_command (cmd);
1563 if (breakpoint_proceeded)
1568 if (breakpoint_proceeded)
1569 /* The inferior is proceeded by the command; bomb out now.
1570 The bpstat chain has been blown away by wait_for_inferior.
1571 But since execution has stopped again, there is a new bpstat
1572 to look at, so start over. */
1575 bs->commands = NULL;
1578 executing_breakpoint_commands = 0;
1579 discard_cleanups (old_chain);
1582 /* This is the normal print_it function for a bpstat. In the future,
1583 much of this logic could (should?) be moved to bpstat_stop_status,
1584 by having it set different print_it functions.
1586 Current scheme: When we stop, bpstat_print() is called.
1587 It loops through the bpstat list of things causing this stop,
1588 calling the print_it function for each one. The default
1589 print_it function, used for breakpoints, is print_it_normal().
1590 (Also see print_it_noop() and print_it_done()).
1592 Return values from this routine (used by bpstat_print() to
1594 1: Means we printed something, and we do *not* desire that
1595 something to be followed by a location.
1596 0: Means we printed something, and we *do* desire that
1597 something to be followed by a location.
1598 -1: Means we printed nothing. */
1601 print_it_normal (bs)
1604 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1605 which has since been deleted. */
1606 if (bs->breakpoint_at == NULL
1607 || (bs->breakpoint_at->type != bp_breakpoint
1608 && bs->breakpoint_at->type != bp_catch_load
1609 && bs->breakpoint_at->type != bp_catch_unload
1610 && bs->breakpoint_at->type != bp_catch_fork
1611 && bs->breakpoint_at->type != bp_catch_vfork
1612 && bs->breakpoint_at->type != bp_catch_exec
1613 && bs->breakpoint_at->type != bp_catch_catch
1614 && bs->breakpoint_at->type != bp_catch_throw
1615 && bs->breakpoint_at->type != bp_hardware_breakpoint
1616 && bs->breakpoint_at->type != bp_watchpoint
1617 && bs->breakpoint_at->type != bp_read_watchpoint
1618 && bs->breakpoint_at->type != bp_access_watchpoint
1619 && bs->breakpoint_at->type != bp_hardware_watchpoint))
1622 if (ep_is_shlib_catchpoint (bs->breakpoint_at))
1624 annotate_catchpoint (bs->breakpoint_at->number);
1625 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1626 if (bs->breakpoint_at->type == bp_catch_load)
1627 printf_filtered ("loaded");
1628 else if (bs->breakpoint_at->type == bp_catch_unload)
1629 printf_filtered ("unloaded");
1630 printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname);
1633 else if (bs->breakpoint_at->type == bp_catch_fork ||
1634 bs->breakpoint_at->type == bp_catch_vfork)
1636 annotate_catchpoint (bs->breakpoint_at->number);
1637 printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
1638 if (bs->breakpoint_at->type == bp_catch_fork)
1639 printf_filtered ("forked");
1640 else if (bs->breakpoint_at->type == bp_catch_vfork)
1641 printf_filtered ("vforked");
1642 printf_filtered (" process %d), ", bs->breakpoint_at->forked_inferior_pid);
1645 else if (bs->breakpoint_at->type == bp_catch_exec)
1647 annotate_catchpoint (bs->breakpoint_at->number);
1648 printf_filtered ("\nCatchpoint %d (exec'd %s), ",
1649 bs->breakpoint_at->number,
1650 bs->breakpoint_at->exec_pathname);
1653 else if (bs->breakpoint_at->type == bp_catch_catch)
1655 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH))
1657 annotate_catchpoint (bs->breakpoint_at->number);
1658 printf_filtered ("\nCatchpoint %d (exception caught), ", bs->breakpoint_at->number);
1659 printf_filtered ("throw location ");
1660 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1661 printf_filtered ("%s:%d",
1662 CURRENT_EXCEPTION_THROW_FILE,
1663 CURRENT_EXCEPTION_THROW_LINE);
1665 printf_filtered ("unknown");
1667 printf_filtered (", catch location ");
1668 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1669 printf_filtered ("%s:%d",
1670 CURRENT_EXCEPTION_CATCH_FILE,
1671 CURRENT_EXCEPTION_CATCH_LINE);
1673 printf_filtered ("unknown");
1675 printf_filtered ("\n");
1676 return 1; /* don't bother to print location frame info */
1680 return -1; /* really throw, some other bpstat will handle it */
1683 else if (bs->breakpoint_at->type == bp_catch_throw)
1685 if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW))
1687 annotate_catchpoint (bs->breakpoint_at->number);
1688 printf_filtered ("\nCatchpoint %d (exception thrown), ", bs->breakpoint_at->number);
1689 printf_filtered ("throw location ");
1690 if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
1691 printf_filtered ("%s:%d",
1692 CURRENT_EXCEPTION_THROW_FILE,
1693 CURRENT_EXCEPTION_THROW_LINE);
1695 printf_filtered ("unknown");
1697 printf_filtered (", catch location ");
1698 if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
1699 printf_filtered ("%s:%d",
1700 CURRENT_EXCEPTION_CATCH_FILE,
1701 CURRENT_EXCEPTION_CATCH_LINE);
1703 printf_filtered ("unknown");
1705 printf_filtered ("\n");
1706 return 1; /* don't bother to print location frame info */
1710 return -1; /* really catch, some other bpstat willhandle it */
1714 else if (bs->breakpoint_at->type == bp_breakpoint ||
1715 bs->breakpoint_at->type == bp_hardware_breakpoint)
1717 /* I think the user probably only wants to see one breakpoint
1718 number, not all of them. */
1719 annotate_breakpoint (bs->breakpoint_at->number);
1720 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
1723 else if ((bs->old_val != NULL) &&
1724 (bs->breakpoint_at->type == bp_watchpoint ||
1725 bs->breakpoint_at->type == bp_access_watchpoint ||
1726 bs->breakpoint_at->type == bp_hardware_watchpoint))
1728 annotate_watchpoint (bs->breakpoint_at->number);
1729 mention (bs->breakpoint_at);
1730 printf_filtered ("\nOld value = ");
1731 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
1732 printf_filtered ("\nNew value = ");
1733 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1734 Val_pretty_default);
1735 printf_filtered ("\n");
1736 value_free (bs->old_val);
1738 /* More than one watchpoint may have been triggered. */
1741 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
1742 bs->breakpoint_at->type == bp_read_watchpoint)
1744 mention (bs->breakpoint_at);
1745 printf_filtered ("\nValue = ");
1746 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1747 Val_pretty_default);
1748 printf_filtered ("\n");
1751 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1755 /* Print a message indicating what happened.
1756 This is called from normal_stop().
1757 The input to this routine is the head of the bpstat list - a list
1758 of the eventpoints that caused this stop.
1759 This routine calls the "print_it" routine(s) associated
1760 with these eventpoints. This will print (for example)
1761 the "Breakpoint n," part of the output.
1762 The return value of this routine is one of:
1764 -1: Means we printed nothing
1765 0: Means we printed something, and expect subsequent
1766 code to print the location. An example is
1767 "Breakpoint 1, " which should be followed by
1769 1 : Means we printed something, but there is no need
1770 to also print the location part of the message.
1771 An example is the catch/throw messages, which
1772 don't require a location appended to the end. */
1783 val = (*bs->print_it) (bs);
1787 /* Maybe another breakpoint in the chain caused us to stop.
1788 (Currently all watchpoints go on the bpstat whether hit or
1789 not. That probably could (should) be changed, provided care is taken
1790 with respect to bpstat_explains_signal). */
1792 return bpstat_print (bs->next);
1794 /* We reached the end of the chain without printing anything. */
1798 /* Evaluate the expression EXP and return 1 if value is zero.
1799 This is used inside a catch_errors to evaluate the breakpoint condition.
1800 The argument is a "struct expression *" that has been cast to char * to
1801 make it pass through catch_errors. */
1804 breakpoint_cond_eval (exp)
1807 value_ptr mark = value_mark ();
1808 int i = !value_true (evaluate_expression ((struct expression *)exp));
1809 value_free_to_mark (mark);
1813 /* Allocate a new bpstat and chain it to the current one. */
1816 bpstat_alloc (b, cbs)
1817 register struct breakpoint *b;
1818 bpstat cbs; /* Current "bs" value */
1822 bs = (bpstat) xmalloc (sizeof (*bs));
1824 bs->breakpoint_at = b;
1825 /* If the condition is false, etc., don't do the commands. */
1826 bs->commands = NULL;
1828 bs->print_it = print_it_normal;
1832 /* Possible return values for watchpoint_check (this can't be an enum
1833 because of check_errors). */
1834 /* The watchpoint has been deleted. */
1835 #define WP_DELETED 1
1836 /* The value has changed. */
1837 #define WP_VALUE_CHANGED 2
1838 /* The value has not changed. */
1839 #define WP_VALUE_NOT_CHANGED 3
1841 #define BP_TEMPFLAG 1
1842 #define BP_HARDWAREFLAG 2
1844 /* Check watchpoint condition. */
1847 watchpoint_check (p)
1850 bpstat bs = (bpstat) p;
1851 struct breakpoint *b;
1852 struct frame_info *fr;
1853 int within_current_scope;
1855 b = bs->breakpoint_at;
1857 if (b->exp_valid_block == NULL)
1858 within_current_scope = 1;
1861 /* There is no current frame at this moment. If we're going to have
1862 any chance of handling watchpoints on local variables, we'll need
1863 the frame chain (so we can determine if we're in scope). */
1864 reinit_frame_cache();
1865 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1866 within_current_scope = (fr != NULL);
1867 if (within_current_scope)
1868 /* If we end up stopping, the current frame will get selected
1869 in normal_stop. So this call to select_frame won't affect
1871 select_frame (fr, -1);
1874 if (within_current_scope)
1876 /* We use value_{,free_to_}mark because it could be a
1877 *long* time before we return to the command level and
1878 call free_all_values. We can't call free_all_values because
1879 we might be in the middle of evaluating a function call. */
1881 value_ptr mark = value_mark ();
1882 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1883 if (!value_equal (b->val, new_val))
1885 release_value (new_val);
1886 value_free_to_mark (mark);
1887 bs->old_val = b->val;
1889 /* We will stop here */
1890 return WP_VALUE_CHANGED;
1894 /* Nothing changed, don't do anything. */
1895 value_free_to_mark (mark);
1896 /* We won't stop here */
1897 return WP_VALUE_NOT_CHANGED;
1902 /* This seems like the only logical thing to do because
1903 if we temporarily ignored the watchpoint, then when
1904 we reenter the block in which it is valid it contains
1905 garbage (in the case of a function, it may have two
1906 garbage values, one before and one after the prologue).
1907 So we can't even detect the first assignment to it and
1908 watch after that (since the garbage may or may not equal
1909 the first value assigned). */
1911 Watchpoint %d deleted because the program has left the block in\n\
1912 which its expression is valid.\n", bs->breakpoint_at->number);
1913 if (b->related_breakpoint)
1914 b->related_breakpoint->disposition = del_at_next_stop;
1915 b->disposition = del_at_next_stop;
1921 /* This is used when everything which needs to be printed has
1922 already been printed. But we still want to print the frame. */
1924 /* Background: When we stop, bpstat_print() is called.
1925 It loops through the bpstat list of things causing this stop,
1926 calling the print_it function for each one. The default
1927 print_it function, used for breakpoints, is print_it_normal().
1928 Also see print_it_noop() and print_it_done() are the other
1929 two possibilities. See comments in bpstat_print() and
1930 in header of print_it_normal() for more detail. */
1939 /* This is used when nothing should be printed for this bpstat entry. */
1940 /* Background: When we stop, bpstat_print() is called.
1941 It loops through the bpstat list of things causing this stop,
1942 calling the print_it function for each one. The default
1943 print_it function, used for breakpoints, is print_it_normal().
1944 Also see print_it_noop() and print_it_done() are the other
1945 two possibilities. See comments in bpstat_print() and
1946 in header of print_it_normal() for more detail. */
1955 /* Get a bpstat associated with having just stopped at address *PC
1956 and frame address CORE_ADDRESS. Update *PC to point at the
1957 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1958 if this is known to not be a real breakpoint (it could still be a
1959 watchpoint, though). */
1961 /* Determine whether we stopped at a breakpoint, etc, or whether we
1962 don't understand this stop. Result is a chain of bpstat's such that:
1964 if we don't understand the stop, the result is a null pointer.
1966 if we understand why we stopped, the result is not null.
1968 Each element of the chain refers to a particular breakpoint or
1969 watchpoint at which we have stopped. (We may have stopped for
1970 several reasons concurrently.)
1972 Each element of the chain has valid next, breakpoint_at,
1973 commands, FIXME??? fields. */
1976 bpstat_stop_status (pc, not_a_breakpoint)
1978 int not_a_breakpoint;
1980 register struct breakpoint *b, *temp;
1982 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1983 int real_breakpoint = 0;
1984 /* Root of the chain of bpstat's */
1985 struct bpstats root_bs[1];
1986 /* Pointer to the last thing in the chain currently. */
1987 bpstat bs = root_bs;
1988 static char message1[] =
1989 "Error evaluating expression for watchpoint %d\n";
1990 char message[sizeof (message1) + 30 /* slop */];
1992 /* Get the address where the breakpoint would have been. */
1993 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1995 ALL_BREAKPOINTS_SAFE (b, temp)
1997 if (b->enable == disabled
1998 || b->enable == shlib_disabled
1999 || b->enable == call_disabled)
2002 if (b->type != bp_watchpoint
2003 && b->type != bp_hardware_watchpoint
2004 && b->type != bp_read_watchpoint
2005 && b->type != bp_access_watchpoint
2006 && b->type != bp_hardware_breakpoint
2007 && b->type != bp_catch_fork
2008 && b->type != bp_catch_vfork
2009 && b->type != bp_catch_exec
2010 && b->type != bp_catch_catch
2011 && b->type != bp_catch_throw) /* a non-watchpoint bp */
2012 if (b->address != bp_addr || /* address doesn't match or */
2013 (overlay_debugging && /* overlay doesn't match */
2014 section_is_overlay (b->section) &&
2015 !section_is_mapped (b->section)))
2018 if (b->type == bp_hardware_breakpoint
2019 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
2022 if (b->type != bp_watchpoint
2023 && b->type != bp_hardware_watchpoint
2024 && b->type != bp_read_watchpoint
2025 && b->type != bp_access_watchpoint
2026 && not_a_breakpoint)
2029 /* Is this a catchpoint of a load or unload? If so, did we
2030 get a load or unload of the specified library? If not,
2032 if ((b->type == bp_catch_load)
2033 #if defined(SOLIB_HAVE_LOAD_EVENT)
2034 && (!SOLIB_HAVE_LOAD_EVENT(inferior_pid)
2035 || ((b->dll_pathname != NULL)
2036 && (strcmp (b->dll_pathname, SOLIB_LOADED_LIBRARY_PATHNAME(inferior_pid)) != 0)))
2041 if ((b->type == bp_catch_unload)
2042 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
2043 && (!SOLIB_HAVE_UNLOAD_EVENT(inferior_pid)
2044 || ((b->dll_pathname != NULL)
2045 && (strcmp (b->dll_pathname, SOLIB_UNLOADED_LIBRARY_PATHNAME(inferior_pid)) != 0)))
2050 if ((b->type == bp_catch_fork)
2051 && ! target_has_forked (inferior_pid, &b->forked_inferior_pid))
2054 if ((b->type == bp_catch_vfork)
2055 && ! target_has_vforked (inferior_pid, &b->forked_inferior_pid))
2058 if ((b->type == bp_catch_exec)
2059 && ! target_has_execd (inferior_pid, &b->exec_pathname))
2062 if (ep_is_exception_catchpoint (b) &&
2063 !(current_exception_event = target_get_current_exception_event ()))
2066 /* Come here if it's a watchpoint, or if the break address matches */
2068 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
2070 /* Watchpoints may change this, if not found to have triggered. */
2074 sprintf (message, message1, b->number);
2075 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
2077 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2080 /* We've already printed what needs to be printed. */
2081 bs->print_it = print_it_done;
2084 case WP_VALUE_CHANGED:
2088 case WP_VALUE_NOT_CHANGED:
2090 bs->print_it = print_it_noop;
2092 /* Don't consider this a hit. */
2099 /* Error from catch_errors. */
2100 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2101 if (b->related_breakpoint)
2102 b->related_breakpoint->disposition = del_at_next_stop;
2103 b->disposition = del_at_next_stop;
2104 /* We've already printed what needs to be printed. */
2105 bs->print_it = print_it_done;
2111 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
2117 addr = target_stopped_data_address();
2118 if (addr == 0) continue;
2119 for (v = b->val_chain; v; v = v->next)
2121 if (v->lval == lval_memory)
2125 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
2131 switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL))
2134 /* We've already printed what needs to be printed. */
2135 bs->print_it = print_it_done;
2138 case WP_VALUE_CHANGED:
2139 case WP_VALUE_NOT_CHANGED:
2146 /* Error from catch_errors. */
2147 printf_filtered ("Watchpoint %d deleted.\n", b->number);
2148 if (b->related_breakpoint)
2149 b->related_breakpoint->disposition = del_at_next_stop;
2150 b->disposition = del_at_next_stop;
2151 /* We've already printed what needs to be printed. */
2152 bs->print_it = print_it_done;
2158 /* By definition, an encountered breakpoint is a triggered
2162 if (DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs)
2163 real_breakpoint = 1;
2166 if (b->frame && b->frame != (get_current_frame ())->frame &&
2167 (b->type == bp_step_resume &&
2168 (INNER_THAN (get_current_frame ()->frame, b->frame))))
2172 int value_is_zero = 0;
2176 /* Need to select the frame, with all that implies
2177 so that the conditions will have the right context. */
2178 select_frame (get_current_frame (), 0);
2180 = catch_errors (breakpoint_cond_eval, (b->cond),
2181 "Error in testing breakpoint condition:\n",
2183 /* FIXME-someday, should give breakpoint # */
2186 if (b->cond && value_is_zero)
2189 /* Don't consider this a hit. */
2192 else if (b->ignore_count > 0)
2199 /* We will stop here */
2200 if (b->disposition == disable)
2201 b->enable = disabled;
2202 bs->commands = b->commands;
2206 (STREQ ("silent", bs->commands->line) ||
2207 (xdb_commands && STREQ ("Q", bs->commands->line))))
2209 bs->commands = bs->commands->next;
2214 /* Print nothing for this entry if we dont stop or if we dont print. */
2215 if (bs->stop == 0 || bs->print == 0)
2216 bs->print_it = print_it_noop;
2219 bs->next = NULL; /* Terminate the chain */
2220 bs = root_bs->next; /* Re-grab the head of the chain */
2222 if ((DECR_PC_AFTER_BREAK != 0 || must_shift_inst_regs) && bs)
2224 if (real_breakpoint)
2227 #if defined (SHIFT_INST_REGS)
2229 #else /* No SHIFT_INST_REGS. */
2231 #endif /* No SHIFT_INST_REGS. */
2235 /* The value of a hardware watchpoint hasn't changed, but the
2236 intermediate memory locations we are watching may have. */
2237 if (bs && ! bs->stop &&
2238 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
2239 bs->breakpoint_at->type == bp_read_watchpoint ||
2240 bs->breakpoint_at->type == bp_access_watchpoint))
2242 remove_breakpoints ();
2243 insert_breakpoints ();
2248 /* Tell what to do about this bpstat. */
2253 /* Classify each bpstat as one of the following. */
2255 /* This bpstat element has no effect on the main_action. */
2258 /* There was a watchpoint, stop but don't print. */
2261 /* There was a watchpoint, stop and print. */
2264 /* There was a breakpoint but we're not stopping. */
2267 /* There was a breakpoint, stop but don't print. */
2270 /* There was a breakpoint, stop and print. */
2273 /* We hit the longjmp breakpoint. */
2276 /* We hit the longjmp_resume breakpoint. */
2279 /* We hit the step_resume breakpoint. */
2282 /* We hit the through_sigtramp breakpoint. */
2285 /* We hit the shared library event breakpoint. */
2288 /* We caught a shared library event. */
2291 /* This is just used to count how many enums there are. */
2295 /* Here is the table which drives this routine. So that we can
2296 format it pretty, we define some abbreviations for the
2297 enum bpstat_what codes. */
2298 #define kc BPSTAT_WHAT_KEEP_CHECKING
2299 #define ss BPSTAT_WHAT_STOP_SILENT
2300 #define sn BPSTAT_WHAT_STOP_NOISY
2301 #define sgl BPSTAT_WHAT_SINGLE
2302 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
2303 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
2304 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
2305 #define sr BPSTAT_WHAT_STEP_RESUME
2306 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
2307 #define shl BPSTAT_WHAT_CHECK_SHLIBS
2308 #define shlr BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
2310 /* "Can't happen." Might want to print an error message.
2311 abort() is not out of the question, but chances are GDB is just
2312 a bit confused, not unusable. */
2313 #define err BPSTAT_WHAT_STOP_NOISY
2315 /* Given an old action and a class, come up with a new action. */
2316 /* One interesting property of this table is that wp_silent is the same
2317 as bp_silent and wp_noisy is the same as bp_noisy. That is because
2318 after stopping, the check for whether to step over a breakpoint
2319 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
2320 reference to how we stopped. We retain separate wp_silent and bp_silent
2321 codes in case we want to change that someday. */
2323 /* step_resume entries: a step resume breakpoint overrides another
2324 breakpoint of signal handling (see comment in wait_for_inferior
2325 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
2326 /* We handle the through_sigtramp_breakpoint the same way; having both
2327 one of those and a step_resume_breakpoint is probably very rare (?). */
2329 static const enum bpstat_what_main_action
2330 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
2333 /* kc ss sn sgl slr clr clrs sr ts shl shlr
2335 /*no_effect*/ {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl, shlr},
2336 /*wp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2337 /*wp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2338 /*bp_nostop*/ {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl, shlr},
2339 /*bp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr},
2340 /*bp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr},
2341 /*long_jump*/ {slr, ss, sn, slr, err, err, err, sr, ts, shl, shlr},
2342 /*long_resume*/ {clr, ss, sn, clrs, err, err, err, sr, ts, shl, shlr},
2343 /*step_resume*/ {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl, shlr},
2344 /*through_sig*/ {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl, shlr},
2345 /*shlib*/ {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl, shlr},
2346 /*catch_shlib*/ {shlr, shlr, shlr, shlr, shlr, shlr, shlr, shlr, ts, shlr, shlr}
2361 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
2362 struct bpstat_what retval;
2364 retval.call_dummy = 0;
2365 for (; bs != NULL; bs = bs->next)
2367 enum class bs_class = no_effect;
2368 if (bs->breakpoint_at == NULL)
2369 /* I suspect this can happen if it was a momentary breakpoint
2370 which has since been deleted. */
2372 switch (bs->breakpoint_at->type)
2378 case bp_hardware_breakpoint:
2384 bs_class = bp_noisy;
2386 bs_class = bp_silent;
2389 bs_class = bp_nostop;
2392 case bp_hardware_watchpoint:
2393 case bp_read_watchpoint:
2394 case bp_access_watchpoint:
2398 bs_class = wp_noisy;
2400 bs_class = wp_silent;
2403 /* There was a watchpoint, but we're not stopping. This requires
2404 no further action. */
2405 bs_class = no_effect;
2408 bs_class = long_jump;
2410 case bp_longjmp_resume:
2411 bs_class = long_resume;
2413 case bp_step_resume:
2416 bs_class = step_resume;
2419 /* It is for the wrong frame. */
2420 bs_class = bp_nostop;
2422 case bp_through_sigtramp:
2423 bs_class = through_sig;
2425 case bp_watchpoint_scope:
2426 bs_class = bp_nostop;
2428 case bp_shlib_event:
2429 bs_class = shlib_event;
2432 case bp_catch_unload:
2433 /* Only if this catchpoint triggered should we cause the
2434 step-out-of-dld behaviour. Otherwise, we ignore this
2437 bs_class = catch_shlib_event;
2439 bs_class = no_effect;
2442 case bp_catch_vfork:
2447 bs_class = bp_noisy;
2449 bs_class = bp_silent;
2452 /* There was a catchpoint, but we're not stopping. This requires
2453 no further action. */
2454 bs_class = no_effect;
2456 case bp_catch_catch:
2457 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_CATCH)
2458 bs_class = bp_nostop;
2460 bs_class = bs->print ? bp_noisy : bp_silent;
2462 case bp_catch_throw:
2463 if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_THROW)
2464 bs_class = bp_nostop;
2466 bs_class = bs->print ? bp_noisy : bp_silent;
2469 /* Make sure the action is stop (silent or noisy), so infrun.c
2470 pops the dummy frame. */
2471 bs_class = bp_silent;
2472 retval.call_dummy = 1;
2475 current_action = table[(int)bs_class][(int)current_action];
2477 retval.main_action = current_action;
2481 /* Nonzero if we should step constantly (e.g. watchpoints on machines
2482 without hardware support). This isn't related to a specific bpstat,
2483 just to things like whether watchpoints are set. */
2486 bpstat_should_step ()
2488 struct breakpoint *b;
2490 if (b->enable == enabled && b->type == bp_watchpoint)
2495 /* Nonzero if there are enabled hardware watchpoints. */
2497 bpstat_have_active_hw_watchpoints ()
2499 struct breakpoint *b;
2501 if ((b->enable == enabled) &&
2503 ((b->type == bp_hardware_watchpoint) ||
2504 (b->type == bp_read_watchpoint) ||
2505 (b->type == bp_access_watchpoint)))
2511 /* Given a bpstat that records zero or more triggered eventpoints, this
2512 function returns another bpstat which contains only the catchpoints
2513 on that first list, if any. */
2515 bpstat_get_triggered_catchpoints (ep_list, cp_list)
2519 struct bpstats root_bs[1];
2520 bpstat bs = root_bs;
2521 struct breakpoint * ep;
2522 char * dll_pathname;
2524 bpstat_clear (cp_list);
2525 root_bs->next = NULL;
2527 for (; ep_list != NULL; ep_list = ep_list->next )
2529 /* Is this eventpoint a catchpoint? If not, ignore it. */
2530 ep = ep_list->breakpoint_at;
2533 if ((ep->type != bp_catch_load) &&
2534 (ep->type != bp_catch_unload) &&
2535 (ep->type != bp_catch_catch) &&
2536 (ep->type != bp_catch_throw)) /* pai: (temp) ADD fork/vfork here!! */
2539 /* Yes; add it to the list. */
2540 bs = bpstat_alloc (ep, bs);
2545 #if defined(SOLIB_ADD)
2546 /* Also, for each triggered catchpoint, tag it with the name of
2547 the library that caused this trigger. (We copy the name now,
2548 because it's only guaranteed to be available NOW, when the
2549 catchpoint triggers. Clients who may wish to know the name
2550 later must get it from the catchpoint itself.) */
2551 if (ep->triggered_dll_pathname != NULL)
2552 free (ep->triggered_dll_pathname);
2553 if (ep->type == bp_catch_load)
2554 dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
2556 dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid);
2558 dll_pathname = NULL;
2562 ep->triggered_dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
2563 strcpy (ep->triggered_dll_pathname, dll_pathname);
2566 ep->triggered_dll_pathname = NULL;
2572 /* Print information on breakpoint number BNUM, or -1 if all.
2573 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
2574 is nonzero, process only watchpoints. */
2579 } ep_type_description_t;
2582 breakpoint_1 (bnum, allflag)
2586 register struct breakpoint *b;
2587 register struct command_line *l;
2588 register struct symbol *sym;
2589 CORE_ADDR last_addr = (CORE_ADDR)-1;
2590 int found_a_breakpoint = 0;
2591 static ep_type_description_t bptypes[] =
2593 {bp_none, "?deleted?"},
2594 {bp_breakpoint, "breakpoint"},
2595 {bp_hardware_breakpoint, "hw breakpoint"},
2596 {bp_until, "until"},
2597 {bp_finish, "finish"},
2598 {bp_watchpoint, "watchpoint"},
2599 {bp_hardware_watchpoint, "hw watchpoint"},
2600 {bp_read_watchpoint, "read watchpoint"},
2601 {bp_access_watchpoint, "acc watchpoint"},
2602 {bp_longjmp, "longjmp"},
2603 {bp_longjmp_resume, "longjmp resume"},
2604 {bp_step_resume, "step resume"},
2605 {bp_through_sigtramp, "sigtramp"},
2606 {bp_watchpoint_scope, "watchpoint scope"},
2607 {bp_call_dummy, "call dummy"},
2608 {bp_shlib_event, "shlib events"},
2609 {bp_catch_load, "catch load"},
2610 {bp_catch_unload, "catch unload"},
2611 {bp_catch_fork, "catch fork"},
2612 {bp_catch_vfork, "catch vfork"},
2613 {bp_catch_exec, "catch exec"},
2614 {bp_catch_catch, "catch catch"},
2615 {bp_catch_throw, "catch throw"}
2618 static char *bpdisps[] = {"del", "dstp", "dis", "keep"};
2619 static char bpenables[] = "nyn";
2620 char wrap_indent[80];
2624 || bnum == b->number)
2626 /* We only print out user settable breakpoints unless the allflag is set. */
2628 && b->type != bp_breakpoint
2629 && b->type != bp_catch_load
2630 && b->type != bp_catch_unload
2631 && b->type != bp_catch_fork
2632 && b->type != bp_catch_vfork
2633 && b->type != bp_catch_exec
2634 && b->type != bp_catch_catch
2635 && b->type != bp_catch_throw
2636 && b->type != bp_hardware_breakpoint
2637 && b->type != bp_watchpoint
2638 && b->type != bp_read_watchpoint
2639 && b->type != bp_access_watchpoint
2640 && b->type != bp_hardware_watchpoint)
2643 if (!found_a_breakpoint++)
2645 annotate_breakpoints_headers ();
2648 printf_filtered ("Num ");
2650 printf_filtered ("Type ");
2652 printf_filtered ("Disp ");
2654 printf_filtered ("Enb ");
2658 printf_filtered ("Address ");
2661 printf_filtered ("What\n");
2663 annotate_breakpoints_table ();
2668 printf_filtered ("%-3d ", b->number);
2670 if ((int)b->type > (sizeof(bptypes)/sizeof(bptypes[0])))
2671 error ("bptypes table does not describe type #%d.", (int)b->type);
2672 if ((int)b->type != bptypes[(int)b->type].type)
2673 error ("bptypes table does not describe type #%d?", (int)b->type);
2674 printf_filtered ("%-14s ", bptypes[(int)b->type].description);
2676 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
2678 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
2680 strcpy (wrap_indent, " ");
2682 strcat (wrap_indent, " ");
2686 case bp_hardware_watchpoint:
2687 case bp_read_watchpoint:
2688 case bp_access_watchpoint:
2689 /* Field 4, the address, is omitted (which makes the columns
2690 not line up too nicely with the headers, but the effect
2691 is relatively readable). */
2693 print_expression (b->exp, gdb_stdout);
2697 case bp_catch_unload:
2698 /* Field 4, the address, is omitted (which makes the columns
2699 not line up too nicely with the headers, but the effect
2700 is relatively readable). */
2702 if (b->dll_pathname == NULL)
2703 printf_filtered ("<any library> ");
2705 printf_filtered ("library \"%s\" ", b->dll_pathname);
2709 case bp_catch_vfork:
2710 /* Field 4, the address, is omitted (which makes the columns
2711 not line up too nicely with the headers, but the effect
2712 is relatively readable). */
2714 if (b->forked_inferior_pid != 0)
2715 printf_filtered ("process %d ", b->forked_inferior_pid);
2719 /* Field 4, the address, is omitted (which makes the columns
2720 not line up too nicely with the headers, but the effect
2721 is relatively readable). */
2723 if (b->exec_pathname != NULL)
2724 printf_filtered ("program \"%s\" ", b->exec_pathname);
2726 case bp_catch_catch:
2727 /* Field 4, the address, is omitted (which makes the columns
2728 not line up too nicely with the headers, but the effect
2729 is relatively readable). */
2731 printf_filtered ("exception catch ");
2733 case bp_catch_throw:
2734 /* Field 4, the address, is omitted (which makes the columns
2735 not line up too nicely with the headers, but the effect
2736 is relatively readable). */
2738 printf_filtered ("exception throw ");
2742 case bp_hardware_breakpoint:
2746 case bp_longjmp_resume:
2747 case bp_step_resume:
2748 case bp_through_sigtramp:
2749 case bp_watchpoint_scope:
2751 case bp_shlib_event:
2755 /* FIXME-32x64: need a print_address_numeric with
2759 local_hex_string_custom
2760 ((unsigned long) b->address, "08l"));
2765 last_addr = b->address;
2768 sym = find_pc_sect_function (b->address, b->section);
2771 fputs_filtered ("in ", gdb_stdout);
2772 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
2773 wrap_here (wrap_indent);
2774 fputs_filtered (" at ", gdb_stdout);
2776 fputs_filtered (b->source_file, gdb_stdout);
2777 printf_filtered (":%d", b->line_number);
2780 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
2784 if (b->thread != -1)
2785 printf_filtered (" thread %d", b->thread );
2787 printf_filtered ("\n");
2793 printf_filtered ("\tstop only in stack frame at ");
2794 print_address_numeric (b->frame, 1, gdb_stdout);
2795 printf_filtered ("\n");
2802 printf_filtered ("\tstop only if ");
2803 print_expression (b->cond, gdb_stdout);
2804 printf_filtered ("\n");
2807 if (b->thread != -1)
2809 /* FIXME should make an annotation for this */
2810 printf_filtered ("\tstop only in thread %d\n", b->thread);
2813 if (show_breakpoint_hit_counts && b->hit_count)
2815 /* FIXME should make an annotation for this */
2816 if (ep_is_catchpoint (b))
2817 printf_filtered ("\tcatchpoint");
2819 printf_filtered ("\tbreakpoint");
2820 printf_filtered (" already hit %d time%s\n",
2821 b->hit_count, (b->hit_count == 1 ? "" : "s"));
2824 if (b->ignore_count)
2828 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
2831 if ((l = b->commands))
2837 print_command_line (l, 4);
2843 if (!found_a_breakpoint)
2846 printf_filtered ("No breakpoints or watchpoints.\n");
2848 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
2851 /* Compare against (CORE_ADDR)-1 in case some compiler decides
2852 that a comparison of an unsigned with -1 is always false. */
2853 if (last_addr != (CORE_ADDR)-1)
2854 set_next_address (last_addr);
2856 annotate_breakpoints_table_end ();
2861 breakpoints_info (bnum_exp, from_tty)
2868 bnum = parse_and_eval_address (bnum_exp);
2870 breakpoint_1 (bnum, 0);
2873 #if MAINTENANCE_CMDS
2877 maintenance_info_breakpoints (bnum_exp, from_tty)
2884 bnum = parse_and_eval_address (bnum_exp);
2886 breakpoint_1 (bnum, 1);
2891 /* Print a message describing any breakpoints set at PC. */
2894 describe_other_breakpoints (pc, section)
2898 register int others = 0;
2899 register struct breakpoint *b;
2902 if (b->address == pc)
2903 if (overlay_debugging == 0 ||
2904 b->section == section)
2908 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
2910 if (b->address == pc)
2911 if (overlay_debugging == 0 ||
2912 b->section == section)
2918 ((b->enable == disabled || b->enable == shlib_disabled || b->enable == call_disabled)
2919 ? " (disabled)" : ""),
2920 (others > 1) ? "," : ((others == 1) ? " and" : ""));
2922 printf_filtered ("also set at pc ");
2923 print_address_numeric (pc, 1, gdb_stdout);
2924 printf_filtered (".\n");
2928 /* Set the default place to put a breakpoint
2929 for the `break' command with no arguments. */
2932 set_default_breakpoint (valid, addr, symtab, line)
2935 struct symtab *symtab;
2938 default_breakpoint_valid = valid;
2939 default_breakpoint_address = addr;
2940 default_breakpoint_symtab = symtab;
2941 default_breakpoint_line = line;
2944 /* Rescan breakpoints at address ADDRESS,
2945 marking the first one as "first" and any others as "duplicates".
2946 This is so that the bpt instruction is only inserted once. */
2949 check_duplicates (address, section)
2953 register struct breakpoint *b;
2954 register int count = 0;
2956 if (address == 0) /* Watchpoints are uninteresting */
2960 if (b->enable != disabled
2961 && b->enable != shlib_disabled
2962 && b->enable != call_disabled
2963 && b->address == address
2964 && (overlay_debugging == 0 || b->section == section))
2967 b->duplicate = count > 1;
2971 /* Low level routine to set a breakpoint.
2972 Takes as args the three things that every breakpoint must have.
2973 Returns the breakpoint object so caller can set other things.
2974 Does not set the breakpoint number!
2975 Does not print anything.
2977 ==> This routine should not be called if there is a chance of later
2978 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
2979 your arguments BEFORE calling this routine! */
2982 set_raw_breakpoint (sal)
2983 struct symtab_and_line sal;
2985 register struct breakpoint *b, *b1;
2987 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
2988 memset (b, 0, sizeof (*b));
2989 b->address = sal.pc;
2990 if (sal.symtab == NULL)
2991 b->source_file = NULL;
2993 b->source_file = savestring (sal.symtab->filename,
2994 strlen (sal.symtab->filename));
2995 b->section = sal.section;
2996 b->language = current_language->la_language;
2997 b->input_radix = input_radix;
2999 b->line_number = sal.line;
3000 b->enable = enabled;
3003 b->ignore_count = 0;
3006 b->dll_pathname = NULL;
3007 b->triggered_dll_pathname = NULL;
3008 b->forked_inferior_pid = 0;
3009 b->exec_pathname = NULL;
3011 /* Add this breakpoint to the end of the chain
3012 so that a list of breakpoints will come out in order
3013 of increasing numbers. */
3015 b1 = breakpoint_chain;
3017 breakpoint_chain = b;
3025 check_duplicates (sal.pc, sal.section);
3026 breakpoints_changed ();
3031 #ifdef GET_LONGJMP_TARGET
3034 create_longjmp_breakpoint (func_name)
3037 struct symtab_and_line sal;
3038 struct breakpoint *b;
3040 INIT_SAL (&sal); /* initialize to zeroes */
3041 if (func_name != NULL)
3043 struct minimal_symbol *m;
3045 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
3047 sal.pc = SYMBOL_VALUE_ADDRESS (m);
3051 sal.section = find_pc_overlay (sal.pc);
3052 b = set_raw_breakpoint (sal);
3055 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
3056 b->disposition = donttouch;
3057 b->enable = disabled;
3060 b->addr_string = strsave(func_name);
3061 b->number = internal_breakpoint_number--;
3064 #endif /* #ifdef GET_LONGJMP_TARGET */
3066 /* Call this routine when stepping and nexting to enable a breakpoint if we do
3067 a longjmp(). When we hit that breakpoint, call
3068 set_longjmp_resume_breakpoint() to figure out where we are going. */
3071 enable_longjmp_breakpoint()
3073 register struct breakpoint *b;
3076 if (b->type == bp_longjmp)
3078 b->enable = enabled;
3079 check_duplicates (b->address, b->section);
3084 disable_longjmp_breakpoint()
3086 register struct breakpoint *b;
3089 if ( b->type == bp_longjmp
3090 || b->type == bp_longjmp_resume)
3092 b->enable = disabled;
3093 check_duplicates (b->address, b->section);
3099 remove_solib_event_breakpoints ()
3101 register struct breakpoint *b, *temp;
3103 ALL_BREAKPOINTS_SAFE (b, temp)
3104 if (b->type == bp_shlib_event)
3105 delete_breakpoint (b);
3109 create_solib_event_breakpoint (address)
3112 struct breakpoint *b;
3113 struct symtab_and_line sal;
3115 INIT_SAL (&sal); /* initialize to zeroes */
3117 sal.section = find_pc_overlay (sal.pc);
3118 b = set_raw_breakpoint (sal);
3119 b->number = internal_breakpoint_number--;
3120 b->disposition = donttouch;
3121 b->type = bp_shlib_event;
3125 disable_breakpoints_in_shlibs (silent)
3128 struct breakpoint * b;
3129 int disabled_shlib_breaks = 0;
3131 /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */
3134 #if defined (PC_SOLIB)
3135 if (((b->type == bp_breakpoint) ||
3136 (b->type == bp_hardware_breakpoint)) &&
3137 (b->enable != shlib_disabled) &&
3138 (b->enable != call_disabled) &&
3140 PC_SOLIB (b->address))
3142 b->enable = shlib_disabled;
3145 if (!disabled_shlib_breaks)
3147 target_terminal_ours_for_output ();
3148 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
3150 disabled_shlib_breaks = 1;
3151 printf_filtered ("%d ", b->number);
3156 if (disabled_shlib_breaks && !silent)
3157 printf_filtered ("\n");
3160 /* Try to reenable any breakpoints in shared libraries. */
3162 re_enable_breakpoints_in_shlibs ()
3164 struct breakpoint *b;
3167 if (b->enable == shlib_disabled)
3171 /* Do not reenable the breakpoint if the shared library
3172 is still not mapped in. */
3173 if (target_read_memory (b->address, buf, 1) == 0)
3174 b->enable = enabled;
3181 create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string, bp_kind)
3184 char * dll_pathname;
3186 enum bptype bp_kind;
3188 struct breakpoint * b;
3189 struct symtabs_and_lines sals;
3190 struct symtab_and_line sal;
3191 struct cleanup * old_chain;
3192 struct cleanup * canonical_strings_chain = NULL;
3194 char * addr_start = hookname;
3195 char * addr_end = NULL;
3196 char ** canonical = (char **) NULL;
3197 int thread = -1; /* All threads. */
3199 /* Set a breakpoint on the specified hook. */
3200 sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical);
3201 addr_end = hookname;
3203 if (sals.nelts == 0)
3205 warning ("Unable to set a breakpoint on dynamic linker callback.");
3206 warning ("Suggest linking with /opt/langtools/lib/end.o.");
3207 warning ("GDB will be unable to track shl_load/shl_unload calls");
3210 if (sals.nelts != 1)
3212 warning ("Unable to set a unique breakpoint on dynamic linker callback.");
3213 warning ("GDB will be unable to track shl_load/shl_unload calls");
3217 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3218 the following errors out. */
3219 old_chain = make_cleanup (free, sals.sals);
3220 if (canonical != (char **)NULL)
3222 make_cleanup (free, canonical);
3223 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3224 if (canonical[0] != NULL)
3225 make_cleanup (free, canonical[0]);
3228 resolve_sal_pc (&sals.sals[0]);
3230 /* Remove the canonical strings from the cleanup, they are needed below. */
3231 if (canonical != (char **)NULL)
3232 discard_cleanups (canonical_strings_chain);
3234 b = set_raw_breakpoint (sals.sals[0]);
3235 set_breakpoint_count (breakpoint_count + 1);
3236 b->number = breakpoint_count;
3238 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3241 if (canonical != (char **)NULL && canonical[0] != NULL)
3242 b->addr_string = canonical[0];
3243 else if (addr_start)
3244 b->addr_string = savestring (addr_start, addr_end - addr_start);
3246 b->enable = enabled;
3247 b->disposition = tempflag ? del : donttouch;
3249 if (dll_pathname == NULL)
3250 b->dll_pathname = NULL;
3253 b->dll_pathname = (char *) xmalloc (strlen (dll_pathname) + 1);
3254 strcpy (b->dll_pathname, dll_pathname);
3259 do_cleanups (old_chain);
3263 create_solib_load_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3266 char * dll_pathname;
3269 create_solib_load_unload_event_breakpoint (hookname,
3277 create_solib_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string)
3280 char * dll_pathname;
3283 create_solib_load_unload_event_breakpoint (hookname,
3291 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_kind)
3294 enum bptype bp_kind;
3296 struct symtab_and_line sal;
3297 struct breakpoint * b;
3298 int thread = -1; /* All threads. */
3305 b = set_raw_breakpoint (sal);
3306 set_breakpoint_count (breakpoint_count + 1);
3307 b->number = breakpoint_count;
3309 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3311 b->addr_string = NULL;
3312 b->enable = enabled;
3313 b->disposition = tempflag ? del : donttouch;
3314 b->forked_inferior_pid = 0;
3322 create_fork_event_catchpoint (tempflag, cond_string)
3326 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_fork);
3330 create_vfork_event_catchpoint (tempflag, cond_string)
3334 create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_vfork);
3338 create_exec_event_catchpoint (tempflag, cond_string)
3342 struct symtab_and_line sal;
3343 struct breakpoint * b;
3344 int thread = -1; /* All threads. */
3351 b = set_raw_breakpoint (sal);
3352 set_breakpoint_count (breakpoint_count + 1);
3353 b->number = breakpoint_count;
3355 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
3357 b->addr_string = NULL;
3358 b->enable = enabled;
3359 b->disposition = tempflag ? del : donttouch;
3361 b->type = bp_catch_exec;
3367 hw_breakpoint_used_count()
3369 register struct breakpoint *b;
3374 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
3382 hw_watchpoint_used_count(type, other_type_used)
3384 int *other_type_used;
3386 register struct breakpoint *b;
3389 *other_type_used = 0;
3392 if (b->enable == enabled)
3394 if (b->type == type) i++;
3395 else if ((b->type == bp_hardware_watchpoint ||
3396 b->type == bp_read_watchpoint ||
3397 b->type == bp_access_watchpoint)
3398 && b->enable == enabled)
3399 *other_type_used = 1;
3405 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
3406 breakpoint at the target of the jmp_buf.
3408 FIXME - This ought to be done by setting a temporary breakpoint that gets
3409 deleted automatically... */
3412 set_longjmp_resume_breakpoint(pc, frame)
3414 struct frame_info *frame;
3416 register struct breakpoint *b;
3419 if (b->type == bp_longjmp_resume)
3422 b->enable = enabled;
3424 b->frame = frame->frame;
3427 check_duplicates (b->address, b->section);
3433 disable_watchpoints_before_interactive_call_start ()
3435 struct breakpoint * b;
3439 if (((b->type == bp_watchpoint)
3440 || (b->type == bp_hardware_watchpoint)
3441 || (b->type == bp_read_watchpoint)
3442 || (b->type == bp_access_watchpoint)
3443 || ep_is_exception_catchpoint (b))
3444 && (b->enable == enabled))
3446 b->enable = call_disabled;
3447 check_duplicates (b->address, b->section);
3453 enable_watchpoints_after_interactive_call_stop ()
3455 struct breakpoint * b;
3459 if (((b->type == bp_watchpoint)
3460 || (b->type == bp_hardware_watchpoint)
3461 || (b->type == bp_read_watchpoint)
3462 || (b->type == bp_access_watchpoint)
3463 || ep_is_exception_catchpoint (b))
3464 && (b->enable == call_disabled))
3466 b->enable = enabled;
3467 check_duplicates (b->address, b->section);
3473 /* Set a breakpoint that will evaporate an end of command
3474 at address specified by SAL.
3475 Restrict it to frame FRAME if FRAME is nonzero. */
3478 set_momentary_breakpoint (sal, frame, type)
3479 struct symtab_and_line sal;
3480 struct frame_info *frame;
3483 register struct breakpoint *b;
3484 b = set_raw_breakpoint (sal);
3486 b->enable = enabled;
3487 b->disposition = donttouch;
3488 b->frame = (frame ? frame->frame : 0);
3490 /* If we're debugging a multi-threaded program, then we
3491 want momentary breakpoints to be active in only a
3492 single thread of control. */
3493 if (in_thread_list (inferior_pid))
3494 b->thread = pid_to_thread_id (inferior_pid);
3500 /* Tell the user we have just set a breakpoint B. */
3504 struct breakpoint *b;
3508 /* FIXME: This is misplaced; mention() is called by things (like hitting a
3509 watchpoint) other than breakpoint creation. It should be possible to
3510 clean this up and at the same time replace the random calls to
3511 breakpoint_changed with this hook, as has already been done for
3512 delete_breakpoint_hook and so on. */
3513 if (create_breakpoint_hook)
3514 create_breakpoint_hook (b);
3519 printf_filtered ("(apparently deleted?) Eventpoint %d: ", b->number);
3522 printf_filtered ("Watchpoint %d: ", b->number);
3523 print_expression (b->exp, gdb_stdout);
3525 case bp_hardware_watchpoint:
3526 printf_filtered ("Hardware watchpoint %d: ", b->number);
3527 print_expression (b->exp, gdb_stdout);
3529 case bp_read_watchpoint:
3530 printf_filtered ("Hardware read watchpoint %d: ", b->number);
3531 print_expression (b->exp, gdb_stdout);
3533 case bp_access_watchpoint:
3534 printf_filtered ("Hardware access (read/write) watchpoint %d: ",b->number);
3535 print_expression (b->exp, gdb_stdout);
3538 printf_filtered ("Breakpoint %d", b->number);
3541 case bp_hardware_breakpoint:
3542 printf_filtered ("Hardware assisted breakpoint %d", b->number);
3546 case bp_catch_unload:
3547 printf_filtered ("Catchpoint %d (%s %s)",
3549 (b->type == bp_catch_load) ? "load" : "unload",
3550 (b->dll_pathname != NULL) ? b->dll_pathname : "<any library>");
3553 case bp_catch_vfork:
3554 printf_filtered ("Catchpoint %d (%s)",
3556 (b->type == bp_catch_fork) ? "fork" : "vfork");
3559 printf_filtered ("Catchpoint %d (exec)",
3562 case bp_catch_catch:
3563 case bp_catch_throw:
3564 printf_filtered ("Catchpoint %d (%s)",
3566 (b->type == bp_catch_catch) ? "catch" : "throw");
3572 case bp_longjmp_resume:
3573 case bp_step_resume:
3574 case bp_through_sigtramp:
3576 case bp_watchpoint_scope:
3577 case bp_shlib_event:
3582 if (addressprint || b->source_file == NULL)
3584 printf_filtered (" at ");
3585 print_address_numeric (b->address, 1, gdb_stdout);
3588 printf_filtered (": file %s, line %d.",
3589 b->source_file, b->line_number);
3590 TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, b, 1));
3591 TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos));
3593 printf_filtered ("\n");
3597 /* Set a breakpoint according to ARG (function, linenum or *address)
3598 flag: first bit : 0 non-temporary, 1 temporary.
3599 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
3602 break_command_1 (arg, flag, from_tty)
3606 int tempflag, hardwareflag;
3607 struct symtabs_and_lines sals;
3608 struct symtab_and_line sal;
3609 register struct expression *cond = 0;
3610 register struct breakpoint *b;
3612 /* Pointers in arg to the start, and one past the end, of the condition. */
3613 char *cond_start = NULL;
3614 char *cond_end = NULL;
3615 /* Pointers in arg to the start, and one past the end,
3616 of the address part. */
3617 char *addr_start = NULL;
3618 char *addr_end = NULL;
3619 struct cleanup *old_chain;
3620 struct cleanup *canonical_strings_chain = NULL;
3621 char **canonical = (char **)NULL;
3625 hardwareflag = flag & BP_HARDWAREFLAG;
3626 tempflag = flag & BP_TEMPFLAG;
3631 INIT_SAL (&sal); /* initialize to zeroes */
3633 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
3635 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
3636 && (arg[2] == ' ' || arg[2] == '\t')))
3638 if (default_breakpoint_valid)
3640 sals.sals = (struct symtab_and_line *)
3641 xmalloc (sizeof (struct symtab_and_line));
3642 sal.pc = default_breakpoint_address;
3643 sal.line = default_breakpoint_line;
3644 sal.symtab = default_breakpoint_symtab;
3645 sal.section = find_pc_overlay (sal.pc);
3650 error ("No default breakpoint address now.");
3656 /* Force almost all breakpoints to be in terms of the
3657 current_source_symtab (which is decode_line_1's default). This
3658 should produce the results we want almost all of the time while
3659 leaving default_breakpoint_* alone. */
3660 if (default_breakpoint_valid
3661 && (!current_source_symtab
3662 || (arg && (*arg == '+' || *arg == '-'))))
3663 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
3664 default_breakpoint_line, &canonical);
3666 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
3674 /* Make sure that all storage allocated in decode_line_1 gets freed in case
3675 the following `for' loop errors out. */
3676 old_chain = make_cleanup (free, sals.sals);
3677 if (canonical != (char **)NULL)
3679 make_cleanup (free, canonical);
3680 canonical_strings_chain = make_cleanup (null_cleanup, 0);
3681 for (i = 0; i < sals.nelts; i++)
3683 if (canonical[i] != NULL)
3684 make_cleanup (free, canonical[i]);
3688 thread = -1; /* No specific thread yet */
3690 /* Resolve all line numbers to PC's, and verify that conditions
3691 can be parsed, before setting any breakpoints. */
3692 for (i = 0; i < sals.nelts; i++)
3694 char *tok, *end_tok;
3697 resolve_sal_pc (&sals.sals[i]);
3699 /* It's possible for the PC to be nonzero, but still an illegal
3700 value on some targets.
3702 For example, on HP-UX if you start gdb, and before running the
3703 inferior you try to set a breakpoint on a shared library function
3704 "foo" where the inferior doesn't call "foo" directly but does
3705 pass its address to another function call, then we do find a
3706 minimal symbol for the "foo", but it's address is invalid.
3707 (Appears to be an index into a table that the loader sets up
3708 when the inferior is run.)
3710 Give the target a chance to bless sals.sals[i].pc before we
3711 try to make a breakpoint for it. */
3712 if (PC_REQUIRES_RUN_BEFORE_USE(sals.sals[i].pc))
3714 error ("Cannot break on %s without a running program.", addr_start);
3721 while (*tok == ' ' || *tok == '\t')
3726 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
3729 toklen = end_tok - tok;
3731 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
3733 tok = cond_start = end_tok + 1;
3734 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
3737 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
3743 thread = strtol (tok, &tok, 0);
3745 error ("Junk after thread keyword.");
3746 if (!valid_thread_id (thread))
3747 error ("Unknown thread %d\n", thread);
3750 error ("Junk at end of arguments.");
3755 int i, target_resources_ok;
3757 i = hw_breakpoint_used_count ();
3758 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
3759 bp_hardware_breakpoint, i + sals.nelts, 0);
3760 if (target_resources_ok == 0)
3761 error ("No hardware breakpoint support in the target.");
3762 else if (target_resources_ok < 0)
3763 error ("Hardware breakpoints used exceeds limit.");
3766 /* Remove the canonical strings from the cleanup, they are needed below. */
3767 if (canonical != (char **)NULL)
3768 discard_cleanups (canonical_strings_chain);
3770 /* Now set all the breakpoints. */
3771 for (i = 0; i < sals.nelts; i++)
3776 describe_other_breakpoints (sal.pc, sal.section);
3778 b = set_raw_breakpoint (sal);
3779 set_breakpoint_count (breakpoint_count + 1);
3780 b->number = breakpoint_count;
3781 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
3785 /* If a canonical line spec is needed use that instead of the
3787 if (canonical != (char **)NULL && canonical[i] != NULL)
3788 b->addr_string = canonical[i];
3789 else if (addr_start)
3790 b->addr_string = savestring (addr_start, addr_end - addr_start);
3792 b->cond_string = savestring (cond_start, cond_end - cond_start);
3794 b->enable = enabled;
3795 b->disposition = tempflag ? del : donttouch;
3801 printf_filtered ("Multiple breakpoints were set.\n");
3802 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3804 do_cleanups (old_chain);
3808 break_at_finish_at_depth_command_1 (arg, flag, from_tty)
3813 struct frame_info *frame;
3814 CORE_ADDR low, high, selected_pc = 0;
3815 char *extra_args, *level_arg, *addr_string;
3816 int extra_args_len = 0, if_arg = 0;
3819 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
3822 if (default_breakpoint_valid)
3826 selected_pc = selected_frame->pc;
3831 error ("No selected frame.");
3834 error ("No default breakpoint address now.");
3838 extra_args = strchr (arg, ' ');
3842 extra_args_len = strlen (extra_args);
3843 level_arg = (char *) xmalloc (extra_args - arg);
3844 strncpy (level_arg, arg, extra_args - arg - 1);
3845 level_arg[extra_args - arg - 1] = '\0';
3849 level_arg = (char *) xmalloc (strlen (arg) + 1);
3850 strcpy (level_arg, arg);
3853 frame = parse_frame_specification (level_arg);
3855 selected_pc = frame->pc;
3862 extra_args_len = strlen (arg);
3867 if (find_pc_partial_function(selected_pc, (char **)NULL, &low, &high))
3869 addr_string = (char *) xmalloc (26 + extra_args_len);
3871 sprintf (addr_string, "*0x%x %s", high, extra_args);
3873 sprintf (addr_string, "*0x%x", high);
3874 break_command_1 (addr_string, flag, from_tty);
3878 error ("No function contains the specified address");
3881 error ("Unable to set breakpoint at procedure exit");
3886 break_at_finish_command_1 (arg, flag, from_tty)
3891 char *addr_string, *break_string, *beg_addr_string;
3892 CORE_ADDR low, high;
3893 struct symtabs_and_lines sals;
3894 struct symtab_and_line sal;
3895 struct cleanup *old_chain;
3897 int extra_args_len = 0;
3901 (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')))
3903 if (default_breakpoint_valid)
3907 addr_string = (char *) xmalloc (15);
3908 sprintf (addr_string, "*0x%x", selected_frame->pc);
3913 error ("No selected frame.");
3916 error ("No default breakpoint address now.");
3920 addr_string = (char *) xmalloc (strlen (arg) + 1);
3921 strcpy (addr_string, arg);
3927 extra_args_len = strlen (arg);
3932 /* get the stuff after the function name or address */
3933 extra_args = strchr (arg, ' ');
3937 extra_args_len = strlen (extra_args);
3944 beg_addr_string = addr_string;
3945 sals = decode_line_1 (&addr_string, 1, (struct symtab *)NULL, 0,
3948 free (beg_addr_string);
3949 old_chain = make_cleanup (free, sals.sals);
3950 for (i = 0; (i < sals.nelts); i++)
3953 if (find_pc_partial_function (sal.pc, (char **)NULL, &low, &high))
3955 break_string = (char *) xmalloc (extra_args_len + 26);
3957 sprintf (break_string, "*0x%x %s", high, extra_args);
3959 sprintf (break_string, "*0x%x", high);
3960 break_command_1 (break_string, flag, from_tty);
3964 error ("No function contains the specified address");
3968 printf_filtered ("Multiple breakpoints were set.\n");
3969 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3971 do_cleanups(old_chain);
3975 /* Helper function for break_command_1 and disassemble_command. */
3978 resolve_sal_pc (sal)
3979 struct symtab_and_line *sal;
3983 if (sal->pc == 0 && sal->symtab != NULL)
3985 if (!find_line_pc (sal->symtab, sal->line, &pc))
3986 error ("No line %d in file \"%s\".",
3987 sal->line, sal->symtab->filename);
3991 if (sal->section == 0 && sal->symtab != NULL)
3993 struct blockvector *bv;
3998 bv = blockvector_for_pc_sect (sal->pc, 0, &index, sal->symtab);
4001 b = BLOCKVECTOR_BLOCK (bv, index);
4002 sym = block_function (b);
4005 fixup_symbol_section (sym, sal->symtab->objfile);
4006 sal->section = SYMBOL_BFD_SECTION (sym);
4010 /* It really is worthwhile to have the section, so we'll just
4011 have to look harder. This case can be executed if we have
4012 line numbers but no functions (as can happen in assembly
4015 struct minimal_symbol *msym;
4017 msym = lookup_minimal_symbol_by_pc (sal->pc);
4019 sal->section = SYMBOL_BFD_SECTION (msym);
4026 break_command (arg, from_tty)
4030 break_command_1 (arg, 0, from_tty);
4034 break_at_finish_command (arg, from_tty)
4038 break_at_finish_command_1 (arg, 0, from_tty);
4042 break_at_finish_at_depth_command (arg, from_tty)
4046 break_at_finish_at_depth_command_1 (arg, 0, from_tty);
4050 tbreak_command (arg, from_tty)
4054 break_command_1 (arg, BP_TEMPFLAG, from_tty);
4058 tbreak_at_finish_command (arg, from_tty)
4062 break_at_finish_command_1 (arg, BP_TEMPFLAG, from_tty);
4066 hbreak_command (arg, from_tty)
4070 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
4074 thbreak_command (arg, from_tty)
4078 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
4082 stop_command (arg, from_tty)
4086 printf_filtered ("Specify the type of breakpoint to set.\n\
4087 Usage: stop in <function | address>\n\
4092 stopin_command (arg, from_tty)
4098 if (arg == (char *)NULL)
4100 else if (*arg != '*')
4105 /* look for a ':'. If this is a line number specification, then say
4106 it is bad, otherwise, it should be an address or function/method
4108 while (*argptr && !hasColon)
4110 hasColon = (*argptr == ':');
4115 badInput = (*argptr != ':'); /* Not a class::method */
4117 badInput = isdigit(*arg); /* a simple line number */
4121 printf_filtered("Usage: stop in <function | address>\n");
4123 break_command_1 (arg, 0, from_tty);
4127 stopat_command (arg, from_tty)
4133 if (arg == (char *)NULL || *arg == '*') /* no line number */
4140 /* look for a ':'. If there is a '::' then get out, otherwise
4141 it is probably a line number. */
4142 while (*argptr && !hasColon)
4144 hasColon = (*argptr == ':');
4149 badInput = (*argptr == ':'); /* we have class::method */
4151 badInput = !isdigit(*arg); /* not a line number */
4155 printf_filtered("Usage: stop at <line>\n");
4157 break_command_1 (arg, 0, from_tty);
4161 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write) */
4163 watch_command_1 (arg, accessflag, from_tty)
4168 struct breakpoint *b;
4169 struct symtab_and_line sal;
4170 struct expression *exp;
4171 struct block *exp_valid_block;
4172 struct value *val, *mark;
4173 struct frame_info *frame;
4174 struct frame_info *prev_frame = NULL;
4175 char *exp_start = NULL;
4176 char *exp_end = NULL;
4177 char *tok, *end_tok;
4179 char *cond_start = NULL;
4180 char *cond_end = NULL;
4181 struct expression *cond = NULL;
4182 int i, other_type_used, target_resources_ok = 0;
4183 enum bptype bp_type;
4186 INIT_SAL (&sal); /* initialize to zeroes */
4188 /* Parse arguments. */
4189 innermost_block = NULL;
4191 exp = parse_exp_1 (&arg, 0, 0);
4193 exp_valid_block = innermost_block;
4194 mark = value_mark ();
4195 val = evaluate_expression (exp);
4196 release_value (val);
4197 if (VALUE_LAZY (val))
4198 value_fetch_lazy (val);
4201 while (*tok == ' ' || *tok == '\t')
4205 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
4208 toklen = end_tok - tok;
4209 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
4211 tok = cond_start = end_tok + 1;
4212 cond = parse_exp_1 (&tok, 0, 0);
4216 error("Junk at end of command.");
4218 if (accessflag == 1) bp_type = bp_read_watchpoint;
4219 else if (accessflag == 2) bp_type = bp_access_watchpoint;
4220 else bp_type = bp_hardware_watchpoint;
4222 mem_cnt = can_use_hardware_watchpoint (val);
4223 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
4224 error ("Expression cannot be implemented with read/access watchpoint.");
4226 i = hw_watchpoint_used_count (bp_type, &other_type_used);
4227 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
4228 bp_type, i + mem_cnt, other_type_used);
4229 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
4230 error ("Target does not have this type of hardware watchpoint support.");
4231 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
4232 error ("Target resources have been allocated for other types of watchpoints.");
4235 #if defined(HPUXHPPA)
4236 /* ??rehrauer: DTS #CHFts23014 notes that on HP-UX if you set a h/w
4237 watchpoint before the "run" command, the inferior dies with a e.g.,
4238 SIGILL once you start it. I initially believed this was due to a
4239 bad interaction between page protection traps and the initial
4240 startup sequence by the dynamic linker.
4242 However, I tried avoiding that by having HP-UX's implementation of
4243 TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
4244 yet, which forced slow watches before a "run" or "attach", and it
4245 still fails somewhere in the startup code.
4247 Until I figure out what's happening, I'm disallowing watches altogether
4248 before the "run" or "attach" command. We'll tell the user they must
4249 set watches after getting the program started. */
4250 if (! target_has_execution)
4252 warning ("can't do that without a running program; try \"break main\", \"run\" first");
4255 #endif /* HPUXHPPA */
4257 /* Now set up the breakpoint. */
4258 b = set_raw_breakpoint (sal);
4259 set_breakpoint_count (breakpoint_count + 1);
4260 b->number = breakpoint_count;
4261 b->disposition = donttouch;
4263 b->exp_valid_block = exp_valid_block;
4264 b->exp_string = savestring (exp_start, exp_end - exp_start);
4268 b->cond_string = savestring (cond_start, cond_end - cond_start);
4272 frame = block_innermost_frame (exp_valid_block);
4275 prev_frame = get_prev_frame (frame);
4276 b->watchpoint_frame = frame->frame;
4279 b->watchpoint_frame = (CORE_ADDR)0;
4281 if (mem_cnt && target_resources_ok > 0)
4284 b->type = bp_watchpoint;
4286 /* If the expression is "local", then set up a "watchpoint scope"
4287 breakpoint at the point where we've left the scope of the watchpoint
4289 if (innermost_block)
4293 struct breakpoint *scope_breakpoint;
4294 struct symtab_and_line scope_sal;
4296 INIT_SAL (&scope_sal); /* initialize to zeroes */
4297 scope_sal.pc = get_frame_pc (prev_frame);
4298 scope_sal.section = find_pc_overlay (scope_sal.pc);
4300 scope_breakpoint = set_raw_breakpoint (scope_sal);
4301 set_breakpoint_count (breakpoint_count + 1);
4302 scope_breakpoint->number = breakpoint_count;
4304 scope_breakpoint->type = bp_watchpoint_scope;
4305 scope_breakpoint->enable = enabled;
4307 /* Automatically delete the breakpoint when it hits. */
4308 scope_breakpoint->disposition = del;
4310 /* Only break in the proper frame (help with recursion). */
4311 scope_breakpoint->frame = prev_frame->frame;
4313 /* Set the address at which we will stop. */
4314 scope_breakpoint->address = get_frame_pc (prev_frame);
4316 /* The scope breakpoint is related to the watchpoint. We
4317 will need to act on them together. */
4318 b->related_breakpoint = scope_breakpoint;
4321 value_free_to_mark (mark);
4325 /* Return count of locations need to be watched and can be handled
4326 in hardware. If the watchpoint can not be handled
4327 in hardware return zero. */
4329 #if !defined(TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT)
4330 #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(byte_size) \
4331 ((byte_size) <= (REGISTER_SIZE))
4335 can_use_hardware_watchpoint (v)
4338 int found_memory_cnt = 0;
4340 /* Did the user specifically forbid us to use hardware watchpoints? */
4341 if (! can_use_hw_watchpoints)
4344 /* Make sure all the intermediate values are in memory. Also make sure
4345 we found at least one memory expression. Guards against watch 0x12345,
4346 which is meaningless, but could cause errors if one tries to insert a
4347 hardware watchpoint for the constant expression. */
4348 for ( ; v; v = v->next)
4350 if (v->lval == lval_memory)
4352 if (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (TYPE_LENGTH (VALUE_TYPE (v))))
4355 else if (v->lval != not_lval && v->modifiable == 0)
4359 /* The expression itself looks suitable for using a hardware
4360 watchpoint, but give the target machine a chance to reject it. */
4361 return found_memory_cnt;
4364 static void watch_command (arg, from_tty)
4368 watch_command_1 (arg, 0, from_tty);
4371 static void rwatch_command (arg, from_tty)
4375 watch_command_1 (arg, 1, from_tty);
4378 static void awatch_command (arg, from_tty)
4382 watch_command_1 (arg, 2, from_tty);
4386 /* Helper routine for the until_command routine in infcmd.c. Here
4387 because it uses the mechanisms of breakpoints. */
4391 until_break_command (arg, from_tty)
4395 struct symtabs_and_lines sals;
4396 struct symtab_and_line sal;
4397 struct frame_info *prev_frame = get_prev_frame (selected_frame);
4398 struct breakpoint *breakpoint;
4399 struct cleanup *old_chain;
4401 clear_proceed_status ();
4403 /* Set a breakpoint where the user wants it and at return from
4406 if (default_breakpoint_valid)
4407 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
4408 default_breakpoint_line, (char ***)NULL);
4410 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
4412 if (sals.nelts != 1)
4413 error ("Couldn't get information on specified line.");
4416 free ((PTR)sals.sals); /* malloc'd, so freed */
4419 error ("Junk at end of arguments.");
4421 resolve_sal_pc (&sal);
4423 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
4425 old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4427 /* Keep within the current frame */
4431 sal = find_pc_line (prev_frame->pc, 0);
4432 sal.pc = prev_frame->pc;
4433 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
4434 make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
4437 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
4438 do_cleanups(old_chain);
4442 /* These aren't used; I don't konw what they were for. */
4443 /* Set a breakpoint at the catch clause for NAME. */
4445 catch_breakpoint (name)
4451 disable_catch_breakpoint ()
4456 delete_catch_breakpoint ()
4461 enable_catch_breakpoint ()
4468 struct sal_chain *next;
4469 struct symtab_and_line sal;
4472 /* Not really used -- invocation in handle_gnu_4_16_catch_command
4473 had been commented out in the v.4.16 sources, and stays
4474 disabled there now because "catch NAME" syntax isn't allowed.
4476 /* This isn't used; I don't know what it was for. */
4477 /* For each catch clause identified in ARGS, run FUNCTION
4478 with that clause as an argument. */
4479 static struct symtabs_and_lines
4480 map_catch_names (args, function)
4484 register char *p = args;
4486 struct symtabs_and_lines sals;
4488 struct sal_chain *sal_chain = 0;
4492 error_no_arg ("one or more catch names");
4500 /* Don't swallow conditional part. */
4501 if (p1[0] == 'i' && p1[1] == 'f'
4502 && (p1[2] == ' ' || p1[2] == '\t'))
4508 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
4512 if (*p1 && *p1 != ' ' && *p1 != '\t')
4513 error ("Arguments must be catch names.");
4519 struct sal_chain *next = (struct sal_chain *)
4520 alloca (sizeof (struct sal_chain));
4521 next->next = sal_chain;
4522 next->sal = get_catch_sal (p);
4527 printf_unfiltered ("No catch clause for exception %s.\n", p);
4532 while (*p == ' ' || *p == '\t') p++;
4536 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
4538 static struct symtabs_and_lines
4539 get_catch_sals (this_level_only)
4540 int this_level_only;
4542 register struct blockvector *bl;
4543 register struct block *block;
4544 int index, have_default = 0;
4546 struct symtabs_and_lines sals;
4547 struct sal_chain *sal_chain = 0;
4548 char *blocks_searched;
4550 /* Not sure whether an error message is always the correct response,
4551 but it's better than a core dump. */
4552 if (selected_frame == NULL)
4553 error ("No selected frame.");
4554 block = get_frame_block (selected_frame);
4555 pc = selected_frame->pc;
4561 error ("No symbol table info available.\n");
4563 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
4564 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4565 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
4569 CORE_ADDR end = BLOCK_END (block) - 4;
4572 if (bl != blockvector_for_pc (end, &index))
4573 error ("blockvector blotch");
4574 if (BLOCKVECTOR_BLOCK (bl, index) != block)
4575 error ("blockvector botch");
4576 last_index = BLOCKVECTOR_NBLOCKS (bl);
4579 /* Don't print out blocks that have gone by. */
4580 while (index < last_index
4581 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
4584 while (index < last_index
4585 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
4587 if (blocks_searched[index] == 0)
4589 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
4592 register struct symbol *sym;
4594 nsyms = BLOCK_NSYMS (b);
4596 for (i = 0; i < nsyms; i++)
4598 sym = BLOCK_SYM (b, i);
4599 if (STREQ (SYMBOL_NAME (sym), "default"))
4605 if (SYMBOL_CLASS (sym) == LOC_LABEL)
4607 struct sal_chain *next = (struct sal_chain *)
4608 alloca (sizeof (struct sal_chain));
4609 next->next = sal_chain;
4610 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
4614 blocks_searched[index] = 1;
4620 if (sal_chain && this_level_only)
4623 /* After handling the function's top-level block, stop.
4624 Don't continue to its superblock, the block of
4625 per-file symbols. */
4626 if (BLOCK_FUNCTION (block))
4628 block = BLOCK_SUPERBLOCK (block);
4633 struct sal_chain *tmp_chain;
4635 /* Count the number of entries. */
4636 for (index = 0, tmp_chain = sal_chain; tmp_chain;
4637 tmp_chain = tmp_chain->next)
4641 sals.sals = (struct symtab_and_line *)
4642 xmalloc (index * sizeof (struct symtab_and_line));
4643 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
4644 sals.sals[index] = sal_chain->sal;
4651 ep_skip_leading_whitespace (s)
4654 if ((s == NULL) || (*s == NULL))
4656 while (isspace(**s))
4660 /* This function examines a string, and attempts to find a token
4661 that might be an event name in the leading characters. If a
4662 possible match is found, a pointer to the last character of
4663 the token is returned. Else, NULL is returned. */
4665 ep_find_event_name_end (arg)
4669 char * event_name_end = NULL;
4671 /* If we could depend upon the presense of strrpbrk, we'd use that... */
4675 /* We break out of the loop when we find a token delimiter.
4676 Basically, we're looking for alphanumerics and underscores;
4677 anything else delimites the token. */
4680 if (! isalnum(*s) && (*s != '_'))
4686 return event_name_end;
4690 /* This function attempts to parse an optional "if <cond>" clause
4691 from the arg string. If one is not found, it returns NULL.
4693 Else, it returns a pointer to the condition string. (It does not
4694 attempt to evaluate the string against a particular block.) And,
4695 it updates arg to point to the first character following the parsed
4696 if clause in the arg string. */
4698 ep_parse_optional_if_clause (arg)
4703 if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace((*arg)[2]))
4706 /* Skip the "if" keyword. */
4709 /* Skip any extra leading whitespace, and record the start of the
4710 condition string. */
4711 ep_skip_leading_whitespace (arg);
4714 /* Assume that the condition occupies the remainder of the arg string. */
4715 (*arg) += strlen (cond_string);
4720 /* This function attempts to parse an optional filename from the arg
4721 string. If one is not found, it returns NULL.
4723 Else, it returns a pointer to the parsed filename. (This function
4724 makes no attempt to verify that a file of that name exists, or is
4725 accessible.) And, it updates arg to point to the first character
4726 following the parsed filename in the arg string.
4728 Note that clients needing to preserve the returned filename for
4729 future access should copy it to their own buffers. */
4731 ep_parse_optional_filename (arg)
4734 static char filename [1024];
4735 char * arg_p = *arg;
4739 if ((*arg_p == '\0') || isspace (*arg_p))
4757 /* Commands to deal with catching events, such as signals, exceptions,
4758 process start/exit, etc. */
4760 typedef enum {catch_fork, catch_vfork} catch_fork_kind;
4763 catch_fork_command_1 (fork_kind, arg, tempflag, from_tty)
4764 catch_fork_kind fork_kind;
4769 char * cond_string = NULL;
4771 ep_skip_leading_whitespace (&arg);
4773 /* The allowed syntax is:
4775 catch [v]fork if <cond>
4777 First, check if there's an if clause. */
4778 cond_string = ep_parse_optional_if_clause (&arg);
4780 if ((*arg != '\0') && !isspace (*arg))
4781 error ("Junk at end of arguments.");
4783 /* If this target supports it, create a fork or vfork catchpoint
4784 and enable reporting of such events. */
4785 switch (fork_kind) {
4787 create_fork_event_catchpoint (tempflag, cond_string);
4790 create_vfork_event_catchpoint (tempflag, cond_string);
4793 error ("unsupported or unknown fork kind; cannot catch it");
4799 catch_exec_command_1 (arg, tempflag, from_tty)
4804 char * cond_string = NULL;
4806 ep_skip_leading_whitespace (&arg);
4808 /* The allowed syntax is:
4810 catch exec if <cond>
4812 First, check if there's an if clause. */
4813 cond_string = ep_parse_optional_if_clause (&arg);
4815 if ((*arg != '\0') && !isspace (*arg))
4816 error ("Junk at end of arguments.");
4818 /* If this target supports it, create an exec catchpoint
4819 and enable reporting of such events. */
4820 create_exec_event_catchpoint (tempflag, cond_string);
4823 #if defined(SOLIB_ADD)
4825 catch_load_command_1 (arg, tempflag, from_tty)
4830 char * dll_pathname = NULL;
4831 char * cond_string = NULL;
4833 ep_skip_leading_whitespace (&arg);
4835 /* The allowed syntax is:
4837 catch load if <cond>
4838 catch load <filename>
4839 catch load <filename> if <cond>
4841 The user is not allowed to specify the <filename> after an
4844 We'll ignore the pathological case of a file named "if".
4846 First, check if there's an if clause. If so, then there
4847 cannot be a filename. */
4848 cond_string = ep_parse_optional_if_clause (&arg);
4850 /* If there was an if clause, then there cannot be a filename.
4851 Else, there might be a filename and an if clause. */
4852 if (cond_string == NULL)
4854 dll_pathname = ep_parse_optional_filename (&arg);
4855 ep_skip_leading_whitespace (&arg);
4856 cond_string = ep_parse_optional_if_clause (&arg);
4859 if ((*arg != '\0') && !isspace (*arg))
4860 error ("Junk at end of arguments.");
4862 /* Create a load breakpoint that only triggers when a load of
4863 the specified dll (or any dll, if no pathname was specified)
4865 SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
4869 catch_unload_command_1 (arg, tempflag, from_tty)
4874 char * dll_pathname = NULL;
4875 char * cond_string = NULL;
4877 ep_skip_leading_whitespace (&arg);
4879 /* The allowed syntax is:
4881 catch unload if <cond>
4882 catch unload <filename>
4883 catch unload <filename> if <cond>
4885 The user is not allowed to specify the <filename> after an
4888 We'll ignore the pathological case of a file named "if".
4890 First, check if there's an if clause. If so, then there
4891 cannot be a filename. */
4892 cond_string = ep_parse_optional_if_clause (&arg);
4894 /* If there was an if clause, then there cannot be a filename.
4895 Else, there might be a filename and an if clause. */
4896 if (cond_string == NULL)
4898 dll_pathname = ep_parse_optional_filename (&arg);
4899 ep_skip_leading_whitespace (&arg);
4900 cond_string = ep_parse_optional_if_clause (&arg);
4903 if ((*arg != '\0') && !isspace (*arg))
4904 error ("Junk at end of arguments.");
4906 /* Create an unload breakpoint that only triggers when an unload of
4907 the specified dll (or any dll, if no pathname was specified)
4909 SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string);
4911 #endif /* SOLIB_ADD */
4913 /* Commands to deal with catching exceptions. */
4915 /* Set a breakpoint at the specified callback routine for an
4916 exception event callback */
4919 create_exception_catchpoint (tempflag, cond_string, ex_event, sal)
4922 enum exception_event_kind ex_event;
4923 struct symtab_and_line * sal;
4925 struct breakpoint * b;
4927 int thread = -1; /* All threads. */
4929 if (!sal) /* no exception support? */
4932 b = set_raw_breakpoint (*sal);
4933 set_breakpoint_count (breakpoint_count + 1);
4934 b->number = breakpoint_count;
4936 b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string));
4938 b->addr_string = NULL;
4939 b->enable = enabled;
4940 b->disposition = tempflag ? del : donttouch;
4943 case EX_EVENT_THROW:
4944 b->type = bp_catch_throw;
4946 case EX_EVENT_CATCH:
4947 b->type = bp_catch_catch;
4949 default: /* error condition */
4951 b->enable = disabled;
4952 error ("Internal error -- invalid catchpoint kind");
4957 /* Deal with "catch catch" and "catch throw" commands */
4960 catch_exception_command_1 (ex_event, arg, tempflag, from_tty)
4961 enum exception_event_kind ex_event;
4966 char * cond_string = NULL;
4967 struct symtab_and_line * sal = NULL;
4969 ep_skip_leading_whitespace (&arg);
4971 cond_string = ep_parse_optional_if_clause (&arg);
4973 if ((*arg != '\0') && !isspace (*arg))
4974 error ("Junk at end of arguments.");
4976 if ((ex_event != EX_EVENT_THROW) &&
4977 (ex_event != EX_EVENT_CATCH))
4978 error ("Unsupported or unknown exception event; cannot catch it");
4980 /* See if we can find a callback routine */
4981 sal = target_enable_exception_callback (ex_event, 1);
4985 /* We have callbacks from the runtime system for exceptions.
4986 Set a breakpoint on the sal found, if no errors */
4987 if (sal != (struct symtab_and_line *) -1)
4988 create_exception_catchpoint (tempflag, cond_string, ex_event, sal);
4990 return; /* something went wrong with setting up callbacks */
4994 /* No callbacks from runtime system for exceptions.
4995 Try GNU C++ exception breakpoints using labels in debug info. */
4996 if (ex_event == EX_EVENT_CATCH)
4998 handle_gnu_4_16_catch_command (arg, tempflag, from_tty);
5000 else if (ex_event == EX_EVENT_THROW)
5002 /* Set a breakpoint on __raise_exception () */
5004 fprintf_filtered (gdb_stderr, "Unsupported with this platform/compiler combination.\n");
5005 fprintf_filtered (gdb_stderr, "Perhaps you can achieve the effect you want by setting\n");
5006 fprintf_filtered (gdb_stderr, "a breakpoint on __raise_exception().\n");
5011 /* Cover routine to allow wrapping target_enable_exception_catchpoints
5012 inside a catch_errors */
5015 cover_target_enable_exception_callback (arg)
5018 args_for_catchpoint_enable *args = arg;
5019 struct symtab_and_line *sal;
5020 sal = target_enable_exception_callback (args->kind, args->enable);
5023 else if (sal == (struct symtab_and_line *) -1)
5026 return 1; /*is valid*/
5031 /* This is the original v.4.16 and earlier version of the
5032 catch_command_1() function. Now that other flavours of "catch"
5033 have been introduced, and since exception handling can be handled
5034 in other ways (through target ops) also, this is used only for the
5035 GNU C++ exception handling system.
5036 Note: Only the "catch" flavour of GDB 4.16 is handled here. The
5037 "catch NAME" is now no longer allowed in catch_command_1(). Also,
5038 there was no code in GDB 4.16 for "catch throw".
5040 Called from catch_exception_command_1 () */
5044 handle_gnu_4_16_catch_command (arg, tempflag, from_tty)
5049 /* First, translate ARG into something we can deal with in terms
5052 struct symtabs_and_lines sals;
5053 struct symtab_and_line sal;
5054 register struct expression *cond = 0;
5055 register struct breakpoint *b;
5059 INIT_SAL (&sal); /* initialize to zeroes */
5061 /* If no arg given, or if first arg is 'if ', all active catch clauses
5062 are breakpointed. */
5064 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
5065 && (arg[2] == ' ' || arg[2] == '\t')))
5067 /* Grab all active catch clauses. */
5068 sals = get_catch_sals (0);
5072 /* Grab selected catch clauses. */
5073 error ("catch NAME not implemented");
5076 /* Not sure why this code has been disabled. I'm leaving
5077 it disabled. We can never come here now anyway
5078 since we don't allow the "catch NAME" syntax.
5081 /* This isn't used; I don't know what it was for. */
5082 sals = map_catch_names (arg, catch_breakpoint);
5090 for (i = 0; i < sals.nelts; i++)
5092 resolve_sal_pc (&sals.sals[i]);
5096 if (arg[0] == 'i' && arg[1] == 'f'
5097 && (arg[2] == ' ' || arg[2] == '\t'))
5098 cond = parse_exp_1 ((arg += 2, &arg),
5099 block_for_pc (sals.sals[i].pc), 0);
5101 error ("Junk at end of arguments.");
5106 for (i = 0; i < sals.nelts; i++)
5111 describe_other_breakpoints (sal.pc, sal.section);
5113 b = set_raw_breakpoint (sal);
5114 set_breakpoint_count (breakpoint_count + 1);
5115 b->number = breakpoint_count;
5116 b->type = bp_breakpoint; /* Important -- this is an ordinary breakpoint.
5117 For platforms with callback support for exceptions,
5118 create_exception_catchpoint() will create special
5119 bp types (bp_catch_catch and bp_catch_throw), and
5120 there is code in insert_breakpoints() and elsewhere
5121 that depends on that. */
5124 b->enable = enabled;
5125 b->disposition = tempflag ? del : donttouch;
5132 printf_unfiltered ("Multiple breakpoints were set.\n");
5133 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
5135 free ((PTR)sals.sals);
5139 /* This creates a temporary internal breakpoint
5140 just to placate infrun */
5141 static struct breakpoint *
5142 create_temp_exception_breakpoint (pc)
5145 struct symtab_and_line sal;
5146 struct breakpoint *b;
5153 b = set_raw_breakpoint (sal);
5155 error ("Internal error -- couldn't set temp exception breakpoint");
5157 b->type = bp_breakpoint;
5158 b->disposition = del;
5159 b->enable = enabled;
5161 b->number = internal_breakpoint_number--;
5167 catch_command_1 (arg, tempflag, from_tty)
5173 /* The first argument may be an event name, such as "start" or "load".
5174 If so, then handle it as such. If it doesn't match an event name,
5175 then attempt to interpret it as an exception name. (This latter is
5176 the v4.16-and-earlier GDB meaning of the "catch" command.)
5178 First, try to find the bounds of what might be an event name. */
5179 char * arg1_start = arg;
5183 if (arg1_start == NULL)
5185 /* Old behaviour was to use pre-v-4.16 syntax */
5186 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5188 /* Now, this is not allowed */
5189 error ("Catch requires an event name.");
5192 arg1_end = ep_find_event_name_end (arg1_start);
5193 if (arg1_end == NULL)
5194 error ("catch requires an event");
5195 arg1_length = arg1_end + 1 - arg1_start;
5197 /* Try to match what we found against known event names. */
5198 if (strncmp (arg1_start, "signal", arg1_length) == 0)
5200 error ("Catch of signal not yet implemented");
5202 else if (strncmp (arg1_start, "catch", arg1_length) == 0)
5204 catch_exception_command_1 (EX_EVENT_CATCH, arg1_end+1, tempflag, from_tty);
5206 else if (strncmp (arg1_start, "throw", arg1_length) == 0)
5208 catch_exception_command_1 (EX_EVENT_THROW, arg1_end+1, tempflag, from_tty);
5210 else if (strncmp (arg1_start, "thread_start", arg1_length) == 0)
5212 error ("Catch of thread_start not yet implemented");
5214 else if (strncmp (arg1_start, "thread_exit", arg1_length) == 0)
5216 error ("Catch of thread_exit not yet implemented");
5218 else if (strncmp (arg1_start, "thread_join", arg1_length) == 0)
5220 error ("Catch of thread_join not yet implemented");
5222 else if (strncmp (arg1_start, "start", arg1_length) == 0)
5224 error ("Catch of start not yet implemented");
5226 else if (strncmp (arg1_start, "exit", arg1_length) == 0)
5228 error ("Catch of exit not yet implemented");
5230 else if (strncmp (arg1_start, "fork", arg1_length) == 0)
5232 #if defined(CHILD_INSERT_FORK_CATCHPOINT)
5233 catch_fork_command_1 (catch_fork, arg1_end+1, tempflag, from_tty);
5235 error ("Catch of fork not yet implemented");
5238 else if (strncmp (arg1_start, "vfork", arg1_length) == 0)
5240 #if defined(CHILD_INSERT_VFORK_CATCHPOINT)
5241 catch_fork_command_1 (catch_vfork, arg1_end+1, tempflag, from_tty);
5243 error ("Catch of vfork not yet implemented");
5246 else if (strncmp (arg1_start, "exec", arg1_length) == 0)
5248 #if defined(CHILD_INSERT_EXEC_CATCHPOINT)
5249 catch_exec_command_1 (arg1_end+1, tempflag, from_tty);
5251 error ("Catch of exec not yet implemented");
5254 else if (strncmp (arg1_start, "load", arg1_length) == 0)
5256 #if defined(SOLIB_ADD)
5257 catch_load_command_1 (arg1_end+1, tempflag, from_tty);
5259 error ("Catch of load not implemented");
5262 else if (strncmp (arg1_start, "unload", arg1_length) == 0)
5264 #if defined(SOLIB_ADD)
5265 catch_unload_command_1 (arg1_end+1, tempflag, from_tty);
5267 error ("Catch of load not implemented");
5270 else if (strncmp (arg1_start, "stop", arg1_length) == 0)
5272 error ("Catch of stop not yet implemented");
5275 /* This doesn't appear to be an event name */
5279 /* Pre-v.4.16 behaviour was to treat the argument
5280 as the name of an exception */
5281 /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */
5282 /* Now this is not allowed */
5283 error ("Unknown event kind specified for catch");
5288 /* Used by the gui, could be made a worker for other things. */
5291 set_breakpoint_sal (sal)
5292 struct symtab_and_line sal;
5294 struct breakpoint *b;
5295 b = set_raw_breakpoint (sal);
5296 set_breakpoint_count (breakpoint_count + 1);
5297 b->number = breakpoint_count;
5298 b->type = bp_breakpoint;
5305 /* These aren't used; I don't know what they were for. */
5306 /* Disable breakpoints on all catch clauses described in ARGS. */
5308 disable_catch (args)
5311 /* Map the disable command to catch clauses described in ARGS. */
5314 /* Enable breakpoints on all catch clauses described in ARGS. */
5319 /* Map the disable command to catch clauses described in ARGS. */
5322 /* Delete breakpoints on all catch clauses in the active scope. */
5327 /* Map the delete command to catch clauses described in ARGS. */
5332 catch_command (arg, from_tty)
5336 catch_command_1 (arg, 0, from_tty);
5341 tcatch_command (arg, from_tty)
5345 catch_command_1 (arg, 1, from_tty);
5350 clear_command (arg, from_tty)
5354 register struct breakpoint *b, *b1;
5356 struct symtabs_and_lines sals;
5357 struct symtab_and_line sal;
5358 register struct breakpoint *found;
5363 sals = decode_line_spec (arg, 1);
5368 sals.sals = (struct symtab_and_line *)
5369 xmalloc (sizeof (struct symtab_and_line));
5370 INIT_SAL (&sal); /* initialize to zeroes */
5371 sal.line = default_breakpoint_line;
5372 sal.symtab = default_breakpoint_symtab;
5373 sal.pc = default_breakpoint_address;
5374 if (sal.symtab == 0)
5375 error ("No source file specified.");
5383 /* For each line spec given, delete bps which correspond
5384 to it. We do this in two loops: the first loop looks at
5385 the initial bp(s) in the chain which should be deleted,
5386 the second goes down the rest of the chain looking ahead
5387 one so it can take those bps off the chain without messing
5391 for (i = 0; i < sals.nelts; i++)
5393 /* If exact pc given, clear bpts at that pc.
5394 If line given (pc == 0), clear all bpts on specified line.
5395 If defaulting, clear all bpts on default line
5398 defaulting sal.pc != 0 tests to do
5403 1 0 <can't happen> */
5406 found = (struct breakpoint *) 0;
5409 while (breakpoint_chain
5410 /* Why don't we check here that this is not
5411 a watchpoint, etc., as we do below?
5412 I can't make it fail, but don't know
5413 what's stopping the failure: a watchpoint
5414 of the same address as "sal.pc" should
5415 wind up being deleted. */
5417 && ( ((sal.pc && (breakpoint_chain->address == sal.pc)) &&
5418 (overlay_debugging == 0 ||
5419 breakpoint_chain->section == sal.section))
5420 || ((default_match || (0 == sal.pc))
5421 && breakpoint_chain->source_file != NULL
5422 && sal.symtab != NULL
5423 && STREQ (breakpoint_chain->source_file, sal.symtab->filename)
5424 && breakpoint_chain->line_number == sal.line)))
5427 b1 = breakpoint_chain;
5428 breakpoint_chain = b1->next;
5436 && b->next->type != bp_none
5437 && b->next->type != bp_watchpoint
5438 && b->next->type != bp_hardware_watchpoint
5439 && b->next->type != bp_read_watchpoint
5440 && b->next->type != bp_access_watchpoint
5441 && ( ((sal.pc && (b->next->address == sal.pc)) &&
5442 (overlay_debugging == 0 ||
5443 b->next->section == sal.section))
5444 || ((default_match || (0 == sal.pc))
5445 && b->next->source_file != NULL
5446 && sal.symtab != NULL
5447 && STREQ (b->next->source_file, sal.symtab->filename)
5448 && b->next->line_number == sal.line)))
5461 error ("No breakpoint at %s.", arg);
5463 error ("No breakpoint at this line.");
5466 if (found->next) from_tty = 1; /* Always report if deleted more than one */
5467 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
5468 breakpoints_changed ();
5471 if (from_tty) printf_unfiltered ("%d ", found->number);
5473 delete_breakpoint (found);
5476 if (from_tty) putchar_unfiltered ('\n');
5478 free ((PTR)sals.sals);
5481 /* Delete breakpoint in BS if they are `delete' breakpoints and
5482 all breakpoints that are marked for deletion, whether hit or not.
5483 This is called after any breakpoint is hit, or after errors. */
5486 breakpoint_auto_delete (bs)
5489 struct breakpoint *b, *temp;
5491 for (; bs; bs = bs->next)
5492 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
5494 delete_breakpoint (bs->breakpoint_at);
5496 ALL_BREAKPOINTS_SAFE (b, temp)
5498 if (b->disposition == del_at_next_stop)
5499 delete_breakpoint (b);
5503 /* Delete a breakpoint and clean up all traces of it in the data structures. */
5506 delete_breakpoint (bpt)
5507 struct breakpoint *bpt;
5509 register struct breakpoint *b;
5513 error ("Internal error (attempted to delete a NULL breakpoint)");
5516 /* Has this bp already been deleted? This can happen because multiple
5517 lists can hold pointers to bp's. bpstat lists are especial culprits.
5519 One example of this happening is a watchpoint's scope bp. When the
5520 scope bp triggers, we notice that the watchpoint is out of scope, and
5521 delete it. We also delete its scope bp. But the scope bp is marked
5522 "auto-deleting", and is already on a bpstat. That bpstat is then
5523 checked for auto-deleting bp's, which are deleted.
5525 A real solution to this problem might involve reference counts in bp's,
5526 and/or giving them pointers back to their referencing bpstat's, and
5527 teaching delete_breakpoint to only free a bp's storage when no more
5528 references were extent. A cheaper bandaid was chosen. */
5529 if (bpt->type == bp_none)
5532 if (delete_breakpoint_hook)
5533 delete_breakpoint_hook (bpt);
5536 remove_breakpoint (bpt, mark_uninserted);
5538 if (breakpoint_chain == bpt)
5539 breakpoint_chain = bpt->next;
5541 /* If we have callback-style exception catchpoints, don't go through
5542 the adjustments to the C++ runtime library etc. if the inferior
5543 isn't actually running. target_enable_exception_callback for a
5544 null target ops vector gives an undesirable error message, so we
5545 check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's
5546 exceptions are supported in this way, it's OK for now. FIXME */
5547 if (ep_is_exception_catchpoint (bpt) && target_has_execution)
5549 static char message1[] = "Error in deleting catchpoint %d:\n";
5550 static char message[sizeof (message1) + 30];
5551 args_for_catchpoint_enable args;
5553 sprintf (message, message1, bpt->number); /* Format possible error msg */
5554 args.kind = bpt->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW;
5556 catch_errors (cover_target_enable_exception_callback, &args,
5557 message, RETURN_MASK_ALL);
5564 b->next = bpt->next;
5568 /* Before turning off the visuals for the bp, check to see that
5569 there are no other bps at the same address. */
5576 clearIt = (b->address != bpt->address);
5583 TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, bpt, 0));
5584 TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos));
5588 check_duplicates (bpt->address, bpt->section);
5589 /* If this breakpoint was inserted, and there is another breakpoint
5590 at the same address, we need to insert the other breakpoint. */
5592 && bpt->type != bp_hardware_watchpoint
5593 && bpt->type != bp_read_watchpoint
5594 && bpt->type != bp_access_watchpoint
5595 && bpt->type != bp_catch_fork
5596 && bpt->type != bp_catch_vfork
5597 && bpt->type != bp_catch_exec)
5600 if (b->address == bpt->address
5601 && b->section == bpt->section
5603 && b->enable != disabled
5604 && b->enable != shlib_disabled
5605 && b->enable != call_disabled)
5608 val = target_insert_breakpoint (b->address, b->shadow_contents);
5611 target_terminal_ours_for_output ();
5612 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
5613 memory_error (val, b->address); /* which bombs us out */
5620 free_command_lines (&bpt->commands);
5623 if (bpt->cond_string != NULL)
5624 free (bpt->cond_string);
5625 if (bpt->addr_string != NULL)
5626 free (bpt->addr_string);
5627 if (bpt->exp != NULL)
5629 if (bpt->exp_string != NULL)
5630 free (bpt->exp_string);
5631 if (bpt->val != NULL)
5632 value_free (bpt->val);
5633 if (bpt->source_file != NULL)
5634 free (bpt->source_file);
5635 if (bpt->dll_pathname != NULL)
5636 free (bpt->dll_pathname);
5637 if (bpt->triggered_dll_pathname != NULL)
5638 free (bpt->triggered_dll_pathname);
5639 if (bpt->exec_pathname != NULL)
5640 free (bpt->exec_pathname);
5642 /* Be sure no bpstat's are pointing at it after it's been freed. */
5643 /* FIXME, how can we find all bpstat's?
5644 We just check stop_bpstat for now. */
5645 for (bs = stop_bpstat; bs; bs = bs->next)
5646 if (bs->breakpoint_at == bpt)
5648 bs->breakpoint_at = NULL;
5650 /* we'd call bpstat_clear_actions, but that free's stuff and due
5651 to the multiple pointers pointing to one item with no
5652 reference counts found anywhere through out the bpstat's (how
5653 do you spell fragile?), we don't want to free things twice --
5654 better a memory leak than a corrupt malloc pool! */
5655 bs->commands = NULL;
5658 /* On the chance that someone will soon try again to delete this same
5659 bp, we mark it as deleted before freeing its storage. */
5660 bpt->type = bp_none;
5666 delete_command (arg, from_tty)
5670 struct breakpoint *b, *temp;
5674 int breaks_to_delete = 0;
5676 /* Delete all breakpoints if no argument.
5677 Do not delete internal or call-dummy breakpoints, these
5678 have to be deleted with an explicit breakpoint number argument. */
5681 if (b->type != bp_call_dummy &&
5682 b->type != bp_shlib_event &&
5684 breaks_to_delete = 1;
5687 /* Ask user only if there are some breakpoints to delete. */
5689 || (breaks_to_delete && query ("Delete all breakpoints? ")))
5691 ALL_BREAKPOINTS_SAFE (b, temp)
5693 if (b->type != bp_call_dummy &&
5694 b->type != bp_shlib_event &&
5696 delete_breakpoint (b);
5701 map_breakpoint_numbers (arg, delete_breakpoint);
5704 /* Reset a breakpoint given it's struct breakpoint * BINT.
5705 The value we return ends up being the return value from catch_errors.
5706 Unused in this case. */
5709 breakpoint_re_set_one (bint)
5712 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
5715 struct symtabs_and_lines sals;
5717 enum enable save_enable;
5722 warning ("attempted to reset apparently deleted breakpoint #%d?\n", b->number);
5725 case bp_hardware_breakpoint:
5727 case bp_catch_unload:
5728 if (b->addr_string == NULL)
5730 /* Anything without a string can't be re-set. */
5731 delete_breakpoint (b);
5734 /* In case we have a problem, disable this breakpoint. We'll restore
5735 its status if we succeed. */
5736 save_enable = b->enable;
5737 b->enable = disabled;
5739 set_language (b->language);
5740 input_radix = b->input_radix;
5742 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
5743 for (i = 0; i < sals.nelts; i++)
5745 resolve_sal_pc (&sals.sals[i]);
5747 /* Reparse conditions, they might contain references to the
5749 if (b->cond_string != NULL)
5753 free ((PTR)b->cond);
5754 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
5757 /* We need to re-set the breakpoint if the address changes...*/
5758 if (b->address != sals.sals[i].pc
5759 /* ...or new and old breakpoints both have source files, and
5760 the source file name or the line number changes... */
5761 || (b->source_file != NULL
5762 && sals.sals[i].symtab != NULL
5763 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
5764 || b->line_number != sals.sals[i].line)
5766 /* ...or we switch between having a source file and not having
5768 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
5771 if (b->source_file != NULL)
5772 free (b->source_file);
5773 if (sals.sals[i].symtab == NULL)
5774 b->source_file = NULL;
5777 savestring (sals.sals[i].symtab->filename,
5778 strlen (sals.sals[i].symtab->filename));
5779 b->line_number = sals.sals[i].line;
5780 b->address = sals.sals[i].pc;
5782 /* Used to check for duplicates here, but that can
5783 cause trouble, as it doesn't check for disable
5788 /* Might be better to do this just once per breakpoint_re_set,
5789 rather than once for every breakpoint. */
5790 breakpoints_changed ();
5792 b->section = sals.sals[i].section;
5793 b->enable = save_enable; /* Restore it, this worked. */
5796 /* Now that this is re-enabled, check_duplicates
5798 check_duplicates (b->address, b->section);
5801 free ((PTR)sals.sals);
5805 case bp_hardware_watchpoint:
5806 case bp_read_watchpoint:
5807 case bp_access_watchpoint:
5808 innermost_block = NULL;
5809 /* The issue arises of what context to evaluate this in. The same
5810 one as when it was set, but what does that mean when symbols have
5811 been re-read? We could save the filename and functionname, but
5812 if the context is more local than that, the best we could do would
5813 be something like how many levels deep and which index at that
5814 particular level, but that's going to be less stable than filenames
5815 or functionnames. */
5816 /* So for now, just use a global context. */
5819 b->exp = parse_expression (b->exp_string);
5820 b->exp_valid_block = innermost_block;
5821 mark = value_mark ();
5823 value_free (b->val);
5824 b->val = evaluate_expression (b->exp);
5825 release_value (b->val);
5826 if (VALUE_LAZY (b->val))
5827 value_fetch_lazy (b->val);
5829 if (b->cond_string != NULL)
5833 free ((PTR)b->cond);
5834 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
5836 if (b->enable == enabled)
5838 value_free_to_mark (mark);
5840 case bp_catch_catch:
5841 case bp_catch_throw:
5843 /* We needn't really do anything to reset these, since the mask
5844 that requests them is unaffected by e.g., new libraries being
5847 case bp_catch_vfork:
5852 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
5854 /* Delete longjmp breakpoints, they will be reset later by
5855 breakpoint_re_set. */
5857 case bp_longjmp_resume:
5858 delete_breakpoint (b);
5861 /* This breakpoint is special, it's set up when the inferior
5862 starts and we really don't want to touch it. */
5863 case bp_shlib_event:
5865 /* Keep temporary breakpoints, which can be encountered when we step
5866 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
5867 Otherwise these should have been blown away via the cleanup chain
5868 or by breakpoint_init_inferior when we rerun the executable. */
5871 case bp_watchpoint_scope:
5873 case bp_step_resume:
5880 /* Re-set all breakpoints after symbols have been re-loaded. */
5882 breakpoint_re_set ()
5884 struct breakpoint *b, *temp;
5885 enum language save_language;
5886 int save_input_radix;
5887 static char message1[] = "Error in re-setting breakpoint %d:\n";
5888 char message[sizeof (message1) + 30 /* slop */];
5890 save_language = current_language->la_language;
5891 save_input_radix = input_radix;
5892 ALL_BREAKPOINTS_SAFE (b, temp)
5894 sprintf (message, message1, b->number); /* Format possible error msg */
5895 catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
5897 set_language (save_language);
5898 input_radix = save_input_radix;
5900 #ifdef GET_LONGJMP_TARGET
5901 create_longjmp_breakpoint ("longjmp");
5902 create_longjmp_breakpoint ("_longjmp");
5903 create_longjmp_breakpoint ("siglongjmp");
5904 create_longjmp_breakpoint ("_siglongjmp");
5905 create_longjmp_breakpoint (NULL);
5909 /* Took this out (temporarily at least), since it produces an extra
5910 blank line at startup. This messes up the gdbtests. -PB */
5911 /* Blank line to finish off all those mention() messages we just printed. */
5912 printf_filtered ("\n");
5916 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
5917 If from_tty is nonzero, it prints a message to that effect,
5918 which ends with a period (no newline). */
5920 /* Reset the thread number of this breakpoint:
5922 - If the breakpoint is for all threads, leave it as-is.
5923 - Else, reset it to the current thread for inferior_pid. */
5925 breakpoint_re_set_thread (b)
5926 struct breakpoint * b;
5928 if (b->thread != -1)
5930 if (in_thread_list (inferior_pid))
5931 b->thread = pid_to_thread_id (inferior_pid);
5936 set_ignore_count (bptnum, count, from_tty)
5937 int bptnum, count, from_tty;
5939 register struct breakpoint *b;
5945 if (b->number == bptnum)
5947 b->ignore_count = count;
5950 else if (count == 0)
5951 printf_filtered ("Will stop next time breakpoint %d is reached.",
5953 else if (count == 1)
5954 printf_filtered ("Will ignore next crossing of breakpoint %d.",
5957 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
5959 breakpoints_changed ();
5963 error ("No breakpoint number %d.", bptnum);
5966 /* Clear the ignore counts of all breakpoints. */
5968 breakpoint_clear_ignore_counts ()
5970 struct breakpoint *b;
5973 b->ignore_count = 0;
5976 /* Command to set ignore-count of breakpoint N to COUNT. */
5979 ignore_command (args, from_tty)
5987 error_no_arg ("a breakpoint number");
5989 num = get_number (&p);
5992 error ("Second argument (specified ignore-count) is missing.");
5994 set_ignore_count (num,
5995 longest_to_int (value_as_long (parse_and_eval (p))),
5997 printf_filtered ("\n");
5998 breakpoints_changed ();
6001 /* Call FUNCTION on each of the breakpoints
6002 whose numbers are given in ARGS. */
6005 map_breakpoint_numbers (args, function)
6007 void (*function) PARAMS ((struct breakpoint *));
6009 register char *p = args;
6012 register struct breakpoint *b;
6015 error_no_arg ("one or more breakpoint numbers");
6021 num = get_number (&p1);
6024 if (b->number == num)
6026 struct breakpoint *related_breakpoint = b->related_breakpoint;
6028 if (related_breakpoint)
6029 function (related_breakpoint);
6032 printf_unfiltered ("No breakpoint number %d.\n", num);
6039 disable_breakpoint (bpt)
6040 struct breakpoint *bpt;
6042 /* Never disable a watchpoint scope breakpoint; we want to
6043 hit them when we leave scope so we can delete both the
6044 watchpoint and its scope breakpoint at that time. */
6045 if (bpt->type == bp_watchpoint_scope)
6048 bpt->enable = disabled;
6050 check_duplicates (bpt->address, bpt->section);
6052 if (modify_breakpoint_hook)
6053 modify_breakpoint_hook (bpt);
6058 disable_command (args, from_tty)
6062 register struct breakpoint *bpt;
6064 ALL_BREAKPOINTS (bpt)
6068 warning ("attempted to disable apparently deleted breakpoint #%d?\n", bpt->number);
6072 case bp_catch_unload:
6074 case bp_catch_vfork:
6076 case bp_catch_catch:
6077 case bp_catch_throw:
6078 case bp_hardware_breakpoint:
6080 case bp_hardware_watchpoint:
6081 case bp_read_watchpoint:
6082 case bp_access_watchpoint:
6083 disable_breakpoint (bpt);
6088 map_breakpoint_numbers (args, disable_breakpoint);
6092 do_enable_breakpoint (bpt, disposition)
6093 struct breakpoint *bpt;
6094 enum bpdisp disposition;
6096 struct frame_info *save_selected_frame = NULL;
6097 int save_selected_frame_level = -1;
6098 int target_resources_ok, other_type_used;
6101 if (bpt->type == bp_hardware_breakpoint)
6104 i = hw_breakpoint_used_count();
6105 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
6106 bp_hardware_breakpoint, i+1, 0);
6107 if (target_resources_ok == 0)
6108 error ("No hardware breakpoint support in the target.");
6109 else if (target_resources_ok < 0)
6110 error ("Hardware breakpoints used exceeds limit.");
6113 bpt->enable = enabled;
6114 bpt->disposition = disposition;
6115 check_duplicates (bpt->address, bpt->section);
6116 breakpoints_changed ();
6118 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
6119 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
6121 if (bpt->exp_valid_block != NULL)
6123 struct frame_info *fr =
6125 /* Ensure that we have the current frame. Else, this
6126 next query may pessimistically be answered as, "No,
6127 not within current scope". */
6128 get_current_frame ();
6129 fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
6133 Cannot enable watchpoint %d because the block in which its expression\n\
6134 is valid is not currently in scope.\n", bpt->number);
6135 bpt->enable = disabled;
6139 save_selected_frame = selected_frame;
6140 save_selected_frame_level = selected_frame_level;
6141 select_frame (fr, -1);
6144 value_free (bpt->val);
6145 mark = value_mark ();
6146 bpt->val = evaluate_expression (bpt->exp);
6147 release_value (bpt->val);
6148 if (VALUE_LAZY (bpt->val))
6149 value_fetch_lazy (bpt->val);
6151 if (bpt->type == bp_hardware_watchpoint ||
6152 bpt->type == bp_read_watchpoint ||
6153 bpt->type == bp_access_watchpoint)
6155 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
6156 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
6158 /* Hack around 'unused var' error for some targets here */
6160 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
6161 bpt->type, i + mem_cnt, other_type_used);
6162 /* we can consider of type is bp_hardware_watchpoint, convert to
6163 bp_watchpoint in the following condition */
6164 if (target_resources_ok < 0)
6167 Cannot enable watchpoint %d because target watch resources\n\
6168 have been allocated for other watchpoints.\n", bpt->number);
6169 bpt->enable = disabled;
6170 value_free_to_mark (mark);
6175 if (save_selected_frame_level >= 0)
6176 select_and_print_frame (save_selected_frame, save_selected_frame_level);
6177 value_free_to_mark (mark);
6179 if (modify_breakpoint_hook)
6180 modify_breakpoint_hook (bpt);
6184 enable_breakpoint (bpt)
6185 struct breakpoint *bpt;
6187 do_enable_breakpoint (bpt, bpt->disposition);
6190 /* The enable command enables the specified breakpoints (or all defined
6191 breakpoints) so they once again become (or continue to be) effective
6192 in stopping the inferior. */
6196 enable_command (args, from_tty)
6200 register struct breakpoint *bpt;
6202 ALL_BREAKPOINTS (bpt)
6206 warning ("attempted to enable apparently deleted breakpoint #%d?\n", bpt->number);
6210 case bp_catch_unload:
6212 case bp_catch_vfork:
6214 case bp_catch_catch:
6215 case bp_catch_throw:
6216 case bp_hardware_breakpoint:
6218 case bp_hardware_watchpoint:
6219 case bp_read_watchpoint:
6220 case bp_access_watchpoint:
6221 enable_breakpoint (bpt);
6226 map_breakpoint_numbers (args, enable_breakpoint);
6230 enable_once_breakpoint (bpt)
6231 struct breakpoint *bpt;
6233 do_enable_breakpoint (bpt, disable);
6238 enable_once_command (args, from_tty)
6242 map_breakpoint_numbers (args, enable_once_breakpoint);
6246 enable_delete_breakpoint (bpt)
6247 struct breakpoint *bpt;
6249 do_enable_breakpoint (bpt, del);
6254 enable_delete_command (args, from_tty)
6258 map_breakpoint_numbers (args, enable_delete_breakpoint);
6261 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
6263 struct symtabs_and_lines
6264 decode_line_spec_1 (string, funfirstline)
6268 struct symtabs_and_lines sals;
6270 error ("Empty line specification.");
6271 if (default_breakpoint_valid)
6272 sals = decode_line_1 (&string, funfirstline,
6273 default_breakpoint_symtab, default_breakpoint_line,
6276 sals = decode_line_1 (&string, funfirstline,
6277 (struct symtab *)NULL, 0, (char ***)NULL);
6279 error ("Junk at end of line specification: %s", string);
6284 _initialize_breakpoint ()
6286 struct cmd_list_element *c;
6288 breakpoint_chain = 0;
6289 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
6290 before a breakpoint is set. */
6291 breakpoint_count = 0;
6293 add_com ("ignore", class_breakpoint, ignore_command,
6294 "Set ignore-count of breakpoint number N to COUNT.\n\
6295 Usage is `ignore N COUNT'.");
6297 add_com_alias("bc", "ignore", class_breakpoint, 1);
6299 add_com ("commands", class_breakpoint, commands_command,
6300 "Set commands to be executed when a breakpoint is hit.\n\
6301 Give breakpoint number as argument after \"commands\".\n\
6302 With no argument, the targeted breakpoint is the last one set.\n\
6303 The commands themselves follow starting on the next line.\n\
6304 Type a line containing \"end\" to indicate the end of them.\n\
6305 Give \"silent\" as the first line to make the breakpoint silent;\n\
6306 then no output is printed when it is hit, except what the commands print.");
6308 add_com ("condition", class_breakpoint, condition_command,
6309 "Specify breakpoint number N to break only if COND is true.\n\
6310 Usage is `condition N COND', where N is an integer and COND is an\n\
6311 expression to be evaluated whenever breakpoint N is reached. ");
6313 add_com ("tbreak", class_breakpoint, tbreak_command,
6314 "Set a temporary breakpoint. Args like \"break\" command.\n\
6315 Like \"break\" except the breakpoint is only temporary,\n\
6316 so it will be deleted when hit. Equivalent to \"break\" followed\n\
6317 by using \"enable delete\" on the breakpoint number.");
6318 add_com("txbreak", class_breakpoint, tbreak_at_finish_command,
6319 "Set temporary breakpoint at procedure exit. Either there should\n\
6320 be no argument or the argument must be a depth.\n");
6322 add_com ("hbreak", class_breakpoint, hbreak_command,
6323 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
6324 Like \"break\" except the breakpoint requires hardware support,\n\
6325 some target hardware may not have this support.");
6327 add_com ("thbreak", class_breakpoint, thbreak_command,
6328 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
6329 Like \"hbreak\" except the breakpoint is only temporary,\n\
6330 so it will be deleted when hit.");
6332 add_prefix_cmd ("enable", class_breakpoint, enable_command,
6333 "Enable some breakpoints.\n\
6334 Give breakpoint numbers (separated by spaces) as arguments.\n\
6335 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6336 This is used to cancel the effect of the \"disable\" command.\n\
6337 With a subcommand you can enable temporarily.",
6338 &enablelist, "enable ", 1, &cmdlist);
6340 add_com("ab", class_breakpoint, enable_command,
6341 "Enable some breakpoints.\n\
6342 Give breakpoint numbers (separated by spaces) as arguments.\n\
6343 With no subcommand, breakpoints are enabled until you command otherwise.\n\
6344 This is used to cancel the effect of the \"disable\" command.\n\
6345 With a subcommand you can enable temporarily.");
6347 add_com_alias ("en", "enable", class_breakpoint, 1);
6349 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
6350 "Enable some breakpoints.\n\
6351 Give breakpoint numbers (separated by spaces) as arguments.\n\
6352 This is used to cancel the effect of the \"disable\" command.\n\
6353 May be abbreviated to simply \"enable\".\n",
6354 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
6356 add_cmd ("once", no_class, enable_once_command,
6357 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6358 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6361 add_cmd ("delete", no_class, enable_delete_command,
6362 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6363 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6366 add_cmd ("delete", no_class, enable_delete_command,
6367 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
6368 If a breakpoint is hit while enabled in this fashion, it is deleted.",
6371 add_cmd ("once", no_class, enable_once_command,
6372 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
6373 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
6376 add_prefix_cmd ("disable", class_breakpoint, disable_command,
6377 "Disable some breakpoints.\n\
6378 Arguments are breakpoint numbers with spaces in between.\n\
6379 To disable all breakpoints, give no argument.\n\
6380 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
6381 &disablelist, "disable ", 1, &cmdlist);
6382 add_com_alias ("dis", "disable", class_breakpoint, 1);
6383 add_com_alias ("disa", "disable", class_breakpoint, 1);
6385 add_com("sb", class_breakpoint, disable_command,
6386 "Disable some breakpoints.\n\
6387 Arguments are breakpoint numbers with spaces in between.\n\
6388 To disable all breakpoints, give no argument.\n\
6389 A disabled breakpoint is not forgotten, but has no effect until reenabled.");
6391 add_cmd ("breakpoints", class_alias, disable_command,
6392 "Disable some breakpoints.\n\
6393 Arguments are breakpoint numbers with spaces in between.\n\
6394 To disable all breakpoints, give no argument.\n\
6395 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
6396 This command may be abbreviated \"disable\".",
6399 add_prefix_cmd ("delete", class_breakpoint, delete_command,
6400 "Delete some breakpoints or auto-display expressions.\n\
6401 Arguments are breakpoint numbers with spaces in between.\n\
6402 To delete all breakpoints, give no argument.\n\
6404 Also a prefix command for deletion of other GDB objects.\n\
6405 The \"unset\" command is also an alias for \"delete\".",
6406 &deletelist, "delete ", 1, &cmdlist);
6407 add_com_alias ("d", "delete", class_breakpoint, 1);
6409 add_com ("db", class_breakpoint, delete_command,
6410 "Delete some breakpoints.\n\
6411 Arguments are breakpoint numbers with spaces in between.\n\
6412 To delete all breakpoints, give no argument.\n");
6414 add_cmd ("breakpoints", class_alias, delete_command,
6415 "Delete some breakpoints or auto-display expressions.\n\
6416 Arguments are breakpoint numbers with spaces in between.\n\
6417 To delete all breakpoints, give no argument.\n\
6418 This command may be abbreviated \"delete\".",
6421 add_com ("clear", class_breakpoint, clear_command,
6422 concat ("Clear breakpoint at specified line or function.\n\
6423 Argument may be line number, function name, or \"*\" and an address.\n\
6424 If line number is specified, all breakpoints in that line are cleared.\n\
6425 If function is specified, breakpoints at beginning of function are cleared.\n\
6426 If an address is specified, breakpoints at that address are cleared.\n\n",
6427 "With no argument, clears all breakpoints in the line that the selected frame\n\
6430 See also the \"delete\" command which clears breakpoints by number.", NULL));
6432 add_com ("break", class_breakpoint, break_command,
6433 concat ("Set breakpoint at specified line or function.\n\
6434 Argument may be line number, function name, or \"*\" and an address.\n\
6435 If line number is specified, break at start of code for that line.\n\
6436 If function is specified, break at start of code for that function.\n\
6437 If an address is specified, break at that exact address.\n",
6438 "With no arg, uses current execution address of selected stack frame.\n\
6439 This is useful for breaking on return to a stack frame.\n\
6441 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6443 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6444 add_com_alias ("b", "break", class_run, 1);
6445 add_com_alias ("br", "break", class_run, 1);
6446 add_com_alias ("bre", "break", class_run, 1);
6447 add_com_alias ("brea", "break", class_run, 1);
6449 add_com("xbreak", class_breakpoint, break_at_finish_command,
6450 concat("Set breakpoint at procedure exit. \n\
6451 Argument may be function name, or \"*\" and an address.\n\
6452 If function is specified, break at end of code for that function.\n\
6453 If an address is specified, break at the end of the function that contains \n\
6454 that exact address.\n",
6455 "With no arg, uses current execution address of selected stack frame.\n\
6456 This is useful for breaking on return to a stack frame.\n\
6458 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
6460 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
6461 add_com_alias ("xb", "xbreak", class_breakpoint, 1);
6462 add_com_alias ("xbr", "xbreak", class_breakpoint, 1);
6463 add_com_alias ("xbre", "xbreak", class_breakpoint, 1);
6464 add_com_alias ("xbrea", "xbreak", class_breakpoint, 1);
6468 add_com_alias ("ba", "break", class_breakpoint, 1);
6469 add_com_alias ("bu", "ubreak", class_breakpoint, 1);
6470 add_com ("bx", class_breakpoint, break_at_finish_at_depth_command,
6471 "Set breakpoint at procedure exit. Either there should\n\
6472 be no argument or the argument must be a depth.\n");
6477 add_abbrev_prefix_cmd("stop", class_breakpoint, stop_command,
6478 "Break in function/address or break at a line in the current file.",
6479 &stoplist, "stop ", 1, &cmdlist);
6480 add_cmd("in", class_breakpoint, stopin_command,
6481 "Break in function or address.\n", &stoplist);
6482 add_cmd("at", class_breakpoint, stopat_command,
6483 "Break at a line in the current file.\n", &stoplist);
6484 add_com("status", class_info, breakpoints_info,
6485 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6486 The \"Type\" column indicates one of:\n\
6487 \tbreakpoint - normal breakpoint\n\
6488 \twatchpoint - watchpoint\n\
6489 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6490 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6491 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6492 address and file/line number respectively.\n\n",
6493 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6494 are set to the address of the last breakpoint listed.\n\n\
6495 Convenience variable \"$bpnum\" contains the number of the last\n\
6496 breakpoint set.", NULL));
6499 add_info ("breakpoints", breakpoints_info,
6500 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6501 The \"Type\" column indicates one of:\n\
6502 \tbreakpoint - normal breakpoint\n\
6503 \twatchpoint - watchpoint\n\
6504 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6505 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6506 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6507 address and file/line number respectively.\n\n",
6508 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6509 are set to the address of the last breakpoint listed.\n\n\
6510 Convenience variable \"$bpnum\" contains the number of the last\n\
6511 breakpoint set.", NULL));
6514 add_com("lb", class_breakpoint, breakpoints_info,
6515 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
6516 The \"Type\" column indicates one of:\n\
6517 \tbreakpoint - normal breakpoint\n\
6518 \twatchpoint - watchpoint\n\
6519 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6520 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6521 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6522 address and file/line number respectively.\n\n",
6523 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6524 are set to the address of the last breakpoint listed.\n\n\
6525 Convenience variable \"$bpnum\" contains the number of the last\n\
6526 breakpoint set.", NULL));
6528 #if MAINTENANCE_CMDS
6530 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
6531 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
6532 The \"Type\" column indicates one of:\n\
6533 \tbreakpoint - normal breakpoint\n\
6534 \twatchpoint - watchpoint\n\
6535 \tlongjmp - internal breakpoint used to step through longjmp()\n\
6536 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
6537 \tuntil - internal breakpoint used by the \"until\" command\n\
6538 \tfinish - internal breakpoint used by the \"finish\" command\n",
6539 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
6540 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
6541 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
6542 address and file/line number respectively.\n\n",
6543 "Convenience variable \"$_\" and default examine address for \"x\"\n\
6544 are set to the address of the last breakpoint listed.\n\n\
6545 Convenience variable \"$bpnum\" contains the number of the last\n\
6546 breakpoint set.", NULL),
6547 &maintenanceinfolist);
6549 #endif /* MAINTENANCE_CMDS */
6551 add_com ("catch", class_breakpoint, catch_command,
6552 "Set catchpoints to catch events.\n\
6553 Raised signals may be caught:\n\
6554 \tcatch signal - all signals\n\
6555 \tcatch signal <signame> - a particular signal\n\
6556 Raised exceptions may be caught:\n\
6557 \tcatch throw - all exceptions, when thrown\n\
6558 \tcatch throw <exceptname> - a particular exception, when thrown\n\
6559 \tcatch catch - all exceptions, when caught\n\
6560 \tcatch catch <exceptname> - a particular exception, when caught\n\
6561 Thread or process events may be caught:\n\
6562 \tcatch thread_start - any threads, just after creation\n\
6563 \tcatch thread_exit - any threads, just before expiration\n\
6564 \tcatch thread_join - any threads, just after joins\n\
6565 Process events may be caught:\n\
6566 \tcatch start - any processes, just after creation\n\
6567 \tcatch exit - any processes, just before expiration\n\
6568 \tcatch fork - calls to fork()\n\
6569 \tcatch vfork - calls to vfork()\n\
6570 \tcatch exec - calls to exec()\n\
6571 Dynamically-linked library events may be caught:\n\
6572 \tcatch load - loads of any library\n\
6573 \tcatch load <libname> - loads of a particular library\n\
6574 \tcatch unload - unloads of any library\n\
6575 \tcatch unload <libname> - unloads of a particular library\n\
6576 The act of your program's execution stopping may also be caught:\n\
6578 C++ exceptions may be caught:\n\
6579 \tcatch throw - all exceptions, when thrown\n\
6580 \tcatch catch - all exceptions, when caught\n\
6582 Do \"help set follow-fork-mode\" for info on debugging your program\n\
6583 after a fork or vfork is caught.\n\n\
6584 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
6586 add_com ("tcatch", class_breakpoint, tcatch_command,
6587 "Set temporary catchpoints to catch events.\n\
6588 Args like \"catch\" command.\n\
6589 Like \"catch\" except the catchpoint is only temporary,\n\
6590 so it will be deleted when hit. Equivalent to \"catch\" followed\n\
6591 by using \"enable delete\" on the catchpoint number.");
6593 add_com ("watch", class_breakpoint, watch_command,
6595 "Set a watchpoint for an expression.\n\
6596 A watchpoint stops execution of your program whenever the value of\n\
6597 an expression changes.");
6599 add_com ("rwatch", class_breakpoint, rwatch_command,
6600 "Set a read watchpoint for an expression.\n\
6601 A watchpoint stops execution of your program whenever the value of\n\
6602 an expression is read.");
6604 add_com ("awatch", class_breakpoint, awatch_command,
6605 "Set a watchpoint for an expression.\n\
6606 A watchpoint stops execution of your program whenever the value of\n\
6607 an expression is either read or written.");
6609 add_info ("watchpoints", breakpoints_info,
6610 "Synonym for ``info breakpoints''.");
6613 c = add_set_cmd ("can-use-hw-watchpoints", class_support, var_zinteger,
6614 (char *) &can_use_hw_watchpoints,
6615 "Set debugger's willingness to use watchpoint hardware.\n\
6616 If zero, gdb will not use hardware for new watchpoints, even if\n\
6617 such is available. (However, any hardware watchpoints that were\n\
6618 created before setting this to nonzero, will continue to use watchpoint\n\
6621 add_show_from_set (c, &showlist);
6623 can_use_hw_watchpoints = 1;