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 /* insert_breakpoints is used when starting or continuing the program.
298 remove_breakpoints is used when the program stops.
299 Both return zero if successful,
300 or an `errno' value if could not write the inferior. */
303 insert_breakpoints ()
305 register struct breakpoint
*b
;
307 int disabled_breaks
= 0;
310 if (b
->address
!= NULL
311 && b
->enable
!= disabled
315 val
= target_insert_breakpoint(b
->address
, b
->shadow_contents
);
318 /* Can't set the breakpoint. */
319 #if defined (DISABLE_UNSETTABLE_BREAK)
320 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
323 b
->enable
= disabled
;
324 if (!disabled_breaks
)
327 "Cannot insert breakpoint %d:\n", b
->number
);
328 printf_filtered ("Disabling shared library breakpoints:\n");
331 printf_filtered ("%d ", b
->number
);
336 fprintf (stderr
, "Cannot insert breakpoint %d:\n", b
->number
);
337 memory_error (val
, b
->address
); /* which bombs us out */
344 printf_filtered ("\n");
349 remove_breakpoints ()
351 register struct breakpoint
*b
;
354 #ifdef BREAKPOINT_DEBUG
355 printf ("Removing breakpoints.\n");
356 #endif /* BREAKPOINT_DEBUG */
359 if (b
->address
!= NULL
&& b
->inserted
)
361 val
= target_remove_breakpoint(b
->address
, b
->shadow_contents
);
365 #ifdef BREAKPOINT_DEBUG
366 printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
367 b
->address
, b
->shadow_contents
[0], b
->shadow_contents
[1]);
368 #endif /* BREAKPOINT_DEBUG */
374 /* Clear the "inserted" flag in all breakpoints.
375 This is done when the inferior is loaded. */
378 mark_breakpoints_out ()
380 register struct breakpoint
*b
;
386 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
387 When continuing from a location with a breakpoint,
388 we actually single step once before calling insert_breakpoints. */
391 breakpoint_here_p (pc
)
394 register struct breakpoint
*b
;
397 if (b
->enable
!= disabled
&& b
->address
== pc
)
403 /* bpstat stuff. External routines' interfaces are documented
418 if (p
->old_val
!= NULL
)
419 value_free (p
->old_val
);
437 for (; bs
!= NULL
; bs
= bs
->next
)
439 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
440 bcopy (bs
, tmp
, sizeof (*tmp
));
442 /* This is the first thing in the chain. */
456 struct breakpoint
*b
;
459 return 0; /* No more breakpoint values */
462 b
= (*bsp
)->breakpoint_at
;
465 return -1; /* breakpoint that's been deleted since */
467 return b
->number
; /* We have its number */
472 bpstat_clear_actions (bs
)
475 for (; bs
!= NULL
; bs
= bs
->next
)
478 if (bs
->old_val
!= NULL
)
480 value_free (bs
->old_val
);
486 /* Execute all the commands associated with all the breakpoints at this
487 location. Any of these commands could cause the process to proceed
488 beyond this point, etc. We look out for such changes by checking
489 the global "breakpoint_proceeded" after each command. */
491 bpstat_do_actions (bsp
)
499 executing_breakpoint_commands
= 1;
500 breakpoint_proceeded
= 0;
501 for (; bs
!= NULL
; bs
= bs
->next
)
505 char *line
= bs
->commands
->line
;
506 bs
->commands
= bs
->commands
->next
;
507 execute_command (line
, 0);
508 /* If the inferior is proceeded by the command, bomb out now.
509 The bpstat chain has been blown away by wait_for_inferior.
510 But since execution has stopped again, there is a new bpstat
511 to look at, so start over. */
512 if (breakpoint_proceeded
)
516 clear_momentary_breakpoints ();
518 executing_breakpoint_commands
= 0;
525 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
526 which has since been deleted. */
527 if (bs
== NULL
|| bs
->breakpoint_at
== NULL
)
530 /* If bpstat_stop_status says don't print, OK, we won't. An example
531 circumstance is when we single-stepped for both a watchpoint and
532 for a "stepi" instruction. The bpstat says that the watchpoint
533 explains the stop, but we shouldn't print because the watchpoint's
534 value didn't change -- and the real reason we are stopping here
535 rather than continuing to step (as the watchpoint would've had us do)
536 is because of the "stepi". */
540 if (bs
->breakpoint_at
->address
!= NULL
)
542 /* I think the user probably only wants to see one breakpoint
543 number, not all of them. */
544 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
548 if (bs
->old_val
!= NULL
)
550 printf_filtered ("\nWatchpoint %d, ", bs
->breakpoint_at
->number
);
551 print_expression (bs
->breakpoint_at
->exp
, stdout
);
552 printf_filtered ("\nOld value = ");
553 value_print (bs
->old_val
, stdout
, 0, Val_pretty_default
);
554 printf_filtered ("\nNew value = ");
555 value_print (bs
->breakpoint_at
->val
, stdout
, 0,
557 printf_filtered ("\n");
558 value_free (bs
->old_val
);
563 fprintf_filtered (stderr
, "gdb internal error: in bpstat_print\n");
567 /* Evaluate the expression EXP and return 1 if value is zero.
568 This is used inside a catch_errors to evaluate the breakpoint condition.
569 The argument is a "struct expression *" that has been cast to int to
570 make it pass through catch_errors. */
573 breakpoint_cond_eval (exp
)
576 return value_zerop (evaluate_expression ((struct expression
*)exp
));
579 /* Allocate a new bpstat and chain it to the current one. */
582 bpstat_alloc (b
, cbs
)
583 register struct breakpoint
*b
;
584 bpstat cbs
; /* Current "bs" value */
588 bs
= (bpstat
) xmalloc (sizeof (*bs
));
590 bs
->breakpoint_at
= b
;
591 /* If the condition is false, etc., don't do the commands. */
593 bs
->momentary
= b
->number
== -3;
598 /* Determine whether we stopped at a breakpoint, etc, or whether we
599 don't understand this stop. Result is a chain of bpstat's such that:
601 if we don't understand the stop, the result is a null pointer.
603 if we understand why we stopped, the result is not null, and
604 the first element of the chain contains summary "stop" and
605 "print" flags for the whole chain.
607 Each element of the chain refers to a particular breakpoint or
608 watchpoint at which we have stopped. (We may have stopped for
611 Each element of the chain has valid next, breakpoint_at,
612 commands, FIXME??? fields.
618 bpstat_stop_status (pc
, frame_address
)
620 FRAME_ADDR frame_address
;
622 register struct breakpoint
*b
;
626 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
627 int real_breakpoint
= 0;
628 /* Root of the chain of bpstat's */
629 struct bpstat__struct root_bs
[1];
630 /* Pointer to the last thing in the chain currently. */
633 /* Get the address where the breakpoint would have been. */
634 bp_addr
= *pc
- DECR_PC_AFTER_BREAK
;
641 if (b
->enable
== disabled
)
643 if (b
->address
!= NULL
&& b
->address
!= bp_addr
)
646 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
651 if (b
->exp
!= NULL
) /* Watchpoint */
653 int within_current_scope
;
654 if (b
->exp_valid_block
!= NULL
)
655 within_current_scope
=
656 contained_in (get_selected_block (), b
->exp_valid_block
);
658 within_current_scope
= 1;
660 if (within_current_scope
)
662 value new_val
= evaluate_expression (b
->exp
);
663 release_value (new_val
);
664 if (!value_equal (b
->val
, new_val
))
666 bs
->old_val
= b
->val
;
668 /* We will stop here */
672 /* Nothing changed, don't do anything. */
673 value_free (new_val
);
675 /* We won't stop here */
680 /* This seems like the only logical thing to do because
681 if we temporarily ignored the watchpoint, then when
682 we reenter the block in which it is valid it contains
683 garbage (in the case of a function, it may have two
684 garbage values, one before and one after the prologue).
685 So we can't even detect the first assignment to it and
686 watch after that (since the garbage may or may not equal
687 the first value assigned). */
688 b
->enable
= disabled
;
690 Watchpoint %d disabled because the program has left the block in\n\
691 which its expression is valid.\n", b
->number
);
692 /* We won't stop here */
693 /* FIXME, maybe we should stop here!!! */
700 if (b
->frame
&& b
->frame
!= frame_address
)
708 /* Need to select the frame, with all that implies
709 so that the conditions will have the right context. */
710 select_frame (get_current_frame (), 0);
712 = catch_errors (breakpoint_cond_eval
, (int)(b
->cond
),
713 "Error occurred in testing breakpoint condition.");
716 if (b
->cond
&& value_zero
)
720 else if (b
->ignore_count
> 0)
727 /* We will stop here */
728 if (b
->enable
== temporary
)
729 b
->enable
= disabled
;
730 bs
->commands
= b
->commands
;
733 if (bs
->commands
&& !strcmp ("silent", bs
->commands
->line
))
735 bs
->commands
= bs
->commands
->next
;
746 bs
->next
= NULL
; /* Terminate the chain */
747 bs
= root_bs
->next
; /* Re-grab the head of the chain */
752 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
756 #if defined (SHIFT_INST_REGS)
758 CORE_ADDR pc
= read_register (PC_REGNUM
);
759 CORE_ADDR npc
= read_register (NPC_REGNUM
);
762 write_register (NNPC_REGNUM
, npc
);
763 write_register (NPC_REGNUM
, pc
);
766 #else /* No SHIFT_INST_REGS. */
768 #endif /* No SHIFT_INST_REGS. */
770 #endif /* DECR_PC_AFTER_BREAK != 0. */
776 bpstat_should_step ()
778 struct breakpoint
*b
;
780 if (b
->enable
!= disabled
&& b
->exp
!= NULL
)
785 /* Print information on breakpoint number BNUM, or -1 if all.
786 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
787 is nonzero, process only watchpoints. */
790 breakpoint_1 (bnum
, watchpoints
)
794 register struct breakpoint
*b
;
795 register struct command_line
*l
;
796 register struct symbol
*sym
;
797 CORE_ADDR last_addr
= (CORE_ADDR
)-1;
798 int header_printed
= 0;
801 if (bnum
== -1 || bnum
== b
->number
)
803 if (b
->address
== NULL
&& !watchpoints
)
807 error ("That is a watchpoint, not a breakpoint.");
809 if (b
->address
!= NULL
&& watchpoints
)
813 error ("That is a breakpoint, not a watchpoint.");
819 printf_filtered (" Enb Expression\n");
820 else if (addressprint
)
821 printf_filtered (" Enb Address Where\n");
823 printf_filtered (" Enb Where\n");
827 printf_filtered ("#%-3d %c ", b
->number
, "nyod"[(int) b
->enable
]);
828 if (b
->address
== NULL
) {
829 printf_filtered (" ");
830 print_expression (b
->exp
, stdout
);
833 printf_filtered (" 0x%08x ", b
->address
);
835 last_addr
= b
->address
;
838 sym
= find_pc_function (b
->address
);
841 fputs_filtered (" in ", stdout
);
842 fputs_demangled (SYMBOL_NAME (sym
), stdout
, 1);
843 fputs_filtered (" at ", stdout
);
845 fputs_filtered (b
->symtab
->filename
, stdout
);
846 printf_filtered (":%d", b
->line_number
);
849 print_address_symbolic (b
->address
, stdout
, demangle
);
852 printf_filtered ("\n");
855 printf_filtered ("\tstop only in stack frame at 0x%x\n", b
->frame
);
858 printf_filtered ("\tstop only if ");
859 print_expression (b
->cond
, stdout
);
860 printf_filtered ("\n");
863 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
864 if ((l
= b
->commands
))
867 fputs_filtered ("\t", stdout
);
868 fputs_filtered (l
->line
, stdout
);
869 fputs_filtered ("\n", stdout
);
876 char *which
= watchpoints
? "watch" : "break";
878 printf_filtered ("No %spoints.\n", which
);
880 printf_filtered ("No %spoint numbered %d.\n", which
, bnum
);
883 /* Compare against (CORE_ADDR)-1 in case some compiler decides
884 that a comparison of an unsigned with -1 is always false. */
885 if (last_addr
!= (CORE_ADDR
)-1)
886 set_next_address (last_addr
);
890 breakpoints_info (bnum_exp
, from_tty
)
897 bnum
= parse_and_eval_address (bnum_exp
);
899 breakpoint_1 (bnum
, 0);
903 watchpoints_info (bnum_exp
, from_tty
)
910 bnum
= parse_and_eval_address (bnum_exp
);
912 breakpoint_1 (bnum
, 1);
915 /* Print a message describing any breakpoints set at PC. */
918 describe_other_breakpoints (pc
)
919 register CORE_ADDR pc
;
921 register int others
= 0;
922 register struct breakpoint
*b
;
925 if (b
->address
== pc
)
929 printf ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
931 if (b
->address
== pc
)
936 (b
->enable
== disabled
) ? " (disabled)" : "",
937 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
939 printf ("also set at pc 0x%x.\n", pc
);
943 /* Set the default place to put a breakpoint
944 for the `break' command with no arguments. */
947 set_default_breakpoint (valid
, addr
, symtab
, line
)
950 struct symtab
*symtab
;
953 default_breakpoint_valid
= valid
;
954 default_breakpoint_address
= addr
;
955 default_breakpoint_symtab
= symtab
;
956 default_breakpoint_line
= line
;
959 /* Rescan breakpoints at address ADDRESS,
960 marking the first one as "first" and any others as "duplicates".
961 This is so that the bpt instruction is only inserted once. */
964 check_duplicates (address
)
967 register struct breakpoint
*b
;
968 register int count
= 0;
970 if (address
== NULL
) /* Watchpoints are uninteresting */
974 if (b
->enable
!= disabled
&& b
->address
== address
)
977 b
->duplicate
= count
> 1;
981 /* Low level routine to set a breakpoint.
982 Takes as args the three things that every breakpoint must have.
983 Returns the breakpoint object so caller can set other things.
984 Does not set the breakpoint number!
985 Does not print anything.
987 ==> This routine should not be called if there is a chance of later
988 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
989 your arguments BEFORE calling this routine! */
991 static struct breakpoint
*
992 set_raw_breakpoint (sal
)
993 struct symtab_and_line sal
;
995 register struct breakpoint
*b
, *b1
;
997 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
998 bzero (b
, sizeof *b
);
1000 b
->symtab
= sal
.symtab
;
1001 b
->line_number
= sal
.line
;
1002 b
->enable
= enabled
;
1005 b
->ignore_count
= 0;
1009 /* Add this breakpoint to the end of the chain
1010 so that a list of breakpoints will come out in order
1011 of increasing numbers. */
1013 b1
= breakpoint_chain
;
1015 breakpoint_chain
= b
;
1023 check_duplicates (sal
.pc
);
1028 /* Set a breakpoint that will evaporate an end of command
1029 at address specified by SAL.
1030 Restrict it to frame FRAME if FRAME is nonzero. */
1033 set_momentary_breakpoint (sal
, frame
)
1034 struct symtab_and_line sal
;
1037 register struct breakpoint
*b
;
1038 b
= set_raw_breakpoint (sal
);
1041 b
->frame
= (frame
? FRAME_FP (frame
) : 0);
1045 clear_momentary_breakpoints ()
1047 register struct breakpoint
*b
;
1049 if (b
->number
== -3)
1051 delete_breakpoint (b
);
1056 /* Tell the user we have just set a breakpoint B. */
1059 struct breakpoint
*b
;
1063 printf_filtered ("Watchpoint %d: ", b
->number
);
1064 print_expression (b
->exp
, stdout
);
1068 printf_filtered ("Breakpoint %d at 0x%x", b
->number
, b
->address
);
1070 printf_filtered (": file %s, line %d.",
1071 b
->symtab
->filename
, b
->line_number
);
1073 printf_filtered ("\n");
1077 /* Nobody calls this currently. */
1078 /* Set a breakpoint from a symtab and line.
1079 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1080 ADDR_STRING is a malloc'd string holding the name of where we are
1081 setting the breakpoint. This is used later to re-set it after the
1082 program is relinked and symbols are reloaded.
1083 Print the same confirmation messages that the breakpoint command prints. */
1086 set_breakpoint (s
, line
, tempflag
, addr_string
)
1092 register struct breakpoint
*b
;
1093 struct symtab_and_line sal
;
1097 sal
.pc
= find_line_pc (sal
.symtab
, sal
.line
);
1099 error ("No line %d in file \"%s\".\n", sal
.line
, sal
.symtab
->filename
);
1102 describe_other_breakpoints (sal
.pc
);
1104 b
= set_raw_breakpoint (sal
);
1105 set_breakpoint_count (breakpoint_count
+ 1);
1106 b
->number
= breakpoint_count
;
1108 b
->addr_string
= addr_string
;
1110 b
->enable
= temporary
;
1117 /* Set a breakpoint according to ARG (function, linenum or *address)
1118 and make it temporary if TEMPFLAG is nonzero. */
1121 break_command_1 (arg
, tempflag
, from_tty
)
1123 int tempflag
, from_tty
;
1125 struct symtabs_and_lines sals
;
1126 struct symtab_and_line sal
;
1127 register struct expression
*cond
= 0;
1128 register struct breakpoint
*b
;
1130 /* Pointers in arg to the start, and one past the end, of the condition. */
1131 char *cond_start
= NULL
;
1133 /* Pointers in arg to the start, and one past the end,
1134 of the address part. */
1135 char *addr_start
= NULL
;
1144 sal
.line
= sal
.pc
= sal
.end
= 0;
1147 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1149 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
1150 && (arg
[2] == ' ' || arg
[2] == '\t')))
1152 if (default_breakpoint_valid
)
1154 sals
.sals
= (struct symtab_and_line
*)
1155 xmalloc (sizeof (struct symtab_and_line
));
1156 sal
.pc
= default_breakpoint_address
;
1157 sal
.line
= default_breakpoint_line
;
1158 sal
.symtab
= default_breakpoint_symtab
;
1163 error ("No default breakpoint address now.");
1169 /* Force almost all breakpoints to be in terms of the
1170 current_source_symtab (which is decode_line_1's default). This
1171 should produce the results we want almost all of the time while
1172 leaving default_breakpoint_* alone. */
1173 if (default_breakpoint_valid
1174 && (!current_source_symtab
1175 || (arg
&& (*arg
== '+' || *arg
== '-'))))
1176 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
1177 default_breakpoint_line
);
1179 sals
= decode_line_1 (&arg
, 1, (struct symtab
*)NULL
, 0);
1187 for (i
= 0; i
< sals
.nelts
; i
++)
1190 if (sal
.pc
== 0 && sal
.symtab
!= 0)
1192 pc
= find_line_pc (sal
.symtab
, sal
.line
);
1194 error ("No line %d in file \"%s\".",
1195 sal
.line
, sal
.symtab
->filename
);
1202 if (arg
[0] == 'i' && arg
[1] == 'f'
1203 && (arg
[2] == ' ' || arg
[2] == '\t'))
1207 cond
= parse_c_1 (&arg
, block_for_pc (pc
), 0);
1211 error ("Junk at end of arguments.");
1213 sals
.sals
[i
].pc
= pc
;
1216 for (i
= 0; i
< sals
.nelts
; i
++)
1221 describe_other_breakpoints (sal
.pc
);
1223 b
= set_raw_breakpoint (sal
);
1224 set_breakpoint_count (breakpoint_count
+ 1);
1225 b
->number
= breakpoint_count
;
1229 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
1231 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
1234 b
->enable
= temporary
;
1241 printf ("Multiple breakpoints were set.\n");
1242 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1248 break_command (arg
, from_tty
)
1252 break_command_1 (arg
, 0, from_tty
);
1256 tbreak_command (arg
, from_tty
)
1260 break_command_1 (arg
, 1, from_tty
);
1264 watch_command (arg
, from_tty
)
1268 struct breakpoint
*b
;
1269 struct symtab_and_line sal
;
1270 struct expression
*exp
;
1271 struct block
*exp_valid_block
;
1278 /* Parse arguments. */
1279 innermost_block
= NULL
;
1280 exp
= parse_c_expression (arg
);
1281 exp_valid_block
= innermost_block
;
1282 val
= evaluate_expression (exp
);
1283 release_value (val
);
1285 /* Now set up the breakpoint. */
1286 b
= set_raw_breakpoint (sal
);
1287 set_breakpoint_count (breakpoint_count
+ 1);
1288 b
->number
= breakpoint_count
;
1290 b
->exp_valid_block
= exp_valid_block
;
1293 b
->cond_string
= NULL
;
1298 * Helper routine for the until_command routine in infcmd.c. Here
1299 * because it uses the mechanisms of breakpoints.
1302 until_break_command (arg
, from_tty
)
1306 struct symtabs_and_lines sals
;
1307 struct symtab_and_line sal
;
1308 FRAME prev_frame
= get_prev_frame (selected_frame
);
1310 clear_proceed_status ();
1312 /* Set a breakpoint where the user wants it and at return from
1315 if (default_breakpoint_valid
)
1316 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
1317 default_breakpoint_line
);
1319 sals
= decode_line_1 (&arg
, 1, (struct symtab
*)NULL
, 0);
1321 if (sals
.nelts
!= 1)
1322 error ("Couldn't get information on specified line.");
1325 free (sals
.sals
); /* malloc'd, so freed */
1328 error ("Junk at end of arguments.");
1330 if (sal
.pc
== 0 && sal
.symtab
!= 0)
1331 sal
.pc
= find_line_pc (sal
.symtab
, sal
.line
);
1334 error ("No line %d in file \"%s\".", sal
.line
, sal
.symtab
->filename
);
1336 set_momentary_breakpoint (sal
, selected_frame
);
1338 /* Keep within the current frame */
1342 struct frame_info
*fi
;
1344 fi
= get_frame_info (prev_frame
);
1345 sal
= find_pc_line (fi
->pc
, 0);
1347 set_momentary_breakpoint (sal
, prev_frame
);
1350 proceed (-1, -1, 0);
1353 /* Set a breakpoint at the catch clause for NAME. */
1355 catch_breakpoint (name
)
1361 disable_catch_breakpoint ()
1366 delete_catch_breakpoint ()
1371 enable_catch_breakpoint ()
1377 struct sal_chain
*next
;
1378 struct symtab_and_line sal
;
1381 /* For each catch clause identified in ARGS, run FUNCTION
1382 with that clause as an argument. */
1383 static struct symtabs_and_lines
1384 map_catch_names (args
, function
)
1388 register char *p
= args
;
1390 struct symtabs_and_lines sals
;
1391 struct sal_chain
*sal_chain
= 0;
1394 error_no_arg ("one or more catch names");
1402 /* Don't swallow conditional part. */
1403 if (p1
[0] == 'i' && p1
[1] == 'f'
1404 && (p1
[2] == ' ' || p1
[2] == '\t'))
1410 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
1414 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
1415 error ("Arguments must be catch names.");
1421 struct sal_chain
*next
1422 = (struct sal_chain
*)alloca (sizeof (struct sal_chain
));
1423 next
->next
= sal_chain
;
1424 next
->sal
= get_catch_sal (p
);
1429 printf ("No catch clause for exception %s.\n", p
);
1432 while (*p
== ' ' || *p
== '\t') p
++;
1436 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
1438 static struct symtabs_and_lines
1439 get_catch_sals (this_level_only
)
1440 int this_level_only
;
1442 extern struct blockvector
*blockvector_for_pc ();
1443 register struct blockvector
*bl
;
1444 register struct block
*block
= get_frame_block (selected_frame
);
1445 int index
, have_default
= 0;
1446 struct frame_info
*fi
= get_frame_info (selected_frame
);
1447 CORE_ADDR pc
= fi
->pc
;
1448 struct symtabs_and_lines sals
;
1449 struct sal_chain
*sal_chain
= 0;
1450 char *blocks_searched
;
1456 error ("No symbol table info available.\n");
1458 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
1459 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1460 bzero (blocks_searched
, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1464 CORE_ADDR end
= BLOCK_END (block
) - 4;
1467 if (bl
!= blockvector_for_pc (end
, &index
))
1468 error ("blockvector blotch");
1469 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
1470 error ("blockvector botch");
1471 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
1474 /* Don't print out blocks that have gone by. */
1475 while (index
< last_index
1476 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
1479 while (index
< last_index
1480 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
1482 if (blocks_searched
[index
] == 0)
1484 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
1487 register struct symbol
*sym
;
1489 nsyms
= BLOCK_NSYMS (b
);
1491 for (i
= 0; i
< nsyms
; i
++)
1493 sym
= BLOCK_SYM (b
, i
);
1494 if (! strcmp (SYMBOL_NAME (sym
), "default"))
1500 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
1502 struct sal_chain
*next
= (struct sal_chain
*)
1503 alloca (sizeof (struct sal_chain
));
1504 next
->next
= sal_chain
;
1505 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
), 0);
1509 blocks_searched
[index
] = 1;
1515 if (sal_chain
&& this_level_only
)
1518 /* After handling the function's top-level block, stop.
1519 Don't continue to its superblock, the block of
1520 per-file symbols. */
1521 if (BLOCK_FUNCTION (block
))
1523 block
= BLOCK_SUPERBLOCK (block
);
1528 struct sal_chain
*tmp_chain
;
1530 /* Count the number of entries. */
1531 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
1532 tmp_chain
= tmp_chain
->next
)
1536 sals
.sals
= (struct symtab_and_line
*)
1537 xmalloc (index
* sizeof (struct symtab_and_line
));
1538 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
1539 sals
.sals
[index
] = sal_chain
->sal
;
1545 /* Commands to deal with catching exceptions. */
1548 catch_command_1 (arg
, tempflag
, from_tty
)
1553 /* First, translate ARG into something we can deal with in terms
1556 struct symtabs_and_lines sals
;
1557 struct symtab_and_line sal
;
1558 register struct expression
*cond
= 0;
1559 register struct breakpoint
*b
;
1564 sal
.line
= sal
.pc
= sal
.end
= 0;
1567 /* If no arg given, or if first arg is 'if ', all active catch clauses
1568 are breakpointed. */
1570 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
1571 && (arg
[2] == ' ' || arg
[2] == '\t')))
1573 /* Grab all active catch clauses. */
1574 sals
= get_catch_sals (0);
1578 /* Grab selected catch clauses. */
1579 error ("catch NAME not implemeneted");
1580 sals
= map_catch_names (arg
, catch_breakpoint
);
1587 for (i
= 0; i
< sals
.nelts
; i
++)
1590 if (sal
.pc
== 0 && sal
.symtab
!= 0)
1592 pc
= find_line_pc (sal
.symtab
, sal
.line
);
1594 error ("No line %d in file \"%s\".",
1595 sal
.line
, sal
.symtab
->filename
);
1602 if (arg
[0] == 'i' && arg
[1] == 'f'
1603 && (arg
[2] == ' ' || arg
[2] == '\t'))
1604 cond
= (struct expression
*) parse_c_1 ((arg
+= 2, &arg
),
1605 block_for_pc (pc
), 0);
1607 error ("Junk at end of arguments.");
1610 sals
.sals
[i
].pc
= pc
;
1613 for (i
= 0; i
< sals
.nelts
; i
++)
1618 describe_other_breakpoints (sal
.pc
);
1620 b
= set_raw_breakpoint (sal
);
1621 b
->number
= ++breakpoint_count
;
1624 b
->enable
= temporary
;
1626 printf ("Breakpoint %d at 0x%x", b
->number
, b
->address
);
1628 printf (": file %s, line %d.", b
->symtab
->filename
, b
->line_number
);
1634 printf ("Multiple breakpoints were set.\n");
1635 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1640 /* Disable breakpoints on all catch clauses described in ARGS. */
1642 disable_catch (args
)
1645 /* Map the disable command to catch clauses described in ARGS. */
1648 /* Enable breakpoints on all catch clauses described in ARGS. */
1653 /* Map the disable command to catch clauses described in ARGS. */
1656 /* Delete breakpoints on all catch clauses in the active scope. */
1661 /* Map the delete command to catch clauses described in ARGS. */
1665 catch_command (arg
, from_tty
)
1669 catch_command_1 (arg
, 0, from_tty
);
1673 clear_command (arg
, from_tty
)
1677 register struct breakpoint
*b
, *b1
;
1678 struct symtabs_and_lines sals
;
1679 struct symtab_and_line sal
;
1680 register struct breakpoint
*found
;
1685 sals
= decode_line_spec (arg
, 1);
1689 sals
.sals
= (struct symtab_and_line
*) xmalloc (sizeof (struct symtab_and_line
));
1690 sal
.line
= default_breakpoint_line
;
1691 sal
.symtab
= default_breakpoint_symtab
;
1693 if (sal
.symtab
== 0)
1694 error ("No source file specified.");
1700 for (i
= 0; i
< sals
.nelts
; i
++)
1702 /* If exact pc given, clear bpts at that pc.
1703 But if sal.pc is zero, clear all bpts on specified line. */
1705 found
= (struct breakpoint
*) 0;
1706 while (breakpoint_chain
1707 && (sal
.pc
? breakpoint_chain
->address
== sal
.pc
1708 : (breakpoint_chain
->symtab
== sal
.symtab
1709 && breakpoint_chain
->line_number
== sal
.line
)))
1711 b1
= breakpoint_chain
;
1712 breakpoint_chain
= b1
->next
;
1719 && b
->next
->address
!= NULL
1720 && (sal
.pc
? b
->next
->address
== sal
.pc
1721 : (b
->next
->symtab
== sal
.symtab
1722 && b
->next
->line_number
== sal
.line
)))
1733 error ("No breakpoint at %s.", arg
);
1735 error ("No breakpoint at this line.");
1738 if (found
->next
) from_tty
= 1; /* Always report if deleted more than one */
1739 if (from_tty
) printf ("Deleted breakpoint%s ", found
->next
? "s" : "");
1742 if (from_tty
) printf ("%d ", found
->number
);
1744 delete_breakpoint (found
);
1747 if (from_tty
) putchar ('\n');
1752 /* Delete breakpoint in BS if they are `delete' breakpoints.
1753 This is called after any breakpoint is hit, or after errors. */
1756 breakpoint_auto_delete (bs
)
1759 for (; bs
; bs
= bs
->next
)
1760 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->enable
== delete)
1761 delete_breakpoint (bs
->breakpoint_at
);
1764 /* Delete a breakpoint and clean up all traces of it in the data structures. */
1767 delete_breakpoint (bpt
)
1768 struct breakpoint
*bpt
;
1770 register struct breakpoint
*b
;
1774 target_remove_breakpoint(bpt
->address
, bpt
->shadow_contents
);
1776 if (breakpoint_chain
== bpt
)
1777 breakpoint_chain
= bpt
->next
;
1782 b
->next
= bpt
->next
;
1786 check_duplicates (bpt
->address
);
1788 free_command_lines (&bpt
->commands
);
1791 if (bpt
->cond_string
!= NULL
)
1792 free (bpt
->cond_string
);
1793 if (bpt
->addr_string
!= NULL
)
1794 free (bpt
->addr_string
);
1796 if (xgdb_verbose
&& bpt
->number
>=0)
1797 printf ("breakpoint #%d deleted\n", bpt
->number
);
1799 /* Be sure no bpstat's are pointing at it after it's been freed. */
1800 /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */
1801 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
1802 if (bs
->breakpoint_at
== bpt
)
1803 bs
->breakpoint_at
= NULL
;
1807 static void map_breakpoint_numbers ();
1810 delete_command (arg
, from_tty
)
1817 /* Ask user only if there are some breakpoints to delete. */
1819 || (breakpoint_chain
&& query ("Delete all breakpoints? ", 0, 0)))
1821 /* No arg; clear all breakpoints. */
1822 while (breakpoint_chain
)
1823 delete_breakpoint (breakpoint_chain
);
1827 map_breakpoint_numbers (arg
, delete_breakpoint
);
1831 breakpoint_re_set_one (bint
)
1834 struct breakpoint
*b
= (struct breakpoint
*)bint
; /* get past catch_errs */
1836 struct symtabs_and_lines sals
;
1837 struct symtab_and_line sal
;
1840 if (b
->address
!= NULL
&& b
->addr_string
!= NULL
)
1843 sals
= decode_line_1 (&s
, 1, (struct symtab
*)NULL
, 0);
1844 for (i
= 0; i
< sals
.nelts
; i
++)
1848 b
->symtab
= sal
.symtab
;
1849 b
->line_number
= sal
.line
;
1850 if (sal
.pc
== 0 && sal
.symtab
!= 0)
1852 sal
.pc
= find_line_pc (sal
.symtab
, sal
.line
);
1854 error ("No line %d in file \"%s\".",
1855 sal
.line
, sal
.symtab
->filename
);
1857 b
->address
= sal
.pc
;
1859 if (b
->cond_string
!= NULL
)
1862 b
->cond
= parse_c_1 (&s
, block_for_pc (sal
.pc
), 0);
1865 check_duplicates (b
->address
);
1873 /* Anything without a string can't be re-set. */
1874 delete_breakpoint (b
);
1878 /* Re-set all breakpoints after symbols have been re-loaded. */
1880 breakpoint_re_set ()
1882 struct breakpoint
*b
;
1886 b
->symtab
= 0; /* Be sure we don't point to old dead symtab */
1887 (void) catch_errors (breakpoint_re_set_one
, (int) b
,
1888 "Error in re-setting breakpoint");
1891 /* Blank line to finish off all those mention() messages we just printed. */
1892 printf_filtered ("\n");
1895 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
1896 If from_tty is nonzero, it prints a message to that effect,
1897 which ends with a period (no newline). */
1900 set_ignore_count (bptnum
, count
, from_tty
)
1901 int bptnum
, count
, from_tty
;
1903 register struct breakpoint
*b
;
1909 if (b
->number
== bptnum
)
1911 b
->ignore_count
= count
;
1914 else if (count
== 0)
1915 printf ("Will stop next time breakpoint %d is reached.", bptnum
);
1916 else if (count
== 1)
1917 printf ("Will ignore next crossing of breakpoint %d.", bptnum
);
1919 printf ("Will ignore next %d crossings of breakpoint %d.",
1924 error ("No breakpoint number %d.", bptnum
);
1927 /* Clear the ignore counts of all breakpoints. */
1929 breakpoint_clear_ignore_counts ()
1931 struct breakpoint
*b
;
1934 b
->ignore_count
= 0;
1937 /* Command to set ignore-count of breakpoint N to COUNT. */
1940 ignore_command (args
, from_tty
)
1948 error_no_arg ("a breakpoint number");
1950 num
= get_number (&p
);
1953 error ("Second argument (specified ignore-count) is missing.");
1955 set_ignore_count (num
, parse_and_eval_address (p
), from_tty
);
1959 /* Call FUNCTION on each of the breakpoints
1960 whose numbers are given in ARGS. */
1963 map_breakpoint_numbers (args
, function
)
1965 void (*function
) ();
1967 register char *p
= args
;
1970 register struct breakpoint
*b
;
1973 error_no_arg ("one or more breakpoint numbers");
1979 num
= get_number (&p1
);
1982 if (b
->number
== num
)
1987 printf ("No breakpoint number %d.\n", num
);
1994 enable_breakpoint (bpt
)
1995 struct breakpoint
*bpt
;
1997 bpt
->enable
= enabled
;
1999 if (xgdb_verbose
&& bpt
->number
>= 0)
2000 printf ("breakpoint #%d enabled\n", bpt
->number
);
2002 check_duplicates (bpt
->address
);
2003 if (bpt
->val
!= NULL
)
2005 if (bpt
->exp_valid_block
!= NULL
2006 && !contained_in (get_selected_block (), bpt
->exp_valid_block
))
2009 Cannot enable watchpoint %d because the block in which its expression\n\
2010 is valid is not currently in scope.\n", bpt
->number
);
2014 value_free (bpt
->val
);
2016 bpt
->val
= evaluate_expression (bpt
->exp
);
2017 release_value (bpt
->val
);
2022 enable_command (args
, from_tty
)
2026 struct breakpoint
*bpt
;
2028 ALL_BREAKPOINTS (bpt
)
2029 enable_breakpoint (bpt
);
2031 map_breakpoint_numbers (args
, enable_breakpoint
);
2035 disable_breakpoint (bpt
)
2036 struct breakpoint
*bpt
;
2038 bpt
->enable
= disabled
;
2040 if (xgdb_verbose
&& bpt
->number
>= 0)
2041 printf ("breakpoint #%d disabled\n", bpt
->number
);
2043 check_duplicates (bpt
->address
);
2047 disable_command (args
, from_tty
)
2051 register struct breakpoint
*bpt
;
2053 ALL_BREAKPOINTS (bpt
)
2054 disable_breakpoint (bpt
);
2056 map_breakpoint_numbers (args
, disable_breakpoint
);
2060 enable_once_breakpoint (bpt
)
2061 struct breakpoint
*bpt
;
2063 bpt
->enable
= temporary
;
2065 check_duplicates (bpt
->address
);
2069 enable_once_command (args
, from_tty
)
2073 map_breakpoint_numbers (args
, enable_once_breakpoint
);
2077 enable_delete_breakpoint (bpt
)
2078 struct breakpoint
*bpt
;
2080 bpt
->enable
= delete;
2082 check_duplicates (bpt
->address
);
2086 enable_delete_command (args
, from_tty
)
2090 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
2094 * Use default_breakpoint_'s, or nothing if they aren't valid.
2096 struct symtabs_and_lines
2097 decode_line_spec_1 (string
, funfirstline
)
2101 struct symtabs_and_lines sals
;
2103 error ("Empty line specification.");
2104 if (default_breakpoint_valid
)
2105 sals
= decode_line_1 (&string
, funfirstline
,
2106 default_breakpoint_symtab
, default_breakpoint_line
);
2108 sals
= decode_line_1 (&string
, funfirstline
, (struct symtab
*)NULL
, 0);
2110 error ("Junk at end of line specification: %s", string
);
2115 /* Chain containing all defined enable commands. */
2117 extern struct cmd_list_element
2118 *enablelist
, *disablelist
,
2119 *deletelist
, *enablebreaklist
;
2121 extern struct cmd_list_element
*cmdlist
;
2124 _initialize_breakpoint ()
2126 breakpoint_chain
= 0;
2127 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
2128 before a breakpoint is set. */
2129 breakpoint_count
= 0;
2131 add_com ("ignore", class_breakpoint
, ignore_command
,
2132 "Set ignore-count of breakpoint number N to COUNT.");
2134 add_com ("commands", class_breakpoint
, commands_command
,
2135 "Set commands to be executed when a breakpoint is hit.\n\
2136 Give breakpoint number as argument after \"commands\".\n\
2137 With no argument, the targeted breakpoint is the last one set.\n\
2138 The commands themselves follow starting on the next line.\n\
2139 Type a line containing \"end\" to indicate the end of them.\n\
2140 Give \"silent\" as the first line to make the breakpoint silent;\n\
2141 then no output is printed when it is hit, except what the commands print.");
2143 add_com ("condition", class_breakpoint
, condition_command
,
2144 "Specify breakpoint number N to break only if COND is true.\n\
2145 N is an integer; COND is a C expression to be evaluated whenever\n\
2146 breakpoint N is reached. Actually break only when COND is nonzero.");
2148 add_com ("tbreak", class_breakpoint
, tbreak_command
,
2149 "Set a temporary breakpoint. Args like \"break\" command.\n\
2150 Like \"break\" except the breakpoint is only enabled temporarily,\n\
2151 so it will be disabled when hit. Equivalent to \"break\" followed\n\
2152 by using \"enable once\" on the breakpoint number.");
2154 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
2155 "Enable some breakpoints.\n\
2156 Give breakpoint numbers (separated by spaces) as arguments.\n\
2157 With no subcommand, breakpoints are enabled until you command otherwise.\n\
2158 This is used to cancel the effect of the \"disable\" command.\n\
2159 With a subcommand you can enable temporarily.",
2160 &enablelist
, "enable ", 1, &cmdlist
);
2162 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
2163 "Enable some breakpoints.\n\
2164 Give breakpoint numbers (separated by spaces) as arguments.\n\
2165 This is used to cancel the effect of the \"disable\" command.\n\
2166 May be abbreviated to simply \"enable\".\n",
2167 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
2169 add_cmd ("once", no_class
, enable_once_command
,
2170 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2171 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2172 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2175 add_cmd ("delete", no_class
, enable_delete_command
,
2176 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2177 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2180 add_cmd ("delete", no_class
, enable_delete_command
,
2181 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2182 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2185 add_cmd ("once", no_class
, enable_once_command
,
2186 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2187 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2188 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2191 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
2192 "Disable some breakpoints.\n\
2193 Arguments are breakpoint numbers with spaces in between.\n\
2194 To disable all breakpoints, give no argument.\n\
2195 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
2196 &disablelist
, "disable ", 1, &cmdlist
);
2197 add_com_alias ("dis", "disable", class_breakpoint
, 1);
2198 add_com_alias ("disa", "disable", class_breakpoint
, 1);
2200 add_cmd ("breakpoints", class_alias
, disable_command
,
2201 "Disable some breakpoints.\n\
2202 Arguments are breakpoint numbers with spaces in between.\n\
2203 To disable all breakpoints, give no argument.\n\
2204 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
2205 This command may be abbreviated \"disable\".",
2208 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
2209 "Delete some breakpoints or auto-display expressions.\n\
2210 Arguments are breakpoint numbers with spaces in between.\n\
2211 To delete all breakpoints, give no argument.\n\
2213 Also a prefix command for deletion of other GDB objects.\n\
2214 The \"unset\" command is also an alias for \"delete\".",
2215 &deletelist
, "delete ", 1, &cmdlist
);
2216 add_com_alias ("d", "delete", class_breakpoint
, 1);
2218 add_cmd ("breakpoints", class_alias
, delete_command
,
2219 "Delete some breakpoints or auto-display expressions.\n\
2220 Arguments are breakpoint numbers with spaces in between.\n\
2221 To delete all breakpoints, give no argument.\n\
2222 This command may be abbreviated \"delete\".",
2225 add_com ("clear", class_breakpoint
, clear_command
,
2226 "Clear breakpoint at specified line or function.\n\
2227 Argument may be line number, function name, or \"*\" and an address.\n\
2228 If line number is specified, all breakpoints in that line are cleared.\n\
2229 If function is specified, breakpoints at beginning of function are cleared.\n\
2230 If an address is specified, breakpoints at that address are cleared.\n\n\
2231 With no argument, clears all breakpoints in the line that the selected frame\n\
2234 See also the \"delete\" command which clears breakpoints by number.");
2236 add_com ("break", class_breakpoint
, break_command
,
2237 "Set breakpoint at specified line or function.\n\
2238 Argument may be line number, function name, or \"*\" and an address.\n\
2239 If line number is specified, break at start of code for that line.\n\
2240 If function is specified, break at start of code for that function.\n\
2241 If an address is specified, break at that exact address.\n\
2242 With no arg, uses current execution address of selected stack frame.\n\
2243 This is useful for breaking on return to a stack frame.\n\
2245 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
2247 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2248 add_com_alias ("b", "break", class_run
, 1);
2249 add_com_alias ("br", "break", class_run
, 1);
2250 add_com_alias ("bre", "break", class_run
, 1);
2251 add_com_alias ("brea", "break", class_run
, 1);
2253 add_info ("breakpoints", breakpoints_info
,
2254 "Status of all breakpoints, or breakpoint number NUMBER.\n\
2255 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
2256 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
2257 Then come the address and the file/line number.\n\n\
2258 Convenience variable \"$_\" and default examine address for \"x\"\n\
2259 are set to the address of the last breakpoint listed.\n\n\
2260 Convenience variable \"$bpnum\" contains the number of the last\n\
2263 add_com ("catch", class_breakpoint
, catch_command
,
2264 "Set breakpoints to catch exceptions that are raised.\n\
2265 Argument may be a single exception to catch, multiple exceptions\n\
2266 to catch, or the default exception \"default\". If no arguments\n\
2267 are given, breakpoints are set at all exception handlers catch clauses\n\
2268 within the current scope.\n\
2270 A condition specified for the catch applies to all breakpoints set\n\
2271 with this command\n\
2273 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2275 add_com ("watch", class_breakpoint
, watch_command
,
2276 "Set a watchpoint for an expression.\n\
2277 A watchpoint stops execution of your program whenever the value of\n\
2278 an expression changes.");
2280 add_info ("watchpoints", watchpoints_info
,
2281 "Status of all watchpoints, or watchpoint number NUMBER.\n\
2282 Second column is \"y\" for enabled watchpoints, \"n\" for disabled.");