1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
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 warning ("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 /* We hit the shared library event breakpoint. */
1454 /* This is just used to count how many enums there are. */
1458 /* Here is the table which drives this routine. So that we can
1459 format it pretty, we define some abbreviations for the
1460 enum bpstat_what codes. */
1461 #define kc BPSTAT_WHAT_KEEP_CHECKING
1462 #define ss BPSTAT_WHAT_STOP_SILENT
1463 #define sn BPSTAT_WHAT_STOP_NOISY
1464 #define sgl BPSTAT_WHAT_SINGLE
1465 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
1466 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1467 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1468 #define sr BPSTAT_WHAT_STEP_RESUME
1469 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1470 #define shl BPSTAT_WHAT_CHECK_SHLIBS
1472 /* "Can't happen." Might want to print an error message.
1473 abort() is not out of the question, but chances are GDB is just
1474 a bit confused, not unusable. */
1475 #define err BPSTAT_WHAT_STOP_NOISY
1477 /* Given an old action and a class, come up with a new action. */
1478 /* One interesting property of this table is that wp_silent is the same
1479 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1480 after stopping, the check for whether to step over a breakpoint
1481 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1482 reference to how we stopped. We retain separate wp_silent and bp_silent
1483 codes in case we want to change that someday. */
1485 /* step_resume entries: a step resume breakpoint overrides another
1486 breakpoint of signal handling (see comment in wait_for_inferior
1487 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1488 /* We handle the through_sigtramp_breakpoint the same way; having both
1489 one of those and a step_resume_breakpoint is probably very rare (?). */
1491 static const enum bpstat_what_main_action
1492 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1495 /* kc ss sn sgl slr clr clrs sr ts shl
1497 /*no_effect*/ {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl},
1498 /*wp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl},
1499 /*wp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl},
1500 /*bp_nostop*/ {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl},
1501 /*bp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl},
1502 /*bp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl},
1503 /*long_jump*/ {slr, ss, sn, slr, err, err, err, sr, ts, shl},
1504 /*long_resume*/ {clr, ss, sn, clrs, err, err, err, sr, ts, shl},
1505 /*step_resume*/ {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl},
1506 /*through_sig*/ {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl},
1507 /*shlib*/ {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl}
1520 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1521 struct bpstat_what retval;
1523 retval.call_dummy = 0;
1524 for (; bs != NULL; bs = bs->next)
1526 enum class bs_class = no_effect;
1527 if (bs->breakpoint_at == NULL)
1528 /* I suspect this can happen if it was a momentary breakpoint
1529 which has since been deleted. */
1531 switch (bs->breakpoint_at->type)
1534 case bp_hardware_breakpoint:
1540 bs_class = bp_noisy;
1542 bs_class = bp_silent;
1545 bs_class = bp_nostop;
1548 case bp_hardware_watchpoint:
1549 case bp_read_watchpoint:
1550 case bp_access_watchpoint:
1554 bs_class = wp_noisy;
1556 bs_class = wp_silent;
1559 /* There was a watchpoint, but we're not stopping. This requires
1560 no further action. */
1561 bs_class = no_effect;
1564 bs_class = long_jump;
1566 case bp_longjmp_resume:
1567 bs_class = long_resume;
1569 case bp_step_resume:
1572 bs_class = step_resume;
1575 /* It is for the wrong frame. */
1576 bs_class = bp_nostop;
1578 case bp_through_sigtramp:
1579 bs_class = through_sig;
1581 case bp_watchpoint_scope:
1582 bs_class = bp_nostop;
1584 case bp_shlib_event:
1585 bs_class = shlib_event;
1588 /* Make sure the action is stop (silent or noisy), so infrun.c
1589 pops the dummy frame. */
1590 bs_class = bp_silent;
1591 retval.call_dummy = 1;
1594 current_action = table[(int)bs_class][(int)current_action];
1596 retval.main_action = current_action;
1600 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1601 without hardware support). This isn't related to a specific bpstat,
1602 just to things like whether watchpoints are set. */
1605 bpstat_should_step ()
1607 struct breakpoint *b;
1609 if (b->enable == enabled && b->type == bp_watchpoint)
1614 /* Print information on breakpoint number BNUM, or -1 if all.
1615 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1616 is nonzero, process only watchpoints. */
1619 breakpoint_1 (bnum, allflag)
1623 register struct breakpoint *b;
1624 register struct command_line *l;
1625 register struct symbol *sym;
1626 CORE_ADDR last_addr = (CORE_ADDR)-1;
1627 int found_a_breakpoint = 0;
1628 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1629 "until", "finish", "watchpoint",
1630 "hw watchpoint", "read watchpoint",
1631 "acc watchpoint", "longjmp",
1632 "longjmp resume", "step resume",
1634 "watchpoint scope", "call dummy",
1636 static char *bpdisps[] = {"del", "dis", "keep"};
1637 static char bpenables[] = "ny";
1638 char wrap_indent[80];
1642 || bnum == b->number)
1644 /* We only print out user settable breakpoints unless the allflag is set. */
1646 && b->type != bp_breakpoint
1647 && b->type != bp_hardware_breakpoint
1648 && b->type != bp_watchpoint
1649 && b->type != bp_read_watchpoint
1650 && b->type != bp_access_watchpoint
1651 && b->type != bp_hardware_watchpoint)
1654 if (!found_a_breakpoint++)
1656 annotate_breakpoints_headers ();
1659 printf_filtered ("Num ");
1661 printf_filtered ("Type ");
1663 printf_filtered ("Disp ");
1665 printf_filtered ("Enb ");
1669 printf_filtered ("Address ");
1672 printf_filtered ("What\n");
1674 annotate_breakpoints_table ();
1679 printf_filtered ("%-3d ", b->number);
1681 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1683 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1685 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1687 strcpy (wrap_indent, " ");
1689 strcat (wrap_indent, " ");
1693 case bp_hardware_watchpoint:
1694 case bp_read_watchpoint:
1695 case bp_access_watchpoint:
1696 /* Field 4, the address, is omitted (which makes the columns
1697 not line up too nicely with the headers, but the effect
1698 is relatively readable). */
1700 print_expression (b->exp, gdb_stdout);
1704 case bp_hardware_breakpoint:
1708 case bp_longjmp_resume:
1709 case bp_step_resume:
1710 case bp_through_sigtramp:
1711 case bp_watchpoint_scope:
1713 case bp_shlib_event:
1717 /* FIXME-32x64: need a print_address_numeric with
1721 local_hex_string_custom
1722 ((unsigned long) b->address, "08l"));
1727 last_addr = b->address;
1730 sym = find_pc_function (b->address);
1733 fputs_filtered ("in ", gdb_stdout);
1734 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1735 wrap_here (wrap_indent);
1736 fputs_filtered (" at ", gdb_stdout);
1738 fputs_filtered (b->source_file, gdb_stdout);
1739 printf_filtered (":%d", b->line_number);
1742 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1746 printf_filtered ("\n");
1752 printf_filtered ("\tstop only in stack frame at ");
1753 print_address_numeric (b->frame, 1, gdb_stdout);
1754 printf_filtered ("\n");
1761 printf_filtered ("\tstop only if ");
1762 print_expression (b->cond, gdb_stdout);
1763 printf_filtered ("\n");
1766 if (show_breakpoint_hit_counts && b->hit_count)
1768 /* FIXME should make an annotation for this */
1770 printf_filtered ("\tbreakpoint already hit %d time%s\n",
1771 b->hit_count, (b->hit_count == 1 ? "" : "s"));
1774 if (b->ignore_count)
1778 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1781 if ((l = b->commands))
1787 print_command_line (l, 4);
1793 if (!found_a_breakpoint)
1796 printf_filtered ("No breakpoints or watchpoints.\n");
1798 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1801 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1802 that a comparison of an unsigned with -1 is always false. */
1803 if (last_addr != (CORE_ADDR)-1)
1804 set_next_address (last_addr);
1806 annotate_breakpoints_table_end ();
1811 breakpoints_info (bnum_exp, from_tty)
1818 bnum = parse_and_eval_address (bnum_exp);
1820 breakpoint_1 (bnum, 0);
1823 #if MAINTENANCE_CMDS
1827 maintenance_info_breakpoints (bnum_exp, from_tty)
1834 bnum = parse_and_eval_address (bnum_exp);
1836 breakpoint_1 (bnum, 1);
1841 /* Print a message describing any breakpoints set at PC. */
1844 describe_other_breakpoints (pc)
1845 register CORE_ADDR pc;
1847 register int others = 0;
1848 register struct breakpoint *b;
1851 if (b->address == pc)
1855 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1857 if (b->address == pc)
1863 (b->enable == disabled) ? " (disabled)" : "",
1864 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1866 printf_filtered ("also set at pc ");
1867 print_address_numeric (pc, 1, gdb_stdout);
1868 printf_filtered (".\n");
1872 /* Set the default place to put a breakpoint
1873 for the `break' command with no arguments. */
1876 set_default_breakpoint (valid, addr, symtab, line)
1879 struct symtab *symtab;
1882 default_breakpoint_valid = valid;
1883 default_breakpoint_address = addr;
1884 default_breakpoint_symtab = symtab;
1885 default_breakpoint_line = line;
1888 /* Rescan breakpoints at address ADDRESS,
1889 marking the first one as "first" and any others as "duplicates".
1890 This is so that the bpt instruction is only inserted once. */
1893 check_duplicates (address)
1896 register struct breakpoint *b;
1897 register int count = 0;
1899 if (address == 0) /* Watchpoints are uninteresting */
1903 if (b->enable != disabled && b->address == address)
1906 b->duplicate = count > 1;
1910 /* Low level routine to set a breakpoint.
1911 Takes as args the three things that every breakpoint must have.
1912 Returns the breakpoint object so caller can set other things.
1913 Does not set the breakpoint number!
1914 Does not print anything.
1916 ==> This routine should not be called if there is a chance of later
1917 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1918 your arguments BEFORE calling this routine! */
1920 static struct breakpoint *
1921 set_raw_breakpoint (sal)
1922 struct symtab_and_line sal;
1924 register struct breakpoint *b, *b1;
1926 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1927 memset (b, 0, sizeof (*b));
1928 b->address = sal.pc;
1929 if (sal.symtab == NULL)
1930 b->source_file = NULL;
1932 b->source_file = savestring (sal.symtab->filename,
1933 strlen (sal.symtab->filename));
1934 b->language = current_language->la_language;
1935 b->input_radix = input_radix;
1937 b->line_number = sal.line;
1938 b->enable = enabled;
1941 b->ignore_count = 0;
1945 /* Add this breakpoint to the end of the chain
1946 so that a list of breakpoints will come out in order
1947 of increasing numbers. */
1949 b1 = breakpoint_chain;
1951 breakpoint_chain = b;
1959 check_duplicates (sal.pc);
1960 breakpoints_changed ();
1965 static int internal_breakpoint_number = -1;
1968 create_longjmp_breakpoint (func_name)
1971 struct symtab_and_line sal;
1972 struct breakpoint *b;
1974 if (func_name != NULL)
1976 struct minimal_symbol *m;
1978 m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL);
1980 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1990 b = set_raw_breakpoint (sal);
1993 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1994 b->disposition = donttouch;
1995 b->enable = disabled;
1998 b->addr_string = strsave(func_name);
1999 b->number = internal_breakpoint_number--;
2002 /* Call this routine when stepping and nexting to enable a breakpoint if we do
2003 a longjmp(). When we hit that breakpoint, call
2004 set_longjmp_resume_breakpoint() to figure out where we are going. */
2007 enable_longjmp_breakpoint()
2009 register struct breakpoint *b;
2012 if (b->type == bp_longjmp)
2014 b->enable = enabled;
2015 check_duplicates (b->address);
2020 disable_longjmp_breakpoint()
2022 register struct breakpoint *b;
2025 if ( b->type == bp_longjmp
2026 || b->type == bp_longjmp_resume)
2028 b->enable = disabled;
2029 check_duplicates (b->address);
2035 remove_solib_event_breakpoints ()
2037 register struct breakpoint *b;
2040 if (b->type == bp_shlib_event)
2041 delete_breakpoint (b);
2045 create_solib_event_breakpoint (address)
2048 struct breakpoint *b;
2049 struct symtab_and_line sal;
2054 b = set_raw_breakpoint (sal);
2055 b->number = internal_breakpoint_number--;
2056 b->disposition = donttouch;
2057 b->type = bp_shlib_event;
2062 hw_breakpoint_used_count()
2064 register struct breakpoint *b;
2069 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2077 hw_watchpoint_used_count(type, other_type_used)
2079 int *other_type_used;
2081 register struct breakpoint *b;
2084 *other_type_used = 0;
2087 if (b->enable == enabled)
2089 if (b->type == type) i++;
2090 else if ((b->type == bp_hardware_watchpoint ||
2091 b->type == bp_read_watchpoint ||
2092 b->type == bp_access_watchpoint)
2093 && b->enable == enabled)
2094 *other_type_used = 1;
2100 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2101 breakpoint at the target of the jmp_buf.
2103 FIXME - This ought to be done by setting a temporary breakpoint that gets
2104 deleted automatically...
2108 set_longjmp_resume_breakpoint(pc, frame)
2110 struct frame_info *frame;
2112 register struct breakpoint *b;
2115 if (b->type == bp_longjmp_resume)
2118 b->enable = enabled;
2120 b->frame = frame->frame;
2123 check_duplicates (b->address);
2128 /* Set a breakpoint that will evaporate an end of command
2129 at address specified by SAL.
2130 Restrict it to frame FRAME if FRAME is nonzero. */
2133 set_momentary_breakpoint (sal, frame, type)
2134 struct symtab_and_line sal;
2135 struct frame_info *frame;
2138 register struct breakpoint *b;
2139 b = set_raw_breakpoint (sal);
2141 b->enable = enabled;
2142 b->disposition = donttouch;
2143 b->frame = (frame ? frame->frame : 0);
2145 /* If we're debugging a multi-threaded program, then we
2146 want momentary breakpoints to be active in only a
2147 single thread of control. */
2148 if (in_thread_list (inferior_pid))
2149 b->thread = pid_to_thread_id (inferior_pid);
2156 clear_momentary_breakpoints ()
2158 register struct breakpoint *b;
2160 if (b->disposition == delete)
2162 delete_breakpoint (b);
2168 /* Tell the user we have just set a breakpoint B. */
2172 struct breakpoint *b;
2176 /* FIXME: This is misplaced; mention() is called by things (like hitting a
2177 watchpoint) other than breakpoint creation. It should be possible to
2178 clean this up and at the same time replace the random calls to
2179 breakpoint_changed with this hook, as has already been done for
2180 delete_breakpoint_hook and so on. */
2181 if (create_breakpoint_hook)
2182 create_breakpoint_hook (b);
2187 printf_filtered ("Watchpoint %d: ", b->number);
2188 print_expression (b->exp, gdb_stdout);
2190 case bp_hardware_watchpoint:
2191 printf_filtered ("Hardware watchpoint %d: ", b->number);
2192 print_expression (b->exp, gdb_stdout);
2194 case bp_read_watchpoint:
2195 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2196 print_expression (b->exp, gdb_stdout);
2198 case bp_access_watchpoint:
2199 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2200 print_expression (b->exp, gdb_stdout);
2203 printf_filtered ("Breakpoint %d", b->number);
2206 case bp_hardware_breakpoint:
2207 printf_filtered ("Hardware assisted breakpoint %d", b->number);
2213 case bp_longjmp_resume:
2214 case bp_step_resume:
2215 case bp_through_sigtramp:
2217 case bp_watchpoint_scope:
2222 if (addressprint || b->source_file == NULL)
2224 printf_filtered (" at ");
2225 print_address_numeric (b->address, 1, gdb_stdout);
2228 printf_filtered (": file %s, line %d.",
2229 b->source_file, b->line_number);
2231 printf_filtered ("\n");
2235 /* Nobody calls this currently. */
2236 /* Set a breakpoint from a symtab and line.
2237 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2238 ADDR_STRING is a malloc'd string holding the name of where we are
2239 setting the breakpoint. This is used later to re-set it after the
2240 program is relinked and symbols are reloaded.
2241 Print the same confirmation messages that the breakpoint command prints. */
2244 set_breakpoint (s, line, tempflag, addr_string)
2250 register struct breakpoint *b;
2251 struct symtab_and_line sal;
2256 resolve_sal_pc (&sal); /* Might error out */
2257 describe_other_breakpoints (sal.pc);
2259 b = set_raw_breakpoint (sal);
2260 set_breakpoint_count (breakpoint_count + 1);
2261 b->number = breakpoint_count;
2262 b->type = bp_breakpoint;
2264 b->addr_string = addr_string;
2265 b->enable = enabled;
2266 b->disposition = tempflag ? delete : donttouch;
2272 /* Set a breakpoint according to ARG (function, linenum or *address)
2273 flag: first bit : 0 non-temporary, 1 temporary.
2274 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2277 break_command_1 (arg, flag, from_tty)
2281 int tempflag, hardwareflag;
2282 struct symtabs_and_lines sals;
2283 struct symtab_and_line sal;
2284 register struct expression *cond = 0;
2285 register struct breakpoint *b;
2287 /* Pointers in arg to the start, and one past the end, of the condition. */
2288 char *cond_start = NULL;
2289 char *cond_end = NULL;
2290 /* Pointers in arg to the start, and one past the end,
2291 of the address part. */
2292 char *addr_start = NULL;
2293 char *addr_end = NULL;
2294 struct cleanup *old_chain;
2295 struct cleanup *canonical_strings_chain = NULL;
2296 char **canonical = (char **)NULL;
2300 hardwareflag = flag & BP_HARDWAREFLAG;
2301 tempflag = flag & BP_TEMPFLAG;
2306 sal.line = sal.pc = sal.end = 0;
2309 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2311 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2312 && (arg[2] == ' ' || arg[2] == '\t')))
2314 if (default_breakpoint_valid)
2316 sals.sals = (struct symtab_and_line *)
2317 xmalloc (sizeof (struct symtab_and_line));
2318 sal.pc = default_breakpoint_address;
2319 sal.line = default_breakpoint_line;
2320 sal.symtab = default_breakpoint_symtab;
2325 error ("No default breakpoint address now.");
2331 /* Force almost all breakpoints to be in terms of the
2332 current_source_symtab (which is decode_line_1's default). This
2333 should produce the results we want almost all of the time while
2334 leaving default_breakpoint_* alone. */
2335 if (default_breakpoint_valid
2336 && (!current_source_symtab
2337 || (arg && (*arg == '+' || *arg == '-'))))
2338 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2339 default_breakpoint_line, &canonical);
2341 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2349 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2350 the following `for' loop errors out. */
2351 old_chain = make_cleanup (free, sals.sals);
2352 if (canonical != (char **)NULL)
2354 make_cleanup (free, canonical);
2355 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2356 for (i = 0; i < sals.nelts; i++)
2358 if (canonical[i] != NULL)
2359 make_cleanup (free, canonical[i]);
2363 thread = -1; /* No specific thread yet */
2365 /* Resolve all line numbers to PC's, and verify that conditions
2366 can be parsed, before setting any breakpoints. */
2367 for (i = 0; i < sals.nelts; i++)
2369 char *tok, *end_tok;
2372 resolve_sal_pc (&sals.sals[i]);
2378 while (*tok == ' ' || *tok == '\t')
2383 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2386 toklen = end_tok - tok;
2388 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2390 tok = cond_start = end_tok + 1;
2391 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2394 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2400 thread = strtol (tok, &tok, 0);
2402 error ("Junk after thread keyword.");
2403 if (!valid_thread_id (thread))
2404 error ("Unknown thread %d\n", thread);
2407 error ("Junk at end of arguments.");
2412 int i, target_resources_ok;
2414 i = hw_breakpoint_used_count ();
2415 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
2416 bp_hardware_breakpoint, i + sals.nelts, 0);
2417 if (target_resources_ok == 0)
2418 error ("No hardware breakpoint support in the target.");
2419 else if (target_resources_ok < 0)
2420 error ("Hardware breakpoints used exceeds limit.");
2423 /* Remove the canonical strings from the cleanup, they are needed below. */
2424 if (canonical != (char **)NULL)
2425 discard_cleanups (canonical_strings_chain);
2427 /* Now set all the breakpoints. */
2428 for (i = 0; i < sals.nelts; i++)
2433 describe_other_breakpoints (sal.pc);
2435 b = set_raw_breakpoint (sal);
2436 set_breakpoint_count (breakpoint_count + 1);
2437 b->number = breakpoint_count;
2438 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2442 /* If a canonical line spec is needed use that instead of the
2444 if (canonical != (char **)NULL && canonical[i] != NULL)
2445 b->addr_string = canonical[i];
2446 else if (addr_start)
2447 b->addr_string = savestring (addr_start, addr_end - addr_start);
2449 b->cond_string = savestring (cond_start, cond_end - cond_start);
2451 b->enable = enabled;
2452 b->disposition = tempflag ? del : donttouch;
2459 printf_filtered ("Multiple breakpoints were set.\n");
2460 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2462 do_cleanups (old_chain);
2465 /* Helper function for break_command_1 and disassemble_command. */
2468 resolve_sal_pc (sal)
2469 struct symtab_and_line *sal;
2473 if (sal->pc == 0 && sal->symtab != 0)
2475 pc = find_line_pc (sal->symtab, sal->line);
2477 error ("No line %d in file \"%s\".",
2478 sal->line, sal->symtab->filename);
2484 break_command (arg, from_tty)
2488 break_command_1 (arg, 0, from_tty);
2492 tbreak_command (arg, from_tty)
2496 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2500 hbreak_command (arg, from_tty)
2504 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2508 thbreak_command (arg, from_tty)
2512 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2516 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2519 watch_command_1 (arg, accessflag, from_tty)
2524 struct breakpoint *b;
2525 struct symtab_and_line sal;
2526 struct expression *exp;
2527 struct block *exp_valid_block;
2528 struct value *val, *mark;
2529 struct frame_info *frame, *prev_frame;
2530 char *exp_start = NULL;
2531 char *exp_end = NULL;
2532 char *tok, *end_tok;
2534 char *cond_start = NULL;
2535 char *cond_end = NULL;
2536 struct expression *cond = NULL;
2537 int i, other_type_used, target_resources_ok;
2538 enum bptype bp_type;
2545 /* Parse arguments. */
2546 innermost_block = NULL;
2548 exp = parse_exp_1 (&arg, 0, 0);
2550 exp_valid_block = innermost_block;
2551 mark = value_mark ();
2552 val = evaluate_expression (exp);
2553 release_value (val);
2554 if (VALUE_LAZY (val))
2555 value_fetch_lazy (val);
2558 while (*tok == ' ' || *tok == '\t')
2562 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2565 toklen = end_tok - tok;
2566 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2568 tok = cond_start = end_tok + 1;
2569 cond = parse_exp_1 (&tok, 0, 0);
2573 error("Junk at end of command.");
2575 if (accessflag == 1) bp_type = bp_read_watchpoint;
2576 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2577 else bp_type = bp_hardware_watchpoint;
2579 mem_cnt = can_use_hardware_watchpoint (val);
2580 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2581 error ("Expression cannot be implemented with read/access watchpoint.");
2583 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2584 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2585 bp_type, i + mem_cnt, other_type_used);
2586 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2587 error ("Target does not have this type of hardware watchpoint support.");
2588 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2589 error ("Target resources have been allocated for other types of watchpoints.");
2592 /* Now set up the breakpoint. */
2593 b = set_raw_breakpoint (sal);
2594 set_breakpoint_count (breakpoint_count + 1);
2595 b->number = breakpoint_count;
2596 b->disposition = donttouch;
2598 b->exp_valid_block = exp_valid_block;
2599 b->exp_string = savestring (exp_start, exp_end - exp_start);
2603 b->cond_string = savestring (cond_start, cond_end - cond_start);
2607 frame = block_innermost_frame (exp_valid_block);
2610 prev_frame = get_prev_frame (frame);
2611 b->watchpoint_frame = frame->frame;
2614 b->watchpoint_frame = (CORE_ADDR)0;
2616 if (mem_cnt && target_resources_ok > 0)
2619 b->type = bp_watchpoint;
2621 /* If the expression is "local", then set up a "watchpoint scope"
2622 breakpoint at the point where we've left the scope of the watchpoint
2624 if (innermost_block)
2626 struct breakpoint *scope_breakpoint;
2627 struct symtab_and_line scope_sal;
2631 scope_sal.pc = get_frame_pc (prev_frame);
2632 scope_sal.symtab = NULL;
2635 scope_breakpoint = set_raw_breakpoint (scope_sal);
2636 set_breakpoint_count (breakpoint_count + 1);
2637 scope_breakpoint->number = breakpoint_count;
2639 scope_breakpoint->type = bp_watchpoint_scope;
2640 scope_breakpoint->enable = enabled;
2642 /* Automatically delete the breakpoint when it hits. */
2643 scope_breakpoint->disposition = del;
2645 /* Only break in the proper frame (help with recursion). */
2646 scope_breakpoint->frame = prev_frame->frame;
2648 /* Set the address at which we will stop. */
2649 scope_breakpoint->address = get_frame_pc (prev_frame);
2651 /* The scope breakpoint is related to the watchpoint. We
2652 will need to act on them together. */
2653 b->related_breakpoint = scope_breakpoint;
2656 value_free_to_mark (mark);
2660 /* Return count of locations need to be watched and can be handled
2661 in hardware. If the watchpoint can not be handled
2662 in hardware return zero. */
2665 can_use_hardware_watchpoint (v)
2668 int found_memory_cnt = 0;
2670 /* Make sure all the intermediate values are in memory. Also make sure
2671 we found at least one memory expression. Guards against watch 0x12345,
2672 which is meaningless, but could cause errors if one tries to insert a
2673 hardware watchpoint for the constant expression. */
2674 for ( ; v; v = v->next)
2676 if (v->lval == lval_memory)
2678 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2681 else if (v->lval != not_lval && v->modifiable == 0)
2685 /* The expression itself looks suitable for using a hardware
2686 watchpoint, but give the target machine a chance to reject it. */
2687 return found_memory_cnt;
2690 static void watch_command (arg, from_tty)
2694 watch_command_1 (arg, 0, from_tty);
2697 static void rwatch_command (arg, from_tty)
2701 watch_command_1 (arg, 1, from_tty);
2704 static void awatch_command (arg, from_tty)
2708 watch_command_1 (arg, 2, from_tty);
2712 /* Helper routine for the until_command routine in infcmd.c. Here
2713 because it uses the mechanisms of breakpoints. */
2717 until_break_command (arg, from_tty)
2721 struct symtabs_and_lines sals;
2722 struct symtab_and_line sal;
2723 struct frame_info *prev_frame = get_prev_frame (selected_frame);
2724 struct breakpoint *breakpoint;
2725 struct cleanup *old_chain;
2727 clear_proceed_status ();
2729 /* Set a breakpoint where the user wants it and at return from
2732 if (default_breakpoint_valid)
2733 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2734 default_breakpoint_line, (char ***)NULL);
2736 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2738 if (sals.nelts != 1)
2739 error ("Couldn't get information on specified line.");
2742 free ((PTR)sals.sals); /* malloc'd, so freed */
2745 error ("Junk at end of arguments.");
2747 resolve_sal_pc (&sal);
2749 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2751 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2753 /* Keep within the current frame */
2757 sal = find_pc_line (prev_frame->pc, 0);
2758 sal.pc = prev_frame->pc;
2759 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2760 make_cleanup(delete_breakpoint, breakpoint);
2763 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2764 do_cleanups(old_chain);
2768 /* These aren't used; I don't konw what they were for. */
2769 /* Set a breakpoint at the catch clause for NAME. */
2771 catch_breakpoint (name)
2777 disable_catch_breakpoint ()
2782 delete_catch_breakpoint ()
2787 enable_catch_breakpoint ()
2794 struct sal_chain *next;
2795 struct symtab_and_line sal;
2799 /* This isn't used; I don't know what it was for. */
2800 /* For each catch clause identified in ARGS, run FUNCTION
2801 with that clause as an argument. */
2802 static struct symtabs_and_lines
2803 map_catch_names (args, function)
2807 register char *p = args;
2809 struct symtabs_and_lines sals;
2811 struct sal_chain *sal_chain = 0;
2815 error_no_arg ("one or more catch names");
2823 /* Don't swallow conditional part. */
2824 if (p1[0] == 'i' && p1[1] == 'f'
2825 && (p1[2] == ' ' || p1[2] == '\t'))
2831 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2835 if (*p1 && *p1 != ' ' && *p1 != '\t')
2836 error ("Arguments must be catch names.");
2842 struct sal_chain *next
2843 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2844 next->next = sal_chain;
2845 next->sal = get_catch_sal (p);
2850 printf_unfiltered ("No catch clause for exception %s.\n", p);
2855 while (*p == ' ' || *p == '\t') p++;
2860 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2862 static struct symtabs_and_lines
2863 get_catch_sals (this_level_only)
2864 int this_level_only;
2866 register struct blockvector *bl;
2867 register struct block *block;
2868 int index, have_default = 0;
2870 struct symtabs_and_lines sals;
2871 struct sal_chain *sal_chain = 0;
2872 char *blocks_searched;
2874 /* Not sure whether an error message is always the correct response,
2875 but it's better than a core dump. */
2876 if (selected_frame == NULL)
2877 error ("No selected frame.");
2878 block = get_frame_block (selected_frame);
2879 pc = selected_frame->pc;
2885 error ("No symbol table info available.\n");
2887 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2888 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2889 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2893 CORE_ADDR end = BLOCK_END (block) - 4;
2896 if (bl != blockvector_for_pc (end, &index))
2897 error ("blockvector blotch");
2898 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2899 error ("blockvector botch");
2900 last_index = BLOCKVECTOR_NBLOCKS (bl);
2903 /* Don't print out blocks that have gone by. */
2904 while (index < last_index
2905 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2908 while (index < last_index
2909 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2911 if (blocks_searched[index] == 0)
2913 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2916 register struct symbol *sym;
2918 nsyms = BLOCK_NSYMS (b);
2920 for (i = 0; i < nsyms; i++)
2922 sym = BLOCK_SYM (b, i);
2923 if (STREQ (SYMBOL_NAME (sym), "default"))
2929 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2931 struct sal_chain *next = (struct sal_chain *)
2932 alloca (sizeof (struct sal_chain));
2933 next->next = sal_chain;
2934 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2938 blocks_searched[index] = 1;
2944 if (sal_chain && this_level_only)
2947 /* After handling the function's top-level block, stop.
2948 Don't continue to its superblock, the block of
2949 per-file symbols. */
2950 if (BLOCK_FUNCTION (block))
2952 block = BLOCK_SUPERBLOCK (block);
2957 struct sal_chain *tmp_chain;
2959 /* Count the number of entries. */
2960 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2961 tmp_chain = tmp_chain->next)
2965 sals.sals = (struct symtab_and_line *)
2966 xmalloc (index * sizeof (struct symtab_and_line));
2967 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2968 sals.sals[index] = sal_chain->sal;
2974 /* Commands to deal with catching exceptions. */
2977 catch_command_1 (arg, tempflag, from_tty)
2982 /* First, translate ARG into something we can deal with in terms
2985 struct symtabs_and_lines sals;
2986 struct symtab_and_line sal;
2987 register struct expression *cond = 0;
2988 register struct breakpoint *b;
2992 sal.line = sal.pc = sal.end = 0;
2995 /* If no arg given, or if first arg is 'if ', all active catch clauses
2996 are breakpointed. */
2998 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2999 && (arg[2] == ' ' || arg[2] == '\t')))
3001 /* Grab all active catch clauses. */
3002 sals = get_catch_sals (0);
3006 /* Grab selected catch clauses. */
3007 error ("catch NAME not implemented");
3009 /* This isn't used; I don't know what it was for. */
3010 sals = map_catch_names (arg, catch_breakpoint);
3018 for (i = 0; i < sals.nelts; i++)
3020 resolve_sal_pc (&sals.sals[i]);
3024 if (arg[0] == 'i' && arg[1] == 'f'
3025 && (arg[2] == ' ' || arg[2] == '\t'))
3026 cond = parse_exp_1 ((arg += 2, &arg),
3027 block_for_pc (sals.sals[i].pc), 0);
3029 error ("Junk at end of arguments.");
3034 for (i = 0; i < sals.nelts; i++)
3039 describe_other_breakpoints (sal.pc);
3041 b = set_raw_breakpoint (sal);
3042 set_breakpoint_count (breakpoint_count + 1);
3043 b->number = breakpoint_count;
3044 b->type = bp_breakpoint;
3046 b->enable = enabled;
3047 b->disposition = tempflag ? del : donttouch;
3054 printf_unfiltered ("Multiple breakpoints were set.\n");
3055 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3057 free ((PTR)sals.sals);
3060 /* Used by the gui, could be made a worker for other things. */
3063 set_breakpoint_sal (sal)
3064 struct symtab_and_line sal;
3066 struct breakpoint *b;
3067 b = set_raw_breakpoint (sal);
3068 set_breakpoint_count (breakpoint_count + 1);
3069 b->number = breakpoint_count;
3070 b->type = bp_breakpoint;
3077 /* These aren't used; I don't know what they were for. */
3078 /* Disable breakpoints on all catch clauses described in ARGS. */
3080 disable_catch (args)
3083 /* Map the disable command to catch clauses described in ARGS. */
3086 /* Enable breakpoints on all catch clauses described in ARGS. */
3091 /* Map the disable command to catch clauses described in ARGS. */
3094 /* Delete breakpoints on all catch clauses in the active scope. */
3099 /* Map the delete command to catch clauses described in ARGS. */
3104 catch_command (arg, from_tty)
3108 catch_command_1 (arg, 0, from_tty);
3112 clear_command (arg, from_tty)
3116 register struct breakpoint *b, *b1;
3117 struct symtabs_and_lines sals;
3118 struct symtab_and_line sal;
3119 register struct breakpoint *found;
3124 sals = decode_line_spec (arg, 1);
3128 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3129 sal.line = default_breakpoint_line;
3130 sal.symtab = default_breakpoint_symtab;
3132 if (sal.symtab == 0)
3133 error ("No source file specified.");
3139 for (i = 0; i < sals.nelts; i++)
3141 /* If exact pc given, clear bpts at that pc.
3142 But if sal.pc is zero, clear all bpts on specified line. */
3144 found = (struct breakpoint *) 0;
3145 while (breakpoint_chain
3147 ? breakpoint_chain->address == sal.pc
3148 : (breakpoint_chain->source_file != NULL
3149 && sal.symtab != NULL
3150 && STREQ (breakpoint_chain->source_file,
3151 sal.symtab->filename)
3152 && breakpoint_chain->line_number == sal.line)))
3154 b1 = breakpoint_chain;
3155 breakpoint_chain = b1->next;
3162 && b->next->type != bp_watchpoint
3163 && b->next->type != bp_hardware_watchpoint
3164 && b->next->type != bp_read_watchpoint
3165 && b->next->type != bp_access_watchpoint
3167 ? b->next->address == sal.pc
3168 : (b->next->source_file != NULL
3169 && sal.symtab != NULL
3170 && STREQ (b->next->source_file, sal.symtab->filename)
3171 && b->next->line_number == sal.line)))
3182 error ("No breakpoint at %s.", arg);
3184 error ("No breakpoint at this line.");
3187 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3188 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3189 breakpoints_changed ();
3192 if (from_tty) printf_unfiltered ("%d ", found->number);
3194 delete_breakpoint (found);
3197 if (from_tty) putchar_unfiltered ('\n');
3199 free ((PTR)sals.sals);
3202 /* Delete breakpoint in BS if they are `delete' breakpoints.
3203 This is called after any breakpoint is hit, or after errors. */
3206 breakpoint_auto_delete (bs)
3209 for (; bs; bs = bs->next)
3210 if (bs->breakpoint_at && bs->breakpoint_at->disposition == del
3212 delete_breakpoint (bs->breakpoint_at);
3215 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3218 delete_breakpoint (bpt)
3219 struct breakpoint *bpt;
3221 register struct breakpoint *b;
3224 if (delete_breakpoint_hook)
3225 delete_breakpoint_hook (bpt);
3228 remove_breakpoint (bpt);
3230 if (breakpoint_chain == bpt)
3231 breakpoint_chain = bpt->next;
3236 b->next = bpt->next;
3240 check_duplicates (bpt->address);
3241 /* If this breakpoint was inserted, and there is another breakpoint
3242 at the same address, we need to insert the other breakpoint. */
3244 && bpt->type != bp_hardware_watchpoint
3245 && bpt->type != bp_read_watchpoint
3246 && bpt->type != bp_access_watchpoint)
3249 if (b->address == bpt->address
3251 && b->enable != disabled)
3254 val = target_insert_breakpoint (b->address, b->shadow_contents);
3257 target_terminal_ours_for_output ();
3258 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3259 memory_error (val, b->address); /* which bombs us out */
3266 free_command_lines (&bpt->commands);
3269 if (bpt->cond_string != NULL)
3270 free (bpt->cond_string);
3271 if (bpt->addr_string != NULL)
3272 free (bpt->addr_string);
3273 if (bpt->exp_string != NULL)
3274 free (bpt->exp_string);
3275 if (bpt->source_file != NULL)
3276 free (bpt->source_file);
3278 /* Be sure no bpstat's are pointing at it after it's been freed. */
3279 /* FIXME, how can we find all bpstat's?
3280 We just check stop_bpstat for now. */
3281 for (bs = stop_bpstat; bs; bs = bs->next)
3282 if (bs->breakpoint_at == bpt)
3283 bs->breakpoint_at = NULL;
3288 delete_command (arg, from_tty)
3295 /* Ask user only if there are some breakpoints to delete. */
3297 || (breakpoint_chain && query ("Delete all breakpoints? ")))
3299 /* No arg; clear all breakpoints. */
3300 while (breakpoint_chain)
3301 delete_breakpoint (breakpoint_chain);
3305 map_breakpoint_numbers (arg, delete_breakpoint);
3308 /* Reset a breakpoint given it's struct breakpoint * BINT.
3309 The value we return ends up being the return value from catch_errors.
3310 Unused in this case. */
3313 breakpoint_re_set_one (bint)
3316 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3319 struct symtabs_and_lines sals;
3321 enum enable save_enable;
3326 case bp_hardware_breakpoint:
3327 if (b->addr_string == NULL)
3329 /* Anything without a string can't be re-set. */
3330 delete_breakpoint (b);
3333 /* In case we have a problem, disable this breakpoint. We'll restore
3334 its status if we succeed. */
3335 save_enable = b->enable;
3336 b->enable = disabled;
3338 set_language (b->language);
3339 input_radix = b->input_radix;
3341 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3342 for (i = 0; i < sals.nelts; i++)
3344 resolve_sal_pc (&sals.sals[i]);
3346 /* Reparse conditions, they might contain references to the
3348 if (b->cond_string != NULL)
3352 free ((PTR)b->cond);
3353 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3356 /* We need to re-set the breakpoint if the address changes...*/
3357 if (b->address != sals.sals[i].pc
3358 /* ...or new and old breakpoints both have source files, and
3359 the source file name or the line number changes... */
3360 || (b->source_file != NULL
3361 && sals.sals[i].symtab != NULL
3362 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3363 || b->line_number != sals.sals[i].line)
3365 /* ...or we switch between having a source file and not having
3367 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3370 if (b->source_file != NULL)
3371 free (b->source_file);
3372 if (sals.sals[i].symtab == NULL)
3373 b->source_file = NULL;
3376 savestring (sals.sals[i].symtab->filename,
3377 strlen (sals.sals[i].symtab->filename));
3378 b->line_number = sals.sals[i].line;
3379 b->address = sals.sals[i].pc;
3381 check_duplicates (b->address);
3385 /* Might be better to do this just once per breakpoint_re_set,
3386 rather than once for every breakpoint. */
3387 breakpoints_changed ();
3389 b->enable = save_enable; /* Restore it, this worked. */
3391 free ((PTR)sals.sals);
3395 case bp_hardware_watchpoint:
3396 case bp_read_watchpoint:
3397 case bp_access_watchpoint:
3398 innermost_block = NULL;
3399 /* The issue arises of what context to evaluate this in. The same
3400 one as when it was set, but what does that mean when symbols have
3401 been re-read? We could save the filename and functionname, but
3402 if the context is more local than that, the best we could do would
3403 be something like how many levels deep and which index at that
3404 particular level, but that's going to be less stable than filenames
3405 or functionnames. */
3406 /* So for now, just use a global context. */
3407 b->exp = parse_expression (b->exp_string);
3408 b->exp_valid_block = innermost_block;
3409 mark = value_mark ();
3410 b->val = evaluate_expression (b->exp);
3411 release_value (b->val);
3412 if (VALUE_LAZY (b->val))
3413 value_fetch_lazy (b->val);
3415 if (b->cond_string != NULL)
3418 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3420 if (b->enable == enabled)
3422 value_free_to_mark (mark);
3426 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3431 case bp_longjmp_resume:
3432 case bp_watchpoint_scope:
3434 delete_breakpoint (b);
3437 /* This breakpoint is special, it's set up when the inferior
3438 starts and we really don't want to touch it. */
3439 case bp_shlib_event:
3446 /* Re-set all breakpoints after symbols have been re-loaded. */
3448 breakpoint_re_set ()
3450 struct breakpoint *b, *temp;
3451 enum language save_language;
3452 int save_input_radix;
3453 static char message1[] = "Error in re-setting breakpoint %d:\n";
3454 char message[sizeof (message1) + 30 /* slop */];
3456 save_language = current_language->la_language;
3457 save_input_radix = input_radix;
3458 ALL_BREAKPOINTS_SAFE (b, temp)
3460 sprintf (message, message1, b->number); /* Format possible error msg */
3461 catch_errors (breakpoint_re_set_one, (char *) b, message,
3464 set_language (save_language);
3465 input_radix = save_input_radix;
3467 #ifdef GET_LONGJMP_TARGET
3468 create_longjmp_breakpoint ("longjmp");
3469 create_longjmp_breakpoint ("_longjmp");
3470 create_longjmp_breakpoint ("siglongjmp");
3471 create_longjmp_breakpoint (NULL);
3475 /* Took this out (temporarily at least), since it produces an extra
3476 blank line at startup. This messes up the gdbtests. -PB */
3477 /* Blank line to finish off all those mention() messages we just printed. */
3478 printf_filtered ("\n");
3482 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3483 If from_tty is nonzero, it prints a message to that effect,
3484 which ends with a period (no newline). */
3487 set_ignore_count (bptnum, count, from_tty)
3488 int bptnum, count, from_tty;
3490 register struct breakpoint *b;
3496 if (b->number == bptnum)
3498 b->ignore_count = count;
3501 else if (count == 0)
3502 printf_filtered ("Will stop next time breakpoint %d is reached.",
3504 else if (count == 1)
3505 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3508 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3510 breakpoints_changed ();
3514 error ("No breakpoint number %d.", bptnum);
3517 /* Clear the ignore counts of all breakpoints. */
3519 breakpoint_clear_ignore_counts ()
3521 struct breakpoint *b;
3524 b->ignore_count = 0;
3527 /* Command to set ignore-count of breakpoint N to COUNT. */
3530 ignore_command (args, from_tty)
3538 error_no_arg ("a breakpoint number");
3540 num = get_number (&p);
3543 error ("Second argument (specified ignore-count) is missing.");
3545 set_ignore_count (num,
3546 longest_to_int (value_as_long (parse_and_eval (p))),
3548 printf_filtered ("\n");
3549 breakpoints_changed ();
3552 /* Call FUNCTION on each of the breakpoints
3553 whose numbers are given in ARGS. */
3556 map_breakpoint_numbers (args, function)
3558 void (*function) PARAMS ((struct breakpoint *));
3560 register char *p = args;
3563 register struct breakpoint *b;
3566 error_no_arg ("one or more breakpoint numbers");
3572 num = get_number (&p1);
3575 if (b->number == num)
3577 struct breakpoint *related_breakpoint = b->related_breakpoint;
3579 if (related_breakpoint)
3580 function (related_breakpoint);
3583 printf_unfiltered ("No breakpoint number %d.\n", num);
3590 enable_breakpoint (bpt)
3591 struct breakpoint *bpt;
3593 struct frame_info *save_selected_frame = NULL;
3594 int save_selected_frame_level = -1;
3595 int target_resources_ok, other_type_used;
3598 if (bpt->type == bp_hardware_breakpoint)
3601 i = hw_breakpoint_used_count();
3602 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3603 bp_hardware_breakpoint, i+1, 0);
3604 if (target_resources_ok == 0)
3605 error ("No hardware breakpoint support in the target.");
3606 else if (target_resources_ok < 0)
3607 error ("Hardware breakpoints used exceeds limit.");
3609 bpt->enable = enabled;
3610 check_duplicates (bpt->address);
3612 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3613 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3615 if (bpt->exp_valid_block != NULL)
3617 struct frame_info *fr =
3618 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3622 Cannot enable watchpoint %d because the block in which its expression\n\
3623 is valid is not currently in scope.\n", bpt->number);
3624 bpt->enable = disabled;
3628 save_selected_frame = selected_frame;
3629 save_selected_frame_level = selected_frame_level;
3630 select_frame (fr, -1);
3633 value_free (bpt->val);
3634 mark = value_mark ();
3635 bpt->val = evaluate_expression (bpt->exp);
3636 release_value (bpt->val);
3637 if (VALUE_LAZY (bpt->val))
3638 value_fetch_lazy (bpt->val);
3640 if (bpt->type == bp_hardware_watchpoint ||
3641 bpt->type == bp_read_watchpoint ||
3642 bpt->type == bp_access_watchpoint)
3644 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3645 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
3647 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3648 bpt->type, i + mem_cnt, other_type_used);
3649 /* we can consider of type is bp_hardware_watchpoint, convert to
3650 bp_watchpoint in the following condition */
3651 if (target_resources_ok < 0)
3654 Cannot enable watchpoint %d because target watch resources\n\
3655 have been allocated for other watchpoints.\n", bpt->number);
3656 bpt->enable = disabled;
3657 value_free_to_mark (mark);
3662 if (save_selected_frame_level >= 0)
3663 select_frame (save_selected_frame, save_selected_frame_level);
3664 value_free_to_mark (mark);
3667 if (modify_breakpoint_hook)
3668 modify_breakpoint_hook (bpt);
3673 enable_command (args, from_tty)
3677 struct breakpoint *bpt;
3679 ALL_BREAKPOINTS (bpt)
3683 case bp_hardware_breakpoint:
3685 case bp_hardware_watchpoint:
3686 case bp_read_watchpoint:
3687 case bp_access_watchpoint:
3688 enable_breakpoint (bpt);
3693 map_breakpoint_numbers (args, enable_breakpoint);
3697 disable_breakpoint (bpt)
3698 struct breakpoint *bpt;
3700 /* Never disable a watchpoint scope breakpoint; we want to
3701 hit them when we leave scope so we can delete both the
3702 watchpoint and its scope breakpoint at that time. */
3703 if (bpt->type == bp_watchpoint_scope)
3706 bpt->enable = disabled;
3708 check_duplicates (bpt->address);
3710 if (modify_breakpoint_hook)
3711 modify_breakpoint_hook (bpt);
3716 disable_command (args, from_tty)
3720 register struct breakpoint *bpt;
3722 ALL_BREAKPOINTS (bpt)
3726 case bp_hardware_breakpoint:
3728 case bp_hardware_watchpoint:
3729 case bp_read_watchpoint:
3730 case bp_access_watchpoint:
3731 disable_breakpoint (bpt);
3736 map_breakpoint_numbers (args, disable_breakpoint);
3740 enable_once_breakpoint (bpt)
3741 struct breakpoint *bpt;
3743 struct frame_info *save_selected_frame = NULL;
3744 int save_selected_frame_level = -1;
3745 int target_resources_ok, other_type_used;
3748 if (bpt->type == bp_hardware_breakpoint)
3751 i = hw_breakpoint_used_count();
3752 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3753 bp_hardware_breakpoint, i+1, 0);
3754 if (target_resources_ok == 0)
3755 error ("No hardware breakpoint support in the target.");
3756 else if (target_resources_ok < 0)
3757 error ("Hardware breakpoints used exceeds limit.");
3760 bpt->enable = enabled;
3761 bpt->disposition = disable;
3762 check_duplicates (bpt->address);
3763 breakpoints_changed ();
3765 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3766 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3768 if (bpt->exp_valid_block != NULL)
3770 struct frame_info *fr =
3771 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3775 Cannot enable watchpoint %d because the block in which its expression\n\
3776 is valid is not currently in scope.\n", bpt->number);
3777 bpt->enable = disabled;
3781 save_selected_frame = selected_frame;
3782 save_selected_frame_level = selected_frame_level;
3783 select_frame (fr, -1);
3786 value_free (bpt->val);
3787 mark = value_mark ();
3788 bpt->val = evaluate_expression (bpt->exp);
3789 release_value (bpt->val);
3790 if (VALUE_LAZY (bpt->val))
3791 value_fetch_lazy (bpt->val);
3793 if (bpt->type == bp_hardware_watchpoint ||
3794 bpt->type == bp_read_watchpoint ||
3795 bpt->type == bp_access_watchpoint)
3797 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3798 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3799 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3800 bpt->type, i+mem_cnt, other_type_used);
3801 /* we can consider of type is bp_hardware_watchpoint, convert to
3802 bp_watchpoint in the following condition */
3803 if (target_resources_ok < 0)
3806 Cannot enable watchpoint %d because target watch resources\n\
3807 have been allocated for other watchpoints.\n", bpt->number);
3808 bpt->enable = disabled;
3809 value_free_to_mark (mark);
3813 if (save_selected_frame_level >= 0)
3814 select_frame (save_selected_frame, save_selected_frame_level);
3815 value_free_to_mark (mark);
3821 enable_once_command (args, from_tty)
3825 map_breakpoint_numbers (args, enable_once_breakpoint);
3829 enable_delete_breakpoint (bpt)
3830 struct breakpoint *bpt;
3832 bpt->enable = enabled;
3833 bpt->disposition = del;
3835 check_duplicates (bpt->address);
3836 breakpoints_changed ();
3841 enable_delete_command (args, from_tty)
3845 map_breakpoint_numbers (args, enable_delete_breakpoint);
3848 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
3850 struct symtabs_and_lines
3851 decode_line_spec_1 (string, funfirstline)
3855 struct symtabs_and_lines sals;
3857 error ("Empty line specification.");
3858 if (default_breakpoint_valid)
3859 sals = decode_line_1 (&string, funfirstline,
3860 default_breakpoint_symtab, default_breakpoint_line,
3863 sals = decode_line_1 (&string, funfirstline,
3864 (struct symtab *)NULL, 0, (char ***)NULL);
3866 error ("Junk at end of line specification: %s", string);
3871 _initialize_breakpoint ()
3873 breakpoint_chain = 0;
3874 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3875 before a breakpoint is set. */
3876 breakpoint_count = 0;
3878 add_com ("ignore", class_breakpoint, ignore_command,
3879 "Set ignore-count of breakpoint number N to COUNT.\n\
3880 Usage is `ignore N COUNT'.");
3882 add_com ("commands", class_breakpoint, commands_command,
3883 "Set commands to be executed when a breakpoint is hit.\n\
3884 Give breakpoint number as argument after \"commands\".\n\
3885 With no argument, the targeted breakpoint is the last one set.\n\
3886 The commands themselves follow starting on the next line.\n\
3887 Type a line containing \"end\" to indicate the end of them.\n\
3888 Give \"silent\" as the first line to make the breakpoint silent;\n\
3889 then no output is printed when it is hit, except what the commands print.");
3891 add_com ("condition", class_breakpoint, condition_command,
3892 "Specify breakpoint number N to break only if COND is true.\n\
3893 Usage is `condition N COND', where N is an integer and COND is an\n\
3894 expression to be evaluated whenever breakpoint N is reached. ");
3896 add_com ("tbreak", class_breakpoint, tbreak_command,
3897 "Set a temporary breakpoint. Args like \"break\" command.\n\
3898 Like \"break\" except the breakpoint is only temporary,\n\
3899 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3900 by using \"enable delete\" on the breakpoint number.");
3902 add_com ("hbreak", class_breakpoint, hbreak_command,
3903 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3904 Like \"break\" except the breakpoint requires hardware support,\n\
3905 some target hardware may not have this support.");
3907 add_com ("thbreak", class_breakpoint, thbreak_command,
3908 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3909 Like \"hbreak\" except the breakpoint is only temporary,\n\
3910 so it will be deleted when hit.");
3912 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3913 "Enable some breakpoints.\n\
3914 Give breakpoint numbers (separated by spaces) as arguments.\n\
3915 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3916 This is used to cancel the effect of the \"disable\" command.\n\
3917 With a subcommand you can enable temporarily.",
3918 &enablelist, "enable ", 1, &cmdlist);
3920 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3921 "Enable some breakpoints.\n\
3922 Give breakpoint numbers (separated by spaces) as arguments.\n\
3923 This is used to cancel the effect of the \"disable\" command.\n\
3924 May be abbreviated to simply \"enable\".\n",
3925 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3927 add_cmd ("once", no_class, enable_once_command,
3928 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3929 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3932 add_cmd ("delete", no_class, enable_delete_command,
3933 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3934 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3937 add_cmd ("delete", no_class, enable_delete_command,
3938 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3939 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3942 add_cmd ("once", no_class, enable_once_command,
3943 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3944 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3947 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3948 "Disable some breakpoints.\n\
3949 Arguments are breakpoint numbers with spaces in between.\n\
3950 To disable all breakpoints, give no argument.\n\
3951 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3952 &disablelist, "disable ", 1, &cmdlist);
3953 add_com_alias ("dis", "disable", class_breakpoint, 1);
3954 add_com_alias ("disa", "disable", class_breakpoint, 1);
3956 add_cmd ("breakpoints", class_alias, disable_command,
3957 "Disable some breakpoints.\n\
3958 Arguments are breakpoint numbers with spaces in between.\n\
3959 To disable all breakpoints, give no argument.\n\
3960 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3961 This command may be abbreviated \"disable\".",
3964 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3965 "Delete some breakpoints or auto-display expressions.\n\
3966 Arguments are breakpoint numbers with spaces in between.\n\
3967 To delete all breakpoints, give no argument.\n\
3969 Also a prefix command for deletion of other GDB objects.\n\
3970 The \"unset\" command is also an alias for \"delete\".",
3971 &deletelist, "delete ", 1, &cmdlist);
3972 add_com_alias ("d", "delete", class_breakpoint, 1);
3974 add_cmd ("breakpoints", class_alias, delete_command,
3975 "Delete some breakpoints or auto-display expressions.\n\
3976 Arguments are breakpoint numbers with spaces in between.\n\
3977 To delete all breakpoints, give no argument.\n\
3978 This command may be abbreviated \"delete\".",
3981 add_com ("clear", class_breakpoint, clear_command,
3982 concat ("Clear breakpoint at specified line or function.\n\
3983 Argument may be line number, function name, or \"*\" and an address.\n\
3984 If line number is specified, all breakpoints in that line are cleared.\n\
3985 If function is specified, breakpoints at beginning of function are cleared.\n\
3986 If an address is specified, breakpoints at that address are cleared.\n\n",
3987 "With no argument, clears all breakpoints in the line that the selected frame\n\
3990 See also the \"delete\" command which clears breakpoints by number.", NULL));
3992 add_com ("break", class_breakpoint, break_command,
3993 concat ("Set breakpoint at specified line or function.\n\
3994 Argument may be line number, function name, or \"*\" and an address.\n\
3995 If line number is specified, break at start of code for that line.\n\
3996 If function is specified, break at start of code for that function.\n\
3997 If an address is specified, break at that exact address.\n",
3998 "With no arg, uses current execution address of selected stack frame.\n\
3999 This is useful for breaking on return to a stack frame.\n\
4001 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
4003 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
4004 add_com_alias ("b", "break", class_run, 1);
4005 add_com_alias ("br", "break", class_run, 1);
4006 add_com_alias ("bre", "break", class_run, 1);
4007 add_com_alias ("brea", "break", class_run, 1);
4009 add_info ("breakpoints", breakpoints_info,
4010 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
4011 The \"Type\" column indicates one of:\n\
4012 \tbreakpoint - normal breakpoint\n\
4013 \twatchpoint - watchpoint\n\
4014 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
4015 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
4016 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
4017 address and file/line number respectively.\n\n",
4018 "Convenience variable \"$_\" and default examine address for \"x\"\n\
4019 are set to the address of the last breakpoint listed.\n\n\
4020 Convenience variable \"$bpnum\" contains the number of the last\n\
4021 breakpoint set.", NULL));
4023 #if MAINTENANCE_CMDS
4025 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
4026 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
4027 The \"Type\" column indicates one of:\n\
4028 \tbreakpoint - normal breakpoint\n\
4029 \twatchpoint - watchpoint\n\
4030 \tlongjmp - internal breakpoint used to step through longjmp()\n\
4031 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
4032 \tuntil - internal breakpoint used by the \"until\" command\n\
4033 \tfinish - internal breakpoint used by the \"finish\" command\n",
4034 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
4035 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
4036 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
4037 address and file/line number respectively.\n\n",
4038 "Convenience variable \"$_\" and default examine address for \"x\"\n\
4039 are set to the address of the last breakpoint listed.\n\n\
4040 Convenience variable \"$bpnum\" contains the number of the last\n\
4041 breakpoint set.", NULL),
4042 &maintenanceinfolist);
4044 #endif /* MAINTENANCE_CMDS */
4046 add_com ("catch", class_breakpoint, catch_command,
4047 "Set breakpoints to catch exceptions that are raised.\n\
4048 Argument may be a single exception to catch, multiple exceptions\n\
4049 to catch, or the default exception \"default\". If no arguments\n\
4050 are given, breakpoints are set at all exception handlers catch clauses\n\
4051 within the current scope.\n\
4053 A condition specified for the catch applies to all breakpoints set\n\
4054 with this command\n\
4056 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
4058 add_com ("watch", class_breakpoint, watch_command,
4059 "Set a watchpoint for an expression.\n\
4060 A watchpoint stops execution of your program whenever the value of\n\
4061 an expression changes.");
4063 add_com ("rwatch", class_breakpoint, rwatch_command,
4064 "Set a read watchpoint for an expression.\n\
4065 A watchpoint stops execution of your program whenever the value of\n\
4066 an expression is read.");
4068 add_com ("awatch", class_breakpoint, awatch_command,
4069 "Set a watchpoint for an expression.\n\
4070 A watchpoint stops execution of your program whenever the value of\n\
4071 an expression is either read or written.");
4073 add_info ("watchpoints", breakpoints_info,
4074 "Synonym for ``info breakpoints''.");