1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992 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. */
24 #include "breakpoint.h"
26 #include "expression.h"
39 /* local function prototypes */
42 catch_command_1 PARAMS ((char *, int, int));
45 enable_delete_command PARAMS ((char *, int));
48 enable_delete_breakpoint PARAMS ((struct breakpoint *));
51 enable_once_command PARAMS ((char *, int));
54 enable_once_breakpoint PARAMS ((struct breakpoint *));
57 disable_command PARAMS ((char *, int));
60 disable_breakpoint PARAMS ((struct breakpoint *));
63 enable_command PARAMS ((char *, int));
66 enable_breakpoint PARAMS ((struct breakpoint *));
69 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
72 ignore_command PARAMS ((char *, int));
75 breakpoint_re_set_one PARAMS ((char *));
78 delete_command PARAMS ((char *, int));
81 clear_command PARAMS ((char *, int));
84 catch_command PARAMS ((char *, int));
86 static struct symtabs_and_lines
87 get_catch_sals PARAMS ((int));
90 watch_command PARAMS ((char *, int));
93 tbreak_command PARAMS ((char *, int));
96 break_command_1 PARAMS ((char *, int, int));
99 mention PARAMS ((struct breakpoint *));
101 static struct breakpoint *
102 set_raw_breakpoint PARAMS ((struct symtab_and_line));
105 check_duplicates PARAMS ((CORE_ADDR));
108 describe_other_breakpoints PARAMS ((CORE_ADDR));
111 breakpoints_info PARAMS ((char *, int));
114 breakpoint_1 PARAMS ((int, int));
117 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
120 breakpoint_cond_eval PARAMS ((char *));
123 cleanup_executing_breakpoints PARAMS ((int));
126 commands_command PARAMS ((char *, int));
129 condition_command PARAMS ((char *, int));
132 get_number PARAMS ((char **));
135 set_breakpoint_count PARAMS ((int));
138 extern int addressprint; /* Print machine addresses? */
139 extern int demangle; /* Print de-mangled symbol names? */
141 /* Are we executing breakpoint commands? */
142 static int executing_breakpoint_commands;
144 /* Walk the following statement or block through all breakpoints.
145 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
148 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
150 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
151 for (b = breakpoint_chain; \
152 b? (tmp=b->next, 1): 0; \
155 /* Chain of all breakpoints defined. */
157 static struct breakpoint *breakpoint_chain;
159 /* Number of last breakpoint made. */
161 static int breakpoint_count;
163 /* Set breakpoint count to NUM. */
165 set_breakpoint_count (num)
168 breakpoint_count = num;
169 set_internalvar (lookup_internalvar ("bpnum"),
170 value_from_longest (builtin_type_int, (LONGEST) num));
173 /* Default address, symtab and line to put a breakpoint at
174 for "break" command with no arg.
175 if default_breakpoint_valid is zero, the other three are
176 not valid, and "break" with no arg is an error.
178 This set by print_stack_frame, which calls set_default_breakpoint. */
180 int default_breakpoint_valid;
181 CORE_ADDR default_breakpoint_address;
182 struct symtab *default_breakpoint_symtab;
183 int default_breakpoint_line;
185 /* Flag indicating extra verbosity for xgdb. */
186 extern int xgdb_verbose;
188 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
189 Advance *PP after the string and any trailing whitespace.
191 Currently the string can either be a number or "$" followed by the name
192 of a convenience variable. Making it an expression wouldn't work well
193 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
202 /* Empty line means refer to the last breakpoint. */
203 return breakpoint_count;
206 /* Make a copy of the name, so we can null-terminate it
207 to pass to lookup_internalvar(). */
212 while (isalnum (*p) || *p == '_')
214 varname = (char *) alloca (p - start + 1);
215 strncpy (varname, start, p - start);
216 varname[p - start] = '\0';
217 val = value_of_internalvar (lookup_internalvar (varname));
218 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
220 "Convenience variables used to specify breakpoints must have integer values."
222 retval = (int) value_as_long (val);
228 while (*p >= '0' && *p <= '9')
231 /* There is no number here. (e.g. "cond a == b"). */
232 error_no_arg ("breakpoint number");
235 if (!(isspace (*p) || *p == '\0'))
236 error ("breakpoint number expected");
243 /* condition N EXP -- set break condition of breakpoint N to EXP. */
246 condition_command (arg, from_tty)
250 register struct breakpoint *b;
255 error_no_arg ("breakpoint number");
258 bnum = get_number (&p);
261 if (b->number == bnum)
268 if (b->cond_string != NULL)
269 free ((PTR)b->cond_string);
274 b->cond_string = NULL;
276 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
281 /* I don't know if it matters whether this is the string the user
282 typed in or the decompiled expression. */
283 b->cond_string = savestring (arg, strlen (arg));
284 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
286 error ("Junk at end of expression");
291 error ("No breakpoint number %d.", bnum);
296 commands_command (arg, from_tty)
300 register struct breakpoint *b;
303 struct command_line *l;
305 /* If we allowed this, we would have problems with when to
306 free the storage, if we change the commands currently
309 if (executing_breakpoint_commands)
310 error ("Can't use the \"commands\" command among a breakpoint's commands.");
313 bnum = get_number (&p);
315 error ("Unexpected extra arguments following breakpoint number.");
318 if (b->number == bnum)
320 if (from_tty && input_from_terminal_p ())
321 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
322 End with a line saying just \"end\".\n", bnum);
323 l = read_command_lines ();
324 free_command_lines (&b->commands);
328 error ("No breakpoint number %d.", bnum);
331 extern int memory_breakpoint_size; /* from mem-break.c */
333 /* Like target_read_memory() but if breakpoints are inserted, return
334 the shadow contents instead of the breakpoints themselves.
336 Read "memory data" from whatever target or inferior we have.
337 Returns zero if successful, errno value if not. EIO is used
338 for address out of bounds. If breakpoints are inserted, returns
339 shadow contents, not the breakpoints themselves. From breakpoint.c. */
342 read_memory_nobpt (memaddr, myaddr, len)
348 struct breakpoint *b;
350 if (memory_breakpoint_size < 0)
351 /* No breakpoints on this machine. FIXME: This should be
352 dependent on the debugging target. Probably want
353 target_insert_breakpoint to return a size, saying how many
354 bytes of the shadow contents are used, or perhaps have
355 something like target_xfer_shadow. */
356 return target_read_memory (memaddr, myaddr, len);
360 if (b->type == bp_watchpoint || !b->inserted)
362 else if (b->address + memory_breakpoint_size <= memaddr)
363 /* The breakpoint is entirely before the chunk of memory
366 else if (b->address >= memaddr + len)
367 /* The breakpoint is entirely after the chunk of memory we
372 /* Copy the breakpoint from the shadow contents, and recurse
373 for the things before and after. */
375 /* Addresses and length of the part of the breakpoint that
377 CORE_ADDR membpt = b->address;
378 unsigned int bptlen = memory_breakpoint_size;
379 /* Offset within shadow_contents. */
382 if (membpt < memaddr)
384 /* Only copy the second part of the breakpoint. */
385 bptlen -= memaddr - membpt;
386 bptoffset = memaddr - membpt;
390 if (membpt + bptlen > memaddr + len)
392 /* Only copy the first part of the breakpoint. */
393 bptlen -= (membpt + bptlen) - (memaddr + len);
396 memcpy (myaddr + membpt - memaddr,
397 b->shadow_contents + bptoffset, bptlen);
399 if (membpt > memaddr)
401 /* Copy the section of memory before the breakpoint. */
402 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
407 if (membpt + bptlen < memaddr + len)
409 /* Copy the section of memory after the breakpoint. */
410 status = read_memory_nobpt
412 myaddr + membpt + bptlen - memaddr,
413 memaddr + len - (membpt + bptlen));
420 /* Nothing overlaps. Just call read_memory_noerr. */
421 return target_read_memory (memaddr, myaddr, len);
424 /* insert_breakpoints is used when starting or continuing the program.
425 remove_breakpoints is used when the program stops.
426 Both return zero if successful,
427 or an `errno' value if could not write the inferior. */
430 insert_breakpoints ()
432 register struct breakpoint *b;
434 int disabled_breaks = 0;
437 if (b->type != bp_watchpoint
438 && b->enable != disabled
442 val = target_insert_breakpoint(b->address, b->shadow_contents);
445 /* Can't set the breakpoint. */
446 #if defined (DISABLE_UNSETTABLE_BREAK)
447 if (DISABLE_UNSETTABLE_BREAK (b->address))
450 b->enable = disabled;
451 if (!disabled_breaks)
453 target_terminal_ours_for_output ();
454 fprintf_unfiltered (gdb_stderr,
455 "Cannot insert breakpoint %d:\n", b->number);
456 printf_filtered ("Disabling shared library breakpoints:\n");
459 printf_filtered ("%d ", b->number);
464 target_terminal_ours_for_output ();
465 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
466 #ifdef ONE_PROCESS_WRITETEXT
467 fprintf_unfiltered (gdb_stderr,
468 "The same program may be running in another process.\n");
470 memory_error (val, b->address); /* which bombs us out */
477 printf_filtered ("\n");
482 remove_breakpoints ()
484 register struct breakpoint *b;
487 #ifdef BREAKPOINT_DEBUG
488 printf_unfiltered ("Removing breakpoints.\n");
489 #endif /* BREAKPOINT_DEBUG */
492 if (b->type != bp_watchpoint && b->inserted)
494 val = target_remove_breakpoint(b->address, b->shadow_contents);
498 #ifdef BREAKPOINT_DEBUG
499 printf_unfiltered ("Removed breakpoint at %s",
500 local_hex_string((unsigned long) b->address));
501 printf_unfiltered (", shadow %s",
502 local_hex_string((unsigned long) b->shadow_contents[0]));
503 printf_unfiltered (", %s.\n",
504 local_hex_string((unsigned long) b->shadow_contents[1]));
505 #endif /* BREAKPOINT_DEBUG */
511 /* Clear the "inserted" flag in all breakpoints. */
514 mark_breakpoints_out ()
516 register struct breakpoint *b;
522 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
523 which should go away between runs of the program. */
526 breakpoint_init_inferior ()
528 register struct breakpoint *b, *temp;
530 ALL_BREAKPOINTS_SAFE (b, temp)
534 /* If the call dummy breakpoint is at the entry point it will
535 cause problems when the inferior is rerun, so we better
537 if (b->type == bp_call_dummy)
538 delete_breakpoint (b);
542 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
543 When continuing from a location with a breakpoint,
544 we actually single step once before calling insert_breakpoints. */
547 breakpoint_here_p (pc)
550 register struct breakpoint *b;
553 if (b->enable != disabled && b->address == pc)
559 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
560 because figuring out the saved SP would take too much time, at least using
561 get_saved_register on the 68k. This means that for this function to
562 work right a port must use the bp_call_dummy breakpoint. */
565 frame_in_dummy (frame)
568 struct breakpoint *b;
572 /* We could also check whether fi->pc is within the call dummy, but
573 that should not be necessary if we check the frame (note the
574 call dummy is sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE
575 bytes not just sizeof (dummy) bytes). */
576 if (b->type == bp_call_dummy
577 && b->frame == frame->frame)
583 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
584 is valid for process/thread PID. */
587 breakpoint_thread_match (pc, pid)
591 struct breakpoint *b;
594 thread = pid_to_thread_id (pid);
597 if (b->enable != disabled
599 && (b->thread == -1 || b->thread == thread))
606 /* bpstat stuff. External routines' interfaces are documented
609 /* Clear a bpstat so that it says we are not at any breakpoint.
610 Also free any storage that is part of a bpstat. */
625 if (p->old_val != NULL)
626 value_free (p->old_val);
633 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
634 is part of the bpstat is copied as well. */
642 bpstat retval = NULL;
647 for (; bs != NULL; bs = bs->next)
649 tmp = (bpstat) xmalloc (sizeof (*tmp));
650 memcpy (tmp, bs, sizeof (*tmp));
652 /* This is the first thing in the chain. */
662 /* Find the bpstat associated with this breakpoint */
665 bpstat_find_breakpoint(bsp, breakpoint)
667 struct breakpoint *breakpoint;
669 if (bsp == NULL) return NULL;
671 for (;bsp != NULL; bsp = bsp->next) {
672 if (bsp->breakpoint_at == breakpoint) return bsp;
677 /* Return the breakpoint number of the first breakpoint we are stopped
678 at. *BSP upon return is a bpstat which points to the remaining
679 breakpoints stopped at (but which is not guaranteed to be good for
680 anything but further calls to bpstat_num).
681 Return 0 if passed a bpstat which does not indicate any breakpoints. */
687 struct breakpoint *b;
690 return 0; /* No more breakpoint values */
693 b = (*bsp)->breakpoint_at;
696 return -1; /* breakpoint that's been deleted since */
698 return b->number; /* We have its number */
702 /* Modify BS so that the actions will not be performed. */
705 bpstat_clear_actions (bs)
708 for (; bs != NULL; bs = bs->next)
711 if (bs->old_val != NULL)
713 value_free (bs->old_val);
719 /* Stub for cleaning up our state if we error-out of a breakpoint command */
722 cleanup_executing_breakpoints (ignore)
725 executing_breakpoint_commands = 0;
728 /* Execute all the commands associated with all the breakpoints at this
729 location. Any of these commands could cause the process to proceed
730 beyond this point, etc. We look out for such changes by checking
731 the global "breakpoint_proceeded" after each command. */
734 bpstat_do_actions (bsp)
738 struct cleanup *old_chain;
740 executing_breakpoint_commands = 1;
741 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
746 breakpoint_proceeded = 0;
747 for (; bs != NULL; bs = bs->next)
751 char *line = bs->commands->line;
752 bs->commands = bs->commands->next;
753 execute_command (line, 0);
754 /* If the inferior is proceeded by the command, bomb out now.
755 The bpstat chain has been blown away by wait_for_inferior.
756 But since execution has stopped again, there is a new bpstat
757 to look at, so start over. */
758 if (breakpoint_proceeded)
763 executing_breakpoint_commands = 0;
764 discard_cleanups (old_chain);
767 /* This is the normal print_it function for a bpstat. In the future,
768 much of this logic could (should?) be moved to bpstat_stop_status,
769 by having it set different print_it functions. */
775 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
776 which has since been deleted. */
777 if (bs->breakpoint_at == NULL
778 || (bs->breakpoint_at->type != bp_breakpoint
779 && bs->breakpoint_at->type != bp_watchpoint))
782 if (bs->breakpoint_at->type == bp_breakpoint)
784 /* I think the user probably only wants to see one breakpoint
785 number, not all of them. */
786 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
790 if (bs->old_val != NULL)
792 printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number);
793 print_expression (bs->breakpoint_at->exp, gdb_stdout);
794 printf_filtered ("\nOld value = ");
795 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
796 printf_filtered ("\nNew value = ");
797 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
799 printf_filtered ("\n");
800 value_free (bs->old_val);
804 /* We can't deal with it. Maybe another member of the bpstat chain can. */
808 /* Print a message indicating what happened. Returns nonzero to
809 say that only the source line should be printed after this (zero
810 return means print the frame as well as the source line). */
811 /* Currently we always return zero. */
821 val = (*bs->print_it) (bs);
825 /* Maybe another breakpoint in the chain caused us to stop.
826 (Currently all watchpoints go on the bpstat whether hit or
827 not. That probably could (should) be changed, provided care is taken
828 with respect to bpstat_explains_signal). */
830 return bpstat_print (bs->next);
832 /* We reached the end of the chain without printing anything. */
836 /* Evaluate the expression EXP and return 1 if value is zero.
837 This is used inside a catch_errors to evaluate the breakpoint condition.
838 The argument is a "struct expression *" that has been cast to char * to
839 make it pass through catch_errors. */
842 breakpoint_cond_eval (exp)
845 return !value_true (evaluate_expression ((struct expression *)exp));
848 /* Allocate a new bpstat and chain it to the current one. */
851 bpstat_alloc (b, cbs)
852 register struct breakpoint *b;
853 bpstat cbs; /* Current "bs" value */
857 bs = (bpstat) xmalloc (sizeof (*bs));
859 bs->breakpoint_at = b;
860 /* If the condition is false, etc., don't do the commands. */
863 bs->print_it = print_it_normal;
867 /* Return the frame which we can use to evaluate the expression
868 whose valid block is valid_block, or NULL if not in scope.
870 This whole concept is probably not the way to do things (it is incredibly
871 slow being the main reason, not to mention fragile (e.g. the sparc
872 frame pointer being fetched as 0 bug causes it to stop)). Instead,
873 introduce a version of "struct frame" which survives over calls to the
874 inferior, but which is better than FRAME_ADDR in the sense that it lets
875 us evaluate expressions relative to that frame (on some machines, it
876 can just be a FRAME_ADDR). Save one of those instead of (or in addition
877 to) the exp_valid_block, and then use it to evaluate the watchpoint
878 expression, with no need to do all this backtracing every time.
880 Or better yet, what if it just copied the struct frame and its next
881 frame? Off the top of my head, I would think that would work
882 because things like (a29k) rsize and msize, or (sparc) bottom just
883 depend on the frame, and aren't going to be different just because
884 the inferior has done something. Trying to recalculate them
885 strikes me as a lot of work, possibly even impossible. Saving the
886 next frame is needed at least on a29k, where get_saved_register
887 uses fi->next->saved_msp. For figuring out whether that frame is
888 still on the stack, I guess this needs to be machine-specific (e.g.
891 read_fp () INNER_THAN watchpoint_frame->frame
893 would generally work.
895 Of course the scope of the expression could be less than a whole
896 function; perhaps if the innermost frame is the one which the
897 watchpoint is relative to (another machine-specific thing, usually
899 FRAMELESS_FUNCTION_INVOCATION (get_current_frame(), fromleaf)
900 read_fp () == wp_frame->frame
903 ), *then* it could do a
905 contained_in (get_current_block (), wp->exp_valid_block).
910 within_scope (valid_block)
911 struct block *valid_block;
913 FRAME fr = get_current_frame ();
914 struct frame_info *fi = get_frame_info (fr);
915 CORE_ADDR func_start;
917 /* If caller_pc_valid is true, we are stepping through
918 a function prologue, which is bounded by callee_func_start
919 (inclusive) and callee_prologue_end (exclusive).
920 caller_pc is the pc of the caller.
922 Yes, this is hairy. */
923 static int caller_pc_valid = 0;
924 static CORE_ADDR caller_pc;
925 static CORE_ADDR callee_func_start;
926 static CORE_ADDR callee_prologue_end;
928 find_pc_partial_function (fi->pc, (PTR)NULL, &func_start, (CORE_ADDR *)NULL);
929 func_start += FUNCTION_START_OFFSET;
930 if (fi->pc == func_start)
932 /* We just called a function. The only other case I
933 can think of where the pc would equal the pc of the
934 start of a function is a frameless function (i.e.
935 no prologue) where we branch back to the start
936 of the function. In that case, SKIP_PROLOGUE won't
937 find one, and we'll clear caller_pc_valid a few lines
940 caller_pc = SAVED_PC_AFTER_CALL (fr);
941 callee_func_start = func_start;
942 SKIP_PROLOGUE (func_start);
943 callee_prologue_end = func_start;
947 if (fi->pc < callee_func_start
948 || fi->pc >= callee_prologue_end)
952 if (contained_in (block_for_pc (caller_pc_valid
959 fr = get_prev_frame (fr);
961 /* If any active frame is in the exp_valid_block, then it's
962 OK. Note that this might not be the same invocation of
963 the exp_valid_block that we were watching a little while
964 ago, or the same one as when the watchpoint was set (e.g.
965 we are watching a local variable in a recursive function.
966 When we return from a recursive invocation, then we are
967 suddenly watching a different instance of the variable).
969 At least for now I am going to consider this a feature. */
970 for (; fr != NULL; fr = get_prev_frame (fr))
972 fi = get_frame_info (fr);
973 if (contained_in (block_for_pc (fi->pc),
982 /* Possible return values for watchpoint_check (this can't be an enum
983 because of check_errors). */
984 /* The watchpoint has been disabled. */
985 #define WP_DISABLED 1
986 /* The value has changed. */
987 #define WP_VALUE_CHANGED 2
988 /* The value has not changed. */
989 #define WP_VALUE_NOT_CHANGED 3
991 /* Check watchpoint condition. */
996 bpstat bs = (bpstat) p;
999 int within_current_scope;
1000 if (bs->breakpoint_at->exp_valid_block == NULL)
1001 within_current_scope = 1;
1004 fr = within_scope (bs->breakpoint_at->exp_valid_block);
1005 within_current_scope = fr != NULL;
1006 if (within_current_scope)
1007 /* If we end up stopping, the current frame will get selected
1008 in normal_stop. So this call to select_frame won't affect
1010 select_frame (fr, -1);
1013 if (within_current_scope)
1015 /* We use value_{,free_to_}mark because it could be a
1016 *long* time before we return to the command level and
1017 call free_all_values. We can't call free_all_values because
1018 we might be in the middle of evaluating a function call. */
1020 value mark = value_mark ();
1021 value new_val = evaluate_expression (bs->breakpoint_at->exp);
1022 if (!value_equal (bs->breakpoint_at->val, new_val))
1024 release_value (new_val);
1025 value_free_to_mark (mark);
1026 bs->old_val = bs->breakpoint_at->val;
1027 bs->breakpoint_at->val = new_val;
1028 /* We will stop here */
1029 return WP_VALUE_CHANGED;
1033 /* Nothing changed, don't do anything. */
1034 value_free_to_mark (mark);
1035 /* We won't stop here */
1036 return WP_VALUE_NOT_CHANGED;
1041 /* This seems like the only logical thing to do because
1042 if we temporarily ignored the watchpoint, then when
1043 we reenter the block in which it is valid it contains
1044 garbage (in the case of a function, it may have two
1045 garbage values, one before and one after the prologue).
1046 So we can't even detect the first assignment to it and
1047 watch after that (since the garbage may or may not equal
1048 the first value assigned). */
1049 bs->breakpoint_at->enable = disabled;
1051 Watchpoint %d disabled because the program has left the block in\n\
1052 which its expression is valid.\n", bs->breakpoint_at->number);
1057 /* This is used when everything which needs to be printed has
1058 already been printed. But we still want to print the frame. */
1066 /* This is used when nothing should be printed for this bpstat entry. */
1075 /* Get a bpstat associated with having just stopped at address *PC
1076 and frame address FRAME_ADDRESS. Update *PC to point at the
1077 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1078 if this is known to not be a real breakpoint (it could still be a
1079 watchpoint, though). */
1081 /* Determine whether we stopped at a breakpoint, etc, or whether we
1082 don't understand this stop. Result is a chain of bpstat's such that:
1084 if we don't understand the stop, the result is a null pointer.
1086 if we understand why we stopped, the result is not null.
1088 Each element of the chain refers to a particular breakpoint or
1089 watchpoint at which we have stopped. (We may have stopped for
1090 several reasons concurrently.)
1092 Each element of the chain has valid next, breakpoint_at,
1093 commands, FIXME??? fields.
1098 bpstat_stop_status (pc, frame_address, not_a_breakpoint)
1100 FRAME_ADDR frame_address;
1101 int not_a_breakpoint;
1103 register struct breakpoint *b;
1105 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1106 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1107 int real_breakpoint = 0;
1109 /* Root of the chain of bpstat's */
1110 struct bpstat root_bs[1];
1111 /* Pointer to the last thing in the chain currently. */
1112 bpstat bs = root_bs;
1114 /* Get the address where the breakpoint would have been. */
1115 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1119 if (b->enable == disabled)
1122 if (b->type != bp_watchpoint && b->address != bp_addr)
1125 if (b->type != bp_watchpoint && not_a_breakpoint)
1128 /* Come here if it's a watchpoint, or if the break address matches */
1130 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1135 if (b->type == bp_watchpoint)
1137 static char message1[] =
1138 "Error evaluating expression for watchpoint %d\n";
1139 char message[sizeof (message1) + 30 /* slop */];
1140 sprintf (message, message1, b->number);
1141 switch (catch_errors (watchpoint_check, (char *) bs, message,
1145 /* We've already printed what needs to be printed. */
1146 bs->print_it = print_it_done;
1149 case WP_VALUE_CHANGED:
1152 case WP_VALUE_NOT_CHANGED:
1154 bs->print_it = print_it_noop;
1161 /* Error from catch_errors. */
1162 b->enable = disabled;
1163 printf_filtered ("Watchpoint %d disabled.\n", b->number);
1164 /* We've already printed what needs to be printed. */
1165 bs->print_it = print_it_done;
1170 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1172 real_breakpoint = 1;
1175 if (b->frame && b->frame != frame_address)
1179 int value_is_zero = 0;
1183 /* Need to select the frame, with all that implies
1184 so that the conditions will have the right context. */
1185 select_frame (get_current_frame (), 0);
1187 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1188 "Error in testing breakpoint condition:\n",
1190 /* FIXME-someday, should give breakpoint # */
1193 if (b->cond && value_is_zero)
1197 else if (b->ignore_count > 0)
1204 /* We will stop here */
1205 if (b->disposition == disable)
1206 b->enable = disabled;
1207 bs->commands = b->commands;
1210 if (bs->commands && STREQ ("silent", bs->commands->line))
1212 bs->commands = bs->commands->next;
1217 /* Print nothing for this entry if we dont stop or if we dont print. */
1218 if (bs->stop == 0 || bs->print == 0)
1219 bs->print_it = print_it_noop;
1222 bs->next = NULL; /* Terminate the chain */
1223 bs = root_bs->next; /* Re-grab the head of the chain */
1224 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1227 if (real_breakpoint)
1230 #if defined (SHIFT_INST_REGS)
1232 #else /* No SHIFT_INST_REGS. */
1234 #endif /* No SHIFT_INST_REGS. */
1237 #endif /* DECR_PC_AFTER_BREAK != 0. */
1241 /* Tell what to do about this bpstat. */
1246 /* Classify each bpstat as one of the following. */
1248 /* This bpstat element has no effect on the main_action. */
1251 /* There was a watchpoint, stop but don't print. */
1254 /* There was a watchpoint, stop and print. */
1257 /* There was a breakpoint but we're not stopping. */
1260 /* There was a breakpoint, stop but don't print. */
1263 /* There was a breakpoint, stop and print. */
1266 /* We hit the longjmp breakpoint. */
1269 /* We hit the longjmp_resume breakpoint. */
1272 /* This is just used to count how many enums there are. */
1276 /* Here is the table which drives this routine. So that we can
1277 format it pretty, we define some abbreviations for the
1278 enum bpstat_what codes. */
1279 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1280 #define stop_s BPSTAT_WHAT_STOP_SILENT
1281 #define stop_n BPSTAT_WHAT_STOP_NOISY
1282 #define single BPSTAT_WHAT_SINGLE
1283 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1284 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1285 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1286 /* "Can't happen." Might want to print an error message.
1287 abort() is not out of the question, but chances are GDB is just
1288 a bit confused, not unusable. */
1289 #define err BPSTAT_WHAT_STOP_NOISY
1291 /* Given an old action and a class, come up with a new action. */
1292 /* One interesting property of this table is that wp_silent is the same
1293 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1294 after stopping, the check for whether to step over a breakpoint
1295 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1296 reference to how we stopped. We retain separate wp_silent and bp_silent
1297 codes in case we want to change that someday. */
1298 static const enum bpstat_what_main_action
1299 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1302 /* keep_c stop_s stop_n single setlr clrlr clrlrs */
1304 /*no_effect*/ {keep_c, stop_s, stop_n, single, setlr , clrlr , clrlrs},
1305 /*wp_silent*/ {stop_s, stop_s, stop_n, stop_s, stop_s, stop_s, stop_s},
1306 /*wp_noisy*/ {stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, stop_n},
1307 /*bp_nostop*/ {single, stop_s, stop_n, single, setlr , clrlrs, clrlrs},
1308 /*bp_silent*/ {stop_s, stop_s, stop_n, stop_s, stop_s, stop_s, stop_s},
1309 /*bp_noisy*/ {stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, stop_n},
1310 /*long_jump*/ {setlr , stop_s, stop_n, setlr , err , err , err },
1311 /*long_resume*/ {clrlr , stop_s, stop_n, clrlrs, err , err , err }
1321 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1322 struct bpstat_what retval;
1324 retval.call_dummy = 0;
1325 retval.step_resume = 0;
1326 for (; bs != NULL; bs = bs->next)
1328 enum class bs_class = no_effect;
1329 if (bs->breakpoint_at == NULL)
1330 /* I suspect this can happen if it was a momentary breakpoint
1331 which has since been deleted. */
1333 switch (bs->breakpoint_at->type)
1341 bs_class = bp_noisy;
1343 bs_class = bp_silent;
1346 bs_class = bp_nostop;
1352 bs_class = wp_noisy;
1354 bs_class = wp_silent;
1357 /* There was a watchpoint, but we're not stopping. This requires
1358 no further action. */
1359 bs_class = no_effect;
1362 bs_class = long_jump;
1364 case bp_longjmp_resume:
1365 bs_class = long_resume;
1367 case bp_step_resume:
1369 /* Need to temporarily disable this until we can fix the bug
1370 with nexting over a breakpoint with ->stop clear causing
1371 an infinite loop. For now, treat the breakpoint as having
1372 been hit even if the frame is wrong. */
1376 retval.step_resume = 1;
1377 /* We don't handle this via the main_action. */
1378 bs_class = no_effect;
1382 /* It is for the wrong frame. */
1383 bs_class = bp_nostop;
1387 /* Make sure the action is stop (silent or noisy), so infrun.c
1388 pops the dummy frame. */
1389 bs_class = bp_silent;
1390 retval.call_dummy = 1;
1393 current_action = table[(int)bs_class][(int)current_action];
1395 retval.main_action = current_action;
1399 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1400 without hardware support). This isn't related to a specific bpstat,
1401 just to things like whether watchpoints are set. */
1404 bpstat_should_step ()
1406 struct breakpoint *b;
1408 if (b->enable == enabled && b->type == bp_watchpoint)
1413 /* Print information on breakpoint number BNUM, or -1 if all.
1414 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1415 is nonzero, process only watchpoints. */
1418 breakpoint_1 (bnum, allflag)
1422 register struct breakpoint *b;
1423 register struct command_line *l;
1424 register struct symbol *sym;
1425 CORE_ADDR last_addr = (CORE_ADDR)-1;
1426 int found_a_breakpoint = 0;
1427 static char *bptypes[] = {"breakpoint", "until", "finish", "watchpoint",
1428 "longjmp", "longjmp resume", "step resume",
1430 static char *bpdisps[] = {"del", "dis", "keep"};
1431 static char bpenables[] = "ny";
1432 char wrap_indent[80];
1436 || bnum == b->number)
1438 /* We only print out user settable breakpoints unless the allflag is set. */
1440 && b->type != bp_breakpoint
1441 && b->type != bp_watchpoint)
1444 if (!found_a_breakpoint++)
1445 printf_filtered ("Num Type Disp Enb %sWhat\n",
1446 addressprint ? "Address " : "");
1448 printf_filtered ("%-3d %-14s %-4s %-3c ",
1450 bptypes[(int)b->type],
1451 bpdisps[(int)b->disposition],
1452 bpenables[(int)b->enable]);
1453 strcpy (wrap_indent, " ");
1455 strcat (wrap_indent, " ");
1459 print_expression (b->exp, gdb_stdout);
1466 case bp_longjmp_resume:
1467 case bp_step_resume:
1470 printf_filtered ("%s ", local_hex_string_custom ((unsigned long) b->address, "08l"));
1472 last_addr = b->address;
1475 sym = find_pc_function (b->address);
1478 fputs_filtered ("in ", gdb_stdout);
1479 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1480 wrap_here (wrap_indent);
1481 fputs_filtered (" at ", gdb_stdout);
1483 fputs_filtered (b->source_file, gdb_stdout);
1484 printf_filtered (":%d", b->line_number);
1487 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1491 printf_filtered ("\n");
1494 printf_filtered ("\tstop only in stack frame at %s\n",
1495 local_hex_string((unsigned long) b->frame));
1498 printf_filtered ("\tstop only if ");
1499 print_expression (b->cond, gdb_stdout);
1500 printf_filtered ("\n");
1502 if (b->ignore_count)
1503 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1504 if ((l = b->commands))
1507 fputs_filtered ("\t", gdb_stdout);
1508 fputs_filtered (l->line, gdb_stdout);
1509 fputs_filtered ("\n", gdb_stdout);
1514 if (!found_a_breakpoint)
1517 printf_filtered ("No breakpoints or watchpoints.\n");
1519 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1522 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1523 that a comparison of an unsigned with -1 is always false. */
1524 if (last_addr != (CORE_ADDR)-1)
1525 set_next_address (last_addr);
1530 breakpoints_info (bnum_exp, from_tty)
1537 bnum = parse_and_eval_address (bnum_exp);
1539 breakpoint_1 (bnum, 0);
1542 #if MAINTENANCE_CMDS
1546 maintenance_info_breakpoints (bnum_exp, from_tty)
1553 bnum = parse_and_eval_address (bnum_exp);
1555 breakpoint_1 (bnum, 1);
1560 /* Print a message describing any breakpoints set at PC. */
1563 describe_other_breakpoints (pc)
1564 register CORE_ADDR pc;
1566 register int others = 0;
1567 register struct breakpoint *b;
1570 if (b->address == pc)
1574 printf_unfiltered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1576 if (b->address == pc)
1579 printf_unfiltered ("%d%s%s ",
1581 (b->enable == disabled) ? " (disabled)" : "",
1582 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1584 printf_unfiltered ("also set at pc %s.\n", local_hex_string((unsigned long) pc));
1588 /* Set the default place to put a breakpoint
1589 for the `break' command with no arguments. */
1592 set_default_breakpoint (valid, addr, symtab, line)
1595 struct symtab *symtab;
1598 default_breakpoint_valid = valid;
1599 default_breakpoint_address = addr;
1600 default_breakpoint_symtab = symtab;
1601 default_breakpoint_line = line;
1604 /* Rescan breakpoints at address ADDRESS,
1605 marking the first one as "first" and any others as "duplicates".
1606 This is so that the bpt instruction is only inserted once. */
1609 check_duplicates (address)
1612 register struct breakpoint *b;
1613 register int count = 0;
1615 if (address == 0) /* Watchpoints are uninteresting */
1619 if (b->enable != disabled && b->address == address)
1622 b->duplicate = count > 1;
1626 /* Low level routine to set a breakpoint.
1627 Takes as args the three things that every breakpoint must have.
1628 Returns the breakpoint object so caller can set other things.
1629 Does not set the breakpoint number!
1630 Does not print anything.
1632 ==> This routine should not be called if there is a chance of later
1633 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1634 your arguments BEFORE calling this routine! */
1636 static struct breakpoint *
1637 set_raw_breakpoint (sal)
1638 struct symtab_and_line sal;
1640 register struct breakpoint *b, *b1;
1642 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1643 memset (b, 0, sizeof (*b));
1644 b->address = sal.pc;
1645 if (sal.symtab == NULL)
1646 b->source_file = NULL;
1648 b->source_file = savestring (sal.symtab->filename,
1649 strlen (sal.symtab->filename));
1651 b->line_number = sal.line;
1652 b->enable = enabled;
1655 b->ignore_count = 0;
1659 /* Add this breakpoint to the end of the chain
1660 so that a list of breakpoints will come out in order
1661 of increasing numbers. */
1663 b1 = breakpoint_chain;
1665 breakpoint_chain = b;
1673 check_duplicates (sal.pc);
1679 create_longjmp_breakpoint(func_name)
1682 struct symtab_and_line sal;
1683 struct breakpoint *b;
1684 static int internal_breakpoint_number = -1;
1686 if (func_name != NULL)
1688 struct minimal_symbol *m;
1690 m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
1692 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1702 b = set_raw_breakpoint(sal);
1705 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1706 b->disposition = donttouch;
1707 b->enable = disabled;
1710 b->addr_string = strsave(func_name);
1711 b->number = internal_breakpoint_number--;
1714 /* Call this routine when stepping and nexting to enable a breakpoint if we do
1715 a longjmp(). When we hit that breakpoint, call
1716 set_longjmp_resume_breakpoint() to figure out where we are going. */
1719 enable_longjmp_breakpoint()
1721 register struct breakpoint *b;
1724 if (b->type == bp_longjmp)
1726 b->enable = enabled;
1727 check_duplicates (b->address);
1732 disable_longjmp_breakpoint()
1734 register struct breakpoint *b;
1737 if ( b->type == bp_longjmp
1738 || b->type == bp_longjmp_resume)
1740 b->enable = disabled;
1741 check_duplicates (b->address);
1745 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
1746 breakpoint at the target of the jmp_buf.
1748 FIXME - This ought to be done by setting a temporary breakpoint that gets
1749 deleted automatically...
1753 set_longjmp_resume_breakpoint(pc, frame)
1757 register struct breakpoint *b;
1760 if (b->type == bp_longjmp_resume)
1763 b->enable = enabled;
1765 b->frame = FRAME_FP(frame);
1768 check_duplicates (b->address);
1773 /* Set a breakpoint that will evaporate an end of command
1774 at address specified by SAL.
1775 Restrict it to frame FRAME if FRAME is nonzero. */
1778 set_momentary_breakpoint (sal, frame, type)
1779 struct symtab_and_line sal;
1783 register struct breakpoint *b;
1784 b = set_raw_breakpoint (sal);
1786 b->enable = enabled;
1787 b->disposition = donttouch;
1788 b->frame = (frame ? FRAME_FP (frame) : 0);
1794 clear_momentary_breakpoints ()
1796 register struct breakpoint *b;
1798 if (b->disposition == delete)
1800 delete_breakpoint (b);
1806 /* Tell the user we have just set a breakpoint B. */
1809 struct breakpoint *b;
1814 printf_filtered ("Watchpoint %d: ", b->number);
1815 print_expression (b->exp, gdb_stdout);
1818 printf_filtered ("Breakpoint %d at %s", b->number,
1819 local_hex_string((unsigned long) b->address));
1821 printf_filtered (": file %s, line %d.",
1822 b->source_file, b->line_number);
1827 case bp_longjmp_resume:
1828 case bp_step_resume:
1832 printf_filtered ("\n");
1836 /* Nobody calls this currently. */
1837 /* Set a breakpoint from a symtab and line.
1838 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1839 ADDR_STRING is a malloc'd string holding the name of where we are
1840 setting the breakpoint. This is used later to re-set it after the
1841 program is relinked and symbols are reloaded.
1842 Print the same confirmation messages that the breakpoint command prints. */
1845 set_breakpoint (s, line, tempflag, addr_string)
1851 register struct breakpoint *b;
1852 struct symtab_and_line sal;
1857 resolve_sal_pc (&sal); /* Might error out */
1858 describe_other_breakpoints (sal.pc);
1860 b = set_raw_breakpoint (sal);
1861 set_breakpoint_count (breakpoint_count + 1);
1862 b->number = breakpoint_count;
1863 b->type = bp_breakpoint;
1865 b->addr_string = addr_string;
1866 b->enable = enabled;
1867 b->disposition = tempflag ? delete : donttouch;
1873 /* Set a breakpoint according to ARG (function, linenum or *address)
1874 and make it temporary if TEMPFLAG is nonzero. */
1877 break_command_1 (arg, tempflag, from_tty)
1879 int tempflag, from_tty;
1881 struct symtabs_and_lines sals;
1882 struct symtab_and_line sal;
1883 register struct expression *cond = 0;
1884 register struct breakpoint *b;
1886 /* Pointers in arg to the start, and one past the end, of the condition. */
1887 char *cond_start = NULL;
1888 char *cond_end = NULL;
1889 /* Pointers in arg to the start, and one past the end,
1890 of the address part. */
1891 char *addr_start = NULL;
1892 char *addr_end = NULL;
1893 struct cleanup *old_chain;
1894 struct cleanup *canonical_strings_chain = NULL;
1895 char **canonical = (char **)NULL;
1902 sal.line = sal.pc = sal.end = 0;
1905 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1907 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1908 && (arg[2] == ' ' || arg[2] == '\t')))
1910 if (default_breakpoint_valid)
1912 sals.sals = (struct symtab_and_line *)
1913 xmalloc (sizeof (struct symtab_and_line));
1914 sal.pc = default_breakpoint_address;
1915 sal.line = default_breakpoint_line;
1916 sal.symtab = default_breakpoint_symtab;
1921 error ("No default breakpoint address now.");
1927 /* Force almost all breakpoints to be in terms of the
1928 current_source_symtab (which is decode_line_1's default). This
1929 should produce the results we want almost all of the time while
1930 leaving default_breakpoint_* alone. */
1931 if (default_breakpoint_valid
1932 && (!current_source_symtab
1933 || (arg && (*arg == '+' || *arg == '-'))))
1934 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1935 default_breakpoint_line, &canonical);
1937 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
1945 /* Make sure that all storage allocated in decode_line_1 gets freed in case
1946 the following `for' loop errors out. */
1947 old_chain = make_cleanup (free, sals.sals);
1948 if (canonical != (char **)NULL)
1950 make_cleanup (free, canonical);
1951 canonical_strings_chain = make_cleanup (null_cleanup, 0);
1952 for (i = 0; i < sals.nelts; i++)
1954 if (canonical[i] != NULL)
1955 make_cleanup (free, canonical[i]);
1959 thread = -1; /* No specific thread yet */
1961 /* Resolve all line numbers to PC's, and verify that conditions
1962 can be parsed, before setting any breakpoints. */
1963 for (i = 0; i < sals.nelts; i++)
1965 char *tok, *end_tok;
1968 resolve_sal_pc (&sals.sals[i]);
1974 while (*tok == ' ' || *tok == '\t')
1979 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
1982 toklen = end_tok - tok;
1984 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
1986 tok = cond_start = end_tok + 1;
1987 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
1990 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
1996 thread = strtol (tok, &tok, 0);
1998 error ("Junk after thread keyword.");
1999 if (!valid_thread_id (thread))
2000 error ("Unknown thread %d\n", thread);
2003 error ("Junk at end of arguments.");
2007 /* Remove the canonical strings from the cleanup, they are needed below. */
2008 if (canonical != (char **)NULL)
2009 discard_cleanups (canonical_strings_chain);
2011 /* Now set all the breakpoints. */
2012 for (i = 0; i < sals.nelts; i++)
2017 describe_other_breakpoints (sal.pc);
2019 b = set_raw_breakpoint (sal);
2020 set_breakpoint_count (breakpoint_count + 1);
2021 b->number = breakpoint_count;
2022 b->type = bp_breakpoint;
2026 /* If a canonical line spec is needed use that instead of the
2028 if (canonical != (char **)NULL && canonical[i] != NULL)
2029 b->addr_string = canonical[i];
2030 else if (addr_start)
2031 b->addr_string = savestring (addr_start, addr_end - addr_start);
2033 b->cond_string = savestring (cond_start, cond_end - cond_start);
2035 b->enable = enabled;
2036 b->disposition = tempflag ? delete : donttouch;
2043 printf_unfiltered ("Multiple breakpoints were set.\n");
2044 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2046 do_cleanups (old_chain);
2049 /* Helper function for break_command_1 and disassemble_command. */
2052 resolve_sal_pc (sal)
2053 struct symtab_and_line *sal;
2057 if (sal->pc == 0 && sal->symtab != 0)
2059 pc = find_line_pc (sal->symtab, sal->line);
2061 error ("No line %d in file \"%s\".",
2062 sal->line, sal->symtab->filename);
2068 break_command (arg, from_tty)
2072 break_command_1 (arg, 0, from_tty);
2076 tbreak_command (arg, from_tty)
2080 break_command_1 (arg, 1, from_tty);
2085 watch_command (arg, from_tty)
2089 struct breakpoint *b;
2090 struct symtab_and_line sal;
2091 struct expression *exp;
2092 struct block *exp_valid_block;
2099 /* Parse arguments. */
2100 innermost_block = NULL;
2101 exp = parse_expression (arg);
2102 exp_valid_block = innermost_block;
2103 val = evaluate_expression (exp);
2104 release_value (val);
2105 if (VALUE_LAZY (val))
2106 value_fetch_lazy (val);
2108 /* Now set up the breakpoint. */
2109 b = set_raw_breakpoint (sal);
2110 set_breakpoint_count (breakpoint_count + 1);
2111 b->number = breakpoint_count;
2112 b->type = bp_watchpoint;
2113 b->disposition = donttouch;
2115 b->exp_valid_block = exp_valid_block;
2118 b->cond_string = NULL;
2119 b->exp_string = savestring (arg, strlen (arg));
2124 * Helper routine for the until_command routine in infcmd.c. Here
2125 * because it uses the mechanisms of breakpoints.
2129 until_break_command (arg, from_tty)
2133 struct symtabs_and_lines sals;
2134 struct symtab_and_line sal;
2135 FRAME prev_frame = get_prev_frame (selected_frame);
2136 struct breakpoint *breakpoint;
2137 struct cleanup *old_chain;
2139 clear_proceed_status ();
2141 /* Set a breakpoint where the user wants it and at return from
2144 if (default_breakpoint_valid)
2145 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2146 default_breakpoint_line, (char ***)NULL);
2148 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2150 if (sals.nelts != 1)
2151 error ("Couldn't get information on specified line.");
2154 free ((PTR)sals.sals); /* malloc'd, so freed */
2157 error ("Junk at end of arguments.");
2159 resolve_sal_pc (&sal);
2161 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2163 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2165 /* Keep within the current frame */
2169 struct frame_info *fi;
2171 fi = get_frame_info (prev_frame);
2172 sal = find_pc_line (fi->pc, 0);
2174 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2175 make_cleanup(delete_breakpoint, breakpoint);
2178 proceed (-1, -1, 0);
2179 do_cleanups(old_chain);
2183 /* These aren't used; I don't konw what they were for. */
2184 /* Set a breakpoint at the catch clause for NAME. */
2186 catch_breakpoint (name)
2192 disable_catch_breakpoint ()
2197 delete_catch_breakpoint ()
2202 enable_catch_breakpoint ()
2209 struct sal_chain *next;
2210 struct symtab_and_line sal;
2214 /* This isn't used; I don't know what it was for. */
2215 /* For each catch clause identified in ARGS, run FUNCTION
2216 with that clause as an argument. */
2217 static struct symtabs_and_lines
2218 map_catch_names (args, function)
2222 register char *p = args;
2224 struct symtabs_and_lines sals;
2226 struct sal_chain *sal_chain = 0;
2230 error_no_arg ("one or more catch names");
2238 /* Don't swallow conditional part. */
2239 if (p1[0] == 'i' && p1[1] == 'f'
2240 && (p1[2] == ' ' || p1[2] == '\t'))
2246 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2250 if (*p1 && *p1 != ' ' && *p1 != '\t')
2251 error ("Arguments must be catch names.");
2257 struct sal_chain *next
2258 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2259 next->next = sal_chain;
2260 next->sal = get_catch_sal (p);
2265 printf_unfiltered ("No catch clause for exception %s.\n", p);
2270 while (*p == ' ' || *p == '\t') p++;
2275 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2277 static struct symtabs_and_lines
2278 get_catch_sals (this_level_only)
2279 int this_level_only;
2281 register struct blockvector *bl;
2282 register struct block *block;
2283 int index, have_default = 0;
2284 struct frame_info *fi;
2286 struct symtabs_and_lines sals;
2287 struct sal_chain *sal_chain = 0;
2288 char *blocks_searched;
2290 /* Not sure whether an error message is always the correct response,
2291 but it's better than a core dump. */
2292 if (selected_frame == NULL)
2293 error ("No selected frame.");
2294 block = get_frame_block (selected_frame);
2295 fi = get_frame_info (selected_frame);
2302 error ("No symbol table info available.\n");
2304 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2305 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2306 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2310 CORE_ADDR end = BLOCK_END (block) - 4;
2313 if (bl != blockvector_for_pc (end, &index))
2314 error ("blockvector blotch");
2315 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2316 error ("blockvector botch");
2317 last_index = BLOCKVECTOR_NBLOCKS (bl);
2320 /* Don't print out blocks that have gone by. */
2321 while (index < last_index
2322 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2325 while (index < last_index
2326 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2328 if (blocks_searched[index] == 0)
2330 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2333 register struct symbol *sym;
2335 nsyms = BLOCK_NSYMS (b);
2337 for (i = 0; i < nsyms; i++)
2339 sym = BLOCK_SYM (b, i);
2340 if (STREQ (SYMBOL_NAME (sym), "default"))
2346 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2348 struct sal_chain *next = (struct sal_chain *)
2349 alloca (sizeof (struct sal_chain));
2350 next->next = sal_chain;
2351 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2355 blocks_searched[index] = 1;
2361 if (sal_chain && this_level_only)
2364 /* After handling the function's top-level block, stop.
2365 Don't continue to its superblock, the block of
2366 per-file symbols. */
2367 if (BLOCK_FUNCTION (block))
2369 block = BLOCK_SUPERBLOCK (block);
2374 struct sal_chain *tmp_chain;
2376 /* Count the number of entries. */
2377 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2378 tmp_chain = tmp_chain->next)
2382 sals.sals = (struct symtab_and_line *)
2383 xmalloc (index * sizeof (struct symtab_and_line));
2384 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2385 sals.sals[index] = sal_chain->sal;
2391 /* Commands to deal with catching exceptions. */
2394 catch_command_1 (arg, tempflag, from_tty)
2399 /* First, translate ARG into something we can deal with in terms
2402 struct symtabs_and_lines sals;
2403 struct symtab_and_line sal;
2404 register struct expression *cond = 0;
2405 register struct breakpoint *b;
2409 sal.line = sal.pc = sal.end = 0;
2412 /* If no arg given, or if first arg is 'if ', all active catch clauses
2413 are breakpointed. */
2415 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2416 && (arg[2] == ' ' || arg[2] == '\t')))
2418 /* Grab all active catch clauses. */
2419 sals = get_catch_sals (0);
2423 /* Grab selected catch clauses. */
2424 error ("catch NAME not implemented");
2426 /* This isn't used; I don't know what it was for. */
2427 sals = map_catch_names (arg, catch_breakpoint);
2435 for (i = 0; i < sals.nelts; i++)
2437 resolve_sal_pc (&sals.sals[i]);
2441 if (arg[0] == 'i' && arg[1] == 'f'
2442 && (arg[2] == ' ' || arg[2] == '\t'))
2443 cond = parse_exp_1 ((arg += 2, &arg),
2444 block_for_pc (sals.sals[i].pc), 0);
2446 error ("Junk at end of arguments.");
2451 for (i = 0; i < sals.nelts; i++)
2456 describe_other_breakpoints (sal.pc);
2458 b = set_raw_breakpoint (sal);
2459 set_breakpoint_count (breakpoint_count + 1);
2460 b->number = breakpoint_count;
2461 b->type = bp_breakpoint;
2463 b->enable = enabled;
2464 b->disposition = tempflag ? delete : donttouch;
2471 printf_unfiltered ("Multiple breakpoints were set.\n");
2472 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2474 free ((PTR)sals.sals);
2478 /* These aren't used; I don't know what they were for. */
2479 /* Disable breakpoints on all catch clauses described in ARGS. */
2481 disable_catch (args)
2484 /* Map the disable command to catch clauses described in ARGS. */
2487 /* Enable breakpoints on all catch clauses described in ARGS. */
2492 /* Map the disable command to catch clauses described in ARGS. */
2495 /* Delete breakpoints on all catch clauses in the active scope. */
2500 /* Map the delete command to catch clauses described in ARGS. */
2505 catch_command (arg, from_tty)
2509 catch_command_1 (arg, 0, from_tty);
2513 clear_command (arg, from_tty)
2517 register struct breakpoint *b, *b1;
2518 struct symtabs_and_lines sals;
2519 struct symtab_and_line sal;
2520 register struct breakpoint *found;
2525 sals = decode_line_spec (arg, 1);
2529 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
2530 sal.line = default_breakpoint_line;
2531 sal.symtab = default_breakpoint_symtab;
2533 if (sal.symtab == 0)
2534 error ("No source file specified.");
2540 for (i = 0; i < sals.nelts; i++)
2542 /* If exact pc given, clear bpts at that pc.
2543 But if sal.pc is zero, clear all bpts on specified line. */
2545 found = (struct breakpoint *) 0;
2546 while (breakpoint_chain
2548 ? breakpoint_chain->address == sal.pc
2549 : (breakpoint_chain->source_file != NULL
2550 && sal.symtab != NULL
2551 && STREQ (breakpoint_chain->source_file,
2552 sal.symtab->filename)
2553 && breakpoint_chain->line_number == sal.line)))
2555 b1 = breakpoint_chain;
2556 breakpoint_chain = b1->next;
2563 && b->next->type != bp_watchpoint
2565 ? b->next->address == sal.pc
2566 : (b->next->source_file != NULL
2567 && sal.symtab != NULL
2568 && STREQ (b->next->source_file, sal.symtab->filename)
2569 && b->next->line_number == sal.line)))
2580 error ("No breakpoint at %s.", arg);
2582 error ("No breakpoint at this line.");
2585 if (found->next) from_tty = 1; /* Always report if deleted more than one */
2586 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
2589 if (from_tty) printf_unfiltered ("%d ", found->number);
2591 delete_breakpoint (found);
2594 if (from_tty) putchar_unfiltered ('\n');
2596 free ((PTR)sals.sals);
2599 /* Delete breakpoint in BS if they are `delete' breakpoints.
2600 This is called after any breakpoint is hit, or after errors. */
2603 breakpoint_auto_delete (bs)
2606 for (; bs; bs = bs->next)
2607 if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
2609 delete_breakpoint (bs->breakpoint_at);
2612 /* Delete a breakpoint and clean up all traces of it in the data structures. */
2615 delete_breakpoint (bpt)
2616 struct breakpoint *bpt;
2618 register struct breakpoint *b;
2622 target_remove_breakpoint(bpt->address, bpt->shadow_contents);
2624 if (breakpoint_chain == bpt)
2625 breakpoint_chain = bpt->next;
2630 b->next = bpt->next;
2634 check_duplicates (bpt->address);
2635 /* If this breakpoint was inserted, and there is another breakpoint
2636 at the same address, we need to insert the other breakpoint. */
2640 if (b->address == bpt->address
2642 && b->enable != disabled)
2645 val = target_insert_breakpoint (b->address, b->shadow_contents);
2648 target_terminal_ours_for_output ();
2649 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
2650 memory_error (val, b->address); /* which bombs us out */
2657 free_command_lines (&bpt->commands);
2660 if (bpt->cond_string != NULL)
2661 free (bpt->cond_string);
2662 if (bpt->addr_string != NULL)
2663 free (bpt->addr_string);
2664 if (bpt->exp_string != NULL)
2665 free (bpt->exp_string);
2666 if (bpt->source_file != NULL)
2667 free (bpt->source_file);
2669 if (xgdb_verbose && bpt->type == bp_breakpoint)
2671 target_terminal_ours_for_output ();
2672 printf_unfiltered ("breakpoint #%d deleted\n", bpt->number);
2675 /* Be sure no bpstat's are pointing at it after it's been freed. */
2676 /* FIXME, how can we find all bpstat's?
2677 We just check stop_bpstat for now. */
2678 for (bs = stop_bpstat; bs; bs = bs->next)
2679 if (bs->breakpoint_at == bpt)
2680 bs->breakpoint_at = NULL;
2685 delete_command (arg, from_tty)
2692 /* Ask user only if there are some breakpoints to delete. */
2694 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
2696 /* No arg; clear all breakpoints. */
2697 while (breakpoint_chain)
2698 delete_breakpoint (breakpoint_chain);
2702 map_breakpoint_numbers (arg, delete_breakpoint);
2705 /* Reset a breakpoint given it's struct breakpoint * BINT.
2706 The value we return ends up being the return value from catch_errors.
2707 Unused in this case. */
2710 breakpoint_re_set_one (bint)
2713 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
2715 struct symtabs_and_lines sals;
2717 enum enable save_enable;
2722 if (b->addr_string == NULL)
2724 /* Anything without a string can't be re-set. */
2725 delete_breakpoint (b);
2728 /* In case we have a problem, disable this breakpoint. We'll restore
2729 its status if we succeed. */
2730 save_enable = b->enable;
2731 b->enable = disabled;
2734 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2735 for (i = 0; i < sals.nelts; i++)
2737 resolve_sal_pc (&sals.sals[i]);
2739 /* Reparse conditions, they might contain references to the
2741 if (b->cond_string != NULL)
2745 free ((PTR)b->cond);
2746 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
2749 /* We need to re-set the breakpoint if the address changes...*/
2750 if (b->address != sals.sals[i].pc
2751 /* ...or new and old breakpoints both have source files, and
2752 the source file name or the line number changes... */
2753 || (b->source_file != NULL
2754 && sals.sals[i].symtab != NULL
2755 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
2756 || b->line_number != sals.sals[i].line)
2758 /* ...or we switch between having a source file and not having
2760 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
2763 if (b->source_file != NULL)
2764 free (b->source_file);
2765 if (sals.sals[i].symtab == NULL)
2766 b->source_file = NULL;
2769 savestring (sals.sals[i].symtab->filename,
2770 strlen (sals.sals[i].symtab->filename));
2771 b->line_number = sals.sals[i].line;
2772 b->address = sals.sals[i].pc;
2774 check_duplicates (b->address);
2778 b->enable = save_enable; /* Restore it, this worked. */
2780 free ((PTR)sals.sals);
2784 innermost_block = NULL;
2785 /* The issue arises of what context to evaluate this in. The same
2786 one as when it was set, but what does that mean when symbols have
2787 been re-read? We could save the filename and functionname, but
2788 if the context is more local than that, the best we could do would
2789 be something like how many levels deep and which index at that
2790 particular level, but that's going to be less stable than filenames
2791 or functionnames. */
2792 /* So for now, just use a global context. */
2793 b->exp = parse_expression (b->exp_string);
2794 b->exp_valid_block = innermost_block;
2795 b->val = evaluate_expression (b->exp);
2796 release_value (b->val);
2797 if (VALUE_LAZY (b->val))
2798 value_fetch_lazy (b->val);
2800 if (b->cond_string != NULL)
2803 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
2805 if (b->enable == enabled)
2810 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
2815 case bp_longjmp_resume:
2817 delete_breakpoint (b);
2824 /* Re-set all breakpoints after symbols have been re-loaded. */
2826 breakpoint_re_set ()
2828 struct breakpoint *b, *temp;
2829 static char message1[] = "Error in re-setting breakpoint %d:\n";
2830 char message[sizeof (message1) + 30 /* slop */];
2832 ALL_BREAKPOINTS_SAFE (b, temp)
2834 sprintf (message, message1, b->number); /* Format possible error msg */
2835 catch_errors (breakpoint_re_set_one, (char *) b, message,
2839 create_longjmp_breakpoint("longjmp");
2840 create_longjmp_breakpoint("_longjmp");
2841 create_longjmp_breakpoint("siglongjmp");
2842 create_longjmp_breakpoint(NULL);
2845 /* Took this out (temporaliy at least), since it produces an extra
2846 blank line at startup. This messes up the gdbtests. -PB */
2847 /* Blank line to finish off all those mention() messages we just printed. */
2848 printf_filtered ("\n");
2852 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
2853 If from_tty is nonzero, it prints a message to that effect,
2854 which ends with a period (no newline). */
2857 set_ignore_count (bptnum, count, from_tty)
2858 int bptnum, count, from_tty;
2860 register struct breakpoint *b;
2866 if (b->number == bptnum)
2868 b->ignore_count = count;
2871 else if (count == 0)
2872 printf_filtered ("Will stop next time breakpoint %d is reached.",
2874 else if (count == 1)
2875 printf_filtered ("Will ignore next crossing of breakpoint %d.",
2878 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
2883 error ("No breakpoint number %d.", bptnum);
2886 /* Clear the ignore counts of all breakpoints. */
2888 breakpoint_clear_ignore_counts ()
2890 struct breakpoint *b;
2893 b->ignore_count = 0;
2896 /* Command to set ignore-count of breakpoint N to COUNT. */
2899 ignore_command (args, from_tty)
2907 error_no_arg ("a breakpoint number");
2909 num = get_number (&p);
2912 error ("Second argument (specified ignore-count) is missing.");
2914 set_ignore_count (num,
2915 longest_to_int (value_as_long (parse_and_eval (p))),
2917 printf_filtered ("\n");
2920 /* Call FUNCTION on each of the breakpoints
2921 whose numbers are given in ARGS. */
2924 map_breakpoint_numbers (args, function)
2926 void (*function) PARAMS ((struct breakpoint *));
2928 register char *p = args;
2931 register struct breakpoint *b;
2934 error_no_arg ("one or more breakpoint numbers");
2940 num = get_number (&p1);
2943 if (b->number == num)
2948 printf_unfiltered ("No breakpoint number %d.\n", num);
2955 enable_breakpoint (bpt)
2956 struct breakpoint *bpt;
2958 FRAME save_selected_frame = NULL;
2959 int save_selected_frame_level = -1;
2961 bpt->enable = enabled;
2963 if (xgdb_verbose && bpt->type == bp_breakpoint)
2964 printf_unfiltered ("breakpoint #%d enabled\n", bpt->number);
2966 check_duplicates (bpt->address);
2967 if (bpt->type == bp_watchpoint)
2969 if (bpt->exp_valid_block != NULL)
2971 FRAME fr = within_scope (bpt->exp_valid_block);
2975 Cannot enable watchpoint %d because the block in which its expression\n\
2976 is valid is not currently in scope.\n", bpt->number);
2977 bpt->enable = disabled;
2980 save_selected_frame = selected_frame;
2981 save_selected_frame_level = selected_frame_level;
2982 select_frame (fr, -1);
2985 value_free (bpt->val);
2987 bpt->val = evaluate_expression (bpt->exp);
2988 release_value (bpt->val);
2989 if (VALUE_LAZY (bpt->val))
2990 value_fetch_lazy (bpt->val);
2992 if (save_selected_frame_level >= 0)
2993 select_frame (save_selected_frame, save_selected_frame_level);
2999 enable_command (args, from_tty)
3003 struct breakpoint *bpt;
3005 ALL_BREAKPOINTS (bpt)
3010 enable_breakpoint (bpt);
3015 map_breakpoint_numbers (args, enable_breakpoint);
3019 disable_breakpoint (bpt)
3020 struct breakpoint *bpt;
3022 bpt->enable = disabled;
3024 if (xgdb_verbose && bpt->type == bp_breakpoint)
3025 printf_filtered ("breakpoint #%d disabled\n", bpt->number);
3027 check_duplicates (bpt->address);
3032 disable_command (args, from_tty)
3036 register struct breakpoint *bpt;
3038 ALL_BREAKPOINTS (bpt)
3043 disable_breakpoint (bpt);
3048 map_breakpoint_numbers (args, disable_breakpoint);
3052 enable_once_breakpoint (bpt)
3053 struct breakpoint *bpt;
3055 bpt->enable = enabled;
3056 bpt->disposition = disable;
3058 check_duplicates (bpt->address);
3063 enable_once_command (args, from_tty)
3067 map_breakpoint_numbers (args, enable_once_breakpoint);
3071 enable_delete_breakpoint (bpt)
3072 struct breakpoint *bpt;
3074 bpt->enable = enabled;
3075 bpt->disposition = delete;
3077 check_duplicates (bpt->address);
3082 enable_delete_command (args, from_tty)
3086 map_breakpoint_numbers (args, enable_delete_breakpoint);
3090 * Use default_breakpoint_'s, or nothing if they aren't valid.
3092 struct symtabs_and_lines
3093 decode_line_spec_1 (string, funfirstline)
3097 struct symtabs_and_lines sals;
3099 error ("Empty line specification.");
3100 if (default_breakpoint_valid)
3101 sals = decode_line_1 (&string, funfirstline,
3102 default_breakpoint_symtab, default_breakpoint_line,
3105 sals = decode_line_1 (&string, funfirstline,
3106 (struct symtab *)NULL, 0, (char ***)NULL);
3108 error ("Junk at end of line specification: %s", string);
3113 _initialize_breakpoint ()
3115 breakpoint_chain = 0;
3116 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3117 before a breakpoint is set. */
3118 breakpoint_count = 0;
3120 add_com ("ignore", class_breakpoint, ignore_command,
3121 "Set ignore-count of breakpoint number N to COUNT.");
3123 add_com ("commands", class_breakpoint, commands_command,
3124 "Set commands to be executed when a breakpoint is hit.\n\
3125 Give breakpoint number as argument after \"commands\".\n\
3126 With no argument, the targeted breakpoint is the last one set.\n\
3127 The commands themselves follow starting on the next line.\n\
3128 Type a line containing \"end\" to indicate the end of them.\n\
3129 Give \"silent\" as the first line to make the breakpoint silent;\n\
3130 then no output is printed when it is hit, except what the commands print.");
3132 add_com ("condition", class_breakpoint, condition_command,
3133 "Specify breakpoint number N to break only if COND is true.\n\
3134 N is an integer; COND is an expression to be evaluated whenever\n\
3135 breakpoint N is reached. ");
3137 add_com ("tbreak", class_breakpoint, tbreak_command,
3138 "Set a temporary breakpoint. Args like \"break\" command.\n\
3139 Like \"break\" except the breakpoint is only enabled temporarily,\n\
3140 so it will be disabled when hit. Equivalent to \"break\" followed\n\
3141 by using \"enable once\" on the breakpoint number.");
3143 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3144 "Enable some breakpoints.\n\
3145 Give breakpoint numbers (separated by spaces) as arguments.\n\
3146 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3147 This is used to cancel the effect of the \"disable\" command.\n\
3148 With a subcommand you can enable temporarily.",
3149 &enablelist, "enable ", 1, &cmdlist);
3151 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3152 "Enable some breakpoints.\n\
3153 Give breakpoint numbers (separated by spaces) as arguments.\n\
3154 This is used to cancel the effect of the \"disable\" command.\n\
3155 May be abbreviated to simply \"enable\".\n",
3156 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3158 add_cmd ("once", no_class, enable_once_command,
3159 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3160 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
3161 See the \"tbreak\" command which sets a breakpoint and enables it once.",
3164 add_cmd ("delete", no_class, enable_delete_command,
3165 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3166 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3169 add_cmd ("delete", no_class, enable_delete_command,
3170 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3171 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3174 add_cmd ("once", no_class, enable_once_command,
3175 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3176 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
3177 See the \"tbreak\" command which sets a breakpoint and enables it once.",
3180 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3181 "Disable some breakpoints.\n\
3182 Arguments are breakpoint numbers with spaces in between.\n\
3183 To disable all breakpoints, give no argument.\n\
3184 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3185 &disablelist, "disable ", 1, &cmdlist);
3186 add_com_alias ("dis", "disable", class_breakpoint, 1);
3187 add_com_alias ("disa", "disable", class_breakpoint, 1);
3189 add_cmd ("breakpoints", class_alias, disable_command,
3190 "Disable some breakpoints.\n\
3191 Arguments are breakpoint numbers with spaces in between.\n\
3192 To disable all breakpoints, give no argument.\n\
3193 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3194 This command may be abbreviated \"disable\".",
3197 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3198 "Delete some breakpoints or auto-display expressions.\n\
3199 Arguments are breakpoint numbers with spaces in between.\n\
3200 To delete all breakpoints, give no argument.\n\
3202 Also a prefix command for deletion of other GDB objects.\n\
3203 The \"unset\" command is also an alias for \"delete\".",
3204 &deletelist, "delete ", 1, &cmdlist);
3205 add_com_alias ("d", "delete", class_breakpoint, 1);
3207 add_cmd ("breakpoints", class_alias, delete_command,
3208 "Delete some breakpoints or auto-display expressions.\n\
3209 Arguments are breakpoint numbers with spaces in between.\n\
3210 To delete all breakpoints, give no argument.\n\
3211 This command may be abbreviated \"delete\".",
3214 add_com ("clear", class_breakpoint, clear_command,
3215 "Clear breakpoint at specified line or function.\n\
3216 Argument may be line number, function name, or \"*\" and an address.\n\
3217 If line number is specified, all breakpoints in that line are cleared.\n\
3218 If function is specified, breakpoints at beginning of function are cleared.\n\
3219 If an address is specified, breakpoints at that address are cleared.\n\n\
3220 With no argument, clears all breakpoints in the line that the selected frame\n\
3223 See also the \"delete\" command which clears breakpoints by number.");
3225 add_com ("break", class_breakpoint, break_command,
3226 "Set breakpoint at specified line or function.\n\
3227 Argument may be line number, function name, or \"*\" and an address.\n\
3228 If line number is specified, break at start of code for that line.\n\
3229 If function is specified, break at start of code for that function.\n\
3230 If an address is specified, break at that exact address.\n\
3231 With no arg, uses current execution address of selected stack frame.\n\
3232 This is useful for breaking on return to a stack frame.\n\
3234 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3236 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3237 add_com_alias ("b", "break", class_run, 1);
3238 add_com_alias ("br", "break", class_run, 1);
3239 add_com_alias ("bre", "break", class_run, 1);
3240 add_com_alias ("brea", "break", class_run, 1);
3242 add_info ("breakpoints", breakpoints_info,
3243 "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3244 The \"Type\" column indicates one of:\n\
3245 \tbreakpoint - normal breakpoint\n\
3246 \twatchpoint - watchpoint\n\
3247 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3248 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3249 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3250 address and file/line number respectively.\n\n\
3251 Convenience variable \"$_\" and default examine address for \"x\"\n\
3252 are set to the address of the last breakpoint listed.\n\n\
3253 Convenience variable \"$bpnum\" contains the number of the last\n\
3256 #if MAINTENANCE_CMDS
3258 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3259 "Status of all breakpoints, or breakpoint number NUMBER.\n\
3260 The \"Type\" column indicates one of:\n\
3261 \tbreakpoint - normal breakpoint\n\
3262 \twatchpoint - watchpoint\n\
3263 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3264 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3265 \tuntil - internal breakpoint used by the \"until\" command\n\
3266 \tfinish - internal breakpoint used by the \"finish\" command\n\
3267 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3268 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3269 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3270 address and file/line number respectively.\n\n\
3271 Convenience variable \"$_\" and default examine address for \"x\"\n\
3272 are set to the address of the last breakpoint listed.\n\n\
3273 Convenience variable \"$bpnum\" contains the number of the last\n\
3275 &maintenanceinfolist);
3277 #endif /* MAINTENANCE_CMDS */
3279 add_com ("catch", class_breakpoint, catch_command,
3280 "Set breakpoints to catch exceptions that are raised.\n\
3281 Argument may be a single exception to catch, multiple exceptions\n\
3282 to catch, or the default exception \"default\". If no arguments\n\
3283 are given, breakpoints are set at all exception handlers catch clauses\n\
3284 within the current scope.\n\
3286 A condition specified for the catch applies to all breakpoints set\n\
3287 with this command\n\
3289 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3291 add_com ("watch", class_breakpoint, watch_command,
3292 "Set a watchpoint for an expression.\n\
3293 A watchpoint stops execution of your program whenever the value of\n\
3294 an expression changes.");
3296 add_info ("watchpoints", breakpoints_info,
3297 "Synonym for ``info breakpoints''.");
3300 /* OK, when we call objfile_relocate, we need to relocate breakpoints
3301 too. breakpoint_re_set is not a good choice--for example, if
3302 addr_string contains just a line number without a file name the
3303 breakpoint might get set in a different file. In general, there is
3304 no need to go all the way back to the user's string (though this might
3305 work if some effort were made to canonicalize it), since symtabs and
3306 everything except addresses are still valid.
3308 Probably the best way to solve this is to have each breakpoint save
3309 the objfile and the section number that was used to set it (if set
3310 by "*addr", probably it is best to use find_pc_line to get a symtab
3311 and use the objfile and block_line_section for that symtab). Then
3312 objfile_relocate can call fixup_breakpoints with the objfile and
3313 the new_offsets, and it can relocate only the appropriate breakpoints. */
3315 #ifdef IBM6000_TARGET
3316 /* But for now, just kludge it based on the concept that before an
3317 objfile is relocated the breakpoint is below 0x10000000, and afterwards
3318 it is higher, so that way we only relocate each breakpoint once. */
3321 fixup_breakpoints (low, high, delta)
3326 struct breakpoint *b;
3330 if (b->address >= low && b->address <= high)
3331 b->address += delta;