1 /* Everything about breakpoints, for GDB.
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26 /* This is the sequence of bytes we insert for a breakpoint. */
28 static char break_insn[] = BREAKPOINT;
30 /* States of enablement of breakpoint.
31 `temporary' means disable when hit.
32 `delete' means delete when hit. */
34 enum enable { disabled, enabled, temporary, delete};
36 /* Not that the ->silent field is not currently used by any commands
37 (though the code is in there if it was to be and set_raw_breakpoint
38 does set it to 0). I implemented it because I thought it would be
39 useful for a hack I had to put in; I'm going to leave it in because
40 I can see how there might be times when it would indeed be useful */
44 struct breakpoint *next;
45 /* Number assigned to distinguish breakpoints. */
47 /* Address to break at. */
49 /* Line number of this address. Redundant. */
51 /* Symtab of file of this address. Redundant. */
52 struct symtab *symtab;
53 /* Zero means disabled; remember the info but don't break here. */
55 /* Non-zero means a silent breakpoint (don't print frame info
58 /* Number of stops at this breakpoint that should
59 be continued automatically before really stopping. */
61 /* "Real" contents of byte where breakpoint has been inserted.
62 Valid only when breakpoints are in the program. */
63 char shadow_contents[sizeof break_insn];
64 /* Nonzero if this breakpoint is now inserted. */
66 /* Nonzero if this is not the first breakpoint in the list
67 for the given address. */
69 /* Chain of command lines to execute when this breakpoint is hit. */
70 struct command_line *commands;
71 /* Stack depth (address of frame). If nonzero, break only if fp
74 /* Conditional. Break only if this expression's value is nonzero. */
75 struct expression *cond;
78 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
80 /* Chain of all breakpoints defined. */
82 struct breakpoint *breakpoint_chain;
84 /* Number of last breakpoint made. */
86 static int breakpoint_count;
88 /* Default address, symtab and line to put a breakpoint at
89 for "break" command with no arg.
90 if default_breakpoint_valid is zero, the other three are
91 not valid, and "break" with no arg is an error.
93 This set by print_stack_frame, which calls set_default_breakpoint. */
95 int default_breakpoint_valid;
96 CORE_ADDR default_breakpoint_address;
97 struct symtab *default_breakpoint_symtab;
98 int default_breakpoint_line;
100 /* Remaining commands (not yet executed)
101 of last breakpoint hit. */
103 struct command_line *breakpoint_commands;
105 static void delete_breakpoint ();
106 void clear_momentary_breakpoints ();
107 void breakpoint_auto_delete ();
109 /* Flag indicating extra verbosity for xgdb. */
110 extern int xgdb_verbose;
112 /* condition N EXP -- set break condition of breakpoint N to EXP. */
115 condition_command (arg, from_tty)
119 register struct breakpoint *b;
122 register struct expression *expr;
125 error_no_arg ("breakpoint number");
128 while (*p >= '0' && *p <= '9') p++;
130 /* There is no number here. (e.g. "cond a == b"). */
131 error_no_arg ("breakpoint number");
135 if (b->number == bnum)
143 printf ("Breakpoint %d now unconditional.\n", bnum);
147 if (*p != ' ' && *p != '\t')
148 error ("Arguments must be an integer (breakpoint number) and an expression.");
150 /* Find start of expression */
151 while (*p == ' ' || *p == '\t') p++;
154 b->cond = (struct expression *) parse_c_1 (&arg, block_for_pc (b->address), 0);
156 error ("Junk at end of expression");
161 error ("No breakpoint number %d.", bnum);
165 commands_command (arg)
168 register struct breakpoint *b;
169 register char *p, *p1;
171 struct command_line *l;
173 /* If we allowed this, we would have problems with when to
174 free the storage, if we change the commands currently
177 if (breakpoint_commands)
178 error ("Can't use the \"commands\" command among a breakpoint's commands.");
180 /* Allow commands by itself to refer to the last breakpoint. */
182 bnum = breakpoint_count;
186 if (! (*p >= '0' && *p <= '9'))
187 error ("Argument must be integer (a breakpoint number).");
189 while (*p >= '0' && *p <= '9') p++;
191 error ("Unexpected extra arguments following breakpoint number.");
197 if (b->number == bnum)
199 if (input_from_terminal_p ())
201 printf ("Type commands for when breakpoint %d is hit, one per line.\n\
202 End with a line saying just \"end\".\n", bnum);
205 l = read_command_lines ();
206 free_command_lines (&b->commands);
210 error ("No breakpoint number %d.", bnum);
213 /* Called from command loop to execute the commands
214 associated with the breakpoint we just stopped at. */
217 do_breakpoint_commands ()
219 while (breakpoint_commands)
221 char *line = breakpoint_commands->line;
222 breakpoint_commands = breakpoint_commands->next;
223 execute_command (line, 0);
224 /* If command was "cont", breakpoint_commands is now 0,
225 of if we stopped at yet another breakpoint which has commands,
226 it is now the commands for the new breakpoint. */
228 clear_momentary_breakpoints ();
231 /* Used when the program is proceeded, to eliminate any remaining
232 commands attached to the previous breakpoint we stopped at. */
235 clear_breakpoint_commands ()
237 breakpoint_commands = 0;
238 breakpoint_auto_delete (0);
241 /* Functions to get and set the current list of pending
242 breakpoint commands. These are used by run_stack_dummy
243 to preserve the commands around a function call. */
245 struct command_line *
246 get_breakpoint_commands ()
248 return breakpoint_commands;
252 set_breakpoint_commands (cmds)
253 struct command_line *cmds;
255 breakpoint_commands = cmds;
258 /* insert_breakpoints is used when starting or continuing the program.
259 remove_breakpoints is used when the program stops.
260 Both return zero if successful,
261 or an `errno' value if could not write the inferior. */
264 insert_breakpoints ()
266 register struct breakpoint *b;
269 #ifdef BREAKPOINT_DEBUG
270 printf ("Inserting breakpoints.\n");
271 #endif /* BREAKPOINT_DEBUG */
274 if (b->enable != disabled && ! b->inserted && ! b->duplicate)
276 read_memory (b->address, b->shadow_contents, sizeof break_insn);
277 val = write_memory (b->address, break_insn, sizeof break_insn);
280 #ifdef BREAKPOINT_DEBUG
281 printf ("Inserted breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
282 b->address, b->shadow_contents[0], b->shadow_contents[1]);
283 #endif /* BREAKPOINT_DEBUG */
290 remove_breakpoints ()
292 register struct breakpoint *b;
295 #ifdef BREAKPOINT_DEBUG
296 printf ("Removing breakpoints.\n");
297 #endif /* BREAKPOINT_DEBUG */
302 val = write_memory (b->address, b->shadow_contents, sizeof break_insn);
306 #ifdef BREAKPOINT_DEBUG
307 printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
308 b->address, b->shadow_contents[0], b->shadow_contents[1]);
309 #endif /* BREAKPOINT_DEBUG */
315 /* Clear the "inserted" flag in all breakpoints.
316 This is done when the inferior is loaded. */
319 mark_breakpoints_out ()
321 register struct breakpoint *b;
327 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
328 When continuing from a location with a breakpoint,
329 we actually single step once before calling insert_breakpoints. */
332 breakpoint_here_p (pc)
335 register struct breakpoint *b;
338 if (b->enable != disabled && b->address == pc)
344 /* Evaluate the expression EXP and return 1 if value is zero.
345 This is used inside a catch_errors to evaluate the breakpoint condition. */
348 breakpoint_cond_eval (exp)
349 struct expression *exp;
351 return value_zerop (evaluate_expression (exp));
354 /* Return 0 if PC is not the address just after a breakpoint,
355 or -1 if breakpoint says do not stop now,
356 or -2 if breakpoint says it has deleted itself and don't stop,
357 or -3 if hit a breakpoint number -3 (delete when program stops),
358 or else the number of the breakpoint,
359 with 0x1000000 added (or subtracted, for a negative return value) for
360 a silent breakpoint. */
363 breakpoint_stop_status (pc, frame_address)
365 FRAME_ADDR frame_address;
367 register struct breakpoint *b;
368 register int cont = 0;
370 /* Get the address where the breakpoint would have been. */
371 pc -= DECR_PC_AFTER_BREAK;
374 if (b->enable != disabled && b->address == pc)
376 if (b->frame && b->frame != frame_address)
383 /* Need to select the frame, with all that implies
384 so that the conditions will have the right context. */
385 select_frame (get_current_frame (), 0);
387 = catch_errors (breakpoint_cond_eval, b->cond,
388 "Error occurred in testing breakpoint condition.");
391 if (b->cond && value_zero)
395 else if (b->ignore_count > 0)
402 if (b->enable == temporary)
403 b->enable = disabled;
404 breakpoint_commands = b->commands;
406 || (breakpoint_commands
407 && !strcmp ("silent", breakpoint_commands->line)))
409 if (breakpoint_commands)
410 breakpoint_commands = breakpoint_commands->next;
411 return (b->number > 0 ?
412 0x1000000 + b->number :
413 b->number - 0x1000000);
427 register struct breakpoint *b;
428 register struct command_line *l;
429 register struct symbol *sym;
430 CORE_ADDR last_addr = (CORE_ADDR)-1;
433 if (bnum == -1 || bnum == b->number)
435 printf_filtered ("#%-3d %c 0x%08x ", b->number,
436 "nyod"[(int) b->enable],
438 last_addr = b->address;
441 sym = find_pc_function (b->address);
443 printf_filtered (" in %s (%s line %d)", SYMBOL_NAME (sym),
444 b->symtab->filename, b->line_number);
446 printf_filtered ("%s line %d", b->symtab->filename, b->line_number);
453 if (find_pc_partial_function (b->address, &name, &addr))
455 if (b->address - addr)
456 printf_filtered ("<%s+%d>", name, b->address - addr);
458 printf_filtered ("<%s>", name);
462 printf_filtered ("\n");
465 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
467 printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame);
470 printf_filtered ("\tbreak only if ");
471 print_expression (b->cond, stdout);
472 printf_filtered ("\n");
477 printf_filtered ("\t%s\n", l->line);
482 /* Compare against (CORE_ADDR)-1 in case some compiler decides
483 that a comparison of an unsigned with -1 is always false. */
484 if (last_addr != (CORE_ADDR)-1)
485 set_next_address (last_addr);
489 breakpoints_info (bnum_exp)
495 bnum = parse_and_eval_address (bnum_exp);
496 else if (breakpoint_chain == 0)
497 printf_filtered ("No breakpoints.\n");
499 printf_filtered ("Breakpoints:\n\
500 Num Enb Address Where\n");
505 /* Print a message describing any breakpoints set at PC. */
508 describe_other_breakpoints (pc)
509 register CORE_ADDR pc;
511 register int others = 0;
512 register struct breakpoint *b;
515 if (b->address == pc)
519 printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
521 if (b->address == pc)
526 (b->enable == disabled) ? " (disabled)" : "",
527 (others > 1) ? "," : ((others == 1) ? " and" : ""));
529 printf ("also set at pc 0x%x.\n", pc);
533 /* Set the default place to put a breakpoint
534 for the `break' command with no arguments. */
537 set_default_breakpoint (valid, addr, symtab, line)
540 struct symtab *symtab;
543 default_breakpoint_valid = valid;
544 default_breakpoint_address = addr;
545 default_breakpoint_symtab = symtab;
546 default_breakpoint_line = line;
549 /* Rescan breakpoints at address ADDRESS,
550 marking the first one as "first" and any others as "duplicates".
551 This is so that the bpt instruction is only inserted once. */
554 check_duplicates (address)
557 register struct breakpoint *b;
558 register int count = 0;
561 if (b->enable != disabled && b->address == address)
564 b->duplicate = count > 1;
568 /* Low level routine to set a breakpoint.
569 Takes as args the three things that every breakpoint must have.
570 Returns the breakpoint object so caller can set other things.
571 Does not set the breakpoint number!
572 Does not print anything. */
574 static struct breakpoint *
575 set_raw_breakpoint (sal)
576 struct symtab_and_line sal;
578 register struct breakpoint *b, *b1;
580 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
581 bzero (b, sizeof *b);
583 b->symtab = sal.symtab;
584 b->line_number = sal.line;
589 /* Add this breakpoint to the end of the chain
590 so that a list of breakpoints will come out in order
591 of increasing numbers. */
593 b1 = breakpoint_chain;
595 breakpoint_chain = b;
603 check_duplicates (sal.pc);
608 /* Set a breakpoint that will evaporate an end of command
609 at address specified by SAL.
610 Restrict it to frame FRAME if FRAME is nonzero. */
613 set_momentary_breakpoint (sal, frame)
614 struct symtab_and_line sal;
617 register struct breakpoint *b;
618 b = set_raw_breakpoint (sal);
621 b->frame = (frame ? FRAME_FP (frame) : 0);
625 clear_momentary_breakpoints ()
627 register struct breakpoint *b;
631 delete_breakpoint (b);
636 /* Set a breakpoint from a symtab and line.
637 If TEMPFLAG is nonzero, it is a temporary breakpoint.
638 Print the same confirmation messages that the breakpoint command prints. */
641 set_breakpoint (s, line, tempflag)
646 register struct breakpoint *b;
647 struct symtab_and_line sal;
651 sal.pc = find_line_pc (sal.symtab, sal.line);
653 error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
656 describe_other_breakpoints (sal.pc);
658 b = set_raw_breakpoint (sal);
659 b->number = ++breakpoint_count;
662 b->enable = temporary;
664 printf ("Breakpoint %d at 0x%x", b->number, b->address);
666 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
671 /* Set a breakpoint according to ARG (function, linenum or *address)
672 and make it temporary if TEMPFLAG is nonzero. */
675 break_command_1 (arg, tempflag, from_tty)
677 int tempflag, from_tty;
679 struct symtabs_and_lines sals;
680 struct symtab_and_line sal;
681 register struct expression *cond = 0;
682 register struct breakpoint *b;
690 sal.line = sal.pc = sal.end = 0;
693 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
695 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
696 && (arg[2] == ' ' || arg[2] == '\t')))
698 if (default_breakpoint_valid)
700 sals.sals = (struct symtab_and_line *)
701 malloc (sizeof (struct symtab_and_line));
702 sal.pc = default_breakpoint_address;
703 sal.line = default_breakpoint_line;
704 sal.symtab = default_breakpoint_symtab;
709 error ("No default breakpoint address now.");
712 /* Force almost all breakpoints to be in terms of the
713 current_source_symtab (which is decode_line_1's default). This
714 should produce the results we want almost all of the time while
715 leaving default_breakpoint_* alone. */
716 if (default_breakpoint_valid
717 && (!current_source_symtab
718 || (arg && (*arg == '+' || *arg == '-'))))
719 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
720 default_breakpoint_line);
722 sals = decode_line_1 (&arg, 1, 0, 0);
728 for (i = 0; i < sals.nelts; i++)
731 if (sal.pc == 0 && sal.symtab != 0)
733 pc = find_line_pc (sal.symtab, sal.line);
735 error ("No line %d in file \"%s\".",
736 sal.line, sal.symtab->filename);
743 if (arg[0] == 'i' && arg[1] == 'f'
744 && (arg[2] == ' ' || arg[2] == '\t'))
745 cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
746 block_for_pc (pc), 0);
748 error ("Junk at end of arguments.");
751 sals.sals[i].pc = pc;
754 for (i = 0; i < sals.nelts; i++)
759 describe_other_breakpoints (sal.pc);
761 b = set_raw_breakpoint (sal);
762 b->number = ++breakpoint_count;
765 b->enable = temporary;
767 printf ("Breakpoint %d at 0x%x", b->number, b->address);
769 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
775 printf ("Multiple breakpoints were set.\n");
776 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
782 break_command (arg, from_tty)
786 break_command_1 (arg, 0, from_tty);
790 tbreak_command (arg, from_tty)
794 break_command_1 (arg, 1, from_tty);
798 * Helper routine for the until_command routine in infcmd.c. Here
799 * because it uses the mechanisms of breakpoints.
802 until_break_command (arg, from_tty)
806 struct symtabs_and_lines sals;
807 struct symtab_and_line sal;
808 FRAME prev_frame = get_prev_frame (selected_frame);
810 clear_proceed_status ();
812 /* Set a breakpoint where the user wants it and at return from
815 if (default_breakpoint_valid)
816 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
817 default_breakpoint_line);
819 sals = decode_line_1 (&arg, 1, 0, 0);
822 error ("Couldn't get information on specified line.");
825 free (sals.sals); /* malloc'd, so freed */
828 error ("Junk at end of arguments.");
830 if (sal.pc == 0 && sal.symtab != 0)
831 sal.pc = find_line_pc (sal.symtab, sal.line);
834 error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
836 set_momentary_breakpoint (sal, selected_frame);
838 /* Keep within the current frame */
842 struct frame_info *fi;
844 fi = get_frame_info (prev_frame);
845 sal = find_pc_line (fi->pc, 0);
847 set_momentary_breakpoint (sal, prev_frame);
854 clear_command (arg, from_tty)
858 register struct breakpoint *b, *b1;
859 struct symtabs_and_lines sals;
860 struct symtab_and_line sal;
861 register struct breakpoint *found;
866 sals = decode_line_spec (arg, 1);
870 sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line));
871 sal.line = default_breakpoint_line;
872 sal.symtab = default_breakpoint_symtab;
875 error ("No source file specified.");
881 for (i = 0; i < sals.nelts; i++)
883 /* If exact pc given, clear bpts at that pc.
884 But if sal.pc is zero, clear all bpts on specified line. */
886 found = (struct breakpoint *) 0;
887 while (breakpoint_chain
888 && (sal.pc ? breakpoint_chain->address == sal.pc
889 : (breakpoint_chain->symtab == sal.symtab
890 && breakpoint_chain->line_number == sal.line)))
892 b1 = breakpoint_chain;
893 breakpoint_chain = b1->next;
900 && (sal.pc ? b->next->address == sal.pc
901 : (b->next->symtab == sal.symtab
902 && b->next->line_number == sal.line)))
911 error ("No breakpoint at %s.", arg);
913 if (found->next) from_tty = 1; /* Always report if deleted more than one */
914 if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
917 if (from_tty) printf ("%d ", found->number);
919 delete_breakpoint (found);
922 if (from_tty) putchar ('\n');
927 /* Delete breakpoint number BNUM if it is a `delete' breakpoint.
928 This is called after breakpoint BNUM has been hit.
929 Also delete any breakpoint numbered -3 unless there are breakpoint
930 commands to be executed. */
933 breakpoint_auto_delete (bnum)
936 register struct breakpoint *b;
939 if (b->number == bnum)
941 if (b->enable == delete)
942 delete_breakpoint (b);
945 if (breakpoint_commands == 0)
946 clear_momentary_breakpoints ();
950 delete_breakpoint (bpt)
951 struct breakpoint *bpt;
953 register struct breakpoint *b;
956 write_memory (bpt->address, bpt->shadow_contents, sizeof break_insn);
958 if (breakpoint_chain == bpt)
959 breakpoint_chain = bpt->next;
968 check_duplicates (bpt->address);
970 free_command_lines (&bpt->commands);
974 if (xgdb_verbose && bpt->number >=0)
975 printf ("breakpoint #%d deleted\n", bpt->number);
980 static void map_breakpoint_numbers ();
983 delete_command (arg, from_tty)
987 register struct breakpoint *b, *b1;
991 /* Ask user only if there are some breakpoints to delete. */
993 || breakpoint_chain && query ("Delete all breakpoints? "))
995 /* No arg; clear all breakpoints. */
996 while (breakpoint_chain)
997 delete_breakpoint (breakpoint_chain);
1001 map_breakpoint_numbers (arg, delete_breakpoint);
1004 /* Delete all breakpoints.
1005 Done when new symtabs are loaded, since the break condition expressions
1006 may become invalid, and the breakpoints are probably wrong anyway. */
1009 clear_breakpoints ()
1011 delete_command (0, 0);
1014 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
1015 If from_tty is nonzero, it prints a message to that effect,
1016 which ends with a period (no newline). */
1019 set_ignore_count (bptnum, count, from_tty)
1020 int bptnum, count, from_tty;
1022 register struct breakpoint *b;
1028 if (b->number == bptnum)
1030 b->ignore_count = count;
1033 else if (count == 0)
1034 printf ("Will stop next time breakpoint %d is reached.", bptnum);
1035 else if (count == 1)
1036 printf ("Will ignore next crossing of breakpoint %d.", bptnum);
1038 printf ("Will ignore next %d crossings of breakpoint %d.",
1043 error ("No breakpoint number %d.", bptnum);
1046 /* Clear the ignore counts of all breakpoints. */
1048 breakpoint_clear_ignore_counts ()
1050 struct breakpoint *b;
1053 b->ignore_count = 0;
1056 /* Command to set ignore-count of breakpoint N to COUNT. */
1059 ignore_command (args, from_tty)
1063 register char *p = args;
1067 error_no_arg ("a breakpoint number");
1069 while (*p >= '0' && *p <= '9') p++;
1070 if (*p && *p != ' ' && *p != '\t')
1071 error ("First argument must be a breakpoint number.");
1076 error ("Second argument (specified ignore-count) is missing.");
1078 set_ignore_count (num, parse_and_eval_address (p), from_tty);
1082 /* Call FUNCTION on each of the breakpoints
1083 whose numbers are given in ARGS. */
1086 map_breakpoint_numbers (args, function)
1088 void (*function) ();
1090 register char *p = args;
1093 register struct breakpoint *b;
1096 error_no_arg ("one or more breakpoint numbers");
1101 while (*p1 >= '0' && *p1 <= '9') p1++;
1102 if (*p1 && *p1 != ' ' && *p1 != '\t')
1103 error ("Arguments must be breakpoint numbers.");
1108 if (b->number == num)
1113 printf ("No breakpoint number %d.\n", num);
1116 while (*p == ' ' || *p == '\t') p++;
1121 enable_breakpoint (bpt)
1122 struct breakpoint *bpt;
1124 bpt->enable = enabled;
1126 if (xgdb_verbose && bpt->number >= 0)
1127 printf ("breakpoint #%d enabled\n", bpt->number);
1129 check_duplicates (bpt->address);
1133 enable_command (args)
1136 struct breakpoint *bpt;
1138 ALL_BREAKPOINTS (bpt)
1139 enable_breakpoint (bpt);
1141 map_breakpoint_numbers (args, enable_breakpoint);
1145 disable_breakpoint (bpt)
1146 struct breakpoint *bpt;
1148 bpt->enable = disabled;
1150 if (xgdb_verbose && bpt->number >= 0)
1151 printf ("breakpoint #%d disabled\n", bpt->number);
1153 check_duplicates (bpt->address);
1157 disable_command (args)
1160 register struct breakpoint *bpt;
1162 ALL_BREAKPOINTS (bpt)
1163 disable_breakpoint (bpt);
1165 map_breakpoint_numbers (args, disable_breakpoint);
1169 enable_once_breakpoint (bpt)
1170 struct breakpoint *bpt;
1172 bpt->enable = temporary;
1174 check_duplicates (bpt->address);
1178 enable_once_command (args)
1181 map_breakpoint_numbers (args, enable_once_breakpoint);
1185 enable_delete_breakpoint (bpt)
1186 struct breakpoint *bpt;
1188 bpt->enable = delete;
1190 check_duplicates (bpt->address);
1194 enable_delete_command (args)
1197 map_breakpoint_numbers (args, enable_delete_breakpoint);
1201 * Use default_breakpoint_'s, or nothing if they aren't valid.
1203 struct symtabs_and_lines
1204 decode_line_spec_1 (string, funfirstline)
1208 struct symtabs_and_lines sals;
1210 error ("Empty line specification.");
1211 if (default_breakpoint_valid)
1212 sals = decode_line_1 (&string, funfirstline,
1213 default_breakpoint_symtab, default_breakpoint_line);
1215 sals = decode_line_1 (&string, funfirstline, 0, 0);
1217 error ("Junk at end of line specification: %s", string);
1222 /* Chain containing all defined enable commands. */
1224 extern struct cmd_list_element
1225 *enablelist, *disablelist,
1226 *deletelist, *enablebreaklist;
1228 extern struct cmd_list_element *cmdlist;
1231 _initialize_breakpoint ()
1233 breakpoint_chain = 0;
1234 breakpoint_count = 0;
1236 add_com ("ignore", class_breakpoint, ignore_command,
1237 "Set ignore-count of breakpoint number N to COUNT.");
1239 add_com ("commands", class_breakpoint, commands_command,
1240 "Set commands to be executed when a breakpoint is hit.\n\
1241 Give breakpoint number as argument after \"commands\".\n\
1242 With no argument, the targeted breakpoint is the last one set.\n\
1243 The commands themselves follow starting on the next line.\n\
1244 Type a line containing \"end\" to indicate the end of them.\n\
1245 Give \"silent\" as the first line to make the breakpoint silent;\n\
1246 then no output is printed when it is hit, except what the commands print.");
1248 add_com ("condition", class_breakpoint, condition_command,
1249 "Specify breakpoint number N to break only if COND is true.\n\
1250 N is an integer; COND is a C expression to be evaluated whenever\n\
1251 breakpoint N is reached. Actually break only when COND is nonzero.");
1253 add_com ("tbreak", class_breakpoint, tbreak_command,
1254 "Set a temporary breakpoint. Args like \"break\" command.\n\
1255 Like \"break\" except the breakpoint is only enabled temporarily,\n\
1256 so it will be disabled when hit. Equivalent to \"break\" followed\n\
1257 by using \"enable once\" on the breakpoint number.");
1259 add_prefix_cmd ("enable", class_breakpoint, enable_command,
1260 "Enable some breakpoints or auto-display expressions.\n\
1261 Give breakpoint numbers (separated by spaces) as arguments.\n\
1262 With no subcommand, breakpoints are enabled until you command otherwise.\n\
1263 This is used to cancel the effect of the \"disable\" command.\n\
1264 With a subcommand you can enable temporarily.\n\
1266 The \"display\" subcommand applies to auto-displays instead of breakpoints.",
1267 &enablelist, "enable ", 1, &cmdlist);
1269 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
1270 "Enable some breakpoints or auto-display expressions.\n\
1271 Give breakpoint numbers (separated by spaces) as arguments.\n\
1272 With no subcommand, breakpoints are enabled until you command otherwise.\n\
1273 This is used to cancel the effect of the \"disable\" command.\n\
1274 May be abbreviates to simply \"enable\".\n\
1275 With a subcommand you can enable temporarily.",
1276 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
1278 add_cmd ("once", no_class, enable_once_command,
1279 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
1280 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
1281 See the \"tbreak\" command which sets a breakpoint and enables it once.",
1284 add_cmd ("delete", no_class, enable_delete_command,
1285 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
1286 If a breakpoint is hit while enabled in this fashion, it is deleted.",
1289 add_cmd ("delete", no_class, enable_delete_command,
1290 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
1291 If a breakpoint is hit while enabled in this fashion, it is deleted.",
1294 add_cmd ("once", no_class, enable_once_command,
1295 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
1296 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
1297 See the \"tbreak\" command which sets a breakpoint and enables it once.",
1300 add_prefix_cmd ("disable", class_breakpoint, disable_command,
1301 "Disable some breakpoints or auto-display expressions.\n\
1302 Arguments are breakpoint numbers with spaces in between.\n\
1303 To disable all breakpoints, give no argument.\n\
1304 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
1306 The \"display\" subcommand applies to auto-displays instead of breakpoints.",
1307 &disablelist, "disable ", 1, &cmdlist);
1308 add_com_alias ("dis", "disable", class_breakpoint, 1);
1309 add_com_alias ("disa", "disable", class_breakpoint, 1);
1311 add_abbrev_cmd ("breakpoints", class_breakpoint, disable_command,
1312 "Disable some breakpoints or auto-display expressions.\n\
1313 Arguments are breakpoint numbers with spaces in between.\n\
1314 To disable all breakpoints, give no argument.\n\
1315 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
1316 This command may be abbreviated \"disable\".",
1319 add_prefix_cmd ("delete", class_breakpoint, delete_command,
1320 "Delete some breakpoints or auto-display expressions.\n\
1321 Arguments are breakpoint numbers with spaces in between.\n\
1322 To delete all breakpoints, give no argument.\n\
1324 Also a prefix command for deletion of other GDB objects.\n\
1325 The \"unset\" command is also an alias for \"delete\".",
1326 &deletelist, "delete ", 1, &cmdlist);
1327 add_com_alias ("d", "delete", class_breakpoint, 1);
1328 add_com_alias ("unset", "delete", class_alias, 1);
1330 add_cmd ("breakpoints", class_alias, delete_command,
1331 "Delete some breakpoints or auto-display expressions.\n\
1332 Arguments are breakpoint numbers with spaces in between.\n\
1333 To delete all breakpoints, give no argument.\n\
1334 This command may be abbreviated \"delete\".",
1337 add_com ("clear", class_breakpoint, clear_command,
1338 "Clear breakpoint at specified line or function.\n\
1339 Argument may be line number, function name, or \"*\" and an address.\n\
1340 If line number is specified, all breakpoints in that line are cleared.\n\
1341 If function is specified, breakpoints at beginning of function are cleared.\n\
1342 If an address is specified, breakpoints at that address are cleared.\n\n\
1343 With no argument, clears all breakpoints in the line that the selected frame\n\
1346 See also the \"delete\" command which clears breakpoints by number.");
1348 add_com ("break", class_breakpoint, break_command,
1349 "Set breakpoint at specified line or function.\n\
1350 Argument may be line number, function name, or \"*\" and an address.\n\
1351 If line number is specified, break at start of code for that line.\n\
1352 If function is specified, break at start of code for that function.\n\
1353 If an address is specified, break at that exact address.\n\
1354 With no arg, uses current execution address of selected stack frame.\n\
1355 This is useful for breaking on return to a stack frame.\n\
1357 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
1359 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
1360 add_com_alias ("b", "break", class_run, 1);
1361 add_com_alias ("br", "break", class_run, 1);
1362 add_com_alias ("bre", "break", class_run, 1);
1363 add_com_alias ("brea", "break", class_run, 1);
1365 add_info ("breakpoints", breakpoints_info,
1366 "Status of all breakpoints, or breakpoint number NUMBER.\n\
1367 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
1368 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
1369 Then come the address and the file/line number.\n\n\
1370 Convenience variable \"$_\" and default examine address for \"x\"\n\
1371 are set to the address of the last breakpoint listed.");