1 /* Everything about breakpoints, for GDB.
2 Copyright (C) 1986, 1987, 1989, 1990 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 #include "breakpoint.h"
27 #include "expression.h"
37 extern int addressprint; /* Print machine addresses? */
38 extern int demangle; /* Print de-mangled symbol names? */
40 extern int catch_errors ();
41 extern void set_next_address (); /* ...for x/ command */
43 /* Are we executing breakpoint commands? */
44 static int executing_breakpoint_commands;
46 /* States of enablement of breakpoint.
47 `temporary' means disable when hit.
48 `delete' means delete when hit. */
50 enum enable { disabled, enabled, temporary, delete};
52 /* Not that the ->silent field is not currently used by any commands
53 (though the code is in there if it was to be, and set_raw_breakpoint
54 does set it to 0). I implemented it because I thought it would be
55 useful for a hack I had to put in; I'm going to leave it in because
56 I can see how there might be times when it would indeed be useful */
58 /* This is for a breakpoint or a watchpoint. */
62 struct breakpoint *next;
63 /* Number assigned to distinguish breakpoints. */
65 /* Address to break at, or NULL if not a breakpoint. */
67 /* Line number of this address. Redundant. Only matters if address
70 /* Symtab of file of this address. Redundant. Only matters if address
72 struct symtab *symtab;
73 /* Zero means disabled; remember the info but don't break here. */
75 /* Non-zero means a silent breakpoint (don't print frame info
78 /* Number of stops at this breakpoint that should
79 be continued automatically before really stopping. */
81 /* "Real" contents of byte where breakpoint has been inserted.
82 Valid only when breakpoints are in the program. Under the complete
83 control of the target insert_breakpoint and remove_breakpoint routines.
84 No other code should assume anything about the value(s) here. */
85 char shadow_contents[BREAKPOINT_MAX];
86 /* Nonzero if this breakpoint is now inserted. Only matters if address
89 /* Nonzero if this is not the first breakpoint in the list
90 for the given address. Only matters if address is non-NULL. */
92 /* Chain of command lines to execute when this breakpoint is hit. */
93 struct command_line *commands;
94 /* Stack depth (address of frame). If nonzero, break only if fp
97 /* Conditional. Break only if this expression's value is nonzero. */
98 struct expression *cond;
100 /* String we used to set the breakpoint (malloc'd). Only matters if
101 address is non-NULL. */
103 /* String form of the breakpoint condition (malloc'd), or NULL if there
107 /* The expression we are watching, or NULL if not a watchpoint. */
108 struct expression *exp;
109 /* The largest block within which it is valid, or NULL if it is
110 valid anywhere (e.g. consists just of global symbols). */
111 struct block *exp_valid_block;
112 /* Value of the watchpoint the last time we checked it. */
116 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
118 /* Chain of all breakpoints defined. */
120 struct breakpoint *breakpoint_chain;
122 /* Number of last breakpoint made. */
124 static int breakpoint_count;
126 /* Set breakpoint count to NUM. */
128 set_breakpoint_count (num)
131 breakpoint_count = num;
132 set_internalvar (lookup_internalvar ("bpnum"),
133 value_from_long (builtin_type_int, (LONGEST) num));
136 /* Default address, symtab and line to put a breakpoint at
137 for "break" command with no arg.
138 if default_breakpoint_valid is zero, the other three are
139 not valid, and "break" with no arg is an error.
141 This set by print_stack_frame, which calls set_default_breakpoint. */
143 int default_breakpoint_valid;
144 CORE_ADDR default_breakpoint_address;
145 struct symtab *default_breakpoint_symtab;
146 int default_breakpoint_line;
148 static void delete_breakpoint ();
149 void breakpoint_auto_delete ();
151 /* Flag indicating extra verbosity for xgdb. */
152 extern int xgdb_verbose;
154 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
155 Advance *PP after the string and any trailing whitespace.
157 Currently the string can either be a number or "$" followed by the name
158 of a convenience variable. Making it an expression wouldn't work well
159 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
168 /* Empty line means refer to the last breakpoint. */
169 return breakpoint_count;
172 /* Make a copy of the name, so we can null-terminate it
173 to pass to lookup_internalvar(). */
178 while (isalnum (*p) || *p == '_')
180 varname = (char *) alloca (p - start + 1);
181 strncpy (varname, start, p - start);
182 varname[p - start] = '\0';
183 val = value_of_internalvar (lookup_internalvar (varname));
184 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
186 "Convenience variables used to specify breakpoints must have integer values."
188 retval = (int) value_as_long (val);
192 while (*p >= '0' && *p <= '9')
195 /* There is no number here. (e.g. "cond a == b"). */
196 error_no_arg ("breakpoint number");
199 if (!(isspace (*p) || *p == '\0'))
200 error ("breakpoint number expected");
207 /* condition N EXP -- set break condition of breakpoint N to EXP. */
210 condition_command (arg, from_tty)
214 register struct breakpoint *b;
219 error_no_arg ("breakpoint number");
222 bnum = get_number (&p);
225 if (b->number == bnum)
232 if (b->cond_string != NULL)
233 free (b->cond_string);
238 b->cond_string = NULL;
240 printf ("Breakpoint %d now unconditional.\n", bnum);
245 /* I don't know if it matters whether this is the string the user
246 typed in or the decompiled expression. */
247 b->cond_string = savestring (arg, strlen (arg));
248 b->cond = parse_c_1 (&arg, block_for_pc (b->address), 0);
250 error ("Junk at end of expression");
255 error ("No breakpoint number %d.", bnum);
259 commands_command (arg, from_tty)
263 register struct breakpoint *b;
266 struct command_line *l;
268 /* If we allowed this, we would have problems with when to
269 free the storage, if we change the commands currently
272 if (executing_breakpoint_commands)
273 error ("Can't use the \"commands\" command among a breakpoint's commands.");
276 bnum = get_number (&p);
278 error ("Unexpected extra arguments following breakpoint number.");
281 if (b->number == bnum)
283 if (input_from_terminal_p ())
285 printf ("Type commands for when breakpoint %d is hit, one per line.\n\
286 End with a line saying just \"end\".\n", bnum);
289 l = read_command_lines ();
290 free_command_lines (&b->commands);
294 error ("No breakpoint number %d.", bnum);
297 extern int memory_breakpoint_size; /* from mem-break.c */
299 /* Like target_read_memory() but if breakpoints are inserted, return
300 the shadow contents instead of the breakpoints themselves. */
302 read_memory_nobpt (memaddr, myaddr, len)
308 struct breakpoint *b;
310 if (memory_breakpoint_size < 0)
311 /* No breakpoints on this machine. */
312 return target_read_memory (memaddr, myaddr, len);
316 if (b->address == NULL || !b->inserted)
318 else if (b->address + memory_breakpoint_size <= memaddr)
319 /* The breakpoint is entirely before the chunk of memory
322 else if (b->address >= memaddr + len)
323 /* The breakpoint is entirely after the chunk of memory we
328 /* Copy the breakpoint from the shadow contents, and recurse
329 for the things before and after. */
331 /* Addresses and length of the part of the breakpoint that
333 CORE_ADDR membpt = b->address;
334 unsigned int bptlen = memory_breakpoint_size;
335 /* Offset within shadow_contents. */
338 if (membpt < memaddr)
340 /* Only copy the second part of the breakpoint. */
341 bptlen -= memaddr - membpt;
342 bptoffset = memaddr - membpt;
346 if (membpt + bptlen > memaddr + len)
348 /* Only copy the first part of the breakpoint. */
349 bptlen -= (membpt + bptlen) - (memaddr + len);
352 bcopy (b->shadow_contents + bptoffset,
353 myaddr + membpt - memaddr, bptlen);
355 if (membpt > memaddr)
357 /* Copy the section of memory before the breakpoint. */
358 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
363 if (membpt + bptlen < memaddr + len)
365 /* Copy the section of memory after the breakpoint. */
366 status = read_memory_nobpt
368 myaddr + membpt + bptlen - memaddr,
369 memaddr + len - (membpt + bptlen));
376 /* Nothing overlaps. Just call read_memory_noerr. */
377 return target_read_memory (memaddr, myaddr, len);
380 /* insert_breakpoints is used when starting or continuing the program.
381 remove_breakpoints is used when the program stops.
382 Both return zero if successful,
383 or an `errno' value if could not write the inferior. */
386 insert_breakpoints ()
388 register struct breakpoint *b;
390 int disabled_breaks = 0;
393 if (b->address != NULL
394 && b->enable != disabled
398 val = target_insert_breakpoint(b->address, b->shadow_contents);
401 /* Can't set the breakpoint. */
402 #if defined (DISABLE_UNSETTABLE_BREAK)
403 if (DISABLE_UNSETTABLE_BREAK (b->address))
406 b->enable = disabled;
407 if (!disabled_breaks)
410 "Cannot insert breakpoint %d:\n", b->number);
411 printf_filtered ("Disabling shared library breakpoints:\n");
414 printf_filtered ("%d ", b->number);
419 fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number);
420 memory_error (val, b->address); /* which bombs us out */
427 printf_filtered ("\n");
432 remove_breakpoints ()
434 register struct breakpoint *b;
437 #ifdef BREAKPOINT_DEBUG
438 printf ("Removing breakpoints.\n");
439 #endif /* BREAKPOINT_DEBUG */
442 if (b->address != NULL && b->inserted)
444 val = target_remove_breakpoint(b->address, b->shadow_contents);
448 #ifdef BREAKPOINT_DEBUG
449 printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
450 b->address, b->shadow_contents[0], b->shadow_contents[1]);
451 #endif /* BREAKPOINT_DEBUG */
457 /* Clear the "inserted" flag in all breakpoints.
458 This is done when the inferior is loaded. */
461 mark_breakpoints_out ()
463 register struct breakpoint *b;
469 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
470 When continuing from a location with a breakpoint,
471 we actually single step once before calling insert_breakpoints. */
474 breakpoint_here_p (pc)
477 register struct breakpoint *b;
480 if (b->enable != disabled && b->address == pc)
486 /* bpstat stuff. External routines' interfaces are documented
501 if (p->old_val != NULL)
502 value_free (p->old_val);
520 for (; bs != NULL; bs = bs->next)
522 tmp = (bpstat) xmalloc (sizeof (*tmp));
523 bcopy (bs, tmp, sizeof (*tmp));
525 /* This is the first thing in the chain. */
539 struct breakpoint *b;
542 return 0; /* No more breakpoint values */
545 b = (*bsp)->breakpoint_at;
548 return -1; /* breakpoint that's been deleted since */
550 return b->number; /* We have its number */
555 bpstat_clear_actions (bs)
558 for (; bs != NULL; bs = bs->next)
561 if (bs->old_val != NULL)
563 value_free (bs->old_val);
569 /* Execute all the commands associated with all the breakpoints at this
570 location. Any of these commands could cause the process to proceed
571 beyond this point, etc. We look out for such changes by checking
572 the global "breakpoint_proceeded" after each command. */
574 bpstat_do_actions (bsp)
582 executing_breakpoint_commands = 1;
583 breakpoint_proceeded = 0;
584 for (; bs != NULL; bs = bs->next)
588 char *line = bs->commands->line;
589 bs->commands = bs->commands->next;
590 execute_command (line, 0);
591 /* If the inferior is proceeded by the command, bomb out now.
592 The bpstat chain has been blown away by wait_for_inferior.
593 But since execution has stopped again, there is a new bpstat
594 to look at, so start over. */
595 if (breakpoint_proceeded)
599 clear_momentary_breakpoints ();
601 executing_breakpoint_commands = 0;
608 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
609 which has since been deleted. */
610 if (bs == NULL || bs->breakpoint_at == NULL)
613 /* If bpstat_stop_status says don't print, OK, we won't. An example
614 circumstance is when we single-stepped for both a watchpoint and
615 for a "stepi" instruction. The bpstat says that the watchpoint
616 explains the stop, but we shouldn't print because the watchpoint's
617 value didn't change -- and the real reason we are stopping here
618 rather than continuing to step (as the watchpoint would've had us do)
619 is because of the "stepi". */
623 if (bs->breakpoint_at->address != NULL)
625 /* I think the user probably only wants to see one breakpoint
626 number, not all of them. */
627 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
631 if (bs->old_val != NULL)
633 printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number);
634 print_expression (bs->breakpoint_at->exp, stdout);
635 printf_filtered ("\nOld value = ");
636 value_print (bs->old_val, stdout, 0, Val_pretty_default);
637 printf_filtered ("\nNew value = ");
638 value_print (bs->breakpoint_at->val, stdout, 0,
640 printf_filtered ("\n");
641 value_free (bs->old_val);
646 fprintf_filtered (stderr, "gdb internal error: in bpstat_print\n");
650 /* Evaluate the expression EXP and return 1 if value is zero.
651 This is used inside a catch_errors to evaluate the breakpoint condition.
652 The argument is a "struct expression *" that has been cast to int to
653 make it pass through catch_errors. */
656 breakpoint_cond_eval (exp)
659 return value_zerop (evaluate_expression ((struct expression *)exp));
662 /* Allocate a new bpstat and chain it to the current one. */
665 bpstat_alloc (b, cbs)
666 register struct breakpoint *b;
667 bpstat cbs; /* Current "bs" value */
671 bs = (bpstat) xmalloc (sizeof (*bs));
673 bs->breakpoint_at = b;
674 /* If the condition is false, etc., don't do the commands. */
676 bs->momentary = b->number == -3;
681 /* Determine whether we stopped at a breakpoint, etc, or whether we
682 don't understand this stop. Result is a chain of bpstat's such that:
684 if we don't understand the stop, the result is a null pointer.
686 if we understand why we stopped, the result is not null, and
687 the first element of the chain contains summary "stop" and
688 "print" flags for the whole chain.
690 Each element of the chain refers to a particular breakpoint or
691 watchpoint at which we have stopped. (We may have stopped for
694 Each element of the chain has valid next, breakpoint_at,
695 commands, FIXME??? fields.
701 bpstat_stop_status (pc, frame_address)
703 FRAME_ADDR frame_address;
705 register struct breakpoint *b;
709 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
710 int real_breakpoint = 0;
711 /* Root of the chain of bpstat's */
712 struct bpstat__struct root_bs[1];
713 /* Pointer to the last thing in the chain currently. */
716 /* Get the address where the breakpoint would have been. */
717 bp_addr = *pc - DECR_PC_AFTER_BREAK;
724 if (b->enable == disabled)
726 if (b->address != NULL && b->address != bp_addr)
729 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
734 if (b->exp != NULL) /* Watchpoint */
736 int within_current_scope;
737 if (b->exp_valid_block != NULL)
738 within_current_scope =
739 contained_in (get_selected_block (), b->exp_valid_block);
741 within_current_scope = 1;
743 if (within_current_scope)
745 value new_val = evaluate_expression (b->exp);
746 release_value (new_val);
747 if (!value_equal (b->val, new_val))
749 bs->old_val = b->val;
751 /* We will stop here */
755 /* Nothing changed, don't do anything. */
756 value_free (new_val);
758 /* We won't stop here */
763 /* This seems like the only logical thing to do because
764 if we temporarily ignored the watchpoint, then when
765 we reenter the block in which it is valid it contains
766 garbage (in the case of a function, it may have two
767 garbage values, one before and one after the prologue).
768 So we can't even detect the first assignment to it and
769 watch after that (since the garbage may or may not equal
770 the first value assigned). */
771 b->enable = disabled;
773 Watchpoint %d disabled because the program has left the block in\n\
774 which its expression is valid.\n", b->number);
775 /* We won't stop here */
776 /* FIXME, maybe we should stop here!!! */
783 if (b->frame && b->frame != frame_address)
791 /* Need to select the frame, with all that implies
792 so that the conditions will have the right context. */
793 select_frame (get_current_frame (), 0);
795 = catch_errors (breakpoint_cond_eval, (int)(b->cond),
796 "Error occurred in testing breakpoint condition.");
799 if (b->cond && value_zero)
803 else if (b->ignore_count > 0)
810 /* We will stop here */
811 if (b->enable == temporary)
812 b->enable = disabled;
813 bs->commands = b->commands;
816 if (bs->commands && !strcmp ("silent", bs->commands->line))
818 bs->commands = bs->commands->next;
829 bs->next = NULL; /* Terminate the chain */
830 bs = root_bs->next; /* Re-grab the head of the chain */
835 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
839 #if defined (SHIFT_INST_REGS)
841 CORE_ADDR pc = read_register (PC_REGNUM);
842 CORE_ADDR npc = read_register (NPC_REGNUM);
845 write_register (NNPC_REGNUM, npc);
846 write_register (NPC_REGNUM, pc);
849 #else /* No SHIFT_INST_REGS. */
851 #endif /* No SHIFT_INST_REGS. */
853 #endif /* DECR_PC_AFTER_BREAK != 0. */
859 bpstat_should_step ()
861 struct breakpoint *b;
863 if (b->enable != disabled && b->exp != NULL)
868 /* Print information on breakpoint number BNUM, or -1 if all.
869 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
870 is nonzero, process only watchpoints. */
873 breakpoint_1 (bnum, watchpoints)
877 register struct breakpoint *b;
878 register struct command_line *l;
879 register struct symbol *sym;
880 CORE_ADDR last_addr = (CORE_ADDR)-1;
881 int header_printed = 0;
884 if (bnum == -1 || bnum == b->number)
886 if (b->address == NULL && !watchpoints)
890 error ("That is a watchpoint, not a breakpoint.");
892 if (b->address != NULL && watchpoints)
896 error ("That is a breakpoint, not a watchpoint.");
902 printf_filtered (" Enb Expression\n");
903 else if (addressprint)
904 printf_filtered (" Enb Address Where\n");
906 printf_filtered (" Enb Where\n");
910 printf_filtered ("#%-3d %c ", b->number, "nyod"[(int) b->enable]);
911 if (b->address == NULL) {
912 printf_filtered (" ");
913 print_expression (b->exp, stdout);
916 printf_filtered (" 0x%08x ", b->address);
918 last_addr = b->address;
921 sym = find_pc_function (b->address);
924 fputs_filtered (" in ", stdout);
925 fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
926 fputs_filtered (" at ", stdout);
928 fputs_filtered (b->symtab->filename, stdout);
929 printf_filtered (":%d", b->line_number);
932 print_address_symbolic (b->address, stdout, demangle);
935 printf_filtered ("\n");
938 printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame);
941 printf_filtered ("\tstop only if ");
942 print_expression (b->cond, stdout);
943 printf_filtered ("\n");
946 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
947 if ((l = b->commands))
950 fputs_filtered ("\t", stdout);
951 fputs_filtered (l->line, stdout);
952 fputs_filtered ("\n", stdout);
959 char *which = watchpoints ? "watch" : "break";
961 printf_filtered ("No %spoints.\n", which);
963 printf_filtered ("No %spoint numbered %d.\n", which, bnum);
966 /* Compare against (CORE_ADDR)-1 in case some compiler decides
967 that a comparison of an unsigned with -1 is always false. */
968 if (last_addr != (CORE_ADDR)-1)
969 set_next_address (last_addr);
973 breakpoints_info (bnum_exp, from_tty)
980 bnum = parse_and_eval_address (bnum_exp);
982 breakpoint_1 (bnum, 0);
986 watchpoints_info (bnum_exp, from_tty)
993 bnum = parse_and_eval_address (bnum_exp);
995 breakpoint_1 (bnum, 1);
998 /* Print a message describing any breakpoints set at PC. */
1001 describe_other_breakpoints (pc)
1002 register CORE_ADDR pc;
1004 register int others = 0;
1005 register struct breakpoint *b;
1008 if (b->address == pc)
1012 printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1014 if (b->address == pc)
1019 (b->enable == disabled) ? " (disabled)" : "",
1020 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1022 printf ("also set at pc 0x%x.\n", pc);
1026 /* Set the default place to put a breakpoint
1027 for the `break' command with no arguments. */
1030 set_default_breakpoint (valid, addr, symtab, line)
1033 struct symtab *symtab;
1036 default_breakpoint_valid = valid;
1037 default_breakpoint_address = addr;
1038 default_breakpoint_symtab = symtab;
1039 default_breakpoint_line = line;
1042 /* Rescan breakpoints at address ADDRESS,
1043 marking the first one as "first" and any others as "duplicates".
1044 This is so that the bpt instruction is only inserted once. */
1047 check_duplicates (address)
1050 register struct breakpoint *b;
1051 register int count = 0;
1053 if (address == NULL) /* Watchpoints are uninteresting */
1057 if (b->enable != disabled && b->address == address)
1060 b->duplicate = count > 1;
1064 /* Low level routine to set a breakpoint.
1065 Takes as args the three things that every breakpoint must have.
1066 Returns the breakpoint object so caller can set other things.
1067 Does not set the breakpoint number!
1068 Does not print anything.
1070 ==> This routine should not be called if there is a chance of later
1071 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1072 your arguments BEFORE calling this routine! */
1074 static struct breakpoint *
1075 set_raw_breakpoint (sal)
1076 struct symtab_and_line sal;
1078 register struct breakpoint *b, *b1;
1080 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1081 bzero (b, sizeof *b);
1082 b->address = sal.pc;
1083 b->symtab = sal.symtab;
1084 b->line_number = sal.line;
1085 b->enable = enabled;
1088 b->ignore_count = 0;
1092 /* Add this breakpoint to the end of the chain
1093 so that a list of breakpoints will come out in order
1094 of increasing numbers. */
1096 b1 = breakpoint_chain;
1098 breakpoint_chain = b;
1106 check_duplicates (sal.pc);
1111 /* Set a breakpoint that will evaporate an end of command
1112 at address specified by SAL.
1113 Restrict it to frame FRAME if FRAME is nonzero. */
1116 set_momentary_breakpoint (sal, frame)
1117 struct symtab_and_line sal;
1120 register struct breakpoint *b;
1121 b = set_raw_breakpoint (sal);
1124 b->frame = (frame ? FRAME_FP (frame) : 0);
1128 clear_momentary_breakpoints ()
1130 register struct breakpoint *b;
1132 if (b->number == -3)
1134 delete_breakpoint (b);
1139 /* Tell the user we have just set a breakpoint B. */
1142 struct breakpoint *b;
1146 printf_filtered ("Watchpoint %d: ", b->number);
1147 print_expression (b->exp, stdout);
1151 printf_filtered ("Breakpoint %d at 0x%x", b->number, b->address);
1153 printf_filtered (": file %s, line %d.",
1154 b->symtab->filename, b->line_number);
1156 printf_filtered ("\n");
1160 /* Nobody calls this currently. */
1161 /* Set a breakpoint from a symtab and line.
1162 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1163 ADDR_STRING is a malloc'd string holding the name of where we are
1164 setting the breakpoint. This is used later to re-set it after the
1165 program is relinked and symbols are reloaded.
1166 Print the same confirmation messages that the breakpoint command prints. */
1169 set_breakpoint (s, line, tempflag, addr_string)
1175 register struct breakpoint *b;
1176 struct symtab_and_line sal;
1180 sal.pc = find_line_pc (sal.symtab, sal.line);
1182 error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
1185 describe_other_breakpoints (sal.pc);
1187 b = set_raw_breakpoint (sal);
1188 set_breakpoint_count (breakpoint_count + 1);
1189 b->number = breakpoint_count;
1191 b->addr_string = addr_string;
1193 b->enable = temporary;
1200 /* Set a breakpoint according to ARG (function, linenum or *address)
1201 and make it temporary if TEMPFLAG is nonzero. */
1204 break_command_1 (arg, tempflag, from_tty)
1206 int tempflag, from_tty;
1208 struct symtabs_and_lines sals;
1209 struct symtab_and_line sal;
1210 register struct expression *cond = 0;
1211 register struct breakpoint *b;
1213 /* Pointers in arg to the start, and one past the end, of the condition. */
1214 char *cond_start = NULL;
1216 /* Pointers in arg to the start, and one past the end,
1217 of the address part. */
1218 char *addr_start = NULL;
1227 sal.line = sal.pc = sal.end = 0;
1230 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1232 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1233 && (arg[2] == ' ' || arg[2] == '\t')))
1235 if (default_breakpoint_valid)
1237 sals.sals = (struct symtab_and_line *)
1238 xmalloc (sizeof (struct symtab_and_line));
1239 sal.pc = default_breakpoint_address;
1240 sal.line = default_breakpoint_line;
1241 sal.symtab = default_breakpoint_symtab;
1246 error ("No default breakpoint address now.");
1252 /* Force almost all breakpoints to be in terms of the
1253 current_source_symtab (which is decode_line_1's default). This
1254 should produce the results we want almost all of the time while
1255 leaving default_breakpoint_* alone. */
1256 if (default_breakpoint_valid
1257 && (!current_source_symtab
1258 || (arg && (*arg == '+' || *arg == '-'))))
1259 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1260 default_breakpoint_line);
1262 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1270 for (i = 0; i < sals.nelts; i++)
1273 if (sal.pc == 0 && sal.symtab != 0)
1275 pc = find_line_pc (sal.symtab, sal.line);
1277 error ("No line %d in file \"%s\".",
1278 sal.line, sal.symtab->filename);
1285 if (arg[0] == 'i' && arg[1] == 'f'
1286 && (arg[2] == ' ' || arg[2] == '\t'))
1290 cond = parse_c_1 (&arg, block_for_pc (pc), 0);
1294 error ("Junk at end of arguments.");
1296 sals.sals[i].pc = pc;
1299 for (i = 0; i < sals.nelts; i++)
1304 describe_other_breakpoints (sal.pc);
1306 b = set_raw_breakpoint (sal);
1307 set_breakpoint_count (breakpoint_count + 1);
1308 b->number = breakpoint_count;
1312 b->addr_string = savestring (addr_start, addr_end - addr_start);
1314 b->cond_string = savestring (cond_start, cond_end - cond_start);
1317 b->enable = temporary;
1324 printf ("Multiple breakpoints were set.\n");
1325 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1331 break_command (arg, from_tty)
1335 break_command_1 (arg, 0, from_tty);
1339 tbreak_command (arg, from_tty)
1343 break_command_1 (arg, 1, from_tty);
1347 watch_command (arg, from_tty)
1351 struct breakpoint *b;
1352 struct symtab_and_line sal;
1353 struct expression *exp;
1354 struct block *exp_valid_block;
1361 /* Parse arguments. */
1362 innermost_block = NULL;
1363 exp = parse_c_expression (arg);
1364 exp_valid_block = innermost_block;
1365 val = evaluate_expression (exp);
1366 release_value (val);
1368 /* Now set up the breakpoint. */
1369 b = set_raw_breakpoint (sal);
1370 set_breakpoint_count (breakpoint_count + 1);
1371 b->number = breakpoint_count;
1373 b->exp_valid_block = exp_valid_block;
1376 b->cond_string = NULL;
1381 * Helper routine for the until_command routine in infcmd.c. Here
1382 * because it uses the mechanisms of breakpoints.
1385 until_break_command (arg, from_tty)
1389 struct symtabs_and_lines sals;
1390 struct symtab_and_line sal;
1391 FRAME prev_frame = get_prev_frame (selected_frame);
1393 clear_proceed_status ();
1395 /* Set a breakpoint where the user wants it and at return from
1398 if (default_breakpoint_valid)
1399 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1400 default_breakpoint_line);
1402 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1404 if (sals.nelts != 1)
1405 error ("Couldn't get information on specified line.");
1408 free (sals.sals); /* malloc'd, so freed */
1411 error ("Junk at end of arguments.");
1413 if (sal.pc == 0 && sal.symtab != 0)
1414 sal.pc = find_line_pc (sal.symtab, sal.line);
1417 error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
1419 set_momentary_breakpoint (sal, selected_frame);
1421 /* Keep within the current frame */
1425 struct frame_info *fi;
1427 fi = get_frame_info (prev_frame);
1428 sal = find_pc_line (fi->pc, 0);
1430 set_momentary_breakpoint (sal, prev_frame);
1433 proceed (-1, -1, 0);
1436 /* Set a breakpoint at the catch clause for NAME. */
1438 catch_breakpoint (name)
1444 disable_catch_breakpoint ()
1449 delete_catch_breakpoint ()
1454 enable_catch_breakpoint ()
1460 struct sal_chain *next;
1461 struct symtab_and_line sal;
1464 /* For each catch clause identified in ARGS, run FUNCTION
1465 with that clause as an argument. */
1466 static struct symtabs_and_lines
1467 map_catch_names (args, function)
1471 register char *p = args;
1473 struct symtabs_and_lines sals;
1474 struct sal_chain *sal_chain = 0;
1477 error_no_arg ("one or more catch names");
1485 /* Don't swallow conditional part. */
1486 if (p1[0] == 'i' && p1[1] == 'f'
1487 && (p1[2] == ' ' || p1[2] == '\t'))
1493 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
1497 if (*p1 && *p1 != ' ' && *p1 != '\t')
1498 error ("Arguments must be catch names.");
1504 struct sal_chain *next
1505 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
1506 next->next = sal_chain;
1507 next->sal = get_catch_sal (p);
1512 printf ("No catch clause for exception %s.\n", p);
1515 while (*p == ' ' || *p == '\t') p++;
1519 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
1521 static struct symtabs_and_lines
1522 get_catch_sals (this_level_only)
1523 int this_level_only;
1525 extern struct blockvector *blockvector_for_pc ();
1526 register struct blockvector *bl;
1527 register struct block *block = get_frame_block (selected_frame);
1528 int index, have_default = 0;
1529 struct frame_info *fi = get_frame_info (selected_frame);
1530 CORE_ADDR pc = fi->pc;
1531 struct symtabs_and_lines sals;
1532 struct sal_chain *sal_chain = 0;
1533 char *blocks_searched;
1539 error ("No symbol table info available.\n");
1541 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
1542 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1543 bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1547 CORE_ADDR end = BLOCK_END (block) - 4;
1550 if (bl != blockvector_for_pc (end, &index))
1551 error ("blockvector blotch");
1552 if (BLOCKVECTOR_BLOCK (bl, index) != block)
1553 error ("blockvector botch");
1554 last_index = BLOCKVECTOR_NBLOCKS (bl);
1557 /* Don't print out blocks that have gone by. */
1558 while (index < last_index
1559 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
1562 while (index < last_index
1563 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
1565 if (blocks_searched[index] == 0)
1567 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
1570 register struct symbol *sym;
1572 nsyms = BLOCK_NSYMS (b);
1574 for (i = 0; i < nsyms; i++)
1576 sym = BLOCK_SYM (b, i);
1577 if (! strcmp (SYMBOL_NAME (sym), "default"))
1583 if (SYMBOL_CLASS (sym) == LOC_LABEL)
1585 struct sal_chain *next = (struct sal_chain *)
1586 alloca (sizeof (struct sal_chain));
1587 next->next = sal_chain;
1588 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
1592 blocks_searched[index] = 1;
1598 if (sal_chain && this_level_only)
1601 /* After handling the function's top-level block, stop.
1602 Don't continue to its superblock, the block of
1603 per-file symbols. */
1604 if (BLOCK_FUNCTION (block))
1606 block = BLOCK_SUPERBLOCK (block);
1611 struct sal_chain *tmp_chain;
1613 /* Count the number of entries. */
1614 for (index = 0, tmp_chain = sal_chain; tmp_chain;
1615 tmp_chain = tmp_chain->next)
1619 sals.sals = (struct symtab_and_line *)
1620 xmalloc (index * sizeof (struct symtab_and_line));
1621 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
1622 sals.sals[index] = sal_chain->sal;
1628 /* Commands to deal with catching exceptions. */
1631 catch_command_1 (arg, tempflag, from_tty)
1636 /* First, translate ARG into something we can deal with in terms
1639 struct symtabs_and_lines sals;
1640 struct symtab_and_line sal;
1641 register struct expression *cond = 0;
1642 register struct breakpoint *b;
1647 sal.line = sal.pc = sal.end = 0;
1650 /* If no arg given, or if first arg is 'if ', all active catch clauses
1651 are breakpointed. */
1653 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1654 && (arg[2] == ' ' || arg[2] == '\t')))
1656 /* Grab all active catch clauses. */
1657 sals = get_catch_sals (0);
1661 /* Grab selected catch clauses. */
1662 error ("catch NAME not implemeneted");
1663 sals = map_catch_names (arg, catch_breakpoint);
1670 for (i = 0; i < sals.nelts; i++)
1673 if (sal.pc == 0 && sal.symtab != 0)
1675 pc = find_line_pc (sal.symtab, sal.line);
1677 error ("No line %d in file \"%s\".",
1678 sal.line, sal.symtab->filename);
1685 if (arg[0] == 'i' && arg[1] == 'f'
1686 && (arg[2] == ' ' || arg[2] == '\t'))
1687 cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
1688 block_for_pc (pc), 0);
1690 error ("Junk at end of arguments.");
1693 sals.sals[i].pc = pc;
1696 for (i = 0; i < sals.nelts; i++)
1701 describe_other_breakpoints (sal.pc);
1703 b = set_raw_breakpoint (sal);
1704 b->number = ++breakpoint_count;
1707 b->enable = temporary;
1709 printf ("Breakpoint %d at 0x%x", b->number, b->address);
1711 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
1717 printf ("Multiple breakpoints were set.\n");
1718 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1723 /* Disable breakpoints on all catch clauses described in ARGS. */
1725 disable_catch (args)
1728 /* Map the disable command to catch clauses described in ARGS. */
1731 /* Enable breakpoints on all catch clauses described in ARGS. */
1736 /* Map the disable command to catch clauses described in ARGS. */
1739 /* Delete breakpoints on all catch clauses in the active scope. */
1744 /* Map the delete command to catch clauses described in ARGS. */
1748 catch_command (arg, from_tty)
1752 catch_command_1 (arg, 0, from_tty);
1756 clear_command (arg, from_tty)
1760 register struct breakpoint *b, *b1;
1761 struct symtabs_and_lines sals;
1762 struct symtab_and_line sal;
1763 register struct breakpoint *found;
1768 sals = decode_line_spec (arg, 1);
1772 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
1773 sal.line = default_breakpoint_line;
1774 sal.symtab = default_breakpoint_symtab;
1776 if (sal.symtab == 0)
1777 error ("No source file specified.");
1783 for (i = 0; i < sals.nelts; i++)
1785 /* If exact pc given, clear bpts at that pc.
1786 But if sal.pc is zero, clear all bpts on specified line. */
1788 found = (struct breakpoint *) 0;
1789 while (breakpoint_chain
1790 && (sal.pc ? breakpoint_chain->address == sal.pc
1791 : (breakpoint_chain->symtab == sal.symtab
1792 && breakpoint_chain->line_number == sal.line)))
1794 b1 = breakpoint_chain;
1795 breakpoint_chain = b1->next;
1802 && b->next->address != NULL
1803 && (sal.pc ? b->next->address == sal.pc
1804 : (b->next->symtab == sal.symtab
1805 && b->next->line_number == sal.line)))
1816 error ("No breakpoint at %s.", arg);
1818 error ("No breakpoint at this line.");
1821 if (found->next) from_tty = 1; /* Always report if deleted more than one */
1822 if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
1825 if (from_tty) printf ("%d ", found->number);
1827 delete_breakpoint (found);
1830 if (from_tty) putchar ('\n');
1835 /* Delete breakpoint in BS if they are `delete' breakpoints.
1836 This is called after any breakpoint is hit, or after errors. */
1839 breakpoint_auto_delete (bs)
1842 for (; bs; bs = bs->next)
1843 if (bs->breakpoint_at && bs->breakpoint_at->enable == delete)
1844 delete_breakpoint (bs->breakpoint_at);
1847 /* Delete a breakpoint and clean up all traces of it in the data structures. */
1850 delete_breakpoint (bpt)
1851 struct breakpoint *bpt;
1853 register struct breakpoint *b;
1857 target_remove_breakpoint(bpt->address, bpt->shadow_contents);
1859 if (breakpoint_chain == bpt)
1860 breakpoint_chain = bpt->next;
1865 b->next = bpt->next;
1869 check_duplicates (bpt->address);
1871 free_command_lines (&bpt->commands);
1874 if (bpt->cond_string != NULL)
1875 free (bpt->cond_string);
1876 if (bpt->addr_string != NULL)
1877 free (bpt->addr_string);
1879 if (xgdb_verbose && bpt->number >=0)
1880 printf ("breakpoint #%d deleted\n", bpt->number);
1882 /* Be sure no bpstat's are pointing at it after it's been freed. */
1883 /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */
1884 for (bs = stop_bpstat; bs; bs = bs->next)
1885 if (bs->breakpoint_at == bpt)
1886 bs->breakpoint_at = NULL;
1890 static void map_breakpoint_numbers ();
1893 delete_command (arg, from_tty)
1900 /* Ask user only if there are some breakpoints to delete. */
1902 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
1904 /* No arg; clear all breakpoints. */
1905 while (breakpoint_chain)
1906 delete_breakpoint (breakpoint_chain);
1910 map_breakpoint_numbers (arg, delete_breakpoint);
1914 breakpoint_re_set_one (bint)
1917 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
1919 struct symtabs_and_lines sals;
1920 struct symtab_and_line sal;
1923 if (b->address != NULL && b->addr_string != NULL)
1926 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0);
1927 for (i = 0; i < sals.nelts; i++)
1931 b->symtab = sal.symtab;
1932 b->line_number = sal.line;
1933 if (sal.pc == 0 && sal.symtab != 0)
1935 sal.pc = find_line_pc (sal.symtab, sal.line);
1937 error ("No line %d in file \"%s\".",
1938 sal.line, sal.symtab->filename);
1940 b->address = sal.pc;
1942 if (b->cond_string != NULL)
1945 b->cond = parse_c_1 (&s, block_for_pc (sal.pc), 0);
1948 check_duplicates (b->address);
1956 /* Anything without a string can't be re-set. */
1957 delete_breakpoint (b);
1961 /* Re-set all breakpoints after symbols have been re-loaded. */
1963 breakpoint_re_set ()
1965 struct breakpoint *b;
1969 b->symtab = 0; /* Be sure we don't point to old dead symtab */
1970 (void) catch_errors (breakpoint_re_set_one, (int) b,
1971 "Error in re-setting breakpoint");
1974 /* Blank line to finish off all those mention() messages we just printed. */
1975 printf_filtered ("\n");
1978 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
1979 If from_tty is nonzero, it prints a message to that effect,
1980 which ends with a period (no newline). */
1983 set_ignore_count (bptnum, count, from_tty)
1984 int bptnum, count, from_tty;
1986 register struct breakpoint *b;
1992 if (b->number == bptnum)
1994 b->ignore_count = count;
1997 else if (count == 0)
1998 printf ("Will stop next time breakpoint %d is reached.", bptnum);
1999 else if (count == 1)
2000 printf ("Will ignore next crossing of breakpoint %d.", bptnum);
2002 printf ("Will ignore next %d crossings of breakpoint %d.",
2007 error ("No breakpoint number %d.", bptnum);
2010 /* Clear the ignore counts of all breakpoints. */
2012 breakpoint_clear_ignore_counts ()
2014 struct breakpoint *b;
2017 b->ignore_count = 0;
2020 /* Command to set ignore-count of breakpoint N to COUNT. */
2023 ignore_command (args, from_tty)
2031 error_no_arg ("a breakpoint number");
2033 num = get_number (&p);
2036 error ("Second argument (specified ignore-count) is missing.");
2038 set_ignore_count (num, parse_and_eval_address (p), from_tty);
2042 /* Call FUNCTION on each of the breakpoints
2043 whose numbers are given in ARGS. */
2046 map_breakpoint_numbers (args, function)
2048 void (*function) ();
2050 register char *p = args;
2053 register struct breakpoint *b;
2056 error_no_arg ("one or more breakpoint numbers");
2062 num = get_number (&p1);
2065 if (b->number == num)
2070 printf ("No breakpoint number %d.\n", num);
2077 enable_breakpoint (bpt)
2078 struct breakpoint *bpt;
2080 bpt->enable = enabled;
2082 if (xgdb_verbose && bpt->number >= 0)
2083 printf ("breakpoint #%d enabled\n", bpt->number);
2085 check_duplicates (bpt->address);
2086 if (bpt->val != NULL)
2088 if (bpt->exp_valid_block != NULL
2089 && !contained_in (get_selected_block (), bpt->exp_valid_block))
2092 Cannot enable watchpoint %d because the block in which its expression\n\
2093 is valid is not currently in scope.\n", bpt->number);
2097 value_free (bpt->val);
2099 bpt->val = evaluate_expression (bpt->exp);
2100 release_value (bpt->val);
2105 enable_command (args, from_tty)
2109 struct breakpoint *bpt;
2111 ALL_BREAKPOINTS (bpt)
2112 enable_breakpoint (bpt);
2114 map_breakpoint_numbers (args, enable_breakpoint);
2118 disable_breakpoint (bpt)
2119 struct breakpoint *bpt;
2121 bpt->enable = disabled;
2123 if (xgdb_verbose && bpt->number >= 0)
2124 printf ("breakpoint #%d disabled\n", bpt->number);
2126 check_duplicates (bpt->address);
2130 disable_command (args, from_tty)
2134 register struct breakpoint *bpt;
2136 ALL_BREAKPOINTS (bpt)
2137 disable_breakpoint (bpt);
2139 map_breakpoint_numbers (args, disable_breakpoint);
2143 enable_once_breakpoint (bpt)
2144 struct breakpoint *bpt;
2146 bpt->enable = temporary;
2148 check_duplicates (bpt->address);
2152 enable_once_command (args, from_tty)
2156 map_breakpoint_numbers (args, enable_once_breakpoint);
2160 enable_delete_breakpoint (bpt)
2161 struct breakpoint *bpt;
2163 bpt->enable = delete;
2165 check_duplicates (bpt->address);
2169 enable_delete_command (args, from_tty)
2173 map_breakpoint_numbers (args, enable_delete_breakpoint);
2177 * Use default_breakpoint_'s, or nothing if they aren't valid.
2179 struct symtabs_and_lines
2180 decode_line_spec_1 (string, funfirstline)
2184 struct symtabs_and_lines sals;
2186 error ("Empty line specification.");
2187 if (default_breakpoint_valid)
2188 sals = decode_line_1 (&string, funfirstline,
2189 default_breakpoint_symtab, default_breakpoint_line);
2191 sals = decode_line_1 (&string, funfirstline, (struct symtab *)NULL, 0);
2193 error ("Junk at end of line specification: %s", string);
2198 /* Chain containing all defined enable commands. */
2200 extern struct cmd_list_element
2201 *enablelist, *disablelist,
2202 *deletelist, *enablebreaklist;
2204 extern struct cmd_list_element *cmdlist;
2207 _initialize_breakpoint ()
2209 breakpoint_chain = 0;
2210 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
2211 before a breakpoint is set. */
2212 breakpoint_count = 0;
2214 add_com ("ignore", class_breakpoint, ignore_command,
2215 "Set ignore-count of breakpoint number N to COUNT.");
2217 add_com ("commands", class_breakpoint, commands_command,
2218 "Set commands to be executed when a breakpoint is hit.\n\
2219 Give breakpoint number as argument after \"commands\".\n\
2220 With no argument, the targeted breakpoint is the last one set.\n\
2221 The commands themselves follow starting on the next line.\n\
2222 Type a line containing \"end\" to indicate the end of them.\n\
2223 Give \"silent\" as the first line to make the breakpoint silent;\n\
2224 then no output is printed when it is hit, except what the commands print.");
2226 add_com ("condition", class_breakpoint, condition_command,
2227 "Specify breakpoint number N to break only if COND is true.\n\
2228 N is an integer; COND is a C expression to be evaluated whenever\n\
2229 breakpoint N is reached. Actually break only when COND is nonzero.");
2231 add_com ("tbreak", class_breakpoint, tbreak_command,
2232 "Set a temporary breakpoint. Args like \"break\" command.\n\
2233 Like \"break\" except the breakpoint is only enabled temporarily,\n\
2234 so it will be disabled when hit. Equivalent to \"break\" followed\n\
2235 by using \"enable once\" on the breakpoint number.");
2237 add_prefix_cmd ("enable", class_breakpoint, enable_command,
2238 "Enable some breakpoints.\n\
2239 Give breakpoint numbers (separated by spaces) as arguments.\n\
2240 With no subcommand, breakpoints are enabled until you command otherwise.\n\
2241 This is used to cancel the effect of the \"disable\" command.\n\
2242 With a subcommand you can enable temporarily.",
2243 &enablelist, "enable ", 1, &cmdlist);
2245 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
2246 "Enable some breakpoints.\n\
2247 Give breakpoint numbers (separated by spaces) as arguments.\n\
2248 This is used to cancel the effect of the \"disable\" command.\n\
2249 May be abbreviated to simply \"enable\".\n",
2250 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
2252 add_cmd ("once", no_class, enable_once_command,
2253 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2254 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2255 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2258 add_cmd ("delete", no_class, enable_delete_command,
2259 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2260 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2263 add_cmd ("delete", no_class, enable_delete_command,
2264 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2265 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2268 add_cmd ("once", no_class, enable_once_command,
2269 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2270 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2271 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2274 add_prefix_cmd ("disable", class_breakpoint, disable_command,
2275 "Disable some breakpoints.\n\
2276 Arguments are breakpoint numbers with spaces in between.\n\
2277 To disable all breakpoints, give no argument.\n\
2278 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
2279 &disablelist, "disable ", 1, &cmdlist);
2280 add_com_alias ("dis", "disable", class_breakpoint, 1);
2281 add_com_alias ("disa", "disable", class_breakpoint, 1);
2283 add_cmd ("breakpoints", class_alias, disable_command,
2284 "Disable some breakpoints.\n\
2285 Arguments are breakpoint numbers with spaces in between.\n\
2286 To disable all breakpoints, give no argument.\n\
2287 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
2288 This command may be abbreviated \"disable\".",
2291 add_prefix_cmd ("delete", class_breakpoint, delete_command,
2292 "Delete some breakpoints or auto-display expressions.\n\
2293 Arguments are breakpoint numbers with spaces in between.\n\
2294 To delete all breakpoints, give no argument.\n\
2296 Also a prefix command for deletion of other GDB objects.\n\
2297 The \"unset\" command is also an alias for \"delete\".",
2298 &deletelist, "delete ", 1, &cmdlist);
2299 add_com_alias ("d", "delete", class_breakpoint, 1);
2301 add_cmd ("breakpoints", class_alias, delete_command,
2302 "Delete some breakpoints or auto-display expressions.\n\
2303 Arguments are breakpoint numbers with spaces in between.\n\
2304 To delete all breakpoints, give no argument.\n\
2305 This command may be abbreviated \"delete\".",
2308 add_com ("clear", class_breakpoint, clear_command,
2309 "Clear breakpoint at specified line or function.\n\
2310 Argument may be line number, function name, or \"*\" and an address.\n\
2311 If line number is specified, all breakpoints in that line are cleared.\n\
2312 If function is specified, breakpoints at beginning of function are cleared.\n\
2313 If an address is specified, breakpoints at that address are cleared.\n\n\
2314 With no argument, clears all breakpoints in the line that the selected frame\n\
2317 See also the \"delete\" command which clears breakpoints by number.");
2319 add_com ("break", class_breakpoint, break_command,
2320 "Set breakpoint at specified line or function.\n\
2321 Argument may be line number, function name, or \"*\" and an address.\n\
2322 If line number is specified, break at start of code for that line.\n\
2323 If function is specified, break at start of code for that function.\n\
2324 If an address is specified, break at that exact address.\n\
2325 With no arg, uses current execution address of selected stack frame.\n\
2326 This is useful for breaking on return to a stack frame.\n\
2328 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
2330 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2331 add_com_alias ("b", "break", class_run, 1);
2332 add_com_alias ("br", "break", class_run, 1);
2333 add_com_alias ("bre", "break", class_run, 1);
2334 add_com_alias ("brea", "break", class_run, 1);
2336 add_info ("breakpoints", breakpoints_info,
2337 "Status of all breakpoints, or breakpoint number NUMBER.\n\
2338 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
2339 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
2340 Then come the address and the file/line number.\n\n\
2341 Convenience variable \"$_\" and default examine address for \"x\"\n\
2342 are set to the address of the last breakpoint listed.\n\n\
2343 Convenience variable \"$bpnum\" contains the number of the last\n\
2346 add_com ("catch", class_breakpoint, catch_command,
2347 "Set breakpoints to catch exceptions that are raised.\n\
2348 Argument may be a single exception to catch, multiple exceptions\n\
2349 to catch, or the default exception \"default\". If no arguments\n\
2350 are given, breakpoints are set at all exception handlers catch clauses\n\
2351 within the current scope.\n\
2353 A condition specified for the catch applies to all breakpoints set\n\
2354 with this command\n\
2356 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2358 add_com ("watch", class_breakpoint, watch_command,
2359 "Set a watchpoint for an expression.\n\
2360 A watchpoint stops execution of your program whenever the value of\n\
2361 an expression changes.");
2363 add_info ("watchpoints", watchpoints_info,
2364 "Status of all watchpoints, or watchpoint number NUMBER.\n\
2365 Second column is \"y\" for enabled watchpoints, \"n\" for disabled.");