1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "breakpoint.h"
27 #include "expression.h"
41 /* local function prototypes */
44 catch_command_1 PARAMS ((char *, int, int));
47 enable_delete_command PARAMS ((char *, int));
50 enable_delete_breakpoint PARAMS ((struct breakpoint *));
53 enable_once_command PARAMS ((char *, int));
56 enable_once_breakpoint PARAMS ((struct breakpoint *));
59 disable_command PARAMS ((char *, int));
62 disable_breakpoint PARAMS ((struct breakpoint *));
65 enable_command PARAMS ((char *, int));
68 enable_breakpoint PARAMS ((struct breakpoint *));
71 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
74 ignore_command PARAMS ((char *, int));
77 breakpoint_re_set_one PARAMS ((char *));
80 delete_command PARAMS ((char *, int));
83 clear_command PARAMS ((char *, int));
86 catch_command PARAMS ((char *, int));
88 static struct symtabs_and_lines
89 get_catch_sals PARAMS ((int));
92 watch_command PARAMS ((char *, int));
95 can_use_hardware_watchpoint PARAMS ((struct value *));
98 tbreak_command PARAMS ((char *, int));
101 break_command_1 PARAMS ((char *, int, int));
104 mention PARAMS ((struct breakpoint *));
106 static struct breakpoint *
107 set_raw_breakpoint PARAMS ((struct symtab_and_line));
110 check_duplicates PARAMS ((CORE_ADDR));
113 describe_other_breakpoints PARAMS ((CORE_ADDR));
116 breakpoints_info PARAMS ((char *, int));
119 breakpoint_1 PARAMS ((int, int));
122 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
125 breakpoint_cond_eval PARAMS ((char *));
128 cleanup_executing_breakpoints PARAMS ((int));
131 commands_command PARAMS ((char *, int));
134 condition_command PARAMS ((char *, int));
137 get_number PARAMS ((char **));
140 set_breakpoint_count PARAMS ((int));
143 remove_breakpoint PARAMS ((struct breakpoint *));
145 extern int addressprint; /* Print machine addresses? */
147 /* Are we executing breakpoint commands? */
148 static int executing_breakpoint_commands;
150 /* Walk the following statement or block through all breakpoints.
151 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
154 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
156 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
157 for (b = breakpoint_chain; \
158 b? (tmp=b->next, 1): 0; \
161 /* By default no support for hardware watchpoints is assumed. */
162 #ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT
163 #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
164 #define target_remove_watchpoint(ADDR,LEN,TYPE) -1
165 #define target_insert_watchpoint(ADDR,LEN,TYPE) -1
168 #ifndef target_insert_hw_breakpoint
169 #define target_remove_hw_breakpoint(ADDR,SHADOW) -1
170 #define target_insert_hw_breakpoint(ADDR,SHADOW) -1
173 #ifndef target_stopped_data_address
174 #define target_stopped_data_address() 0
177 /* True if breakpoint hit counts should be displayed in breakpoint info. */
179 int show_breakpoint_hit_counts = 1;
181 /* Chain of all breakpoints defined. */
183 static struct breakpoint *breakpoint_chain;
185 /* Number of last breakpoint made. */
187 static int breakpoint_count;
189 /* Set breakpoint count to NUM. */
192 set_breakpoint_count (num)
195 breakpoint_count = num;
196 set_internalvar (lookup_internalvar ("bpnum"),
197 value_from_longest (builtin_type_int, (LONGEST) num));
200 /* Used in run_command to zero the hit count when a new run starts. */
203 clear_breakpoint_hit_counts ()
205 struct breakpoint *b;
211 /* Default address, symtab and line to put a breakpoint at
212 for "break" command with no arg.
213 if default_breakpoint_valid is zero, the other three are
214 not valid, and "break" with no arg is an error.
216 This set by print_stack_frame, which calls set_default_breakpoint. */
218 int default_breakpoint_valid;
219 CORE_ADDR default_breakpoint_address;
220 struct symtab *default_breakpoint_symtab;
221 int default_breakpoint_line;
223 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
224 Advance *PP after the string and any trailing whitespace.
226 Currently the string can either be a number or "$" followed by the name
227 of a convenience variable. Making it an expression wouldn't work well
228 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
237 /* Empty line means refer to the last breakpoint. */
238 return breakpoint_count;
241 /* Make a copy of the name, so we can null-terminate it
242 to pass to lookup_internalvar(). */
247 while (isalnum (*p) || *p == '_')
249 varname = (char *) alloca (p - start + 1);
250 strncpy (varname, start, p - start);
251 varname[p - start] = '\0';
252 val = value_of_internalvar (lookup_internalvar (varname));
253 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
255 "Convenience variables used to specify breakpoints must have integer values."
257 retval = (int) value_as_long (val);
263 while (*p >= '0' && *p <= '9')
266 /* There is no number here. (e.g. "cond a == b"). */
267 error_no_arg ("breakpoint number");
270 if (!(isspace (*p) || *p == '\0'))
271 error ("breakpoint number expected");
278 /* condition N EXP -- set break condition of breakpoint N to EXP. */
281 condition_command (arg, from_tty)
285 register struct breakpoint *b;
290 error_no_arg ("breakpoint number");
293 bnum = get_number (&p);
296 if (b->number == bnum)
303 if (b->cond_string != NULL)
304 free ((PTR)b->cond_string);
309 b->cond_string = NULL;
311 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
316 /* I don't know if it matters whether this is the string the user
317 typed in or the decompiled expression. */
318 b->cond_string = savestring (arg, strlen (arg));
319 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
321 error ("Junk at end of expression");
326 error ("No breakpoint number %d.", bnum);
331 commands_command (arg, from_tty)
335 register struct breakpoint *b;
338 struct command_line *l;
340 /* If we allowed this, we would have problems with when to
341 free the storage, if we change the commands currently
344 if (executing_breakpoint_commands)
345 error ("Can't use the \"commands\" command among a breakpoint's commands.");
348 bnum = get_number (&p);
350 error ("Unexpected extra arguments following breakpoint number.");
353 if (b->number == bnum)
355 if (from_tty && input_from_terminal_p ())
356 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
357 End with a line saying just \"end\".\n", bnum);
358 l = read_command_lines ();
359 free_command_lines (&b->commands);
361 breakpoints_changed ();
364 error ("No breakpoint number %d.", bnum);
367 extern int memory_breakpoint_size; /* from mem-break.c */
369 /* Like target_read_memory() but if breakpoints are inserted, return
370 the shadow contents instead of the breakpoints themselves.
372 Read "memory data" from whatever target or inferior we have.
373 Returns zero if successful, errno value if not. EIO is used
374 for address out of bounds. If breakpoints are inserted, returns
375 shadow contents, not the breakpoints themselves. From breakpoint.c. */
378 read_memory_nobpt (memaddr, myaddr, len)
384 struct breakpoint *b;
386 if (memory_breakpoint_size < 0)
387 /* No breakpoints on this machine. FIXME: This should be
388 dependent on the debugging target. Probably want
389 target_insert_breakpoint to return a size, saying how many
390 bytes of the shadow contents are used, or perhaps have
391 something like target_xfer_shadow. */
392 return target_read_memory (memaddr, myaddr, len);
396 if (b->type == bp_watchpoint
397 || b->type == bp_hardware_watchpoint
398 || b->type == bp_read_watchpoint
399 || b->type == bp_access_watchpoint
402 else if (b->address + memory_breakpoint_size <= memaddr)
403 /* The breakpoint is entirely before the chunk of memory
406 else if (b->address >= memaddr + len)
407 /* The breakpoint is entirely after the chunk of memory we
412 /* Copy the breakpoint from the shadow contents, and recurse
413 for the things before and after. */
415 /* Addresses and length of the part of the breakpoint that
417 CORE_ADDR membpt = b->address;
418 unsigned int bptlen = memory_breakpoint_size;
419 /* Offset within shadow_contents. */
422 if (membpt < memaddr)
424 /* Only copy the second part of the breakpoint. */
425 bptlen -= memaddr - membpt;
426 bptoffset = memaddr - membpt;
430 if (membpt + bptlen > memaddr + len)
432 /* Only copy the first part of the breakpoint. */
433 bptlen -= (membpt + bptlen) - (memaddr + len);
436 memcpy (myaddr + membpt - memaddr,
437 b->shadow_contents + bptoffset, bptlen);
439 if (membpt > memaddr)
441 /* Copy the section of memory before the breakpoint. */
442 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
447 if (membpt + bptlen < memaddr + len)
449 /* Copy the section of memory after the breakpoint. */
450 status = read_memory_nobpt
452 myaddr + membpt + bptlen - memaddr,
453 memaddr + len - (membpt + bptlen));
460 /* Nothing overlaps. Just call read_memory_noerr. */
461 return target_read_memory (memaddr, myaddr, len);
464 /* insert_breakpoints is used when starting or continuing the program.
465 remove_breakpoints is used when the program stops.
466 Both return zero if successful,
467 or an `errno' value if could not write the inferior. */
470 insert_breakpoints ()
472 register struct breakpoint *b;
474 int disabled_breaks = 0;
477 if (b->type != bp_watchpoint
478 && b->type != bp_hardware_watchpoint
479 && b->type != bp_read_watchpoint
480 && b->type != bp_access_watchpoint
481 && b->enable != disabled
485 if (b->type == bp_hardware_breakpoint)
486 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
488 val = target_insert_breakpoint(b->address, b->shadow_contents);
491 /* Can't set the breakpoint. */
492 #if defined (DISABLE_UNSETTABLE_BREAK)
493 if (DISABLE_UNSETTABLE_BREAK (b->address))
496 b->enable = disabled;
497 if (!disabled_breaks)
499 target_terminal_ours_for_output ();
500 fprintf_unfiltered (gdb_stderr,
501 "Cannot insert breakpoint %d:\n", b->number);
502 printf_filtered ("Disabling shared library breakpoints:\n");
505 printf_filtered ("%d ", b->number);
510 target_terminal_ours_for_output ();
511 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
512 #ifdef ONE_PROCESS_WRITETEXT
513 fprintf_unfiltered (gdb_stderr,
514 "The same program may be running in another process.\n");
516 memory_error (val, b->address); /* which bombs us out */
522 else if ((b->type == bp_hardware_watchpoint ||
523 b->type == bp_read_watchpoint ||
524 b->type == bp_access_watchpoint)
525 && b->enable == enabled
530 int saved_level, within_current_scope;
531 value_ptr mark = value_mark ();
534 /* Save the current frame and level so we can restore it after
535 evaluating the watchpoint expression on its own frame. */
536 saved_frame = selected_frame;
537 saved_level = selected_frame_level;
539 /* Determine if the watchpoint is within scope. */
540 if (b->exp_valid_block == NULL)
541 within_current_scope = 1;
544 FRAME fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
545 within_current_scope = (fr != NULL);
546 if (within_current_scope)
547 select_frame (fr, -1);
550 if (within_current_scope)
552 /* Evaluate the expression and cut the chain of values
553 produced off from the value chain. */
554 v = evaluate_expression (b->exp);
555 value_release_to_mark (mark);
560 /* Look at each value on the value chain. */
561 for ( ; v; v=v->next)
563 /* If it's a memory location, then we must watch it. */
564 if (v->lval == lval_memory)
568 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
569 len = TYPE_LENGTH (VALUE_TYPE (v));
571 if (b->type == bp_read_watchpoint)
573 else if (b->type == bp_access_watchpoint)
576 val = target_insert_watchpoint (addr, len, type);
585 /* Failure to insert a watchpoint on any memory value in the
586 value chain brings us here. */
588 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
594 Hardware watchpoint %d deleted because the program has left the block in\n\
595 which its expression is valid.\n", b->number);
596 if (b->related_breakpoint)
597 delete_breakpoint (b->related_breakpoint);
598 delete_breakpoint (b);
601 /* Restore the frame and level. */
602 select_frame (saved_frame, saved_level);
605 printf_filtered ("\n");
611 remove_breakpoints ()
613 register struct breakpoint *b;
620 val = remove_breakpoint (b);
630 remove_breakpoint (b)
631 struct breakpoint *b;
635 if (b->type != bp_watchpoint
636 && b->type != bp_hardware_watchpoint
637 && b->type != bp_read_watchpoint
638 && b->type != bp_access_watchpoint)
640 if (b->type == bp_hardware_breakpoint)
641 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
643 val = target_remove_breakpoint(b->address, b->shadow_contents);
648 else if ((b->type == bp_hardware_watchpoint ||
649 b->type == bp_read_watchpoint ||
650 b->type == bp_access_watchpoint)
651 && b->enable == enabled
657 /* Walk down the saved value chain. */
658 for (v = b->val_chain; v; v = v->next)
660 /* For each memory reference remove the watchpoint
662 if (v->lval == lval_memory)
666 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
667 len = TYPE_LENGTH (VALUE_TYPE (v));
668 val = target_remove_watchpoint (addr, len, b->type);
674 /* Failure to remove any of the hardware watchpoints comes here. */
676 error ("Hardware watchpoint %d: Could not remove watchpoint\n",
679 /* Free the saved value chain. We will construct a new one
680 the next time the watchpoint is inserted. */
681 for (v = b->val_chain; v; v = n)
691 /* Clear the "inserted" flag in all breakpoints. */
694 mark_breakpoints_out ()
696 register struct breakpoint *b;
702 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
703 which should go away between runs of the program. */
706 breakpoint_init_inferior ()
708 register struct breakpoint *b, *temp;
710 ALL_BREAKPOINTS_SAFE (b, temp)
714 /* If the call dummy breakpoint is at the entry point it will
715 cause problems when the inferior is rerun, so we better
717 if (b->type == bp_call_dummy)
718 delete_breakpoint (b);
720 /* Likewise for scope breakpoints. */
721 if (b->type == bp_watchpoint_scope)
722 delete_breakpoint (b);
724 /* Likewise for watchpoints on local expressions. */
725 if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint ||
726 b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
727 && b->exp_valid_block != NULL)
728 delete_breakpoint (b);
732 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
733 When continuing from a location with a breakpoint,
734 we actually single step once before calling insert_breakpoints. */
737 breakpoint_here_p (pc)
740 register struct breakpoint *b;
743 if (b->enable != disabled && b->address == pc)
749 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
750 because figuring out the saved SP would take too much time, at least using
751 get_saved_register on the 68k. This means that for this function to
752 work right a port must use the bp_call_dummy breakpoint. */
755 frame_in_dummy (frame)
758 struct breakpoint *b;
763 static unsigned LONGEST dummy[] = CALL_DUMMY;
765 if (b->type == bp_call_dummy
766 && b->frame == frame->frame
768 /* We need to check the PC as well as the frame on the sparc,
769 for signals.exp in the testsuite. */
772 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
773 && frame->pc <= b->address)
776 #endif /* CALL_DUMMY */
780 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
781 is valid for process/thread PID. */
784 breakpoint_thread_match (pc, pid)
788 struct breakpoint *b;
791 thread = pid_to_thread_id (pid);
794 if (b->enable != disabled
796 && (b->thread == -1 || b->thread == thread))
803 /* bpstat stuff. External routines' interfaces are documented
806 /* Clear a bpstat so that it says we are not at any breakpoint.
807 Also free any storage that is part of a bpstat. */
822 if (p->old_val != NULL)
823 value_free (p->old_val);
830 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
831 is part of the bpstat is copied as well. */
839 bpstat retval = NULL;
844 for (; bs != NULL; bs = bs->next)
846 tmp = (bpstat) xmalloc (sizeof (*tmp));
847 memcpy (tmp, bs, sizeof (*tmp));
849 /* This is the first thing in the chain. */
859 /* Find the bpstat associated with this breakpoint */
862 bpstat_find_breakpoint(bsp, breakpoint)
864 struct breakpoint *breakpoint;
866 if (bsp == NULL) return NULL;
868 for (;bsp != NULL; bsp = bsp->next) {
869 if (bsp->breakpoint_at == breakpoint) return bsp;
874 /* Return the breakpoint number of the first breakpoint we are stopped
875 at. *BSP upon return is a bpstat which points to the remaining
876 breakpoints stopped at (but which is not guaranteed to be good for
877 anything but further calls to bpstat_num).
878 Return 0 if passed a bpstat which does not indicate any breakpoints. */
884 struct breakpoint *b;
887 return 0; /* No more breakpoint values */
890 b = (*bsp)->breakpoint_at;
893 return -1; /* breakpoint that's been deleted since */
895 return b->number; /* We have its number */
899 /* Modify BS so that the actions will not be performed. */
902 bpstat_clear_actions (bs)
905 for (; bs != NULL; bs = bs->next)
908 if (bs->old_val != NULL)
910 value_free (bs->old_val);
916 /* Stub for cleaning up our state if we error-out of a breakpoint command */
919 cleanup_executing_breakpoints (ignore)
922 executing_breakpoint_commands = 0;
925 /* Execute all the commands associated with all the breakpoints at this
926 location. Any of these commands could cause the process to proceed
927 beyond this point, etc. We look out for such changes by checking
928 the global "breakpoint_proceeded" after each command. */
931 bpstat_do_actions (bsp)
935 struct cleanup *old_chain;
937 executing_breakpoint_commands = 1;
938 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
943 breakpoint_proceeded = 0;
944 for (; bs != NULL; bs = bs->next)
948 char *line = bs->commands->line;
949 bs->commands = bs->commands->next;
950 execute_command (line, 0);
951 /* If the inferior is proceeded by the command, bomb out now.
952 The bpstat chain has been blown away by wait_for_inferior.
953 But since execution has stopped again, there is a new bpstat
954 to look at, so start over. */
955 if (breakpoint_proceeded)
960 executing_breakpoint_commands = 0;
961 discard_cleanups (old_chain);
964 /* This is the normal print_it function for a bpstat. In the future,
965 much of this logic could (should?) be moved to bpstat_stop_status,
966 by having it set different print_it functions. */
972 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
973 which has since been deleted. */
974 if (bs->breakpoint_at == NULL
975 || (bs->breakpoint_at->type != bp_breakpoint
976 && bs->breakpoint_at->type != bp_hardware_breakpoint
977 && bs->breakpoint_at->type != bp_watchpoint
978 && bs->breakpoint_at->type != bp_read_watchpoint
979 && bs->breakpoint_at->type != bp_access_watchpoint
980 && bs->breakpoint_at->type != bp_hardware_watchpoint))
983 if (bs->breakpoint_at->type == bp_breakpoint ||
984 bs->breakpoint_at->type == bp_hardware_breakpoint)
986 /* I think the user probably only wants to see one breakpoint
987 number, not all of them. */
988 annotate_breakpoint (bs->breakpoint_at->number);
989 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
992 else if ((bs->old_val != NULL) &&
993 (bs->breakpoint_at->type == bp_watchpoint ||
994 bs->breakpoint_at->type == bp_access_watchpoint ||
995 bs->breakpoint_at->type == bp_hardware_watchpoint))
997 annotate_watchpoint (bs->breakpoint_at->number);
998 mention (bs->breakpoint_at);
999 printf_filtered ("\nOld value = ");
1000 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
1001 printf_filtered ("\nNew value = ");
1002 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1003 Val_pretty_default);
1004 printf_filtered ("\n");
1005 value_free (bs->old_val);
1007 /* More than one watchpoint may have been triggered. */
1010 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
1011 bs->breakpoint_at->type == bp_read_watchpoint)
1013 mention (bs->breakpoint_at);
1014 printf_filtered ("\nValue = ");
1015 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1016 Val_pretty_default);
1017 printf_filtered ("\n");
1020 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1024 /* Print a message indicating what happened. Returns nonzero to
1025 say that only the source line should be printed after this (zero
1026 return means print the frame as well as the source line). */
1027 /* Currently we always return zero. */
1037 val = (*bs->print_it) (bs);
1041 /* Maybe another breakpoint in the chain caused us to stop.
1042 (Currently all watchpoints go on the bpstat whether hit or
1043 not. That probably could (should) be changed, provided care is taken
1044 with respect to bpstat_explains_signal). */
1046 return bpstat_print (bs->next);
1048 /* We reached the end of the chain without printing anything. */
1052 /* Evaluate the expression EXP and return 1 if value is zero.
1053 This is used inside a catch_errors to evaluate the breakpoint condition.
1054 The argument is a "struct expression *" that has been cast to char * to
1055 make it pass through catch_errors. */
1058 breakpoint_cond_eval (exp)
1061 value_ptr mark = value_mark ();
1062 int i = !value_true (evaluate_expression ((struct expression *)exp));
1063 value_free_to_mark (mark);
1067 /* Allocate a new bpstat and chain it to the current one. */
1070 bpstat_alloc (b, cbs)
1071 register struct breakpoint *b;
1072 bpstat cbs; /* Current "bs" value */
1076 bs = (bpstat) xmalloc (sizeof (*bs));
1078 bs->breakpoint_at = b;
1079 /* If the condition is false, etc., don't do the commands. */
1080 bs->commands = NULL;
1082 bs->print_it = print_it_normal;
1088 /* Possible return values for watchpoint_check (this can't be an enum
1089 because of check_errors). */
1090 /* The watchpoint has been deleted. */
1091 #define WP_DELETED 1
1092 /* The value has changed. */
1093 #define WP_VALUE_CHANGED 2
1094 /* The value has not changed. */
1095 #define WP_VALUE_NOT_CHANGED 3
1097 /* Check watchpoint condition. */
1099 watchpoint_check (p)
1102 bpstat bs = (bpstat) p;
1103 struct breakpoint *b;
1104 FRAME saved_frame, fr;
1105 int within_current_scope, saved_level;
1107 /* Save the current frame and level so we can restore it after
1108 evaluating the watchpoint expression on its own frame. */
1109 saved_frame = selected_frame;
1110 saved_level = selected_frame_level;
1112 if (bs->breakpoint_at->exp_valid_block == NULL)
1113 within_current_scope = 1;
1116 fr = find_frame_addr_in_frame_chain (bs->breakpoint_at->watchpoint_frame);
1117 within_current_scope = (fr != NULL);
1118 if (within_current_scope)
1119 /* If we end up stopping, the current frame will get selected
1120 in normal_stop. So this call to select_frame won't affect
1122 select_frame (fr, -1);
1125 if (within_current_scope)
1127 /* We use value_{,free_to_}mark because it could be a
1128 *long* time before we return to the command level and
1129 call free_all_values. We can't call free_all_values because
1130 we might be in the middle of evaluating a function call. */
1132 value_ptr mark = value_mark ();
1133 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1134 if (!value_equal (bs->breakpoint_at->val, new_val))
1136 release_value (new_val);
1137 value_free_to_mark (mark);
1138 bs->old_val = bs->breakpoint_at->val;
1139 bs->breakpoint_at->val = new_val;
1140 /* We will stop here */
1141 select_frame (saved_frame, saved_level);
1142 return WP_VALUE_CHANGED;
1146 /* Nothing changed, don't do anything. */
1147 value_free_to_mark (mark);
1148 /* We won't stop here */
1149 select_frame (saved_frame, saved_level);
1150 return WP_VALUE_NOT_CHANGED;
1155 /* This seems like the only logical thing to do because
1156 if we temporarily ignored the watchpoint, then when
1157 we reenter the block in which it is valid it contains
1158 garbage (in the case of a function, it may have two
1159 garbage values, one before and one after the prologue).
1160 So we can't even detect the first assignment to it and
1161 watch after that (since the garbage may or may not equal
1162 the first value assigned). */
1164 Watchpoint %d deleted because the program has left the block in\n\
1165 which its expression is valid.\n", bs->breakpoint_at->number);
1166 if (bs->breakpoint_at->related_breakpoint)
1167 delete_breakpoint (bs->breakpoint_at->related_breakpoint);
1168 delete_breakpoint (bs->breakpoint_at);
1170 select_frame (saved_frame, saved_level);
1175 /* This is used when everything which needs to be printed has
1176 already been printed. But we still want to print the frame. */
1184 /* This is used when nothing should be printed for this bpstat entry. */
1193 /* Get a bpstat associated with having just stopped at address *PC
1194 and frame address FRAME_ADDRESS. Update *PC to point at the
1195 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1196 if this is known to not be a real breakpoint (it could still be a
1197 watchpoint, though). */
1199 /* Determine whether we stopped at a breakpoint, etc, or whether we
1200 don't understand this stop. Result is a chain of bpstat's such that:
1202 if we don't understand the stop, the result is a null pointer.
1204 if we understand why we stopped, the result is not null.
1206 Each element of the chain refers to a particular breakpoint or
1207 watchpoint at which we have stopped. (We may have stopped for
1208 several reasons concurrently.)
1210 Each element of the chain has valid next, breakpoint_at,
1211 commands, FIXME??? fields.
1216 bpstat_stop_status (pc, frame_address, not_a_breakpoint)
1218 FRAME_ADDR frame_address;
1219 int not_a_breakpoint;
1221 register struct breakpoint *b;
1223 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1224 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1225 int real_breakpoint = 0;
1227 /* Root of the chain of bpstat's */
1228 struct bpstat root_bs[1];
1229 /* Pointer to the last thing in the chain currently. */
1230 bpstat bs = root_bs;
1231 static char message1[] =
1232 "Error evaluating expression for watchpoint %d\n";
1233 char message[sizeof (message1) + 30 /* slop */];
1235 /* Get the address where the breakpoint would have been. */
1236 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1240 if (b->enable == disabled)
1243 if (b->type != bp_watchpoint
1244 && b->type != bp_hardware_watchpoint
1245 && b->type != bp_read_watchpoint
1246 && b->type != bp_access_watchpoint
1247 && b->type != bp_hardware_breakpoint
1248 && b->address != bp_addr)
1251 #ifndef DECR_PC_AFTER_HW_BREAK
1252 #define DECR_PC_AFTER_HW_BREAK 0
1254 if (b->type == bp_hardware_breakpoint
1255 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
1258 if (b->type != bp_watchpoint
1259 && b->type != bp_hardware_watchpoint
1260 && b->type != bp_read_watchpoint
1261 && b->type != bp_access_watchpoint
1262 && not_a_breakpoint)
1265 /* Come here if it's a watchpoint, or if the break address matches */
1269 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1274 sprintf (message, message1, b->number);
1275 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
1277 switch (catch_errors (watchpoint_check, (char *) bs, message,
1281 /* We've already printed what needs to be printed. */
1282 bs->print_it = print_it_done;
1285 case WP_VALUE_CHANGED:
1288 case WP_VALUE_NOT_CHANGED:
1290 bs->print_it = print_it_noop;
1297 /* Error from catch_errors. */
1298 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1299 if (b->related_breakpoint)
1300 delete_breakpoint (b->related_breakpoint);
1301 delete_breakpoint (b);
1302 /* We've already printed what needs to be printed. */
1303 bs->print_it = print_it_done;
1309 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
1315 addr = target_stopped_data_address();
1316 if (addr == 0) continue;
1317 for (v = b->val_chain; v; v = v->next)
1319 if (v->lval == lval_memory)
1323 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1329 switch (catch_errors (watchpoint_check, (char *) bs, message,
1333 /* We've already printed what needs to be printed. */
1334 bs->print_it = print_it_done;
1337 case WP_VALUE_CHANGED:
1338 case WP_VALUE_NOT_CHANGED:
1344 /* Error from catch_errors. */
1345 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1346 if (b->related_breakpoint)
1347 delete_breakpoint (b->related_breakpoint);
1348 delete_breakpoint (b);
1349 /* We've already printed what needs to be printed. */
1350 bs->print_it = print_it_done;
1354 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1356 real_breakpoint = 1;
1359 if (b->frame && b->frame != frame_address)
1363 int value_is_zero = 0;
1367 /* Need to select the frame, with all that implies
1368 so that the conditions will have the right context. */
1369 select_frame (get_current_frame (), 0);
1371 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1372 "Error in testing breakpoint condition:\n",
1374 /* FIXME-someday, should give breakpoint # */
1377 if (b->cond && value_is_zero)
1381 else if (b->ignore_count > 0)
1388 /* We will stop here */
1389 if (b->disposition == disable)
1390 b->enable = disabled;
1391 bs->commands = b->commands;
1394 if (bs->commands && STREQ ("silent", bs->commands->line))
1396 bs->commands = bs->commands->next;
1401 /* Print nothing for this entry if we dont stop or if we dont print. */
1402 if (bs->stop == 0 || bs->print == 0)
1403 bs->print_it = print_it_noop;
1406 bs->next = NULL; /* Terminate the chain */
1407 bs = root_bs->next; /* Re-grab the head of the chain */
1408 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1411 if (real_breakpoint)
1414 #if defined (SHIFT_INST_REGS)
1416 #else /* No SHIFT_INST_REGS. */
1418 #endif /* No SHIFT_INST_REGS. */
1421 #endif /* DECR_PC_AFTER_BREAK != 0. */
1423 /* The value of a hardware watchpoint hasn't changed, but the
1424 intermediate memory locations we are watching may have. */
1425 if (bs && ! bs->stop &&
1426 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
1427 bs->breakpoint_at->type == bp_read_watchpoint ||
1428 bs->breakpoint_at->type == bp_access_watchpoint))
1430 remove_breakpoints ();
1431 insert_breakpoints ();
1436 /* Tell what to do about this bpstat. */
1441 /* Classify each bpstat as one of the following. */
1443 /* This bpstat element has no effect on the main_action. */
1446 /* There was a watchpoint, stop but don't print. */
1449 /* There was a watchpoint, stop and print. */
1452 /* There was a breakpoint but we're not stopping. */
1455 /* There was a breakpoint, stop but don't print. */
1458 /* There was a breakpoint, stop and print. */
1461 /* We hit the longjmp breakpoint. */
1464 /* We hit the longjmp_resume breakpoint. */
1467 /* We hit the step_resume breakpoint. */
1470 /* We hit the through_sigtramp breakpoint. */
1473 /* This is just used to count how many enums there are. */
1477 /* Here is the table which drives this routine. So that we can
1478 format it pretty, we define some abbreviations for the
1479 enum bpstat_what codes. */
1480 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1481 #define stop_s BPSTAT_WHAT_STOP_SILENT
1482 #define stop_n BPSTAT_WHAT_STOP_NOISY
1483 #define single BPSTAT_WHAT_SINGLE
1484 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1485 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1486 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1487 #define sr BPSTAT_WHAT_STEP_RESUME
1488 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1490 /* "Can't happen." Might want to print an error message.
1491 abort() is not out of the question, but chances are GDB is just
1492 a bit confused, not unusable. */
1493 #define err BPSTAT_WHAT_STOP_NOISY
1495 /* Given an old action and a class, come up with a new action. */
1496 /* One interesting property of this table is that wp_silent is the same
1497 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1498 after stopping, the check for whether to step over a breakpoint
1499 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1500 reference to how we stopped. We retain separate wp_silent and bp_silent
1501 codes in case we want to change that someday. */
1503 /* step_resume entries: a step resume breakpoint overrides another
1504 breakpoint of signal handling (see comment in wait_for_inferior
1505 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1506 /* We handle the through_sigtramp_breakpoint the same way; having both
1507 one of those and a step_resume_breakpoint is probably very rare (?). */
1509 static const enum bpstat_what_main_action
1510 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1513 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr ts
1515 /*no_effect*/ {keep_c,stop_s,stop_n,single, setlr , clrlr , clrlrs, sr, ts},
1516 /*wp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1517 /*wp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1518 /*bp_nostop*/ {single,stop_s,stop_n,single, setlr , clrlrs, clrlrs, sr, ts},
1519 /*bp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1520 /*bp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1521 /*long_jump*/ {setlr ,stop_s,stop_n,setlr , err , err , err , sr, ts},
1522 /*long_resume*/ {clrlr ,stop_s,stop_n,clrlrs, err , err , err , sr, ts},
1523 /*step_resume*/ {sr ,sr ,sr ,sr , sr , sr , sr , sr, ts},
1524 /*through_sig*/ {ts ,ts ,ts ,ts , ts , ts , ts , ts, ts}
1536 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1537 struct bpstat_what retval;
1539 retval.call_dummy = 0;
1540 for (; bs != NULL; bs = bs->next)
1542 enum class bs_class = no_effect;
1543 if (bs->breakpoint_at == NULL)
1544 /* I suspect this can happen if it was a momentary breakpoint
1545 which has since been deleted. */
1547 switch (bs->breakpoint_at->type)
1550 case bp_hardware_breakpoint:
1556 bs_class = bp_noisy;
1558 bs_class = bp_silent;
1561 bs_class = bp_nostop;
1564 case bp_hardware_watchpoint:
1565 case bp_read_watchpoint:
1566 case bp_access_watchpoint:
1570 bs_class = wp_noisy;
1572 bs_class = wp_silent;
1575 /* There was a watchpoint, but we're not stopping. This requires
1576 no further action. */
1577 bs_class = no_effect;
1580 bs_class = long_jump;
1582 case bp_longjmp_resume:
1583 bs_class = long_resume;
1585 case bp_step_resume:
1588 bs_class = step_resume;
1591 /* It is for the wrong frame. */
1592 bs_class = bp_nostop;
1594 case bp_through_sigtramp:
1595 bs_class = through_sig;
1597 case bp_watchpoint_scope:
1598 bs_class = bp_nostop;
1602 /* Make sure the action is stop (silent or noisy), so infrun.c
1603 pops the dummy frame. */
1604 bs_class = bp_silent;
1605 retval.call_dummy = 1;
1608 current_action = table[(int)bs_class][(int)current_action];
1610 retval.main_action = current_action;
1614 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1615 without hardware support). This isn't related to a specific bpstat,
1616 just to things like whether watchpoints are set. */
1619 bpstat_should_step ()
1621 struct breakpoint *b;
1623 if (b->enable == enabled && b->type == bp_watchpoint)
1628 /* Print information on breakpoint number BNUM, or -1 if all.
1629 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1630 is nonzero, process only watchpoints. */
1633 breakpoint_1 (bnum, allflag)
1637 register struct breakpoint *b;
1638 register struct command_line *l;
1639 register struct symbol *sym;
1640 CORE_ADDR last_addr = (CORE_ADDR)-1;
1641 int found_a_breakpoint = 0;
1642 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1643 "until", "finish", "watchpoint",
1644 "hw watchpoint", "read watchpoint",
1645 "acc watchpoint", "longjmp",
1646 "longjmp resume", "step resume",
1647 "watchpoint scope", "call dummy" };
1648 static char *bpdisps[] = {"del", "dis", "keep"};
1649 static char bpenables[] = "ny";
1650 char wrap_indent[80];
1654 || bnum == b->number)
1656 /* We only print out user settable breakpoints unless the allflag is set. */
1658 && b->type != bp_breakpoint
1659 && b->type != bp_hardware_breakpoint
1660 && b->type != bp_watchpoint
1661 && b->type != bp_read_watchpoint
1662 && b->type != bp_access_watchpoint
1663 && b->type != bp_hardware_watchpoint)
1666 if (!found_a_breakpoint++)
1668 annotate_breakpoints_headers ();
1671 printf_filtered ("Num ");
1673 printf_filtered ("Type ");
1675 printf_filtered ("Disp ");
1677 printf_filtered ("Enb ");
1681 printf_filtered ("Address ");
1684 printf_filtered ("What\n");
1686 annotate_breakpoints_table ();
1691 printf_filtered ("%-3d ", b->number);
1693 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1695 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1697 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1699 strcpy (wrap_indent, " ");
1701 strcat (wrap_indent, " ");
1705 case bp_hardware_watchpoint:
1706 case bp_read_watchpoint:
1707 case bp_access_watchpoint:
1708 /* Field 4, the address, is omitted (which makes the columns
1709 not line up too nicely with the headers, but the effect
1710 is relatively readable). */
1712 print_expression (b->exp, gdb_stdout);
1716 case bp_hardware_breakpoint:
1720 case bp_longjmp_resume:
1721 case bp_step_resume:
1722 case bp_through_sigtramp:
1723 case bp_watchpoint_scope:
1728 /* FIXME-32x64: need a print_address_numeric with
1732 local_hex_string_custom
1733 ((unsigned long) b->address, "08l"));
1738 last_addr = b->address;
1741 sym = find_pc_function (b->address);
1744 fputs_filtered ("in ", gdb_stdout);
1745 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1746 wrap_here (wrap_indent);
1747 fputs_filtered (" at ", gdb_stdout);
1749 fputs_filtered (b->source_file, gdb_stdout);
1750 printf_filtered (":%d", b->line_number);
1753 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1757 printf_filtered ("\n");
1763 printf_filtered ("\tstop only in stack frame at ");
1764 print_address_numeric (b->frame, 1, gdb_stdout);
1765 printf_filtered ("\n");
1772 printf_filtered ("\tstop only if ");
1773 print_expression (b->cond, gdb_stdout);
1774 printf_filtered ("\n");
1777 if (show_breakpoint_hit_counts && b->hit_count)
1779 /* FIXME should make an annotation for this */
1781 printf_filtered ("\tbreakpoint already hit %d times\n",
1785 if (b->ignore_count)
1789 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1792 if ((l = b->commands))
1798 fputs_filtered ("\t", gdb_stdout);
1799 fputs_filtered (l->line, gdb_stdout);
1800 fputs_filtered ("\n", gdb_stdout);
1806 if (!found_a_breakpoint)
1809 printf_filtered ("No breakpoints or watchpoints.\n");
1811 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1814 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1815 that a comparison of an unsigned with -1 is always false. */
1816 if (last_addr != (CORE_ADDR)-1)
1817 set_next_address (last_addr);
1819 annotate_breakpoints_table_end ();
1824 breakpoints_info (bnum_exp, from_tty)
1831 bnum = parse_and_eval_address (bnum_exp);
1833 breakpoint_1 (bnum, 0);
1836 #if MAINTENANCE_CMDS
1840 maintenance_info_breakpoints (bnum_exp, from_tty)
1847 bnum = parse_and_eval_address (bnum_exp);
1849 breakpoint_1 (bnum, 1);
1854 /* Print a message describing any breakpoints set at PC. */
1857 describe_other_breakpoints (pc)
1858 register CORE_ADDR pc;
1860 register int others = 0;
1861 register struct breakpoint *b;
1864 if (b->address == pc)
1868 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1870 if (b->address == pc)
1876 (b->enable == disabled) ? " (disabled)" : "",
1877 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1879 printf_filtered ("also set at pc ");
1880 print_address_numeric (pc, 1, gdb_stdout);
1881 printf_filtered (".\n");
1885 /* Set the default place to put a breakpoint
1886 for the `break' command with no arguments. */
1889 set_default_breakpoint (valid, addr, symtab, line)
1892 struct symtab *symtab;
1895 default_breakpoint_valid = valid;
1896 default_breakpoint_address = addr;
1897 default_breakpoint_symtab = symtab;
1898 default_breakpoint_line = line;
1901 /* Rescan breakpoints at address ADDRESS,
1902 marking the first one as "first" and any others as "duplicates".
1903 This is so that the bpt instruction is only inserted once. */
1906 check_duplicates (address)
1909 register struct breakpoint *b;
1910 register int count = 0;
1912 if (address == 0) /* Watchpoints are uninteresting */
1916 if (b->enable != disabled && b->address == address)
1919 b->duplicate = count > 1;
1923 /* Low level routine to set a breakpoint.
1924 Takes as args the three things that every breakpoint must have.
1925 Returns the breakpoint object so caller can set other things.
1926 Does not set the breakpoint number!
1927 Does not print anything.
1929 ==> This routine should not be called if there is a chance of later
1930 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1931 your arguments BEFORE calling this routine! */
1933 static struct breakpoint *
1934 set_raw_breakpoint (sal)
1935 struct symtab_and_line sal;
1937 register struct breakpoint *b, *b1;
1939 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1940 memset (b, 0, sizeof (*b));
1941 b->address = sal.pc;
1942 if (sal.symtab == NULL)
1943 b->source_file = NULL;
1945 b->source_file = savestring (sal.symtab->filename,
1946 strlen (sal.symtab->filename));
1948 b->line_number = sal.line;
1949 b->enable = enabled;
1952 b->ignore_count = 0;
1956 /* Add this breakpoint to the end of the chain
1957 so that a list of breakpoints will come out in order
1958 of increasing numbers. */
1960 b1 = breakpoint_chain;
1962 breakpoint_chain = b;
1970 check_duplicates (sal.pc);
1971 breakpoints_changed ();
1977 create_longjmp_breakpoint(func_name)
1980 struct symtab_and_line sal;
1981 struct breakpoint *b;
1982 static int internal_breakpoint_number = -1;
1984 if (func_name != NULL)
1986 struct minimal_symbol *m;
1988 m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
1990 sal.pc = SYMBOL_VALUE_ADDRESS (m);
2000 b = set_raw_breakpoint(sal);
2003 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
2004 b->disposition = donttouch;
2005 b->enable = disabled;
2008 b->addr_string = strsave(func_name);
2009 b->number = internal_breakpoint_number--;
2012 /* Call this routine when stepping and nexting to enable a breakpoint if we do
2013 a longjmp(). When we hit that breakpoint, call
2014 set_longjmp_resume_breakpoint() to figure out where we are going. */
2017 enable_longjmp_breakpoint()
2019 register struct breakpoint *b;
2022 if (b->type == bp_longjmp)
2024 b->enable = enabled;
2025 check_duplicates (b->address);
2030 disable_longjmp_breakpoint()
2032 register struct breakpoint *b;
2035 if ( b->type == bp_longjmp
2036 || b->type == bp_longjmp_resume)
2038 b->enable = disabled;
2039 check_duplicates (b->address);
2044 hw_breakpoint_used_count()
2046 register struct breakpoint *b;
2051 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2059 hw_watchpoint_used_count(type, other_type_used)
2061 int *other_type_used;
2063 register struct breakpoint *b;
2066 *other_type_used = 0;
2069 if (b->enable == enabled)
2071 if (b->type == type) i++;
2072 else if ((b->type == bp_hardware_watchpoint ||
2073 b->type == bp_read_watchpoint ||
2074 b->type == bp_access_watchpoint)
2075 && b->enable == enabled)
2076 *other_type_used = 1;
2082 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2083 breakpoint at the target of the jmp_buf.
2085 FIXME - This ought to be done by setting a temporary breakpoint that gets
2086 deleted automatically...
2090 set_longjmp_resume_breakpoint(pc, frame)
2094 register struct breakpoint *b;
2097 if (b->type == bp_longjmp_resume)
2100 b->enable = enabled;
2102 b->frame = FRAME_FP(frame);
2105 check_duplicates (b->address);
2110 /* Set a breakpoint that will evaporate an end of command
2111 at address specified by SAL.
2112 Restrict it to frame FRAME if FRAME is nonzero. */
2115 set_momentary_breakpoint (sal, frame, type)
2116 struct symtab_and_line sal;
2120 register struct breakpoint *b;
2121 b = set_raw_breakpoint (sal);
2123 b->enable = enabled;
2124 b->disposition = donttouch;
2125 b->frame = (frame ? FRAME_FP (frame) : 0);
2131 clear_momentary_breakpoints ()
2133 register struct breakpoint *b;
2135 if (b->disposition == delete)
2137 delete_breakpoint (b);
2143 /* Tell the user we have just set a breakpoint B. */
2147 struct breakpoint *b;
2154 printf_filtered ("Watchpoint %d: ", b->number);
2155 print_expression (b->exp, gdb_stdout);
2157 case bp_hardware_watchpoint:
2158 printf_filtered ("Hardware watchpoint %d: ", b->number);
2159 print_expression (b->exp, gdb_stdout);
2161 case bp_read_watchpoint:
2162 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2163 print_expression (b->exp, gdb_stdout);
2165 case bp_access_watchpoint:
2166 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2167 print_expression (b->exp, gdb_stdout);
2170 printf_filtered ("Breakpoint %d", b->number);
2173 case bp_hardware_breakpoint:
2174 printf_filtered ("Hardware assisted breakpoint %d", b->number);
2180 case bp_longjmp_resume:
2181 case bp_step_resume:
2182 case bp_through_sigtramp:
2184 case bp_watchpoint_scope:
2189 if (addressprint || b->source_file == NULL)
2191 printf_filtered (" at ");
2192 print_address_numeric (b->address, 1, gdb_stdout);
2195 printf_filtered (": file %s, line %d.",
2196 b->source_file, b->line_number);
2198 printf_filtered ("\n");
2202 /* Nobody calls this currently. */
2203 /* Set a breakpoint from a symtab and line.
2204 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2205 ADDR_STRING is a malloc'd string holding the name of where we are
2206 setting the breakpoint. This is used later to re-set it after the
2207 program is relinked and symbols are reloaded.
2208 Print the same confirmation messages that the breakpoint command prints. */
2211 set_breakpoint (s, line, tempflag, addr_string)
2217 register struct breakpoint *b;
2218 struct symtab_and_line sal;
2223 resolve_sal_pc (&sal); /* Might error out */
2224 describe_other_breakpoints (sal.pc);
2226 b = set_raw_breakpoint (sal);
2227 set_breakpoint_count (breakpoint_count + 1);
2228 b->number = breakpoint_count;
2229 b->type = bp_breakpoint;
2231 b->addr_string = addr_string;
2232 b->enable = enabled;
2233 b->disposition = tempflag ? delete : donttouch;
2239 /* Set a breakpoint according to ARG (function, linenum or *address)
2240 flag: first bit : 0 non-temporary, 1 temporary.
2241 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2244 break_command_1 (arg, flag, from_tty)
2248 int tempflag, hardwareflag;
2249 struct symtabs_and_lines sals;
2250 struct symtab_and_line sal;
2251 register struct expression *cond = 0;
2252 register struct breakpoint *b;
2254 /* Pointers in arg to the start, and one past the end, of the condition. */
2255 char *cond_start = NULL;
2256 char *cond_end = NULL;
2257 /* Pointers in arg to the start, and one past the end,
2258 of the address part. */
2259 char *addr_start = NULL;
2260 char *addr_end = NULL;
2261 struct cleanup *old_chain;
2262 struct cleanup *canonical_strings_chain = NULL;
2263 char **canonical = (char **)NULL;
2267 hardwareflag = flag & 2;
2268 tempflag = flag & 1;
2273 sal.line = sal.pc = sal.end = 0;
2276 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2278 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2279 && (arg[2] == ' ' || arg[2] == '\t')))
2281 if (default_breakpoint_valid)
2283 sals.sals = (struct symtab_and_line *)
2284 xmalloc (sizeof (struct symtab_and_line));
2285 sal.pc = default_breakpoint_address;
2286 sal.line = default_breakpoint_line;
2287 sal.symtab = default_breakpoint_symtab;
2292 error ("No default breakpoint address now.");
2298 /* Force almost all breakpoints to be in terms of the
2299 current_source_symtab (which is decode_line_1's default). This
2300 should produce the results we want almost all of the time while
2301 leaving default_breakpoint_* alone. */
2302 if (default_breakpoint_valid
2303 && (!current_source_symtab
2304 || (arg && (*arg == '+' || *arg == '-'))))
2305 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2306 default_breakpoint_line, &canonical);
2308 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2316 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2317 the following `for' loop errors out. */
2318 old_chain = make_cleanup (free, sals.sals);
2319 if (canonical != (char **)NULL)
2321 make_cleanup (free, canonical);
2322 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2323 for (i = 0; i < sals.nelts; i++)
2325 if (canonical[i] != NULL)
2326 make_cleanup (free, canonical[i]);
2330 thread = -1; /* No specific thread yet */
2332 /* Resolve all line numbers to PC's, and verify that conditions
2333 can be parsed, before setting any breakpoints. */
2334 for (i = 0; i < sals.nelts; i++)
2336 char *tok, *end_tok;
2339 resolve_sal_pc (&sals.sals[i]);
2345 while (*tok == ' ' || *tok == '\t')
2350 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2353 toklen = end_tok - tok;
2355 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2357 tok = cond_start = end_tok + 1;
2358 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2361 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2367 thread = strtol (tok, &tok, 0);
2369 error ("Junk after thread keyword.");
2370 if (!valid_thread_id (thread))
2371 error ("Unknown thread %d\n", thread);
2374 error ("Junk at end of arguments.");
2379 int i, other_type_used, target_resources_ok;
2380 i = hw_breakpoint_used_count();
2381 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2382 bp_hardware_breakpoint, i+sals.nelts, 0);
2383 if (target_resources_ok == 0)
2384 error ("No hardware breakpoint support in the target.");
2385 else if (target_resources_ok < 0)
2386 error ("Hardware breakpoints used exceeds limit.");
2389 /* Remove the canonical strings from the cleanup, they are needed below. */
2390 if (canonical != (char **)NULL)
2391 discard_cleanups (canonical_strings_chain);
2393 /* Now set all the breakpoints. */
2394 for (i = 0; i < sals.nelts; i++)
2399 describe_other_breakpoints (sal.pc);
2401 b = set_raw_breakpoint (sal);
2402 set_breakpoint_count (breakpoint_count + 1);
2403 b->number = breakpoint_count;
2404 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2408 /* If a canonical line spec is needed use that instead of the
2410 if (canonical != (char **)NULL && canonical[i] != NULL)
2411 b->addr_string = canonical[i];
2412 else if (addr_start)
2413 b->addr_string = savestring (addr_start, addr_end - addr_start);
2415 b->cond_string = savestring (cond_start, cond_end - cond_start);
2417 b->enable = enabled;
2418 b->disposition = tempflag ? delete : donttouch;
2425 printf_filtered ("Multiple breakpoints were set.\n");
2426 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2428 do_cleanups (old_chain);
2431 /* Helper function for break_command_1 and disassemble_command. */
2434 resolve_sal_pc (sal)
2435 struct symtab_and_line *sal;
2439 if (sal->pc == 0 && sal->symtab != 0)
2441 pc = find_line_pc (sal->symtab, sal->line);
2443 error ("No line %d in file \"%s\".",
2444 sal->line, sal->symtab->filename);
2449 #define BP_TEMPFLAG 1
2450 #define BP_HARDWAREFLAG 2
2452 break_command (arg, from_tty)
2456 break_command_1 (arg, 0, from_tty);
2460 tbreak_command (arg, from_tty)
2464 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2468 hbreak_command (arg, from_tty)
2472 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2476 thbreak_command (arg, from_tty)
2480 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2484 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2487 watch_command_1 (arg, accessflag, from_tty)
2492 struct breakpoint *b;
2493 struct symtab_and_line sal;
2494 struct expression *exp;
2495 struct block *exp_valid_block;
2496 struct value *val, *mark;
2497 FRAME frame, prev_frame;
2498 char *exp_start = NULL;
2499 char *exp_end = NULL;
2500 char *tok, *end_tok;
2502 char *cond_start = NULL;
2503 char *cond_end = NULL;
2504 struct expression *cond = NULL;
2505 int i, other_type_used, target_resources_ok;
2506 enum bptype bp_type;
2513 /* Parse arguments. */
2514 innermost_block = NULL;
2516 exp = parse_exp_1 (&arg, 0, 0);
2518 exp_valid_block = innermost_block;
2519 mark = value_mark ();
2520 val = evaluate_expression (exp);
2521 release_value (val);
2522 if (VALUE_LAZY (val))
2523 value_fetch_lazy (val);
2526 while (*tok == ' ' || *tok == '\t')
2530 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2533 toklen = end_tok - tok;
2534 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2536 tok = cond_start = end_tok + 1;
2537 cond = parse_exp_1 (&tok, 0, 0);
2541 error("Junk at end of command.");
2543 if (accessflag == 1) bp_type = bp_read_watchpoint;
2544 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2545 else bp_type = bp_hardware_watchpoint;
2547 mem_cnt = can_use_hardware_watchpoint (val);
2548 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2549 error ("Expression cannot be implemented with read/access watchpoint.");
2551 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2552 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2553 bp_type, i + mem_cnt, other_type_used);
2554 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2555 error ("Target does not have this type of hardware watchpoint support.");
2556 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2557 error ("Target resources have been allocated for other types of watchpoints.");
2560 /* Now set up the breakpoint. */
2561 b = set_raw_breakpoint (sal);
2562 set_breakpoint_count (breakpoint_count + 1);
2563 b->number = breakpoint_count;
2564 b->disposition = donttouch;
2566 b->exp_valid_block = exp_valid_block;
2567 b->exp_string = savestring (exp_start, exp_end - exp_start);
2571 b->cond_string = savestring (cond_start, cond_end - cond_start);
2575 frame = block_innermost_frame (exp_valid_block);
2578 prev_frame = get_prev_frame (frame);
2579 b->watchpoint_frame = FRAME_FP (frame);
2582 b->watchpoint_frame = (CORE_ADDR)0;
2584 if (mem_cnt && target_resources_ok > 0)
2587 b->type = bp_watchpoint;
2589 /* If the expression is "local", then set up a "watchpoint scope"
2590 breakpoint at the point where we've left the scope of the watchpoint
2592 if (innermost_block)
2594 struct breakpoint *scope_breakpoint;
2595 struct symtab_and_line scope_sal;
2599 scope_sal.pc = get_frame_pc (prev_frame);
2600 scope_sal.symtab = NULL;
2603 scope_breakpoint = set_raw_breakpoint (scope_sal);
2604 set_breakpoint_count (breakpoint_count + 1);
2605 scope_breakpoint->number = breakpoint_count;
2607 scope_breakpoint->type = bp_watchpoint_scope;
2608 scope_breakpoint->enable = enabled;
2610 /* Automatically delete the breakpoint when it hits. */
2611 scope_breakpoint->disposition = delete;
2613 /* Only break in the proper frame (help with recursion). */
2614 scope_breakpoint->frame = prev_frame->frame;
2616 /* Set the address at which we will stop. */
2617 scope_breakpoint->address = get_frame_pc (prev_frame);
2619 /* The scope breakpoint is related to the watchpoint. We
2620 will need to act on them together. */
2621 b->related_breakpoint = scope_breakpoint;
2624 value_free_to_mark (mark);
2628 /* Return count of locations need to be watched and can be handled
2629 in hardware. If the watchpoint can not be handled
2630 in hardware return zero. */
2633 can_use_hardware_watchpoint (v)
2636 int found_memory_cnt = 0;
2638 /* Make sure all the intermediate values are in memory. Also make sure
2639 we found at least one memory expression. Guards against watch 0x12345,
2640 which is meaningless, but could cause errors if one tries to insert a
2641 hardware watchpoint for the constant expression. */
2642 for ( ; v; v = v->next)
2644 if (v->lval == lval_memory)
2646 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2649 else if (v->lval != not_lval && v->modifiable == 0)
2653 /* The expression itself looks suitable for using a hardware
2654 watchpoint, but give the target machine a chance to reject it. */
2655 return found_memory_cnt;
2658 static void watch_command (arg, from_tty)
2662 watch_command_1 (arg, 0, from_tty);
2665 static void rwatch_command (arg, from_tty)
2669 watch_command_1 (arg, 1, from_tty);
2672 static void awatch_command (arg, from_tty)
2676 watch_command_1 (arg, 2, from_tty);
2681 * Helper routine for the until_command routine in infcmd.c. Here
2682 * because it uses the mechanisms of breakpoints.
2686 until_break_command (arg, from_tty)
2690 struct symtabs_and_lines sals;
2691 struct symtab_and_line sal;
2692 FRAME prev_frame = get_prev_frame (selected_frame);
2693 struct breakpoint *breakpoint;
2694 struct cleanup *old_chain;
2696 clear_proceed_status ();
2698 /* Set a breakpoint where the user wants it and at return from
2701 if (default_breakpoint_valid)
2702 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2703 default_breakpoint_line, (char ***)NULL);
2705 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2707 if (sals.nelts != 1)
2708 error ("Couldn't get information on specified line.");
2711 free ((PTR)sals.sals); /* malloc'd, so freed */
2714 error ("Junk at end of arguments.");
2716 resolve_sal_pc (&sal);
2718 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2720 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2722 /* Keep within the current frame */
2726 struct frame_info *fi;
2728 fi = get_frame_info (prev_frame);
2729 sal = find_pc_line (fi->pc, 0);
2731 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2732 make_cleanup(delete_breakpoint, breakpoint);
2735 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2736 do_cleanups(old_chain);
2740 /* These aren't used; I don't konw what they were for. */
2741 /* Set a breakpoint at the catch clause for NAME. */
2743 catch_breakpoint (name)
2749 disable_catch_breakpoint ()
2754 delete_catch_breakpoint ()
2759 enable_catch_breakpoint ()
2766 struct sal_chain *next;
2767 struct symtab_and_line sal;
2771 /* This isn't used; I don't know what it was for. */
2772 /* For each catch clause identified in ARGS, run FUNCTION
2773 with that clause as an argument. */
2774 static struct symtabs_and_lines
2775 map_catch_names (args, function)
2779 register char *p = args;
2781 struct symtabs_and_lines sals;
2783 struct sal_chain *sal_chain = 0;
2787 error_no_arg ("one or more catch names");
2795 /* Don't swallow conditional part. */
2796 if (p1[0] == 'i' && p1[1] == 'f'
2797 && (p1[2] == ' ' || p1[2] == '\t'))
2803 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2807 if (*p1 && *p1 != ' ' && *p1 != '\t')
2808 error ("Arguments must be catch names.");
2814 struct sal_chain *next
2815 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2816 next->next = sal_chain;
2817 next->sal = get_catch_sal (p);
2822 printf_unfiltered ("No catch clause for exception %s.\n", p);
2827 while (*p == ' ' || *p == '\t') p++;
2832 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2834 static struct symtabs_and_lines
2835 get_catch_sals (this_level_only)
2836 int this_level_only;
2838 register struct blockvector *bl;
2839 register struct block *block;
2840 int index, have_default = 0;
2841 struct frame_info *fi;
2843 struct symtabs_and_lines sals;
2844 struct sal_chain *sal_chain = 0;
2845 char *blocks_searched;
2847 /* Not sure whether an error message is always the correct response,
2848 but it's better than a core dump. */
2849 if (selected_frame == NULL)
2850 error ("No selected frame.");
2851 block = get_frame_block (selected_frame);
2852 fi = get_frame_info (selected_frame);
2859 error ("No symbol table info available.\n");
2861 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2862 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2863 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2867 CORE_ADDR end = BLOCK_END (block) - 4;
2870 if (bl != blockvector_for_pc (end, &index))
2871 error ("blockvector blotch");
2872 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2873 error ("blockvector botch");
2874 last_index = BLOCKVECTOR_NBLOCKS (bl);
2877 /* Don't print out blocks that have gone by. */
2878 while (index < last_index
2879 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2882 while (index < last_index
2883 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2885 if (blocks_searched[index] == 0)
2887 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2890 register struct symbol *sym;
2892 nsyms = BLOCK_NSYMS (b);
2894 for (i = 0; i < nsyms; i++)
2896 sym = BLOCK_SYM (b, i);
2897 if (STREQ (SYMBOL_NAME (sym), "default"))
2903 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2905 struct sal_chain *next = (struct sal_chain *)
2906 alloca (sizeof (struct sal_chain));
2907 next->next = sal_chain;
2908 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2912 blocks_searched[index] = 1;
2918 if (sal_chain && this_level_only)
2921 /* After handling the function's top-level block, stop.
2922 Don't continue to its superblock, the block of
2923 per-file symbols. */
2924 if (BLOCK_FUNCTION (block))
2926 block = BLOCK_SUPERBLOCK (block);
2931 struct sal_chain *tmp_chain;
2933 /* Count the number of entries. */
2934 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2935 tmp_chain = tmp_chain->next)
2939 sals.sals = (struct symtab_and_line *)
2940 xmalloc (index * sizeof (struct symtab_and_line));
2941 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2942 sals.sals[index] = sal_chain->sal;
2948 /* Commands to deal with catching exceptions. */
2951 catch_command_1 (arg, tempflag, from_tty)
2956 /* First, translate ARG into something we can deal with in terms
2959 struct symtabs_and_lines sals;
2960 struct symtab_and_line sal;
2961 register struct expression *cond = 0;
2962 register struct breakpoint *b;
2966 sal.line = sal.pc = sal.end = 0;
2969 /* If no arg given, or if first arg is 'if ', all active catch clauses
2970 are breakpointed. */
2972 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2973 && (arg[2] == ' ' || arg[2] == '\t')))
2975 /* Grab all active catch clauses. */
2976 sals = get_catch_sals (0);
2980 /* Grab selected catch clauses. */
2981 error ("catch NAME not implemented");
2983 /* This isn't used; I don't know what it was for. */
2984 sals = map_catch_names (arg, catch_breakpoint);
2992 for (i = 0; i < sals.nelts; i++)
2994 resolve_sal_pc (&sals.sals[i]);
2998 if (arg[0] == 'i' && arg[1] == 'f'
2999 && (arg[2] == ' ' || arg[2] == '\t'))
3000 cond = parse_exp_1 ((arg += 2, &arg),
3001 block_for_pc (sals.sals[i].pc), 0);
3003 error ("Junk at end of arguments.");
3008 for (i = 0; i < sals.nelts; i++)
3013 describe_other_breakpoints (sal.pc);
3015 b = set_raw_breakpoint (sal);
3016 set_breakpoint_count (breakpoint_count + 1);
3017 b->number = breakpoint_count;
3018 b->type = bp_breakpoint;
3020 b->enable = enabled;
3021 b->disposition = tempflag ? delete : donttouch;
3028 printf_unfiltered ("Multiple breakpoints were set.\n");
3029 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3031 free ((PTR)sals.sals);
3035 /* These aren't used; I don't know what they were for. */
3036 /* Disable breakpoints on all catch clauses described in ARGS. */
3038 disable_catch (args)
3041 /* Map the disable command to catch clauses described in ARGS. */
3044 /* Enable breakpoints on all catch clauses described in ARGS. */
3049 /* Map the disable command to catch clauses described in ARGS. */
3052 /* Delete breakpoints on all catch clauses in the active scope. */
3057 /* Map the delete command to catch clauses described in ARGS. */
3062 catch_command (arg, from_tty)
3066 catch_command_1 (arg, 0, from_tty);
3070 clear_command (arg, from_tty)
3074 register struct breakpoint *b, *b1;
3075 struct symtabs_and_lines sals;
3076 struct symtab_and_line sal;
3077 register struct breakpoint *found;
3082 sals = decode_line_spec (arg, 1);
3086 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3087 sal.line = default_breakpoint_line;
3088 sal.symtab = default_breakpoint_symtab;
3090 if (sal.symtab == 0)
3091 error ("No source file specified.");
3097 for (i = 0; i < sals.nelts; i++)
3099 /* If exact pc given, clear bpts at that pc.
3100 But if sal.pc is zero, clear all bpts on specified line. */
3102 found = (struct breakpoint *) 0;
3103 while (breakpoint_chain
3105 ? breakpoint_chain->address == sal.pc
3106 : (breakpoint_chain->source_file != NULL
3107 && sal.symtab != NULL
3108 && STREQ (breakpoint_chain->source_file,
3109 sal.symtab->filename)
3110 && breakpoint_chain->line_number == sal.line)))
3112 b1 = breakpoint_chain;
3113 breakpoint_chain = b1->next;
3120 && b->next->type != bp_watchpoint
3121 && b->next->type != bp_hardware_watchpoint
3122 && b->next->type != bp_read_watchpoint
3123 && b->next->type != bp_access_watchpoint
3125 ? b->next->address == sal.pc
3126 : (b->next->source_file != NULL
3127 && sal.symtab != NULL
3128 && STREQ (b->next->source_file, sal.symtab->filename)
3129 && b->next->line_number == sal.line)))
3140 error ("No breakpoint at %s.", arg);
3142 error ("No breakpoint at this line.");
3145 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3146 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3147 breakpoints_changed ();
3150 if (from_tty) printf_unfiltered ("%d ", found->number);
3152 delete_breakpoint (found);
3155 if (from_tty) putchar_unfiltered ('\n');
3157 free ((PTR)sals.sals);
3160 /* Delete breakpoint in BS if they are `delete' breakpoints.
3161 This is called after any breakpoint is hit, or after errors. */
3164 breakpoint_auto_delete (bs)
3167 for (; bs; bs = bs->next)
3168 if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
3170 delete_breakpoint (bs->breakpoint_at);
3173 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3176 delete_breakpoint (bpt)
3177 struct breakpoint *bpt;
3179 register struct breakpoint *b;
3183 remove_breakpoint (bpt);
3185 if (breakpoint_chain == bpt)
3186 breakpoint_chain = bpt->next;
3191 b->next = bpt->next;
3195 check_duplicates (bpt->address);
3196 /* If this breakpoint was inserted, and there is another breakpoint
3197 at the same address, we need to insert the other breakpoint. */
3199 && bpt->type != bp_hardware_watchpoint
3200 && bpt->type != bp_read_watchpoint
3201 && bpt->type != bp_access_watchpoint)
3204 if (b->address == bpt->address
3206 && b->enable != disabled)
3209 val = target_insert_breakpoint (b->address, b->shadow_contents);
3212 target_terminal_ours_for_output ();
3213 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3214 memory_error (val, b->address); /* which bombs us out */
3221 free_command_lines (&bpt->commands);
3224 if (bpt->cond_string != NULL)
3225 free (bpt->cond_string);
3226 if (bpt->addr_string != NULL)
3227 free (bpt->addr_string);
3228 if (bpt->exp_string != NULL)
3229 free (bpt->exp_string);
3230 if (bpt->source_file != NULL)
3231 free (bpt->source_file);
3233 breakpoints_changed ();
3235 /* Be sure no bpstat's are pointing at it after it's been freed. */
3236 /* FIXME, how can we find all bpstat's?
3237 We just check stop_bpstat for now. */
3238 for (bs = stop_bpstat; bs; bs = bs->next)
3239 if (bs->breakpoint_at == bpt)
3240 bs->breakpoint_at = NULL;
3245 delete_command (arg, from_tty)
3252 /* Ask user only if there are some breakpoints to delete. */
3254 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
3256 /* No arg; clear all breakpoints. */
3257 while (breakpoint_chain)
3258 delete_breakpoint (breakpoint_chain);
3262 map_breakpoint_numbers (arg, delete_breakpoint);
3265 /* Reset a breakpoint given it's struct breakpoint * BINT.
3266 The value we return ends up being the return value from catch_errors.
3267 Unused in this case. */
3270 breakpoint_re_set_one (bint)
3273 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3276 struct symtabs_and_lines sals;
3278 enum enable save_enable;
3283 case bp_hardware_breakpoint:
3284 if (b->addr_string == NULL)
3286 /* Anything without a string can't be re-set. */
3287 delete_breakpoint (b);
3290 /* In case we have a problem, disable this breakpoint. We'll restore
3291 its status if we succeed. */
3292 save_enable = b->enable;
3293 b->enable = disabled;
3296 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3297 for (i = 0; i < sals.nelts; i++)
3299 resolve_sal_pc (&sals.sals[i]);
3301 /* Reparse conditions, they might contain references to the
3303 if (b->cond_string != NULL)
3307 free ((PTR)b->cond);
3308 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3311 /* We need to re-set the breakpoint if the address changes...*/
3312 if (b->address != sals.sals[i].pc
3313 /* ...or new and old breakpoints both have source files, and
3314 the source file name or the line number changes... */
3315 || (b->source_file != NULL
3316 && sals.sals[i].symtab != NULL
3317 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3318 || b->line_number != sals.sals[i].line)
3320 /* ...or we switch between having a source file and not having
3322 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3325 if (b->source_file != NULL)
3326 free (b->source_file);
3327 if (sals.sals[i].symtab == NULL)
3328 b->source_file = NULL;
3331 savestring (sals.sals[i].symtab->filename,
3332 strlen (sals.sals[i].symtab->filename));
3333 b->line_number = sals.sals[i].line;
3334 b->address = sals.sals[i].pc;
3336 check_duplicates (b->address);
3340 /* Might be better to do this just once per breakpoint_re_set,
3341 rather than once for every breakpoint. */
3342 breakpoints_changed ();
3344 b->enable = save_enable; /* Restore it, this worked. */
3346 free ((PTR)sals.sals);
3350 case bp_hardware_watchpoint:
3351 case bp_read_watchpoint:
3352 case bp_access_watchpoint:
3353 innermost_block = NULL;
3354 /* The issue arises of what context to evaluate this in. The same
3355 one as when it was set, but what does that mean when symbols have
3356 been re-read? We could save the filename and functionname, but
3357 if the context is more local than that, the best we could do would
3358 be something like how many levels deep and which index at that
3359 particular level, but that's going to be less stable than filenames
3360 or functionnames. */
3361 /* So for now, just use a global context. */
3362 b->exp = parse_expression (b->exp_string);
3363 b->exp_valid_block = innermost_block;
3364 mark = value_mark ();
3365 b->val = evaluate_expression (b->exp);
3366 release_value (b->val);
3367 if (VALUE_LAZY (b->val))
3368 value_fetch_lazy (b->val);
3370 if (b->cond_string != NULL)
3373 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3375 if (b->enable == enabled)
3377 value_free_to_mark (mark);
3381 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3386 case bp_longjmp_resume:
3387 case bp_watchpoint_scope:
3389 delete_breakpoint (b);
3396 /* Re-set all breakpoints after symbols have been re-loaded. */
3398 breakpoint_re_set ()
3400 struct breakpoint *b, *temp;
3401 static char message1[] = "Error in re-setting breakpoint %d:\n";
3402 char message[sizeof (message1) + 30 /* slop */];
3404 ALL_BREAKPOINTS_SAFE (b, temp)
3406 sprintf (message, message1, b->number); /* Format possible error msg */
3407 catch_errors (breakpoint_re_set_one, (char *) b, message,
3411 create_longjmp_breakpoint("longjmp");
3412 create_longjmp_breakpoint("_longjmp");
3413 create_longjmp_breakpoint("siglongjmp");
3414 create_longjmp_breakpoint(NULL);
3417 /* Took this out (temporaliy at least), since it produces an extra
3418 blank line at startup. This messes up the gdbtests. -PB */
3419 /* Blank line to finish off all those mention() messages we just printed. */
3420 printf_filtered ("\n");
3424 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3425 If from_tty is nonzero, it prints a message to that effect,
3426 which ends with a period (no newline). */
3429 set_ignore_count (bptnum, count, from_tty)
3430 int bptnum, count, from_tty;
3432 register struct breakpoint *b;
3438 if (b->number == bptnum)
3440 b->ignore_count = count;
3443 else if (count == 0)
3444 printf_filtered ("Will stop next time breakpoint %d is reached.",
3446 else if (count == 1)
3447 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3450 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3452 breakpoints_changed ();
3456 error ("No breakpoint number %d.", bptnum);
3459 /* Clear the ignore counts of all breakpoints. */
3461 breakpoint_clear_ignore_counts ()
3463 struct breakpoint *b;
3466 b->ignore_count = 0;
3469 /* Command to set ignore-count of breakpoint N to COUNT. */
3472 ignore_command (args, from_tty)
3480 error_no_arg ("a breakpoint number");
3482 num = get_number (&p);
3485 error ("Second argument (specified ignore-count) is missing.");
3487 set_ignore_count (num,
3488 longest_to_int (value_as_long (parse_and_eval (p))),
3490 printf_filtered ("\n");
3491 breakpoints_changed ();
3494 /* Call FUNCTION on each of the breakpoints
3495 whose numbers are given in ARGS. */
3498 map_breakpoint_numbers (args, function)
3500 void (*function) PARAMS ((struct breakpoint *));
3502 register char *p = args;
3505 register struct breakpoint *b;
3508 error_no_arg ("one or more breakpoint numbers");
3514 num = get_number (&p1);
3517 if (b->number == num)
3519 struct breakpoint *related_breakpoint = b->related_breakpoint;
3521 if (related_breakpoint)
3522 function (related_breakpoint);
3525 printf_unfiltered ("No breakpoint number %d.\n", num);
3532 enable_breakpoint (bpt)
3533 struct breakpoint *bpt;
3535 FRAME save_selected_frame = NULL;
3536 int save_selected_frame_level = -1;
3537 int target_resources_ok, other_type_used;
3540 if (bpt->type == bp_hardware_breakpoint)
3543 i = hw_breakpoint_used_count();
3544 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3545 bp_hardware_breakpoint, i+1, 0);
3546 if (target_resources_ok == 0)
3547 error ("No hardware breakpoint support in the target.");
3548 else if (target_resources_ok < 0)
3549 error ("Hardware breakpoints used exceeds limit.");
3551 bpt->enable = enabled;
3552 breakpoints_changed ();
3553 check_duplicates (bpt->address);
3555 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3556 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3558 if (bpt->exp_valid_block != NULL)
3560 FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3564 Cannot enable watchpoint %d because the block in which its expression\n\
3565 is valid is not currently in scope.\n", bpt->number);
3566 bpt->enable = disabled;
3570 save_selected_frame = selected_frame;
3571 save_selected_frame_level = selected_frame_level;
3572 select_frame (fr, -1);
3575 value_free (bpt->val);
3576 mark = value_mark ();
3577 bpt->val = evaluate_expression (bpt->exp);
3578 release_value (bpt->val);
3579 if (VALUE_LAZY (bpt->val))
3580 value_fetch_lazy (bpt->val);
3582 if (bpt->type == bp_hardware_watchpoint ||
3583 bpt->type == bp_read_watchpoint ||
3584 bpt->type == bp_access_watchpoint)
3586 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3587 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3588 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3589 bpt->type, i+mem_cnt, other_type_used);
3590 /* we can consider of type is bp_hardware_watchpoint, convert to
3591 bp_watchpoint in the following condition */
3592 if (target_resources_ok < 0)
3595 Cannot enable watchpoint %d because target watch resources\n\
3596 have been allocated for other watchpoints.\n", bpt->number);
3597 bpt->enable = disabled;
3598 value_free_to_mark (mark);
3603 if (save_selected_frame_level >= 0)
3604 select_frame (save_selected_frame, save_selected_frame_level);
3605 value_free_to_mark (mark);
3611 enable_command (args, from_tty)
3615 struct breakpoint *bpt;
3617 ALL_BREAKPOINTS (bpt)
3621 case bp_hardware_breakpoint:
3623 case bp_hardware_watchpoint:
3624 case bp_read_watchpoint:
3625 case bp_access_watchpoint:
3626 enable_breakpoint (bpt);
3631 map_breakpoint_numbers (args, enable_breakpoint);
3635 disable_breakpoint (bpt)
3636 struct breakpoint *bpt;
3638 /* Never disable a watchpoint scope breakpoint; we want to
3639 hit them when we leave scope so we can delete both the
3640 watchpoint and its scope breakpoint at that time. */
3641 if (bpt->type == bp_watchpoint_scope)
3644 bpt->enable = disabled;
3646 breakpoints_changed ();
3648 check_duplicates (bpt->address);
3653 disable_command (args, from_tty)
3657 register struct breakpoint *bpt;
3659 ALL_BREAKPOINTS (bpt)
3663 case bp_hardware_breakpoint:
3665 case bp_hardware_watchpoint:
3666 case bp_read_watchpoint:
3667 case bp_access_watchpoint:
3668 disable_breakpoint (bpt);
3673 map_breakpoint_numbers (args, disable_breakpoint);
3677 enable_once_breakpoint (bpt)
3678 struct breakpoint *bpt;
3680 FRAME save_selected_frame = NULL;
3681 int save_selected_frame_level = -1;
3682 int target_resources_ok, other_type_used;
3685 if (bpt->type == bp_hardware_breakpoint)
3688 i = hw_breakpoint_used_count();
3689 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3690 bp_hardware_breakpoint, i+1, 0);
3691 if (target_resources_ok == 0)
3692 error ("No hardware breakpoint support in the target.");
3693 else if (target_resources_ok < 0)
3694 error ("Hardware breakpoints used exceeds limit.");
3697 bpt->enable = enabled;
3698 bpt->disposition = disable;
3699 check_duplicates (bpt->address);
3700 breakpoints_changed ();
3702 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3703 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3705 if (bpt->exp_valid_block != NULL)
3707 FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3711 Cannot enable watchpoint %d because the block in which its expression\n\
3712 is valid is not currently in scope.\n", bpt->number);
3713 bpt->enable = disabled;
3717 save_selected_frame = selected_frame;
3718 save_selected_frame_level = selected_frame_level;
3719 select_frame (fr, -1);
3722 value_free (bpt->val);
3723 mark = value_mark ();
3724 bpt->val = evaluate_expression (bpt->exp);
3725 release_value (bpt->val);
3726 if (VALUE_LAZY (bpt->val))
3727 value_fetch_lazy (bpt->val);
3729 if (bpt->type == bp_hardware_watchpoint ||
3730 bpt->type == bp_read_watchpoint ||
3731 bpt->type == bp_access_watchpoint)
3733 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3734 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3735 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3736 bpt->type, i+mem_cnt, other_type_used);
3737 /* we can consider of type is bp_hardware_watchpoint, convert to
3738 bp_watchpoint in the following condition */
3739 if (target_resources_ok < 0)
3742 Cannot enable watchpoint %d because target watch resources\n\
3743 have been allocated for other watchpoints.\n", bpt->number);
3744 bpt->enable = disabled;
3745 value_free_to_mark (mark);
3749 if (save_selected_frame_level >= 0)
3750 select_frame (save_selected_frame, save_selected_frame_level);
3751 value_free_to_mark (mark);
3757 enable_once_command (args, from_tty)
3761 map_breakpoint_numbers (args, enable_once_breakpoint);
3765 enable_delete_breakpoint (bpt)
3766 struct breakpoint *bpt;
3768 bpt->enable = enabled;
3769 bpt->disposition = delete;
3771 check_duplicates (bpt->address);
3772 breakpoints_changed ();
3777 enable_delete_command (args, from_tty)
3781 map_breakpoint_numbers (args, enable_delete_breakpoint);
3785 * Use default_breakpoint_'s, or nothing if they aren't valid.
3787 struct symtabs_and_lines
3788 decode_line_spec_1 (string, funfirstline)
3792 struct symtabs_and_lines sals;
3794 error ("Empty line specification.");
3795 if (default_breakpoint_valid)
3796 sals = decode_line_1 (&string, funfirstline,
3797 default_breakpoint_symtab, default_breakpoint_line,
3800 sals = decode_line_1 (&string, funfirstline,
3801 (struct symtab *)NULL, 0, (char ***)NULL);
3803 error ("Junk at end of line specification: %s", string);
3808 _initialize_breakpoint ()
3810 breakpoint_chain = 0;
3811 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3812 before a breakpoint is set. */
3813 breakpoint_count = 0;
3815 add_com ("ignore", class_breakpoint, ignore_command,
3816 "Set ignore-count of breakpoint number N to COUNT.");
3818 add_com ("commands", class_breakpoint, commands_command,
3819 "Set commands to be executed when a breakpoint is hit.\n\
3820 Give breakpoint number as argument after \"commands\".\n\
3821 With no argument, the targeted breakpoint is the last one set.\n\
3822 The commands themselves follow starting on the next line.\n\
3823 Type a line containing \"end\" to indicate the end of them.\n\
3824 Give \"silent\" as the first line to make the breakpoint silent;\n\
3825 then no output is printed when it is hit, except what the commands print.");
3827 add_com ("condition", class_breakpoint, condition_command,
3828 "Specify breakpoint number N to break only if COND is true.\n\
3829 N is an integer; COND is an expression to be evaluated whenever\n\
3830 breakpoint N is reached. ");
3832 add_com ("tbreak", class_breakpoint, tbreak_command,
3833 "Set a temporary breakpoint. Args like \"break\" command.\n\
3834 Like \"break\" except the breakpoint is only temporary,\n\
3835 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3836 by using \"enable delete\" on the breakpoint number.");
3838 add_com ("hbreak", class_breakpoint, hbreak_command,
3839 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3840 Like \"break\" except the breakpoint requires hardware support,\n\
3841 some target hardware may not have this support.");
3843 add_com ("thbreak", class_breakpoint, thbreak_command,
3844 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3845 Like \"hbreak\" except the breakpoint is only temporary,\n\
3846 so it will be deleted when hit.");
3848 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3849 "Enable some breakpoints.\n\
3850 Give breakpoint numbers (separated by spaces) as arguments.\n\
3851 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3852 This is used to cancel the effect of the \"disable\" command.\n\
3853 With a subcommand you can enable temporarily.",
3854 &enablelist, "enable ", 1, &cmdlist);
3856 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3857 "Enable some breakpoints.\n\
3858 Give breakpoint numbers (separated by spaces) as arguments.\n\
3859 This is used to cancel the effect of the \"disable\" command.\n\
3860 May be abbreviated to simply \"enable\".\n",
3861 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3863 add_cmd ("once", no_class, enable_once_command,
3864 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3865 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3868 add_cmd ("delete", no_class, enable_delete_command,
3869 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3870 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3873 add_cmd ("delete", no_class, enable_delete_command,
3874 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3875 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3878 add_cmd ("once", no_class, enable_once_command,
3879 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3880 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3883 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3884 "Disable some breakpoints.\n\
3885 Arguments are breakpoint numbers with spaces in between.\n\
3886 To disable all breakpoints, give no argument.\n\
3887 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3888 &disablelist, "disable ", 1, &cmdlist);
3889 add_com_alias ("dis", "disable", class_breakpoint, 1);
3890 add_com_alias ("disa", "disable", class_breakpoint, 1);
3892 add_cmd ("breakpoints", class_alias, disable_command,
3893 "Disable some breakpoints.\n\
3894 Arguments are breakpoint numbers with spaces in between.\n\
3895 To disable all breakpoints, give no argument.\n\
3896 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3897 This command may be abbreviated \"disable\".",
3900 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3901 "Delete some breakpoints or auto-display expressions.\n\
3902 Arguments are breakpoint numbers with spaces in between.\n\
3903 To delete all breakpoints, give no argument.\n\
3905 Also a prefix command for deletion of other GDB objects.\n\
3906 The \"unset\" command is also an alias for \"delete\".",
3907 &deletelist, "delete ", 1, &cmdlist);
3908 add_com_alias ("d", "delete", class_breakpoint, 1);
3910 add_cmd ("breakpoints", class_alias, delete_command,
3911 "Delete some breakpoints or auto-display expressions.\n\
3912 Arguments are breakpoint numbers with spaces in between.\n\
3913 To delete all breakpoints, give no argument.\n\
3914 This command may be abbreviated \"delete\".",
3917 add_com ("clear", class_breakpoint, clear_command,
3918 "Clear breakpoint at specified line or function.\n\
3919 Argument may be line number, function name, or \"*\" and an address.\n\
3920 If line number is specified, all breakpoints in that line are cleared.\n\
3921 If function is specified, breakpoints at beginning of function are cleared.\n\
3922 If an address is specified, breakpoints at that address are cleared.\n\n\
3923 With no argument, clears all breakpoints in the line that the selected frame\n\
3926 See also the \"delete\" command which clears breakpoints by number.");
3928 add_com ("break", class_breakpoint, break_command,
3929 "Set breakpoint at specified line or function.\n\
3930 Argument may be line number, function name, or \"*\" and an address.\n\
3931 If line number is specified, break at start of code for that line.\n\
3932 If function is specified, break at start of code for that function.\n\
3933 If an address is specified, break at that exact address.\n\
3934 With no arg, uses current execution address of selected stack frame.\n\
3935 This is useful for breaking on return to a stack frame.\n\
3937 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3939 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3940 add_com_alias ("b", "break", class_run, 1);
3941 add_com_alias ("br", "break", class_run, 1);
3942 add_com_alias ("bre", "break", class_run, 1);
3943 add_com_alias ("brea", "break", class_run, 1);
3945 add_info ("breakpoints", breakpoints_info,
3946 "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3947 The \"Type\" column indicates one of:\n\
3948 \tbreakpoint - normal breakpoint\n\
3949 \twatchpoint - watchpoint\n\
3950 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3951 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3952 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3953 address and file/line number respectively.\n\n\
3954 Convenience variable \"$_\" and default examine address for \"x\"\n\
3955 are set to the address of the last breakpoint listed.\n\n\
3956 Convenience variable \"$bpnum\" contains the number of the last\n\
3959 #if MAINTENANCE_CMDS
3961 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3962 "Status of all breakpoints, or breakpoint number NUMBER.\n\
3963 The \"Type\" column indicates one of:\n\
3964 \tbreakpoint - normal breakpoint\n\
3965 \twatchpoint - watchpoint\n\
3966 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3967 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3968 \tuntil - internal breakpoint used by the \"until\" command\n\
3969 \tfinish - internal breakpoint used by the \"finish\" command\n\
3970 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3971 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3972 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3973 address and file/line number respectively.\n\n\
3974 Convenience variable \"$_\" and default examine address for \"x\"\n\
3975 are set to the address of the last breakpoint listed.\n\n\
3976 Convenience variable \"$bpnum\" contains the number of the last\n\
3978 &maintenanceinfolist);
3980 #endif /* MAINTENANCE_CMDS */
3982 add_com ("catch", class_breakpoint, catch_command,
3983 "Set breakpoints to catch exceptions that are raised.\n\
3984 Argument may be a single exception to catch, multiple exceptions\n\
3985 to catch, or the default exception \"default\". If no arguments\n\
3986 are given, breakpoints are set at all exception handlers catch clauses\n\
3987 within the current scope.\n\
3989 A condition specified for the catch applies to all breakpoints set\n\
3990 with this command\n\
3992 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3994 add_com ("watch", class_breakpoint, watch_command,
3995 "Set a watchpoint for an expression.\n\
3996 A watchpoint stops execution of your program whenever the value of\n\
3997 an expression changes.");
3999 add_com ("rwatch", class_breakpoint, rwatch_command,
4000 "Set a read watchpoint for an expression.\n\
4001 A watchpoint stops execution of your program whenever the value of\n\
4002 an expression is read.");
4004 add_com ("awatch", class_breakpoint, awatch_command,
4005 "Set a watchpoint for an expression.\n\
4006 A watchpoint stops execution of your program whenever the value of\n\
4007 an expression is either read or written.");
4009 add_info ("watchpoints", breakpoints_info,
4010 "Synonym for ``info breakpoints''.");
4014 /* OK, when we call objfile_relocate, we need to relocate breakpoints
4015 too. breakpoint_re_set is not a good choice--for example, if
4016 addr_string contains just a line number without a file name the
4017 breakpoint might get set in a different file. In general, there is
4018 no need to go all the way back to the user's string (though this might
4019 work if some effort were made to canonicalize it), since symtabs and
4020 everything except addresses are still valid.
4022 Probably the best way to solve this is to have each breakpoint save
4023 the objfile and the section number that was used to set it (if set
4024 by "*addr", probably it is best to use find_pc_line to get a symtab
4025 and use the objfile and block_line_section for that symtab). Then
4026 objfile_relocate can call fixup_breakpoints with the objfile and
4027 the new_offsets, and it can relocate only the appropriate breakpoints. */
4029 #ifdef IBM6000_TARGET
4030 /* But for now, just kludge it based on the concept that before an
4031 objfile is relocated the breakpoint is below 0x10000000, and afterwards
4032 it is higher, so that way we only relocate each breakpoint once. */
4035 fixup_breakpoints (low, high, delta)
4040 struct breakpoint *b;
4044 if (b->address >= low && b->address <= high)
4045 b->address += delta;