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 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "breakpoint.h"
27 #include "expression.h"
38 extern int addressprint; /* Print machine addresses? */
39 extern int demangle; /* Print de-mangled symbol names? */
41 extern int catch_errors ();
42 extern void set_next_address (); /* ...for x/ command */
44 /* Are we executing breakpoint commands? */
45 static int executing_breakpoint_commands;
47 /* States of enablement of breakpoint.
48 `temporary' means disable when hit.
49 `delete' means delete when hit. */
51 enum enable { disabled, enabled, temporary, delete};
53 /* Not that the ->silent field is not currently used by any commands
54 (though the code is in there if it was to be, and set_raw_breakpoint
55 does set it to 0). I implemented it because I thought it would be
56 useful for a hack I had to put in; I'm going to leave it in because
57 I can see how there might be times when it would indeed be useful */
59 /* This is for a breakpoint or a watchpoint. */
63 struct breakpoint *next;
64 /* Number assigned to distinguish breakpoints. */
66 /* Address to break at, or NULL if not a breakpoint. */
68 /* Line number of this address. Redundant. Only matters if address
71 /* Symtab of file of this address. Redundant. Only matters if address
73 struct symtab *symtab;
74 /* Zero means disabled; remember the info but don't break here. */
76 /* Non-zero means a silent breakpoint (don't print frame info
79 /* Number of stops at this breakpoint that should
80 be continued automatically before really stopping. */
82 /* "Real" contents of byte where breakpoint has been inserted.
83 Valid only when breakpoints are in the program. Under the complete
84 control of the target insert_breakpoint and remove_breakpoint routines.
85 No other code should assume anything about the value(s) here. */
86 char shadow_contents[BREAKPOINT_MAX];
87 /* Nonzero if this breakpoint is now inserted. Only matters if address
90 /* Nonzero if this is not the first breakpoint in the list
91 for the given address. Only matters if address is non-NULL. */
93 /* Chain of command lines to execute when this breakpoint is hit. */
94 struct command_line *commands;
95 /* Stack depth (address of frame). If nonzero, break only if fp
98 /* Conditional. Break only if this expression's value is nonzero. */
99 struct expression *cond;
101 /* String we used to set the breakpoint (malloc'd). Only matters if
102 address is non-NULL. */
104 /* String form of the breakpoint condition (malloc'd), or NULL if there
108 /* The expression we are watching, or NULL if not a watchpoint. */
109 struct expression *exp;
110 /* The largest block within which it is valid, or NULL if it is
111 valid anywhere (e.g. consists just of global symbols). */
112 struct block *exp_valid_block;
113 /* Value of the watchpoint the last time we checked it. */
117 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
119 /* Chain of all breakpoints defined. */
121 struct breakpoint *breakpoint_chain;
123 /* Number of last breakpoint made. */
125 static int breakpoint_count;
127 /* Set breakpoint count to NUM. */
129 set_breakpoint_count (num)
132 breakpoint_count = num;
133 set_internalvar (lookup_internalvar ("bpnum"),
134 value_from_longest (builtin_type_int, (LONGEST) num));
137 /* Default address, symtab and line to put a breakpoint at
138 for "break" command with no arg.
139 if default_breakpoint_valid is zero, the other three are
140 not valid, and "break" with no arg is an error.
142 This set by print_stack_frame, which calls set_default_breakpoint. */
144 int default_breakpoint_valid;
145 CORE_ADDR default_breakpoint_address;
146 struct symtab *default_breakpoint_symtab;
147 int default_breakpoint_line;
149 static void delete_breakpoint ();
150 void breakpoint_auto_delete ();
152 /* Flag indicating extra verbosity for xgdb. */
153 extern int xgdb_verbose;
155 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
156 Advance *PP after the string and any trailing whitespace.
158 Currently the string can either be a number or "$" followed by the name
159 of a convenience variable. Making it an expression wouldn't work well
160 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
169 /* Empty line means refer to the last breakpoint. */
170 return breakpoint_count;
173 /* Make a copy of the name, so we can null-terminate it
174 to pass to lookup_internalvar(). */
179 while (isalnum (*p) || *p == '_')
181 varname = (char *) alloca (p - start + 1);
182 strncpy (varname, start, p - start);
183 varname[p - start] = '\0';
184 val = value_of_internalvar (lookup_internalvar (varname));
185 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
187 "Convenience variables used to specify breakpoints must have integer values."
189 retval = (int) value_as_long (val);
193 while (*p >= '0' && *p <= '9')
196 /* There is no number here. (e.g. "cond a == b"). */
197 error_no_arg ("breakpoint number");
200 if (!(isspace (*p) || *p == '\0'))
201 error ("breakpoint number expected");
208 /* condition N EXP -- set break condition of breakpoint N to EXP. */
211 condition_command (arg, from_tty)
215 register struct breakpoint *b;
220 error_no_arg ("breakpoint number");
223 bnum = get_number (&p);
226 if (b->number == bnum)
233 if (b->cond_string != NULL)
234 free (b->cond_string);
239 b->cond_string = NULL;
241 printf ("Breakpoint %d now unconditional.\n", bnum);
246 /* I don't know if it matters whether this is the string the user
247 typed in or the decompiled expression. */
248 b->cond_string = savestring (arg, strlen (arg));
249 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
251 error ("Junk at end of expression");
256 error ("No breakpoint number %d.", bnum);
261 commands_command (arg, from_tty)
265 register struct breakpoint *b;
268 struct command_line *l;
270 /* If we allowed this, we would have problems with when to
271 free the storage, if we change the commands currently
274 if (executing_breakpoint_commands)
275 error ("Can't use the \"commands\" command among a breakpoint's commands.");
278 bnum = get_number (&p);
280 error ("Unexpected extra arguments following breakpoint number.");
283 if (b->number == bnum)
285 if (from_tty && input_from_terminal_p ())
287 printf ("Type commands for when breakpoint %d is hit, one per line.\n\
288 End with a line saying just \"end\".\n", bnum);
291 l = read_command_lines ();
292 free_command_lines (&b->commands);
296 error ("No breakpoint number %d.", bnum);
299 extern int memory_breakpoint_size; /* from mem-break.c */
301 /* Like target_read_memory() but if breakpoints are inserted, return
302 the shadow contents instead of the breakpoints themselves. */
304 read_memory_nobpt (memaddr, myaddr, len)
310 struct breakpoint *b;
312 if (memory_breakpoint_size < 0)
313 /* No breakpoints on this machine. */
314 return target_read_memory (memaddr, myaddr, len);
318 if (b->address == NULL || !b->inserted)
320 else if (b->address + memory_breakpoint_size <= memaddr)
321 /* The breakpoint is entirely before the chunk of memory
324 else if (b->address >= memaddr + len)
325 /* The breakpoint is entirely after the chunk of memory we
330 /* Copy the breakpoint from the shadow contents, and recurse
331 for the things before and after. */
333 /* Addresses and length of the part of the breakpoint that
335 CORE_ADDR membpt = b->address;
336 unsigned int bptlen = memory_breakpoint_size;
337 /* Offset within shadow_contents. */
340 if (membpt < memaddr)
342 /* Only copy the second part of the breakpoint. */
343 bptlen -= memaddr - membpt;
344 bptoffset = memaddr - membpt;
348 if (membpt + bptlen > memaddr + len)
350 /* Only copy the first part of the breakpoint. */
351 bptlen -= (membpt + bptlen) - (memaddr + len);
354 bcopy (b->shadow_contents + bptoffset,
355 myaddr + membpt - memaddr, bptlen);
357 if (membpt > memaddr)
359 /* Copy the section of memory before the breakpoint. */
360 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
365 if (membpt + bptlen < memaddr + len)
367 /* Copy the section of memory after the breakpoint. */
368 status = read_memory_nobpt
370 myaddr + membpt + bptlen - memaddr,
371 memaddr + len - (membpt + bptlen));
378 /* Nothing overlaps. Just call read_memory_noerr. */
379 return target_read_memory (memaddr, myaddr, len);
382 /* insert_breakpoints is used when starting or continuing the program.
383 remove_breakpoints is used when the program stops.
384 Both return zero if successful,
385 or an `errno' value if could not write the inferior. */
388 insert_breakpoints ()
390 register struct breakpoint *b;
392 int disabled_breaks = 0;
395 if (b->address != NULL
396 && b->enable != disabled
400 val = target_insert_breakpoint(b->address, b->shadow_contents);
403 /* Can't set the breakpoint. */
404 #if defined (DISABLE_UNSETTABLE_BREAK)
405 if (DISABLE_UNSETTABLE_BREAK (b->address))
408 b->enable = disabled;
409 if (!disabled_breaks)
412 "Cannot insert breakpoint %d:\n", b->number);
413 printf_filtered ("Disabling shared library breakpoints:\n");
416 printf_filtered ("%d ", b->number);
421 fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number);
422 #ifdef ONE_PROCESS_WRITETEXT
424 "The same program may be running in another process.\n");
426 memory_error (val, b->address); /* which bombs us out */
433 printf_filtered ("\n");
438 remove_breakpoints ()
440 register struct breakpoint *b;
443 #ifdef BREAKPOINT_DEBUG
444 printf ("Removing breakpoints.\n");
445 #endif /* BREAKPOINT_DEBUG */
448 if (b->address != NULL && b->inserted)
450 val = target_remove_breakpoint(b->address, b->shadow_contents);
454 #ifdef BREAKPOINT_DEBUG
455 printf ("Removed breakpoint at %s",
456 local_hex_string(b->address));
457 printf (", shadow %s",
458 local_hex_string(b->shadow_contents[0]));
460 local_hex_string(b->shadow_contents[1]));
461 #endif /* BREAKPOINT_DEBUG */
467 /* Clear the "inserted" flag in all breakpoints.
468 This is done when the inferior is loaded. */
471 mark_breakpoints_out ()
473 register struct breakpoint *b;
479 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
480 When continuing from a location with a breakpoint,
481 we actually single step once before calling insert_breakpoints. */
484 breakpoint_here_p (pc)
487 register struct breakpoint *b;
490 if (b->enable != disabled && b->address == pc)
496 /* bpstat stuff. External routines' interfaces are documented
511 if (p->old_val != NULL)
512 value_free (p->old_val);
530 for (; bs != NULL; bs = bs->next)
532 tmp = (bpstat) xmalloc (sizeof (*tmp));
533 bcopy (bs, tmp, sizeof (*tmp));
535 /* This is the first thing in the chain. */
549 struct breakpoint *b;
552 return 0; /* No more breakpoint values */
555 b = (*bsp)->breakpoint_at;
558 return -1; /* breakpoint that's been deleted since */
560 return b->number; /* We have its number */
565 bpstat_clear_actions (bs)
568 for (; bs != NULL; bs = bs->next)
571 if (bs->old_val != NULL)
573 value_free (bs->old_val);
579 /* Stub for cleaning up our state if we error-out of a breakpoint command */
582 cleanup_executing_breakpoints (ignore)
585 executing_breakpoint_commands = 0;
588 /* Execute all the commands associated with all the breakpoints at this
589 location. Any of these commands could cause the process to proceed
590 beyond this point, etc. We look out for such changes by checking
591 the global "breakpoint_proceeded" after each command. */
593 bpstat_do_actions (bsp)
597 struct cleanup *old_chain;
599 executing_breakpoint_commands = 1;
600 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
605 breakpoint_proceeded = 0;
606 for (; bs != NULL; bs = bs->next)
610 char *line = bs->commands->line;
611 bs->commands = bs->commands->next;
612 execute_command (line, 0);
613 /* If the inferior is proceeded by the command, bomb out now.
614 The bpstat chain has been blown away by wait_for_inferior.
615 But since execution has stopped again, there is a new bpstat
616 to look at, so start over. */
617 if (breakpoint_proceeded)
621 clear_momentary_breakpoints ();
623 executing_breakpoint_commands = 0;
624 discard_cleanups (old_chain);
631 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
632 which has since been deleted. */
633 if (bs == NULL || bs->breakpoint_at == NULL)
636 /* If bpstat_stop_status says don't print, OK, we won't. An example
637 circumstance is when we single-stepped for both a watchpoint and
638 for a "stepi" instruction. The bpstat says that the watchpoint
639 explains the stop, but we shouldn't print because the watchpoint's
640 value didn't change -- and the real reason we are stopping here
641 rather than continuing to step (as the watchpoint would've had us do)
642 is because of the "stepi". */
646 if (bs->breakpoint_at->address != NULL)
648 /* I think the user probably only wants to see one breakpoint
649 number, not all of them. */
650 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
654 if (bs->old_val != NULL)
656 printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number);
657 print_expression (bs->breakpoint_at->exp, stdout);
658 printf_filtered ("\nOld value = ");
659 value_print (bs->old_val, stdout, 0, Val_pretty_default);
660 printf_filtered ("\nNew value = ");
661 value_print (bs->breakpoint_at->val, stdout, 0,
663 printf_filtered ("\n");
664 value_free (bs->old_val);
669 /* Maybe another breakpoint in the chain caused us to stop.
670 (Currently all watchpoints go on the bpstat whether hit or
671 not. That probably could (should) be changed, provided care is taken
672 with respect to bpstat_explains_signal). */
674 return bpstat_print (bs->next);
676 fprintf_filtered (stderr, "gdb internal error: in bpstat_print\n");
680 /* Evaluate the expression EXP and return 1 if value is zero.
681 This is used inside a catch_errors to evaluate the breakpoint condition.
682 The argument is a "struct expression *" that has been cast to char * to
683 make it pass through catch_errors. */
686 breakpoint_cond_eval (exp)
689 return !value_true (evaluate_expression ((struct expression *)exp));
692 /* Allocate a new bpstat and chain it to the current one. */
695 bpstat_alloc (b, cbs)
696 register struct breakpoint *b;
697 bpstat cbs; /* Current "bs" value */
701 bs = (bpstat) xmalloc (sizeof (*bs));
703 bs->breakpoint_at = b;
704 /* If the condition is false, etc., don't do the commands. */
706 bs->momentary = b->number == -3;
711 /* Determine whether we stopped at a breakpoint, etc, or whether we
712 don't understand this stop. Result is a chain of bpstat's such that:
714 if we don't understand the stop, the result is a null pointer.
716 if we understand why we stopped, the result is not null, and
717 the first element of the chain contains summary "stop" and
718 "print" flags for the whole chain.
720 Each element of the chain refers to a particular breakpoint or
721 watchpoint at which we have stopped. (We may have stopped for
724 Each element of the chain has valid next, breakpoint_at,
725 commands, FIXME??? fields.
731 bpstat_stop_status (pc, frame_address)
733 FRAME_ADDR frame_address;
735 register struct breakpoint *b;
739 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
740 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
741 int real_breakpoint = 0;
743 /* Root of the chain of bpstat's */
744 struct bpstat__struct root_bs[1];
745 /* Pointer to the last thing in the chain currently. */
748 /* Get the address where the breakpoint would have been. */
749 bp_addr = *pc - DECR_PC_AFTER_BREAK;
756 if (b->enable == disabled)
758 if (b->address != NULL && b->address != bp_addr)
761 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
766 if (b->exp != NULL) /* Watchpoint */
768 int within_current_scope;
769 if (b->exp_valid_block != NULL)
770 within_current_scope =
771 contained_in (get_selected_block (), b->exp_valid_block);
773 within_current_scope = 1;
775 if (within_current_scope)
777 /* We use value_{,free_to_}mark because it could be a
778 *long* time before we return to the command level and
779 call free_all_values. */
781 value mark = value_mark ();
782 value new_val = evaluate_expression (b->exp);
783 if (!value_equal (b->val, new_val))
785 release_value (new_val);
786 value_free_to_mark (mark);
787 bs->old_val = b->val;
789 /* We will stop here */
793 /* Nothing changed, don't do anything. */
794 value_free_to_mark (mark);
796 /* We won't stop here */
801 /* This seems like the only logical thing to do because
802 if we temporarily ignored the watchpoint, then when
803 we reenter the block in which it is valid it contains
804 garbage (in the case of a function, it may have two
805 garbage values, one before and one after the prologue).
806 So we can't even detect the first assignment to it and
807 watch after that (since the garbage may or may not equal
808 the first value assigned). */
809 b->enable = disabled;
811 Watchpoint %d disabled because the program has left the block in\n\
812 which its expression is valid.\n", b->number);
813 /* We won't stop here */
814 /* FIXME, maybe we should stop here!!! */
818 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
823 if (b->frame && b->frame != frame_address)
831 /* Need to select the frame, with all that implies
832 so that the conditions will have the right context. */
833 select_frame (get_current_frame (), 0);
835 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
836 "Error in testing breakpoint condition:\n");
837 /* FIXME-someday, should give breakpoint # */
840 if (b->cond && value_is_zero)
844 else if (b->ignore_count > 0)
851 /* We will stop here */
852 if (b->enable == temporary)
853 b->enable = disabled;
854 bs->commands = b->commands;
857 if (bs->commands && !strcmp ("silent", bs->commands->line))
859 bs->commands = bs->commands->next;
870 bs->next = NULL; /* Terminate the chain */
871 bs = root_bs->next; /* Re-grab the head of the chain */
876 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
880 #if defined (SHIFT_INST_REGS)
882 CORE_ADDR pc = read_register (PC_REGNUM);
883 CORE_ADDR npc = read_register (NPC_REGNUM);
886 write_register (NNPC_REGNUM, npc);
887 write_register (NPC_REGNUM, pc);
890 #else /* No SHIFT_INST_REGS. */
892 #endif /* No SHIFT_INST_REGS. */
894 #endif /* DECR_PC_AFTER_BREAK != 0. */
900 bpstat_should_step ()
902 struct breakpoint *b;
904 if (b->enable != disabled && b->exp != NULL)
909 /* Print information on breakpoint number BNUM, or -1 if all.
910 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
911 is nonzero, process only watchpoints. */
914 breakpoint_1 (bnum, watchpoints)
918 register struct breakpoint *b;
919 register struct command_line *l;
920 register struct symbol *sym;
921 CORE_ADDR last_addr = (CORE_ADDR)-1;
922 int header_printed = 0;
925 if (bnum == -1 || bnum == b->number)
927 if (b->address == NULL && !watchpoints)
931 error ("That is a watchpoint, not a breakpoint.");
933 if (b->address != NULL && watchpoints)
937 error ("That is a breakpoint, not a watchpoint.");
943 printf_filtered (" Enb Expression\n");
944 else if (addressprint)
945 printf_filtered (" Enb Address Where\n");
947 printf_filtered (" Enb Where\n");
951 printf_filtered ("#%-3d %c ", b->number, "nyod"[(int) b->enable]);
952 if (b->address == NULL) {
953 printf_filtered (" ");
954 print_expression (b->exp, stdout);
957 printf_filtered (" %s ", local_hex_string_custom(b->address, "08"));
959 last_addr = b->address;
962 sym = find_pc_function (b->address);
965 fputs_filtered (" in ", stdout);
966 fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
967 fputs_filtered (" at ", stdout);
969 fputs_filtered (b->symtab->filename, stdout);
970 printf_filtered (":%d", b->line_number);
973 print_address_symbolic (b->address, stdout, demangle, " ");
976 printf_filtered ("\n");
979 printf_filtered ("\tstop only in stack frame at %s\n",
980 local_hex_string(b->frame));
983 printf_filtered ("\tstop only if ");
984 print_expression (b->cond, stdout);
985 printf_filtered ("\n");
988 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
989 if ((l = b->commands))
992 fputs_filtered ("\t", stdout);
993 fputs_filtered (l->line, stdout);
994 fputs_filtered ("\n", stdout);
1001 char *which = watchpoints ? "watch" : "break";
1003 printf_filtered ("No %spoints.\n", which);
1005 printf_filtered ("No %spoint numbered %d.\n", which, bnum);
1008 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1009 that a comparison of an unsigned with -1 is always false. */
1010 if (last_addr != (CORE_ADDR)-1)
1011 set_next_address (last_addr);
1016 breakpoints_info (bnum_exp, from_tty)
1023 bnum = parse_and_eval_address (bnum_exp);
1025 breakpoint_1 (bnum, 0);
1030 watchpoints_info (bnum_exp, from_tty)
1037 bnum = parse_and_eval_address (bnum_exp);
1039 breakpoint_1 (bnum, 1);
1042 /* Print a message describing any breakpoints set at PC. */
1045 describe_other_breakpoints (pc)
1046 register CORE_ADDR pc;
1048 register int others = 0;
1049 register struct breakpoint *b;
1052 if (b->address == pc)
1056 printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1058 if (b->address == pc)
1063 (b->enable == disabled) ? " (disabled)" : "",
1064 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1066 printf ("also set at pc %s.\n", local_hex_string(pc));
1070 /* Set the default place to put a breakpoint
1071 for the `break' command with no arguments. */
1074 set_default_breakpoint (valid, addr, symtab, line)
1077 struct symtab *symtab;
1080 default_breakpoint_valid = valid;
1081 default_breakpoint_address = addr;
1082 default_breakpoint_symtab = symtab;
1083 default_breakpoint_line = line;
1086 /* Rescan breakpoints at address ADDRESS,
1087 marking the first one as "first" and any others as "duplicates".
1088 This is so that the bpt instruction is only inserted once. */
1091 check_duplicates (address)
1094 register struct breakpoint *b;
1095 register int count = 0;
1097 if (address == NULL) /* Watchpoints are uninteresting */
1101 if (b->enable != disabled && b->address == address)
1104 b->duplicate = count > 1;
1108 /* Low level routine to set a breakpoint.
1109 Takes as args the three things that every breakpoint must have.
1110 Returns the breakpoint object so caller can set other things.
1111 Does not set the breakpoint number!
1112 Does not print anything.
1114 ==> This routine should not be called if there is a chance of later
1115 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1116 your arguments BEFORE calling this routine! */
1118 static struct breakpoint *
1119 set_raw_breakpoint (sal)
1120 struct symtab_and_line sal;
1122 register struct breakpoint *b, *b1;
1124 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1125 bzero (b, sizeof *b);
1126 b->address = sal.pc;
1127 b->symtab = sal.symtab;
1128 b->line_number = sal.line;
1129 b->enable = enabled;
1132 b->ignore_count = 0;
1136 /* Add this breakpoint to the end of the chain
1137 so that a list of breakpoints will come out in order
1138 of increasing numbers. */
1140 b1 = breakpoint_chain;
1142 breakpoint_chain = b;
1150 check_duplicates (sal.pc);
1155 /* Set a breakpoint that will evaporate an end of command
1156 at address specified by SAL.
1157 Restrict it to frame FRAME if FRAME is nonzero. */
1160 set_momentary_breakpoint (sal, frame)
1161 struct symtab_and_line sal;
1164 register struct breakpoint *b;
1165 b = set_raw_breakpoint (sal);
1168 b->frame = (frame ? FRAME_FP (frame) : 0);
1172 clear_momentary_breakpoints ()
1174 register struct breakpoint *b;
1176 if (b->number == -3)
1178 delete_breakpoint (b);
1183 /* Tell the user we have just set a breakpoint B. */
1186 struct breakpoint *b;
1190 printf_filtered ("Watchpoint %d: ", b->number);
1191 print_expression (b->exp, stdout);
1195 printf_filtered ("Breakpoint %d at %s", b->number,
1196 local_hex_string(b->address));
1198 printf_filtered (": file %s, line %d.",
1199 b->symtab->filename, b->line_number);
1201 printf_filtered ("\n");
1205 /* Nobody calls this currently. */
1206 /* Set a breakpoint from a symtab and line.
1207 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1208 ADDR_STRING is a malloc'd string holding the name of where we are
1209 setting the breakpoint. This is used later to re-set it after the
1210 program is relinked and symbols are reloaded.
1211 Print the same confirmation messages that the breakpoint command prints. */
1214 set_breakpoint (s, line, tempflag, addr_string)
1220 register struct breakpoint *b;
1221 struct symtab_and_line sal;
1225 sal.pc = find_line_pc (sal.symtab, sal.line);
1227 error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
1230 describe_other_breakpoints (sal.pc);
1232 b = set_raw_breakpoint (sal);
1233 set_breakpoint_count (breakpoint_count + 1);
1234 b->number = breakpoint_count;
1236 b->addr_string = addr_string;
1238 b->enable = temporary;
1245 /* Set a breakpoint according to ARG (function, linenum or *address)
1246 and make it temporary if TEMPFLAG is nonzero. */
1249 break_command_1 (arg, tempflag, from_tty)
1251 int tempflag, from_tty;
1253 struct symtabs_and_lines sals;
1254 struct symtab_and_line sal;
1255 register struct expression *cond = 0;
1256 register struct breakpoint *b;
1258 /* Pointers in arg to the start, and one past the end, of the condition. */
1259 char *cond_start = NULL;
1261 /* Pointers in arg to the start, and one past the end,
1262 of the address part. */
1263 char *addr_start = NULL;
1272 sal.line = sal.pc = sal.end = 0;
1275 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1277 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1278 && (arg[2] == ' ' || arg[2] == '\t')))
1280 if (default_breakpoint_valid)
1282 sals.sals = (struct symtab_and_line *)
1283 xmalloc (sizeof (struct symtab_and_line));
1284 sal.pc = default_breakpoint_address;
1285 sal.line = default_breakpoint_line;
1286 sal.symtab = default_breakpoint_symtab;
1291 error ("No default breakpoint address now.");
1297 /* Force almost all breakpoints to be in terms of the
1298 current_source_symtab (which is decode_line_1's default). This
1299 should produce the results we want almost all of the time while
1300 leaving default_breakpoint_* alone. */
1301 if (default_breakpoint_valid
1302 && (!current_source_symtab
1303 || (arg && (*arg == '+' || *arg == '-'))))
1304 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1305 default_breakpoint_line);
1307 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1315 for (i = 0; i < sals.nelts; i++)
1318 if (sal.pc == 0 && sal.symtab != 0)
1320 pc = find_line_pc (sal.symtab, sal.line);
1322 error ("No line %d in file \"%s\".",
1323 sal.line, sal.symtab->filename);
1330 if (arg[0] == 'i' && arg[1] == 'f'
1331 && (arg[2] == ' ' || arg[2] == '\t'))
1335 cond = parse_exp_1 (&arg, block_for_pc (pc), 0);
1339 error ("Junk at end of arguments.");
1341 sals.sals[i].pc = pc;
1344 for (i = 0; i < sals.nelts; i++)
1349 describe_other_breakpoints (sal.pc);
1351 b = set_raw_breakpoint (sal);
1352 set_breakpoint_count (breakpoint_count + 1);
1353 b->number = breakpoint_count;
1357 b->addr_string = savestring (addr_start, addr_end - addr_start);
1359 b->cond_string = savestring (cond_start, cond_end - cond_start);
1362 b->enable = temporary;
1369 printf ("Multiple breakpoints were set.\n");
1370 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1376 break_command (arg, from_tty)
1380 break_command_1 (arg, 0, from_tty);
1384 tbreak_command (arg, from_tty)
1388 break_command_1 (arg, 1, from_tty);
1393 watch_command (arg, from_tty)
1397 struct breakpoint *b;
1398 struct symtab_and_line sal;
1399 struct expression *exp;
1400 struct block *exp_valid_block;
1407 /* Parse arguments. */
1408 innermost_block = NULL;
1409 exp = parse_expression (arg);
1410 exp_valid_block = innermost_block;
1411 val = evaluate_expression (exp);
1412 release_value (val);
1414 /* Now set up the breakpoint. */
1415 b = set_raw_breakpoint (sal);
1416 set_breakpoint_count (breakpoint_count + 1);
1417 b->number = breakpoint_count;
1419 b->exp_valid_block = exp_valid_block;
1422 b->cond_string = NULL;
1427 * Helper routine for the until_command routine in infcmd.c. Here
1428 * because it uses the mechanisms of breakpoints.
1432 until_break_command (arg, from_tty)
1436 struct symtabs_and_lines sals;
1437 struct symtab_and_line sal;
1438 FRAME prev_frame = get_prev_frame (selected_frame);
1440 clear_proceed_status ();
1442 /* Set a breakpoint where the user wants it and at return from
1445 if (default_breakpoint_valid)
1446 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1447 default_breakpoint_line);
1449 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1451 if (sals.nelts != 1)
1452 error ("Couldn't get information on specified line.");
1455 free (sals.sals); /* malloc'd, so freed */
1458 error ("Junk at end of arguments.");
1460 if (sal.pc == 0 && sal.symtab != 0)
1461 sal.pc = find_line_pc (sal.symtab, sal.line);
1464 error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
1466 set_momentary_breakpoint (sal, selected_frame);
1468 /* Keep within the current frame */
1472 struct frame_info *fi;
1474 fi = get_frame_info (prev_frame);
1475 sal = find_pc_line (fi->pc, 0);
1477 set_momentary_breakpoint (sal, prev_frame);
1480 proceed (-1, -1, 0);
1484 /* These aren't used; I don't konw what they were for. */
1485 /* Set a breakpoint at the catch clause for NAME. */
1487 catch_breakpoint (name)
1493 disable_catch_breakpoint ()
1498 delete_catch_breakpoint ()
1503 enable_catch_breakpoint ()
1510 struct sal_chain *next;
1511 struct symtab_and_line sal;
1515 /* This isn't used; I don't know what it was for. */
1516 /* For each catch clause identified in ARGS, run FUNCTION
1517 with that clause as an argument. */
1518 static struct symtabs_and_lines
1519 map_catch_names (args, function)
1523 register char *p = args;
1525 struct symtabs_and_lines sals;
1527 struct sal_chain *sal_chain = 0;
1531 error_no_arg ("one or more catch names");
1539 /* Don't swallow conditional part. */
1540 if (p1[0] == 'i' && p1[1] == 'f'
1541 && (p1[2] == ' ' || p1[2] == '\t'))
1547 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
1551 if (*p1 && *p1 != ' ' && *p1 != '\t')
1552 error ("Arguments must be catch names.");
1558 struct sal_chain *next
1559 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
1560 next->next = sal_chain;
1561 next->sal = get_catch_sal (p);
1566 printf ("No catch clause for exception %s.\n", p);
1571 while (*p == ' ' || *p == '\t') p++;
1576 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
1578 static struct symtabs_and_lines
1579 get_catch_sals (this_level_only)
1580 int this_level_only;
1582 extern struct blockvector *blockvector_for_pc ();
1583 register struct blockvector *bl;
1584 register struct block *block;
1585 int index, have_default = 0;
1586 struct frame_info *fi;
1588 struct symtabs_and_lines sals;
1589 struct sal_chain *sal_chain = 0;
1590 char *blocks_searched;
1592 /* Not sure whether an error message is always the correct response,
1593 but it's better than a core dump. */
1594 if (selected_frame == NULL)
1595 error ("No selected frame.");
1596 block = get_frame_block (selected_frame);
1597 fi = get_frame_info (selected_frame);
1604 error ("No symbol table info available.\n");
1606 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
1607 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1608 bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1612 CORE_ADDR end = BLOCK_END (block) - 4;
1615 if (bl != blockvector_for_pc (end, &index))
1616 error ("blockvector blotch");
1617 if (BLOCKVECTOR_BLOCK (bl, index) != block)
1618 error ("blockvector botch");
1619 last_index = BLOCKVECTOR_NBLOCKS (bl);
1622 /* Don't print out blocks that have gone by. */
1623 while (index < last_index
1624 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
1627 while (index < last_index
1628 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
1630 if (blocks_searched[index] == 0)
1632 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
1635 register struct symbol *sym;
1637 nsyms = BLOCK_NSYMS (b);
1639 for (i = 0; i < nsyms; i++)
1641 sym = BLOCK_SYM (b, i);
1642 if (! strcmp (SYMBOL_NAME (sym), "default"))
1648 if (SYMBOL_CLASS (sym) == LOC_LABEL)
1650 struct sal_chain *next = (struct sal_chain *)
1651 alloca (sizeof (struct sal_chain));
1652 next->next = sal_chain;
1653 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
1657 blocks_searched[index] = 1;
1663 if (sal_chain && this_level_only)
1666 /* After handling the function's top-level block, stop.
1667 Don't continue to its superblock, the block of
1668 per-file symbols. */
1669 if (BLOCK_FUNCTION (block))
1671 block = BLOCK_SUPERBLOCK (block);
1676 struct sal_chain *tmp_chain;
1678 /* Count the number of entries. */
1679 for (index = 0, tmp_chain = sal_chain; tmp_chain;
1680 tmp_chain = tmp_chain->next)
1684 sals.sals = (struct symtab_and_line *)
1685 xmalloc (index * sizeof (struct symtab_and_line));
1686 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
1687 sals.sals[index] = sal_chain->sal;
1693 /* Commands to deal with catching exceptions. */
1696 catch_command_1 (arg, tempflag, from_tty)
1701 /* First, translate ARG into something we can deal with in terms
1704 struct symtabs_and_lines sals;
1705 struct symtab_and_line sal;
1706 register struct expression *cond = 0;
1707 register struct breakpoint *b;
1712 sal.line = sal.pc = sal.end = 0;
1715 /* If no arg given, or if first arg is 'if ', all active catch clauses
1716 are breakpointed. */
1718 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1719 && (arg[2] == ' ' || arg[2] == '\t')))
1721 /* Grab all active catch clauses. */
1722 sals = get_catch_sals (0);
1726 /* Grab selected catch clauses. */
1727 error ("catch NAME not implemeneted");
1729 /* This isn't used; I don't know what it was for. */
1730 sals = map_catch_names (arg, catch_breakpoint);
1738 for (i = 0; i < sals.nelts; i++)
1741 if (sal.pc == 0 && sal.symtab != 0)
1743 pc = find_line_pc (sal.symtab, sal.line);
1745 error ("No line %d in file \"%s\".",
1746 sal.line, sal.symtab->filename);
1753 if (arg[0] == 'i' && arg[1] == 'f'
1754 && (arg[2] == ' ' || arg[2] == '\t'))
1755 cond = (struct expression *) parse_exp_1 ((arg += 2, &arg),
1756 block_for_pc (pc), 0);
1758 error ("Junk at end of arguments.");
1761 sals.sals[i].pc = pc;
1764 for (i = 0; i < sals.nelts; i++)
1769 describe_other_breakpoints (sal.pc);
1771 b = set_raw_breakpoint (sal);
1772 b->number = ++breakpoint_count;
1775 b->enable = temporary;
1777 printf ("Breakpoint %d at %s", b->number, local_hex_string(b->address));
1779 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
1785 printf ("Multiple breakpoints were set.\n");
1786 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1792 /* These aren't used; I don't know what they were for. */
1793 /* Disable breakpoints on all catch clauses described in ARGS. */
1795 disable_catch (args)
1798 /* Map the disable command to catch clauses described in ARGS. */
1801 /* Enable breakpoints on all catch clauses described in ARGS. */
1806 /* Map the disable command to catch clauses described in ARGS. */
1809 /* Delete breakpoints on all catch clauses in the active scope. */
1814 /* Map the delete command to catch clauses described in ARGS. */
1819 catch_command (arg, from_tty)
1823 catch_command_1 (arg, 0, from_tty);
1827 clear_command (arg, from_tty)
1831 register struct breakpoint *b, *b1;
1832 struct symtabs_and_lines sals;
1833 struct symtab_and_line sal;
1834 register struct breakpoint *found;
1839 sals = decode_line_spec (arg, 1);
1843 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
1844 sal.line = default_breakpoint_line;
1845 sal.symtab = default_breakpoint_symtab;
1847 if (sal.symtab == 0)
1848 error ("No source file specified.");
1854 for (i = 0; i < sals.nelts; i++)
1856 /* If exact pc given, clear bpts at that pc.
1857 But if sal.pc is zero, clear all bpts on specified line. */
1859 found = (struct breakpoint *) 0;
1860 while (breakpoint_chain
1861 && (sal.pc ? breakpoint_chain->address == sal.pc
1862 : (breakpoint_chain->symtab == sal.symtab
1863 && breakpoint_chain->line_number == sal.line)))
1865 b1 = breakpoint_chain;
1866 breakpoint_chain = b1->next;
1873 && b->next->address != NULL
1874 && (sal.pc ? b->next->address == sal.pc
1875 : (b->next->symtab == sal.symtab
1876 && b->next->line_number == sal.line)))
1887 error ("No breakpoint at %s.", arg);
1889 error ("No breakpoint at this line.");
1892 if (found->next) from_tty = 1; /* Always report if deleted more than one */
1893 if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
1896 if (from_tty) printf ("%d ", found->number);
1898 delete_breakpoint (found);
1901 if (from_tty) putchar ('\n');
1906 /* Delete breakpoint in BS if they are `delete' breakpoints.
1907 This is called after any breakpoint is hit, or after errors. */
1910 breakpoint_auto_delete (bs)
1913 for (; bs; bs = bs->next)
1914 if (bs->breakpoint_at && bs->breakpoint_at->enable == delete)
1915 delete_breakpoint (bs->breakpoint_at);
1918 /* Delete a breakpoint and clean up all traces of it in the data structures. */
1921 delete_breakpoint (bpt)
1922 struct breakpoint *bpt;
1924 register struct breakpoint *b;
1928 target_remove_breakpoint(bpt->address, bpt->shadow_contents);
1930 if (breakpoint_chain == bpt)
1931 breakpoint_chain = bpt->next;
1936 b->next = bpt->next;
1940 check_duplicates (bpt->address);
1942 free_command_lines (&bpt->commands);
1945 if (bpt->cond_string != NULL)
1946 free (bpt->cond_string);
1947 if (bpt->addr_string != NULL)
1948 free (bpt->addr_string);
1950 if (xgdb_verbose && bpt->number >=0)
1951 printf ("breakpoint #%d deleted\n", bpt->number);
1953 /* Be sure no bpstat's are pointing at it after it's been freed. */
1954 /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */
1955 for (bs = stop_bpstat; bs; bs = bs->next)
1956 if (bs->breakpoint_at == bpt)
1957 bs->breakpoint_at = NULL;
1961 static void map_breakpoint_numbers ();
1964 delete_command (arg, from_tty)
1971 /* Ask user only if there are some breakpoints to delete. */
1973 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
1975 /* No arg; clear all breakpoints. */
1976 while (breakpoint_chain)
1977 delete_breakpoint (breakpoint_chain);
1981 map_breakpoint_numbers (arg, delete_breakpoint);
1984 /* Reset a breakpoint given it's struct breakpoint * BINT.
1985 The value we return ends up being the return value from catch_errors.
1986 Unused in this case. */
1989 breakpoint_re_set_one (bint)
1992 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
1994 struct symtabs_and_lines sals;
1995 struct symtab_and_line sal;
1998 if (b->address != NULL && b->addr_string != NULL)
2001 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0);
2002 for (i = 0; i < sals.nelts; i++)
2006 b->symtab = sal.symtab;
2007 b->line_number = sal.line;
2008 if (sal.pc == 0 && sal.symtab != 0)
2010 sal.pc = find_line_pc (sal.symtab, sal.line);
2012 error ("No line %d in file \"%s\".",
2013 sal.line, sal.symtab->filename);
2015 b->address = sal.pc;
2017 if (b->cond_string != NULL)
2020 b->cond = parse_exp_1 (&s, block_for_pc (sal.pc), 0);
2023 check_duplicates (b->address);
2031 /* Anything without a string can't be re-set. */
2032 delete_breakpoint (b);
2037 /* Re-set all breakpoints after symbols have been re-loaded. */
2039 breakpoint_re_set ()
2041 struct breakpoint *b;
2045 b->symtab = 0; /* Be sure we don't point to old dead symtab */
2046 (void) catch_errors (breakpoint_re_set_one, (char *) b,
2047 "Error in re-setting breakpoint:\n");
2050 /* Blank line to finish off all those mention() messages we just printed. */
2051 printf_filtered ("\n");
2054 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
2055 If from_tty is nonzero, it prints a message to that effect,
2056 which ends with a period (no newline). */
2059 set_ignore_count (bptnum, count, from_tty)
2060 int bptnum, count, from_tty;
2062 register struct breakpoint *b;
2068 if (b->number == bptnum)
2070 b->ignore_count = count;
2073 else if (count == 0)
2074 printf ("Will stop next time breakpoint %d is reached.", bptnum);
2075 else if (count == 1)
2076 printf ("Will ignore next crossing of breakpoint %d.", bptnum);
2078 printf ("Will ignore next %d crossings of breakpoint %d.",
2083 error ("No breakpoint number %d.", bptnum);
2086 /* Clear the ignore counts of all breakpoints. */
2088 breakpoint_clear_ignore_counts ()
2090 struct breakpoint *b;
2093 b->ignore_count = 0;
2096 /* Command to set ignore-count of breakpoint N to COUNT. */
2099 ignore_command (args, from_tty)
2107 error_no_arg ("a breakpoint number");
2109 num = get_number (&p);
2112 error ("Second argument (specified ignore-count) is missing.");
2114 set_ignore_count (num,
2115 longest_to_int (value_as_long (parse_and_eval (p))),
2120 /* Call FUNCTION on each of the breakpoints
2121 whose numbers are given in ARGS. */
2124 map_breakpoint_numbers (args, function)
2126 void (*function) ();
2128 register char *p = args;
2131 register struct breakpoint *b;
2134 error_no_arg ("one or more breakpoint numbers");
2140 num = get_number (&p1);
2143 if (b->number == num)
2148 printf ("No breakpoint number %d.\n", num);
2155 enable_breakpoint (bpt)
2156 struct breakpoint *bpt;
2158 bpt->enable = enabled;
2160 if (xgdb_verbose && bpt->number >= 0)
2161 printf ("breakpoint #%d enabled\n", bpt->number);
2163 check_duplicates (bpt->address);
2164 if (bpt->val != NULL)
2166 if (bpt->exp_valid_block != NULL
2167 && !contained_in (get_selected_block (), bpt->exp_valid_block))
2170 Cannot enable watchpoint %d because the block in which its expression\n\
2171 is valid is not currently in scope.\n", bpt->number);
2175 value_free (bpt->val);
2177 bpt->val = evaluate_expression (bpt->exp);
2178 release_value (bpt->val);
2184 enable_command (args, from_tty)
2188 struct breakpoint *bpt;
2190 ALL_BREAKPOINTS (bpt)
2191 enable_breakpoint (bpt);
2193 map_breakpoint_numbers (args, enable_breakpoint);
2197 disable_breakpoint (bpt)
2198 struct breakpoint *bpt;
2200 bpt->enable = disabled;
2202 if (xgdb_verbose && bpt->number >= 0)
2203 printf ("breakpoint #%d disabled\n", bpt->number);
2205 check_duplicates (bpt->address);
2210 disable_command (args, from_tty)
2214 register struct breakpoint *bpt;
2216 ALL_BREAKPOINTS (bpt)
2217 disable_breakpoint (bpt);
2219 map_breakpoint_numbers (args, disable_breakpoint);
2223 enable_once_breakpoint (bpt)
2224 struct breakpoint *bpt;
2226 bpt->enable = temporary;
2228 check_duplicates (bpt->address);
2233 enable_once_command (args, from_tty)
2237 map_breakpoint_numbers (args, enable_once_breakpoint);
2241 enable_delete_breakpoint (bpt)
2242 struct breakpoint *bpt;
2244 bpt->enable = delete;
2246 check_duplicates (bpt->address);
2251 enable_delete_command (args, from_tty)
2255 map_breakpoint_numbers (args, enable_delete_breakpoint);
2259 * Use default_breakpoint_'s, or nothing if they aren't valid.
2261 struct symtabs_and_lines
2262 decode_line_spec_1 (string, funfirstline)
2266 struct symtabs_and_lines sals;
2268 error ("Empty line specification.");
2269 if (default_breakpoint_valid)
2270 sals = decode_line_1 (&string, funfirstline,
2271 default_breakpoint_symtab, default_breakpoint_line);
2273 sals = decode_line_1 (&string, funfirstline, (struct symtab *)NULL, 0);
2275 error ("Junk at end of line specification: %s", string);
2280 /* Chain containing all defined enable commands. */
2282 extern struct cmd_list_element
2283 *enablelist, *disablelist,
2284 *deletelist, *enablebreaklist;
2286 extern struct cmd_list_element *cmdlist;
2289 _initialize_breakpoint ()
2291 breakpoint_chain = 0;
2292 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
2293 before a breakpoint is set. */
2294 breakpoint_count = 0;
2296 add_com ("ignore", class_breakpoint, ignore_command,
2297 "Set ignore-count of breakpoint number N to COUNT.");
2299 add_com ("commands", class_breakpoint, commands_command,
2300 "Set commands to be executed when a breakpoint is hit.\n\
2301 Give breakpoint number as argument after \"commands\".\n\
2302 With no argument, the targeted breakpoint is the last one set.\n\
2303 The commands themselves follow starting on the next line.\n\
2304 Type a line containing \"end\" to indicate the end of them.\n\
2305 Give \"silent\" as the first line to make the breakpoint silent;\n\
2306 then no output is printed when it is hit, except what the commands print.");
2308 add_com ("condition", class_breakpoint, condition_command,
2309 "Specify breakpoint number N to break only if COND is true.\n\
2310 N is an integer; COND is an expression to be evaluated whenever\n\
2311 breakpoint N is reached. ");
2313 add_com ("tbreak", class_breakpoint, tbreak_command,
2314 "Set a temporary breakpoint. Args like \"break\" command.\n\
2315 Like \"break\" except the breakpoint is only enabled temporarily,\n\
2316 so it will be disabled when hit. Equivalent to \"break\" followed\n\
2317 by using \"enable once\" on the breakpoint number.");
2319 add_prefix_cmd ("enable", class_breakpoint, enable_command,
2320 "Enable some breakpoints.\n\
2321 Give breakpoint numbers (separated by spaces) as arguments.\n\
2322 With no subcommand, breakpoints are enabled until you command otherwise.\n\
2323 This is used to cancel the effect of the \"disable\" command.\n\
2324 With a subcommand you can enable temporarily.",
2325 &enablelist, "enable ", 1, &cmdlist);
2327 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
2328 "Enable some breakpoints.\n\
2329 Give breakpoint numbers (separated by spaces) as arguments.\n\
2330 This is used to cancel the effect of the \"disable\" command.\n\
2331 May be abbreviated to simply \"enable\".\n",
2332 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
2334 add_cmd ("once", no_class, enable_once_command,
2335 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2336 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2337 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2340 add_cmd ("delete", no_class, enable_delete_command,
2341 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2342 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2345 add_cmd ("delete", no_class, enable_delete_command,
2346 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2347 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2350 add_cmd ("once", no_class, enable_once_command,
2351 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2352 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2353 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2356 add_prefix_cmd ("disable", class_breakpoint, disable_command,
2357 "Disable some breakpoints.\n\
2358 Arguments are breakpoint numbers with spaces in between.\n\
2359 To disable all breakpoints, give no argument.\n\
2360 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
2361 &disablelist, "disable ", 1, &cmdlist);
2362 add_com_alias ("dis", "disable", class_breakpoint, 1);
2363 add_com_alias ("disa", "disable", class_breakpoint, 1);
2365 add_cmd ("breakpoints", class_alias, disable_command,
2366 "Disable some breakpoints.\n\
2367 Arguments are breakpoint numbers with spaces in between.\n\
2368 To disable all breakpoints, give no argument.\n\
2369 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
2370 This command may be abbreviated \"disable\".",
2373 add_prefix_cmd ("delete", class_breakpoint, delete_command,
2374 "Delete some breakpoints or auto-display expressions.\n\
2375 Arguments are breakpoint numbers with spaces in between.\n\
2376 To delete all breakpoints, give no argument.\n\
2378 Also a prefix command for deletion of other GDB objects.\n\
2379 The \"unset\" command is also an alias for \"delete\".",
2380 &deletelist, "delete ", 1, &cmdlist);
2381 add_com_alias ("d", "delete", class_breakpoint, 1);
2383 add_cmd ("breakpoints", class_alias, delete_command,
2384 "Delete some breakpoints or auto-display expressions.\n\
2385 Arguments are breakpoint numbers with spaces in between.\n\
2386 To delete all breakpoints, give no argument.\n\
2387 This command may be abbreviated \"delete\".",
2390 add_com ("clear", class_breakpoint, clear_command,
2391 "Clear breakpoint at specified line or function.\n\
2392 Argument may be line number, function name, or \"*\" and an address.\n\
2393 If line number is specified, all breakpoints in that line are cleared.\n\
2394 If function is specified, breakpoints at beginning of function are cleared.\n\
2395 If an address is specified, breakpoints at that address are cleared.\n\n\
2396 With no argument, clears all breakpoints in the line that the selected frame\n\
2399 See also the \"delete\" command which clears breakpoints by number.");
2401 add_com ("break", class_breakpoint, break_command,
2402 "Set breakpoint at specified line or function.\n\
2403 Argument may be line number, function name, or \"*\" and an address.\n\
2404 If line number is specified, break at start of code for that line.\n\
2405 If function is specified, break at start of code for that function.\n\
2406 If an address is specified, break at that exact address.\n\
2407 With no arg, uses current execution address of selected stack frame.\n\
2408 This is useful for breaking on return to a stack frame.\n\
2410 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
2412 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2413 add_com_alias ("b", "break", class_run, 1);
2414 add_com_alias ("br", "break", class_run, 1);
2415 add_com_alias ("bre", "break", class_run, 1);
2416 add_com_alias ("brea", "break", class_run, 1);
2418 add_info ("breakpoints", breakpoints_info,
2419 "Status of all breakpoints, or breakpoint number NUMBER.\n\
2420 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
2421 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
2422 Then come the address and the file/line number.\n\n\
2423 Convenience variable \"$_\" and default examine address for \"x\"\n\
2424 are set to the address of the last breakpoint listed.\n\n\
2425 Convenience variable \"$bpnum\" contains the number of the last\n\
2428 add_com ("catch", class_breakpoint, catch_command,
2429 "Set breakpoints to catch exceptions that are raised.\n\
2430 Argument may be a single exception to catch, multiple exceptions\n\
2431 to catch, or the default exception \"default\". If no arguments\n\
2432 are given, breakpoints are set at all exception handlers catch clauses\n\
2433 within the current scope.\n\
2435 A condition specified for the catch applies to all breakpoints set\n\
2436 with this command\n\
2438 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2440 add_com ("watch", class_breakpoint, watch_command,
2441 "Set a watchpoint for an expression.\n\
2442 A watchpoint stops execution of your program whenever the value of\n\
2443 an expression changes.");
2445 add_info ("watchpoints", watchpoints_info,
2446 "Status of all watchpoints, or watchpoint number NUMBER.\n\
2447 Second column is \"y\" for enabled watchpoints, \"n\" for disabled.");