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;
573 static unsigned LONGEST dummy[] = CALL_DUMMY;
575 if (b->type == bp_call_dummy
576 && b->frame == frame->frame
578 /* We need to check the PC as well as the frame on the sparc,
579 for signals.exp in the testsuite. */
582 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
583 && frame->pc <= b->address)
586 #endif /* CALL_DUMMY */
590 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
591 is valid for process/thread PID. */
594 breakpoint_thread_match (pc, pid)
598 struct breakpoint *b;
601 thread = pid_to_thread_id (pid);
604 if (b->enable != disabled
606 && (b->thread == -1 || b->thread == thread))
613 /* bpstat stuff. External routines' interfaces are documented
616 /* Clear a bpstat so that it says we are not at any breakpoint.
617 Also free any storage that is part of a bpstat. */
632 if (p->old_val != NULL)
633 value_free (p->old_val);
640 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
641 is part of the bpstat is copied as well. */
649 bpstat retval = NULL;
654 for (; bs != NULL; bs = bs->next)
656 tmp = (bpstat) xmalloc (sizeof (*tmp));
657 memcpy (tmp, bs, sizeof (*tmp));
659 /* This is the first thing in the chain. */
669 /* Find the bpstat associated with this breakpoint */
672 bpstat_find_breakpoint(bsp, breakpoint)
674 struct breakpoint *breakpoint;
676 if (bsp == NULL) return NULL;
678 for (;bsp != NULL; bsp = bsp->next) {
679 if (bsp->breakpoint_at == breakpoint) return bsp;
684 /* Return the breakpoint number of the first breakpoint we are stopped
685 at. *BSP upon return is a bpstat which points to the remaining
686 breakpoints stopped at (but which is not guaranteed to be good for
687 anything but further calls to bpstat_num).
688 Return 0 if passed a bpstat which does not indicate any breakpoints. */
694 struct breakpoint *b;
697 return 0; /* No more breakpoint values */
700 b = (*bsp)->breakpoint_at;
703 return -1; /* breakpoint that's been deleted since */
705 return b->number; /* We have its number */
709 /* Modify BS so that the actions will not be performed. */
712 bpstat_clear_actions (bs)
715 for (; bs != NULL; bs = bs->next)
718 if (bs->old_val != NULL)
720 value_free (bs->old_val);
726 /* Stub for cleaning up our state if we error-out of a breakpoint command */
729 cleanup_executing_breakpoints (ignore)
732 executing_breakpoint_commands = 0;
735 /* Execute all the commands associated with all the breakpoints at this
736 location. Any of these commands could cause the process to proceed
737 beyond this point, etc. We look out for such changes by checking
738 the global "breakpoint_proceeded" after each command. */
741 bpstat_do_actions (bsp)
745 struct cleanup *old_chain;
747 executing_breakpoint_commands = 1;
748 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
753 breakpoint_proceeded = 0;
754 for (; bs != NULL; bs = bs->next)
758 char *line = bs->commands->line;
759 bs->commands = bs->commands->next;
760 execute_command (line, 0);
761 /* If the inferior is proceeded by the command, bomb out now.
762 The bpstat chain has been blown away by wait_for_inferior.
763 But since execution has stopped again, there is a new bpstat
764 to look at, so start over. */
765 if (breakpoint_proceeded)
770 executing_breakpoint_commands = 0;
771 discard_cleanups (old_chain);
774 /* This is the normal print_it function for a bpstat. In the future,
775 much of this logic could (should?) be moved to bpstat_stop_status,
776 by having it set different print_it functions. */
782 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
783 which has since been deleted. */
784 if (bs->breakpoint_at == NULL
785 || (bs->breakpoint_at->type != bp_breakpoint
786 && bs->breakpoint_at->type != bp_watchpoint))
789 if (bs->breakpoint_at->type == bp_breakpoint)
791 /* I think the user probably only wants to see one breakpoint
792 number, not all of them. */
793 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
797 if (bs->old_val != NULL)
799 printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number);
800 print_expression (bs->breakpoint_at->exp, gdb_stdout);
801 printf_filtered ("\nOld value = ");
802 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
803 printf_filtered ("\nNew value = ");
804 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
806 printf_filtered ("\n");
807 value_free (bs->old_val);
811 /* We can't deal with it. Maybe another member of the bpstat chain can. */
815 /* Print a message indicating what happened. Returns nonzero to
816 say that only the source line should be printed after this (zero
817 return means print the frame as well as the source line). */
818 /* Currently we always return zero. */
828 val = (*bs->print_it) (bs);
832 /* Maybe another breakpoint in the chain caused us to stop.
833 (Currently all watchpoints go on the bpstat whether hit or
834 not. That probably could (should) be changed, provided care is taken
835 with respect to bpstat_explains_signal). */
837 return bpstat_print (bs->next);
839 /* We reached the end of the chain without printing anything. */
843 /* Evaluate the expression EXP and return 1 if value is zero.
844 This is used inside a catch_errors to evaluate the breakpoint condition.
845 The argument is a "struct expression *" that has been cast to char * to
846 make it pass through catch_errors. */
849 breakpoint_cond_eval (exp)
852 return !value_true (evaluate_expression ((struct expression *)exp));
855 /* Allocate a new bpstat and chain it to the current one. */
858 bpstat_alloc (b, cbs)
859 register struct breakpoint *b;
860 bpstat cbs; /* Current "bs" value */
864 bs = (bpstat) xmalloc (sizeof (*bs));
866 bs->breakpoint_at = b;
867 /* If the condition is false, etc., don't do the commands. */
870 bs->print_it = print_it_normal;
874 /* Return the frame which we can use to evaluate the expression
875 whose valid block is valid_block, or NULL if not in scope.
877 This whole concept is probably not the way to do things (it is incredibly
878 slow being the main reason, not to mention fragile (e.g. the sparc
879 frame pointer being fetched as 0 bug causes it to stop)). Instead,
880 introduce a version of "struct frame" which survives over calls to the
881 inferior, but which is better than FRAME_ADDR in the sense that it lets
882 us evaluate expressions relative to that frame (on some machines, it
883 can just be a FRAME_ADDR). Save one of those instead of (or in addition
884 to) the exp_valid_block, and then use it to evaluate the watchpoint
885 expression, with no need to do all this backtracing every time.
887 Or better yet, what if it just copied the struct frame and its next
888 frame? Off the top of my head, I would think that would work
889 because things like (a29k) rsize and msize, or (sparc) bottom just
890 depend on the frame, and aren't going to be different just because
891 the inferior has done something. Trying to recalculate them
892 strikes me as a lot of work, possibly even impossible. Saving the
893 next frame is needed at least on a29k, where get_saved_register
894 uses fi->next->saved_msp. For figuring out whether that frame is
895 still on the stack, I guess this needs to be machine-specific (e.g.
898 read_fp () INNER_THAN watchpoint_frame->frame
900 would generally work.
902 Of course the scope of the expression could be less than a whole
903 function; perhaps if the innermost frame is the one which the
904 watchpoint is relative to (another machine-specific thing, usually
906 FRAMELESS_FUNCTION_INVOCATION (get_current_frame(), fromleaf)
907 read_fp () == wp_frame->frame
910 ), *then* it could do a
912 contained_in (get_current_block (), wp->exp_valid_block).
917 within_scope (valid_block)
918 struct block *valid_block;
920 FRAME fr = get_current_frame ();
921 struct frame_info *fi = get_frame_info (fr);
922 CORE_ADDR func_start;
924 /* If caller_pc_valid is true, we are stepping through
925 a function prologue, which is bounded by callee_func_start
926 (inclusive) and callee_prologue_end (exclusive).
927 caller_pc is the pc of the caller.
929 Yes, this is hairy. */
930 static int caller_pc_valid = 0;
931 static CORE_ADDR caller_pc;
932 static CORE_ADDR callee_func_start;
933 static CORE_ADDR callee_prologue_end;
935 find_pc_partial_function (fi->pc, (PTR)NULL, &func_start, (CORE_ADDR *)NULL);
936 func_start += FUNCTION_START_OFFSET;
937 if (fi->pc == func_start)
939 /* We just called a function. The only other case I
940 can think of where the pc would equal the pc of the
941 start of a function is a frameless function (i.e.
942 no prologue) where we branch back to the start
943 of the function. In that case, SKIP_PROLOGUE won't
944 find one, and we'll clear caller_pc_valid a few lines
947 caller_pc = SAVED_PC_AFTER_CALL (fr);
948 callee_func_start = func_start;
949 SKIP_PROLOGUE (func_start);
950 callee_prologue_end = func_start;
954 if (fi->pc < callee_func_start
955 || fi->pc >= callee_prologue_end)
959 if (contained_in (block_for_pc (caller_pc_valid
966 fr = get_prev_frame (fr);
968 /* If any active frame is in the exp_valid_block, then it's
969 OK. Note that this might not be the same invocation of
970 the exp_valid_block that we were watching a little while
971 ago, or the same one as when the watchpoint was set (e.g.
972 we are watching a local variable in a recursive function.
973 When we return from a recursive invocation, then we are
974 suddenly watching a different instance of the variable).
976 At least for now I am going to consider this a feature. */
977 for (; fr != NULL; fr = get_prev_frame (fr))
979 fi = get_frame_info (fr);
980 if (contained_in (block_for_pc (fi->pc),
989 /* Possible return values for watchpoint_check (this can't be an enum
990 because of check_errors). */
991 /* The watchpoint has been disabled. */
992 #define WP_DISABLED 1
993 /* The value has changed. */
994 #define WP_VALUE_CHANGED 2
995 /* The value has not changed. */
996 #define WP_VALUE_NOT_CHANGED 3
998 /* Check watchpoint condition. */
1000 watchpoint_check (p)
1003 bpstat bs = (bpstat) p;
1006 int within_current_scope;
1007 if (bs->breakpoint_at->exp_valid_block == NULL)
1008 within_current_scope = 1;
1011 fr = within_scope (bs->breakpoint_at->exp_valid_block);
1012 within_current_scope = fr != NULL;
1013 if (within_current_scope)
1014 /* If we end up stopping, the current frame will get selected
1015 in normal_stop. So this call to select_frame won't affect
1017 select_frame (fr, -1);
1020 if (within_current_scope)
1022 /* We use value_{,free_to_}mark because it could be a
1023 *long* time before we return to the command level and
1024 call free_all_values. We can't call free_all_values because
1025 we might be in the middle of evaluating a function call. */
1027 value mark = value_mark ();
1028 value new_val = evaluate_expression (bs->breakpoint_at->exp);
1029 if (!value_equal (bs->breakpoint_at->val, new_val))
1031 release_value (new_val);
1032 value_free_to_mark (mark);
1033 bs->old_val = bs->breakpoint_at->val;
1034 bs->breakpoint_at->val = new_val;
1035 /* We will stop here */
1036 return WP_VALUE_CHANGED;
1040 /* Nothing changed, don't do anything. */
1041 value_free_to_mark (mark);
1042 /* We won't stop here */
1043 return WP_VALUE_NOT_CHANGED;
1048 /* This seems like the only logical thing to do because
1049 if we temporarily ignored the watchpoint, then when
1050 we reenter the block in which it is valid it contains
1051 garbage (in the case of a function, it may have two
1052 garbage values, one before and one after the prologue).
1053 So we can't even detect the first assignment to it and
1054 watch after that (since the garbage may or may not equal
1055 the first value assigned). */
1056 bs->breakpoint_at->enable = disabled;
1058 Watchpoint %d disabled because the program has left the block in\n\
1059 which its expression is valid.\n", bs->breakpoint_at->number);
1064 /* This is used when everything which needs to be printed has
1065 already been printed. But we still want to print the frame. */
1073 /* This is used when nothing should be printed for this bpstat entry. */
1082 /* Get a bpstat associated with having just stopped at address *PC
1083 and frame address FRAME_ADDRESS. Update *PC to point at the
1084 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1085 if this is known to not be a real breakpoint (it could still be a
1086 watchpoint, though). */
1088 /* Determine whether we stopped at a breakpoint, etc, or whether we
1089 don't understand this stop. Result is a chain of bpstat's such that:
1091 if we don't understand the stop, the result is a null pointer.
1093 if we understand why we stopped, the result is not null.
1095 Each element of the chain refers to a particular breakpoint or
1096 watchpoint at which we have stopped. (We may have stopped for
1097 several reasons concurrently.)
1099 Each element of the chain has valid next, breakpoint_at,
1100 commands, FIXME??? fields.
1105 bpstat_stop_status (pc, frame_address, not_a_breakpoint)
1107 FRAME_ADDR frame_address;
1108 int not_a_breakpoint;
1110 register struct breakpoint *b;
1112 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1113 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1114 int real_breakpoint = 0;
1116 /* Root of the chain of bpstat's */
1117 struct bpstat root_bs[1];
1118 /* Pointer to the last thing in the chain currently. */
1119 bpstat bs = root_bs;
1121 /* Get the address where the breakpoint would have been. */
1122 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1126 if (b->enable == disabled)
1129 if (b->type != bp_watchpoint && b->address != bp_addr)
1132 if (b->type != bp_watchpoint && not_a_breakpoint)
1135 /* Come here if it's a watchpoint, or if the break address matches */
1137 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1142 if (b->type == bp_watchpoint)
1144 static char message1[] =
1145 "Error evaluating expression for watchpoint %d\n";
1146 char message[sizeof (message1) + 30 /* slop */];
1147 sprintf (message, message1, b->number);
1148 switch (catch_errors (watchpoint_check, (char *) bs, message,
1152 /* We've already printed what needs to be printed. */
1153 bs->print_it = print_it_done;
1156 case WP_VALUE_CHANGED:
1159 case WP_VALUE_NOT_CHANGED:
1161 bs->print_it = print_it_noop;
1168 /* Error from catch_errors. */
1169 b->enable = disabled;
1170 printf_filtered ("Watchpoint %d disabled.\n", b->number);
1171 /* We've already printed what needs to be printed. */
1172 bs->print_it = print_it_done;
1177 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1179 real_breakpoint = 1;
1182 if (b->frame && b->frame != frame_address)
1186 int value_is_zero = 0;
1190 /* Need to select the frame, with all that implies
1191 so that the conditions will have the right context. */
1192 select_frame (get_current_frame (), 0);
1194 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1195 "Error in testing breakpoint condition:\n",
1197 /* FIXME-someday, should give breakpoint # */
1200 if (b->cond && value_is_zero)
1204 else if (b->ignore_count > 0)
1211 /* We will stop here */
1212 if (b->disposition == disable)
1213 b->enable = disabled;
1214 bs->commands = b->commands;
1217 if (bs->commands && STREQ ("silent", bs->commands->line))
1219 bs->commands = bs->commands->next;
1224 /* Print nothing for this entry if we dont stop or if we dont print. */
1225 if (bs->stop == 0 || bs->print == 0)
1226 bs->print_it = print_it_noop;
1229 bs->next = NULL; /* Terminate the chain */
1230 bs = root_bs->next; /* Re-grab the head of the chain */
1231 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1234 if (real_breakpoint)
1237 #if defined (SHIFT_INST_REGS)
1239 #else /* No SHIFT_INST_REGS. */
1241 #endif /* No SHIFT_INST_REGS. */
1244 #endif /* DECR_PC_AFTER_BREAK != 0. */
1248 /* Tell what to do about this bpstat. */
1253 /* Classify each bpstat as one of the following. */
1255 /* This bpstat element has no effect on the main_action. */
1258 /* There was a watchpoint, stop but don't print. */
1261 /* There was a watchpoint, stop and print. */
1264 /* There was a breakpoint but we're not stopping. */
1267 /* There was a breakpoint, stop but don't print. */
1270 /* There was a breakpoint, stop and print. */
1273 /* We hit the longjmp breakpoint. */
1276 /* We hit the longjmp_resume breakpoint. */
1279 /* We hit the step_resume breakpoint. */
1282 /* This is just used to count how many enums there are. */
1286 /* Here is the table which drives this routine. So that we can
1287 format it pretty, we define some abbreviations for the
1288 enum bpstat_what codes. */
1289 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1290 #define stop_s BPSTAT_WHAT_STOP_SILENT
1291 #define stop_n BPSTAT_WHAT_STOP_NOISY
1292 #define single BPSTAT_WHAT_SINGLE
1293 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1294 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1295 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1296 #define sr BPSTAT_WHAT_STEP_RESUME
1298 /* "Can't happen." Might want to print an error message.
1299 abort() is not out of the question, but chances are GDB is just
1300 a bit confused, not unusable. */
1301 #define err BPSTAT_WHAT_STOP_NOISY
1303 /* Given an old action and a class, come up with a new action. */
1304 /* One interesting property of this table is that wp_silent is the same
1305 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1306 after stopping, the check for whether to step over a breakpoint
1307 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1308 reference to how we stopped. We retain separate wp_silent and bp_silent
1309 codes in case we want to change that someday. */
1311 /* step_resume entries: a step resume breakpoint overrides another
1312 breakpoint of signal handling (see comment in wait_for_inferior
1313 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1315 static const enum bpstat_what_main_action
1316 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1319 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr */
1321 /*no_effect*/ {keep_c, stop_s, stop_n, single, setlr , clrlr , clrlrs, sr},
1322 /*wp_silent*/ {stop_s, stop_s, stop_n, stop_s, stop_s, stop_s, stop_s, sr},
1323 /*wp_noisy*/ {stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, sr},
1324 /*bp_nostop*/ {single, stop_s, stop_n, single, setlr , clrlrs, clrlrs, sr},
1325 /*bp_silent*/ {stop_s, stop_s, stop_n, stop_s, stop_s, stop_s, stop_s, sr},
1326 /*bp_noisy*/ {stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, stop_n, sr},
1327 /*long_jump*/ {setlr , stop_s, stop_n, setlr , err , err , err , sr},
1328 /*long_resume*/ {clrlr , stop_s, stop_n, clrlrs, err , err , err , sr},
1329 /*step_resume*/ {sr , sr , sr , sr , sr , sr , sr , sr}
1339 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1340 struct bpstat_what retval;
1342 retval.call_dummy = 0;
1343 for (; bs != NULL; bs = bs->next)
1345 enum class bs_class = no_effect;
1346 if (bs->breakpoint_at == NULL)
1347 /* I suspect this can happen if it was a momentary breakpoint
1348 which has since been deleted. */
1350 switch (bs->breakpoint_at->type)
1358 bs_class = bp_noisy;
1360 bs_class = bp_silent;
1363 bs_class = bp_nostop;
1369 bs_class = wp_noisy;
1371 bs_class = wp_silent;
1374 /* There was a watchpoint, but we're not stopping. This requires
1375 no further action. */
1376 bs_class = no_effect;
1379 bs_class = long_jump;
1381 case bp_longjmp_resume:
1382 bs_class = long_resume;
1384 case bp_step_resume:
1386 /* Need to temporarily disable this until we can fix the bug
1387 with nexting over a breakpoint with ->stop clear causing
1388 an infinite loop. For now, treat the breakpoint as having
1389 been hit even if the frame is wrong. */
1393 bs_class = step_resume;
1397 /* It is for the wrong frame. */
1398 bs_class = bp_nostop;
1402 /* Make sure the action is stop (silent or noisy), so infrun.c
1403 pops the dummy frame. */
1404 bs_class = bp_silent;
1405 retval.call_dummy = 1;
1408 current_action = table[(int)bs_class][(int)current_action];
1410 retval.main_action = current_action;
1414 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1415 without hardware support). This isn't related to a specific bpstat,
1416 just to things like whether watchpoints are set. */
1419 bpstat_should_step ()
1421 struct breakpoint *b;
1423 if (b->enable == enabled && b->type == bp_watchpoint)
1428 /* Print information on breakpoint number BNUM, or -1 if all.
1429 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1430 is nonzero, process only watchpoints. */
1433 breakpoint_1 (bnum, allflag)
1437 register struct breakpoint *b;
1438 register struct command_line *l;
1439 register struct symbol *sym;
1440 CORE_ADDR last_addr = (CORE_ADDR)-1;
1441 int found_a_breakpoint = 0;
1442 static char *bptypes[] = {"breakpoint", "until", "finish", "watchpoint",
1443 "longjmp", "longjmp resume", "step resume",
1445 static char *bpdisps[] = {"del", "dis", "keep"};
1446 static char bpenables[] = "ny";
1447 char wrap_indent[80];
1451 || bnum == b->number)
1453 /* We only print out user settable breakpoints unless the allflag is set. */
1455 && b->type != bp_breakpoint
1456 && b->type != bp_watchpoint)
1459 if (!found_a_breakpoint++)
1460 printf_filtered ("Num Type Disp Enb %sWhat\n",
1461 addressprint ? "Address " : "");
1463 printf_filtered ("%-3d %-14s %-4s %-3c ",
1465 bptypes[(int)b->type],
1466 bpdisps[(int)b->disposition],
1467 bpenables[(int)b->enable]);
1468 strcpy (wrap_indent, " ");
1470 strcat (wrap_indent, " ");
1474 print_expression (b->exp, gdb_stdout);
1481 case bp_longjmp_resume:
1482 case bp_step_resume:
1485 printf_filtered ("%s ", local_hex_string_custom ((unsigned long) b->address, "08l"));
1487 last_addr = b->address;
1490 sym = find_pc_function (b->address);
1493 fputs_filtered ("in ", gdb_stdout);
1494 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1495 wrap_here (wrap_indent);
1496 fputs_filtered (" at ", gdb_stdout);
1498 fputs_filtered (b->source_file, gdb_stdout);
1499 printf_filtered (":%d", b->line_number);
1502 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1506 printf_filtered ("\n");
1509 printf_filtered ("\tstop only in stack frame at %s\n",
1510 local_hex_string((unsigned long) b->frame));
1513 printf_filtered ("\tstop only if ");
1514 print_expression (b->cond, gdb_stdout);
1515 printf_filtered ("\n");
1517 if (b->ignore_count)
1518 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1519 if ((l = b->commands))
1522 fputs_filtered ("\t", gdb_stdout);
1523 fputs_filtered (l->line, gdb_stdout);
1524 fputs_filtered ("\n", gdb_stdout);
1529 if (!found_a_breakpoint)
1532 printf_filtered ("No breakpoints or watchpoints.\n");
1534 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1537 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1538 that a comparison of an unsigned with -1 is always false. */
1539 if (last_addr != (CORE_ADDR)-1)
1540 set_next_address (last_addr);
1545 breakpoints_info (bnum_exp, from_tty)
1552 bnum = parse_and_eval_address (bnum_exp);
1554 breakpoint_1 (bnum, 0);
1557 #if MAINTENANCE_CMDS
1561 maintenance_info_breakpoints (bnum_exp, from_tty)
1568 bnum = parse_and_eval_address (bnum_exp);
1570 breakpoint_1 (bnum, 1);
1575 /* Print a message describing any breakpoints set at PC. */
1578 describe_other_breakpoints (pc)
1579 register CORE_ADDR pc;
1581 register int others = 0;
1582 register struct breakpoint *b;
1585 if (b->address == pc)
1589 printf_unfiltered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1591 if (b->address == pc)
1594 printf_unfiltered ("%d%s%s ",
1596 (b->enable == disabled) ? " (disabled)" : "",
1597 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1599 printf_unfiltered ("also set at pc %s.\n", local_hex_string((unsigned long) pc));
1603 /* Set the default place to put a breakpoint
1604 for the `break' command with no arguments. */
1607 set_default_breakpoint (valid, addr, symtab, line)
1610 struct symtab *symtab;
1613 default_breakpoint_valid = valid;
1614 default_breakpoint_address = addr;
1615 default_breakpoint_symtab = symtab;
1616 default_breakpoint_line = line;
1619 /* Rescan breakpoints at address ADDRESS,
1620 marking the first one as "first" and any others as "duplicates".
1621 This is so that the bpt instruction is only inserted once. */
1624 check_duplicates (address)
1627 register struct breakpoint *b;
1628 register int count = 0;
1630 if (address == 0) /* Watchpoints are uninteresting */
1634 if (b->enable != disabled && b->address == address)
1637 b->duplicate = count > 1;
1641 /* Low level routine to set a breakpoint.
1642 Takes as args the three things that every breakpoint must have.
1643 Returns the breakpoint object so caller can set other things.
1644 Does not set the breakpoint number!
1645 Does not print anything.
1647 ==> This routine should not be called if there is a chance of later
1648 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1649 your arguments BEFORE calling this routine! */
1651 static struct breakpoint *
1652 set_raw_breakpoint (sal)
1653 struct symtab_and_line sal;
1655 register struct breakpoint *b, *b1;
1657 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1658 memset (b, 0, sizeof (*b));
1659 b->address = sal.pc;
1660 if (sal.symtab == NULL)
1661 b->source_file = NULL;
1663 b->source_file = savestring (sal.symtab->filename,
1664 strlen (sal.symtab->filename));
1666 b->line_number = sal.line;
1667 b->enable = enabled;
1670 b->ignore_count = 0;
1674 /* Add this breakpoint to the end of the chain
1675 so that a list of breakpoints will come out in order
1676 of increasing numbers. */
1678 b1 = breakpoint_chain;
1680 breakpoint_chain = b;
1688 check_duplicates (sal.pc);
1694 create_longjmp_breakpoint(func_name)
1697 struct symtab_and_line sal;
1698 struct breakpoint *b;
1699 static int internal_breakpoint_number = -1;
1701 if (func_name != NULL)
1703 struct minimal_symbol *m;
1705 m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
1707 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1717 b = set_raw_breakpoint(sal);
1720 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1721 b->disposition = donttouch;
1722 b->enable = disabled;
1725 b->addr_string = strsave(func_name);
1726 b->number = internal_breakpoint_number--;
1729 /* Call this routine when stepping and nexting to enable a breakpoint if we do
1730 a longjmp(). When we hit that breakpoint, call
1731 set_longjmp_resume_breakpoint() to figure out where we are going. */
1734 enable_longjmp_breakpoint()
1736 register struct breakpoint *b;
1739 if (b->type == bp_longjmp)
1741 b->enable = enabled;
1742 check_duplicates (b->address);
1747 disable_longjmp_breakpoint()
1749 register struct breakpoint *b;
1752 if ( b->type == bp_longjmp
1753 || b->type == bp_longjmp_resume)
1755 b->enable = disabled;
1756 check_duplicates (b->address);
1760 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
1761 breakpoint at the target of the jmp_buf.
1763 FIXME - This ought to be done by setting a temporary breakpoint that gets
1764 deleted automatically...
1768 set_longjmp_resume_breakpoint(pc, frame)
1772 register struct breakpoint *b;
1775 if (b->type == bp_longjmp_resume)
1778 b->enable = enabled;
1780 b->frame = FRAME_FP(frame);
1783 check_duplicates (b->address);
1788 /* Set a breakpoint that will evaporate an end of command
1789 at address specified by SAL.
1790 Restrict it to frame FRAME if FRAME is nonzero. */
1793 set_momentary_breakpoint (sal, frame, type)
1794 struct symtab_and_line sal;
1798 register struct breakpoint *b;
1799 b = set_raw_breakpoint (sal);
1801 b->enable = enabled;
1802 b->disposition = donttouch;
1803 b->frame = (frame ? FRAME_FP (frame) : 0);
1809 clear_momentary_breakpoints ()
1811 register struct breakpoint *b;
1813 if (b->disposition == delete)
1815 delete_breakpoint (b);
1821 /* Tell the user we have just set a breakpoint B. */
1824 struct breakpoint *b;
1829 printf_filtered ("Watchpoint %d: ", b->number);
1830 print_expression (b->exp, gdb_stdout);
1833 printf_filtered ("Breakpoint %d at %s", b->number,
1834 local_hex_string((unsigned long) b->address));
1836 printf_filtered (": file %s, line %d.",
1837 b->source_file, b->line_number);
1842 case bp_longjmp_resume:
1843 case bp_step_resume:
1847 printf_filtered ("\n");
1851 /* Nobody calls this currently. */
1852 /* Set a breakpoint from a symtab and line.
1853 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1854 ADDR_STRING is a malloc'd string holding the name of where we are
1855 setting the breakpoint. This is used later to re-set it after the
1856 program is relinked and symbols are reloaded.
1857 Print the same confirmation messages that the breakpoint command prints. */
1860 set_breakpoint (s, line, tempflag, addr_string)
1866 register struct breakpoint *b;
1867 struct symtab_and_line sal;
1872 resolve_sal_pc (&sal); /* Might error out */
1873 describe_other_breakpoints (sal.pc);
1875 b = set_raw_breakpoint (sal);
1876 set_breakpoint_count (breakpoint_count + 1);
1877 b->number = breakpoint_count;
1878 b->type = bp_breakpoint;
1880 b->addr_string = addr_string;
1881 b->enable = enabled;
1882 b->disposition = tempflag ? delete : donttouch;
1888 /* Set a breakpoint according to ARG (function, linenum or *address)
1889 and make it temporary if TEMPFLAG is nonzero. */
1892 break_command_1 (arg, tempflag, from_tty)
1894 int tempflag, from_tty;
1896 struct symtabs_and_lines sals;
1897 struct symtab_and_line sal;
1898 register struct expression *cond = 0;
1899 register struct breakpoint *b;
1901 /* Pointers in arg to the start, and one past the end, of the condition. */
1902 char *cond_start = NULL;
1903 char *cond_end = NULL;
1904 /* Pointers in arg to the start, and one past the end,
1905 of the address part. */
1906 char *addr_start = NULL;
1907 char *addr_end = NULL;
1908 struct cleanup *old_chain;
1909 struct cleanup *canonical_strings_chain = NULL;
1910 char **canonical = (char **)NULL;
1917 sal.line = sal.pc = sal.end = 0;
1920 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1922 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1923 && (arg[2] == ' ' || arg[2] == '\t')))
1925 if (default_breakpoint_valid)
1927 sals.sals = (struct symtab_and_line *)
1928 xmalloc (sizeof (struct symtab_and_line));
1929 sal.pc = default_breakpoint_address;
1930 sal.line = default_breakpoint_line;
1931 sal.symtab = default_breakpoint_symtab;
1936 error ("No default breakpoint address now.");
1942 /* Force almost all breakpoints to be in terms of the
1943 current_source_symtab (which is decode_line_1's default). This
1944 should produce the results we want almost all of the time while
1945 leaving default_breakpoint_* alone. */
1946 if (default_breakpoint_valid
1947 && (!current_source_symtab
1948 || (arg && (*arg == '+' || *arg == '-'))))
1949 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1950 default_breakpoint_line, &canonical);
1952 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
1960 /* Make sure that all storage allocated in decode_line_1 gets freed in case
1961 the following `for' loop errors out. */
1962 old_chain = make_cleanup (free, sals.sals);
1963 if (canonical != (char **)NULL)
1965 make_cleanup (free, canonical);
1966 canonical_strings_chain = make_cleanup (null_cleanup, 0);
1967 for (i = 0; i < sals.nelts; i++)
1969 if (canonical[i] != NULL)
1970 make_cleanup (free, canonical[i]);
1974 thread = -1; /* No specific thread yet */
1976 /* Resolve all line numbers to PC's, and verify that conditions
1977 can be parsed, before setting any breakpoints. */
1978 for (i = 0; i < sals.nelts; i++)
1980 char *tok, *end_tok;
1983 resolve_sal_pc (&sals.sals[i]);
1989 while (*tok == ' ' || *tok == '\t')
1994 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
1997 toklen = end_tok - tok;
1999 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2001 tok = cond_start = end_tok + 1;
2002 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2005 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2011 thread = strtol (tok, &tok, 0);
2013 error ("Junk after thread keyword.");
2014 if (!valid_thread_id (thread))
2015 error ("Unknown thread %d\n", thread);
2018 error ("Junk at end of arguments.");
2022 /* Remove the canonical strings from the cleanup, they are needed below. */
2023 if (canonical != (char **)NULL)
2024 discard_cleanups (canonical_strings_chain);
2026 /* Now set all the breakpoints. */
2027 for (i = 0; i < sals.nelts; i++)
2032 describe_other_breakpoints (sal.pc);
2034 b = set_raw_breakpoint (sal);
2035 set_breakpoint_count (breakpoint_count + 1);
2036 b->number = breakpoint_count;
2037 b->type = bp_breakpoint;
2041 /* If a canonical line spec is needed use that instead of the
2043 if (canonical != (char **)NULL && canonical[i] != NULL)
2044 b->addr_string = canonical[i];
2045 else if (addr_start)
2046 b->addr_string = savestring (addr_start, addr_end - addr_start);
2048 b->cond_string = savestring (cond_start, cond_end - cond_start);
2050 b->enable = enabled;
2051 b->disposition = tempflag ? delete : donttouch;
2058 printf_unfiltered ("Multiple breakpoints were set.\n");
2059 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2061 do_cleanups (old_chain);
2064 /* Helper function for break_command_1 and disassemble_command. */
2067 resolve_sal_pc (sal)
2068 struct symtab_and_line *sal;
2072 if (sal->pc == 0 && sal->symtab != 0)
2074 pc = find_line_pc (sal->symtab, sal->line);
2076 error ("No line %d in file \"%s\".",
2077 sal->line, sal->symtab->filename);
2083 break_command (arg, from_tty)
2087 break_command_1 (arg, 0, from_tty);
2091 tbreak_command (arg, from_tty)
2095 break_command_1 (arg, 1, from_tty);
2100 watch_command (arg, from_tty)
2104 struct breakpoint *b;
2105 struct symtab_and_line sal;
2106 struct expression *exp;
2107 struct block *exp_valid_block;
2114 /* Parse arguments. */
2115 innermost_block = NULL;
2116 exp = parse_expression (arg);
2117 exp_valid_block = innermost_block;
2118 val = evaluate_expression (exp);
2119 release_value (val);
2120 if (VALUE_LAZY (val))
2121 value_fetch_lazy (val);
2123 /* Now set up the breakpoint. */
2124 b = set_raw_breakpoint (sal);
2125 set_breakpoint_count (breakpoint_count + 1);
2126 b->number = breakpoint_count;
2127 b->type = bp_watchpoint;
2128 b->disposition = donttouch;
2130 b->exp_valid_block = exp_valid_block;
2133 b->cond_string = NULL;
2134 b->exp_string = savestring (arg, strlen (arg));
2139 * Helper routine for the until_command routine in infcmd.c. Here
2140 * because it uses the mechanisms of breakpoints.
2144 until_break_command (arg, from_tty)
2148 struct symtabs_and_lines sals;
2149 struct symtab_and_line sal;
2150 FRAME prev_frame = get_prev_frame (selected_frame);
2151 struct breakpoint *breakpoint;
2152 struct cleanup *old_chain;
2154 clear_proceed_status ();
2156 /* Set a breakpoint where the user wants it and at return from
2159 if (default_breakpoint_valid)
2160 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2161 default_breakpoint_line, (char ***)NULL);
2163 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2165 if (sals.nelts != 1)
2166 error ("Couldn't get information on specified line.");
2169 free ((PTR)sals.sals); /* malloc'd, so freed */
2172 error ("Junk at end of arguments.");
2174 resolve_sal_pc (&sal);
2176 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2178 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2180 /* Keep within the current frame */
2184 struct frame_info *fi;
2186 fi = get_frame_info (prev_frame);
2187 sal = find_pc_line (fi->pc, 0);
2189 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2190 make_cleanup(delete_breakpoint, breakpoint);
2193 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2194 do_cleanups(old_chain);
2198 /* These aren't used; I don't konw what they were for. */
2199 /* Set a breakpoint at the catch clause for NAME. */
2201 catch_breakpoint (name)
2207 disable_catch_breakpoint ()
2212 delete_catch_breakpoint ()
2217 enable_catch_breakpoint ()
2224 struct sal_chain *next;
2225 struct symtab_and_line sal;
2229 /* This isn't used; I don't know what it was for. */
2230 /* For each catch clause identified in ARGS, run FUNCTION
2231 with that clause as an argument. */
2232 static struct symtabs_and_lines
2233 map_catch_names (args, function)
2237 register char *p = args;
2239 struct symtabs_and_lines sals;
2241 struct sal_chain *sal_chain = 0;
2245 error_no_arg ("one or more catch names");
2253 /* Don't swallow conditional part. */
2254 if (p1[0] == 'i' && p1[1] == 'f'
2255 && (p1[2] == ' ' || p1[2] == '\t'))
2261 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2265 if (*p1 && *p1 != ' ' && *p1 != '\t')
2266 error ("Arguments must be catch names.");
2272 struct sal_chain *next
2273 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2274 next->next = sal_chain;
2275 next->sal = get_catch_sal (p);
2280 printf_unfiltered ("No catch clause for exception %s.\n", p);
2285 while (*p == ' ' || *p == '\t') p++;
2290 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2292 static struct symtabs_and_lines
2293 get_catch_sals (this_level_only)
2294 int this_level_only;
2296 register struct blockvector *bl;
2297 register struct block *block;
2298 int index, have_default = 0;
2299 struct frame_info *fi;
2301 struct symtabs_and_lines sals;
2302 struct sal_chain *sal_chain = 0;
2303 char *blocks_searched;
2305 /* Not sure whether an error message is always the correct response,
2306 but it's better than a core dump. */
2307 if (selected_frame == NULL)
2308 error ("No selected frame.");
2309 block = get_frame_block (selected_frame);
2310 fi = get_frame_info (selected_frame);
2317 error ("No symbol table info available.\n");
2319 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2320 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2321 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2325 CORE_ADDR end = BLOCK_END (block) - 4;
2328 if (bl != blockvector_for_pc (end, &index))
2329 error ("blockvector blotch");
2330 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2331 error ("blockvector botch");
2332 last_index = BLOCKVECTOR_NBLOCKS (bl);
2335 /* Don't print out blocks that have gone by. */
2336 while (index < last_index
2337 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2340 while (index < last_index
2341 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2343 if (blocks_searched[index] == 0)
2345 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2348 register struct symbol *sym;
2350 nsyms = BLOCK_NSYMS (b);
2352 for (i = 0; i < nsyms; i++)
2354 sym = BLOCK_SYM (b, i);
2355 if (STREQ (SYMBOL_NAME (sym), "default"))
2361 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2363 struct sal_chain *next = (struct sal_chain *)
2364 alloca (sizeof (struct sal_chain));
2365 next->next = sal_chain;
2366 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2370 blocks_searched[index] = 1;
2376 if (sal_chain && this_level_only)
2379 /* After handling the function's top-level block, stop.
2380 Don't continue to its superblock, the block of
2381 per-file symbols. */
2382 if (BLOCK_FUNCTION (block))
2384 block = BLOCK_SUPERBLOCK (block);
2389 struct sal_chain *tmp_chain;
2391 /* Count the number of entries. */
2392 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2393 tmp_chain = tmp_chain->next)
2397 sals.sals = (struct symtab_and_line *)
2398 xmalloc (index * sizeof (struct symtab_and_line));
2399 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2400 sals.sals[index] = sal_chain->sal;
2406 /* Commands to deal with catching exceptions. */
2409 catch_command_1 (arg, tempflag, from_tty)
2414 /* First, translate ARG into something we can deal with in terms
2417 struct symtabs_and_lines sals;
2418 struct symtab_and_line sal;
2419 register struct expression *cond = 0;
2420 register struct breakpoint *b;
2424 sal.line = sal.pc = sal.end = 0;
2427 /* If no arg given, or if first arg is 'if ', all active catch clauses
2428 are breakpointed. */
2430 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2431 && (arg[2] == ' ' || arg[2] == '\t')))
2433 /* Grab all active catch clauses. */
2434 sals = get_catch_sals (0);
2438 /* Grab selected catch clauses. */
2439 error ("catch NAME not implemented");
2441 /* This isn't used; I don't know what it was for. */
2442 sals = map_catch_names (arg, catch_breakpoint);
2450 for (i = 0; i < sals.nelts; i++)
2452 resolve_sal_pc (&sals.sals[i]);
2456 if (arg[0] == 'i' && arg[1] == 'f'
2457 && (arg[2] == ' ' || arg[2] == '\t'))
2458 cond = parse_exp_1 ((arg += 2, &arg),
2459 block_for_pc (sals.sals[i].pc), 0);
2461 error ("Junk at end of arguments.");
2466 for (i = 0; i < sals.nelts; i++)
2471 describe_other_breakpoints (sal.pc);
2473 b = set_raw_breakpoint (sal);
2474 set_breakpoint_count (breakpoint_count + 1);
2475 b->number = breakpoint_count;
2476 b->type = bp_breakpoint;
2478 b->enable = enabled;
2479 b->disposition = tempflag ? delete : donttouch;
2486 printf_unfiltered ("Multiple breakpoints were set.\n");
2487 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2489 free ((PTR)sals.sals);
2493 /* These aren't used; I don't know what they were for. */
2494 /* Disable breakpoints on all catch clauses described in ARGS. */
2496 disable_catch (args)
2499 /* Map the disable command to catch clauses described in ARGS. */
2502 /* Enable breakpoints on all catch clauses described in ARGS. */
2507 /* Map the disable command to catch clauses described in ARGS. */
2510 /* Delete breakpoints on all catch clauses in the active scope. */
2515 /* Map the delete command to catch clauses described in ARGS. */
2520 catch_command (arg, from_tty)
2524 catch_command_1 (arg, 0, from_tty);
2528 clear_command (arg, from_tty)
2532 register struct breakpoint *b, *b1;
2533 struct symtabs_and_lines sals;
2534 struct symtab_and_line sal;
2535 register struct breakpoint *found;
2540 sals = decode_line_spec (arg, 1);
2544 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
2545 sal.line = default_breakpoint_line;
2546 sal.symtab = default_breakpoint_symtab;
2548 if (sal.symtab == 0)
2549 error ("No source file specified.");
2555 for (i = 0; i < sals.nelts; i++)
2557 /* If exact pc given, clear bpts at that pc.
2558 But if sal.pc is zero, clear all bpts on specified line. */
2560 found = (struct breakpoint *) 0;
2561 while (breakpoint_chain
2563 ? breakpoint_chain->address == sal.pc
2564 : (breakpoint_chain->source_file != NULL
2565 && sal.symtab != NULL
2566 && STREQ (breakpoint_chain->source_file,
2567 sal.symtab->filename)
2568 && breakpoint_chain->line_number == sal.line)))
2570 b1 = breakpoint_chain;
2571 breakpoint_chain = b1->next;
2578 && b->next->type != bp_watchpoint
2580 ? b->next->address == sal.pc
2581 : (b->next->source_file != NULL
2582 && sal.symtab != NULL
2583 && STREQ (b->next->source_file, sal.symtab->filename)
2584 && b->next->line_number == sal.line)))
2595 error ("No breakpoint at %s.", arg);
2597 error ("No breakpoint at this line.");
2600 if (found->next) from_tty = 1; /* Always report if deleted more than one */
2601 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
2604 if (from_tty) printf_unfiltered ("%d ", found->number);
2606 delete_breakpoint (found);
2609 if (from_tty) putchar_unfiltered ('\n');
2611 free ((PTR)sals.sals);
2614 /* Delete breakpoint in BS if they are `delete' breakpoints.
2615 This is called after any breakpoint is hit, or after errors. */
2618 breakpoint_auto_delete (bs)
2621 for (; bs; bs = bs->next)
2622 if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
2624 delete_breakpoint (bs->breakpoint_at);
2627 /* Delete a breakpoint and clean up all traces of it in the data structures. */
2630 delete_breakpoint (bpt)
2631 struct breakpoint *bpt;
2633 register struct breakpoint *b;
2637 target_remove_breakpoint(bpt->address, bpt->shadow_contents);
2639 if (breakpoint_chain == bpt)
2640 breakpoint_chain = bpt->next;
2645 b->next = bpt->next;
2649 check_duplicates (bpt->address);
2650 /* If this breakpoint was inserted, and there is another breakpoint
2651 at the same address, we need to insert the other breakpoint. */
2655 if (b->address == bpt->address
2657 && b->enable != disabled)
2660 val = target_insert_breakpoint (b->address, b->shadow_contents);
2663 target_terminal_ours_for_output ();
2664 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
2665 memory_error (val, b->address); /* which bombs us out */
2672 free_command_lines (&bpt->commands);
2675 if (bpt->cond_string != NULL)
2676 free (bpt->cond_string);
2677 if (bpt->addr_string != NULL)
2678 free (bpt->addr_string);
2679 if (bpt->exp_string != NULL)
2680 free (bpt->exp_string);
2681 if (bpt->source_file != NULL)
2682 free (bpt->source_file);
2684 if (xgdb_verbose && bpt->type == bp_breakpoint)
2686 target_terminal_ours_for_output ();
2687 printf_unfiltered ("breakpoint #%d deleted\n", bpt->number);
2690 /* Be sure no bpstat's are pointing at it after it's been freed. */
2691 /* FIXME, how can we find all bpstat's?
2692 We just check stop_bpstat for now. */
2693 for (bs = stop_bpstat; bs; bs = bs->next)
2694 if (bs->breakpoint_at == bpt)
2695 bs->breakpoint_at = NULL;
2700 delete_command (arg, from_tty)
2707 /* Ask user only if there are some breakpoints to delete. */
2709 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
2711 /* No arg; clear all breakpoints. */
2712 while (breakpoint_chain)
2713 delete_breakpoint (breakpoint_chain);
2717 map_breakpoint_numbers (arg, delete_breakpoint);
2720 /* Reset a breakpoint given it's struct breakpoint * BINT.
2721 The value we return ends up being the return value from catch_errors.
2722 Unused in this case. */
2725 breakpoint_re_set_one (bint)
2728 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
2730 struct symtabs_and_lines sals;
2732 enum enable save_enable;
2737 if (b->addr_string == NULL)
2739 /* Anything without a string can't be re-set. */
2740 delete_breakpoint (b);
2743 /* In case we have a problem, disable this breakpoint. We'll restore
2744 its status if we succeed. */
2745 save_enable = b->enable;
2746 b->enable = disabled;
2749 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2750 for (i = 0; i < sals.nelts; i++)
2752 resolve_sal_pc (&sals.sals[i]);
2754 /* Reparse conditions, they might contain references to the
2756 if (b->cond_string != NULL)
2760 free ((PTR)b->cond);
2761 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
2764 /* We need to re-set the breakpoint if the address changes...*/
2765 if (b->address != sals.sals[i].pc
2766 /* ...or new and old breakpoints both have source files, and
2767 the source file name or the line number changes... */
2768 || (b->source_file != NULL
2769 && sals.sals[i].symtab != NULL
2770 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
2771 || b->line_number != sals.sals[i].line)
2773 /* ...or we switch between having a source file and not having
2775 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
2778 if (b->source_file != NULL)
2779 free (b->source_file);
2780 if (sals.sals[i].symtab == NULL)
2781 b->source_file = NULL;
2784 savestring (sals.sals[i].symtab->filename,
2785 strlen (sals.sals[i].symtab->filename));
2786 b->line_number = sals.sals[i].line;
2787 b->address = sals.sals[i].pc;
2789 check_duplicates (b->address);
2793 b->enable = save_enable; /* Restore it, this worked. */
2795 free ((PTR)sals.sals);
2799 innermost_block = NULL;
2800 /* The issue arises of what context to evaluate this in. The same
2801 one as when it was set, but what does that mean when symbols have
2802 been re-read? We could save the filename and functionname, but
2803 if the context is more local than that, the best we could do would
2804 be something like how many levels deep and which index at that
2805 particular level, but that's going to be less stable than filenames
2806 or functionnames. */
2807 /* So for now, just use a global context. */
2808 b->exp = parse_expression (b->exp_string);
2809 b->exp_valid_block = innermost_block;
2810 b->val = evaluate_expression (b->exp);
2811 release_value (b->val);
2812 if (VALUE_LAZY (b->val))
2813 value_fetch_lazy (b->val);
2815 if (b->cond_string != NULL)
2818 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
2820 if (b->enable == enabled)
2825 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
2830 case bp_longjmp_resume:
2832 delete_breakpoint (b);
2839 /* Re-set all breakpoints after symbols have been re-loaded. */
2841 breakpoint_re_set ()
2843 struct breakpoint *b, *temp;
2844 static char message1[] = "Error in re-setting breakpoint %d:\n";
2845 char message[sizeof (message1) + 30 /* slop */];
2847 ALL_BREAKPOINTS_SAFE (b, temp)
2849 sprintf (message, message1, b->number); /* Format possible error msg */
2850 catch_errors (breakpoint_re_set_one, (char *) b, message,
2854 create_longjmp_breakpoint("longjmp");
2855 create_longjmp_breakpoint("_longjmp");
2856 create_longjmp_breakpoint("siglongjmp");
2857 create_longjmp_breakpoint(NULL);
2860 /* Took this out (temporaliy at least), since it produces an extra
2861 blank line at startup. This messes up the gdbtests. -PB */
2862 /* Blank line to finish off all those mention() messages we just printed. */
2863 printf_filtered ("\n");
2867 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
2868 If from_tty is nonzero, it prints a message to that effect,
2869 which ends with a period (no newline). */
2872 set_ignore_count (bptnum, count, from_tty)
2873 int bptnum, count, from_tty;
2875 register struct breakpoint *b;
2881 if (b->number == bptnum)
2883 b->ignore_count = count;
2886 else if (count == 0)
2887 printf_filtered ("Will stop next time breakpoint %d is reached.",
2889 else if (count == 1)
2890 printf_filtered ("Will ignore next crossing of breakpoint %d.",
2893 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
2898 error ("No breakpoint number %d.", bptnum);
2901 /* Clear the ignore counts of all breakpoints. */
2903 breakpoint_clear_ignore_counts ()
2905 struct breakpoint *b;
2908 b->ignore_count = 0;
2911 /* Command to set ignore-count of breakpoint N to COUNT. */
2914 ignore_command (args, from_tty)
2922 error_no_arg ("a breakpoint number");
2924 num = get_number (&p);
2927 error ("Second argument (specified ignore-count) is missing.");
2929 set_ignore_count (num,
2930 longest_to_int (value_as_long (parse_and_eval (p))),
2932 printf_filtered ("\n");
2935 /* Call FUNCTION on each of the breakpoints
2936 whose numbers are given in ARGS. */
2939 map_breakpoint_numbers (args, function)
2941 void (*function) PARAMS ((struct breakpoint *));
2943 register char *p = args;
2946 register struct breakpoint *b;
2949 error_no_arg ("one or more breakpoint numbers");
2955 num = get_number (&p1);
2958 if (b->number == num)
2963 printf_unfiltered ("No breakpoint number %d.\n", num);
2970 enable_breakpoint (bpt)
2971 struct breakpoint *bpt;
2973 FRAME save_selected_frame = NULL;
2974 int save_selected_frame_level = -1;
2976 bpt->enable = enabled;
2978 if (xgdb_verbose && bpt->type == bp_breakpoint)
2979 printf_unfiltered ("breakpoint #%d enabled\n", bpt->number);
2981 check_duplicates (bpt->address);
2982 if (bpt->type == bp_watchpoint)
2984 if (bpt->exp_valid_block != NULL)
2986 FRAME fr = within_scope (bpt->exp_valid_block);
2990 Cannot enable watchpoint %d because the block in which its expression\n\
2991 is valid is not currently in scope.\n", bpt->number);
2992 bpt->enable = disabled;
2995 save_selected_frame = selected_frame;
2996 save_selected_frame_level = selected_frame_level;
2997 select_frame (fr, -1);
3000 value_free (bpt->val);
3002 bpt->val = evaluate_expression (bpt->exp);
3003 release_value (bpt->val);
3004 if (VALUE_LAZY (bpt->val))
3005 value_fetch_lazy (bpt->val);
3007 if (save_selected_frame_level >= 0)
3008 select_frame (save_selected_frame, save_selected_frame_level);
3014 enable_command (args, from_tty)
3018 struct breakpoint *bpt;
3020 ALL_BREAKPOINTS (bpt)
3025 enable_breakpoint (bpt);
3030 map_breakpoint_numbers (args, enable_breakpoint);
3034 disable_breakpoint (bpt)
3035 struct breakpoint *bpt;
3037 bpt->enable = disabled;
3039 if (xgdb_verbose && bpt->type == bp_breakpoint)
3040 printf_filtered ("breakpoint #%d disabled\n", bpt->number);
3042 check_duplicates (bpt->address);
3047 disable_command (args, from_tty)
3051 register struct breakpoint *bpt;
3053 ALL_BREAKPOINTS (bpt)
3058 disable_breakpoint (bpt);
3063 map_breakpoint_numbers (args, disable_breakpoint);
3067 enable_once_breakpoint (bpt)
3068 struct breakpoint *bpt;
3070 bpt->enable = enabled;
3071 bpt->disposition = disable;
3073 check_duplicates (bpt->address);
3078 enable_once_command (args, from_tty)
3082 map_breakpoint_numbers (args, enable_once_breakpoint);
3086 enable_delete_breakpoint (bpt)
3087 struct breakpoint *bpt;
3089 bpt->enable = enabled;
3090 bpt->disposition = delete;
3092 check_duplicates (bpt->address);
3097 enable_delete_command (args, from_tty)
3101 map_breakpoint_numbers (args, enable_delete_breakpoint);
3105 * Use default_breakpoint_'s, or nothing if they aren't valid.
3107 struct symtabs_and_lines
3108 decode_line_spec_1 (string, funfirstline)
3112 struct symtabs_and_lines sals;
3114 error ("Empty line specification.");
3115 if (default_breakpoint_valid)
3116 sals = decode_line_1 (&string, funfirstline,
3117 default_breakpoint_symtab, default_breakpoint_line,
3120 sals = decode_line_1 (&string, funfirstline,
3121 (struct symtab *)NULL, 0, (char ***)NULL);
3123 error ("Junk at end of line specification: %s", string);
3128 _initialize_breakpoint ()
3130 breakpoint_chain = 0;
3131 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3132 before a breakpoint is set. */
3133 breakpoint_count = 0;
3135 add_com ("ignore", class_breakpoint, ignore_command,
3136 "Set ignore-count of breakpoint number N to COUNT.");
3138 add_com ("commands", class_breakpoint, commands_command,
3139 "Set commands to be executed when a breakpoint is hit.\n\
3140 Give breakpoint number as argument after \"commands\".\n\
3141 With no argument, the targeted breakpoint is the last one set.\n\
3142 The commands themselves follow starting on the next line.\n\
3143 Type a line containing \"end\" to indicate the end of them.\n\
3144 Give \"silent\" as the first line to make the breakpoint silent;\n\
3145 then no output is printed when it is hit, except what the commands print.");
3147 add_com ("condition", class_breakpoint, condition_command,
3148 "Specify breakpoint number N to break only if COND is true.\n\
3149 N is an integer; COND is an expression to be evaluated whenever\n\
3150 breakpoint N is reached. ");
3152 add_com ("tbreak", class_breakpoint, tbreak_command,
3153 "Set a temporary breakpoint. Args like \"break\" command.\n\
3154 Like \"break\" except the breakpoint is only enabled temporarily,\n\
3155 so it will be disabled when hit. Equivalent to \"break\" followed\n\
3156 by using \"enable once\" on the breakpoint number.");
3158 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3159 "Enable some breakpoints.\n\
3160 Give breakpoint numbers (separated by spaces) as arguments.\n\
3161 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3162 This is used to cancel the effect of the \"disable\" command.\n\
3163 With a subcommand you can enable temporarily.",
3164 &enablelist, "enable ", 1, &cmdlist);
3166 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3167 "Enable some breakpoints.\n\
3168 Give breakpoint numbers (separated by spaces) as arguments.\n\
3169 This is used to cancel the effect of the \"disable\" command.\n\
3170 May be abbreviated to simply \"enable\".\n",
3171 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3173 add_cmd ("once", no_class, enable_once_command,
3174 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3175 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
3176 See the \"tbreak\" command which sets a breakpoint and enables it once.",
3179 add_cmd ("delete", no_class, enable_delete_command,
3180 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3181 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3184 add_cmd ("delete", no_class, enable_delete_command,
3185 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3186 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3189 add_cmd ("once", no_class, enable_once_command,
3190 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3191 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
3192 See the \"tbreak\" command which sets a breakpoint and enables it once.",
3195 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3196 "Disable some breakpoints.\n\
3197 Arguments are breakpoint numbers with spaces in between.\n\
3198 To disable all breakpoints, give no argument.\n\
3199 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3200 &disablelist, "disable ", 1, &cmdlist);
3201 add_com_alias ("dis", "disable", class_breakpoint, 1);
3202 add_com_alias ("disa", "disable", class_breakpoint, 1);
3204 add_cmd ("breakpoints", class_alias, disable_command,
3205 "Disable some breakpoints.\n\
3206 Arguments are breakpoint numbers with spaces in between.\n\
3207 To disable all breakpoints, give no argument.\n\
3208 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3209 This command may be abbreviated \"disable\".",
3212 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3213 "Delete some breakpoints or auto-display expressions.\n\
3214 Arguments are breakpoint numbers with spaces in between.\n\
3215 To delete all breakpoints, give no argument.\n\
3217 Also a prefix command for deletion of other GDB objects.\n\
3218 The \"unset\" command is also an alias for \"delete\".",
3219 &deletelist, "delete ", 1, &cmdlist);
3220 add_com_alias ("d", "delete", class_breakpoint, 1);
3222 add_cmd ("breakpoints", class_alias, delete_command,
3223 "Delete some breakpoints or auto-display expressions.\n\
3224 Arguments are breakpoint numbers with spaces in between.\n\
3225 To delete all breakpoints, give no argument.\n\
3226 This command may be abbreviated \"delete\".",
3229 add_com ("clear", class_breakpoint, clear_command,
3230 "Clear breakpoint at specified line or function.\n\
3231 Argument may be line number, function name, or \"*\" and an address.\n\
3232 If line number is specified, all breakpoints in that line are cleared.\n\
3233 If function is specified, breakpoints at beginning of function are cleared.\n\
3234 If an address is specified, breakpoints at that address are cleared.\n\n\
3235 With no argument, clears all breakpoints in the line that the selected frame\n\
3238 See also the \"delete\" command which clears breakpoints by number.");
3240 add_com ("break", class_breakpoint, break_command,
3241 "Set breakpoint at specified line or function.\n\
3242 Argument may be line number, function name, or \"*\" and an address.\n\
3243 If line number is specified, break at start of code for that line.\n\
3244 If function is specified, break at start of code for that function.\n\
3245 If an address is specified, break at that exact address.\n\
3246 With no arg, uses current execution address of selected stack frame.\n\
3247 This is useful for breaking on return to a stack frame.\n\
3249 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3251 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3252 add_com_alias ("b", "break", class_run, 1);
3253 add_com_alias ("br", "break", class_run, 1);
3254 add_com_alias ("bre", "break", class_run, 1);
3255 add_com_alias ("brea", "break", class_run, 1);
3257 add_info ("breakpoints", breakpoints_info,
3258 "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3259 The \"Type\" column indicates one of:\n\
3260 \tbreakpoint - normal breakpoint\n\
3261 \twatchpoint - watchpoint\n\
3262 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3263 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3264 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3265 address and file/line number respectively.\n\n\
3266 Convenience variable \"$_\" and default examine address for \"x\"\n\
3267 are set to the address of the last breakpoint listed.\n\n\
3268 Convenience variable \"$bpnum\" contains the number of the last\n\
3271 #if MAINTENANCE_CMDS
3273 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3274 "Status of all breakpoints, or breakpoint number NUMBER.\n\
3275 The \"Type\" column indicates one of:\n\
3276 \tbreakpoint - normal breakpoint\n\
3277 \twatchpoint - watchpoint\n\
3278 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3279 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3280 \tuntil - internal breakpoint used by the \"until\" command\n\
3281 \tfinish - internal breakpoint used by the \"finish\" command\n\
3282 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3283 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3284 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3285 address and file/line number respectively.\n\n\
3286 Convenience variable \"$_\" and default examine address for \"x\"\n\
3287 are set to the address of the last breakpoint listed.\n\n\
3288 Convenience variable \"$bpnum\" contains the number of the last\n\
3290 &maintenanceinfolist);
3292 #endif /* MAINTENANCE_CMDS */
3294 add_com ("catch", class_breakpoint, catch_command,
3295 "Set breakpoints to catch exceptions that are raised.\n\
3296 Argument may be a single exception to catch, multiple exceptions\n\
3297 to catch, or the default exception \"default\". If no arguments\n\
3298 are given, breakpoints are set at all exception handlers catch clauses\n\
3299 within the current scope.\n\
3301 A condition specified for the catch applies to all breakpoints set\n\
3302 with this command\n\
3304 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3306 add_com ("watch", class_breakpoint, watch_command,
3307 "Set a watchpoint for an expression.\n\
3308 A watchpoint stops execution of your program whenever the value of\n\
3309 an expression changes.");
3311 add_info ("watchpoints", breakpoints_info,
3312 "Synonym for ``info breakpoints''.");
3315 /* OK, when we call objfile_relocate, we need to relocate breakpoints
3316 too. breakpoint_re_set is not a good choice--for example, if
3317 addr_string contains just a line number without a file name the
3318 breakpoint might get set in a different file. In general, there is
3319 no need to go all the way back to the user's string (though this might
3320 work if some effort were made to canonicalize it), since symtabs and
3321 everything except addresses are still valid.
3323 Probably the best way to solve this is to have each breakpoint save
3324 the objfile and the section number that was used to set it (if set
3325 by "*addr", probably it is best to use find_pc_line to get a symtab
3326 and use the objfile and block_line_section for that symtab). Then
3327 objfile_relocate can call fixup_breakpoints with the objfile and
3328 the new_offsets, and it can relocate only the appropriate breakpoints. */
3330 #ifdef IBM6000_TARGET
3331 /* But for now, just kludge it based on the concept that before an
3332 objfile is relocated the breakpoint is below 0x10000000, and afterwards
3333 it is higher, so that way we only relocate each breakpoint once. */
3336 fixup_breakpoints (low, high, delta)
3341 struct breakpoint *b;
3345 if (b->address >= low && b->address <= high)
3346 b->address += delta;