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., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "breakpoint.h"
27 #include "expression.h"
37 #include "gdb_string.h"
41 /* local function prototypes */
44 catch_command_1 PARAMS ((char *, int, int));
47 enable_delete_command PARAMS ((char *, int));
50 enable_delete_breakpoint PARAMS ((struct breakpoint *));
53 enable_once_command PARAMS ((char *, int));
56 enable_once_breakpoint PARAMS ((struct breakpoint *));
59 disable_command PARAMS ((char *, int));
62 enable_command PARAMS ((char *, int));
65 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
68 ignore_command PARAMS ((char *, int));
71 breakpoint_re_set_one PARAMS ((char *));
74 delete_command PARAMS ((char *, int));
77 clear_command PARAMS ((char *, int));
80 catch_command PARAMS ((char *, 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 *));
100 static struct breakpoint *
101 set_raw_breakpoint PARAMS ((struct symtab_and_line));
104 check_duplicates PARAMS ((CORE_ADDR));
107 describe_other_breakpoints PARAMS ((CORE_ADDR));
110 breakpoints_info PARAMS ((char *, int));
113 breakpoint_1 PARAMS ((int, int));
116 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
119 breakpoint_cond_eval PARAMS ((char *));
122 cleanup_executing_breakpoints PARAMS ((int));
125 commands_command PARAMS ((char *, int));
128 condition_command PARAMS ((char *, int));
131 get_number PARAMS ((char **));
134 set_breakpoint_count PARAMS ((int));
137 remove_breakpoint PARAMS ((struct breakpoint *));
139 extern int addressprint; /* Print machine addresses? */
141 /* Are we executing breakpoint commands? */
142 static int executing_breakpoint_commands;
144 /* Walk the following statement or block through all breakpoints.
145 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
148 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
150 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
151 for (b = breakpoint_chain; \
152 b? (tmp=b->next, 1): 0; \
155 /* True if breakpoint hit counts should be displayed in breakpoint info. */
157 int show_breakpoint_hit_counts = 1;
159 /* Chain of all breakpoints defined. */
161 struct breakpoint *breakpoint_chain;
163 /* Number of last breakpoint made. */
165 static int breakpoint_count;
167 /* Set breakpoint count to NUM. */
170 set_breakpoint_count (num)
173 breakpoint_count = num;
174 set_internalvar (lookup_internalvar ("bpnum"),
175 value_from_longest (builtin_type_int, (LONGEST) num));
178 /* Used in run_command to zero the hit count when a new run starts. */
181 clear_breakpoint_hit_counts ()
183 struct breakpoint *b;
189 /* Default address, symtab and line to put a breakpoint at
190 for "break" command with no arg.
191 if default_breakpoint_valid is zero, the other three are
192 not valid, and "break" with no arg is an error.
194 This set by print_stack_frame, which calls set_default_breakpoint. */
196 int default_breakpoint_valid;
197 CORE_ADDR default_breakpoint_address;
198 struct symtab *default_breakpoint_symtab;
199 int default_breakpoint_line;
201 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
202 Advance *PP after the string and any trailing whitespace.
204 Currently the string can either be a number or "$" followed by the name
205 of a convenience variable. Making it an expression wouldn't work well
206 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
215 /* Empty line means refer to the last breakpoint. */
216 return breakpoint_count;
219 /* Make a copy of the name, so we can null-terminate it
220 to pass to lookup_internalvar(). */
225 while (isalnum (*p) || *p == '_')
227 varname = (char *) alloca (p - start + 1);
228 strncpy (varname, start, p - start);
229 varname[p - start] = '\0';
230 val = value_of_internalvar (lookup_internalvar (varname));
231 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
233 "Convenience variables used to specify breakpoints must have integer values."
235 retval = (int) value_as_long (val);
241 while (*p >= '0' && *p <= '9')
244 /* There is no number here. (e.g. "cond a == b"). */
245 error_no_arg ("breakpoint number");
248 if (!(isspace (*p) || *p == '\0'))
249 error ("breakpoint number expected");
256 /* condition N EXP -- set break condition of breakpoint N to EXP. */
259 condition_command (arg, from_tty)
263 register struct breakpoint *b;
268 error_no_arg ("breakpoint number");
271 bnum = get_number (&p);
274 if (b->number == bnum)
281 if (b->cond_string != NULL)
282 free ((PTR)b->cond_string);
287 b->cond_string = NULL;
289 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
294 /* I don't know if it matters whether this is the string the user
295 typed in or the decompiled expression. */
296 b->cond_string = savestring (arg, strlen (arg));
297 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
299 error ("Junk at end of expression");
301 breakpoints_changed ();
305 error ("No breakpoint number %d.", bnum);
310 commands_command (arg, from_tty)
314 register struct breakpoint *b;
317 struct command_line *l;
319 /* If we allowed this, we would have problems with when to
320 free the storage, if we change the commands currently
323 if (executing_breakpoint_commands)
324 error ("Can't use the \"commands\" command among a breakpoint's commands.");
327 bnum = get_number (&p);
329 error ("Unexpected extra arguments following breakpoint number.");
332 if (b->number == bnum)
334 if (from_tty && input_from_terminal_p ())
335 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
336 End with a line saying just \"end\".\n", bnum);
337 l = read_command_lines ();
338 free_command_lines (&b->commands);
340 breakpoints_changed ();
343 error ("No breakpoint number %d.", bnum);
346 extern int memory_breakpoint_size; /* from mem-break.c */
348 /* Like target_read_memory() but if breakpoints are inserted, return
349 the shadow contents instead of the breakpoints themselves.
351 Read "memory data" from whatever target or inferior we have.
352 Returns zero if successful, errno value if not. EIO is used
353 for address out of bounds. If breakpoints are inserted, returns
354 shadow contents, not the breakpoints themselves. From breakpoint.c. */
357 read_memory_nobpt (memaddr, myaddr, len)
363 struct breakpoint *b;
365 if (memory_breakpoint_size < 0)
366 /* No breakpoints on this machine. FIXME: This should be
367 dependent on the debugging target. Probably want
368 target_insert_breakpoint to return a size, saying how many
369 bytes of the shadow contents are used, or perhaps have
370 something like target_xfer_shadow. */
371 return target_read_memory (memaddr, myaddr, len);
375 if (b->type == bp_watchpoint
376 || b->type == bp_hardware_watchpoint
377 || b->type == bp_read_watchpoint
378 || b->type == bp_access_watchpoint
381 else if (b->address + memory_breakpoint_size <= memaddr)
382 /* The breakpoint is entirely before the chunk of memory
385 else if (b->address >= memaddr + len)
386 /* The breakpoint is entirely after the chunk of memory we
391 /* Copy the breakpoint from the shadow contents, and recurse
392 for the things before and after. */
394 /* Addresses and length of the part of the breakpoint that
396 CORE_ADDR membpt = b->address;
397 unsigned int bptlen = memory_breakpoint_size;
398 /* Offset within shadow_contents. */
401 if (membpt < memaddr)
403 /* Only copy the second part of the breakpoint. */
404 bptlen -= memaddr - membpt;
405 bptoffset = memaddr - membpt;
409 if (membpt + bptlen > memaddr + len)
411 /* Only copy the first part of the breakpoint. */
412 bptlen -= (membpt + bptlen) - (memaddr + len);
415 memcpy (myaddr + membpt - memaddr,
416 b->shadow_contents + bptoffset, bptlen);
418 if (membpt > memaddr)
420 /* Copy the section of memory before the breakpoint. */
421 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
426 if (membpt + bptlen < memaddr + len)
428 /* Copy the section of memory after the breakpoint. */
429 status = read_memory_nobpt
431 myaddr + membpt + bptlen - memaddr,
432 memaddr + len - (membpt + bptlen));
439 /* Nothing overlaps. Just call read_memory_noerr. */
440 return target_read_memory (memaddr, myaddr, len);
443 /* insert_breakpoints is used when starting or continuing the program.
444 remove_breakpoints is used when the program stops.
445 Both return zero if successful,
446 or an `errno' value if could not write the inferior. */
449 insert_breakpoints ()
451 register struct breakpoint *b;
453 int disabled_breaks = 0;
456 if (b->type != bp_watchpoint
457 && b->type != bp_hardware_watchpoint
458 && b->type != bp_read_watchpoint
459 && b->type != bp_access_watchpoint
460 && b->enable != disabled
464 if (b->type == bp_hardware_breakpoint)
465 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
467 val = target_insert_breakpoint(b->address, b->shadow_contents);
470 /* Can't set the breakpoint. */
471 #if defined (DISABLE_UNSETTABLE_BREAK)
472 if (DISABLE_UNSETTABLE_BREAK (b->address))
475 b->enable = disabled;
476 if (!disabled_breaks)
478 target_terminal_ours_for_output ();
479 fprintf_unfiltered (gdb_stderr,
480 "Cannot insert breakpoint %d:\n", b->number);
481 printf_filtered ("Disabling shared library breakpoints:\n");
484 printf_filtered ("%d ", b->number);
489 target_terminal_ours_for_output ();
490 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
491 #ifdef ONE_PROCESS_WRITETEXT
492 fprintf_unfiltered (gdb_stderr,
493 "The same program may be running in another process.\n");
495 memory_error (val, b->address); /* which bombs us out */
501 else if ((b->type == bp_hardware_watchpoint ||
502 b->type == bp_read_watchpoint ||
503 b->type == bp_access_watchpoint)
504 && b->enable == enabled
508 struct frame_info *saved_frame;
509 int saved_level, within_current_scope;
510 value_ptr mark = value_mark ();
513 /* Save the current frame and level so we can restore it after
514 evaluating the watchpoint expression on its own frame. */
515 saved_frame = selected_frame;
516 saved_level = selected_frame_level;
518 /* Determine if the watchpoint is within scope. */
519 if (b->exp_valid_block == NULL)
520 within_current_scope = 1;
523 struct frame_info *fi =
524 find_frame_addr_in_frame_chain (b->watchpoint_frame);
525 within_current_scope = (fi != NULL);
526 if (within_current_scope)
527 select_frame (fi, -1);
530 if (within_current_scope)
532 /* Evaluate the expression and cut the chain of values
533 produced off from the value chain. */
534 v = evaluate_expression (b->exp);
535 value_release_to_mark (mark);
540 /* Look at each value on the value chain. */
541 for ( ; v; v=v->next)
543 /* If it's a memory location, then we must watch it. */
544 if (v->lval == lval_memory)
548 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
549 len = TYPE_LENGTH (VALUE_TYPE (v));
551 if (b->type == bp_read_watchpoint)
553 else if (b->type == bp_access_watchpoint)
556 val = target_insert_watchpoint (addr, len, type);
565 /* Failure to insert a watchpoint on any memory value in the
566 value chain brings us here. */
568 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
574 Hardware watchpoint %d deleted because the program has left the block in\n\
575 which its expression is valid.\n", b->number);
576 if (b->related_breakpoint)
577 delete_breakpoint (b->related_breakpoint);
578 delete_breakpoint (b);
581 /* Restore the frame and level. */
582 select_frame (saved_frame, saved_level);
585 printf_filtered ("\n");
591 remove_breakpoints ()
593 register struct breakpoint *b;
600 val = remove_breakpoint (b);
610 remove_breakpoint (b)
611 struct breakpoint *b;
615 if (b->type != bp_watchpoint
616 && b->type != bp_hardware_watchpoint
617 && b->type != bp_read_watchpoint
618 && b->type != bp_access_watchpoint)
620 if (b->type == bp_hardware_breakpoint)
621 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
623 val = target_remove_breakpoint(b->address, b->shadow_contents);
628 else if ((b->type == bp_hardware_watchpoint ||
629 b->type == bp_read_watchpoint ||
630 b->type == bp_access_watchpoint)
631 && b->enable == enabled
637 /* Walk down the saved value chain. */
638 for (v = b->val_chain; v; v = v->next)
640 /* For each memory reference remove the watchpoint
642 if (v->lval == lval_memory)
646 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
647 len = TYPE_LENGTH (VALUE_TYPE (v));
648 val = target_remove_watchpoint (addr, len, b->type);
654 /* Failure to remove any of the hardware watchpoints comes here. */
656 error ("Hardware watchpoint %d: Could not remove watchpoint\n",
659 /* Free the saved value chain. We will construct a new one
660 the next time the watchpoint is inserted. */
661 for (v = b->val_chain; v; v = n)
671 /* Clear the "inserted" flag in all breakpoints. */
674 mark_breakpoints_out ()
676 register struct breakpoint *b;
682 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
683 which should go away between runs of the program. */
686 breakpoint_init_inferior ()
688 register struct breakpoint *b, *temp;
690 ALL_BREAKPOINTS_SAFE (b, temp)
694 /* If the call dummy breakpoint is at the entry point it will
695 cause problems when the inferior is rerun, so we better
697 if (b->type == bp_call_dummy)
698 delete_breakpoint (b);
700 /* Likewise for scope breakpoints. */
701 if (b->type == bp_watchpoint_scope)
702 delete_breakpoint (b);
704 /* Likewise for watchpoints on local expressions. */
705 if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint ||
706 b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
707 && b->exp_valid_block != NULL)
708 delete_breakpoint (b);
712 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
713 When continuing from a location with a breakpoint,
714 we actually single step once before calling insert_breakpoints. */
717 breakpoint_here_p (pc)
720 register struct breakpoint *b;
723 if (b->enable != disabled && b->address == pc)
729 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
730 because figuring out the saved SP would take too much time, at least using
731 get_saved_register on the 68k. This means that for this function to
732 work right a port must use the bp_call_dummy breakpoint. */
735 frame_in_dummy (frame)
736 struct frame_info *frame;
738 struct breakpoint *b;
743 static unsigned LONGEST dummy[] = CALL_DUMMY;
745 if (b->type == bp_call_dummy
746 && b->frame == frame->frame
748 /* We need to check the PC as well as the frame on the sparc,
749 for signals.exp in the testsuite. */
752 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
753 && frame->pc <= b->address)
756 #endif /* CALL_DUMMY */
760 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
761 is valid for process/thread PID. */
764 breakpoint_thread_match (pc, pid)
768 struct breakpoint *b;
771 thread = pid_to_thread_id (pid);
774 if (b->enable != disabled
776 && (b->thread == -1 || b->thread == thread))
783 /* bpstat stuff. External routines' interfaces are documented
786 /* Clear a bpstat so that it says we are not at any breakpoint.
787 Also free any storage that is part of a bpstat. */
802 if (p->old_val != NULL)
803 value_free (p->old_val);
810 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
811 is part of the bpstat is copied as well. */
819 bpstat retval = NULL;
824 for (; bs != NULL; bs = bs->next)
826 tmp = (bpstat) xmalloc (sizeof (*tmp));
827 memcpy (tmp, bs, sizeof (*tmp));
829 /* This is the first thing in the chain. */
839 /* Find the bpstat associated with this breakpoint */
842 bpstat_find_breakpoint(bsp, breakpoint)
844 struct breakpoint *breakpoint;
846 if (bsp == NULL) return NULL;
848 for (;bsp != NULL; bsp = bsp->next) {
849 if (bsp->breakpoint_at == breakpoint) return bsp;
854 /* Return the breakpoint number of the first breakpoint we are stopped
855 at. *BSP upon return is a bpstat which points to the remaining
856 breakpoints stopped at (but which is not guaranteed to be good for
857 anything but further calls to bpstat_num).
858 Return 0 if passed a bpstat which does not indicate any breakpoints. */
864 struct breakpoint *b;
867 return 0; /* No more breakpoint values */
870 b = (*bsp)->breakpoint_at;
873 return -1; /* breakpoint that's been deleted since */
875 return b->number; /* We have its number */
879 /* Modify BS so that the actions will not be performed. */
882 bpstat_clear_actions (bs)
885 for (; bs != NULL; bs = bs->next)
888 if (bs->old_val != NULL)
890 value_free (bs->old_val);
896 /* Stub for cleaning up our state if we error-out of a breakpoint command */
899 cleanup_executing_breakpoints (ignore)
902 executing_breakpoint_commands = 0;
905 /* Execute all the commands associated with all the breakpoints at this
906 location. Any of these commands could cause the process to proceed
907 beyond this point, etc. We look out for such changes by checking
908 the global "breakpoint_proceeded" after each command. */
911 bpstat_do_actions (bsp)
915 struct cleanup *old_chain;
916 struct command_line *cmd;
918 executing_breakpoint_commands = 1;
919 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
924 breakpoint_proceeded = 0;
925 for (; bs != NULL; bs = bs->next)
930 execute_control_command (cmd);
933 if (breakpoint_proceeded)
934 /* The inferior is proceeded by the command; bomb out now.
935 The bpstat chain has been blown away by wait_for_inferior.
936 But since execution has stopped again, there is a new bpstat
937 to look at, so start over. */
943 executing_breakpoint_commands = 0;
944 discard_cleanups (old_chain);
947 /* This is the normal print_it function for a bpstat. In the future,
948 much of this logic could (should?) be moved to bpstat_stop_status,
949 by having it set different print_it functions. */
955 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
956 which has since been deleted. */
957 if (bs->breakpoint_at == NULL
958 || (bs->breakpoint_at->type != bp_breakpoint
959 && bs->breakpoint_at->type != bp_hardware_breakpoint
960 && bs->breakpoint_at->type != bp_watchpoint
961 && bs->breakpoint_at->type != bp_read_watchpoint
962 && bs->breakpoint_at->type != bp_access_watchpoint
963 && bs->breakpoint_at->type != bp_hardware_watchpoint))
966 if (bs->breakpoint_at->type == bp_breakpoint ||
967 bs->breakpoint_at->type == bp_hardware_breakpoint)
969 /* I think the user probably only wants to see one breakpoint
970 number, not all of them. */
971 annotate_breakpoint (bs->breakpoint_at->number);
972 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
975 else if ((bs->old_val != NULL) &&
976 (bs->breakpoint_at->type == bp_watchpoint ||
977 bs->breakpoint_at->type == bp_access_watchpoint ||
978 bs->breakpoint_at->type == bp_hardware_watchpoint))
980 annotate_watchpoint (bs->breakpoint_at->number);
981 mention (bs->breakpoint_at);
982 printf_filtered ("\nOld value = ");
983 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
984 printf_filtered ("\nNew value = ");
985 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
987 printf_filtered ("\n");
988 value_free (bs->old_val);
990 /* More than one watchpoint may have been triggered. */
993 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
994 bs->breakpoint_at->type == bp_read_watchpoint)
996 mention (bs->breakpoint_at);
997 printf_filtered ("\nValue = ");
998 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1000 printf_filtered ("\n");
1003 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1007 /* Print a message indicating what happened. Returns nonzero to
1008 say that only the source line should be printed after this (zero
1009 return means print the frame as well as the source line). */
1010 /* Currently we always return zero. */
1020 val = (*bs->print_it) (bs);
1024 /* Maybe another breakpoint in the chain caused us to stop.
1025 (Currently all watchpoints go on the bpstat whether hit or
1026 not. That probably could (should) be changed, provided care is taken
1027 with respect to bpstat_explains_signal). */
1029 return bpstat_print (bs->next);
1031 /* We reached the end of the chain without printing anything. */
1035 /* Evaluate the expression EXP and return 1 if value is zero.
1036 This is used inside a catch_errors to evaluate the breakpoint condition.
1037 The argument is a "struct expression *" that has been cast to char * to
1038 make it pass through catch_errors. */
1041 breakpoint_cond_eval (exp)
1044 value_ptr mark = value_mark ();
1045 int i = !value_true (evaluate_expression ((struct expression *)exp));
1046 value_free_to_mark (mark);
1050 /* Allocate a new bpstat and chain it to the current one. */
1053 bpstat_alloc (b, cbs)
1054 register struct breakpoint *b;
1055 bpstat cbs; /* Current "bs" value */
1059 bs = (bpstat) xmalloc (sizeof (*bs));
1061 bs->breakpoint_at = b;
1062 /* If the condition is false, etc., don't do the commands. */
1063 bs->commands = NULL;
1065 bs->print_it = print_it_normal;
1069 /* Possible return values for watchpoint_check (this can't be an enum
1070 because of check_errors). */
1071 /* The watchpoint has been deleted. */
1072 #define WP_DELETED 1
1073 /* The value has changed. */
1074 #define WP_VALUE_CHANGED 2
1075 /* The value has not changed. */
1076 #define WP_VALUE_NOT_CHANGED 3
1078 #define BP_TEMPFLAG 1
1079 #define BP_HARDWAREFLAG 2
1081 /* Check watchpoint condition. */
1084 watchpoint_check (p)
1087 bpstat bs = (bpstat) p;
1088 struct breakpoint *b;
1089 struct frame_info *fr;
1090 int within_current_scope;
1092 b = bs->breakpoint_at;
1094 if (b->exp_valid_block == NULL)
1095 within_current_scope = 1;
1098 /* There is no current frame at this moment. If we're going to have
1099 any chance of handling watchpoints on local variables, we'll need
1100 the frame chain (so we can determine if we're in scope). */
1101 reinit_frame_cache();
1102 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1103 within_current_scope = (fr != NULL);
1104 if (within_current_scope)
1105 /* If we end up stopping, the current frame will get selected
1106 in normal_stop. So this call to select_frame won't affect
1108 select_frame (fr, -1);
1111 if (within_current_scope)
1113 /* We use value_{,free_to_}mark because it could be a
1114 *long* time before we return to the command level and
1115 call free_all_values. We can't call free_all_values because
1116 we might be in the middle of evaluating a function call. */
1118 value_ptr mark = value_mark ();
1119 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1120 if (!value_equal (b->val, new_val))
1122 release_value (new_val);
1123 value_free_to_mark (mark);
1124 bs->old_val = b->val;
1126 /* We will stop here */
1127 return WP_VALUE_CHANGED;
1131 /* Nothing changed, don't do anything. */
1132 value_free_to_mark (mark);
1133 /* We won't stop here */
1134 return WP_VALUE_NOT_CHANGED;
1139 /* This seems like the only logical thing to do because
1140 if we temporarily ignored the watchpoint, then when
1141 we reenter the block in which it is valid it contains
1142 garbage (in the case of a function, it may have two
1143 garbage values, one before and one after the prologue).
1144 So we can't even detect the first assignment to it and
1145 watch after that (since the garbage may or may not equal
1146 the first value assigned). */
1148 Watchpoint %d deleted because the program has left the block in\n\
1149 which its expression is valid.\n", bs->breakpoint_at->number);
1150 if (b->related_breakpoint)
1151 delete_breakpoint (b->related_breakpoint);
1152 delete_breakpoint (b);
1158 /* This is used when everything which needs to be printed has
1159 already been printed. But we still want to print the frame. */
1167 /* This is used when nothing should be printed for this bpstat entry. */
1176 /* Get a bpstat associated with having just stopped at address *PC
1177 and frame address CORE_ADDRESS. Update *PC to point at the
1178 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1179 if this is known to not be a real breakpoint (it could still be a
1180 watchpoint, though). */
1182 /* Determine whether we stopped at a breakpoint, etc, or whether we
1183 don't understand this stop. Result is a chain of bpstat's such that:
1185 if we don't understand the stop, the result is a null pointer.
1187 if we understand why we stopped, the result is not null.
1189 Each element of the chain refers to a particular breakpoint or
1190 watchpoint at which we have stopped. (We may have stopped for
1191 several reasons concurrently.)
1193 Each element of the chain has valid next, breakpoint_at,
1194 commands, FIXME??? fields.
1199 bpstat_stop_status (pc, not_a_breakpoint)
1201 int not_a_breakpoint;
1203 register struct breakpoint *b;
1205 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1206 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1207 int real_breakpoint = 0;
1209 /* Root of the chain of bpstat's */
1210 struct bpstats root_bs[1];
1211 /* Pointer to the last thing in the chain currently. */
1212 bpstat bs = root_bs;
1213 static char message1[] =
1214 "Error evaluating expression for watchpoint %d\n";
1215 char message[sizeof (message1) + 30 /* slop */];
1217 /* Get the address where the breakpoint would have been. */
1218 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1222 if (b->enable == disabled)
1225 if (b->type != bp_watchpoint
1226 && b->type != bp_hardware_watchpoint
1227 && b->type != bp_read_watchpoint
1228 && b->type != bp_access_watchpoint
1229 && b->type != bp_hardware_breakpoint
1230 && b->address != bp_addr)
1233 if (b->type == bp_hardware_breakpoint
1234 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
1237 if (b->type != bp_watchpoint
1238 && b->type != bp_hardware_watchpoint
1239 && b->type != bp_read_watchpoint
1240 && b->type != bp_access_watchpoint
1241 && not_a_breakpoint)
1244 /* Come here if it's a watchpoint, or if the break address matches */
1248 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1253 sprintf (message, message1, b->number);
1254 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
1256 switch (catch_errors (watchpoint_check, (char *) bs, message,
1260 /* We've already printed what needs to be printed. */
1261 bs->print_it = print_it_done;
1264 case WP_VALUE_CHANGED:
1267 case WP_VALUE_NOT_CHANGED:
1269 bs->print_it = print_it_noop;
1276 /* Error from catch_errors. */
1277 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1278 if (b->related_breakpoint)
1279 delete_breakpoint (b->related_breakpoint);
1280 delete_breakpoint (b);
1281 /* We've already printed what needs to be printed. */
1282 bs->print_it = print_it_done;
1288 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
1294 addr = target_stopped_data_address();
1295 if (addr == 0) continue;
1296 for (v = b->val_chain; v; v = v->next)
1298 if (v->lval == lval_memory)
1302 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1308 switch (catch_errors (watchpoint_check, (char *) bs, message,
1312 /* We've already printed what needs to be printed. */
1313 bs->print_it = print_it_done;
1316 case WP_VALUE_CHANGED:
1317 case WP_VALUE_NOT_CHANGED:
1323 /* Error from catch_errors. */
1324 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1325 if (b->related_breakpoint)
1326 delete_breakpoint (b->related_breakpoint);
1327 delete_breakpoint (b);
1328 /* We've already printed what needs to be printed. */
1329 bs->print_it = print_it_done;
1333 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1335 real_breakpoint = 1;
1338 if (b->frame && b->frame != (get_current_frame ())->frame)
1342 int value_is_zero = 0;
1346 /* Need to select the frame, with all that implies
1347 so that the conditions will have the right context. */
1348 select_frame (get_current_frame (), 0);
1350 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1351 "Error in testing breakpoint condition:\n",
1353 /* FIXME-someday, should give breakpoint # */
1356 if (b->cond && value_is_zero)
1360 else if (b->ignore_count > 0)
1367 /* We will stop here */
1368 if (b->disposition == disable)
1369 b->enable = disabled;
1370 bs->commands = b->commands;
1373 if (bs->commands && STREQ ("silent", bs->commands->line))
1375 bs->commands = bs->commands->next;
1380 /* Print nothing for this entry if we dont stop or if we dont print. */
1381 if (bs->stop == 0 || bs->print == 0)
1382 bs->print_it = print_it_noop;
1385 bs->next = NULL; /* Terminate the chain */
1386 bs = root_bs->next; /* Re-grab the head of the chain */
1387 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1390 if (real_breakpoint)
1393 #if defined (SHIFT_INST_REGS)
1395 #else /* No SHIFT_INST_REGS. */
1397 #endif /* No SHIFT_INST_REGS. */
1400 #endif /* DECR_PC_AFTER_BREAK != 0. */
1402 /* The value of a hardware watchpoint hasn't changed, but the
1403 intermediate memory locations we are watching may have. */
1404 if (bs && ! bs->stop &&
1405 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
1406 bs->breakpoint_at->type == bp_read_watchpoint ||
1407 bs->breakpoint_at->type == bp_access_watchpoint))
1409 remove_breakpoints ();
1410 insert_breakpoints ();
1415 /* Tell what to do about this bpstat. */
1420 /* Classify each bpstat as one of the following. */
1422 /* This bpstat element has no effect on the main_action. */
1425 /* There was a watchpoint, stop but don't print. */
1428 /* There was a watchpoint, stop and print. */
1431 /* There was a breakpoint but we're not stopping. */
1434 /* There was a breakpoint, stop but don't print. */
1437 /* There was a breakpoint, stop and print. */
1440 /* We hit the longjmp breakpoint. */
1443 /* We hit the longjmp_resume breakpoint. */
1446 /* We hit the step_resume breakpoint. */
1449 /* We hit the through_sigtramp breakpoint. */
1452 /* This is just used to count how many enums there are. */
1456 /* Here is the table which drives this routine. So that we can
1457 format it pretty, we define some abbreviations for the
1458 enum bpstat_what codes. */
1459 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1460 #define stop_s BPSTAT_WHAT_STOP_SILENT
1461 #define stop_n BPSTAT_WHAT_STOP_NOISY
1462 #define single BPSTAT_WHAT_SINGLE
1463 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1464 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1465 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1466 #define sr BPSTAT_WHAT_STEP_RESUME
1467 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1469 /* "Can't happen." Might want to print an error message.
1470 abort() is not out of the question, but chances are GDB is just
1471 a bit confused, not unusable. */
1472 #define err BPSTAT_WHAT_STOP_NOISY
1474 /* Given an old action and a class, come up with a new action. */
1475 /* One interesting property of this table is that wp_silent is the same
1476 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1477 after stopping, the check for whether to step over a breakpoint
1478 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1479 reference to how we stopped. We retain separate wp_silent and bp_silent
1480 codes in case we want to change that someday. */
1482 /* step_resume entries: a step resume breakpoint overrides another
1483 breakpoint of signal handling (see comment in wait_for_inferior
1484 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1485 /* We handle the through_sigtramp_breakpoint the same way; having both
1486 one of those and a step_resume_breakpoint is probably very rare (?). */
1488 static const enum bpstat_what_main_action
1489 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1492 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr ts
1494 /*no_effect*/ {keep_c,stop_s,stop_n,single, setlr , clrlr , clrlrs, sr, ts},
1495 /*wp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1496 /*wp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1497 /*bp_nostop*/ {single,stop_s,stop_n,single, setlr , clrlrs, clrlrs, sr, ts},
1498 /*bp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1499 /*bp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1500 /*long_jump*/ {setlr ,stop_s,stop_n,setlr , err , err , err , sr, ts},
1501 /*long_resume*/ {clrlr ,stop_s,stop_n,clrlrs, err , err , err , sr, ts},
1502 /*step_resume*/ {sr ,sr ,sr ,sr , sr , sr , sr , sr, ts},
1503 /*through_sig*/ {ts ,ts ,ts ,ts , ts , ts , ts , ts, ts}
1515 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1516 struct bpstat_what retval;
1518 retval.call_dummy = 0;
1519 for (; bs != NULL; bs = bs->next)
1521 enum class bs_class = no_effect;
1522 if (bs->breakpoint_at == NULL)
1523 /* I suspect this can happen if it was a momentary breakpoint
1524 which has since been deleted. */
1526 switch (bs->breakpoint_at->type)
1529 case bp_hardware_breakpoint:
1535 bs_class = bp_noisy;
1537 bs_class = bp_silent;
1540 bs_class = bp_nostop;
1543 case bp_hardware_watchpoint:
1544 case bp_read_watchpoint:
1545 case bp_access_watchpoint:
1549 bs_class = wp_noisy;
1551 bs_class = wp_silent;
1554 /* There was a watchpoint, but we're not stopping. This requires
1555 no further action. */
1556 bs_class = no_effect;
1559 bs_class = long_jump;
1561 case bp_longjmp_resume:
1562 bs_class = long_resume;
1564 case bp_step_resume:
1567 bs_class = step_resume;
1570 /* It is for the wrong frame. */
1571 bs_class = bp_nostop;
1573 case bp_through_sigtramp:
1574 bs_class = through_sig;
1576 case bp_watchpoint_scope:
1577 bs_class = bp_nostop;
1581 /* Make sure the action is stop (silent or noisy), so infrun.c
1582 pops the dummy frame. */
1583 bs_class = bp_silent;
1584 retval.call_dummy = 1;
1587 current_action = table[(int)bs_class][(int)current_action];
1589 retval.main_action = current_action;
1593 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1594 without hardware support). This isn't related to a specific bpstat,
1595 just to things like whether watchpoints are set. */
1598 bpstat_should_step ()
1600 struct breakpoint *b;
1602 if (b->enable == enabled && b->type == bp_watchpoint)
1607 /* Print information on breakpoint number BNUM, or -1 if all.
1608 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1609 is nonzero, process only watchpoints. */
1612 breakpoint_1 (bnum, allflag)
1616 register struct breakpoint *b;
1617 register struct command_line *l;
1618 register struct symbol *sym;
1619 CORE_ADDR last_addr = (CORE_ADDR)-1;
1620 int found_a_breakpoint = 0;
1621 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1622 "until", "finish", "watchpoint",
1623 "hw watchpoint", "read watchpoint",
1624 "acc watchpoint", "longjmp",
1625 "longjmp resume", "step resume",
1626 "watchpoint scope", "call dummy" };
1627 static char *bpdisps[] = {"del", "dis", "keep"};
1628 static char bpenables[] = "ny";
1629 char wrap_indent[80];
1633 || bnum == b->number)
1635 /* We only print out user settable breakpoints unless the allflag is set. */
1637 && b->type != bp_breakpoint
1638 && b->type != bp_hardware_breakpoint
1639 && b->type != bp_watchpoint
1640 && b->type != bp_read_watchpoint
1641 && b->type != bp_access_watchpoint
1642 && b->type != bp_hardware_watchpoint)
1645 if (!found_a_breakpoint++)
1647 annotate_breakpoints_headers ();
1650 printf_filtered ("Num ");
1652 printf_filtered ("Type ");
1654 printf_filtered ("Disp ");
1656 printf_filtered ("Enb ");
1660 printf_filtered ("Address ");
1663 printf_filtered ("What\n");
1665 annotate_breakpoints_table ();
1670 printf_filtered ("%-3d ", b->number);
1672 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1674 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1676 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1678 strcpy (wrap_indent, " ");
1680 strcat (wrap_indent, " ");
1684 case bp_hardware_watchpoint:
1685 case bp_read_watchpoint:
1686 case bp_access_watchpoint:
1687 /* Field 4, the address, is omitted (which makes the columns
1688 not line up too nicely with the headers, but the effect
1689 is relatively readable). */
1691 print_expression (b->exp, gdb_stdout);
1695 case bp_hardware_breakpoint:
1699 case bp_longjmp_resume:
1700 case bp_step_resume:
1701 case bp_through_sigtramp:
1702 case bp_watchpoint_scope:
1707 /* FIXME-32x64: need a print_address_numeric with
1711 local_hex_string_custom
1712 ((unsigned long) b->address, "08l"));
1717 last_addr = b->address;
1720 sym = find_pc_function (b->address);
1723 fputs_filtered ("in ", gdb_stdout);
1724 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1725 wrap_here (wrap_indent);
1726 fputs_filtered (" at ", gdb_stdout);
1728 fputs_filtered (b->source_file, gdb_stdout);
1729 printf_filtered (":%d", b->line_number);
1732 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1736 printf_filtered ("\n");
1742 printf_filtered ("\tstop only in stack frame at ");
1743 print_address_numeric (b->frame, 1, gdb_stdout);
1744 printf_filtered ("\n");
1751 printf_filtered ("\tstop only if ");
1752 print_expression (b->cond, gdb_stdout);
1753 printf_filtered ("\n");
1756 if (show_breakpoint_hit_counts && b->hit_count)
1758 /* FIXME should make an annotation for this */
1760 printf_filtered ("\tbreakpoint already hit %d time%s\n",
1761 b->hit_count, (b->hit_count == 1 ? "" : "s"));
1764 if (b->ignore_count)
1768 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1771 if ((l = b->commands))
1777 print_command_line (l, 4);
1783 if (!found_a_breakpoint)
1786 printf_filtered ("No breakpoints or watchpoints.\n");
1788 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1791 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1792 that a comparison of an unsigned with -1 is always false. */
1793 if (last_addr != (CORE_ADDR)-1)
1794 set_next_address (last_addr);
1796 annotate_breakpoints_table_end ();
1801 breakpoints_info (bnum_exp, from_tty)
1808 bnum = parse_and_eval_address (bnum_exp);
1810 breakpoint_1 (bnum, 0);
1813 #if MAINTENANCE_CMDS
1817 maintenance_info_breakpoints (bnum_exp, from_tty)
1824 bnum = parse_and_eval_address (bnum_exp);
1826 breakpoint_1 (bnum, 1);
1831 /* Print a message describing any breakpoints set at PC. */
1834 describe_other_breakpoints (pc)
1835 register CORE_ADDR pc;
1837 register int others = 0;
1838 register struct breakpoint *b;
1841 if (b->address == pc)
1845 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1847 if (b->address == pc)
1853 (b->enable == disabled) ? " (disabled)" : "",
1854 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1856 printf_filtered ("also set at pc ");
1857 print_address_numeric (pc, 1, gdb_stdout);
1858 printf_filtered (".\n");
1862 /* Set the default place to put a breakpoint
1863 for the `break' command with no arguments. */
1866 set_default_breakpoint (valid, addr, symtab, line)
1869 struct symtab *symtab;
1872 default_breakpoint_valid = valid;
1873 default_breakpoint_address = addr;
1874 default_breakpoint_symtab = symtab;
1875 default_breakpoint_line = line;
1878 /* Rescan breakpoints at address ADDRESS,
1879 marking the first one as "first" and any others as "duplicates".
1880 This is so that the bpt instruction is only inserted once. */
1883 check_duplicates (address)
1886 register struct breakpoint *b;
1887 register int count = 0;
1889 if (address == 0) /* Watchpoints are uninteresting */
1893 if (b->enable != disabled && b->address == address)
1896 b->duplicate = count > 1;
1900 /* Low level routine to set a breakpoint.
1901 Takes as args the three things that every breakpoint must have.
1902 Returns the breakpoint object so caller can set other things.
1903 Does not set the breakpoint number!
1904 Does not print anything.
1906 ==> This routine should not be called if there is a chance of later
1907 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1908 your arguments BEFORE calling this routine! */
1910 static struct breakpoint *
1911 set_raw_breakpoint (sal)
1912 struct symtab_and_line sal;
1914 register struct breakpoint *b, *b1;
1916 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1917 memset (b, 0, sizeof (*b));
1918 b->address = sal.pc;
1919 if (sal.symtab == NULL)
1920 b->source_file = NULL;
1922 b->source_file = savestring (sal.symtab->filename,
1923 strlen (sal.symtab->filename));
1924 b->language = current_language->la_language;
1925 b->input_radix = input_radix;
1927 b->line_number = sal.line;
1928 b->enable = enabled;
1931 b->ignore_count = 0;
1935 /* Add this breakpoint to the end of the chain
1936 so that a list of breakpoints will come out in order
1937 of increasing numbers. */
1939 b1 = breakpoint_chain;
1941 breakpoint_chain = b;
1949 check_duplicates (sal.pc);
1950 breakpoints_changed ();
1956 create_longjmp_breakpoint(func_name)
1959 struct symtab_and_line sal;
1960 struct breakpoint *b;
1961 static int internal_breakpoint_number = -1;
1963 if (func_name != NULL)
1965 struct minimal_symbol *m;
1967 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
1969 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1979 b = set_raw_breakpoint(sal);
1982 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1983 b->disposition = donttouch;
1984 b->enable = disabled;
1987 b->addr_string = strsave(func_name);
1988 b->number = internal_breakpoint_number--;
1991 /* Call this routine when stepping and nexting to enable a breakpoint if we do
1992 a longjmp(). When we hit that breakpoint, call
1993 set_longjmp_resume_breakpoint() to figure out where we are going. */
1996 enable_longjmp_breakpoint()
1998 register struct breakpoint *b;
2001 if (b->type == bp_longjmp)
2003 b->enable = enabled;
2004 check_duplicates (b->address);
2009 disable_longjmp_breakpoint()
2011 register struct breakpoint *b;
2014 if ( b->type == bp_longjmp
2015 || b->type == bp_longjmp_resume)
2017 b->enable = disabled;
2018 check_duplicates (b->address);
2023 hw_breakpoint_used_count()
2025 register struct breakpoint *b;
2030 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2038 hw_watchpoint_used_count(type, other_type_used)
2040 int *other_type_used;
2042 register struct breakpoint *b;
2045 *other_type_used = 0;
2048 if (b->enable == enabled)
2050 if (b->type == type) i++;
2051 else if ((b->type == bp_hardware_watchpoint ||
2052 b->type == bp_read_watchpoint ||
2053 b->type == bp_access_watchpoint)
2054 && b->enable == enabled)
2055 *other_type_used = 1;
2061 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2062 breakpoint at the target of the jmp_buf.
2064 FIXME - This ought to be done by setting a temporary breakpoint that gets
2065 deleted automatically...
2069 set_longjmp_resume_breakpoint(pc, frame)
2071 struct frame_info *frame;
2073 register struct breakpoint *b;
2076 if (b->type == bp_longjmp_resume)
2079 b->enable = enabled;
2081 b->frame = frame->frame;
2084 check_duplicates (b->address);
2089 /* Set a breakpoint that will evaporate an end of command
2090 at address specified by SAL.
2091 Restrict it to frame FRAME if FRAME is nonzero. */
2094 set_momentary_breakpoint (sal, frame, type)
2095 struct symtab_and_line sal;
2096 struct frame_info *frame;
2099 register struct breakpoint *b;
2100 b = set_raw_breakpoint (sal);
2102 b->enable = enabled;
2103 b->disposition = donttouch;
2104 b->frame = (frame ? frame->frame : 0);
2106 /* If we're debugging a multi-threaded program, then we
2107 want momentary breakpoints to be active in only a
2108 single thread of control. */
2109 if (in_thread_list (inferior_pid))
2110 b->thread = pid_to_thread_id (inferior_pid);
2117 clear_momentary_breakpoints ()
2119 register struct breakpoint *b;
2121 if (b->disposition == delete)
2123 delete_breakpoint (b);
2129 /* Tell the user we have just set a breakpoint B. */
2133 struct breakpoint *b;
2137 /* FIXME: This is misplaced; mention() is called by things (like hitting a
2138 watchpoint) other than breakpoint creation. It should be possible to
2139 clean this up and at the same time replace the random calls to
2140 breakpoint_changed with this hook, as has already been done for
2141 delete_breakpoint_hook and so on. */
2142 if (create_breakpoint_hook)
2143 create_breakpoint_hook (b);
2148 printf_filtered ("Watchpoint %d: ", b->number);
2149 print_expression (b->exp, gdb_stdout);
2151 case bp_hardware_watchpoint:
2152 printf_filtered ("Hardware watchpoint %d: ", b->number);
2153 print_expression (b->exp, gdb_stdout);
2155 case bp_read_watchpoint:
2156 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2157 print_expression (b->exp, gdb_stdout);
2159 case bp_access_watchpoint:
2160 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2161 print_expression (b->exp, gdb_stdout);
2164 printf_filtered ("Breakpoint %d", b->number);
2167 case bp_hardware_breakpoint:
2168 printf_filtered ("Hardware assisted breakpoint %d", b->number);
2174 case bp_longjmp_resume:
2175 case bp_step_resume:
2176 case bp_through_sigtramp:
2178 case bp_watchpoint_scope:
2183 if (addressprint || b->source_file == NULL)
2185 printf_filtered (" at ");
2186 print_address_numeric (b->address, 1, gdb_stdout);
2189 printf_filtered (": file %s, line %d.",
2190 b->source_file, b->line_number);
2192 printf_filtered ("\n");
2196 /* Nobody calls this currently. */
2197 /* Set a breakpoint from a symtab and line.
2198 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2199 ADDR_STRING is a malloc'd string holding the name of where we are
2200 setting the breakpoint. This is used later to re-set it after the
2201 program is relinked and symbols are reloaded.
2202 Print the same confirmation messages that the breakpoint command prints. */
2205 set_breakpoint (s, line, tempflag, addr_string)
2211 register struct breakpoint *b;
2212 struct symtab_and_line sal;
2217 resolve_sal_pc (&sal); /* Might error out */
2218 describe_other_breakpoints (sal.pc);
2220 b = set_raw_breakpoint (sal);
2221 set_breakpoint_count (breakpoint_count + 1);
2222 b->number = breakpoint_count;
2223 b->type = bp_breakpoint;
2225 b->addr_string = addr_string;
2226 b->enable = enabled;
2227 b->disposition = tempflag ? delete : donttouch;
2233 /* Set a breakpoint according to ARG (function, linenum or *address)
2234 flag: first bit : 0 non-temporary, 1 temporary.
2235 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2238 break_command_1 (arg, flag, from_tty)
2242 int tempflag, hardwareflag;
2243 struct symtabs_and_lines sals;
2244 struct symtab_and_line sal;
2245 register struct expression *cond = 0;
2246 register struct breakpoint *b;
2248 /* Pointers in arg to the start, and one past the end, of the condition. */
2249 char *cond_start = NULL;
2250 char *cond_end = NULL;
2251 /* Pointers in arg to the start, and one past the end,
2252 of the address part. */
2253 char *addr_start = NULL;
2254 char *addr_end = NULL;
2255 struct cleanup *old_chain;
2256 struct cleanup *canonical_strings_chain = NULL;
2257 char **canonical = (char **)NULL;
2261 hardwareflag = flag & BP_HARDWAREFLAG;
2262 tempflag = flag & BP_TEMPFLAG;
2267 sal.line = sal.pc = sal.end = 0;
2270 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2272 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2273 && (arg[2] == ' ' || arg[2] == '\t')))
2275 if (default_breakpoint_valid)
2277 sals.sals = (struct symtab_and_line *)
2278 xmalloc (sizeof (struct symtab_and_line));
2279 sal.pc = default_breakpoint_address;
2280 sal.line = default_breakpoint_line;
2281 sal.symtab = default_breakpoint_symtab;
2286 error ("No default breakpoint address now.");
2292 /* Force almost all breakpoints to be in terms of the
2293 current_source_symtab (which is decode_line_1's default). This
2294 should produce the results we want almost all of the time while
2295 leaving default_breakpoint_* alone. */
2296 if (default_breakpoint_valid
2297 && (!current_source_symtab
2298 || (arg && (*arg == '+' || *arg == '-'))))
2299 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2300 default_breakpoint_line, &canonical);
2302 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2310 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2311 the following `for' loop errors out. */
2312 old_chain = make_cleanup (free, sals.sals);
2313 if (canonical != (char **)NULL)
2315 make_cleanup (free, canonical);
2316 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2317 for (i = 0; i < sals.nelts; i++)
2319 if (canonical[i] != NULL)
2320 make_cleanup (free, canonical[i]);
2324 thread = -1; /* No specific thread yet */
2326 /* Resolve all line numbers to PC's, and verify that conditions
2327 can be parsed, before setting any breakpoints. */
2328 for (i = 0; i < sals.nelts; i++)
2330 char *tok, *end_tok;
2333 resolve_sal_pc (&sals.sals[i]);
2339 while (*tok == ' ' || *tok == '\t')
2344 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2347 toklen = end_tok - tok;
2349 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2351 tok = cond_start = end_tok + 1;
2352 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2355 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2361 thread = strtol (tok, &tok, 0);
2363 error ("Junk after thread keyword.");
2364 if (!valid_thread_id (thread))
2365 error ("Unknown thread %d\n", thread);
2368 error ("Junk at end of arguments.");
2373 int i, target_resources_ok;
2375 i = hw_breakpoint_used_count ();
2376 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
2377 bp_hardware_breakpoint, i + sals.nelts, 0);
2378 if (target_resources_ok == 0)
2379 error ("No hardware breakpoint support in the target.");
2380 else if (target_resources_ok < 0)
2381 error ("Hardware breakpoints used exceeds limit.");
2384 /* Remove the canonical strings from the cleanup, they are needed below. */
2385 if (canonical != (char **)NULL)
2386 discard_cleanups (canonical_strings_chain);
2388 /* Now set all the breakpoints. */
2389 for (i = 0; i < sals.nelts; i++)
2394 describe_other_breakpoints (sal.pc);
2396 b = set_raw_breakpoint (sal);
2397 set_breakpoint_count (breakpoint_count + 1);
2398 b->number = breakpoint_count;
2399 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2403 /* If a canonical line spec is needed use that instead of the
2405 if (canonical != (char **)NULL && canonical[i] != NULL)
2406 b->addr_string = canonical[i];
2407 else if (addr_start)
2408 b->addr_string = savestring (addr_start, addr_end - addr_start);
2410 b->cond_string = savestring (cond_start, cond_end - cond_start);
2412 b->enable = enabled;
2413 b->disposition = tempflag ? del : donttouch;
2420 printf_filtered ("Multiple breakpoints were set.\n");
2421 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2423 do_cleanups (old_chain);
2426 /* Helper function for break_command_1 and disassemble_command. */
2429 resolve_sal_pc (sal)
2430 struct symtab_and_line *sal;
2434 if (sal->pc == 0 && sal->symtab != 0)
2436 pc = find_line_pc (sal->symtab, sal->line);
2438 error ("No line %d in file \"%s\".",
2439 sal->line, sal->symtab->filename);
2445 break_command (arg, from_tty)
2449 break_command_1 (arg, 0, from_tty);
2453 tbreak_command (arg, from_tty)
2457 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2461 hbreak_command (arg, from_tty)
2465 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2469 thbreak_command (arg, from_tty)
2473 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2477 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2480 watch_command_1 (arg, accessflag, from_tty)
2485 struct breakpoint *b;
2486 struct symtab_and_line sal;
2487 struct expression *exp;
2488 struct block *exp_valid_block;
2489 struct value *val, *mark;
2490 struct frame_info *frame, *prev_frame;
2491 char *exp_start = NULL;
2492 char *exp_end = NULL;
2493 char *tok, *end_tok;
2495 char *cond_start = NULL;
2496 char *cond_end = NULL;
2497 struct expression *cond = NULL;
2498 int i, other_type_used, target_resources_ok;
2499 enum bptype bp_type;
2506 /* Parse arguments. */
2507 innermost_block = NULL;
2509 exp = parse_exp_1 (&arg, 0, 0);
2511 exp_valid_block = innermost_block;
2512 mark = value_mark ();
2513 val = evaluate_expression (exp);
2514 release_value (val);
2515 if (VALUE_LAZY (val))
2516 value_fetch_lazy (val);
2519 while (*tok == ' ' || *tok == '\t')
2523 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2526 toklen = end_tok - tok;
2527 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2529 tok = cond_start = end_tok + 1;
2530 cond = parse_exp_1 (&tok, 0, 0);
2534 error("Junk at end of command.");
2536 if (accessflag == 1) bp_type = bp_read_watchpoint;
2537 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2538 else bp_type = bp_hardware_watchpoint;
2540 mem_cnt = can_use_hardware_watchpoint (val);
2541 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2542 error ("Expression cannot be implemented with read/access watchpoint.");
2544 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2545 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2546 bp_type, i + mem_cnt, other_type_used);
2547 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2548 error ("Target does not have this type of hardware watchpoint support.");
2549 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2550 error ("Target resources have been allocated for other types of watchpoints.");
2553 /* Now set up the breakpoint. */
2554 b = set_raw_breakpoint (sal);
2555 set_breakpoint_count (breakpoint_count + 1);
2556 b->number = breakpoint_count;
2557 b->disposition = donttouch;
2559 b->exp_valid_block = exp_valid_block;
2560 b->exp_string = savestring (exp_start, exp_end - exp_start);
2564 b->cond_string = savestring (cond_start, cond_end - cond_start);
2568 frame = block_innermost_frame (exp_valid_block);
2571 prev_frame = get_prev_frame (frame);
2572 b->watchpoint_frame = frame->frame;
2575 b->watchpoint_frame = (CORE_ADDR)0;
2577 if (mem_cnt && target_resources_ok > 0)
2580 b->type = bp_watchpoint;
2582 /* If the expression is "local", then set up a "watchpoint scope"
2583 breakpoint at the point where we've left the scope of the watchpoint
2585 if (innermost_block)
2587 struct breakpoint *scope_breakpoint;
2588 struct symtab_and_line scope_sal;
2592 scope_sal.pc = get_frame_pc (prev_frame);
2593 scope_sal.symtab = NULL;
2596 scope_breakpoint = set_raw_breakpoint (scope_sal);
2597 set_breakpoint_count (breakpoint_count + 1);
2598 scope_breakpoint->number = breakpoint_count;
2600 scope_breakpoint->type = bp_watchpoint_scope;
2601 scope_breakpoint->enable = enabled;
2603 /* Automatically delete the breakpoint when it hits. */
2604 scope_breakpoint->disposition = del;
2606 /* Only break in the proper frame (help with recursion). */
2607 scope_breakpoint->frame = prev_frame->frame;
2609 /* Set the address at which we will stop. */
2610 scope_breakpoint->address = get_frame_pc (prev_frame);
2612 /* The scope breakpoint is related to the watchpoint. We
2613 will need to act on them together. */
2614 b->related_breakpoint = scope_breakpoint;
2617 value_free_to_mark (mark);
2621 /* Return count of locations need to be watched and can be handled
2622 in hardware. If the watchpoint can not be handled
2623 in hardware return zero. */
2626 can_use_hardware_watchpoint (v)
2629 int found_memory_cnt = 0;
2631 /* Make sure all the intermediate values are in memory. Also make sure
2632 we found at least one memory expression. Guards against watch 0x12345,
2633 which is meaningless, but could cause errors if one tries to insert a
2634 hardware watchpoint for the constant expression. */
2635 for ( ; v; v = v->next)
2637 if (v->lval == lval_memory)
2639 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2642 else if (v->lval != not_lval && v->modifiable == 0)
2646 /* The expression itself looks suitable for using a hardware
2647 watchpoint, but give the target machine a chance to reject it. */
2648 return found_memory_cnt;
2651 static void watch_command (arg, from_tty)
2655 watch_command_1 (arg, 0, from_tty);
2658 static void rwatch_command (arg, from_tty)
2662 watch_command_1 (arg, 1, from_tty);
2665 static void awatch_command (arg, from_tty)
2669 watch_command_1 (arg, 2, from_tty);
2673 /* Helper routine for the until_command routine in infcmd.c. Here
2674 because it uses the mechanisms of breakpoints. */
2678 until_break_command (arg, from_tty)
2682 struct symtabs_and_lines sals;
2683 struct symtab_and_line sal;
2684 struct frame_info *prev_frame = get_prev_frame (selected_frame);
2685 struct breakpoint *breakpoint;
2686 struct cleanup *old_chain;
2688 clear_proceed_status ();
2690 /* Set a breakpoint where the user wants it and at return from
2693 if (default_breakpoint_valid)
2694 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2695 default_breakpoint_line, (char ***)NULL);
2697 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2699 if (sals.nelts != 1)
2700 error ("Couldn't get information on specified line.");
2703 free ((PTR)sals.sals); /* malloc'd, so freed */
2706 error ("Junk at end of arguments.");
2708 resolve_sal_pc (&sal);
2710 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2712 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2714 /* Keep within the current frame */
2718 sal = find_pc_line (prev_frame->pc, 0);
2719 sal.pc = prev_frame->pc;
2720 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2721 make_cleanup(delete_breakpoint, breakpoint);
2724 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2725 do_cleanups(old_chain);
2729 /* These aren't used; I don't konw what they were for. */
2730 /* Set a breakpoint at the catch clause for NAME. */
2732 catch_breakpoint (name)
2738 disable_catch_breakpoint ()
2743 delete_catch_breakpoint ()
2748 enable_catch_breakpoint ()
2755 struct sal_chain *next;
2756 struct symtab_and_line sal;
2760 /* This isn't used; I don't know what it was for. */
2761 /* For each catch clause identified in ARGS, run FUNCTION
2762 with that clause as an argument. */
2763 static struct symtabs_and_lines
2764 map_catch_names (args, function)
2768 register char *p = args;
2770 struct symtabs_and_lines sals;
2772 struct sal_chain *sal_chain = 0;
2776 error_no_arg ("one or more catch names");
2784 /* Don't swallow conditional part. */
2785 if (p1[0] == 'i' && p1[1] == 'f'
2786 && (p1[2] == ' ' || p1[2] == '\t'))
2792 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2796 if (*p1 && *p1 != ' ' && *p1 != '\t')
2797 error ("Arguments must be catch names.");
2803 struct sal_chain *next
2804 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2805 next->next = sal_chain;
2806 next->sal = get_catch_sal (p);
2811 printf_unfiltered ("No catch clause for exception %s.\n", p);
2816 while (*p == ' ' || *p == '\t') p++;
2821 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2823 static struct symtabs_and_lines
2824 get_catch_sals (this_level_only)
2825 int this_level_only;
2827 register struct blockvector *bl;
2828 register struct block *block;
2829 int index, have_default = 0;
2831 struct symtabs_and_lines sals;
2832 struct sal_chain *sal_chain = 0;
2833 char *blocks_searched;
2835 /* Not sure whether an error message is always the correct response,
2836 but it's better than a core dump. */
2837 if (selected_frame == NULL)
2838 error ("No selected frame.");
2839 block = get_frame_block (selected_frame);
2840 pc = selected_frame->pc;
2846 error ("No symbol table info available.\n");
2848 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2849 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2850 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2854 CORE_ADDR end = BLOCK_END (block) - 4;
2857 if (bl != blockvector_for_pc (end, &index))
2858 error ("blockvector blotch");
2859 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2860 error ("blockvector botch");
2861 last_index = BLOCKVECTOR_NBLOCKS (bl);
2864 /* Don't print out blocks that have gone by. */
2865 while (index < last_index
2866 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2869 while (index < last_index
2870 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2872 if (blocks_searched[index] == 0)
2874 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2877 register struct symbol *sym;
2879 nsyms = BLOCK_NSYMS (b);
2881 for (i = 0; i < nsyms; i++)
2883 sym = BLOCK_SYM (b, i);
2884 if (STREQ (SYMBOL_NAME (sym), "default"))
2890 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2892 struct sal_chain *next = (struct sal_chain *)
2893 alloca (sizeof (struct sal_chain));
2894 next->next = sal_chain;
2895 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2899 blocks_searched[index] = 1;
2905 if (sal_chain && this_level_only)
2908 /* After handling the function's top-level block, stop.
2909 Don't continue to its superblock, the block of
2910 per-file symbols. */
2911 if (BLOCK_FUNCTION (block))
2913 block = BLOCK_SUPERBLOCK (block);
2918 struct sal_chain *tmp_chain;
2920 /* Count the number of entries. */
2921 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2922 tmp_chain = tmp_chain->next)
2926 sals.sals = (struct symtab_and_line *)
2927 xmalloc (index * sizeof (struct symtab_and_line));
2928 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2929 sals.sals[index] = sal_chain->sal;
2935 /* Commands to deal with catching exceptions. */
2938 catch_command_1 (arg, tempflag, from_tty)
2943 /* First, translate ARG into something we can deal with in terms
2946 struct symtabs_and_lines sals;
2947 struct symtab_and_line sal;
2948 register struct expression *cond = 0;
2949 register struct breakpoint *b;
2953 sal.line = sal.pc = sal.end = 0;
2956 /* If no arg given, or if first arg is 'if ', all active catch clauses
2957 are breakpointed. */
2959 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2960 && (arg[2] == ' ' || arg[2] == '\t')))
2962 /* Grab all active catch clauses. */
2963 sals = get_catch_sals (0);
2967 /* Grab selected catch clauses. */
2968 error ("catch NAME not implemented");
2970 /* This isn't used; I don't know what it was for. */
2971 sals = map_catch_names (arg, catch_breakpoint);
2979 for (i = 0; i < sals.nelts; i++)
2981 resolve_sal_pc (&sals.sals[i]);
2985 if (arg[0] == 'i' && arg[1] == 'f'
2986 && (arg[2] == ' ' || arg[2] == '\t'))
2987 cond = parse_exp_1 ((arg += 2, &arg),
2988 block_for_pc (sals.sals[i].pc), 0);
2990 error ("Junk at end of arguments.");
2995 for (i = 0; i < sals.nelts; i++)
3000 describe_other_breakpoints (sal.pc);
3002 b = set_raw_breakpoint (sal);
3003 set_breakpoint_count (breakpoint_count + 1);
3004 b->number = breakpoint_count;
3005 b->type = bp_breakpoint;
3007 b->enable = enabled;
3008 b->disposition = tempflag ? del : donttouch;
3015 printf_unfiltered ("Multiple breakpoints were set.\n");
3016 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3018 free ((PTR)sals.sals);
3021 /* Used by the gui, could be made a worker for other things. */
3024 set_breakpoint_sal (sal)
3025 struct symtab_and_line sal;
3027 struct breakpoint *b;
3028 b = set_raw_breakpoint (sal);
3029 set_breakpoint_count (breakpoint_count + 1);
3030 b->number = breakpoint_count;
3031 b->type = bp_breakpoint;
3038 /* These aren't used; I don't know what they were for. */
3039 /* Disable breakpoints on all catch clauses described in ARGS. */
3041 disable_catch (args)
3044 /* Map the disable command to catch clauses described in ARGS. */
3047 /* Enable breakpoints on all catch clauses described in ARGS. */
3052 /* Map the disable command to catch clauses described in ARGS. */
3055 /* Delete breakpoints on all catch clauses in the active scope. */
3060 /* Map the delete command to catch clauses described in ARGS. */
3065 catch_command (arg, from_tty)
3069 catch_command_1 (arg, 0, from_tty);
3073 clear_command (arg, from_tty)
3077 register struct breakpoint *b, *b1;
3078 struct symtabs_and_lines sals;
3079 struct symtab_and_line sal;
3080 register struct breakpoint *found;
3085 sals = decode_line_spec (arg, 1);
3089 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3090 sal.line = default_breakpoint_line;
3091 sal.symtab = default_breakpoint_symtab;
3093 if (sal.symtab == 0)
3094 error ("No source file specified.");
3100 for (i = 0; i < sals.nelts; i++)
3102 /* If exact pc given, clear bpts at that pc.
3103 But if sal.pc is zero, clear all bpts on specified line. */
3105 found = (struct breakpoint *) 0;
3106 while (breakpoint_chain
3108 ? breakpoint_chain->address == sal.pc
3109 : (breakpoint_chain->source_file != NULL
3110 && sal.symtab != NULL
3111 && STREQ (breakpoint_chain->source_file,
3112 sal.symtab->filename)
3113 && breakpoint_chain->line_number == sal.line)))
3115 b1 = breakpoint_chain;
3116 breakpoint_chain = b1->next;
3123 && b->next->type != bp_watchpoint
3124 && b->next->type != bp_hardware_watchpoint
3125 && b->next->type != bp_read_watchpoint
3126 && b->next->type != bp_access_watchpoint
3128 ? b->next->address == sal.pc
3129 : (b->next->source_file != NULL
3130 && sal.symtab != NULL
3131 && STREQ (b->next->source_file, sal.symtab->filename)
3132 && b->next->line_number == sal.line)))
3143 error ("No breakpoint at %s.", arg);
3145 error ("No breakpoint at this line.");
3148 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3149 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3150 breakpoints_changed ();
3153 if (from_tty) printf_unfiltered ("%d ", found->number);
3155 delete_breakpoint (found);
3158 if (from_tty) putchar_unfiltered ('\n');
3160 free ((PTR)sals.sals);
3163 /* Delete breakpoint in BS if they are `delete' breakpoints.
3164 This is called after any breakpoint is hit, or after errors. */
3167 breakpoint_auto_delete (bs)
3170 for (; bs; bs = bs->next)
3171 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
3173 delete_breakpoint (bs->breakpoint_at);
3176 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3179 delete_breakpoint (bpt)
3180 struct breakpoint *bpt;
3182 register struct breakpoint *b;
3185 if (delete_breakpoint_hook)
3186 delete_breakpoint_hook (bpt);
3189 remove_breakpoint (bpt);
3191 if (breakpoint_chain == bpt)
3192 breakpoint_chain = bpt->next;
3197 b->next = bpt->next;
3201 check_duplicates (bpt->address);
3202 /* If this breakpoint was inserted, and there is another breakpoint
3203 at the same address, we need to insert the other breakpoint. */
3205 && bpt->type != bp_hardware_watchpoint
3206 && bpt->type != bp_read_watchpoint
3207 && bpt->type != bp_access_watchpoint)
3210 if (b->address == bpt->address
3212 && b->enable != disabled)
3215 val = target_insert_breakpoint (b->address, b->shadow_contents);
3218 target_terminal_ours_for_output ();
3219 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3220 memory_error (val, b->address); /* which bombs us out */
3227 free_command_lines (&bpt->commands);
3230 if (bpt->cond_string != NULL)
3231 free (bpt->cond_string);
3232 if (bpt->addr_string != NULL)
3233 free (bpt->addr_string);
3234 if (bpt->exp_string != NULL)
3235 free (bpt->exp_string);
3236 if (bpt->source_file != NULL)
3237 free (bpt->source_file);
3239 /* Be sure no bpstat's are pointing at it after it's been freed. */
3240 /* FIXME, how can we find all bpstat's?
3241 We just check stop_bpstat for now. */
3242 for (bs = stop_bpstat; bs; bs = bs->next)
3243 if (bs->breakpoint_at == bpt)
3244 bs->breakpoint_at = NULL;
3249 delete_command (arg, from_tty)
3256 /* Ask user only if there are some breakpoints to delete. */
3258 || (breakpoint_chain && query ("Delete all breakpoints? ")))
3260 /* No arg; clear all breakpoints. */
3261 while (breakpoint_chain)
3262 delete_breakpoint (breakpoint_chain);
3266 map_breakpoint_numbers (arg, delete_breakpoint);
3269 /* Reset a breakpoint given it's struct breakpoint * BINT.
3270 The value we return ends up being the return value from catch_errors.
3271 Unused in this case. */
3274 breakpoint_re_set_one (bint)
3277 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3280 struct symtabs_and_lines sals;
3282 enum enable save_enable;
3287 case bp_hardware_breakpoint:
3288 if (b->addr_string == NULL)
3290 /* Anything without a string can't be re-set. */
3291 delete_breakpoint (b);
3294 /* In case we have a problem, disable this breakpoint. We'll restore
3295 its status if we succeed. */
3296 save_enable = b->enable;
3297 b->enable = disabled;
3299 set_language (b->language);
3300 input_radix = b->input_radix;
3302 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3303 for (i = 0; i < sals.nelts; i++)
3305 resolve_sal_pc (&sals.sals[i]);
3307 /* Reparse conditions, they might contain references to the
3309 if (b->cond_string != NULL)
3313 free ((PTR)b->cond);
3314 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3317 /* We need to re-set the breakpoint if the address changes...*/
3318 if (b->address != sals.sals[i].pc
3319 /* ...or new and old breakpoints both have source files, and
3320 the source file name or the line number changes... */
3321 || (b->source_file != NULL
3322 && sals.sals[i].symtab != NULL
3323 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3324 || b->line_number != sals.sals[i].line)
3326 /* ...or we switch between having a source file and not having
3328 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3331 if (b->source_file != NULL)
3332 free (b->source_file);
3333 if (sals.sals[i].symtab == NULL)
3334 b->source_file = NULL;
3337 savestring (sals.sals[i].symtab->filename,
3338 strlen (sals.sals[i].symtab->filename));
3339 b->line_number = sals.sals[i].line;
3340 b->address = sals.sals[i].pc;
3342 check_duplicates (b->address);
3346 /* Might be better to do this just once per breakpoint_re_set,
3347 rather than once for every breakpoint. */
3348 breakpoints_changed ();
3350 b->enable = save_enable; /* Restore it, this worked. */
3352 free ((PTR)sals.sals);
3356 case bp_hardware_watchpoint:
3357 case bp_read_watchpoint:
3358 case bp_access_watchpoint:
3359 innermost_block = NULL;
3360 /* The issue arises of what context to evaluate this in. The same
3361 one as when it was set, but what does that mean when symbols have
3362 been re-read? We could save the filename and functionname, but
3363 if the context is more local than that, the best we could do would
3364 be something like how many levels deep and which index at that
3365 particular level, but that's going to be less stable than filenames
3366 or functionnames. */
3367 /* So for now, just use a global context. */
3368 b->exp = parse_expression (b->exp_string);
3369 b->exp_valid_block = innermost_block;
3370 mark = value_mark ();
3371 b->val = evaluate_expression (b->exp);
3372 release_value (b->val);
3373 if (VALUE_LAZY (b->val))
3374 value_fetch_lazy (b->val);
3376 if (b->cond_string != NULL)
3379 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3381 if (b->enable == enabled)
3383 value_free_to_mark (mark);
3387 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3392 case bp_longjmp_resume:
3393 case bp_watchpoint_scope:
3395 delete_breakpoint (b);
3402 /* Re-set all breakpoints after symbols have been re-loaded. */
3404 breakpoint_re_set ()
3406 struct breakpoint *b, *temp;
3407 enum language save_language;
3408 int save_input_radix;
3409 static char message1[] = "Error in re-setting breakpoint %d:\n";
3410 char message[sizeof (message1) + 30 /* slop */];
3412 save_language = current_language->la_language;
3413 save_input_radix = input_radix;
3414 ALL_BREAKPOINTS_SAFE (b, temp)
3416 sprintf (message, message1, b->number); /* Format possible error msg */
3417 catch_errors (breakpoint_re_set_one, (char *) b, message,
3420 set_language (save_language);
3421 input_radix = save_input_radix;
3423 create_longjmp_breakpoint("longjmp");
3424 create_longjmp_breakpoint("_longjmp");
3425 create_longjmp_breakpoint("siglongjmp");
3426 create_longjmp_breakpoint(NULL);
3429 /* Took this out (temporaliy at least), since it produces an extra
3430 blank line at startup. This messes up the gdbtests. -PB */
3431 /* Blank line to finish off all those mention() messages we just printed. */
3432 printf_filtered ("\n");
3436 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3437 If from_tty is nonzero, it prints a message to that effect,
3438 which ends with a period (no newline). */
3441 set_ignore_count (bptnum, count, from_tty)
3442 int bptnum, count, from_tty;
3444 register struct breakpoint *b;
3450 if (b->number == bptnum)
3452 b->ignore_count = count;
3455 else if (count == 0)
3456 printf_filtered ("Will stop next time breakpoint %d is reached.",
3458 else if (count == 1)
3459 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3462 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3464 breakpoints_changed ();
3468 error ("No breakpoint number %d.", bptnum);
3471 /* Clear the ignore counts of all breakpoints. */
3473 breakpoint_clear_ignore_counts ()
3475 struct breakpoint *b;
3478 b->ignore_count = 0;
3481 /* Command to set ignore-count of breakpoint N to COUNT. */
3484 ignore_command (args, from_tty)
3492 error_no_arg ("a breakpoint number");
3494 num = get_number (&p);
3497 error ("Second argument (specified ignore-count) is missing.");
3499 set_ignore_count (num,
3500 longest_to_int (value_as_long (parse_and_eval (p))),
3502 printf_filtered ("\n");
3503 breakpoints_changed ();
3506 /* Call FUNCTION on each of the breakpoints
3507 whose numbers are given in ARGS. */
3510 map_breakpoint_numbers (args, function)
3512 void (*function) PARAMS ((struct breakpoint *));
3514 register char *p = args;
3517 register struct breakpoint *b;
3520 error_no_arg ("one or more breakpoint numbers");
3526 num = get_number (&p1);
3529 if (b->number == num)
3531 struct breakpoint *related_breakpoint = b->related_breakpoint;
3533 if (related_breakpoint)
3534 function (related_breakpoint);
3537 printf_unfiltered ("No breakpoint number %d.\n", num);
3544 enable_breakpoint (bpt)
3545 struct breakpoint *bpt;
3547 struct frame_info *save_selected_frame = NULL;
3548 int save_selected_frame_level = -1;
3549 int target_resources_ok, other_type_used;
3552 if (bpt->type == bp_hardware_breakpoint)
3555 i = hw_breakpoint_used_count();
3556 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3557 bp_hardware_breakpoint, i+1, 0);
3558 if (target_resources_ok == 0)
3559 error ("No hardware breakpoint support in the target.");
3560 else if (target_resources_ok < 0)
3561 error ("Hardware breakpoints used exceeds limit.");
3563 bpt->enable = enabled;
3564 check_duplicates (bpt->address);
3566 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3567 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3569 if (bpt->exp_valid_block != NULL)
3571 struct frame_info *fr =
3572 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3576 Cannot enable watchpoint %d because the block in which its expression\n\
3577 is valid is not currently in scope.\n", bpt->number);
3578 bpt->enable = disabled;
3582 save_selected_frame = selected_frame;
3583 save_selected_frame_level = selected_frame_level;
3584 select_frame (fr, -1);
3587 value_free (bpt->val);
3588 mark = value_mark ();
3589 bpt->val = evaluate_expression (bpt->exp);
3590 release_value (bpt->val);
3591 if (VALUE_LAZY (bpt->val))
3592 value_fetch_lazy (bpt->val);
3594 if (bpt->type == bp_hardware_watchpoint ||
3595 bpt->type == bp_read_watchpoint ||
3596 bpt->type == bp_access_watchpoint)
3598 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3599 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
3601 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3602 bpt->type, i + mem_cnt, other_type_used);
3603 /* we can consider of type is bp_hardware_watchpoint, convert to
3604 bp_watchpoint in the following condition */
3605 if (target_resources_ok < 0)
3608 Cannot enable watchpoint %d because target watch resources\n\
3609 have been allocated for other watchpoints.\n", bpt->number);
3610 bpt->enable = disabled;
3611 value_free_to_mark (mark);
3616 if (save_selected_frame_level >= 0)
3617 select_frame (save_selected_frame, save_selected_frame_level);
3618 value_free_to_mark (mark);
3621 if (modify_breakpoint_hook)
3622 modify_breakpoint_hook (bpt);
3627 enable_command (args, from_tty)
3631 struct breakpoint *bpt;
3633 ALL_BREAKPOINTS (bpt)
3637 case bp_hardware_breakpoint:
3639 case bp_hardware_watchpoint:
3640 case bp_read_watchpoint:
3641 case bp_access_watchpoint:
3642 enable_breakpoint (bpt);
3647 map_breakpoint_numbers (args, enable_breakpoint);
3651 disable_breakpoint (bpt)
3652 struct breakpoint *bpt;
3654 /* Never disable a watchpoint scope breakpoint; we want to
3655 hit them when we leave scope so we can delete both the
3656 watchpoint and its scope breakpoint at that time. */
3657 if (bpt->type == bp_watchpoint_scope)
3660 bpt->enable = disabled;
3662 check_duplicates (bpt->address);
3664 if (modify_breakpoint_hook)
3665 modify_breakpoint_hook (bpt);
3670 disable_command (args, from_tty)
3674 register struct breakpoint *bpt;
3676 ALL_BREAKPOINTS (bpt)
3680 case bp_hardware_breakpoint:
3682 case bp_hardware_watchpoint:
3683 case bp_read_watchpoint:
3684 case bp_access_watchpoint:
3685 disable_breakpoint (bpt);
3690 map_breakpoint_numbers (args, disable_breakpoint);
3694 enable_once_breakpoint (bpt)
3695 struct breakpoint *bpt;
3697 struct frame_info *save_selected_frame = NULL;
3698 int save_selected_frame_level = -1;
3699 int target_resources_ok, other_type_used;
3702 if (bpt->type == bp_hardware_breakpoint)
3705 i = hw_breakpoint_used_count();
3706 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3707 bp_hardware_breakpoint, i+1, 0);
3708 if (target_resources_ok == 0)
3709 error ("No hardware breakpoint support in the target.");
3710 else if (target_resources_ok < 0)
3711 error ("Hardware breakpoints used exceeds limit.");
3714 bpt->enable = enabled;
3715 bpt->disposition = disable;
3716 check_duplicates (bpt->address);
3717 breakpoints_changed ();
3719 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3720 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3722 if (bpt->exp_valid_block != NULL)
3724 struct frame_info *fr =
3725 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3729 Cannot enable watchpoint %d because the block in which its expression\n\
3730 is valid is not currently in scope.\n", bpt->number);
3731 bpt->enable = disabled;
3735 save_selected_frame = selected_frame;
3736 save_selected_frame_level = selected_frame_level;
3737 select_frame (fr, -1);
3740 value_free (bpt->val);
3741 mark = value_mark ();
3742 bpt->val = evaluate_expression (bpt->exp);
3743 release_value (bpt->val);
3744 if (VALUE_LAZY (bpt->val))
3745 value_fetch_lazy (bpt->val);
3747 if (bpt->type == bp_hardware_watchpoint ||
3748 bpt->type == bp_read_watchpoint ||
3749 bpt->type == bp_access_watchpoint)
3751 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3752 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3753 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3754 bpt->type, i+mem_cnt, other_type_used);
3755 /* we can consider of type is bp_hardware_watchpoint, convert to
3756 bp_watchpoint in the following condition */
3757 if (target_resources_ok < 0)
3760 Cannot enable watchpoint %d because target watch resources\n\
3761 have been allocated for other watchpoints.\n", bpt->number);
3762 bpt->enable = disabled;
3763 value_free_to_mark (mark);
3767 if (save_selected_frame_level >= 0)
3768 select_frame (save_selected_frame, save_selected_frame_level);
3769 value_free_to_mark (mark);
3775 enable_once_command (args, from_tty)
3779 map_breakpoint_numbers (args, enable_once_breakpoint);
3783 enable_delete_breakpoint (bpt)
3784 struct breakpoint *bpt;
3786 bpt->enable = enabled;
3787 bpt->disposition = del;
3789 check_duplicates (bpt->address);
3790 breakpoints_changed ();
3795 enable_delete_command (args, from_tty)
3799 map_breakpoint_numbers (args, enable_delete_breakpoint);
3802 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
3804 struct symtabs_and_lines
3805 decode_line_spec_1 (string, funfirstline)
3809 struct symtabs_and_lines sals;
3811 error ("Empty line specification.");
3812 if (default_breakpoint_valid)
3813 sals = decode_line_1 (&string, funfirstline,
3814 default_breakpoint_symtab, default_breakpoint_line,
3817 sals = decode_line_1 (&string, funfirstline,
3818 (struct symtab *)NULL, 0, (char ***)NULL);
3820 error ("Junk at end of line specification: %s", string);
3825 _initialize_breakpoint ()
3827 breakpoint_chain = 0;
3828 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3829 before a breakpoint is set. */
3830 breakpoint_count = 0;
3832 add_com ("ignore", class_breakpoint, ignore_command,
3833 "Set ignore-count of breakpoint number N to COUNT.\n\
3834 Usage is `ignore N COUNT'.");
3836 add_com ("commands", class_breakpoint, commands_command,
3837 "Set commands to be executed when a breakpoint is hit.\n\
3838 Give breakpoint number as argument after \"commands\".\n\
3839 With no argument, the targeted breakpoint is the last one set.\n\
3840 The commands themselves follow starting on the next line.\n\
3841 Type a line containing \"end\" to indicate the end of them.\n\
3842 Give \"silent\" as the first line to make the breakpoint silent;\n\
3843 then no output is printed when it is hit, except what the commands print.");
3845 add_com ("condition", class_breakpoint, condition_command,
3846 "Specify breakpoint number N to break only if COND is true.\n\
3847 Usage is `condition N COND', where N is an integer and COND is an\n\
3848 expression to be evaluated whenever breakpoint N is reached. ");
3850 add_com ("tbreak", class_breakpoint, tbreak_command,
3851 "Set a temporary breakpoint. Args like \"break\" command.\n\
3852 Like \"break\" except the breakpoint is only temporary,\n\
3853 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3854 by using \"enable delete\" on the breakpoint number.");
3856 add_com ("hbreak", class_breakpoint, hbreak_command,
3857 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3858 Like \"break\" except the breakpoint requires hardware support,\n\
3859 some target hardware may not have this support.");
3861 add_com ("thbreak", class_breakpoint, thbreak_command,
3862 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3863 Like \"hbreak\" except the breakpoint is only temporary,\n\
3864 so it will be deleted when hit.");
3866 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3867 "Enable some breakpoints.\n\
3868 Give breakpoint numbers (separated by spaces) as arguments.\n\
3869 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3870 This is used to cancel the effect of the \"disable\" command.\n\
3871 With a subcommand you can enable temporarily.",
3872 &enablelist, "enable ", 1, &cmdlist);
3874 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3875 "Enable some breakpoints.\n\
3876 Give breakpoint numbers (separated by spaces) as arguments.\n\
3877 This is used to cancel the effect of the \"disable\" command.\n\
3878 May be abbreviated to simply \"enable\".\n",
3879 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3881 add_cmd ("once", no_class, enable_once_command,
3882 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3883 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3886 add_cmd ("delete", no_class, enable_delete_command,
3887 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3888 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3891 add_cmd ("delete", no_class, enable_delete_command,
3892 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3893 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3896 add_cmd ("once", no_class, enable_once_command,
3897 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3898 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3901 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3902 "Disable some breakpoints.\n\
3903 Arguments are breakpoint numbers with spaces in between.\n\
3904 To disable all breakpoints, give no argument.\n\
3905 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3906 &disablelist, "disable ", 1, &cmdlist);
3907 add_com_alias ("dis", "disable", class_breakpoint, 1);
3908 add_com_alias ("disa", "disable", class_breakpoint, 1);
3910 add_cmd ("breakpoints", class_alias, disable_command,
3911 "Disable some breakpoints.\n\
3912 Arguments are breakpoint numbers with spaces in between.\n\
3913 To disable all breakpoints, give no argument.\n\
3914 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3915 This command may be abbreviated \"disable\".",
3918 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3919 "Delete some breakpoints or auto-display expressions.\n\
3920 Arguments are breakpoint numbers with spaces in between.\n\
3921 To delete all breakpoints, give no argument.\n\
3923 Also a prefix command for deletion of other GDB objects.\n\
3924 The \"unset\" command is also an alias for \"delete\".",
3925 &deletelist, "delete ", 1, &cmdlist);
3926 add_com_alias ("d", "delete", class_breakpoint, 1);
3928 add_cmd ("breakpoints", class_alias, delete_command,
3929 "Delete some breakpoints or auto-display expressions.\n\
3930 Arguments are breakpoint numbers with spaces in between.\n\
3931 To delete all breakpoints, give no argument.\n\
3932 This command may be abbreviated \"delete\".",
3935 add_com ("clear", class_breakpoint, clear_command,
3936 concat ("Clear breakpoint at specified line or function.\n\
3937 Argument may be line number, function name, or \"*\" and an address.\n\
3938 If line number is specified, all breakpoints in that line are cleared.\n\
3939 If function is specified, breakpoints at beginning of function are cleared.\n\
3940 If an address is specified, breakpoints at that address are cleared.\n\n",
3941 "With no argument, clears all breakpoints in the line that the selected frame\n\
3944 See also the \"delete\" command which clears breakpoints by number.", NULL));
3946 add_com ("break", class_breakpoint, break_command,
3947 concat ("Set breakpoint at specified line or function.\n\
3948 Argument may be line number, function name, or \"*\" and an address.\n\
3949 If line number is specified, break at start of code for that line.\n\
3950 If function is specified, break at start of code for that function.\n\
3951 If an address is specified, break at that exact address.\n",
3952 "With no arg, uses current execution address of selected stack frame.\n\
3953 This is useful for breaking on return to a stack frame.\n\
3955 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3957 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
3958 add_com_alias ("b", "break", class_run, 1);
3959 add_com_alias ("br", "break", class_run, 1);
3960 add_com_alias ("bre", "break", class_run, 1);
3961 add_com_alias ("brea", "break", class_run, 1);
3963 add_info ("breakpoints", breakpoints_info,
3964 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3965 The \"Type\" column indicates one of:\n\
3966 \tbreakpoint - normal breakpoint\n\
3967 \twatchpoint - watchpoint\n\
3968 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3969 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3970 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3971 address and file/line number respectively.\n\n",
3972 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3973 are set to the address of the last breakpoint listed.\n\n\
3974 Convenience variable \"$bpnum\" contains the number of the last\n\
3975 breakpoint set.", NULL));
3977 #if MAINTENANCE_CMDS
3979 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3980 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
3981 The \"Type\" column indicates one of:\n\
3982 \tbreakpoint - normal breakpoint\n\
3983 \twatchpoint - watchpoint\n\
3984 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3985 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3986 \tuntil - internal breakpoint used by the \"until\" command\n\
3987 \tfinish - internal breakpoint used by the \"finish\" command\n",
3988 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3989 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3990 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3991 address and file/line number respectively.\n\n",
3992 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3993 are set to the address of the last breakpoint listed.\n\n\
3994 Convenience variable \"$bpnum\" contains the number of the last\n\
3995 breakpoint set.", NULL),
3996 &maintenanceinfolist);
3998 #endif /* MAINTENANCE_CMDS */
4000 add_com ("catch", class_breakpoint, catch_command,
4001 "Set breakpoints to catch exceptions that are raised.\n\
4002 Argument may be a single exception to catch, multiple exceptions\n\
4003 to catch, or the default exception \"default\". If no arguments\n\
4004 are given, breakpoints are set at all exception handlers catch clauses\n\
4005 within the current scope.\n\
4007 A condition specified for the catch applies to all breakpoints set\n\
4008 with this command\n\
4010 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
4012 add_com ("watch", class_breakpoint, watch_command,
4013 "Set a watchpoint for an expression.\n\
4014 A watchpoint stops execution of your program whenever the value of\n\
4015 an expression changes.");
4017 add_com ("rwatch", class_breakpoint, rwatch_command,
4018 "Set a read watchpoint for an expression.\n\
4019 A watchpoint stops execution of your program whenever the value of\n\
4020 an expression is read.");
4022 add_com ("awatch", class_breakpoint, awatch_command,
4023 "Set a watchpoint for an expression.\n\
4024 A watchpoint stops execution of your program whenever the value of\n\
4025 an expression is either read or written.");
4027 add_info ("watchpoints", breakpoints_info,
4028 "Synonym for ``info breakpoints''.");