1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995
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"
36 #include "gdb_string.h"
40 /* local function prototypes */
43 catch_command_1 PARAMS ((char *, int, int));
46 enable_delete_command PARAMS ((char *, int));
49 enable_delete_breakpoint PARAMS ((struct breakpoint *));
52 enable_once_command PARAMS ((char *, int));
55 enable_once_breakpoint PARAMS ((struct breakpoint *));
58 disable_command PARAMS ((char *, int));
61 enable_command PARAMS ((char *, int));
64 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
67 ignore_command PARAMS ((char *, int));
70 breakpoint_re_set_one PARAMS ((char *));
73 delete_command PARAMS ((char *, int));
76 clear_command PARAMS ((char *, int));
79 catch_command PARAMS ((char *, int));
81 static struct symtabs_and_lines
82 get_catch_sals PARAMS ((int));
85 watch_command PARAMS ((char *, int));
88 can_use_hardware_watchpoint PARAMS ((struct value *));
91 tbreak_command PARAMS ((char *, int));
94 break_command_1 PARAMS ((char *, int, int));
97 mention PARAMS ((struct breakpoint *));
99 static struct breakpoint *
100 set_raw_breakpoint PARAMS ((struct symtab_and_line));
103 check_duplicates PARAMS ((CORE_ADDR));
106 describe_other_breakpoints PARAMS ((CORE_ADDR));
109 breakpoints_info PARAMS ((char *, int));
112 breakpoint_1 PARAMS ((int, int));
115 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
118 breakpoint_cond_eval PARAMS ((char *));
121 cleanup_executing_breakpoints PARAMS ((int));
124 commands_command PARAMS ((char *, int));
127 condition_command PARAMS ((char *, int));
130 get_number PARAMS ((char **));
133 set_breakpoint_count PARAMS ((int));
136 remove_breakpoint PARAMS ((struct breakpoint *));
138 extern int addressprint; /* Print machine addresses? */
140 /* Are we executing breakpoint commands? */
141 static int executing_breakpoint_commands;
143 /* Walk the following statement or block through all breakpoints.
144 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
147 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
149 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
150 for (b = breakpoint_chain; \
151 b? (tmp=b->next, 1): 0; \
154 /* True if breakpoint hit counts should be displayed in breakpoint info. */
156 int show_breakpoint_hit_counts = 1;
158 /* Chain of all breakpoints defined. */
160 struct breakpoint *breakpoint_chain;
162 /* Number of last breakpoint made. */
164 static int breakpoint_count;
166 /* Set breakpoint count to NUM. */
169 set_breakpoint_count (num)
172 breakpoint_count = num;
173 set_internalvar (lookup_internalvar ("bpnum"),
174 value_from_longest (builtin_type_int, (LONGEST) num));
177 /* Used in run_command to zero the hit count when a new run starts. */
180 clear_breakpoint_hit_counts ()
182 struct breakpoint *b;
188 /* Default address, symtab and line to put a breakpoint at
189 for "break" command with no arg.
190 if default_breakpoint_valid is zero, the other three are
191 not valid, and "break" with no arg is an error.
193 This set by print_stack_frame, which calls set_default_breakpoint. */
195 int default_breakpoint_valid;
196 CORE_ADDR default_breakpoint_address;
197 struct symtab *default_breakpoint_symtab;
198 int default_breakpoint_line;
200 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
201 Advance *PP after the string and any trailing whitespace.
203 Currently the string can either be a number or "$" followed by the name
204 of a convenience variable. Making it an expression wouldn't work well
205 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
214 /* Empty line means refer to the last breakpoint. */
215 return breakpoint_count;
218 /* Make a copy of the name, so we can null-terminate it
219 to pass to lookup_internalvar(). */
224 while (isalnum (*p) || *p == '_')
226 varname = (char *) alloca (p - start + 1);
227 strncpy (varname, start, p - start);
228 varname[p - start] = '\0';
229 val = value_of_internalvar (lookup_internalvar (varname));
230 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
232 "Convenience variables used to specify breakpoints must have integer values."
234 retval = (int) value_as_long (val);
240 while (*p >= '0' && *p <= '9')
243 /* There is no number here. (e.g. "cond a == b"). */
244 error_no_arg ("breakpoint number");
247 if (!(isspace (*p) || *p == '\0'))
248 error ("breakpoint number expected");
255 /* condition N EXP -- set break condition of breakpoint N to EXP. */
258 condition_command (arg, from_tty)
262 register struct breakpoint *b;
267 error_no_arg ("breakpoint number");
270 bnum = get_number (&p);
273 if (b->number == bnum)
280 if (b->cond_string != NULL)
281 free ((PTR)b->cond_string);
286 b->cond_string = NULL;
288 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
293 /* I don't know if it matters whether this is the string the user
294 typed in or the decompiled expression. */
295 b->cond_string = savestring (arg, strlen (arg));
296 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
298 error ("Junk at end of expression");
300 breakpoints_changed ();
304 error ("No breakpoint number %d.", bnum);
309 commands_command (arg, from_tty)
313 register struct breakpoint *b;
316 struct command_line *l;
318 /* If we allowed this, we would have problems with when to
319 free the storage, if we change the commands currently
322 if (executing_breakpoint_commands)
323 error ("Can't use the \"commands\" command among a breakpoint's commands.");
326 bnum = get_number (&p);
328 error ("Unexpected extra arguments following breakpoint number.");
331 if (b->number == bnum)
333 if (from_tty && input_from_terminal_p ())
334 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
335 End with a line saying just \"end\".\n", bnum);
336 l = read_command_lines ();
337 free_command_lines (&b->commands);
339 breakpoints_changed ();
342 error ("No breakpoint number %d.", bnum);
345 extern int memory_breakpoint_size; /* from mem-break.c */
347 /* Like target_read_memory() but if breakpoints are inserted, return
348 the shadow contents instead of the breakpoints themselves.
350 Read "memory data" from whatever target or inferior we have.
351 Returns zero if successful, errno value if not. EIO is used
352 for address out of bounds. If breakpoints are inserted, returns
353 shadow contents, not the breakpoints themselves. From breakpoint.c. */
356 read_memory_nobpt (memaddr, myaddr, len)
362 struct breakpoint *b;
364 if (memory_breakpoint_size < 0)
365 /* No breakpoints on this machine. FIXME: This should be
366 dependent on the debugging target. Probably want
367 target_insert_breakpoint to return a size, saying how many
368 bytes of the shadow contents are used, or perhaps have
369 something like target_xfer_shadow. */
370 return target_read_memory (memaddr, myaddr, len);
374 if (b->type == bp_watchpoint
375 || b->type == bp_hardware_watchpoint
376 || b->type == bp_read_watchpoint
377 || b->type == bp_access_watchpoint
380 else if (b->address + memory_breakpoint_size <= memaddr)
381 /* The breakpoint is entirely before the chunk of memory
384 else if (b->address >= memaddr + len)
385 /* The breakpoint is entirely after the chunk of memory we
390 /* Copy the breakpoint from the shadow contents, and recurse
391 for the things before and after. */
393 /* Addresses and length of the part of the breakpoint that
395 CORE_ADDR membpt = b->address;
396 unsigned int bptlen = memory_breakpoint_size;
397 /* Offset within shadow_contents. */
400 if (membpt < memaddr)
402 /* Only copy the second part of the breakpoint. */
403 bptlen -= memaddr - membpt;
404 bptoffset = memaddr - membpt;
408 if (membpt + bptlen > memaddr + len)
410 /* Only copy the first part of the breakpoint. */
411 bptlen -= (membpt + bptlen) - (memaddr + len);
414 memcpy (myaddr + membpt - memaddr,
415 b->shadow_contents + bptoffset, bptlen);
417 if (membpt > memaddr)
419 /* Copy the section of memory before the breakpoint. */
420 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
425 if (membpt + bptlen < memaddr + len)
427 /* Copy the section of memory after the breakpoint. */
428 status = read_memory_nobpt
430 myaddr + membpt + bptlen - memaddr,
431 memaddr + len - (membpt + bptlen));
438 /* Nothing overlaps. Just call read_memory_noerr. */
439 return target_read_memory (memaddr, myaddr, len);
442 /* insert_breakpoints is used when starting or continuing the program.
443 remove_breakpoints is used when the program stops.
444 Both return zero if successful,
445 or an `errno' value if could not write the inferior. */
448 insert_breakpoints ()
450 register struct breakpoint *b;
452 int disabled_breaks = 0;
455 if (b->type != bp_watchpoint
456 && b->type != bp_hardware_watchpoint
457 && b->type != bp_read_watchpoint
458 && b->type != bp_access_watchpoint
459 && b->enable != disabled
463 if (b->type == bp_hardware_breakpoint)
464 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
466 val = target_insert_breakpoint(b->address, b->shadow_contents);
469 /* Can't set the breakpoint. */
470 #if defined (DISABLE_UNSETTABLE_BREAK)
471 if (DISABLE_UNSETTABLE_BREAK (b->address))
474 b->enable = disabled;
475 if (!disabled_breaks)
477 target_terminal_ours_for_output ();
478 fprintf_unfiltered (gdb_stderr,
479 "Cannot insert breakpoint %d:\n", b->number);
480 printf_filtered ("Disabling shared library breakpoints:\n");
483 printf_filtered ("%d ", b->number);
488 target_terminal_ours_for_output ();
489 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
490 #ifdef ONE_PROCESS_WRITETEXT
491 fprintf_unfiltered (gdb_stderr,
492 "The same program may be running in another process.\n");
494 memory_error (val, b->address); /* which bombs us out */
500 else if ((b->type == bp_hardware_watchpoint ||
501 b->type == bp_read_watchpoint ||
502 b->type == bp_access_watchpoint)
503 && b->enable == enabled
507 struct frame_info *saved_frame;
508 int saved_level, within_current_scope;
509 value_ptr mark = value_mark ();
512 /* Save the current frame and level so we can restore it after
513 evaluating the watchpoint expression on its own frame. */
514 saved_frame = selected_frame;
515 saved_level = selected_frame_level;
517 /* Determine if the watchpoint is within scope. */
518 if (b->exp_valid_block == NULL)
519 within_current_scope = 1;
522 struct frame_info *fi =
523 find_frame_addr_in_frame_chain (b->watchpoint_frame);
524 within_current_scope = (fi != NULL);
525 if (within_current_scope)
526 select_frame (fi, -1);
529 if (within_current_scope)
531 /* Evaluate the expression and cut the chain of values
532 produced off from the value chain. */
533 v = evaluate_expression (b->exp);
534 value_release_to_mark (mark);
539 /* Look at each value on the value chain. */
540 for ( ; v; v=v->next)
542 /* If it's a memory location, then we must watch it. */
543 if (v->lval == lval_memory)
547 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
548 len = TYPE_LENGTH (VALUE_TYPE (v));
550 if (b->type == bp_read_watchpoint)
552 else if (b->type == bp_access_watchpoint)
555 val = target_insert_watchpoint (addr, len, type);
564 /* Failure to insert a watchpoint on any memory value in the
565 value chain brings us here. */
567 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
573 Hardware watchpoint %d deleted because the program has left the block in\n\
574 which its expression is valid.\n", b->number);
575 if (b->related_breakpoint)
576 delete_breakpoint (b->related_breakpoint);
577 delete_breakpoint (b);
580 /* Restore the frame and level. */
581 select_frame (saved_frame, saved_level);
584 printf_filtered ("\n");
590 remove_breakpoints ()
592 register struct breakpoint *b;
599 val = remove_breakpoint (b);
609 remove_breakpoint (b)
610 struct breakpoint *b;
614 if (b->type != bp_watchpoint
615 && b->type != bp_hardware_watchpoint
616 && b->type != bp_read_watchpoint
617 && b->type != bp_access_watchpoint)
619 if (b->type == bp_hardware_breakpoint)
620 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
622 val = target_remove_breakpoint(b->address, b->shadow_contents);
627 else if ((b->type == bp_hardware_watchpoint ||
628 b->type == bp_read_watchpoint ||
629 b->type == bp_access_watchpoint)
630 && b->enable == enabled
636 /* Walk down the saved value chain. */
637 for (v = b->val_chain; v; v = v->next)
639 /* For each memory reference remove the watchpoint
641 if (v->lval == lval_memory)
645 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
646 len = TYPE_LENGTH (VALUE_TYPE (v));
647 val = target_remove_watchpoint (addr, len, b->type);
653 /* Failure to remove any of the hardware watchpoints comes here. */
655 error ("Hardware watchpoint %d: Could not remove watchpoint\n",
658 /* Free the saved value chain. We will construct a new one
659 the next time the watchpoint is inserted. */
660 for (v = b->val_chain; v; v = n)
670 /* Clear the "inserted" flag in all breakpoints. */
673 mark_breakpoints_out ()
675 register struct breakpoint *b;
681 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
682 which should go away between runs of the program. */
685 breakpoint_init_inferior ()
687 register struct breakpoint *b, *temp;
689 ALL_BREAKPOINTS_SAFE (b, temp)
693 /* If the call dummy breakpoint is at the entry point it will
694 cause problems when the inferior is rerun, so we better
696 if (b->type == bp_call_dummy)
697 delete_breakpoint (b);
699 /* Likewise for scope breakpoints. */
700 if (b->type == bp_watchpoint_scope)
701 delete_breakpoint (b);
703 /* Likewise for watchpoints on local expressions. */
704 if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint ||
705 b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
706 && b->exp_valid_block != NULL)
707 delete_breakpoint (b);
711 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
712 When continuing from a location with a breakpoint,
713 we actually single step once before calling insert_breakpoints. */
716 breakpoint_here_p (pc)
719 register struct breakpoint *b;
722 if (b->enable != disabled && b->address == pc)
728 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
729 because figuring out the saved SP would take too much time, at least using
730 get_saved_register on the 68k. This means that for this function to
731 work right a port must use the bp_call_dummy breakpoint. */
734 frame_in_dummy (frame)
735 struct frame_info *frame;
737 struct breakpoint *b;
742 static unsigned LONGEST dummy[] = CALL_DUMMY;
744 if (b->type == bp_call_dummy
745 && b->frame == frame->frame
747 /* We need to check the PC as well as the frame on the sparc,
748 for signals.exp in the testsuite. */
751 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
752 && frame->pc <= b->address)
755 #endif /* CALL_DUMMY */
759 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
760 is valid for process/thread PID. */
763 breakpoint_thread_match (pc, pid)
767 struct breakpoint *b;
770 thread = pid_to_thread_id (pid);
773 if (b->enable != disabled
775 && (b->thread == -1 || b->thread == thread))
782 /* bpstat stuff. External routines' interfaces are documented
785 /* Clear a bpstat so that it says we are not at any breakpoint.
786 Also free any storage that is part of a bpstat. */
801 if (p->old_val != NULL)
802 value_free (p->old_val);
809 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
810 is part of the bpstat is copied as well. */
818 bpstat retval = NULL;
823 for (; bs != NULL; bs = bs->next)
825 tmp = (bpstat) xmalloc (sizeof (*tmp));
826 memcpy (tmp, bs, sizeof (*tmp));
828 /* This is the first thing in the chain. */
838 /* Find the bpstat associated with this breakpoint */
841 bpstat_find_breakpoint(bsp, breakpoint)
843 struct breakpoint *breakpoint;
845 if (bsp == NULL) return NULL;
847 for (;bsp != NULL; bsp = bsp->next) {
848 if (bsp->breakpoint_at == breakpoint) return bsp;
853 /* Return the breakpoint number of the first breakpoint we are stopped
854 at. *BSP upon return is a bpstat which points to the remaining
855 breakpoints stopped at (but which is not guaranteed to be good for
856 anything but further calls to bpstat_num).
857 Return 0 if passed a bpstat which does not indicate any breakpoints. */
863 struct breakpoint *b;
866 return 0; /* No more breakpoint values */
869 b = (*bsp)->breakpoint_at;
872 return -1; /* breakpoint that's been deleted since */
874 return b->number; /* We have its number */
878 /* Modify BS so that the actions will not be performed. */
881 bpstat_clear_actions (bs)
884 for (; bs != NULL; bs = bs->next)
887 if (bs->old_val != NULL)
889 value_free (bs->old_val);
895 /* Stub for cleaning up our state if we error-out of a breakpoint command */
898 cleanup_executing_breakpoints (ignore)
901 executing_breakpoint_commands = 0;
904 /* Execute all the commands associated with all the breakpoints at this
905 location. Any of these commands could cause the process to proceed
906 beyond this point, etc. We look out for such changes by checking
907 the global "breakpoint_proceeded" after each command. */
910 bpstat_do_actions (bsp)
914 struct cleanup *old_chain;
915 struct command_line *cmd;
917 executing_breakpoint_commands = 1;
918 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
923 breakpoint_proceeded = 0;
924 for (; bs != NULL; bs = bs->next)
929 execute_control_command (cmd);
932 if (breakpoint_proceeded)
933 /* The inferior is proceeded by the command; bomb out now.
934 The bpstat chain has been blown away by wait_for_inferior.
935 But since execution has stopped again, there is a new bpstat
936 to look at, so start over. */
942 executing_breakpoint_commands = 0;
943 discard_cleanups (old_chain);
946 /* This is the normal print_it function for a bpstat. In the future,
947 much of this logic could (should?) be moved to bpstat_stop_status,
948 by having it set different print_it functions. */
954 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
955 which has since been deleted. */
956 if (bs->breakpoint_at == NULL
957 || (bs->breakpoint_at->type != bp_breakpoint
958 && bs->breakpoint_at->type != bp_hardware_breakpoint
959 && bs->breakpoint_at->type != bp_watchpoint
960 && bs->breakpoint_at->type != bp_read_watchpoint
961 && bs->breakpoint_at->type != bp_access_watchpoint
962 && bs->breakpoint_at->type != bp_hardware_watchpoint))
965 if (bs->breakpoint_at->type == bp_breakpoint ||
966 bs->breakpoint_at->type == bp_hardware_breakpoint)
968 /* I think the user probably only wants to see one breakpoint
969 number, not all of them. */
970 annotate_breakpoint (bs->breakpoint_at->number);
971 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
974 else if ((bs->old_val != NULL) &&
975 (bs->breakpoint_at->type == bp_watchpoint ||
976 bs->breakpoint_at->type == bp_access_watchpoint ||
977 bs->breakpoint_at->type == bp_hardware_watchpoint))
979 annotate_watchpoint (bs->breakpoint_at->number);
980 mention (bs->breakpoint_at);
981 printf_filtered ("\nOld value = ");
982 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
983 printf_filtered ("\nNew value = ");
984 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
986 printf_filtered ("\n");
987 value_free (bs->old_val);
989 /* More than one watchpoint may have been triggered. */
992 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
993 bs->breakpoint_at->type == bp_read_watchpoint)
995 mention (bs->breakpoint_at);
996 printf_filtered ("\nValue = ");
997 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
999 printf_filtered ("\n");
1002 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1006 /* Print a message indicating what happened. Returns nonzero to
1007 say that only the source line should be printed after this (zero
1008 return means print the frame as well as the source line). */
1009 /* Currently we always return zero. */
1019 val = (*bs->print_it) (bs);
1023 /* Maybe another breakpoint in the chain caused us to stop.
1024 (Currently all watchpoints go on the bpstat whether hit or
1025 not. That probably could (should) be changed, provided care is taken
1026 with respect to bpstat_explains_signal). */
1028 return bpstat_print (bs->next);
1030 /* We reached the end of the chain without printing anything. */
1034 /* Evaluate the expression EXP and return 1 if value is zero.
1035 This is used inside a catch_errors to evaluate the breakpoint condition.
1036 The argument is a "struct expression *" that has been cast to char * to
1037 make it pass through catch_errors. */
1040 breakpoint_cond_eval (exp)
1043 value_ptr mark = value_mark ();
1044 int i = !value_true (evaluate_expression ((struct expression *)exp));
1045 value_free_to_mark (mark);
1049 /* Allocate a new bpstat and chain it to the current one. */
1052 bpstat_alloc (b, cbs)
1053 register struct breakpoint *b;
1054 bpstat cbs; /* Current "bs" value */
1058 bs = (bpstat) xmalloc (sizeof (*bs));
1060 bs->breakpoint_at = b;
1061 /* If the condition is false, etc., don't do the commands. */
1062 bs->commands = NULL;
1064 bs->print_it = print_it_normal;
1068 /* Possible return values for watchpoint_check (this can't be an enum
1069 because of check_errors). */
1070 /* The watchpoint has been deleted. */
1071 #define WP_DELETED 1
1072 /* The value has changed. */
1073 #define WP_VALUE_CHANGED 2
1074 /* The value has not changed. */
1075 #define WP_VALUE_NOT_CHANGED 3
1077 #define BP_TEMPFLAG 1
1078 #define BP_HARDWAREFLAG 2
1080 /* Check watchpoint condition. */
1083 watchpoint_check (p)
1086 bpstat bs = (bpstat) p;
1087 struct breakpoint *b;
1088 struct frame_info *fr;
1089 int within_current_scope;
1091 b = bs->breakpoint_at;
1093 if (b->exp_valid_block == NULL)
1094 within_current_scope = 1;
1097 /* There is no current frame at this moment. If we're going to have
1098 any chance of handling watchpoints on local variables, we'll need
1099 the frame chain (so we can determine if we're in scope). */
1100 reinit_frame_cache();
1101 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1102 within_current_scope = (fr != NULL);
1103 if (within_current_scope)
1104 /* If we end up stopping, the current frame will get selected
1105 in normal_stop. So this call to select_frame won't affect
1107 select_frame (fr, -1);
1110 if (within_current_scope)
1112 /* We use value_{,free_to_}mark because it could be a
1113 *long* time before we return to the command level and
1114 call free_all_values. We can't call free_all_values because
1115 we might be in the middle of evaluating a function call. */
1117 value_ptr mark = value_mark ();
1118 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1119 if (!value_equal (b->val, new_val))
1121 release_value (new_val);
1122 value_free_to_mark (mark);
1123 bs->old_val = b->val;
1125 /* We will stop here */
1126 return WP_VALUE_CHANGED;
1130 /* Nothing changed, don't do anything. */
1131 value_free_to_mark (mark);
1132 /* We won't stop here */
1133 return WP_VALUE_NOT_CHANGED;
1138 /* This seems like the only logical thing to do because
1139 if we temporarily ignored the watchpoint, then when
1140 we reenter the block in which it is valid it contains
1141 garbage (in the case of a function, it may have two
1142 garbage values, one before and one after the prologue).
1143 So we can't even detect the first assignment to it and
1144 watch after that (since the garbage may or may not equal
1145 the first value assigned). */
1147 Watchpoint %d deleted because the program has left the block in\n\
1148 which its expression is valid.\n", bs->breakpoint_at->number);
1149 if (b->related_breakpoint)
1150 delete_breakpoint (b->related_breakpoint);
1151 delete_breakpoint (b);
1157 /* This is used when everything which needs to be printed has
1158 already been printed. But we still want to print the frame. */
1166 /* This is used when nothing should be printed for this bpstat entry. */
1175 /* Get a bpstat associated with having just stopped at address *PC
1176 and frame address CORE_ADDRESS. Update *PC to point at the
1177 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1178 if this is known to not be a real breakpoint (it could still be a
1179 watchpoint, though). */
1181 /* Determine whether we stopped at a breakpoint, etc, or whether we
1182 don't understand this stop. Result is a chain of bpstat's such that:
1184 if we don't understand the stop, the result is a null pointer.
1186 if we understand why we stopped, the result is not null.
1188 Each element of the chain refers to a particular breakpoint or
1189 watchpoint at which we have stopped. (We may have stopped for
1190 several reasons concurrently.)
1192 Each element of the chain has valid next, breakpoint_at,
1193 commands, FIXME??? fields.
1198 bpstat_stop_status (pc, not_a_breakpoint)
1200 int not_a_breakpoint;
1202 register struct breakpoint *b;
1204 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1205 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1206 int real_breakpoint = 0;
1208 /* Root of the chain of bpstat's */
1209 struct bpstats root_bs[1];
1210 /* Pointer to the last thing in the chain currently. */
1211 bpstat bs = root_bs;
1212 static char message1[] =
1213 "Error evaluating expression for watchpoint %d\n";
1214 char message[sizeof (message1) + 30 /* slop */];
1216 /* Get the address where the breakpoint would have been. */
1217 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1221 if (b->enable == disabled)
1224 if (b->type != bp_watchpoint
1225 && b->type != bp_hardware_watchpoint
1226 && b->type != bp_read_watchpoint
1227 && b->type != bp_access_watchpoint
1228 && b->type != bp_hardware_breakpoint
1229 && b->address != bp_addr)
1232 if (b->type == bp_hardware_breakpoint
1233 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
1236 if (b->type != bp_watchpoint
1237 && b->type != bp_hardware_watchpoint
1238 && b->type != bp_read_watchpoint
1239 && b->type != bp_access_watchpoint
1240 && not_a_breakpoint)
1243 /* Come here if it's a watchpoint, or if the break address matches */
1247 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1252 sprintf (message, message1, b->number);
1253 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
1255 switch (catch_errors (watchpoint_check, (char *) bs, message,
1259 /* We've already printed what needs to be printed. */
1260 bs->print_it = print_it_done;
1263 case WP_VALUE_CHANGED:
1266 case WP_VALUE_NOT_CHANGED:
1268 bs->print_it = print_it_noop;
1275 /* Error from catch_errors. */
1276 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1277 if (b->related_breakpoint)
1278 delete_breakpoint (b->related_breakpoint);
1279 delete_breakpoint (b);
1280 /* We've already printed what needs to be printed. */
1281 bs->print_it = print_it_done;
1287 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
1293 addr = target_stopped_data_address();
1294 if (addr == 0) continue;
1295 for (v = b->val_chain; v; v = v->next)
1297 if (v->lval == lval_memory)
1301 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1307 switch (catch_errors (watchpoint_check, (char *) bs, message,
1311 /* We've already printed what needs to be printed. */
1312 bs->print_it = print_it_done;
1315 case WP_VALUE_CHANGED:
1316 case WP_VALUE_NOT_CHANGED:
1322 /* Error from catch_errors. */
1323 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1324 if (b->related_breakpoint)
1325 delete_breakpoint (b->related_breakpoint);
1326 delete_breakpoint (b);
1327 /* We've already printed what needs to be printed. */
1328 bs->print_it = print_it_done;
1332 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1334 real_breakpoint = 1;
1337 if (b->frame && b->frame != (get_current_frame ())->frame)
1341 int value_is_zero = 0;
1345 /* Need to select the frame, with all that implies
1346 so that the conditions will have the right context. */
1347 select_frame (get_current_frame (), 0);
1349 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1350 "Error in testing breakpoint condition:\n",
1352 /* FIXME-someday, should give breakpoint # */
1355 if (b->cond && value_is_zero)
1359 else if (b->ignore_count > 0)
1366 /* We will stop here */
1367 if (b->disposition == disable)
1368 b->enable = disabled;
1369 bs->commands = b->commands;
1372 if (bs->commands && STREQ ("silent", bs->commands->line))
1374 bs->commands = bs->commands->next;
1379 /* Print nothing for this entry if we dont stop or if we dont print. */
1380 if (bs->stop == 0 || bs->print == 0)
1381 bs->print_it = print_it_noop;
1384 bs->next = NULL; /* Terminate the chain */
1385 bs = root_bs->next; /* Re-grab the head of the chain */
1386 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1389 if (real_breakpoint)
1392 #if defined (SHIFT_INST_REGS)
1394 #else /* No SHIFT_INST_REGS. */
1396 #endif /* No SHIFT_INST_REGS. */
1399 #endif /* DECR_PC_AFTER_BREAK != 0. */
1401 /* The value of a hardware watchpoint hasn't changed, but the
1402 intermediate memory locations we are watching may have. */
1403 if (bs && ! bs->stop &&
1404 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
1405 bs->breakpoint_at->type == bp_read_watchpoint ||
1406 bs->breakpoint_at->type == bp_access_watchpoint))
1408 remove_breakpoints ();
1409 insert_breakpoints ();
1414 /* Tell what to do about this bpstat. */
1419 /* Classify each bpstat as one of the following. */
1421 /* This bpstat element has no effect on the main_action. */
1424 /* There was a watchpoint, stop but don't print. */
1427 /* There was a watchpoint, stop and print. */
1430 /* There was a breakpoint but we're not stopping. */
1433 /* There was a breakpoint, stop but don't print. */
1436 /* There was a breakpoint, stop and print. */
1439 /* We hit the longjmp breakpoint. */
1442 /* We hit the longjmp_resume breakpoint. */
1445 /* We hit the step_resume breakpoint. */
1448 /* We hit the through_sigtramp breakpoint. */
1451 /* This is just used to count how many enums there are. */
1455 /* Here is the table which drives this routine. So that we can
1456 format it pretty, we define some abbreviations for the
1457 enum bpstat_what codes. */
1458 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1459 #define stop_s BPSTAT_WHAT_STOP_SILENT
1460 #define stop_n BPSTAT_WHAT_STOP_NOISY
1461 #define single BPSTAT_WHAT_SINGLE
1462 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1463 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1464 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1465 #define sr BPSTAT_WHAT_STEP_RESUME
1466 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1468 /* "Can't happen." Might want to print an error message.
1469 abort() is not out of the question, but chances are GDB is just
1470 a bit confused, not unusable. */
1471 #define err BPSTAT_WHAT_STOP_NOISY
1473 /* Given an old action and a class, come up with a new action. */
1474 /* One interesting property of this table is that wp_silent is the same
1475 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1476 after stopping, the check for whether to step over a breakpoint
1477 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1478 reference to how we stopped. We retain separate wp_silent and bp_silent
1479 codes in case we want to change that someday. */
1481 /* step_resume entries: a step resume breakpoint overrides another
1482 breakpoint of signal handling (see comment in wait_for_inferior
1483 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1484 /* We handle the through_sigtramp_breakpoint the same way; having both
1485 one of those and a step_resume_breakpoint is probably very rare (?). */
1487 static const enum bpstat_what_main_action
1488 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1491 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr ts
1493 /*no_effect*/ {keep_c,stop_s,stop_n,single, setlr , clrlr , clrlrs, sr, ts},
1494 /*wp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1495 /*wp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1496 /*bp_nostop*/ {single,stop_s,stop_n,single, setlr , clrlrs, clrlrs, sr, ts},
1497 /*bp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1498 /*bp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1499 /*long_jump*/ {setlr ,stop_s,stop_n,setlr , err , err , err , sr, ts},
1500 /*long_resume*/ {clrlr ,stop_s,stop_n,clrlrs, err , err , err , sr, ts},
1501 /*step_resume*/ {sr ,sr ,sr ,sr , sr , sr , sr , sr, ts},
1502 /*through_sig*/ {ts ,ts ,ts ,ts , ts , ts , ts , ts, ts}
1514 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1515 struct bpstat_what retval;
1517 retval.call_dummy = 0;
1518 for (; bs != NULL; bs = bs->next)
1520 enum class bs_class = no_effect;
1521 if (bs->breakpoint_at == NULL)
1522 /* I suspect this can happen if it was a momentary breakpoint
1523 which has since been deleted. */
1525 switch (bs->breakpoint_at->type)
1528 case bp_hardware_breakpoint:
1534 bs_class = bp_noisy;
1536 bs_class = bp_silent;
1539 bs_class = bp_nostop;
1542 case bp_hardware_watchpoint:
1543 case bp_read_watchpoint:
1544 case bp_access_watchpoint:
1548 bs_class = wp_noisy;
1550 bs_class = wp_silent;
1553 /* There was a watchpoint, but we're not stopping. This requires
1554 no further action. */
1555 bs_class = no_effect;
1558 bs_class = long_jump;
1560 case bp_longjmp_resume:
1561 bs_class = long_resume;
1563 case bp_step_resume:
1566 bs_class = step_resume;
1569 /* It is for the wrong frame. */
1570 bs_class = bp_nostop;
1572 case bp_through_sigtramp:
1573 bs_class = through_sig;
1575 case bp_watchpoint_scope:
1576 bs_class = bp_nostop;
1580 /* Make sure the action is stop (silent or noisy), so infrun.c
1581 pops the dummy frame. */
1582 bs_class = bp_silent;
1583 retval.call_dummy = 1;
1586 current_action = table[(int)bs_class][(int)current_action];
1588 retval.main_action = current_action;
1592 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1593 without hardware support). This isn't related to a specific bpstat,
1594 just to things like whether watchpoints are set. */
1597 bpstat_should_step ()
1599 struct breakpoint *b;
1601 if (b->enable == enabled && b->type == bp_watchpoint)
1606 /* Print information on breakpoint number BNUM, or -1 if all.
1607 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1608 is nonzero, process only watchpoints. */
1611 breakpoint_1 (bnum, allflag)
1615 register struct breakpoint *b;
1616 register struct command_line *l;
1617 register struct symbol *sym;
1618 CORE_ADDR last_addr = (CORE_ADDR)-1;
1619 int found_a_breakpoint = 0;
1620 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1621 "until", "finish", "watchpoint",
1622 "hw watchpoint", "read watchpoint",
1623 "acc watchpoint", "longjmp",
1624 "longjmp resume", "step resume",
1625 "watchpoint scope", "call dummy" };
1626 static char *bpdisps[] = {"del", "dis", "keep"};
1627 static char bpenables[] = "ny";
1628 char wrap_indent[80];
1632 || bnum == b->number)
1634 /* We only print out user settable breakpoints unless the allflag is set. */
1636 && b->type != bp_breakpoint
1637 && b->type != bp_hardware_breakpoint
1638 && b->type != bp_watchpoint
1639 && b->type != bp_read_watchpoint
1640 && b->type != bp_access_watchpoint
1641 && b->type != bp_hardware_watchpoint)
1644 if (!found_a_breakpoint++)
1646 annotate_breakpoints_headers ();
1649 printf_filtered ("Num ");
1651 printf_filtered ("Type ");
1653 printf_filtered ("Disp ");
1655 printf_filtered ("Enb ");
1659 printf_filtered ("Address ");
1662 printf_filtered ("What\n");
1664 annotate_breakpoints_table ();
1669 printf_filtered ("%-3d ", b->number);
1671 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1673 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1675 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1677 strcpy (wrap_indent, " ");
1679 strcat (wrap_indent, " ");
1683 case bp_hardware_watchpoint:
1684 case bp_read_watchpoint:
1685 case bp_access_watchpoint:
1686 /* Field 4, the address, is omitted (which makes the columns
1687 not line up too nicely with the headers, but the effect
1688 is relatively readable). */
1690 print_expression (b->exp, gdb_stdout);
1694 case bp_hardware_breakpoint:
1698 case bp_longjmp_resume:
1699 case bp_step_resume:
1700 case bp_through_sigtramp:
1701 case bp_watchpoint_scope:
1706 /* FIXME-32x64: need a print_address_numeric with
1710 local_hex_string_custom
1711 ((unsigned long) b->address, "08l"));
1716 last_addr = b->address;
1719 sym = find_pc_function (b->address);
1722 fputs_filtered ("in ", gdb_stdout);
1723 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1724 wrap_here (wrap_indent);
1725 fputs_filtered (" at ", gdb_stdout);
1727 fputs_filtered (b->source_file, gdb_stdout);
1728 printf_filtered (":%d", b->line_number);
1731 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1735 printf_filtered ("\n");
1741 printf_filtered ("\tstop only in stack frame at ");
1742 print_address_numeric (b->frame, 1, gdb_stdout);
1743 printf_filtered ("\n");
1750 printf_filtered ("\tstop only if ");
1751 print_expression (b->cond, gdb_stdout);
1752 printf_filtered ("\n");
1755 if (show_breakpoint_hit_counts && b->hit_count)
1757 /* FIXME should make an annotation for this */
1759 printf_filtered ("\tbreakpoint already hit %d time%s\n",
1760 b->hit_count, (b->hit_count == 1 ? "" : "s"));
1763 if (b->ignore_count)
1767 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1770 if ((l = b->commands))
1776 print_command_line (l, 4);
1782 if (!found_a_breakpoint)
1785 printf_filtered ("No breakpoints or watchpoints.\n");
1787 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1790 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1791 that a comparison of an unsigned with -1 is always false. */
1792 if (last_addr != (CORE_ADDR)-1)
1793 set_next_address (last_addr);
1795 annotate_breakpoints_table_end ();
1800 breakpoints_info (bnum_exp, from_tty)
1807 bnum = parse_and_eval_address (bnum_exp);
1809 breakpoint_1 (bnum, 0);
1812 #if MAINTENANCE_CMDS
1816 maintenance_info_breakpoints (bnum_exp, from_tty)
1823 bnum = parse_and_eval_address (bnum_exp);
1825 breakpoint_1 (bnum, 1);
1830 /* Print a message describing any breakpoints set at PC. */
1833 describe_other_breakpoints (pc)
1834 register CORE_ADDR pc;
1836 register int others = 0;
1837 register struct breakpoint *b;
1840 if (b->address == pc)
1844 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1846 if (b->address == pc)
1852 (b->enable == disabled) ? " (disabled)" : "",
1853 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1855 printf_filtered ("also set at pc ");
1856 print_address_numeric (pc, 1, gdb_stdout);
1857 printf_filtered (".\n");
1861 /* Set the default place to put a breakpoint
1862 for the `break' command with no arguments. */
1865 set_default_breakpoint (valid, addr, symtab, line)
1868 struct symtab *symtab;
1871 default_breakpoint_valid = valid;
1872 default_breakpoint_address = addr;
1873 default_breakpoint_symtab = symtab;
1874 default_breakpoint_line = line;
1877 /* Rescan breakpoints at address ADDRESS,
1878 marking the first one as "first" and any others as "duplicates".
1879 This is so that the bpt instruction is only inserted once. */
1882 check_duplicates (address)
1885 register struct breakpoint *b;
1886 register int count = 0;
1888 if (address == 0) /* Watchpoints are uninteresting */
1892 if (b->enable != disabled && b->address == address)
1895 b->duplicate = count > 1;
1899 /* Low level routine to set a breakpoint.
1900 Takes as args the three things that every breakpoint must have.
1901 Returns the breakpoint object so caller can set other things.
1902 Does not set the breakpoint number!
1903 Does not print anything.
1905 ==> This routine should not be called if there is a chance of later
1906 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1907 your arguments BEFORE calling this routine! */
1909 static struct breakpoint *
1910 set_raw_breakpoint (sal)
1911 struct symtab_and_line sal;
1913 register struct breakpoint *b, *b1;
1915 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1916 memset (b, 0, sizeof (*b));
1917 b->address = sal.pc;
1918 if (sal.symtab == NULL)
1919 b->source_file = NULL;
1921 b->source_file = savestring (sal.symtab->filename,
1922 strlen (sal.symtab->filename));
1923 b->language = current_language->la_language;
1924 b->input_radix = input_radix;
1926 b->line_number = sal.line;
1927 b->enable = enabled;
1930 b->ignore_count = 0;
1934 /* Add this breakpoint to the end of the chain
1935 so that a list of breakpoints will come out in order
1936 of increasing numbers. */
1938 b1 = breakpoint_chain;
1940 breakpoint_chain = b;
1948 check_duplicates (sal.pc);
1949 breakpoints_changed ();
1955 create_longjmp_breakpoint (func_name)
1958 struct symtab_and_line sal;
1959 struct breakpoint *b;
1960 static int internal_breakpoint_number = -1;
1962 if (func_name != NULL)
1964 struct minimal_symbol *m;
1966 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
1968 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1978 b = set_raw_breakpoint (sal);
1981 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1982 b->disposition = donttouch;
1983 b->enable = disabled;
1986 b->addr_string = strsave(func_name);
1987 b->number = internal_breakpoint_number--;
1990 /* Call this routine when stepping and nexting to enable a breakpoint if we do
1991 a longjmp(). When we hit that breakpoint, call
1992 set_longjmp_resume_breakpoint() to figure out where we are going. */
1995 enable_longjmp_breakpoint()
1997 register struct breakpoint *b;
2000 if (b->type == bp_longjmp)
2002 b->enable = enabled;
2003 check_duplicates (b->address);
2008 disable_longjmp_breakpoint()
2010 register struct breakpoint *b;
2013 if ( b->type == bp_longjmp
2014 || b->type == bp_longjmp_resume)
2016 b->enable = disabled;
2017 check_duplicates (b->address);
2022 hw_breakpoint_used_count()
2024 register struct breakpoint *b;
2029 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2037 hw_watchpoint_used_count(type, other_type_used)
2039 int *other_type_used;
2041 register struct breakpoint *b;
2044 *other_type_used = 0;
2047 if (b->enable == enabled)
2049 if (b->type == type) i++;
2050 else if ((b->type == bp_hardware_watchpoint ||
2051 b->type == bp_read_watchpoint ||
2052 b->type == bp_access_watchpoint)
2053 && b->enable == enabled)
2054 *other_type_used = 1;
2060 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2061 breakpoint at the target of the jmp_buf.
2063 FIXME - This ought to be done by setting a temporary breakpoint that gets
2064 deleted automatically...
2068 set_longjmp_resume_breakpoint(pc, frame)
2070 struct frame_info *frame;
2072 register struct breakpoint *b;
2075 if (b->type == bp_longjmp_resume)
2078 b->enable = enabled;
2080 b->frame = frame->frame;
2083 check_duplicates (b->address);
2088 /* Set a breakpoint that will evaporate an end of command
2089 at address specified by SAL.
2090 Restrict it to frame FRAME if FRAME is nonzero. */
2093 set_momentary_breakpoint (sal, frame, type)
2094 struct symtab_and_line sal;
2095 struct frame_info *frame;
2098 register struct breakpoint *b;
2099 b = set_raw_breakpoint (sal);
2101 b->enable = enabled;
2102 b->disposition = donttouch;
2103 b->frame = (frame ? frame->frame : 0);
2105 /* If we're debugging a multi-threaded program, then we
2106 want momentary breakpoints to be active in only a
2107 single thread of control. */
2108 if (in_thread_list (inferior_pid))
2109 b->thread = pid_to_thread_id (inferior_pid);
2116 clear_momentary_breakpoints ()
2118 register struct breakpoint *b;
2120 if (b->disposition == delete)
2122 delete_breakpoint (b);
2128 /* Tell the user we have just set a breakpoint B. */
2132 struct breakpoint *b;
2136 /* FIXME: This is misplaced; mention() is called by things (like hitting a
2137 watchpoint) other than breakpoint creation. It should be possible to
2138 clean this up and at the same time replace the random calls to
2139 breakpoint_changed with this hook, as has already been done for
2140 delete_breakpoint_hook and so on. */
2141 if (create_breakpoint_hook)
2142 create_breakpoint_hook (b);
2147 printf_filtered ("Watchpoint %d: ", b->number);
2148 print_expression (b->exp, gdb_stdout);
2150 case bp_hardware_watchpoint:
2151 printf_filtered ("Hardware watchpoint %d: ", b->number);
2152 print_expression (b->exp, gdb_stdout);
2154 case bp_read_watchpoint:
2155 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2156 print_expression (b->exp, gdb_stdout);
2158 case bp_access_watchpoint:
2159 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2160 print_expression (b->exp, gdb_stdout);
2163 printf_filtered ("Breakpoint %d", b->number);
2166 case bp_hardware_breakpoint:
2167 printf_filtered ("Hardware assisted breakpoint %d", b->number);
2173 case bp_longjmp_resume:
2174 case bp_step_resume:
2175 case bp_through_sigtramp:
2177 case bp_watchpoint_scope:
2182 if (addressprint || b->source_file == NULL)
2184 printf_filtered (" at ");
2185 print_address_numeric (b->address, 1, gdb_stdout);
2188 printf_filtered (": file %s, line %d.",
2189 b->source_file, b->line_number);
2191 printf_filtered ("\n");
2195 /* Nobody calls this currently. */
2196 /* Set a breakpoint from a symtab and line.
2197 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2198 ADDR_STRING is a malloc'd string holding the name of where we are
2199 setting the breakpoint. This is used later to re-set it after the
2200 program is relinked and symbols are reloaded.
2201 Print the same confirmation messages that the breakpoint command prints. */
2204 set_breakpoint (s, line, tempflag, addr_string)
2210 register struct breakpoint *b;
2211 struct symtab_and_line sal;
2216 resolve_sal_pc (&sal); /* Might error out */
2217 describe_other_breakpoints (sal.pc);
2219 b = set_raw_breakpoint (sal);
2220 set_breakpoint_count (breakpoint_count + 1);
2221 b->number = breakpoint_count;
2222 b->type = bp_breakpoint;
2224 b->addr_string = addr_string;
2225 b->enable = enabled;
2226 b->disposition = tempflag ? delete : donttouch;
2232 /* Set a breakpoint according to ARG (function, linenum or *address)
2233 flag: first bit : 0 non-temporary, 1 temporary.
2234 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2237 break_command_1 (arg, flag, from_tty)
2241 int tempflag, hardwareflag;
2242 struct symtabs_and_lines sals;
2243 struct symtab_and_line sal;
2244 register struct expression *cond = 0;
2245 register struct breakpoint *b;
2247 /* Pointers in arg to the start, and one past the end, of the condition. */
2248 char *cond_start = NULL;
2249 char *cond_end = NULL;
2250 /* Pointers in arg to the start, and one past the end,
2251 of the address part. */
2252 char *addr_start = NULL;
2253 char *addr_end = NULL;
2254 struct cleanup *old_chain;
2255 struct cleanup *canonical_strings_chain = NULL;
2256 char **canonical = (char **)NULL;
2260 hardwareflag = flag & BP_HARDWAREFLAG;
2261 tempflag = flag & BP_TEMPFLAG;
2266 sal.line = sal.pc = sal.end = 0;
2269 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2271 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2272 && (arg[2] == ' ' || arg[2] == '\t')))
2274 if (default_breakpoint_valid)
2276 sals.sals = (struct symtab_and_line *)
2277 xmalloc (sizeof (struct symtab_and_line));
2278 sal.pc = default_breakpoint_address;
2279 sal.line = default_breakpoint_line;
2280 sal.symtab = default_breakpoint_symtab;
2285 error ("No default breakpoint address now.");
2291 /* Force almost all breakpoints to be in terms of the
2292 current_source_symtab (which is decode_line_1's default). This
2293 should produce the results we want almost all of the time while
2294 leaving default_breakpoint_* alone. */
2295 if (default_breakpoint_valid
2296 && (!current_source_symtab
2297 || (arg && (*arg == '+' || *arg == '-'))))
2298 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2299 default_breakpoint_line, &canonical);
2301 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2309 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2310 the following `for' loop errors out. */
2311 old_chain = make_cleanup (free, sals.sals);
2312 if (canonical != (char **)NULL)
2314 make_cleanup (free, canonical);
2315 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2316 for (i = 0; i < sals.nelts; i++)
2318 if (canonical[i] != NULL)
2319 make_cleanup (free, canonical[i]);
2323 thread = -1; /* No specific thread yet */
2325 /* Resolve all line numbers to PC's, and verify that conditions
2326 can be parsed, before setting any breakpoints. */
2327 for (i = 0; i < sals.nelts; i++)
2329 char *tok, *end_tok;
2332 resolve_sal_pc (&sals.sals[i]);
2338 while (*tok == ' ' || *tok == '\t')
2343 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2346 toklen = end_tok - tok;
2348 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2350 tok = cond_start = end_tok + 1;
2351 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2354 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2360 thread = strtol (tok, &tok, 0);
2362 error ("Junk after thread keyword.");
2363 if (!valid_thread_id (thread))
2364 error ("Unknown thread %d\n", thread);
2367 error ("Junk at end of arguments.");
2372 int i, target_resources_ok;
2374 i = hw_breakpoint_used_count ();
2375 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
2376 bp_hardware_breakpoint, i + sals.nelts, 0);
2377 if (target_resources_ok == 0)
2378 error ("No hardware breakpoint support in the target.");
2379 else if (target_resources_ok < 0)
2380 error ("Hardware breakpoints used exceeds limit.");
2383 /* Remove the canonical strings from the cleanup, they are needed below. */
2384 if (canonical != (char **)NULL)
2385 discard_cleanups (canonical_strings_chain);
2387 /* Now set all the breakpoints. */
2388 for (i = 0; i < sals.nelts; i++)
2393 describe_other_breakpoints (sal.pc);
2395 b = set_raw_breakpoint (sal);
2396 set_breakpoint_count (breakpoint_count + 1);
2397 b->number = breakpoint_count;
2398 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2402 /* If a canonical line spec is needed use that instead of the
2404 if (canonical != (char **)NULL && canonical[i] != NULL)
2405 b->addr_string = canonical[i];
2406 else if (addr_start)
2407 b->addr_string = savestring (addr_start, addr_end - addr_start);
2409 b->cond_string = savestring (cond_start, cond_end - cond_start);
2411 b->enable = enabled;
2412 b->disposition = tempflag ? del : donttouch;
2419 printf_filtered ("Multiple breakpoints were set.\n");
2420 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2422 do_cleanups (old_chain);
2425 /* Helper function for break_command_1 and disassemble_command. */
2428 resolve_sal_pc (sal)
2429 struct symtab_and_line *sal;
2433 if (sal->pc == 0 && sal->symtab != 0)
2435 pc = find_line_pc (sal->symtab, sal->line);
2437 error ("No line %d in file \"%s\".",
2438 sal->line, sal->symtab->filename);
2444 break_command (arg, from_tty)
2448 break_command_1 (arg, 0, from_tty);
2452 tbreak_command (arg, from_tty)
2456 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2460 hbreak_command (arg, from_tty)
2464 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2468 thbreak_command (arg, from_tty)
2472 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2476 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2479 watch_command_1 (arg, accessflag, from_tty)
2484 struct breakpoint *b;
2485 struct symtab_and_line sal;
2486 struct expression *exp;
2487 struct block *exp_valid_block;
2488 struct value *val, *mark;
2489 struct frame_info *frame, *prev_frame;
2490 char *exp_start = NULL;
2491 char *exp_end = NULL;
2492 char *tok, *end_tok;
2494 char *cond_start = NULL;
2495 char *cond_end = NULL;
2496 struct expression *cond = NULL;
2497 int i, other_type_used, target_resources_ok;
2498 enum bptype bp_type;
2505 /* Parse arguments. */
2506 innermost_block = NULL;
2508 exp = parse_exp_1 (&arg, 0, 0);
2510 exp_valid_block = innermost_block;
2511 mark = value_mark ();
2512 val = evaluate_expression (exp);
2513 release_value (val);
2514 if (VALUE_LAZY (val))
2515 value_fetch_lazy (val);
2518 while (*tok == ' ' || *tok == '\t')
2522 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2525 toklen = end_tok - tok;
2526 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2528 tok = cond_start = end_tok + 1;
2529 cond = parse_exp_1 (&tok, 0, 0);
2533 error("Junk at end of command.");
2535 if (accessflag == 1) bp_type = bp_read_watchpoint;
2536 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2537 else bp_type = bp_hardware_watchpoint;
2539 mem_cnt = can_use_hardware_watchpoint (val);
2540 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2541 error ("Expression cannot be implemented with read/access watchpoint.");
2543 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2544 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2545 bp_type, i + mem_cnt, other_type_used);
2546 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2547 error ("Target does not have this type of hardware watchpoint support.");
2548 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2549 error ("Target resources have been allocated for other types of watchpoints.");
2552 /* Now set up the breakpoint. */
2553 b = set_raw_breakpoint (sal);
2554 set_breakpoint_count (breakpoint_count + 1);
2555 b->number = breakpoint_count;
2556 b->disposition = donttouch;
2558 b->exp_valid_block = exp_valid_block;
2559 b->exp_string = savestring (exp_start, exp_end - exp_start);
2563 b->cond_string = savestring (cond_start, cond_end - cond_start);
2567 frame = block_innermost_frame (exp_valid_block);
2570 prev_frame = get_prev_frame (frame);
2571 b->watchpoint_frame = frame->frame;
2574 b->watchpoint_frame = (CORE_ADDR)0;
2576 if (mem_cnt && target_resources_ok > 0)
2579 b->type = bp_watchpoint;
2581 /* If the expression is "local", then set up a "watchpoint scope"
2582 breakpoint at the point where we've left the scope of the watchpoint
2584 if (innermost_block)
2586 struct breakpoint *scope_breakpoint;
2587 struct symtab_and_line scope_sal;
2591 scope_sal.pc = get_frame_pc (prev_frame);
2592 scope_sal.symtab = NULL;
2595 scope_breakpoint = set_raw_breakpoint (scope_sal);
2596 set_breakpoint_count (breakpoint_count + 1);
2597 scope_breakpoint->number = breakpoint_count;
2599 scope_breakpoint->type = bp_watchpoint_scope;
2600 scope_breakpoint->enable = enabled;
2602 /* Automatically delete the breakpoint when it hits. */
2603 scope_breakpoint->disposition = del;
2605 /* Only break in the proper frame (help with recursion). */
2606 scope_breakpoint->frame = prev_frame->frame;
2608 /* Set the address at which we will stop. */
2609 scope_breakpoint->address = get_frame_pc (prev_frame);
2611 /* The scope breakpoint is related to the watchpoint. We
2612 will need to act on them together. */
2613 b->related_breakpoint = scope_breakpoint;
2616 value_free_to_mark (mark);
2620 /* Return count of locations need to be watched and can be handled
2621 in hardware. If the watchpoint can not be handled
2622 in hardware return zero. */
2625 can_use_hardware_watchpoint (v)
2628 int found_memory_cnt = 0;
2630 /* Make sure all the intermediate values are in memory. Also make sure
2631 we found at least one memory expression. Guards against watch 0x12345,
2632 which is meaningless, but could cause errors if one tries to insert a
2633 hardware watchpoint for the constant expression. */
2634 for ( ; v; v = v->next)
2636 if (v->lval == lval_memory)
2638 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2641 else if (v->lval != not_lval && v->modifiable == 0)
2645 /* The expression itself looks suitable for using a hardware
2646 watchpoint, but give the target machine a chance to reject it. */
2647 return found_memory_cnt;
2650 static void watch_command (arg, from_tty)
2654 watch_command_1 (arg, 0, from_tty);
2657 static void rwatch_command (arg, from_tty)
2661 watch_command_1 (arg, 1, from_tty);
2664 static void awatch_command (arg, from_tty)
2668 watch_command_1 (arg, 2, from_tty);
2672 /* Helper routine for the until_command routine in infcmd.c. Here
2673 because it uses the mechanisms of breakpoints. */
2677 until_break_command (arg, from_tty)
2681 struct symtabs_and_lines sals;
2682 struct symtab_and_line sal;
2683 struct frame_info *prev_frame = get_prev_frame (selected_frame);
2684 struct breakpoint *breakpoint;
2685 struct cleanup *old_chain;
2687 clear_proceed_status ();
2689 /* Set a breakpoint where the user wants it and at return from
2692 if (default_breakpoint_valid)
2693 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2694 default_breakpoint_line, (char ***)NULL);
2696 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2698 if (sals.nelts != 1)
2699 error ("Couldn't get information on specified line.");
2702 free ((PTR)sals.sals); /* malloc'd, so freed */
2705 error ("Junk at end of arguments.");
2707 resolve_sal_pc (&sal);
2709 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2711 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2713 /* Keep within the current frame */
2717 sal = find_pc_line (prev_frame->pc, 0);
2718 sal.pc = prev_frame->pc;
2719 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2720 make_cleanup(delete_breakpoint, breakpoint);
2723 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2724 do_cleanups(old_chain);
2728 /* These aren't used; I don't konw what they were for. */
2729 /* Set a breakpoint at the catch clause for NAME. */
2731 catch_breakpoint (name)
2737 disable_catch_breakpoint ()
2742 delete_catch_breakpoint ()
2747 enable_catch_breakpoint ()
2754 struct sal_chain *next;
2755 struct symtab_and_line sal;
2759 /* This isn't used; I don't know what it was for. */
2760 /* For each catch clause identified in ARGS, run FUNCTION
2761 with that clause as an argument. */
2762 static struct symtabs_and_lines
2763 map_catch_names (args, function)
2767 register char *p = args;
2769 struct symtabs_and_lines sals;
2771 struct sal_chain *sal_chain = 0;
2775 error_no_arg ("one or more catch names");
2783 /* Don't swallow conditional part. */
2784 if (p1[0] == 'i' && p1[1] == 'f'
2785 && (p1[2] == ' ' || p1[2] == '\t'))
2791 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2795 if (*p1 && *p1 != ' ' && *p1 != '\t')
2796 error ("Arguments must be catch names.");
2802 struct sal_chain *next
2803 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2804 next->next = sal_chain;
2805 next->sal = get_catch_sal (p);
2810 printf_unfiltered ("No catch clause for exception %s.\n", p);
2815 while (*p == ' ' || *p == '\t') p++;
2820 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2822 static struct symtabs_and_lines
2823 get_catch_sals (this_level_only)
2824 int this_level_only;
2826 register struct blockvector *bl;
2827 register struct block *block;
2828 int index, have_default = 0;
2830 struct symtabs_and_lines sals;
2831 struct sal_chain *sal_chain = 0;
2832 char *blocks_searched;
2834 /* Not sure whether an error message is always the correct response,
2835 but it's better than a core dump. */
2836 if (selected_frame == NULL)
2837 error ("No selected frame.");
2838 block = get_frame_block (selected_frame);
2839 pc = selected_frame->pc;
2845 error ("No symbol table info available.\n");
2847 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2848 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2849 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2853 CORE_ADDR end = BLOCK_END (block) - 4;
2856 if (bl != blockvector_for_pc (end, &index))
2857 error ("blockvector blotch");
2858 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2859 error ("blockvector botch");
2860 last_index = BLOCKVECTOR_NBLOCKS (bl);
2863 /* Don't print out blocks that have gone by. */
2864 while (index < last_index
2865 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2868 while (index < last_index
2869 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2871 if (blocks_searched[index] == 0)
2873 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2876 register struct symbol *sym;
2878 nsyms = BLOCK_NSYMS (b);
2880 for (i = 0; i < nsyms; i++)
2882 sym = BLOCK_SYM (b, i);
2883 if (STREQ (SYMBOL_NAME (sym), "default"))
2889 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2891 struct sal_chain *next = (struct sal_chain *)
2892 alloca (sizeof (struct sal_chain));
2893 next->next = sal_chain;
2894 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2898 blocks_searched[index] = 1;
2904 if (sal_chain && this_level_only)
2907 /* After handling the function's top-level block, stop.
2908 Don't continue to its superblock, the block of
2909 per-file symbols. */
2910 if (BLOCK_FUNCTION (block))
2912 block = BLOCK_SUPERBLOCK (block);
2917 struct sal_chain *tmp_chain;
2919 /* Count the number of entries. */
2920 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2921 tmp_chain = tmp_chain->next)
2925 sals.sals = (struct symtab_and_line *)
2926 xmalloc (index * sizeof (struct symtab_and_line));
2927 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2928 sals.sals[index] = sal_chain->sal;
2934 /* Commands to deal with catching exceptions. */
2937 catch_command_1 (arg, tempflag, from_tty)
2942 /* First, translate ARG into something we can deal with in terms
2945 struct symtabs_and_lines sals;
2946 struct symtab_and_line sal;
2947 register struct expression *cond = 0;
2948 register struct breakpoint *b;
2952 sal.line = sal.pc = sal.end = 0;
2955 /* If no arg given, or if first arg is 'if ', all active catch clauses
2956 are breakpointed. */
2958 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2959 && (arg[2] == ' ' || arg[2] == '\t')))
2961 /* Grab all active catch clauses. */
2962 sals = get_catch_sals (0);
2966 /* Grab selected catch clauses. */
2967 error ("catch NAME not implemented");
2969 /* This isn't used; I don't know what it was for. */
2970 sals = map_catch_names (arg, catch_breakpoint);
2978 for (i = 0; i < sals.nelts; i++)
2980 resolve_sal_pc (&sals.sals[i]);
2984 if (arg[0] == 'i' && arg[1] == 'f'
2985 && (arg[2] == ' ' || arg[2] == '\t'))
2986 cond = parse_exp_1 ((arg += 2, &arg),
2987 block_for_pc (sals.sals[i].pc), 0);
2989 error ("Junk at end of arguments.");
2994 for (i = 0; i < sals.nelts; i++)
2999 describe_other_breakpoints (sal.pc);
3001 b = set_raw_breakpoint (sal);
3002 set_breakpoint_count (breakpoint_count + 1);
3003 b->number = breakpoint_count;
3004 b->type = bp_breakpoint;
3006 b->enable = enabled;
3007 b->disposition = tempflag ? del : donttouch;
3014 printf_unfiltered ("Multiple breakpoints were set.\n");
3015 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3017 free ((PTR)sals.sals);
3020 /* Used by the gui, could be made a worker for other things. */
3023 set_breakpoint_sal (sal)
3024 struct symtab_and_line sal;
3026 struct breakpoint *b;
3027 b = set_raw_breakpoint (sal);
3028 set_breakpoint_count (breakpoint_count + 1);
3029 b->number = breakpoint_count;
3030 b->type = bp_breakpoint;
3037 /* These aren't used; I don't know what they were for. */
3038 /* Disable breakpoints on all catch clauses described in ARGS. */
3040 disable_catch (args)
3043 /* Map the disable command to catch clauses described in ARGS. */
3046 /* Enable breakpoints on all catch clauses described in ARGS. */
3051 /* Map the disable command to catch clauses described in ARGS. */
3054 /* Delete breakpoints on all catch clauses in the active scope. */
3059 /* Map the delete command to catch clauses described in ARGS. */
3064 catch_command (arg, from_tty)
3068 catch_command_1 (arg, 0, from_tty);
3072 clear_command (arg, from_tty)
3076 register struct breakpoint *b, *b1;
3077 struct symtabs_and_lines sals;
3078 struct symtab_and_line sal;
3079 register struct breakpoint *found;
3084 sals = decode_line_spec (arg, 1);
3088 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3089 sal.line = default_breakpoint_line;
3090 sal.symtab = default_breakpoint_symtab;
3092 if (sal.symtab == 0)
3093 error ("No source file specified.");
3099 for (i = 0; i < sals.nelts; i++)
3101 /* If exact pc given, clear bpts at that pc.
3102 But if sal.pc is zero, clear all bpts on specified line. */
3104 found = (struct breakpoint *) 0;
3105 while (breakpoint_chain
3107 ? breakpoint_chain->address == sal.pc
3108 : (breakpoint_chain->source_file != NULL
3109 && sal.symtab != NULL
3110 && STREQ (breakpoint_chain->source_file,
3111 sal.symtab->filename)
3112 && breakpoint_chain->line_number == sal.line)))
3114 b1 = breakpoint_chain;
3115 breakpoint_chain = b1->next;
3122 && b->next->type != bp_watchpoint
3123 && b->next->type != bp_hardware_watchpoint
3124 && b->next->type != bp_read_watchpoint
3125 && b->next->type != bp_access_watchpoint
3127 ? b->next->address == sal.pc
3128 : (b->next->source_file != NULL
3129 && sal.symtab != NULL
3130 && STREQ (b->next->source_file, sal.symtab->filename)
3131 && b->next->line_number == sal.line)))
3142 error ("No breakpoint at %s.", arg);
3144 error ("No breakpoint at this line.");
3147 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3148 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3149 breakpoints_changed ();
3152 if (from_tty) printf_unfiltered ("%d ", found->number);
3154 delete_breakpoint (found);
3157 if (from_tty) putchar_unfiltered ('\n');
3159 free ((PTR)sals.sals);
3162 /* Delete breakpoint in BS if they are `delete' breakpoints.
3163 This is called after any breakpoint is hit, or after errors. */
3166 breakpoint_auto_delete (bs)
3169 for (; bs; bs = bs->next)
3170 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
3172 delete_breakpoint (bs->breakpoint_at);
3175 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3178 delete_breakpoint (bpt)
3179 struct breakpoint *bpt;
3181 register struct breakpoint *b;
3184 if (delete_breakpoint_hook)
3185 delete_breakpoint_hook (bpt);
3188 remove_breakpoint (bpt);
3190 if (breakpoint_chain == bpt)
3191 breakpoint_chain = bpt->next;
3196 b->next = bpt->next;
3200 check_duplicates (bpt->address);
3201 /* If this breakpoint was inserted, and there is another breakpoint
3202 at the same address, we need to insert the other breakpoint. */
3204 && bpt->type != bp_hardware_watchpoint
3205 && bpt->type != bp_read_watchpoint
3206 && bpt->type != bp_access_watchpoint)
3209 if (b->address == bpt->address
3211 && b->enable != disabled)
3214 val = target_insert_breakpoint (b->address, b->shadow_contents);
3217 target_terminal_ours_for_output ();
3218 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3219 memory_error (val, b->address); /* which bombs us out */
3226 free_command_lines (&bpt->commands);
3229 if (bpt->cond_string != NULL)
3230 free (bpt->cond_string);
3231 if (bpt->addr_string != NULL)
3232 free (bpt->addr_string);
3233 if (bpt->exp_string != NULL)
3234 free (bpt->exp_string);
3235 if (bpt->source_file != NULL)
3236 free (bpt->source_file);
3238 /* Be sure no bpstat's are pointing at it after it's been freed. */
3239 /* FIXME, how can we find all bpstat's?
3240 We just check stop_bpstat for now. */
3241 for (bs = stop_bpstat; bs; bs = bs->next)
3242 if (bs->breakpoint_at == bpt)
3243 bs->breakpoint_at = NULL;
3248 delete_command (arg, from_tty)
3255 /* Ask user only if there are some breakpoints to delete. */
3257 || (breakpoint_chain && query ("Delete all breakpoints? ")))
3259 /* No arg; clear all breakpoints. */
3260 while (breakpoint_chain)
3261 delete_breakpoint (breakpoint_chain);
3265 map_breakpoint_numbers (arg, delete_breakpoint);
3268 /* Reset a breakpoint given it's struct breakpoint * BINT.
3269 The value we return ends up being the return value from catch_errors.
3270 Unused in this case. */
3273 breakpoint_re_set_one (bint)
3276 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3279 struct symtabs_and_lines sals;
3281 enum enable save_enable;
3286 case bp_hardware_breakpoint:
3287 if (b->addr_string == NULL)
3289 /* Anything without a string can't be re-set. */
3290 delete_breakpoint (b);
3293 /* In case we have a problem, disable this breakpoint. We'll restore
3294 its status if we succeed. */
3295 save_enable = b->enable;
3296 b->enable = disabled;
3298 set_language (b->language);
3299 input_radix = b->input_radix;
3301 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3302 for (i = 0; i < sals.nelts; i++)
3304 resolve_sal_pc (&sals.sals[i]);
3306 /* Reparse conditions, they might contain references to the
3308 if (b->cond_string != NULL)
3312 free ((PTR)b->cond);
3313 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3316 /* We need to re-set the breakpoint if the address changes...*/
3317 if (b->address != sals.sals[i].pc
3318 /* ...or new and old breakpoints both have source files, and
3319 the source file name or the line number changes... */
3320 || (b->source_file != NULL
3321 && sals.sals[i].symtab != NULL
3322 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3323 || b->line_number != sals.sals[i].line)
3325 /* ...or we switch between having a source file and not having
3327 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3330 if (b->source_file != NULL)
3331 free (b->source_file);
3332 if (sals.sals[i].symtab == NULL)
3333 b->source_file = NULL;
3336 savestring (sals.sals[i].symtab->filename,
3337 strlen (sals.sals[i].symtab->filename));
3338 b->line_number = sals.sals[i].line;
3339 b->address = sals.sals[i].pc;
3341 check_duplicates (b->address);
3345 /* Might be better to do this just once per breakpoint_re_set,
3346 rather than once for every breakpoint. */
3347 breakpoints_changed ();
3349 b->enable = save_enable; /* Restore it, this worked. */
3351 free ((PTR)sals.sals);
3355 case bp_hardware_watchpoint:
3356 case bp_read_watchpoint:
3357 case bp_access_watchpoint:
3358 innermost_block = NULL;
3359 /* The issue arises of what context to evaluate this in. The same
3360 one as when it was set, but what does that mean when symbols have
3361 been re-read? We could save the filename and functionname, but
3362 if the context is more local than that, the best we could do would
3363 be something like how many levels deep and which index at that
3364 particular level, but that's going to be less stable than filenames
3365 or functionnames. */
3366 /* So for now, just use a global context. */
3367 b->exp = parse_expression (b->exp_string);
3368 b->exp_valid_block = innermost_block;
3369 mark = value_mark ();
3370 b->val = evaluate_expression (b->exp);
3371 release_value (b->val);
3372 if (VALUE_LAZY (b->val))
3373 value_fetch_lazy (b->val);
3375 if (b->cond_string != NULL)
3378 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3380 if (b->enable == enabled)
3382 value_free_to_mark (mark);
3386 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3391 case bp_longjmp_resume:
3392 case bp_watchpoint_scope:
3394 delete_breakpoint (b);
3401 /* Re-set all breakpoints after symbols have been re-loaded. */
3403 breakpoint_re_set ()
3405 struct breakpoint *b, *temp;
3406 enum language save_language;
3407 int save_input_radix;
3408 static char message1[] = "Error in re-setting breakpoint %d:\n";
3409 char message[sizeof (message1) + 30 /* slop */];
3411 save_language = current_language->la_language;
3412 save_input_radix = input_radix;
3413 ALL_BREAKPOINTS_SAFE (b, temp)
3415 sprintf (message, message1, b->number); /* Format possible error msg */
3416 catch_errors (breakpoint_re_set_one, (char *) b, message,
3419 set_language (save_language);
3420 input_radix = save_input_radix;
3422 #ifdef GET_LONGJMP_TARGET
3423 create_longjmp_breakpoint ("longjmp");
3424 create_longjmp_breakpoint ("_longjmp");
3425 create_longjmp_breakpoint ("siglongjmp");
3426 create_longjmp_breakpoint (NULL);
3430 /* Took this out (temporaliy at least), since it produces an extra
3431 blank line at startup. This messes up the gdbtests. -PB */
3432 /* Blank line to finish off all those mention() messages we just printed. */
3433 printf_filtered ("\n");
3437 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3438 If from_tty is nonzero, it prints a message to that effect,
3439 which ends with a period (no newline). */
3442 set_ignore_count (bptnum, count, from_tty)
3443 int bptnum, count, from_tty;
3445 register struct breakpoint *b;
3451 if (b->number == bptnum)
3453 b->ignore_count = count;
3456 else if (count == 0)
3457 printf_filtered ("Will stop next time breakpoint %d is reached.",
3459 else if (count == 1)
3460 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3463 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3465 breakpoints_changed ();
3469 error ("No breakpoint number %d.", bptnum);
3472 /* Clear the ignore counts of all breakpoints. */
3474 breakpoint_clear_ignore_counts ()
3476 struct breakpoint *b;
3479 b->ignore_count = 0;
3482 /* Command to set ignore-count of breakpoint N to COUNT. */
3485 ignore_command (args, from_tty)
3493 error_no_arg ("a breakpoint number");
3495 num = get_number (&p);
3498 error ("Second argument (specified ignore-count) is missing.");
3500 set_ignore_count (num,
3501 longest_to_int (value_as_long (parse_and_eval (p))),
3503 printf_filtered ("\n");
3504 breakpoints_changed ();
3507 /* Call FUNCTION on each of the breakpoints
3508 whose numbers are given in ARGS. */
3511 map_breakpoint_numbers (args, function)
3513 void (*function) PARAMS ((struct breakpoint *));
3515 register char *p = args;
3518 register struct breakpoint *b;
3521 error_no_arg ("one or more breakpoint numbers");
3527 num = get_number (&p1);
3530 if (b->number == num)
3532 struct breakpoint *related_breakpoint = b->related_breakpoint;
3534 if (related_breakpoint)
3535 function (related_breakpoint);
3538 printf_unfiltered ("No breakpoint number %d.\n", num);
3545 enable_breakpoint (bpt)
3546 struct breakpoint *bpt;
3548 struct frame_info *save_selected_frame = NULL;
3549 int save_selected_frame_level = -1;
3550 int target_resources_ok, other_type_used;
3553 if (bpt->type == bp_hardware_breakpoint)
3556 i = hw_breakpoint_used_count();
3557 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3558 bp_hardware_breakpoint, i+1, 0);
3559 if (target_resources_ok == 0)
3560 error ("No hardware breakpoint support in the target.");
3561 else if (target_resources_ok < 0)
3562 error ("Hardware breakpoints used exceeds limit.");
3564 bpt->enable = enabled;
3565 check_duplicates (bpt->address);
3567 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3568 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3570 if (bpt->exp_valid_block != NULL)
3572 struct frame_info *fr =
3573 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3577 Cannot enable watchpoint %d because the block in which its expression\n\
3578 is valid is not currently in scope.\n", bpt->number);
3579 bpt->enable = disabled;
3583 save_selected_frame = selected_frame;
3584 save_selected_frame_level = selected_frame_level;
3585 select_frame (fr, -1);
3588 value_free (bpt->val);
3589 mark = value_mark ();
3590 bpt->val = evaluate_expression (bpt->exp);
3591 release_value (bpt->val);
3592 if (VALUE_LAZY (bpt->val))
3593 value_fetch_lazy (bpt->val);
3595 if (bpt->type == bp_hardware_watchpoint ||
3596 bpt->type == bp_read_watchpoint ||
3597 bpt->type == bp_access_watchpoint)
3599 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3600 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
3602 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3603 bpt->type, i + mem_cnt, other_type_used);
3604 /* we can consider of type is bp_hardware_watchpoint, convert to
3605 bp_watchpoint in the following condition */
3606 if (target_resources_ok < 0)
3609 Cannot enable watchpoint %d because target watch resources\n\
3610 have been allocated for other watchpoints.\n", bpt->number);
3611 bpt->enable = disabled;
3612 value_free_to_mark (mark);
3617 if (save_selected_frame_level >= 0)
3618 select_frame (save_selected_frame, save_selected_frame_level);
3619 value_free_to_mark (mark);
3622 if (modify_breakpoint_hook)
3623 modify_breakpoint_hook (bpt);
3628 enable_command (args, from_tty)
3632 struct breakpoint *bpt;
3634 ALL_BREAKPOINTS (bpt)
3638 case bp_hardware_breakpoint:
3640 case bp_hardware_watchpoint:
3641 case bp_read_watchpoint:
3642 case bp_access_watchpoint:
3643 enable_breakpoint (bpt);
3648 map_breakpoint_numbers (args, enable_breakpoint);
3652 disable_breakpoint (bpt)
3653 struct breakpoint *bpt;
3655 /* Never disable a watchpoint scope breakpoint; we want to
3656 hit them when we leave scope so we can delete both the
3657 watchpoint and its scope breakpoint at that time. */
3658 if (bpt->type == bp_watchpoint_scope)
3661 bpt->enable = disabled;
3663 check_duplicates (bpt->address);
3665 if (modify_breakpoint_hook)
3666 modify_breakpoint_hook (bpt);
3671 disable_command (args, from_tty)
3675 register struct breakpoint *bpt;
3677 ALL_BREAKPOINTS (bpt)
3681 case bp_hardware_breakpoint:
3683 case bp_hardware_watchpoint:
3684 case bp_read_watchpoint:
3685 case bp_access_watchpoint:
3686 disable_breakpoint (bpt);
3691 map_breakpoint_numbers (args, disable_breakpoint);
3695 enable_once_breakpoint (bpt)
3696 struct breakpoint *bpt;
3698 struct frame_info *save_selected_frame = NULL;
3699 int save_selected_frame_level = -1;
3700 int target_resources_ok, other_type_used;
3703 if (bpt->type == bp_hardware_breakpoint)
3706 i = hw_breakpoint_used_count();
3707 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3708 bp_hardware_breakpoint, i+1, 0);
3709 if (target_resources_ok == 0)
3710 error ("No hardware breakpoint support in the target.");
3711 else if (target_resources_ok < 0)
3712 error ("Hardware breakpoints used exceeds limit.");
3715 bpt->enable = enabled;
3716 bpt->disposition = disable;
3717 check_duplicates (bpt->address);
3718 breakpoints_changed ();
3720 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3721 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3723 if (bpt->exp_valid_block != NULL)
3725 struct frame_info *fr =
3726 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3730 Cannot enable watchpoint %d because the block in which its expression\n\
3731 is valid is not currently in scope.\n", bpt->number);
3732 bpt->enable = disabled;
3736 save_selected_frame = selected_frame;
3737 save_selected_frame_level = selected_frame_level;
3738 select_frame (fr, -1);
3741 value_free (bpt->val);
3742 mark = value_mark ();
3743 bpt->val = evaluate_expression (bpt->exp);
3744 release_value (bpt->val);
3745 if (VALUE_LAZY (bpt->val))
3746 value_fetch_lazy (bpt->val);
3748 if (bpt->type == bp_hardware_watchpoint ||
3749 bpt->type == bp_read_watchpoint ||
3750 bpt->type == bp_access_watchpoint)
3752 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3753 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3754 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3755 bpt->type, i+mem_cnt, other_type_used);
3756 /* we can consider of type is bp_hardware_watchpoint, convert to
3757 bp_watchpoint in the following condition */
3758 if (target_resources_ok < 0)
3761 Cannot enable watchpoint %d because target watch resources\n\
3762 have been allocated for other watchpoints.\n", bpt->number);
3763 bpt->enable = disabled;
3764 value_free_to_mark (mark);
3768 if (save_selected_frame_level >= 0)
3769 select_frame (save_selected_frame, save_selected_frame_level);
3770 value_free_to_mark (mark);
3776 enable_once_command (args, from_tty)
3780 map_breakpoint_numbers (args, enable_once_breakpoint);
3784 enable_delete_breakpoint (bpt)
3785 struct breakpoint *bpt;
3787 bpt->enable = enabled;
3788 bpt->disposition = del;
3790 check_duplicates (bpt->address);
3791 breakpoints_changed ();
3796 enable_delete_command (args, from_tty)
3800 map_breakpoint_numbers (args, enable_delete_breakpoint);
3803 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
3805 struct symtabs_and_lines
3806 decode_line_spec_1 (string, funfirstline)
3810 struct symtabs_and_lines sals;
3812 error ("Empty line specification.");
3813 if (default_breakpoint_valid)
3814 sals = decode_line_1 (&string, funfirstline,
3815 default_breakpoint_symtab, default_breakpoint_line,
3818 sals = decode_line_1 (&string, funfirstline,
3819 (struct symtab *)NULL, 0, (char ***)NULL);
3821 error ("Junk at end of line specification: %s", string);
3826 _initialize_breakpoint ()
3828 breakpoint_chain = 0;
3829 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3830 before a breakpoint is set. */
3831 breakpoint_count = 0;
3833 add_com ("ignore", class_breakpoint, ignore_command,
3834 "Set ignore-count of breakpoint number N to COUNT.\n\
3835 Usage is `ignore N COUNT'.");
3837 add_com ("commands", class_breakpoint, commands_command,
3838 "Set commands to be executed when a breakpoint is hit.\n\
3839 Give breakpoint number as argument after \"commands\".\n\
3840 With no argument, the targeted breakpoint is the last one set.\n\
3841 The commands themselves follow starting on the next line.\n\
3842 Type a line containing \"end\" to indicate the end of them.\n\
3843 Give \"silent\" as the first line to make the breakpoint silent;\n\
3844 then no output is printed when it is hit, except what the commands print.");
3846 add_com ("condition", class_breakpoint, condition_command,
3847 "Specify breakpoint number N to break only if COND is true.\n\
3848 Usage is `condition N COND', where N is an integer and COND is an\n\
3849 expression to be evaluated whenever breakpoint N is reached. ");
3851 add_com ("tbreak", class_breakpoint, tbreak_command,
3852 "Set a temporary breakpoint. Args like \"break\" command.\n\
3853 Like \"break\" except the breakpoint is only temporary,\n\
3854 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3855 by using \"enable delete\" on the breakpoint number.");
3857 add_com ("hbreak", class_breakpoint, hbreak_command,
3858 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3859 Like \"break\" except the breakpoint requires hardware support,\n\
3860 some target hardware may not have this support.");
3862 add_com ("thbreak", class_breakpoint, thbreak_command,
3863 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3864 Like \"hbreak\" except the breakpoint is only temporary,\n\
3865 so it will be deleted when hit.");
3867 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3868 "Enable some breakpoints.\n\
3869 Give breakpoint numbers (separated by spaces) as arguments.\n\
3870 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3871 This is used to cancel the effect of the \"disable\" command.\n\
3872 With a subcommand you can enable temporarily.",
3873 &enablelist, "enable ", 1, &cmdlist);
3875 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3876 "Enable some breakpoints.\n\
3877 Give breakpoint numbers (separated by spaces) as arguments.\n\
3878 This is used to cancel the effect of the \"disable\" command.\n\
3879 May be abbreviated to simply \"enable\".\n",
3880 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3882 add_cmd ("once", no_class, enable_once_command,
3883 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3884 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3887 add_cmd ("delete", no_class, enable_delete_command,
3888 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3889 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3892 add_cmd ("delete", no_class, enable_delete_command,
3893 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3894 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3897 add_cmd ("once", no_class, enable_once_command,
3898 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3899 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3902 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3903 "Disable some breakpoints.\n\
3904 Arguments are breakpoint numbers with spaces in between.\n\
3905 To disable all breakpoints, give no argument.\n\
3906 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3907 &disablelist, "disable ", 1, &cmdlist);
3908 add_com_alias ("dis", "disable", class_breakpoint, 1);
3909 add_com_alias ("disa", "disable", class_breakpoint, 1);
3911 add_cmd ("breakpoints", class_alias, disable_command,
3912 "Disable some breakpoints.\n\
3913 Arguments are breakpoint numbers with spaces in between.\n\
3914 To disable all breakpoints, give no argument.\n\
3915 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3916 This command may be abbreviated \"disable\".",
3919 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3920 "Delete some breakpoints or auto-display expressions.\n\
3921 Arguments are breakpoint numbers with spaces in between.\n\
3922 To delete all breakpoints, give no argument.\n\
3924 Also a prefix command for deletion of other GDB objects.\n\
3925 The \"unset\" command is also an alias for \"delete\".",
3926 &deletelist, "delete ", 1, &cmdlist);
3927 add_com_alias ("d", "delete", class_breakpoint, 1);
3929 add_cmd ("breakpoints", class_alias, delete_command,
3930 "Delete some breakpoints or auto-display expressions.\n\
3931 Arguments are breakpoint numbers with spaces in between.\n\
3932 To delete all breakpoints, give no argument.\n\
3933 This command may be abbreviated \"delete\".",
3936 add_com ("clear", class_breakpoint, clear_command,
3937 concat ("Clear breakpoint at specified line or function.\n\
3938 Argument may be line number, function name, or \"*\" and an address.\n\
3939 If line number is specified, all breakpoints in that line are cleared.\n\
3940 If function is specified, breakpoints at beginning of function are cleared.\n\
3941 If an address is specified, breakpoints at that address are cleared.\n\n",
3942 "With no argument, clears all breakpoints in the line that the selected frame\n\
3945 See also the \"delete\" command which clears breakpoints by number.", NULL));
3947 add_com ("break", class_breakpoint, break_command,
3948 concat ("Set breakpoint at specified line or function.\n\
3949 Argument may be line number, function name, or \"*\" and an address.\n\
3950 If line number is specified, break at start of code for that line.\n\
3951 If function is specified, break at start of code for that function.\n\
3952 If an address is specified, break at that exact address.\n",
3953 "With no arg, uses current execution address of selected stack frame.\n\
3954 This is useful for breaking on return to a stack frame.\n\
3956 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3958 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
3959 add_com_alias ("b", "break", class_run, 1);
3960 add_com_alias ("br", "break", class_run, 1);
3961 add_com_alias ("bre", "break", class_run, 1);
3962 add_com_alias ("brea", "break", class_run, 1);
3964 add_info ("breakpoints", breakpoints_info,
3965 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3966 The \"Type\" column indicates one of:\n\
3967 \tbreakpoint - normal breakpoint\n\
3968 \twatchpoint - watchpoint\n\
3969 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3970 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3971 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3972 address and file/line number respectively.\n\n",
3973 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3974 are set to the address of the last breakpoint listed.\n\n\
3975 Convenience variable \"$bpnum\" contains the number of the last\n\
3976 breakpoint set.", NULL));
3978 #if MAINTENANCE_CMDS
3980 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3981 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
3982 The \"Type\" column indicates one of:\n\
3983 \tbreakpoint - normal breakpoint\n\
3984 \twatchpoint - watchpoint\n\
3985 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3986 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3987 \tuntil - internal breakpoint used by the \"until\" command\n\
3988 \tfinish - internal breakpoint used by the \"finish\" command\n",
3989 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3990 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3991 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3992 address and file/line number respectively.\n\n",
3993 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3994 are set to the address of the last breakpoint listed.\n\n\
3995 Convenience variable \"$bpnum\" contains the number of the last\n\
3996 breakpoint set.", NULL),
3997 &maintenanceinfolist);
3999 #endif /* MAINTENANCE_CMDS */
4001 add_com ("catch", class_breakpoint, catch_command,
4002 "Set breakpoints to catch exceptions that are raised.\n\
4003 Argument may be a single exception to catch, multiple exceptions\n\
4004 to catch, or the default exception \"default\". If no arguments\n\
4005 are given, breakpoints are set at all exception handlers catch clauses\n\
4006 within the current scope.\n\
4008 A condition specified for the catch applies to all breakpoints set\n\
4009 with this command\n\
4011 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
4013 add_com ("watch", class_breakpoint, watch_command,
4014 "Set a watchpoint for an expression.\n\
4015 A watchpoint stops execution of your program whenever the value of\n\
4016 an expression changes.");
4018 add_com ("rwatch", class_breakpoint, rwatch_command,
4019 "Set a read watchpoint for an expression.\n\
4020 A watchpoint stops execution of your program whenever the value of\n\
4021 an expression is read.");
4023 add_com ("awatch", class_breakpoint, awatch_command,
4024 "Set a watchpoint for an expression.\n\
4025 A watchpoint stops execution of your program whenever the value of\n\
4026 an expression is either read or written.");
4028 add_info ("watchpoints", breakpoints_info,
4029 "Synonym for ``info breakpoints''.");