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. */
27 /* This is the sequence of bytes we insert for a breakpoint. */
29 static char break_insn[] = BREAKPOINT;
31 /* States of enablement of breakpoint.
32 `temporary' means disable when hit.
33 `delete' means delete when hit. */
35 enum enable { disabled, enabled, temporary, delete};
37 /* Not that the ->silent field is not currently used by any commands
38 (though the code is in there if it was to be and set_raw_breakpoint
39 does set it to 0). I implemented it because I thought it would be
40 useful for a hack I had to put in; I'm going to leave it in because
41 I can see how there might be times when it would indeed be useful */
45 struct breakpoint *next;
46 /* Number assigned to distinguish breakpoints. */
48 /* Address to break at. */
50 /* Line number of this address. Redundant. */
52 /* Symtab of file of this address. Redundant. */
53 struct symtab *symtab;
54 /* Zero means disabled; remember the info but don't break here. */
56 /* Non-zero means a silent breakpoint (don't print frame info
59 /* Number of stops at this breakpoint that should
60 be continued automatically before really stopping. */
62 /* "Real" contents of byte where breakpoint has been inserted.
63 Valid only when breakpoints are in the program. */
64 char shadow_contents[sizeof break_insn];
65 /* Nonzero if this breakpoint is now inserted. */
67 /* Nonzero if this is not the first breakpoint in the list
68 for the given address. */
70 /* Chain of command lines to execute when this breakpoint is hit. */
71 struct command_line *commands;
72 /* Stack depth (address of frame). If nonzero, break only if fp
75 /* Conditional. Break only if this expression's value is nonzero. */
76 struct expression *cond;
79 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
81 /* Chain of all breakpoints defined. */
83 struct breakpoint *breakpoint_chain;
85 /* Number of last breakpoint made. */
87 static int breakpoint_count;
89 /* Default address, symtab and line to put a breakpoint at
90 for "break" command with no arg.
91 if default_breakpoint_valid is zero, the other three are
92 not valid, and "break" with no arg is an error.
94 This set by print_stack_frame, which calls set_default_breakpoint. */
96 int default_breakpoint_valid;
97 CORE_ADDR default_breakpoint_address;
98 struct symtab *default_breakpoint_symtab;
99 int default_breakpoint_line;
101 /* Remaining commands (not yet executed)
102 of last breakpoint hit. */
104 struct command_line *breakpoint_commands;
106 static void delete_breakpoint ();
107 void clear_momentary_breakpoints ();
108 void breakpoint_auto_delete ();
110 /* Flag indicating extra verbosity for xgdb. */
111 extern int xgdb_verbose;
113 /* condition N EXP -- set break condition of breakpoint N to EXP. */
116 condition_command (arg, from_tty)
120 register struct breakpoint *b;
123 register struct expression *expr;
126 error_no_arg ("breakpoint number");
129 while (*p >= '0' && *p <= '9') p++;
131 /* There is no number here. (e.g. "cond a == b"). */
132 error_no_arg ("breakpoint number");
136 if (b->number == bnum)
144 printf ("Breakpoint %d now unconditional.\n", bnum);
148 if (*p != ' ' && *p != '\t')
149 error ("Arguments must be an integer (breakpoint number) and an expression.");
151 /* Find start of expression */
152 while (*p == ' ' || *p == '\t') p++;
155 b->cond = (struct expression *) parse_c_1 (&arg, block_for_pc (b->address), 0);
157 error ("Junk at end of expression");
162 error ("No breakpoint number %d.", bnum);
166 commands_command (arg)
169 register struct breakpoint *b;
170 register char *p, *p1;
172 struct command_line *l;
174 /* If we allowed this, we would have problems with when to
175 free the storage, if we change the commands currently
178 if (breakpoint_commands)
179 error ("Can't use the \"commands\" command among a breakpoint's commands.");
181 /* Allow commands by itself to refer to the last breakpoint. */
183 bnum = breakpoint_count;
187 if (! (*p >= '0' && *p <= '9'))
188 error ("Argument must be integer (a breakpoint number).");
190 while (*p >= '0' && *p <= '9') p++;
192 error ("Unexpected extra arguments following breakpoint number.");
198 if (b->number == bnum)
200 if (input_from_terminal_p ())
202 printf ("Type commands for when breakpoint %d is hit, one per line.\n\
203 End with a line saying just \"end\".\n", bnum);
206 l = read_command_lines ();
207 free_command_lines (&b->commands);
211 error ("No breakpoint number %d.", bnum);
214 /* Called from command loop to execute the commands
215 associated with the breakpoint we just stopped at. */
218 do_breakpoint_commands ()
220 while (breakpoint_commands)
222 char *line = breakpoint_commands->line;
223 breakpoint_commands = breakpoint_commands->next;
224 execute_command (line, 0);
225 /* If command was "cont", breakpoint_commands is now 0,
226 of if we stopped at yet another breakpoint which has commands,
227 it is now the commands for the new breakpoint. */
229 clear_momentary_breakpoints ();
232 /* Used when the program is proceeded, to eliminate any remaining
233 commands attached to the previous breakpoint we stopped at. */
236 clear_breakpoint_commands ()
238 breakpoint_commands = 0;
239 breakpoint_auto_delete (0);
242 /* Functions to get and set the current list of pending
243 breakpoint commands. These are used by run_stack_dummy
244 to preserve the commands around a function call. */
246 struct command_line *
247 get_breakpoint_commands ()
249 return breakpoint_commands;
253 set_breakpoint_commands (cmds)
254 struct command_line *cmds;
256 breakpoint_commands = cmds;
259 /* insert_breakpoints is used when starting or continuing the program.
260 remove_breakpoints is used when the program stops.
261 Both return zero if successful,
262 or an `errno' value if could not write the inferior. */
265 insert_breakpoints ()
267 register struct breakpoint *b;
270 #ifdef BREAKPOINT_DEBUG
271 printf ("Inserting breakpoints.\n");
272 #endif /* BREAKPOINT_DEBUG */
275 if (b->enable != disabled && ! b->inserted && ! b->duplicate)
277 read_memory (b->address, b->shadow_contents, sizeof break_insn);
278 val = write_memory (b->address, break_insn, sizeof break_insn);
281 #ifdef BREAKPOINT_DEBUG
282 printf ("Inserted breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
283 b->address, b->shadow_contents[0], b->shadow_contents[1]);
284 #endif /* BREAKPOINT_DEBUG */
291 remove_breakpoints ()
293 register struct breakpoint *b;
296 #ifdef BREAKPOINT_DEBUG
297 printf ("Removing breakpoints.\n");
298 #endif /* BREAKPOINT_DEBUG */
303 val = write_memory (b->address, b->shadow_contents, sizeof break_insn);
307 #ifdef BREAKPOINT_DEBUG
308 printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
309 b->address, b->shadow_contents[0], b->shadow_contents[1]);
310 #endif /* BREAKPOINT_DEBUG */
316 /* Clear the "inserted" flag in all breakpoints.
317 This is done when the inferior is loaded. */
320 mark_breakpoints_out ()
322 register struct breakpoint *b;
328 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
329 When continuing from a location with a breakpoint,
330 we actually single step once before calling insert_breakpoints. */
333 breakpoint_here_p (pc)
336 register struct breakpoint *b;
339 if (b->enable != disabled && b->address == pc)
345 /* Evaluate the expression EXP and return 1 if value is zero.
346 This is used inside a catch_errors to evaluate the breakpoint condition. */
349 breakpoint_cond_eval (exp)
350 struct expression *exp;
352 return value_zerop (evaluate_expression (exp));
355 /* Return 0 if PC is not the address just after a breakpoint,
356 or -1 if breakpoint says do not stop now,
357 or -2 if breakpoint says it has deleted itself and don't stop,
358 or -3 if hit a breakpoint number -3 (delete when program stops),
359 or else the number of the breakpoint,
360 with 0x1000000 added (or subtracted, for a negative return value) for
361 a silent breakpoint. */
364 breakpoint_stop_status (pc, frame_address)
366 FRAME_ADDR frame_address;
368 register struct breakpoint *b;
369 register int cont = 0;
371 /* Get the address where the breakpoint would have been. */
372 pc -= DECR_PC_AFTER_BREAK;
375 if (b->enable != disabled && b->address == pc)
377 if (b->frame && b->frame != frame_address)
384 /* Need to select the frame, with all that implies
385 so that the conditions will have the right context. */
386 select_frame (get_current_frame (), 0);
388 = catch_errors (breakpoint_cond_eval, b->cond,
389 "Error occurred in testing breakpoint condition.");
392 if (b->cond && value_zero)
396 else if (b->ignore_count > 0)
403 if (b->enable == temporary)
404 b->enable = disabled;
405 breakpoint_commands = b->commands;
407 || (breakpoint_commands
408 && !strcmp ("silent", breakpoint_commands->line)))
410 if (breakpoint_commands)
411 breakpoint_commands = breakpoint_commands->next;
412 return (b->number > 0 ?
413 0x1000000 + b->number :
414 b->number - 0x1000000);
428 register struct breakpoint *b;
429 register struct command_line *l;
430 register struct symbol *sym;
431 CORE_ADDR last_addr = (CORE_ADDR)-1;
434 if (bnum == -1 || bnum == b->number)
436 printf_filtered ("#%-3d %c 0x%08x ", b->number,
437 "nyod"[(int) b->enable],
439 last_addr = b->address;
442 sym = find_pc_function (b->address);
444 printf_filtered (" in %s (%s line %d)", SYMBOL_NAME (sym),
445 b->symtab->filename, b->line_number);
447 printf_filtered ("%s line %d", b->symtab->filename, b->line_number);
454 if (find_pc_partial_function (b->address, &name, &addr))
456 if (b->address - addr)
457 printf_filtered ("<%s+%d>", name, b->address - addr);
459 printf_filtered ("<%s>", name);
463 printf_filtered ("\n");
466 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
468 printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame);
471 printf_filtered ("\tbreak only if ");
472 print_expression (b->cond, stdout);
473 printf_filtered ("\n");
478 printf_filtered ("\t%s\n", l->line);
483 /* Compare against (CORE_ADDR)-1 in case some compiler decides
484 that a comparison of an unsigned with -1 is always false. */
485 if (last_addr != (CORE_ADDR)-1)
486 set_next_address (last_addr);
490 breakpoints_info (bnum_exp)
496 bnum = parse_and_eval_address (bnum_exp);
497 else if (breakpoint_chain == 0)
498 printf_filtered ("No breakpoints.\n");
500 printf_filtered ("Breakpoints:\n\
501 Num Enb Address Where\n");
506 /* Print a message describing any breakpoints set at PC. */
509 describe_other_breakpoints (pc)
510 register CORE_ADDR pc;
512 register int others = 0;
513 register struct breakpoint *b;
516 if (b->address == pc)
520 printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
522 if (b->address == pc)
527 (b->enable == disabled) ? " (disabled)" : "",
528 (others > 1) ? "," : ((others == 1) ? " and" : ""));
530 printf (" also set at pc 0x%x\n", pc);
534 /* Set the default place to put a breakpoint
535 for the `break' command with no arguments. */
538 set_default_breakpoint (valid, addr, symtab, line)
541 struct symtab *symtab;
544 default_breakpoint_valid = valid;
545 default_breakpoint_address = addr;
546 default_breakpoint_symtab = symtab;
547 default_breakpoint_line = line;
550 /* Rescan breakpoints at address ADDRESS,
551 marking the first one as "first" and any others as "duplicates".
552 This is so that the bpt instruction is only inserted once. */
555 check_duplicates (address)
558 register struct breakpoint *b;
559 register int count = 0;
562 if (b->enable != disabled && b->address == address)
565 b->duplicate = count > 1;
569 /* Low level routine to set a breakpoint.
570 Takes as args the three things that every breakpoint must have.
571 Returns the breakpoint object so caller can set other things.
572 Does not set the breakpoint number!
573 Does not print anything. */
575 static struct breakpoint *
576 set_raw_breakpoint (sal)
577 struct symtab_and_line sal;
579 register struct breakpoint *b, *b1;
581 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
582 bzero (b, sizeof *b);
584 b->symtab = sal.symtab;
585 b->line_number = sal.line;
590 /* Add this breakpoint to the end of the chain
591 so that a list of breakpoints will come out in order
592 of increasing numbers. */
594 b1 = breakpoint_chain;
596 breakpoint_chain = b;
604 check_duplicates (sal.pc);
609 /* Set a breakpoint that will evaporate an end of command
610 at address specified by SAL.
611 Restrict it to frame FRAME if FRAME is nonzero. */
614 set_momentary_breakpoint (sal, frame)
615 struct symtab_and_line sal;
618 register struct breakpoint *b;
619 b = set_raw_breakpoint (sal);
622 b->frame = (frame ? FRAME_FP (frame) : 0);
626 clear_momentary_breakpoints ()
628 register struct breakpoint *b;
632 delete_breakpoint (b);
637 /* Set a breakpoint from a symtab and line.
638 If TEMPFLAG is nonzero, it is a temporary breakpoint.
639 Print the same confirmation messages that the breakpoint command prints. */
642 set_breakpoint (s, line, tempflag)
647 register struct breakpoint *b;
648 struct symtab_and_line sal;
652 sal.pc = find_line_pc (sal.symtab, sal.line);
654 error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
657 describe_other_breakpoints (sal.pc);
659 b = set_raw_breakpoint (sal);
660 b->number = ++breakpoint_count;
663 b->enable = temporary;
665 printf ("Breakpoint %d at 0x%x", b->number, b->address);
667 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
672 /* Set a breakpoint according to ARG (function, linenum or *address)
673 and make it temporary if TEMPFLAG is nonzero. */
676 break_command_1 (arg, tempflag, from_tty)
678 int tempflag, from_tty;
680 struct symtabs_and_lines sals;
681 struct symtab_and_line sal;
682 register struct expression *cond = 0;
683 register struct breakpoint *b;
691 sal.line = sal.pc = sal.end = 0;
694 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
696 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
697 && (arg[2] == ' ' || arg[2] == '\t')))
699 if (default_breakpoint_valid)
701 sals.sals = (struct symtab_and_line *)
702 malloc (sizeof (struct symtab_and_line));
703 sal.pc = default_breakpoint_address;
704 sal.line = default_breakpoint_line;
705 sal.symtab = default_breakpoint_symtab;
710 error ("No default breakpoint address now.");
713 /* Force almost all breakpoints to be in terms of the
714 current_source_symtab (which is decode_line_1's default). This
715 should produce the results we want almost all of the time while
716 leaving default_breakpoint_* alone. */
717 if (default_breakpoint_valid
718 && (!current_source_symtab
719 || (arg && (*arg == '+' || *arg == '-'))))
720 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
721 default_breakpoint_line);
723 sals = decode_line_1 (&arg, 1, 0, 0);
729 for (i = 0; i < sals.nelts; i++)
732 if (sal.pc == 0 && sal.symtab != 0)
734 pc = find_line_pc (sal.symtab, sal.line);
736 error ("No line %d in file \"%s\".",
737 sal.line, sal.symtab->filename);
744 if (arg[0] == 'i' && arg[1] == 'f'
745 && (arg[2] == ' ' || arg[2] == '\t'))
746 cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
747 block_for_pc (pc), 0);
749 error ("Junk at end of arguments.");
752 sals.sals[i].pc = pc;
755 for (i = 0; i < sals.nelts; i++)
760 describe_other_breakpoints (sal.pc);
762 b = set_raw_breakpoint (sal);
763 b->number = ++breakpoint_count;
766 b->enable = temporary;
768 printf ("Breakpoint %d at 0x%x", b->number, b->address);
770 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
776 printf ("Multiple breakpoints were set.\n");
777 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
783 break_command (arg, from_tty)
787 break_command_1 (arg, 0, from_tty);
791 tbreak_command (arg, from_tty)
795 break_command_1 (arg, 1, from_tty);
799 * Helper routine for the until_command routine in infcmd.c. Here
800 * because it uses the mechanisms of breakpoints.
803 until_break_command (arg, from_tty)
807 struct symtabs_and_lines sals;
808 struct symtab_and_line sal;
809 FRAME prev_frame = get_prev_frame (selected_frame);
811 clear_proceed_status ();
813 /* Set a breakpoint where the user wants it and at return from
816 if (default_breakpoint_valid)
817 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
818 default_breakpoint_line);
820 sals = decode_line_1 (&arg, 1, 0, 0);
823 error ("Couldn't get information on specified line.");
826 free (sals.sals); /* malloc'd, so freed */
829 error ("Junk at end of arguments.");
831 if (sal.pc == 0 && sal.symtab != 0)
832 sal.pc = find_line_pc (sal.symtab, sal.line);
835 error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
837 set_momentary_breakpoint (sal, selected_frame);
839 /* Keep within the current frame */
843 struct frame_info *fi;
845 fi = get_frame_info (prev_frame);
846 sal = find_pc_line (fi->pc, 0);
848 set_momentary_breakpoint (sal, prev_frame);
855 clear_command (arg, from_tty)
859 register struct breakpoint *b, *b1;
860 struct symtabs_and_lines sals;
861 struct symtab_and_line sal;
862 register struct breakpoint *found;
867 sals = decode_line_spec (arg, 1);
871 sals.sals = (struct symtab_and_line *) malloc (sizeof (struct symtab_and_line));
872 sal.line = default_breakpoint_line;
873 sal.symtab = default_breakpoint_symtab;
876 error ("No source file specified.");
882 for (i = 0; i < sals.nelts; i++)
884 /* If exact pc given, clear bpts at that pc.
885 But if sal.pc is zero, clear all bpts on specified line. */
887 found = (struct breakpoint *) 0;
888 while (breakpoint_chain
889 && (sal.pc ? breakpoint_chain->address == sal.pc
890 : (breakpoint_chain->symtab == sal.symtab
891 && breakpoint_chain->line_number == sal.line)))
893 b1 = breakpoint_chain;
894 breakpoint_chain = b1->next;
901 && (sal.pc ? b->next->address == sal.pc
902 : (b->next->symtab == sal.symtab
903 && b->next->line_number == sal.line)))
912 error ("No breakpoint at %s.", arg);
914 if (found->next) from_tty = 1; /* Always report if deleted more than one */
915 if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
918 if (from_tty) printf ("%d ", found->number);
920 delete_breakpoint (found);
923 if (from_tty) putchar ('\n');
928 /* Delete breakpoint number BNUM if it is a `delete' breakpoint.
929 This is called after breakpoint BNUM has been hit.
930 Also delete any breakpoint numbered -3 unless there are breakpoint
931 commands to be executed. */
934 breakpoint_auto_delete (bnum)
937 register struct breakpoint *b;
940 if (b->number == bnum)
942 if (b->enable == delete)
943 delete_breakpoint (b);
946 if (breakpoint_commands == 0)
947 clear_momentary_breakpoints ();
951 delete_breakpoint (bpt)
952 struct breakpoint *bpt;
954 register struct breakpoint *b;
957 write_memory (bpt->address, bpt->shadow_contents, sizeof break_insn);
959 if (breakpoint_chain == bpt)
960 breakpoint_chain = bpt->next;
969 check_duplicates (bpt->address);
971 free_command_lines (&bpt->commands);
975 if (xgdb_verbose && bpt->number >=0)
976 printf ("breakpoint #%d deleted\n", bpt->number);
981 static void map_breakpoint_numbers ();
984 delete_command (arg, from_tty)
988 register struct breakpoint *b, *b1;
992 /* Ask user only if there are some breakpoints to delete. */
994 || breakpoint_chain && query ("Delete all breakpoints? "))
996 /* No arg; clear all breakpoints. */
997 while (breakpoint_chain)
998 delete_breakpoint (breakpoint_chain);
1002 map_breakpoint_numbers (arg, delete_breakpoint);
1005 /* Delete all breakpoints.
1006 Done when new symtabs are loaded, since the break condition expressions
1007 may become invalid, and the breakpoints are probably wrong anyway. */
1010 clear_breakpoints ()
1012 delete_command (0, 0);
1015 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
1016 If from_tty is nonzero, it prints a message to that effect,
1017 which ends with a period (no newline). */
1020 set_ignore_count (bptnum, count, from_tty)
1021 int bptnum, count, from_tty;
1023 register struct breakpoint *b;
1029 if (b->number == bptnum)
1031 b->ignore_count = count;
1034 else if (count == 0)
1035 printf ("Will stop next time breakpoint %d is reached.", bptnum);
1036 else if (count == 1)
1037 printf ("Will ignore next crossing of breakpoint %d.", bptnum);
1039 printf ("Will ignore next %d crossings of breakpoint %d.",
1044 error ("No breakpoint number %d.", bptnum);
1047 /* Command to set ignore-count of breakpoint N to COUNT. */
1050 ignore_command (args, from_tty)
1054 register char *p = args;
1058 error_no_arg ("a breakpoint number");
1060 while (*p >= '0' && *p <= '9') p++;
1061 if (*p && *p != ' ' && *p != '\t')
1062 error ("First argument must be a breakpoint number.");
1067 error ("Second argument (specified ignore-count) is missing.");
1069 set_ignore_count (num, parse_and_eval_address (p), from_tty);
1073 /* Call FUNCTION on each of the breakpoints
1074 whose numbers are given in ARGS. */
1077 map_breakpoint_numbers (args, function)
1079 void (*function) ();
1081 register char *p = args;
1084 register struct breakpoint *b;
1087 error_no_arg ("one or more breakpoint numbers");
1092 while (*p1 >= '0' && *p1 <= '9') p1++;
1093 if (*p1 && *p1 != ' ' && *p1 != '\t')
1094 error ("Arguments must be breakpoint numbers.");
1099 if (b->number == num)
1104 printf ("No breakpoint number %d.\n", num);
1107 while (*p == ' ' || *p == '\t') p++;
1112 enable_breakpoint (bpt)
1113 struct breakpoint *bpt;
1115 bpt->enable = enabled;
1117 if (xgdb_verbose && bpt->number >= 0)
1118 printf ("breakpoint #%d enabled\n", bpt->number);
1120 check_duplicates (bpt->address);
1124 enable_command (args)
1127 struct breakpoint *bpt;
1129 ALL_BREAKPOINTS (bpt)
1130 enable_breakpoint (bpt);
1132 map_breakpoint_numbers (args, enable_breakpoint);
1136 disable_breakpoint (bpt)
1137 struct breakpoint *bpt;
1139 bpt->enable = disabled;
1141 if (xgdb_verbose && bpt->number >= 0)
1142 printf ("breakpoint #%d disabled\n", bpt->number);
1144 check_duplicates (bpt->address);
1148 disable_command (args)
1151 register struct breakpoint *bpt;
1153 ALL_BREAKPOINTS (bpt)
1154 disable_breakpoint (bpt);
1156 map_breakpoint_numbers (args, disable_breakpoint);
1160 enable_once_breakpoint (bpt)
1161 struct breakpoint *bpt;
1163 bpt->enable = temporary;
1165 check_duplicates (bpt->address);
1169 enable_once_command (args)
1172 map_breakpoint_numbers (args, enable_once_breakpoint);
1176 enable_delete_breakpoint (bpt)
1177 struct breakpoint *bpt;
1179 bpt->enable = delete;
1181 check_duplicates (bpt->address);
1185 enable_delete_command (args)
1188 map_breakpoint_numbers (args, enable_delete_breakpoint);
1192 * Use default_breakpoint_'s, or nothing if they aren't valid.
1194 struct symtabs_and_lines
1195 decode_line_spec_1 (string, funfirstline)
1199 struct symtabs_and_lines sals;
1201 error ("Empty line specification.");
1202 if (default_breakpoint_valid)
1203 sals = decode_line_1 (&string, funfirstline,
1204 default_breakpoint_symtab, default_breakpoint_line);
1206 sals = decode_line_1 (&string, funfirstline, 0, 0);
1208 error ("Junk at end of line specification: %s", string);
1213 /* Chain containing all defined enable commands. */
1215 extern struct cmd_list_element
1216 *enablelist, *disablelist,
1217 *deletelist, *enablebreaklist;
1219 extern struct cmd_list_element *cmdlist;
1222 _initialize_breakpoint ()
1224 breakpoint_chain = 0;
1225 breakpoint_count = 0;
1227 add_com ("ignore", class_breakpoint, ignore_command,
1228 "Set ignore-count of breakpoint number N to COUNT.");
1230 add_com ("commands", class_breakpoint, commands_command,
1231 "Set commands to be executed when a breakpoint is hit.\n\
1232 Give breakpoint number as argument after \"commands\".\n\
1233 With no argument, the targeted breakpoint is the last one set.\n\
1234 The commands themselves follow starting on the next line.\n\
1235 Type a line containing \"end\" to indicate the end of them.\n\
1236 Give \"silent\" as the first line to make the breakpoint silent;\n\
1237 then no output is printed when it is hit, except what the commands print.");
1239 add_com ("condition", class_breakpoint, condition_command,
1240 "Specify breakpoint number N to break only if COND is true.\n\
1241 N is an integer; COND is a C expression to be evaluated whenever\n\
1242 breakpoint N is reached. Actually break only when COND is nonzero.");
1244 add_com ("tbreak", class_breakpoint, tbreak_command,
1245 "Set a temporary breakpoint. Args like \"break\" command.\n\
1246 Like \"break\" except the breakpoint is only enabled temporarily,\n\
1247 so it will be disabled when hit. Equivalent to \"break\" followed\n\
1248 by using \"enable once\" on the breakpoint number.");
1250 add_prefix_cmd ("enable", class_breakpoint, enable_command,
1251 "Enable some breakpoints or auto-display expressions.\n\
1252 Give breakpoint numbers (separated by spaces) as arguments.\n\
1253 With no subcommand, breakpoints are enabled until you command otherwise.\n\
1254 This is used to cancel the effect of the \"disable\" command.\n\
1255 With a subcommand you can enable temporarily.\n\
1257 The \"display\" subcommand applies to auto-displays instead of breakpoints.",
1258 &enablelist, "enable ", 1, &cmdlist);
1260 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
1261 "Enable some breakpoints or auto-display expressions.\n\
1262 Give breakpoint numbers (separated by spaces) as arguments.\n\
1263 With no subcommand, breakpoints are enabled until you command otherwise.\n\
1264 This is used to cancel the effect of the \"disable\" command.\n\
1265 May be abbreviates to simply \"enable\".\n\
1266 With a subcommand you can enable temporarily.",
1267 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
1269 add_cmd ("once", no_class, enable_once_command,
1270 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
1271 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
1272 See the \"tbreak\" command which sets a breakpoint and enables it once.",
1275 add_cmd ("delete", no_class, enable_delete_command,
1276 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
1277 If a breakpoint is hit while enabled in this fashion, it is deleted.",
1280 add_cmd ("delete", no_class, enable_delete_command,
1281 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
1282 If a breakpoint is hit while enabled in this fashion, it is deleted.",
1285 add_cmd ("once", no_class, enable_once_command,
1286 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
1287 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
1288 See the \"tbreak\" command which sets a breakpoint and enables it once.",
1291 add_prefix_cmd ("disable", class_breakpoint, disable_command,
1292 "Disable some breakpoints or auto-display expressions.\n\
1293 Arguments are breakpoint numbers with spaces in between.\n\
1294 To disable all breakpoints, give no argument.\n\
1295 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
1297 The \"display\" subcommand applies to auto-displays instead of breakpoints.",
1298 &disablelist, "disable ", 1, &cmdlist);
1299 add_com_alias ("dis", "disable", class_breakpoint, 1);
1300 add_com_alias ("disa", "disable", class_breakpoint, 1);
1302 add_abbrev_cmd ("breakpoints", class_breakpoint, disable_command,
1303 "Disable some breakpoints or auto-display expressions.\n\
1304 Arguments are breakpoint numbers with spaces in between.\n\
1305 To disable all breakpoints, give no argument.\n\
1306 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
1307 This command may be abbreviated \"disable\".",
1310 add_prefix_cmd ("delete", class_breakpoint, delete_command,
1311 "Delete some breakpoints or auto-display expressions.\n\
1312 Arguments are breakpoint numbers with spaces in between.\n\
1313 To delete all breakpoints, give no argument.\n\
1315 Also a prefix command for deletion of other GDB objects.\n\
1316 The \"unset\" command is also an alias for \"delete\".",
1317 &deletelist, "delete ", 1, &cmdlist);
1318 add_com_alias ("d", "delete", class_breakpoint, 1);
1319 add_com_alias ("unset", "delete", class_alias, 1);
1321 add_cmd ("breakpoints", class_alias, delete_command,
1322 "Delete some breakpoints or auto-display expressions.\n\
1323 Arguments are breakpoint numbers with spaces in between.\n\
1324 To delete all breakpoints, give no argument.\n\
1325 This command may be abbreviated \"delete\".",
1328 add_com ("clear", class_breakpoint, clear_command,
1329 "Clear breakpoint at specified line or function.\n\
1330 Argument may be line number, function name, or \"*\" and an address.\n\
1331 If line number is specified, all breakpoints in that line are cleared.\n\
1332 If function is specified, breakpoints at beginning of function are cleared.\n\
1333 If an address is specified, breakpoints at that address are cleared.\n\n\
1334 With no argument, clears all breakpoints in the line that the selected frame\n\
1337 See also the \"delete\" command which clears breakpoints by number.");
1339 add_com ("break", class_breakpoint, break_command,
1340 "Set breakpoint at specified line or function.\n\
1341 Argument may be line number, function name, or \"*\" and an address.\n\
1342 If line number is specified, break at start of code for that line.\n\
1343 If function is specified, break at start of code for that function.\n\
1344 If an address is specified, break at that exact address.\n\
1345 With no arg, uses current execution address of selected stack frame.\n\
1346 This is useful for breaking on return to a stack frame.\n\
1348 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
1350 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
1351 add_com_alias ("b", "break", class_run, 1);
1352 add_com_alias ("br", "break", class_run, 1);
1353 add_com_alias ("bre", "break", class_run, 1);
1354 add_com_alias ("brea", "break", class_run, 1);
1356 add_info ("breakpoints", breakpoints_info,
1357 "Status of all breakpoints, or breakpoint number NUMBER.\n\
1358 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
1359 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
1360 Then come the address and the file/line number.\n\n\
1361 Convenience variable \"$_\" and default examine address for \"x\"\n\
1362 are set to the address of the last breakpoint listed.");