1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #include "breakpoint.h"
26 #include "expression.h"
39 /* local function prototypes */
42 catch_command_1 PARAMS ((char *, int, int));
45 enable_delete_command PARAMS ((char *, int));
48 enable_delete_breakpoint PARAMS ((struct breakpoint *));
51 enable_once_command PARAMS ((char *, int));
54 enable_once_breakpoint PARAMS ((struct breakpoint *));
57 disable_command PARAMS ((char *, int));
60 disable_breakpoint PARAMS ((struct breakpoint *));
63 enable_command PARAMS ((char *, int));
66 enable_breakpoint PARAMS ((struct breakpoint *));
69 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
72 ignore_command PARAMS ((char *, int));
75 breakpoint_re_set_one PARAMS ((char *));
78 delete_command PARAMS ((char *, int));
81 clear_command PARAMS ((char *, int));
84 catch_command PARAMS ((char *, int));
86 static struct symtabs_and_lines
87 get_catch_sals PARAMS ((int));
90 watch_command PARAMS ((char *, int));
93 can_use_hardware_watchpoint PARAMS ((struct value *));
96 tbreak_command PARAMS ((char *, int));
99 break_command_1 PARAMS ((char *, int, int));
102 mention PARAMS ((struct breakpoint *));
104 static struct breakpoint *
105 set_raw_breakpoint PARAMS ((struct symtab_and_line));
108 check_duplicates PARAMS ((CORE_ADDR));
111 describe_other_breakpoints PARAMS ((CORE_ADDR));
114 breakpoints_info PARAMS ((char *, int));
117 breakpoint_1 PARAMS ((int, int));
120 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
123 breakpoint_cond_eval PARAMS ((char *));
126 cleanup_executing_breakpoints PARAMS ((int));
129 commands_command PARAMS ((char *, int));
132 condition_command PARAMS ((char *, int));
135 get_number PARAMS ((char **));
138 set_breakpoint_count PARAMS ((int));
141 remove_breakpoint PARAMS ((struct breakpoint *));
143 extern int addressprint; /* Print machine addresses? */
144 extern int demangle; /* Print de-mangled symbol names? */
146 /* Are we executing breakpoint commands? */
147 static int executing_breakpoint_commands;
149 /* Walk the following statement or block through all breakpoints.
150 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
153 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
155 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
156 for (b = breakpoint_chain; \
157 b? (tmp=b->next, 1): 0; \
160 /* By default no support for hardware watchpoints is assumed. */
161 #ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT
162 #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
163 #define target_remove_watchpoint(ADDR,LEN,TYPE) -1
164 #define target_insert_watchpoint(ADDR,LEN,TYPE) -1
167 #ifndef target_insert_hw_breakpoint
168 #define target_remove_hw_breakpoint(ADDR,SHADOW) -1
169 #define target_insert_hw_breakpoint(ADDR,SHADOW) -1
172 #ifndef target_stopped_data_address
173 #define target_stopped_data_address() 0
176 /* Chain of all breakpoints defined. */
178 static struct breakpoint *breakpoint_chain;
180 /* Number of last breakpoint made. */
182 static int breakpoint_count;
184 /* Set breakpoint count to NUM. */
186 set_breakpoint_count (num)
189 breakpoint_count = num;
190 set_internalvar (lookup_internalvar ("bpnum"),
191 value_from_longest (builtin_type_int, (LONGEST) num));
194 /* Default address, symtab and line to put a breakpoint at
195 for "break" command with no arg.
196 if default_breakpoint_valid is zero, the other three are
197 not valid, and "break" with no arg is an error.
199 This set by print_stack_frame, which calls set_default_breakpoint. */
201 int default_breakpoint_valid;
202 CORE_ADDR default_breakpoint_address;
203 struct symtab *default_breakpoint_symtab;
204 int default_breakpoint_line;
206 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
207 Advance *PP after the string and any trailing whitespace.
209 Currently the string can either be a number or "$" followed by the name
210 of a convenience variable. Making it an expression wouldn't work well
211 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
220 /* Empty line means refer to the last breakpoint. */
221 return breakpoint_count;
224 /* Make a copy of the name, so we can null-terminate it
225 to pass to lookup_internalvar(). */
230 while (isalnum (*p) || *p == '_')
232 varname = (char *) alloca (p - start + 1);
233 strncpy (varname, start, p - start);
234 varname[p - start] = '\0';
235 val = value_of_internalvar (lookup_internalvar (varname));
236 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
238 "Convenience variables used to specify breakpoints must have integer values."
240 retval = (int) value_as_long (val);
246 while (*p >= '0' && *p <= '9')
249 /* There is no number here. (e.g. "cond a == b"). */
250 error_no_arg ("breakpoint number");
253 if (!(isspace (*p) || *p == '\0'))
254 error ("breakpoint number expected");
261 /* condition N EXP -- set break condition of breakpoint N to EXP. */
264 condition_command (arg, from_tty)
268 register struct breakpoint *b;
273 error_no_arg ("breakpoint number");
276 bnum = get_number (&p);
279 if (b->number == bnum)
286 if (b->cond_string != NULL)
287 free ((PTR)b->cond_string);
292 b->cond_string = NULL;
294 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
299 /* I don't know if it matters whether this is the string the user
300 typed in or the decompiled expression. */
301 b->cond_string = savestring (arg, strlen (arg));
302 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
304 error ("Junk at end of expression");
309 error ("No breakpoint number %d.", bnum);
314 commands_command (arg, from_tty)
318 register struct breakpoint *b;
321 struct command_line *l;
323 /* If we allowed this, we would have problems with when to
324 free the storage, if we change the commands currently
327 if (executing_breakpoint_commands)
328 error ("Can't use the \"commands\" command among a breakpoint's commands.");
331 bnum = get_number (&p);
333 error ("Unexpected extra arguments following breakpoint number.");
336 if (b->number == bnum)
338 if (from_tty && input_from_terminal_p ())
339 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
340 End with a line saying just \"end\".\n", bnum);
341 l = read_command_lines ();
342 free_command_lines (&b->commands);
344 breakpoints_changed ();
347 error ("No breakpoint number %d.", bnum);
350 extern int memory_breakpoint_size; /* from mem-break.c */
352 /* Like target_read_memory() but if breakpoints are inserted, return
353 the shadow contents instead of the breakpoints themselves.
355 Read "memory data" from whatever target or inferior we have.
356 Returns zero if successful, errno value if not. EIO is used
357 for address out of bounds. If breakpoints are inserted, returns
358 shadow contents, not the breakpoints themselves. From breakpoint.c. */
361 read_memory_nobpt (memaddr, myaddr, len)
367 struct breakpoint *b;
369 if (memory_breakpoint_size < 0)
370 /* No breakpoints on this machine. FIXME: This should be
371 dependent on the debugging target. Probably want
372 target_insert_breakpoint to return a size, saying how many
373 bytes of the shadow contents are used, or perhaps have
374 something like target_xfer_shadow. */
375 return target_read_memory (memaddr, myaddr, len);
379 if (b->type == bp_watchpoint
380 || b->type == bp_hardware_watchpoint
381 || b->type == bp_read_watchpoint
382 || b->type == bp_access_watchpoint
385 else if (b->address + memory_breakpoint_size <= memaddr)
386 /* The breakpoint is entirely before the chunk of memory
389 else if (b->address >= memaddr + len)
390 /* The breakpoint is entirely after the chunk of memory we
395 /* Copy the breakpoint from the shadow contents, and recurse
396 for the things before and after. */
398 /* Addresses and length of the part of the breakpoint that
400 CORE_ADDR membpt = b->address;
401 unsigned int bptlen = memory_breakpoint_size;
402 /* Offset within shadow_contents. */
405 if (membpt < memaddr)
407 /* Only copy the second part of the breakpoint. */
408 bptlen -= memaddr - membpt;
409 bptoffset = memaddr - membpt;
413 if (membpt + bptlen > memaddr + len)
415 /* Only copy the first part of the breakpoint. */
416 bptlen -= (membpt + bptlen) - (memaddr + len);
419 memcpy (myaddr + membpt - memaddr,
420 b->shadow_contents + bptoffset, bptlen);
422 if (membpt > memaddr)
424 /* Copy the section of memory before the breakpoint. */
425 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
430 if (membpt + bptlen < memaddr + len)
432 /* Copy the section of memory after the breakpoint. */
433 status = read_memory_nobpt
435 myaddr + membpt + bptlen - memaddr,
436 memaddr + len - (membpt + bptlen));
443 /* Nothing overlaps. Just call read_memory_noerr. */
444 return target_read_memory (memaddr, myaddr, len);
447 /* insert_breakpoints is used when starting or continuing the program.
448 remove_breakpoints is used when the program stops.
449 Both return zero if successful,
450 or an `errno' value if could not write the inferior. */
453 insert_breakpoints ()
455 register struct breakpoint *b;
457 int disabled_breaks = 0;
460 if (b->type != bp_watchpoint
461 && b->type != bp_hardware_watchpoint
462 && b->type != bp_read_watchpoint
463 && b->type != bp_access_watchpoint
464 && b->enable != disabled
468 if (b->type == bp_hardware_breakpoint)
469 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
471 val = target_insert_breakpoint(b->address, b->shadow_contents);
474 /* Can't set the breakpoint. */
475 #if defined (DISABLE_UNSETTABLE_BREAK)
476 if (DISABLE_UNSETTABLE_BREAK (b->address))
479 b->enable = disabled;
480 if (!disabled_breaks)
482 target_terminal_ours_for_output ();
483 fprintf_unfiltered (gdb_stderr,
484 "Cannot insert breakpoint %d:\n", b->number);
485 printf_filtered ("Disabling shared library breakpoints:\n");
488 printf_filtered ("%d ", b->number);
493 target_terminal_ours_for_output ();
494 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
495 #ifdef ONE_PROCESS_WRITETEXT
496 fprintf_unfiltered (gdb_stderr,
497 "The same program may be running in another process.\n");
499 memory_error (val, b->address); /* which bombs us out */
505 else if ((b->type == bp_hardware_watchpoint ||
506 b->type == bp_read_watchpoint ||
507 b->type == bp_access_watchpoint)
508 && b->enable == enabled
513 int saved_level, within_current_scope;
514 value_ptr mark = value_mark ();
517 /* Save the current frame and level so we can restore it after
518 evaluating the watchpoint expression on its own frame. */
519 saved_frame = selected_frame;
520 saved_level = selected_frame_level;
522 /* Determine if the watchpoint is within scope. */
523 if (b->exp_valid_block == NULL)
524 within_current_scope = 1;
527 FRAME fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
528 within_current_scope = (fr != NULL);
529 if (within_current_scope)
530 select_frame (fr, -1);
533 if (within_current_scope)
535 /* Evaluate the expression and cut the chain of values
536 produced off from the value chain. */
537 v = evaluate_expression (b->exp);
538 value_release_to_mark (mark);
543 /* Look at each value on the value chain. */
544 for ( ; v; v=v->next)
546 /* If it's a memory location, then we must watch it. */
547 if (v->lval == lval_memory)
551 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
552 len = TYPE_LENGTH (VALUE_TYPE (v));
554 if (b->type == bp_read_watchpoint)
556 else if (b->type == bp_access_watchpoint)
559 val = target_insert_watchpoint (addr, len, type);
568 /* Failure to insert a watchpoint on any memory value in the
569 value chain brings us here. */
571 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
577 Hardware watchpoint %d deleted because the program has left the block in\n\
578 which its expression is valid.\n", b->number);
579 if (b->related_breakpoint)
580 delete_breakpoint (b->related_breakpoint);
581 delete_breakpoint (b);
584 /* Restore the frame and level. */
585 select_frame (saved_frame, saved_level);
588 printf_filtered ("\n");
594 remove_breakpoints ()
596 register struct breakpoint *b;
603 val = remove_breakpoint (b);
613 remove_breakpoint (b)
614 struct breakpoint *b;
618 if (b->type != bp_watchpoint
619 && b->type != bp_hardware_watchpoint
620 && b->type != bp_read_watchpoint
621 && b->type != bp_access_watchpoint)
623 if (b->type == bp_hardware_breakpoint)
624 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
626 val = target_remove_breakpoint(b->address, b->shadow_contents);
631 else if ((b->type == bp_hardware_watchpoint ||
632 b->type == bp_read_watchpoint ||
633 b->type == bp_access_watchpoint)
634 && b->enable == enabled
640 /* Walk down the saved value chain. */
641 for (v = b->val_chain; v; v = v->next)
643 /* For each memory reference remove the watchpoint
645 if (v->lval == lval_memory)
649 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
650 len = TYPE_LENGTH (VALUE_TYPE (v));
651 val = target_remove_watchpoint (addr, len, b->type);
657 /* Failure to remove any of the hardware watchpoints comes here. */
659 error ("Hardware watchpoint %d: Could not remove watchpoint\n",
662 /* Free the saved value chain. We will construct a new one
663 the next time the watchpoint is inserted. */
664 for (v = b->val_chain; v; v = n)
674 /* Clear the "inserted" flag in all breakpoints. */
677 mark_breakpoints_out ()
679 register struct breakpoint *b;
685 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
686 which should go away between runs of the program. */
689 breakpoint_init_inferior ()
691 register struct breakpoint *b, *temp;
693 ALL_BREAKPOINTS_SAFE (b, temp)
697 /* If the call dummy breakpoint is at the entry point it will
698 cause problems when the inferior is rerun, so we better
700 if (b->type == bp_call_dummy)
701 delete_breakpoint (b);
703 /* Likewise for scope breakpoints. */
704 if (b->type == bp_watchpoint_scope)
705 delete_breakpoint (b);
707 /* Likewise for watchpoints on local expressions. */
708 if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint ||
709 b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
710 && b->exp_valid_block != NULL)
711 delete_breakpoint (b);
715 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
716 When continuing from a location with a breakpoint,
717 we actually single step once before calling insert_breakpoints. */
720 breakpoint_here_p (pc)
723 register struct breakpoint *b;
726 if (b->enable != disabled && b->address == pc)
732 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
733 because figuring out the saved SP would take too much time, at least using
734 get_saved_register on the 68k. This means that for this function to
735 work right a port must use the bp_call_dummy breakpoint. */
738 frame_in_dummy (frame)
741 struct breakpoint *b;
746 static unsigned LONGEST dummy[] = CALL_DUMMY;
748 if (b->type == bp_call_dummy
749 && b->frame == frame->frame
751 /* We need to check the PC as well as the frame on the sparc,
752 for signals.exp in the testsuite. */
755 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
756 && frame->pc <= b->address)
759 #endif /* CALL_DUMMY */
763 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
764 is valid for process/thread PID. */
767 breakpoint_thread_match (pc, pid)
771 struct breakpoint *b;
774 thread = pid_to_thread_id (pid);
777 if (b->enable != disabled
779 && (b->thread == -1 || b->thread == thread))
786 /* bpstat stuff. External routines' interfaces are documented
789 /* Clear a bpstat so that it says we are not at any breakpoint.
790 Also free any storage that is part of a bpstat. */
805 if (p->old_val != NULL)
806 value_free (p->old_val);
813 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
814 is part of the bpstat is copied as well. */
822 bpstat retval = NULL;
827 for (; bs != NULL; bs = bs->next)
829 tmp = (bpstat) xmalloc (sizeof (*tmp));
830 memcpy (tmp, bs, sizeof (*tmp));
832 /* This is the first thing in the chain. */
842 /* Find the bpstat associated with this breakpoint */
845 bpstat_find_breakpoint(bsp, breakpoint)
847 struct breakpoint *breakpoint;
849 if (bsp == NULL) return NULL;
851 for (;bsp != NULL; bsp = bsp->next) {
852 if (bsp->breakpoint_at == breakpoint) return bsp;
857 /* Return the breakpoint number of the first breakpoint we are stopped
858 at. *BSP upon return is a bpstat which points to the remaining
859 breakpoints stopped at (but which is not guaranteed to be good for
860 anything but further calls to bpstat_num).
861 Return 0 if passed a bpstat which does not indicate any breakpoints. */
867 struct breakpoint *b;
870 return 0; /* No more breakpoint values */
873 b = (*bsp)->breakpoint_at;
876 return -1; /* breakpoint that's been deleted since */
878 return b->number; /* We have its number */
882 /* Modify BS so that the actions will not be performed. */
885 bpstat_clear_actions (bs)
888 for (; bs != NULL; bs = bs->next)
891 if (bs->old_val != NULL)
893 value_free (bs->old_val);
899 /* Stub for cleaning up our state if we error-out of a breakpoint command */
902 cleanup_executing_breakpoints (ignore)
905 executing_breakpoint_commands = 0;
908 /* Execute all the commands associated with all the breakpoints at this
909 location. Any of these commands could cause the process to proceed
910 beyond this point, etc. We look out for such changes by checking
911 the global "breakpoint_proceeded" after each command. */
914 bpstat_do_actions (bsp)
918 struct cleanup *old_chain;
920 executing_breakpoint_commands = 1;
921 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
926 breakpoint_proceeded = 0;
927 for (; bs != NULL; bs = bs->next)
931 char *line = bs->commands->line;
932 bs->commands = bs->commands->next;
933 execute_command (line, 0);
934 /* If the inferior is proceeded by the command, bomb out now.
935 The bpstat chain has been blown away by wait_for_inferior.
936 But since execution has stopped again, there is a new bpstat
937 to look at, so start over. */
938 if (breakpoint_proceeded)
943 executing_breakpoint_commands = 0;
944 discard_cleanups (old_chain);
947 /* This is the normal print_it function for a bpstat. In the future,
948 much of this logic could (should?) be moved to bpstat_stop_status,
949 by having it set different print_it functions. */
955 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
956 which has since been deleted. */
957 if (bs->breakpoint_at == NULL
958 || (bs->breakpoint_at->type != bp_breakpoint
959 && bs->breakpoint_at->type != bp_hardware_breakpoint
960 && bs->breakpoint_at->type != bp_watchpoint
961 && bs->breakpoint_at->type != bp_read_watchpoint
962 && bs->breakpoint_at->type != bp_access_watchpoint
963 && bs->breakpoint_at->type != bp_hardware_watchpoint))
966 if (bs->breakpoint_at->type == bp_breakpoint ||
967 bs->breakpoint_at->type == bp_hardware_breakpoint)
969 /* I think the user probably only wants to see one breakpoint
970 number, not all of them. */
971 annotate_breakpoint (bs->breakpoint_at->number);
972 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
975 else if ((bs->old_val != NULL) &&
976 (bs->breakpoint_at->type == bp_watchpoint ||
977 bs->breakpoint_at->type == bp_access_watchpoint ||
978 bs->breakpoint_at->type == bp_hardware_watchpoint))
980 annotate_watchpoint (bs->breakpoint_at->number);
981 mention (bs->breakpoint_at);
982 printf_filtered ("\nOld value = ");
983 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
984 printf_filtered ("\nNew value = ");
985 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
987 printf_filtered ("\n");
988 value_free (bs->old_val);
990 /* More than one watchpoint may have been triggered. */
993 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
994 bs->breakpoint_at->type == bp_read_watchpoint)
996 mention (bs->breakpoint_at);
997 printf_filtered ("\nValue = ");
998 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1000 printf_filtered ("\n");
1003 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1007 /* Print a message indicating what happened. Returns nonzero to
1008 say that only the source line should be printed after this (zero
1009 return means print the frame as well as the source line). */
1010 /* Currently we always return zero. */
1020 val = (*bs->print_it) (bs);
1024 /* Maybe another breakpoint in the chain caused us to stop.
1025 (Currently all watchpoints go on the bpstat whether hit or
1026 not. That probably could (should) be changed, provided care is taken
1027 with respect to bpstat_explains_signal). */
1029 return bpstat_print (bs->next);
1031 /* We reached the end of the chain without printing anything. */
1035 /* Evaluate the expression EXP and return 1 if value is zero.
1036 This is used inside a catch_errors to evaluate the breakpoint condition.
1037 The argument is a "struct expression *" that has been cast to char * to
1038 make it pass through catch_errors. */
1041 breakpoint_cond_eval (exp)
1044 value_ptr mark = value_mark ();
1045 int i = !value_true (evaluate_expression ((struct expression *)exp));
1046 value_free_to_mark (mark);
1050 /* Allocate a new bpstat and chain it to the current one. */
1053 bpstat_alloc (b, cbs)
1054 register struct breakpoint *b;
1055 bpstat cbs; /* Current "bs" value */
1059 bs = (bpstat) xmalloc (sizeof (*bs));
1061 bs->breakpoint_at = b;
1062 /* If the condition is false, etc., don't do the commands. */
1063 bs->commands = NULL;
1065 bs->print_it = print_it_normal;
1071 /* Possible return values for watchpoint_check (this can't be an enum
1072 because of check_errors). */
1073 /* The watchpoint has been deleted. */
1074 #define WP_DELETED 1
1075 /* The value has changed. */
1076 #define WP_VALUE_CHANGED 2
1077 /* The value has not changed. */
1078 #define WP_VALUE_NOT_CHANGED 3
1080 /* Check watchpoint condition. */
1082 watchpoint_check (p)
1085 bpstat bs = (bpstat) p;
1086 struct breakpoint *b;
1087 FRAME saved_frame, fr;
1088 int within_current_scope, saved_level;
1090 /* Save the current frame and level so we can restore it after
1091 evaluating the watchpoint expression on its own frame. */
1092 saved_frame = selected_frame;
1093 saved_level = selected_frame_level;
1095 if (bs->breakpoint_at->exp_valid_block == NULL)
1096 within_current_scope = 1;
1099 fr = find_frame_addr_in_frame_chain (bs->breakpoint_at->watchpoint_frame);
1100 within_current_scope = (fr != NULL);
1101 if (within_current_scope)
1102 /* If we end up stopping, the current frame will get selected
1103 in normal_stop. So this call to select_frame won't affect
1105 select_frame (fr, -1);
1108 if (within_current_scope)
1110 /* We use value_{,free_to_}mark because it could be a
1111 *long* time before we return to the command level and
1112 call free_all_values. We can't call free_all_values because
1113 we might be in the middle of evaluating a function call. */
1115 value_ptr mark = value_mark ();
1116 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1117 if (!value_equal (bs->breakpoint_at->val, new_val))
1119 release_value (new_val);
1120 value_free_to_mark (mark);
1121 bs->old_val = bs->breakpoint_at->val;
1122 bs->breakpoint_at->val = new_val;
1123 /* We will stop here */
1124 select_frame (saved_frame, saved_level);
1125 return WP_VALUE_CHANGED;
1129 /* Nothing changed, don't do anything. */
1130 value_free_to_mark (mark);
1131 /* We won't stop here */
1132 select_frame (saved_frame, saved_level);
1133 return WP_VALUE_NOT_CHANGED;
1138 /* This seems like the only logical thing to do because
1139 if we temporarily ignored the watchpoint, then when
1140 we reenter the block in which it is valid it contains
1141 garbage (in the case of a function, it may have two
1142 garbage values, one before and one after the prologue).
1143 So we can't even detect the first assignment to it and
1144 watch after that (since the garbage may or may not equal
1145 the first value assigned). */
1147 Watchpoint %d deleted because the program has left the block in\n\
1148 which its expression is valid.\n", bs->breakpoint_at->number);
1149 if (bs->breakpoint_at->related_breakpoint)
1150 delete_breakpoint (bs->breakpoint_at->related_breakpoint);
1151 delete_breakpoint (bs->breakpoint_at);
1153 select_frame (saved_frame, saved_level);
1158 /* This is used when everything which needs to be printed has
1159 already been printed. But we still want to print the frame. */
1167 /* This is used when nothing should be printed for this bpstat entry. */
1176 /* Get a bpstat associated with having just stopped at address *PC
1177 and frame address FRAME_ADDRESS. Update *PC to point at the
1178 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1179 if this is known to not be a real breakpoint (it could still be a
1180 watchpoint, though). */
1182 /* Determine whether we stopped at a breakpoint, etc, or whether we
1183 don't understand this stop. Result is a chain of bpstat's such that:
1185 if we don't understand the stop, the result is a null pointer.
1187 if we understand why we stopped, the result is not null.
1189 Each element of the chain refers to a particular breakpoint or
1190 watchpoint at which we have stopped. (We may have stopped for
1191 several reasons concurrently.)
1193 Each element of the chain has valid next, breakpoint_at,
1194 commands, FIXME??? fields.
1199 bpstat_stop_status (pc, frame_address, not_a_breakpoint)
1201 FRAME_ADDR frame_address;
1202 int not_a_breakpoint;
1204 register struct breakpoint *b;
1206 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1207 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1208 int real_breakpoint = 0;
1210 /* Root of the chain of bpstat's */
1211 struct bpstat root_bs[1];
1212 /* Pointer to the last thing in the chain currently. */
1213 bpstat bs = root_bs;
1214 static char message1[] =
1215 "Error evaluating expression for watchpoint %d\n";
1216 char message[sizeof (message1) + 30 /* slop */];
1218 /* Get the address where the breakpoint would have been. */
1219 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1223 if (b->enable == disabled)
1226 if (b->type != bp_watchpoint
1227 && b->type != bp_hardware_watchpoint
1228 && b->type != bp_read_watchpoint
1229 && b->type != bp_access_watchpoint
1230 && b->type != bp_hardware_breakpoint
1231 && b->address != bp_addr)
1234 #ifndef DECR_PC_AFTER_HW_BREAK
1235 #define DECR_PC_AFTER_HW_BREAK 0
1237 if (b->type == bp_hardware_breakpoint
1238 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
1241 if (b->type != bp_watchpoint
1242 && b->type != bp_hardware_watchpoint
1243 && b->type != bp_read_watchpoint
1244 && b->type != bp_access_watchpoint
1245 && not_a_breakpoint)
1248 /* Come here if it's a watchpoint, or if the break address matches */
1250 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1255 sprintf (message, message1, b->number);
1256 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
1258 switch (catch_errors (watchpoint_check, (char *) bs, message,
1262 /* We've already printed what needs to be printed. */
1263 bs->print_it = print_it_done;
1266 case WP_VALUE_CHANGED:
1269 case WP_VALUE_NOT_CHANGED:
1271 bs->print_it = print_it_noop;
1278 /* Error from catch_errors. */
1279 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1280 if (b->related_breakpoint)
1281 delete_breakpoint (b->related_breakpoint);
1282 delete_breakpoint (b);
1283 /* We've already printed what needs to be printed. */
1284 bs->print_it = print_it_done;
1290 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
1296 addr = target_stopped_data_address();
1297 if (addr == 0) continue;
1298 for (v = b->val_chain; v; v = v->next)
1300 if (v->lval == lval_memory)
1304 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1310 switch (catch_errors (watchpoint_check, (char *) bs, message,
1314 /* We've already printed what needs to be printed. */
1315 bs->print_it = print_it_done;
1318 case WP_VALUE_CHANGED:
1319 case WP_VALUE_NOT_CHANGED:
1325 /* Error from catch_errors. */
1326 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1327 if (b->related_breakpoint)
1328 delete_breakpoint (b->related_breakpoint);
1329 delete_breakpoint (b);
1330 /* We've already printed what needs to be printed. */
1331 bs->print_it = print_it_done;
1335 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1337 real_breakpoint = 1;
1340 if (b->frame && b->frame != frame_address)
1344 int value_is_zero = 0;
1348 /* Need to select the frame, with all that implies
1349 so that the conditions will have the right context. */
1350 select_frame (get_current_frame (), 0);
1352 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1353 "Error in testing breakpoint condition:\n",
1355 /* FIXME-someday, should give breakpoint # */
1358 if (b->cond && value_is_zero)
1362 else if (b->ignore_count > 0)
1369 /* We will stop here */
1370 if (b->disposition == disable)
1371 b->enable = disabled;
1372 bs->commands = b->commands;
1375 if (bs->commands && STREQ ("silent", bs->commands->line))
1377 bs->commands = bs->commands->next;
1382 /* Print nothing for this entry if we dont stop or if we dont print. */
1383 if (bs->stop == 0 || bs->print == 0)
1384 bs->print_it = print_it_noop;
1387 bs->next = NULL; /* Terminate the chain */
1388 bs = root_bs->next; /* Re-grab the head of the chain */
1389 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1392 if (real_breakpoint)
1395 #if defined (SHIFT_INST_REGS)
1397 #else /* No SHIFT_INST_REGS. */
1399 #endif /* No SHIFT_INST_REGS. */
1402 #endif /* DECR_PC_AFTER_BREAK != 0. */
1404 /* The value of a hardware watchpoint hasn't changed, but the
1405 intermediate memory locations we are watching may have. */
1406 if (bs && ! bs->stop &&
1407 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
1408 bs->breakpoint_at->type == bp_read_watchpoint ||
1409 bs->breakpoint_at->type == bp_access_watchpoint))
1411 remove_breakpoints ();
1412 insert_breakpoints ();
1417 /* Tell what to do about this bpstat. */
1422 /* Classify each bpstat as one of the following. */
1424 /* This bpstat element has no effect on the main_action. */
1427 /* There was a watchpoint, stop but don't print. */
1430 /* There was a watchpoint, stop and print. */
1433 /* There was a breakpoint but we're not stopping. */
1436 /* There was a breakpoint, stop but don't print. */
1439 /* There was a breakpoint, stop and print. */
1442 /* We hit the longjmp breakpoint. */
1445 /* We hit the longjmp_resume breakpoint. */
1448 /* We hit the step_resume breakpoint. */
1451 /* We hit the through_sigtramp breakpoint. */
1454 /* This is just used to count how many enums there are. */
1458 /* Here is the table which drives this routine. So that we can
1459 format it pretty, we define some abbreviations for the
1460 enum bpstat_what codes. */
1461 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1462 #define stop_s BPSTAT_WHAT_STOP_SILENT
1463 #define stop_n BPSTAT_WHAT_STOP_NOISY
1464 #define single BPSTAT_WHAT_SINGLE
1465 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1466 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1467 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1468 #define sr BPSTAT_WHAT_STEP_RESUME
1469 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1471 /* "Can't happen." Might want to print an error message.
1472 abort() is not out of the question, but chances are GDB is just
1473 a bit confused, not unusable. */
1474 #define err BPSTAT_WHAT_STOP_NOISY
1476 /* Given an old action and a class, come up with a new action. */
1477 /* One interesting property of this table is that wp_silent is the same
1478 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1479 after stopping, the check for whether to step over a breakpoint
1480 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1481 reference to how we stopped. We retain separate wp_silent and bp_silent
1482 codes in case we want to change that someday. */
1484 /* step_resume entries: a step resume breakpoint overrides another
1485 breakpoint of signal handling (see comment in wait_for_inferior
1486 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1487 /* We handle the through_sigtramp_breakpoint the same way; having both
1488 one of those and a step_resume_breakpoint is probably very rare (?). */
1490 static const enum bpstat_what_main_action
1491 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1494 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr ts
1496 /*no_effect*/ {keep_c,stop_s,stop_n,single, setlr , clrlr , clrlrs, sr, ts},
1497 /*wp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1498 /*wp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1499 /*bp_nostop*/ {single,stop_s,stop_n,single, setlr , clrlrs, clrlrs, sr, ts},
1500 /*bp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1501 /*bp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1502 /*long_jump*/ {setlr ,stop_s,stop_n,setlr , err , err , err , sr, ts},
1503 /*long_resume*/ {clrlr ,stop_s,stop_n,clrlrs, err , err , err , sr, ts},
1504 /*step_resume*/ {sr ,sr ,sr ,sr , sr , sr , sr , sr, ts},
1505 /*through_sig*/ {ts ,ts ,ts ,ts , ts , ts , ts , ts, ts}
1517 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1518 struct bpstat_what retval;
1520 retval.call_dummy = 0;
1521 for (; bs != NULL; bs = bs->next)
1523 enum class bs_class = no_effect;
1524 if (bs->breakpoint_at == NULL)
1525 /* I suspect this can happen if it was a momentary breakpoint
1526 which has since been deleted. */
1528 switch (bs->breakpoint_at->type)
1531 case bp_hardware_breakpoint:
1537 bs_class = bp_noisy;
1539 bs_class = bp_silent;
1542 bs_class = bp_nostop;
1545 case bp_hardware_watchpoint:
1546 case bp_read_watchpoint:
1547 case bp_access_watchpoint:
1551 bs_class = wp_noisy;
1553 bs_class = wp_silent;
1556 /* There was a watchpoint, but we're not stopping. This requires
1557 no further action. */
1558 bs_class = no_effect;
1561 bs_class = long_jump;
1563 case bp_longjmp_resume:
1564 bs_class = long_resume;
1566 case bp_step_resume:
1569 bs_class = step_resume;
1572 /* It is for the wrong frame. */
1573 bs_class = bp_nostop;
1575 case bp_through_sigtramp:
1576 bs_class = through_sig;
1578 case bp_watchpoint_scope:
1579 bs_class = bp_nostop;
1583 /* Make sure the action is stop (silent or noisy), so infrun.c
1584 pops the dummy frame. */
1585 bs_class = bp_silent;
1586 retval.call_dummy = 1;
1589 current_action = table[(int)bs_class][(int)current_action];
1591 retval.main_action = current_action;
1595 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1596 without hardware support). This isn't related to a specific bpstat,
1597 just to things like whether watchpoints are set. */
1600 bpstat_should_step ()
1602 struct breakpoint *b;
1604 if (b->enable == enabled && b->type == bp_watchpoint)
1609 /* Print information on breakpoint number BNUM, or -1 if all.
1610 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1611 is nonzero, process only watchpoints. */
1614 breakpoint_1 (bnum, allflag)
1618 register struct breakpoint *b;
1619 register struct command_line *l;
1620 register struct symbol *sym;
1621 CORE_ADDR last_addr = (CORE_ADDR)-1;
1622 int found_a_breakpoint = 0;
1623 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1624 "until", "finish", "watchpoint",
1625 "hw watchpoint", "read watchpoint",
1626 "acc watchpoint", "longjmp",
1627 "longjmp resume", "step resume",
1628 "watchpoint scope", "call dummy" };
1629 static char *bpdisps[] = {"del", "dis", "keep"};
1630 static char bpenables[] = "ny";
1631 char wrap_indent[80];
1635 || bnum == b->number)
1637 /* We only print out user settable breakpoints unless the allflag is set. */
1639 && b->type != bp_breakpoint
1640 && b->type != bp_hardware_breakpoint
1641 && b->type != bp_watchpoint
1642 && b->type != bp_read_watchpoint
1643 && b->type != bp_access_watchpoint
1644 && b->type != bp_hardware_watchpoint)
1647 if (!found_a_breakpoint++)
1649 annotate_breakpoints_headers ();
1652 printf_filtered ("Num ");
1654 printf_filtered ("Type ");
1656 printf_filtered ("Disp ");
1658 printf_filtered ("Enb ");
1662 printf_filtered ("Address ");
1665 printf_filtered ("What\n");
1667 annotate_breakpoints_table ();
1672 printf_filtered ("%-3d ", b->number);
1674 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1676 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1678 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1680 strcpy (wrap_indent, " ");
1682 strcat (wrap_indent, " ");
1686 case bp_hardware_watchpoint:
1687 case bp_read_watchpoint:
1688 case bp_access_watchpoint:
1689 /* Field 4, the address, is omitted (which makes the columns
1690 not line up too nicely with the headers, but the effect
1691 is relatively readable). */
1692 if (annotation_level > 1)
1693 printf_filtered ("\n\032\032field 5\n");
1694 print_expression (b->exp, gdb_stdout);
1698 case bp_hardware_breakpoint:
1702 case bp_longjmp_resume:
1703 case bp_step_resume:
1704 case bp_through_sigtramp:
1705 case bp_watchpoint_scope:
1710 /* FIXME-32x64: need a print_address_numeric with
1714 local_hex_string_custom
1715 ((unsigned long) b->address, "08l"));
1720 last_addr = b->address;
1723 sym = find_pc_function (b->address);
1726 fputs_filtered ("in ", gdb_stdout);
1727 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1728 wrap_here (wrap_indent);
1729 fputs_filtered (" at ", gdb_stdout);
1731 fputs_filtered (b->source_file, gdb_stdout);
1732 printf_filtered (":%d", b->line_number);
1735 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1739 printf_filtered ("\n");
1745 printf_filtered ("\tstop only in stack frame at ");
1746 print_address_numeric (b->frame, 1, gdb_stdout);
1747 printf_filtered ("\n");
1754 printf_filtered ("\tstop only if ");
1755 print_expression (b->cond, gdb_stdout);
1756 printf_filtered ("\n");
1759 if (b->ignore_count)
1763 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1766 if ((l = b->commands))
1772 fputs_filtered ("\t", gdb_stdout);
1773 fputs_filtered (l->line, gdb_stdout);
1774 fputs_filtered ("\n", gdb_stdout);
1780 if (!found_a_breakpoint)
1783 printf_filtered ("No breakpoints or watchpoints.\n");
1785 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1788 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1789 that a comparison of an unsigned with -1 is always false. */
1790 if (last_addr != (CORE_ADDR)-1)
1791 set_next_address (last_addr);
1793 annotate_breakpoints_table_end ();
1798 breakpoints_info (bnum_exp, from_tty)
1805 bnum = parse_and_eval_address (bnum_exp);
1807 breakpoint_1 (bnum, 0);
1810 #if MAINTENANCE_CMDS
1814 maintenance_info_breakpoints (bnum_exp, from_tty)
1821 bnum = parse_and_eval_address (bnum_exp);
1823 breakpoint_1 (bnum, 1);
1828 /* Print a message describing any breakpoints set at PC. */
1831 describe_other_breakpoints (pc)
1832 register CORE_ADDR pc;
1834 register int others = 0;
1835 register struct breakpoint *b;
1838 if (b->address == pc)
1842 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1844 if (b->address == pc)
1850 (b->enable == disabled) ? " (disabled)" : "",
1851 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1853 printf_filtered ("also set at pc ");
1854 print_address_numeric (pc, 1, gdb_stdout);
1855 printf_filtered (".\n");
1859 /* Set the default place to put a breakpoint
1860 for the `break' command with no arguments. */
1863 set_default_breakpoint (valid, addr, symtab, line)
1866 struct symtab *symtab;
1869 default_breakpoint_valid = valid;
1870 default_breakpoint_address = addr;
1871 default_breakpoint_symtab = symtab;
1872 default_breakpoint_line = line;
1875 /* Rescan breakpoints at address ADDRESS,
1876 marking the first one as "first" and any others as "duplicates".
1877 This is so that the bpt instruction is only inserted once. */
1880 check_duplicates (address)
1883 register struct breakpoint *b;
1884 register int count = 0;
1886 if (address == 0) /* Watchpoints are uninteresting */
1890 if (b->enable != disabled && b->address == address)
1893 b->duplicate = count > 1;
1897 /* Low level routine to set a breakpoint.
1898 Takes as args the three things that every breakpoint must have.
1899 Returns the breakpoint object so caller can set other things.
1900 Does not set the breakpoint number!
1901 Does not print anything.
1903 ==> This routine should not be called if there is a chance of later
1904 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1905 your arguments BEFORE calling this routine! */
1907 static struct breakpoint *
1908 set_raw_breakpoint (sal)
1909 struct symtab_and_line sal;
1911 register struct breakpoint *b, *b1;
1913 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1914 memset (b, 0, sizeof (*b));
1915 b->address = sal.pc;
1916 if (sal.symtab == NULL)
1917 b->source_file = NULL;
1919 b->source_file = savestring (sal.symtab->filename,
1920 strlen (sal.symtab->filename));
1922 b->line_number = sal.line;
1923 b->enable = enabled;
1926 b->ignore_count = 0;
1930 /* Add this breakpoint to the end of the chain
1931 so that a list of breakpoints will come out in order
1932 of increasing numbers. */
1934 b1 = breakpoint_chain;
1936 breakpoint_chain = b;
1944 check_duplicates (sal.pc);
1945 breakpoints_changed ();
1951 create_longjmp_breakpoint(func_name)
1954 struct symtab_and_line sal;
1955 struct breakpoint *b;
1956 static int internal_breakpoint_number = -1;
1958 if (func_name != NULL)
1960 struct minimal_symbol *m;
1962 m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
1964 sal.pc = SYMBOL_VALUE_ADDRESS (m);
1974 b = set_raw_breakpoint(sal);
1977 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
1978 b->disposition = donttouch;
1979 b->enable = disabled;
1982 b->addr_string = strsave(func_name);
1983 b->number = internal_breakpoint_number--;
1986 /* Call this routine when stepping and nexting to enable a breakpoint if we do
1987 a longjmp(). When we hit that breakpoint, call
1988 set_longjmp_resume_breakpoint() to figure out where we are going. */
1991 enable_longjmp_breakpoint()
1993 register struct breakpoint *b;
1996 if (b->type == bp_longjmp)
1998 b->enable = enabled;
1999 check_duplicates (b->address);
2004 disable_longjmp_breakpoint()
2006 register struct breakpoint *b;
2009 if ( b->type == bp_longjmp
2010 || b->type == bp_longjmp_resume)
2012 b->enable = disabled;
2013 check_duplicates (b->address);
2018 hw_breakpoint_used_count()
2020 register struct breakpoint *b;
2025 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2033 hw_watchpoint_used_count(type, other_type_used)
2035 int *other_type_used;
2037 register struct breakpoint *b;
2040 *other_type_used = 0;
2043 if (b->enable == enabled)
2045 if (b->type == type) i++;
2046 else if ((b->type == bp_hardware_watchpoint ||
2047 b->type == bp_read_watchpoint ||
2048 b->type == bp_access_watchpoint)
2049 && b->enable == enabled)
2050 *other_type_used = 1;
2056 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2057 breakpoint at the target of the jmp_buf.
2059 FIXME - This ought to be done by setting a temporary breakpoint that gets
2060 deleted automatically...
2064 set_longjmp_resume_breakpoint(pc, frame)
2068 register struct breakpoint *b;
2071 if (b->type == bp_longjmp_resume)
2074 b->enable = enabled;
2076 b->frame = FRAME_FP(frame);
2079 check_duplicates (b->address);
2084 /* Set a breakpoint that will evaporate an end of command
2085 at address specified by SAL.
2086 Restrict it to frame FRAME if FRAME is nonzero. */
2089 set_momentary_breakpoint (sal, frame, type)
2090 struct symtab_and_line sal;
2094 register struct breakpoint *b;
2095 b = set_raw_breakpoint (sal);
2097 b->enable = enabled;
2098 b->disposition = donttouch;
2099 b->frame = (frame ? FRAME_FP (frame) : 0);
2105 clear_momentary_breakpoints ()
2107 register struct breakpoint *b;
2109 if (b->disposition == delete)
2111 delete_breakpoint (b);
2117 /* Tell the user we have just set a breakpoint B. */
2120 struct breakpoint *b;
2125 printf_filtered ("Watchpoint %d: ", b->number);
2126 print_expression (b->exp, gdb_stdout);
2128 case bp_hardware_watchpoint:
2129 printf_filtered ("Hardware watchpoint %d: ", b->number);
2130 print_expression (b->exp, gdb_stdout);
2132 case bp_read_watchpoint:
2133 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2134 print_expression (b->exp, gdb_stdout);
2136 case bp_access_watchpoint:
2137 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2138 print_expression (b->exp, gdb_stdout);
2141 printf_filtered ("Breakpoint %d at ", b->number);
2142 print_address_numeric (b->address, 1, gdb_stdout);
2144 printf_filtered (": file %s, line %d.",
2145 b->source_file, b->line_number);
2147 case bp_hardware_breakpoint:
2148 printf_filtered ("Hardware assisted breakpoint %d at ", b->number);
2149 print_address_numeric (b->address, 1, gdb_stdout);
2151 printf_filtered (": file %s, line %d.",
2152 b->source_file, b->line_number);
2157 case bp_longjmp_resume:
2158 case bp_step_resume:
2159 case bp_through_sigtramp:
2161 case bp_watchpoint_scope:
2164 printf_filtered ("\n");
2168 /* Nobody calls this currently. */
2169 /* Set a breakpoint from a symtab and line.
2170 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2171 ADDR_STRING is a malloc'd string holding the name of where we are
2172 setting the breakpoint. This is used later to re-set it after the
2173 program is relinked and symbols are reloaded.
2174 Print the same confirmation messages that the breakpoint command prints. */
2177 set_breakpoint (s, line, tempflag, addr_string)
2183 register struct breakpoint *b;
2184 struct symtab_and_line sal;
2189 resolve_sal_pc (&sal); /* Might error out */
2190 describe_other_breakpoints (sal.pc);
2192 b = set_raw_breakpoint (sal);
2193 set_breakpoint_count (breakpoint_count + 1);
2194 b->number = breakpoint_count;
2195 b->type = bp_breakpoint;
2197 b->addr_string = addr_string;
2198 b->enable = enabled;
2199 b->disposition = tempflag ? delete : donttouch;
2205 /* Set a breakpoint according to ARG (function, linenum or *address)
2206 flag: first bit : 0 non-temporary, 1 temporary.
2207 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2210 break_command_1 (arg, flag, from_tty)
2214 int tempflag, hardwareflag;
2215 struct symtabs_and_lines sals;
2216 struct symtab_and_line sal;
2217 register struct expression *cond = 0;
2218 register struct breakpoint *b;
2220 /* Pointers in arg to the start, and one past the end, of the condition. */
2221 char *cond_start = NULL;
2222 char *cond_end = NULL;
2223 /* Pointers in arg to the start, and one past the end,
2224 of the address part. */
2225 char *addr_start = NULL;
2226 char *addr_end = NULL;
2227 struct cleanup *old_chain;
2228 struct cleanup *canonical_strings_chain = NULL;
2229 char **canonical = (char **)NULL;
2233 hardwareflag = flag & 2;
2234 tempflag = flag & 1;
2239 sal.line = sal.pc = sal.end = 0;
2242 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2244 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2245 && (arg[2] == ' ' || arg[2] == '\t')))
2247 if (default_breakpoint_valid)
2249 sals.sals = (struct symtab_and_line *)
2250 xmalloc (sizeof (struct symtab_and_line));
2251 sal.pc = default_breakpoint_address;
2252 sal.line = default_breakpoint_line;
2253 sal.symtab = default_breakpoint_symtab;
2258 error ("No default breakpoint address now.");
2264 /* Force almost all breakpoints to be in terms of the
2265 current_source_symtab (which is decode_line_1's default). This
2266 should produce the results we want almost all of the time while
2267 leaving default_breakpoint_* alone. */
2268 if (default_breakpoint_valid
2269 && (!current_source_symtab
2270 || (arg && (*arg == '+' || *arg == '-'))))
2271 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2272 default_breakpoint_line, &canonical);
2274 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2282 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2283 the following `for' loop errors out. */
2284 old_chain = make_cleanup (free, sals.sals);
2285 if (canonical != (char **)NULL)
2287 make_cleanup (free, canonical);
2288 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2289 for (i = 0; i < sals.nelts; i++)
2291 if (canonical[i] != NULL)
2292 make_cleanup (free, canonical[i]);
2296 thread = -1; /* No specific thread yet */
2298 /* Resolve all line numbers to PC's, and verify that conditions
2299 can be parsed, before setting any breakpoints. */
2300 for (i = 0; i < sals.nelts; i++)
2302 char *tok, *end_tok;
2305 resolve_sal_pc (&sals.sals[i]);
2311 while (*tok == ' ' || *tok == '\t')
2316 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2319 toklen = end_tok - tok;
2321 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2323 tok = cond_start = end_tok + 1;
2324 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2327 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2333 thread = strtol (tok, &tok, 0);
2335 error ("Junk after thread keyword.");
2336 if (!valid_thread_id (thread))
2337 error ("Unknown thread %d\n", thread);
2340 error ("Junk at end of arguments.");
2345 int i, other_type_used, target_resources_ok;
2346 i = hw_breakpoint_used_count();
2347 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2348 bp_hardware_breakpoint, i+sals.nelts, 0);
2349 if (target_resources_ok == 0)
2350 error ("No hardware breakpoint support in the target.");
2351 else if (target_resources_ok < 0)
2352 error ("Hardware breakpoints used exceeds limit.");
2355 /* Remove the canonical strings from the cleanup, they are needed below. */
2356 if (canonical != (char **)NULL)
2357 discard_cleanups (canonical_strings_chain);
2359 /* Now set all the breakpoints. */
2360 for (i = 0; i < sals.nelts; i++)
2365 describe_other_breakpoints (sal.pc);
2367 b = set_raw_breakpoint (sal);
2368 set_breakpoint_count (breakpoint_count + 1);
2369 b->number = breakpoint_count;
2370 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2374 /* If a canonical line spec is needed use that instead of the
2376 if (canonical != (char **)NULL && canonical[i] != NULL)
2377 b->addr_string = canonical[i];
2378 else if (addr_start)
2379 b->addr_string = savestring (addr_start, addr_end - addr_start);
2381 b->cond_string = savestring (cond_start, cond_end - cond_start);
2383 b->enable = enabled;
2384 b->disposition = tempflag ? delete : donttouch;
2391 printf_filtered ("Multiple breakpoints were set.\n");
2392 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2394 do_cleanups (old_chain);
2397 /* Helper function for break_command_1 and disassemble_command. */
2400 resolve_sal_pc (sal)
2401 struct symtab_and_line *sal;
2405 if (sal->pc == 0 && sal->symtab != 0)
2407 pc = find_line_pc (sal->symtab, sal->line);
2409 error ("No line %d in file \"%s\".",
2410 sal->line, sal->symtab->filename);
2415 #define BP_TEMPFLAG 1
2416 #define BP_HARDWAREFLAG 2
2418 break_command (arg, from_tty)
2422 break_command_1 (arg, 0, from_tty);
2426 tbreak_command (arg, from_tty)
2430 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2434 hbreak_command (arg, from_tty)
2438 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2442 thbreak_command (arg, from_tty)
2446 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2450 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2453 watch_command_1 (arg, accessflag, from_tty)
2458 struct breakpoint *b;
2459 struct symtab_and_line sal;
2460 struct expression *exp;
2461 struct block *exp_valid_block;
2462 struct value *val, *mark;
2463 FRAME frame, prev_frame;
2464 char *exp_start = NULL;
2465 char *exp_end = NULL;
2466 char *tok, *end_tok;
2468 char *cond_start = NULL;
2469 char *cond_end = NULL;
2470 struct expression *cond = NULL;
2471 int i, other_type_used, target_resources_ok;
2472 enum bptype bp_type;
2479 /* Parse arguments. */
2480 innermost_block = NULL;
2482 exp = parse_exp_1 (&arg, 0, 0);
2484 exp_valid_block = innermost_block;
2485 mark = value_mark ();
2486 val = evaluate_expression (exp);
2487 release_value (val);
2488 if (VALUE_LAZY (val))
2489 value_fetch_lazy (val);
2492 while (*tok == ' ' || *tok == '\t')
2496 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2499 toklen = end_tok - tok;
2500 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2502 tok = cond_start = end_tok + 1;
2503 cond = parse_exp_1 (&tok, 0, 0);
2507 error("Junk at end of command.");
2509 if (accessflag == 1) bp_type = bp_read_watchpoint;
2510 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2511 else bp_type = bp_hardware_watchpoint;
2513 mem_cnt = can_use_hardware_watchpoint (val);
2514 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2515 error ("Expression cannot be implemented with read/access watchpoint.");
2517 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2518 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2519 bp_type, i + mem_cnt, other_type_used);
2520 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2521 error ("Target does not have this type of hardware watchpoint support.");
2522 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2523 error ("Target resources have been allocated for other types of watchpoints.");
2526 /* Now set up the breakpoint. */
2527 b = set_raw_breakpoint (sal);
2528 set_breakpoint_count (breakpoint_count + 1);
2529 b->number = breakpoint_count;
2530 b->disposition = donttouch;
2532 b->exp_valid_block = exp_valid_block;
2533 b->exp_string = savestring (exp_start, exp_end - exp_start);
2537 b->cond_string = savestring (cond_start, cond_end - cond_start);
2541 frame = block_innermost_frame (exp_valid_block);
2544 prev_frame = get_prev_frame (frame);
2545 b->watchpoint_frame = FRAME_FP (frame);
2548 b->watchpoint_frame = (CORE_ADDR)0;
2550 if (mem_cnt && target_resources_ok > 0)
2553 b->type = bp_watchpoint;
2555 /* If the expression is "local", then set up a "watchpoint scope"
2556 breakpoint at the point where we've left the scope of the watchpoint
2558 if (innermost_block)
2560 struct breakpoint *scope_breakpoint;
2561 struct symtab_and_line scope_sal;
2565 scope_sal.pc = get_frame_pc (prev_frame);
2566 scope_sal.symtab = NULL;
2569 scope_breakpoint = set_raw_breakpoint (scope_sal);
2570 set_breakpoint_count (breakpoint_count + 1);
2571 scope_breakpoint->number = breakpoint_count;
2573 scope_breakpoint->type = bp_watchpoint_scope;
2574 scope_breakpoint->enable = enabled;
2576 /* Automatically delete the breakpoint when it hits. */
2577 scope_breakpoint->disposition = delete;
2579 /* Only break in the proper frame (help with recursion). */
2580 scope_breakpoint->frame = prev_frame->frame;
2582 /* Set the address at which we will stop. */
2583 scope_breakpoint->address = get_frame_pc (prev_frame);
2585 /* The scope breakpoint is related to the watchpoint. We
2586 will need to act on them together. */
2587 b->related_breakpoint = scope_breakpoint;
2590 value_free_to_mark (mark);
2594 /* Return count of locations need to be watched and can be handled
2595 in hardware. If the watchpoint can not be handled
2596 in hardware return zero. */
2599 can_use_hardware_watchpoint (v)
2602 int found_memory_cnt = 0;
2604 /* Make sure all the intermediate values are in memory. Also make sure
2605 we found at least one memory expression. Guards against watch 0x12345,
2606 which is meaningless, but could cause errors if one tries to insert a
2607 hardware watchpoint for the constant expression. */
2608 for ( ; v; v = v->next)
2610 if (v->lval == lval_memory)
2612 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2615 else if (v->lval != not_lval && v->modifiable == 0)
2619 /* The expression itself looks suitable for using a hardware
2620 watchpoint, but give the target machine a chance to reject it. */
2621 return found_memory_cnt;
2624 static void watch_command (arg, from_tty)
2628 watch_command_1 (arg, 0, from_tty);
2631 static void rwatch_command (arg, from_tty)
2635 watch_command_1 (arg, 1, from_tty);
2638 static void awatch_command (arg, from_tty)
2642 watch_command_1 (arg, 2, from_tty);
2647 * Helper routine for the until_command routine in infcmd.c. Here
2648 * because it uses the mechanisms of breakpoints.
2652 until_break_command (arg, from_tty)
2656 struct symtabs_and_lines sals;
2657 struct symtab_and_line sal;
2658 FRAME prev_frame = get_prev_frame (selected_frame);
2659 struct breakpoint *breakpoint;
2660 struct cleanup *old_chain;
2662 clear_proceed_status ();
2664 /* Set a breakpoint where the user wants it and at return from
2667 if (default_breakpoint_valid)
2668 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2669 default_breakpoint_line, (char ***)NULL);
2671 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2673 if (sals.nelts != 1)
2674 error ("Couldn't get information on specified line.");
2677 free ((PTR)sals.sals); /* malloc'd, so freed */
2680 error ("Junk at end of arguments.");
2682 resolve_sal_pc (&sal);
2684 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2686 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2688 /* Keep within the current frame */
2692 struct frame_info *fi;
2694 fi = get_frame_info (prev_frame);
2695 sal = find_pc_line (fi->pc, 0);
2697 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2698 make_cleanup(delete_breakpoint, breakpoint);
2701 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2702 do_cleanups(old_chain);
2706 /* These aren't used; I don't konw what they were for. */
2707 /* Set a breakpoint at the catch clause for NAME. */
2709 catch_breakpoint (name)
2715 disable_catch_breakpoint ()
2720 delete_catch_breakpoint ()
2725 enable_catch_breakpoint ()
2732 struct sal_chain *next;
2733 struct symtab_and_line sal;
2737 /* This isn't used; I don't know what it was for. */
2738 /* For each catch clause identified in ARGS, run FUNCTION
2739 with that clause as an argument. */
2740 static struct symtabs_and_lines
2741 map_catch_names (args, function)
2745 register char *p = args;
2747 struct symtabs_and_lines sals;
2749 struct sal_chain *sal_chain = 0;
2753 error_no_arg ("one or more catch names");
2761 /* Don't swallow conditional part. */
2762 if (p1[0] == 'i' && p1[1] == 'f'
2763 && (p1[2] == ' ' || p1[2] == '\t'))
2769 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2773 if (*p1 && *p1 != ' ' && *p1 != '\t')
2774 error ("Arguments must be catch names.");
2780 struct sal_chain *next
2781 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2782 next->next = sal_chain;
2783 next->sal = get_catch_sal (p);
2788 printf_unfiltered ("No catch clause for exception %s.\n", p);
2793 while (*p == ' ' || *p == '\t') p++;
2798 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2800 static struct symtabs_and_lines
2801 get_catch_sals (this_level_only)
2802 int this_level_only;
2804 register struct blockvector *bl;
2805 register struct block *block;
2806 int index, have_default = 0;
2807 struct frame_info *fi;
2809 struct symtabs_and_lines sals;
2810 struct sal_chain *sal_chain = 0;
2811 char *blocks_searched;
2813 /* Not sure whether an error message is always the correct response,
2814 but it's better than a core dump. */
2815 if (selected_frame == NULL)
2816 error ("No selected frame.");
2817 block = get_frame_block (selected_frame);
2818 fi = get_frame_info (selected_frame);
2825 error ("No symbol table info available.\n");
2827 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2828 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2829 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2833 CORE_ADDR end = BLOCK_END (block) - 4;
2836 if (bl != blockvector_for_pc (end, &index))
2837 error ("blockvector blotch");
2838 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2839 error ("blockvector botch");
2840 last_index = BLOCKVECTOR_NBLOCKS (bl);
2843 /* Don't print out blocks that have gone by. */
2844 while (index < last_index
2845 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2848 while (index < last_index
2849 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2851 if (blocks_searched[index] == 0)
2853 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2856 register struct symbol *sym;
2858 nsyms = BLOCK_NSYMS (b);
2860 for (i = 0; i < nsyms; i++)
2862 sym = BLOCK_SYM (b, i);
2863 if (STREQ (SYMBOL_NAME (sym), "default"))
2869 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2871 struct sal_chain *next = (struct sal_chain *)
2872 alloca (sizeof (struct sal_chain));
2873 next->next = sal_chain;
2874 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2878 blocks_searched[index] = 1;
2884 if (sal_chain && this_level_only)
2887 /* After handling the function's top-level block, stop.
2888 Don't continue to its superblock, the block of
2889 per-file symbols. */
2890 if (BLOCK_FUNCTION (block))
2892 block = BLOCK_SUPERBLOCK (block);
2897 struct sal_chain *tmp_chain;
2899 /* Count the number of entries. */
2900 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2901 tmp_chain = tmp_chain->next)
2905 sals.sals = (struct symtab_and_line *)
2906 xmalloc (index * sizeof (struct symtab_and_line));
2907 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2908 sals.sals[index] = sal_chain->sal;
2914 /* Commands to deal with catching exceptions. */
2917 catch_command_1 (arg, tempflag, from_tty)
2922 /* First, translate ARG into something we can deal with in terms
2925 struct symtabs_and_lines sals;
2926 struct symtab_and_line sal;
2927 register struct expression *cond = 0;
2928 register struct breakpoint *b;
2932 sal.line = sal.pc = sal.end = 0;
2935 /* If no arg given, or if first arg is 'if ', all active catch clauses
2936 are breakpointed. */
2938 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2939 && (arg[2] == ' ' || arg[2] == '\t')))
2941 /* Grab all active catch clauses. */
2942 sals = get_catch_sals (0);
2946 /* Grab selected catch clauses. */
2947 error ("catch NAME not implemented");
2949 /* This isn't used; I don't know what it was for. */
2950 sals = map_catch_names (arg, catch_breakpoint);
2958 for (i = 0; i < sals.nelts; i++)
2960 resolve_sal_pc (&sals.sals[i]);
2964 if (arg[0] == 'i' && arg[1] == 'f'
2965 && (arg[2] == ' ' || arg[2] == '\t'))
2966 cond = parse_exp_1 ((arg += 2, &arg),
2967 block_for_pc (sals.sals[i].pc), 0);
2969 error ("Junk at end of arguments.");
2974 for (i = 0; i < sals.nelts; i++)
2979 describe_other_breakpoints (sal.pc);
2981 b = set_raw_breakpoint (sal);
2982 set_breakpoint_count (breakpoint_count + 1);
2983 b->number = breakpoint_count;
2984 b->type = bp_breakpoint;
2986 b->enable = enabled;
2987 b->disposition = tempflag ? delete : donttouch;
2994 printf_unfiltered ("Multiple breakpoints were set.\n");
2995 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2997 free ((PTR)sals.sals);
3001 /* These aren't used; I don't know what they were for. */
3002 /* Disable breakpoints on all catch clauses described in ARGS. */
3004 disable_catch (args)
3007 /* Map the disable command to catch clauses described in ARGS. */
3010 /* Enable breakpoints on all catch clauses described in ARGS. */
3015 /* Map the disable command to catch clauses described in ARGS. */
3018 /* Delete breakpoints on all catch clauses in the active scope. */
3023 /* Map the delete command to catch clauses described in ARGS. */
3028 catch_command (arg, from_tty)
3032 catch_command_1 (arg, 0, from_tty);
3036 clear_command (arg, from_tty)
3040 register struct breakpoint *b, *b1;
3041 struct symtabs_and_lines sals;
3042 struct symtab_and_line sal;
3043 register struct breakpoint *found;
3048 sals = decode_line_spec (arg, 1);
3052 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3053 sal.line = default_breakpoint_line;
3054 sal.symtab = default_breakpoint_symtab;
3056 if (sal.symtab == 0)
3057 error ("No source file specified.");
3063 for (i = 0; i < sals.nelts; i++)
3065 /* If exact pc given, clear bpts at that pc.
3066 But if sal.pc is zero, clear all bpts on specified line. */
3068 found = (struct breakpoint *) 0;
3069 while (breakpoint_chain
3071 ? breakpoint_chain->address == sal.pc
3072 : (breakpoint_chain->source_file != NULL
3073 && sal.symtab != NULL
3074 && STREQ (breakpoint_chain->source_file,
3075 sal.symtab->filename)
3076 && breakpoint_chain->line_number == sal.line)))
3078 b1 = breakpoint_chain;
3079 breakpoint_chain = b1->next;
3086 && b->next->type != bp_watchpoint
3087 && b->next->type != bp_hardware_watchpoint
3088 && b->next->type != bp_read_watchpoint
3089 && b->next->type != bp_access_watchpoint
3091 ? b->next->address == sal.pc
3092 : (b->next->source_file != NULL
3093 && sal.symtab != NULL
3094 && STREQ (b->next->source_file, sal.symtab->filename)
3095 && b->next->line_number == sal.line)))
3106 error ("No breakpoint at %s.", arg);
3108 error ("No breakpoint at this line.");
3111 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3112 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3113 breakpoints_changed ();
3116 if (from_tty) printf_unfiltered ("%d ", found->number);
3118 delete_breakpoint (found);
3121 if (from_tty) putchar_unfiltered ('\n');
3123 free ((PTR)sals.sals);
3126 /* Delete breakpoint in BS if they are `delete' breakpoints.
3127 This is called after any breakpoint is hit, or after errors. */
3130 breakpoint_auto_delete (bs)
3133 for (; bs; bs = bs->next)
3134 if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
3136 delete_breakpoint (bs->breakpoint_at);
3139 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3142 delete_breakpoint (bpt)
3143 struct breakpoint *bpt;
3145 register struct breakpoint *b;
3149 remove_breakpoint (bpt);
3151 if (breakpoint_chain == bpt)
3152 breakpoint_chain = bpt->next;
3157 b->next = bpt->next;
3161 check_duplicates (bpt->address);
3162 /* If this breakpoint was inserted, and there is another breakpoint
3163 at the same address, we need to insert the other breakpoint. */
3165 && bpt->type != bp_hardware_watchpoint
3166 && bpt->type != bp_read_watchpoint
3167 && bpt->type != bp_access_watchpoint)
3170 if (b->address == bpt->address
3172 && b->enable != disabled)
3175 val = target_insert_breakpoint (b->address, b->shadow_contents);
3178 target_terminal_ours_for_output ();
3179 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3180 memory_error (val, b->address); /* which bombs us out */
3187 free_command_lines (&bpt->commands);
3190 if (bpt->cond_string != NULL)
3191 free (bpt->cond_string);
3192 if (bpt->addr_string != NULL)
3193 free (bpt->addr_string);
3194 if (bpt->exp_string != NULL)
3195 free (bpt->exp_string);
3196 if (bpt->source_file != NULL)
3197 free (bpt->source_file);
3199 breakpoints_changed ();
3201 /* Be sure no bpstat's are pointing at it after it's been freed. */
3202 /* FIXME, how can we find all bpstat's?
3203 We just check stop_bpstat for now. */
3204 for (bs = stop_bpstat; bs; bs = bs->next)
3205 if (bs->breakpoint_at == bpt)
3206 bs->breakpoint_at = NULL;
3211 delete_command (arg, from_tty)
3218 /* Ask user only if there are some breakpoints to delete. */
3220 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
3222 /* No arg; clear all breakpoints. */
3223 while (breakpoint_chain)
3224 delete_breakpoint (breakpoint_chain);
3228 map_breakpoint_numbers (arg, delete_breakpoint);
3231 /* Reset a breakpoint given it's struct breakpoint * BINT.
3232 The value we return ends up being the return value from catch_errors.
3233 Unused in this case. */
3236 breakpoint_re_set_one (bint)
3239 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3242 struct symtabs_and_lines sals;
3244 enum enable save_enable;
3249 case bp_hardware_breakpoint:
3250 if (b->addr_string == NULL)
3252 /* Anything without a string can't be re-set. */
3253 delete_breakpoint (b);
3256 /* In case we have a problem, disable this breakpoint. We'll restore
3257 its status if we succeed. */
3258 save_enable = b->enable;
3259 b->enable = disabled;
3262 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3263 for (i = 0; i < sals.nelts; i++)
3265 resolve_sal_pc (&sals.sals[i]);
3267 /* Reparse conditions, they might contain references to the
3269 if (b->cond_string != NULL)
3273 free ((PTR)b->cond);
3274 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3277 /* We need to re-set the breakpoint if the address changes...*/
3278 if (b->address != sals.sals[i].pc
3279 /* ...or new and old breakpoints both have source files, and
3280 the source file name or the line number changes... */
3281 || (b->source_file != NULL
3282 && sals.sals[i].symtab != NULL
3283 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3284 || b->line_number != sals.sals[i].line)
3286 /* ...or we switch between having a source file and not having
3288 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3291 if (b->source_file != NULL)
3292 free (b->source_file);
3293 if (sals.sals[i].symtab == NULL)
3294 b->source_file = NULL;
3297 savestring (sals.sals[i].symtab->filename,
3298 strlen (sals.sals[i].symtab->filename));
3299 b->line_number = sals.sals[i].line;
3300 b->address = sals.sals[i].pc;
3302 check_duplicates (b->address);
3306 /* Might be better to do this just once per breakpoint_re_set,
3307 rather than once for every breakpoint. */
3308 breakpoints_changed ();
3310 b->enable = save_enable; /* Restore it, this worked. */
3312 free ((PTR)sals.sals);
3316 case bp_hardware_watchpoint:
3317 case bp_read_watchpoint:
3318 case bp_access_watchpoint:
3319 innermost_block = NULL;
3320 /* The issue arises of what context to evaluate this in. The same
3321 one as when it was set, but what does that mean when symbols have
3322 been re-read? We could save the filename and functionname, but
3323 if the context is more local than that, the best we could do would
3324 be something like how many levels deep and which index at that
3325 particular level, but that's going to be less stable than filenames
3326 or functionnames. */
3327 /* So for now, just use a global context. */
3328 b->exp = parse_expression (b->exp_string);
3329 b->exp_valid_block = innermost_block;
3330 mark = value_mark ();
3331 b->val = evaluate_expression (b->exp);
3332 release_value (b->val);
3333 if (VALUE_LAZY (b->val))
3334 value_fetch_lazy (b->val);
3336 if (b->cond_string != NULL)
3339 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3341 if (b->enable == enabled)
3343 value_free_to_mark (mark);
3347 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3352 case bp_longjmp_resume:
3353 case bp_watchpoint_scope:
3355 delete_breakpoint (b);
3362 /* Re-set all breakpoints after symbols have been re-loaded. */
3364 breakpoint_re_set ()
3366 struct breakpoint *b, *temp;
3367 static char message1[] = "Error in re-setting breakpoint %d:\n";
3368 char message[sizeof (message1) + 30 /* slop */];
3370 ALL_BREAKPOINTS_SAFE (b, temp)
3372 sprintf (message, message1, b->number); /* Format possible error msg */
3373 catch_errors (breakpoint_re_set_one, (char *) b, message,
3377 create_longjmp_breakpoint("longjmp");
3378 create_longjmp_breakpoint("_longjmp");
3379 create_longjmp_breakpoint("siglongjmp");
3380 create_longjmp_breakpoint(NULL);
3383 /* Took this out (temporaliy at least), since it produces an extra
3384 blank line at startup. This messes up the gdbtests. -PB */
3385 /* Blank line to finish off all those mention() messages we just printed. */
3386 printf_filtered ("\n");
3390 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3391 If from_tty is nonzero, it prints a message to that effect,
3392 which ends with a period (no newline). */
3395 set_ignore_count (bptnum, count, from_tty)
3396 int bptnum, count, from_tty;
3398 register struct breakpoint *b;
3404 if (b->number == bptnum)
3406 b->ignore_count = count;
3409 else if (count == 0)
3410 printf_filtered ("Will stop next time breakpoint %d is reached.",
3412 else if (count == 1)
3413 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3416 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3418 breakpoints_changed ();
3422 error ("No breakpoint number %d.", bptnum);
3425 /* Clear the ignore counts of all breakpoints. */
3427 breakpoint_clear_ignore_counts ()
3429 struct breakpoint *b;
3432 b->ignore_count = 0;
3435 /* Command to set ignore-count of breakpoint N to COUNT. */
3438 ignore_command (args, from_tty)
3446 error_no_arg ("a breakpoint number");
3448 num = get_number (&p);
3451 error ("Second argument (specified ignore-count) is missing.");
3453 set_ignore_count (num,
3454 longest_to_int (value_as_long (parse_and_eval (p))),
3456 printf_filtered ("\n");
3457 breakpoints_changed ();
3460 /* Call FUNCTION on each of the breakpoints
3461 whose numbers are given in ARGS. */
3464 map_breakpoint_numbers (args, function)
3466 void (*function) PARAMS ((struct breakpoint *));
3468 register char *p = args;
3471 register struct breakpoint *b;
3474 error_no_arg ("one or more breakpoint numbers");
3480 num = get_number (&p1);
3483 if (b->number == num)
3485 struct breakpoint *related_breakpoint = b->related_breakpoint;
3487 if (related_breakpoint)
3488 function (related_breakpoint);
3491 printf_unfiltered ("No breakpoint number %d.\n", num);
3498 enable_breakpoint (bpt)
3499 struct breakpoint *bpt;
3501 FRAME save_selected_frame = NULL;
3502 int save_selected_frame_level = -1;
3503 int target_resources_ok, other_type_used;
3506 if (bpt->type == bp_hardware_breakpoint)
3509 i = hw_breakpoint_used_count();
3510 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3511 bp_hardware_breakpoint, i+1, 0);
3512 if (target_resources_ok == 0)
3513 error ("No hardware breakpoint support in the target.");
3514 else if (target_resources_ok < 0)
3515 error ("Hardware breakpoints used exceeds limit.");
3517 bpt->enable = enabled;
3518 breakpoints_changed ();
3519 check_duplicates (bpt->address);
3521 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3522 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3524 if (bpt->exp_valid_block != NULL)
3526 FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3530 Cannot enable watchpoint %d because the block in which its expression\n\
3531 is valid is not currently in scope.\n", bpt->number);
3532 bpt->enable = disabled;
3536 save_selected_frame = selected_frame;
3537 save_selected_frame_level = selected_frame_level;
3538 select_frame (fr, -1);
3541 value_free (bpt->val);
3542 mark = value_mark ();
3543 bpt->val = evaluate_expression (bpt->exp);
3544 release_value (bpt->val);
3545 if (VALUE_LAZY (bpt->val))
3546 value_fetch_lazy (bpt->val);
3548 if (bpt->type == bp_hardware_watchpoint ||
3549 bpt->type == bp_read_watchpoint ||
3550 bpt->type == bp_access_watchpoint)
3552 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3553 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3554 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3555 bpt->type, i+mem_cnt, other_type_used);
3556 /* we can consider of type is bp_hardware_watchpoint, convert to
3557 bp_watchpoint in the following condition */
3558 if (target_resources_ok < 0)
3561 Cannot enable watchpoint %d because target watch resources\n\
3562 have been allocated for other watchpoints.\n", bpt->number);
3563 bpt->enable = disabled;
3564 value_free_to_mark (mark);
3569 if (save_selected_frame_level >= 0)
3570 select_frame (save_selected_frame, save_selected_frame_level);
3571 value_free_to_mark (mark);
3577 enable_command (args, from_tty)
3581 struct breakpoint *bpt;
3583 ALL_BREAKPOINTS (bpt)
3587 case bp_hardware_breakpoint:
3589 case bp_hardware_watchpoint:
3590 case bp_read_watchpoint:
3591 case bp_access_watchpoint:
3592 enable_breakpoint (bpt);
3597 map_breakpoint_numbers (args, enable_breakpoint);
3601 disable_breakpoint (bpt)
3602 struct breakpoint *bpt;
3604 /* Never disable a watchpoint scope breakpoint; we want to
3605 hit them when we leave scope so we can delete both the
3606 watchpoint and its scope breakpoint at that time. */
3607 if (bpt->type == bp_watchpoint_scope)
3610 bpt->enable = disabled;
3612 breakpoints_changed ();
3614 check_duplicates (bpt->address);
3619 disable_command (args, from_tty)
3623 register struct breakpoint *bpt;
3625 ALL_BREAKPOINTS (bpt)
3629 case bp_hardware_breakpoint:
3631 case bp_hardware_watchpoint:
3632 case bp_read_watchpoint:
3633 case bp_access_watchpoint:
3634 disable_breakpoint (bpt);
3639 map_breakpoint_numbers (args, disable_breakpoint);
3643 enable_once_breakpoint (bpt)
3644 struct breakpoint *bpt;
3646 FRAME save_selected_frame = NULL;
3647 int save_selected_frame_level = -1;
3648 int target_resources_ok, other_type_used;
3651 if (bpt->type == bp_hardware_breakpoint)
3654 i = hw_breakpoint_used_count();
3655 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3656 bp_hardware_breakpoint, i+1, 0);
3657 if (target_resources_ok == 0)
3658 error ("No hardware breakpoint support in the target.");
3659 else if (target_resources_ok < 0)
3660 error ("Hardware breakpoints used exceeds limit.");
3663 bpt->enable = enabled;
3664 bpt->disposition = disable;
3665 check_duplicates (bpt->address);
3666 breakpoints_changed ();
3668 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3669 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3671 if (bpt->exp_valid_block != NULL)
3673 FRAME fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3677 Cannot enable watchpoint %d because the block in which its expression\n\
3678 is valid is not currently in scope.\n", bpt->number);
3679 bpt->enable = disabled;
3683 save_selected_frame = selected_frame;
3684 save_selected_frame_level = selected_frame_level;
3685 select_frame (fr, -1);
3688 value_free (bpt->val);
3689 mark = value_mark ();
3690 bpt->val = evaluate_expression (bpt->exp);
3691 release_value (bpt->val);
3692 if (VALUE_LAZY (bpt->val))
3693 value_fetch_lazy (bpt->val);
3695 if (bpt->type == bp_hardware_watchpoint ||
3696 bpt->type == bp_read_watchpoint ||
3697 bpt->type == bp_access_watchpoint)
3699 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3700 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3701 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3702 bpt->type, i+mem_cnt, other_type_used);
3703 /* we can consider of type is bp_hardware_watchpoint, convert to
3704 bp_watchpoint in the following condition */
3705 if (target_resources_ok < 0)
3708 Cannot enable watchpoint %d because target watch resources\n\
3709 have been allocated for other watchpoints.\n", bpt->number);
3710 bpt->enable = disabled;
3711 value_free_to_mark (mark);
3715 if (save_selected_frame_level >= 0)
3716 select_frame (save_selected_frame, save_selected_frame_level);
3717 value_free_to_mark (mark);
3723 enable_once_command (args, from_tty)
3727 map_breakpoint_numbers (args, enable_once_breakpoint);
3731 enable_delete_breakpoint (bpt)
3732 struct breakpoint *bpt;
3734 bpt->enable = enabled;
3735 bpt->disposition = delete;
3737 check_duplicates (bpt->address);
3738 breakpoints_changed ();
3743 enable_delete_command (args, from_tty)
3747 map_breakpoint_numbers (args, enable_delete_breakpoint);
3751 * Use default_breakpoint_'s, or nothing if they aren't valid.
3753 struct symtabs_and_lines
3754 decode_line_spec_1 (string, funfirstline)
3758 struct symtabs_and_lines sals;
3760 error ("Empty line specification.");
3761 if (default_breakpoint_valid)
3762 sals = decode_line_1 (&string, funfirstline,
3763 default_breakpoint_symtab, default_breakpoint_line,
3766 sals = decode_line_1 (&string, funfirstline,
3767 (struct symtab *)NULL, 0, (char ***)NULL);
3769 error ("Junk at end of line specification: %s", string);
3774 _initialize_breakpoint ()
3776 breakpoint_chain = 0;
3777 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3778 before a breakpoint is set. */
3779 breakpoint_count = 0;
3781 add_com ("ignore", class_breakpoint, ignore_command,
3782 "Set ignore-count of breakpoint number N to COUNT.");
3784 add_com ("commands", class_breakpoint, commands_command,
3785 "Set commands to be executed when a breakpoint is hit.\n\
3786 Give breakpoint number as argument after \"commands\".\n\
3787 With no argument, the targeted breakpoint is the last one set.\n\
3788 The commands themselves follow starting on the next line.\n\
3789 Type a line containing \"end\" to indicate the end of them.\n\
3790 Give \"silent\" as the first line to make the breakpoint silent;\n\
3791 then no output is printed when it is hit, except what the commands print.");
3793 add_com ("condition", class_breakpoint, condition_command,
3794 "Specify breakpoint number N to break only if COND is true.\n\
3795 N is an integer; COND is an expression to be evaluated whenever\n\
3796 breakpoint N is reached. ");
3798 add_com ("tbreak", class_breakpoint, tbreak_command,
3799 "Set a temporary breakpoint. Args like \"break\" command.\n\
3800 Like \"break\" except the breakpoint is only temporary,\n\
3801 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3802 by using \"enable delete\" on the breakpoint number.");
3804 add_com ("hbreak", class_breakpoint, hbreak_command,
3805 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3806 Like \"break\" except the breakpoint requires hardware support,\n\
3807 some target hardware may not have this support.");
3809 add_com ("thbreak", class_breakpoint, thbreak_command,
3810 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3811 Like \"hbreak\" except the breakpoint is only temporary,\n\
3812 so it will be deleted when hit.");
3814 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3815 "Enable some breakpoints.\n\
3816 Give breakpoint numbers (separated by spaces) as arguments.\n\
3817 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3818 This is used to cancel the effect of the \"disable\" command.\n\
3819 With a subcommand you can enable temporarily.",
3820 &enablelist, "enable ", 1, &cmdlist);
3822 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3823 "Enable some breakpoints.\n\
3824 Give breakpoint numbers (separated by spaces) as arguments.\n\
3825 This is used to cancel the effect of the \"disable\" command.\n\
3826 May be abbreviated to simply \"enable\".\n",
3827 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3829 add_cmd ("once", no_class, enable_once_command,
3830 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3831 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3834 add_cmd ("delete", no_class, enable_delete_command,
3835 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3836 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3839 add_cmd ("delete", no_class, enable_delete_command,
3840 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3841 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3844 add_cmd ("once", no_class, enable_once_command,
3845 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3846 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3849 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3850 "Disable some breakpoints.\n\
3851 Arguments are breakpoint numbers with spaces in between.\n\
3852 To disable all breakpoints, give no argument.\n\
3853 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3854 &disablelist, "disable ", 1, &cmdlist);
3855 add_com_alias ("dis", "disable", class_breakpoint, 1);
3856 add_com_alias ("disa", "disable", class_breakpoint, 1);
3858 add_cmd ("breakpoints", class_alias, disable_command,
3859 "Disable some breakpoints.\n\
3860 Arguments are breakpoint numbers with spaces in between.\n\
3861 To disable all breakpoints, give no argument.\n\
3862 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3863 This command may be abbreviated \"disable\".",
3866 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3867 "Delete some breakpoints or auto-display expressions.\n\
3868 Arguments are breakpoint numbers with spaces in between.\n\
3869 To delete all breakpoints, give no argument.\n\
3871 Also a prefix command for deletion of other GDB objects.\n\
3872 The \"unset\" command is also an alias for \"delete\".",
3873 &deletelist, "delete ", 1, &cmdlist);
3874 add_com_alias ("d", "delete", class_breakpoint, 1);
3876 add_cmd ("breakpoints", class_alias, delete_command,
3877 "Delete some breakpoints or auto-display expressions.\n\
3878 Arguments are breakpoint numbers with spaces in between.\n\
3879 To delete all breakpoints, give no argument.\n\
3880 This command may be abbreviated \"delete\".",
3883 add_com ("clear", class_breakpoint, clear_command,
3884 "Clear breakpoint at specified line or function.\n\
3885 Argument may be line number, function name, or \"*\" and an address.\n\
3886 If line number is specified, all breakpoints in that line are cleared.\n\
3887 If function is specified, breakpoints at beginning of function are cleared.\n\
3888 If an address is specified, breakpoints at that address are cleared.\n\n\
3889 With no argument, clears all breakpoints in the line that the selected frame\n\
3892 See also the \"delete\" command which clears breakpoints by number.");
3894 add_com ("break", class_breakpoint, break_command,
3895 "Set breakpoint at specified line or function.\n\
3896 Argument may be line number, function name, or \"*\" and an address.\n\
3897 If line number is specified, break at start of code for that line.\n\
3898 If function is specified, break at start of code for that function.\n\
3899 If an address is specified, break at that exact address.\n\
3900 With no arg, uses current execution address of selected stack frame.\n\
3901 This is useful for breaking on return to a stack frame.\n\
3903 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3905 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3906 add_com_alias ("b", "break", class_run, 1);
3907 add_com_alias ("br", "break", class_run, 1);
3908 add_com_alias ("bre", "break", class_run, 1);
3909 add_com_alias ("brea", "break", class_run, 1);
3911 add_info ("breakpoints", breakpoints_info,
3912 "Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3913 The \"Type\" column indicates one of:\n\
3914 \tbreakpoint - normal breakpoint\n\
3915 \twatchpoint - watchpoint\n\
3916 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3917 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3918 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3919 address and file/line number respectively.\n\n\
3920 Convenience variable \"$_\" and default examine address for \"x\"\n\
3921 are set to the address of the last breakpoint listed.\n\n\
3922 Convenience variable \"$bpnum\" contains the number of the last\n\
3925 #if MAINTENANCE_CMDS
3927 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3928 "Status of all breakpoints, or breakpoint number NUMBER.\n\
3929 The \"Type\" column indicates one of:\n\
3930 \tbreakpoint - normal breakpoint\n\
3931 \twatchpoint - watchpoint\n\
3932 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3933 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3934 \tuntil - internal breakpoint used by the \"until\" command\n\
3935 \tfinish - internal breakpoint used by the \"finish\" command\n\
3936 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3937 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3938 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3939 address and file/line number respectively.\n\n\
3940 Convenience variable \"$_\" and default examine address for \"x\"\n\
3941 are set to the address of the last breakpoint listed.\n\n\
3942 Convenience variable \"$bpnum\" contains the number of the last\n\
3944 &maintenanceinfolist);
3946 #endif /* MAINTENANCE_CMDS */
3948 add_com ("catch", class_breakpoint, catch_command,
3949 "Set breakpoints to catch exceptions that are raised.\n\
3950 Argument may be a single exception to catch, multiple exceptions\n\
3951 to catch, or the default exception \"default\". If no arguments\n\
3952 are given, breakpoints are set at all exception handlers catch clauses\n\
3953 within the current scope.\n\
3955 A condition specified for the catch applies to all breakpoints set\n\
3956 with this command\n\
3958 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
3960 add_com ("watch", class_breakpoint, watch_command,
3961 "Set a watchpoint for an expression.\n\
3962 A watchpoint stops execution of your program whenever the value of\n\
3963 an expression changes.");
3965 add_com ("rwatch", class_breakpoint, rwatch_command,
3966 "Set a read watchpoint for an expression.\n\
3967 A watchpoint stops execution of your program whenever the value of\n\
3968 an expression is read.");
3970 add_com ("awatch", class_breakpoint, awatch_command,
3971 "Set a watchpoint for an expression.\n\
3972 A watchpoint stops execution of your program whenever the value of\n\
3973 an expression is either read or written.");
3975 add_info ("watchpoints", breakpoints_info,
3976 "Synonym for ``info breakpoints''.");
3979 /* OK, when we call objfile_relocate, we need to relocate breakpoints
3980 too. breakpoint_re_set is not a good choice--for example, if
3981 addr_string contains just a line number without a file name the
3982 breakpoint might get set in a different file. In general, there is
3983 no need to go all the way back to the user's string (though this might
3984 work if some effort were made to canonicalize it), since symtabs and
3985 everything except addresses are still valid.
3987 Probably the best way to solve this is to have each breakpoint save
3988 the objfile and the section number that was used to set it (if set
3989 by "*addr", probably it is best to use find_pc_line to get a symtab
3990 and use the objfile and block_line_section for that symtab). Then
3991 objfile_relocate can call fixup_breakpoints with the objfile and
3992 the new_offsets, and it can relocate only the appropriate breakpoints. */
3994 #ifdef IBM6000_TARGET
3995 /* But for now, just kludge it based on the concept that before an
3996 objfile is relocated the breakpoint is below 0x10000000, and afterwards
3997 it is higher, so that way we only relocate each breakpoint once. */
4000 fixup_breakpoints (low, high, delta)
4005 struct breakpoint *b;
4009 if (b->address >= low && b->address <= high)
4010 b->address += delta;