1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "breakpoint.h"
27 #include "expression.h"
41 /* local function prototypes */
44 catch_command_1 PARAMS ((char *, int, int));
47 enable_delete_command PARAMS ((char *, int));
50 enable_delete_breakpoint PARAMS ((struct breakpoint *));
53 enable_once_command PARAMS ((char *, int));
56 enable_once_breakpoint PARAMS ((struct breakpoint *));
59 disable_command PARAMS ((char *, int));
62 disable_breakpoint PARAMS ((struct breakpoint *));
65 enable_command PARAMS ((char *, int));
68 enable_breakpoint PARAMS ((struct breakpoint *));
71 map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *)));
74 ignore_command PARAMS ((char *, int));
77 breakpoint_re_set_one PARAMS ((char *));
80 delete_command PARAMS ((char *, int));
83 clear_command PARAMS ((char *, int));
86 catch_command PARAMS ((char *, int));
88 static struct symtabs_and_lines
89 get_catch_sals PARAMS ((int));
92 watch_command PARAMS ((char *, int));
95 can_use_hardware_watchpoint PARAMS ((struct value *));
98 tbreak_command PARAMS ((char *, int));
101 break_command_1 PARAMS ((char *, int, int));
104 mention PARAMS ((struct breakpoint *));
106 static struct breakpoint *
107 set_raw_breakpoint PARAMS ((struct symtab_and_line));
110 check_duplicates PARAMS ((CORE_ADDR));
113 describe_other_breakpoints PARAMS ((CORE_ADDR));
116 breakpoints_info PARAMS ((char *, int));
119 breakpoint_1 PARAMS ((int, int));
122 bpstat_alloc PARAMS ((struct breakpoint *, bpstat));
125 breakpoint_cond_eval PARAMS ((char *));
128 cleanup_executing_breakpoints PARAMS ((int));
131 commands_command PARAMS ((char *, int));
134 condition_command PARAMS ((char *, int));
137 get_number PARAMS ((char **));
140 set_breakpoint_count PARAMS ((int));
143 remove_breakpoint PARAMS ((struct breakpoint *));
145 extern int addressprint; /* Print machine addresses? */
147 /* Are we executing breakpoint commands? */
148 static int executing_breakpoint_commands;
150 /* Walk the following statement or block through all breakpoints.
151 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
154 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
156 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
157 for (b = breakpoint_chain; \
158 b? (tmp=b->next, 1): 0; \
161 /* By default no support for hardware watchpoints is assumed. */
162 #ifndef TARGET_CAN_USE_HARDWARE_WATCHPOINT
163 #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(TYPE,CNT,OTHERTYPE) 0
164 #define target_remove_watchpoint(ADDR,LEN,TYPE) -1
165 #define target_insert_watchpoint(ADDR,LEN,TYPE) -1
168 #ifndef target_insert_hw_breakpoint
169 #define target_remove_hw_breakpoint(ADDR,SHADOW) -1
170 #define target_insert_hw_breakpoint(ADDR,SHADOW) -1
173 #ifndef target_stopped_data_address
174 #define target_stopped_data_address() 0
177 /* True if breakpoint hit counts should be displayed in breakpoint info. */
179 int show_breakpoint_hit_counts = 1;
181 /* Chain of all breakpoints defined. */
183 static struct breakpoint *breakpoint_chain;
185 /* Number of last breakpoint made. */
187 static int breakpoint_count;
189 /* Set breakpoint count to NUM. */
192 set_breakpoint_count (num)
195 breakpoint_count = num;
196 set_internalvar (lookup_internalvar ("bpnum"),
197 value_from_longest (builtin_type_int, (LONGEST) num));
200 /* Used in run_command to zero the hit count when a new run starts. */
203 clear_breakpoint_hit_counts ()
205 struct breakpoint *b;
211 /* Default address, symtab and line to put a breakpoint at
212 for "break" command with no arg.
213 if default_breakpoint_valid is zero, the other three are
214 not valid, and "break" with no arg is an error.
216 This set by print_stack_frame, which calls set_default_breakpoint. */
218 int default_breakpoint_valid;
219 CORE_ADDR default_breakpoint_address;
220 struct symtab *default_breakpoint_symtab;
221 int default_breakpoint_line;
223 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
224 Advance *PP after the string and any trailing whitespace.
226 Currently the string can either be a number or "$" followed by the name
227 of a convenience variable. Making it an expression wouldn't work well
228 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
237 /* Empty line means refer to the last breakpoint. */
238 return breakpoint_count;
241 /* Make a copy of the name, so we can null-terminate it
242 to pass to lookup_internalvar(). */
247 while (isalnum (*p) || *p == '_')
249 varname = (char *) alloca (p - start + 1);
250 strncpy (varname, start, p - start);
251 varname[p - start] = '\0';
252 val = value_of_internalvar (lookup_internalvar (varname));
253 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
255 "Convenience variables used to specify breakpoints must have integer values."
257 retval = (int) value_as_long (val);
263 while (*p >= '0' && *p <= '9')
266 /* There is no number here. (e.g. "cond a == b"). */
267 error_no_arg ("breakpoint number");
270 if (!(isspace (*p) || *p == '\0'))
271 error ("breakpoint number expected");
278 /* condition N EXP -- set break condition of breakpoint N to EXP. */
281 condition_command (arg, from_tty)
285 register struct breakpoint *b;
290 error_no_arg ("breakpoint number");
293 bnum = get_number (&p);
296 if (b->number == bnum)
303 if (b->cond_string != NULL)
304 free ((PTR)b->cond_string);
309 b->cond_string = NULL;
311 printf_filtered ("Breakpoint %d now unconditional.\n", bnum);
316 /* I don't know if it matters whether this is the string the user
317 typed in or the decompiled expression. */
318 b->cond_string = savestring (arg, strlen (arg));
319 b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0);
321 error ("Junk at end of expression");
323 breakpoints_changed ();
327 error ("No breakpoint number %d.", bnum);
332 commands_command (arg, from_tty)
336 register struct breakpoint *b;
339 struct command_line *l;
341 /* If we allowed this, we would have problems with when to
342 free the storage, if we change the commands currently
345 if (executing_breakpoint_commands)
346 error ("Can't use the \"commands\" command among a breakpoint's commands.");
349 bnum = get_number (&p);
351 error ("Unexpected extra arguments following breakpoint number.");
354 if (b->number == bnum)
356 if (from_tty && input_from_terminal_p ())
357 printf_filtered ("Type commands for when breakpoint %d is hit, one per line.\n\
358 End with a line saying just \"end\".\n", bnum);
359 l = read_command_lines ();
360 free_command_lines (&b->commands);
362 breakpoints_changed ();
365 error ("No breakpoint number %d.", bnum);
368 extern int memory_breakpoint_size; /* from mem-break.c */
370 /* Like target_read_memory() but if breakpoints are inserted, return
371 the shadow contents instead of the breakpoints themselves.
373 Read "memory data" from whatever target or inferior we have.
374 Returns zero if successful, errno value if not. EIO is used
375 for address out of bounds. If breakpoints are inserted, returns
376 shadow contents, not the breakpoints themselves. From breakpoint.c. */
379 read_memory_nobpt (memaddr, myaddr, len)
385 struct breakpoint *b;
387 if (memory_breakpoint_size < 0)
388 /* No breakpoints on this machine. FIXME: This should be
389 dependent on the debugging target. Probably want
390 target_insert_breakpoint to return a size, saying how many
391 bytes of the shadow contents are used, or perhaps have
392 something like target_xfer_shadow. */
393 return target_read_memory (memaddr, myaddr, len);
397 if (b->type == bp_watchpoint
398 || b->type == bp_hardware_watchpoint
399 || b->type == bp_read_watchpoint
400 || b->type == bp_access_watchpoint
403 else if (b->address + memory_breakpoint_size <= memaddr)
404 /* The breakpoint is entirely before the chunk of memory
407 else if (b->address >= memaddr + len)
408 /* The breakpoint is entirely after the chunk of memory we
413 /* Copy the breakpoint from the shadow contents, and recurse
414 for the things before and after. */
416 /* Addresses and length of the part of the breakpoint that
418 CORE_ADDR membpt = b->address;
419 unsigned int bptlen = memory_breakpoint_size;
420 /* Offset within shadow_contents. */
423 if (membpt < memaddr)
425 /* Only copy the second part of the breakpoint. */
426 bptlen -= memaddr - membpt;
427 bptoffset = memaddr - membpt;
431 if (membpt + bptlen > memaddr + len)
433 /* Only copy the first part of the breakpoint. */
434 bptlen -= (membpt + bptlen) - (memaddr + len);
437 memcpy (myaddr + membpt - memaddr,
438 b->shadow_contents + bptoffset, bptlen);
440 if (membpt > memaddr)
442 /* Copy the section of memory before the breakpoint. */
443 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
448 if (membpt + bptlen < memaddr + len)
450 /* Copy the section of memory after the breakpoint. */
451 status = read_memory_nobpt
453 myaddr + membpt + bptlen - memaddr,
454 memaddr + len - (membpt + bptlen));
461 /* Nothing overlaps. Just call read_memory_noerr. */
462 return target_read_memory (memaddr, myaddr, len);
465 /* insert_breakpoints is used when starting or continuing the program.
466 remove_breakpoints is used when the program stops.
467 Both return zero if successful,
468 or an `errno' value if could not write the inferior. */
471 insert_breakpoints ()
473 register struct breakpoint *b;
475 int disabled_breaks = 0;
478 if (b->type != bp_watchpoint
479 && b->type != bp_hardware_watchpoint
480 && b->type != bp_read_watchpoint
481 && b->type != bp_access_watchpoint
482 && b->enable != disabled
486 if (b->type == bp_hardware_breakpoint)
487 val = target_insert_hw_breakpoint(b->address, b->shadow_contents);
489 val = target_insert_breakpoint(b->address, b->shadow_contents);
492 /* Can't set the breakpoint. */
493 #if defined (DISABLE_UNSETTABLE_BREAK)
494 if (DISABLE_UNSETTABLE_BREAK (b->address))
497 b->enable = disabled;
498 if (!disabled_breaks)
500 target_terminal_ours_for_output ();
501 fprintf_unfiltered (gdb_stderr,
502 "Cannot insert breakpoint %d:\n", b->number);
503 printf_filtered ("Disabling shared library breakpoints:\n");
506 printf_filtered ("%d ", b->number);
511 target_terminal_ours_for_output ();
512 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
513 #ifdef ONE_PROCESS_WRITETEXT
514 fprintf_unfiltered (gdb_stderr,
515 "The same program may be running in another process.\n");
517 memory_error (val, b->address); /* which bombs us out */
523 else if ((b->type == bp_hardware_watchpoint ||
524 b->type == bp_read_watchpoint ||
525 b->type == bp_access_watchpoint)
526 && b->enable == enabled
530 struct frame_info *saved_frame;
531 int saved_level, within_current_scope;
532 value_ptr mark = value_mark ();
535 /* Save the current frame and level so we can restore it after
536 evaluating the watchpoint expression on its own frame. */
537 saved_frame = selected_frame;
538 saved_level = selected_frame_level;
540 /* Determine if the watchpoint is within scope. */
541 if (b->exp_valid_block == NULL)
542 within_current_scope = 1;
545 struct frame_info *fi =
546 find_frame_addr_in_frame_chain (b->watchpoint_frame);
547 within_current_scope = (fi != NULL);
548 if (within_current_scope)
549 select_frame (fi, -1);
552 if (within_current_scope)
554 /* Evaluate the expression and cut the chain of values
555 produced off from the value chain. */
556 v = evaluate_expression (b->exp);
557 value_release_to_mark (mark);
562 /* Look at each value on the value chain. */
563 for ( ; v; v=v->next)
565 /* If it's a memory location, then we must watch it. */
566 if (v->lval == lval_memory)
570 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
571 len = TYPE_LENGTH (VALUE_TYPE (v));
573 if (b->type == bp_read_watchpoint)
575 else if (b->type == bp_access_watchpoint)
578 val = target_insert_watchpoint (addr, len, type);
587 /* Failure to insert a watchpoint on any memory value in the
588 value chain brings us here. */
590 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
596 Hardware watchpoint %d deleted because the program has left the block in\n\
597 which its expression is valid.\n", b->number);
598 if (b->related_breakpoint)
599 delete_breakpoint (b->related_breakpoint);
600 delete_breakpoint (b);
603 /* Restore the frame and level. */
604 select_frame (saved_frame, saved_level);
607 printf_filtered ("\n");
613 remove_breakpoints ()
615 register struct breakpoint *b;
622 val = remove_breakpoint (b);
632 remove_breakpoint (b)
633 struct breakpoint *b;
637 if (b->type != bp_watchpoint
638 && b->type != bp_hardware_watchpoint
639 && b->type != bp_read_watchpoint
640 && b->type != bp_access_watchpoint)
642 if (b->type == bp_hardware_breakpoint)
643 val = target_remove_hw_breakpoint(b->address, b->shadow_contents);
645 val = target_remove_breakpoint(b->address, b->shadow_contents);
650 else if ((b->type == bp_hardware_watchpoint ||
651 b->type == bp_read_watchpoint ||
652 b->type == bp_access_watchpoint)
653 && b->enable == enabled
659 /* Walk down the saved value chain. */
660 for (v = b->val_chain; v; v = v->next)
662 /* For each memory reference remove the watchpoint
664 if (v->lval == lval_memory)
668 addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
669 len = TYPE_LENGTH (VALUE_TYPE (v));
670 val = target_remove_watchpoint (addr, len, b->type);
676 /* Failure to remove any of the hardware watchpoints comes here. */
678 error ("Hardware watchpoint %d: Could not remove watchpoint\n",
681 /* Free the saved value chain. We will construct a new one
682 the next time the watchpoint is inserted. */
683 for (v = b->val_chain; v; v = n)
693 /* Clear the "inserted" flag in all breakpoints. */
696 mark_breakpoints_out ()
698 register struct breakpoint *b;
704 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
705 which should go away between runs of the program. */
708 breakpoint_init_inferior ()
710 register struct breakpoint *b, *temp;
712 ALL_BREAKPOINTS_SAFE (b, temp)
716 /* If the call dummy breakpoint is at the entry point it will
717 cause problems when the inferior is rerun, so we better
719 if (b->type == bp_call_dummy)
720 delete_breakpoint (b);
722 /* Likewise for scope breakpoints. */
723 if (b->type == bp_watchpoint_scope)
724 delete_breakpoint (b);
726 /* Likewise for watchpoints on local expressions. */
727 if ((b->type == bp_watchpoint || b->type == bp_hardware_watchpoint ||
728 b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
729 && b->exp_valid_block != NULL)
730 delete_breakpoint (b);
734 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
735 When continuing from a location with a breakpoint,
736 we actually single step once before calling insert_breakpoints. */
739 breakpoint_here_p (pc)
742 register struct breakpoint *b;
745 if (b->enable != disabled && b->address == pc)
751 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
752 because figuring out the saved SP would take too much time, at least using
753 get_saved_register on the 68k. This means that for this function to
754 work right a port must use the bp_call_dummy breakpoint. */
757 frame_in_dummy (frame)
758 struct frame_info *frame;
760 struct breakpoint *b;
765 static unsigned LONGEST dummy[] = CALL_DUMMY;
767 if (b->type == bp_call_dummy
768 && b->frame == frame->frame
770 /* We need to check the PC as well as the frame on the sparc,
771 for signals.exp in the testsuite. */
774 - sizeof (dummy) / sizeof (LONGEST) * REGISTER_SIZE))
775 && frame->pc <= b->address)
778 #endif /* CALL_DUMMY */
782 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
783 is valid for process/thread PID. */
786 breakpoint_thread_match (pc, pid)
790 struct breakpoint *b;
793 thread = pid_to_thread_id (pid);
796 if (b->enable != disabled
798 && (b->thread == -1 || b->thread == thread))
805 /* bpstat stuff. External routines' interfaces are documented
808 /* Clear a bpstat so that it says we are not at any breakpoint.
809 Also free any storage that is part of a bpstat. */
824 if (p->old_val != NULL)
825 value_free (p->old_val);
832 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
833 is part of the bpstat is copied as well. */
841 bpstat retval = NULL;
846 for (; bs != NULL; bs = bs->next)
848 tmp = (bpstat) xmalloc (sizeof (*tmp));
849 memcpy (tmp, bs, sizeof (*tmp));
851 /* This is the first thing in the chain. */
861 /* Find the bpstat associated with this breakpoint */
864 bpstat_find_breakpoint(bsp, breakpoint)
866 struct breakpoint *breakpoint;
868 if (bsp == NULL) return NULL;
870 for (;bsp != NULL; bsp = bsp->next) {
871 if (bsp->breakpoint_at == breakpoint) return bsp;
876 /* Return the breakpoint number of the first breakpoint we are stopped
877 at. *BSP upon return is a bpstat which points to the remaining
878 breakpoints stopped at (but which is not guaranteed to be good for
879 anything but further calls to bpstat_num).
880 Return 0 if passed a bpstat which does not indicate any breakpoints. */
886 struct breakpoint *b;
889 return 0; /* No more breakpoint values */
892 b = (*bsp)->breakpoint_at;
895 return -1; /* breakpoint that's been deleted since */
897 return b->number; /* We have its number */
901 /* Modify BS so that the actions will not be performed. */
904 bpstat_clear_actions (bs)
907 for (; bs != NULL; bs = bs->next)
910 if (bs->old_val != NULL)
912 value_free (bs->old_val);
918 /* Stub for cleaning up our state if we error-out of a breakpoint command */
921 cleanup_executing_breakpoints (ignore)
924 executing_breakpoint_commands = 0;
927 /* Execute all the commands associated with all the breakpoints at this
928 location. Any of these commands could cause the process to proceed
929 beyond this point, etc. We look out for such changes by checking
930 the global "breakpoint_proceeded" after each command. */
933 bpstat_do_actions (bsp)
937 struct cleanup *old_chain;
939 executing_breakpoint_commands = 1;
940 old_chain = make_cleanup (cleanup_executing_breakpoints, 0);
945 breakpoint_proceeded = 0;
946 for (; bs != NULL; bs = bs->next)
950 char *line = bs->commands->line;
951 bs->commands = bs->commands->next;
952 execute_command (line, 0);
953 /* If the inferior is proceeded by the command, bomb out now.
954 The bpstat chain has been blown away by wait_for_inferior.
955 But since execution has stopped again, there is a new bpstat
956 to look at, so start over. */
957 if (breakpoint_proceeded)
962 executing_breakpoint_commands = 0;
963 discard_cleanups (old_chain);
966 /* This is the normal print_it function for a bpstat. In the future,
967 much of this logic could (should?) be moved to bpstat_stop_status,
968 by having it set different print_it functions. */
974 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
975 which has since been deleted. */
976 if (bs->breakpoint_at == NULL
977 || (bs->breakpoint_at->type != bp_breakpoint
978 && bs->breakpoint_at->type != bp_hardware_breakpoint
979 && bs->breakpoint_at->type != bp_watchpoint
980 && bs->breakpoint_at->type != bp_read_watchpoint
981 && bs->breakpoint_at->type != bp_access_watchpoint
982 && bs->breakpoint_at->type != bp_hardware_watchpoint))
985 if (bs->breakpoint_at->type == bp_breakpoint ||
986 bs->breakpoint_at->type == bp_hardware_breakpoint)
988 /* I think the user probably only wants to see one breakpoint
989 number, not all of them. */
990 annotate_breakpoint (bs->breakpoint_at->number);
991 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
994 else if ((bs->old_val != NULL) &&
995 (bs->breakpoint_at->type == bp_watchpoint ||
996 bs->breakpoint_at->type == bp_access_watchpoint ||
997 bs->breakpoint_at->type == bp_hardware_watchpoint))
999 annotate_watchpoint (bs->breakpoint_at->number);
1000 mention (bs->breakpoint_at);
1001 printf_filtered ("\nOld value = ");
1002 value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
1003 printf_filtered ("\nNew value = ");
1004 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1005 Val_pretty_default);
1006 printf_filtered ("\n");
1007 value_free (bs->old_val);
1009 /* More than one watchpoint may have been triggered. */
1012 else if (bs->breakpoint_at->type == bp_access_watchpoint ||
1013 bs->breakpoint_at->type == bp_read_watchpoint)
1015 mention (bs->breakpoint_at);
1016 printf_filtered ("\nValue = ");
1017 value_print (bs->breakpoint_at->val, gdb_stdout, 0,
1018 Val_pretty_default);
1019 printf_filtered ("\n");
1022 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1026 /* Print a message indicating what happened. Returns nonzero to
1027 say that only the source line should be printed after this (zero
1028 return means print the frame as well as the source line). */
1029 /* Currently we always return zero. */
1039 val = (*bs->print_it) (bs);
1043 /* Maybe another breakpoint in the chain caused us to stop.
1044 (Currently all watchpoints go on the bpstat whether hit or
1045 not. That probably could (should) be changed, provided care is taken
1046 with respect to bpstat_explains_signal). */
1048 return bpstat_print (bs->next);
1050 /* We reached the end of the chain without printing anything. */
1054 /* Evaluate the expression EXP and return 1 if value is zero.
1055 This is used inside a catch_errors to evaluate the breakpoint condition.
1056 The argument is a "struct expression *" that has been cast to char * to
1057 make it pass through catch_errors. */
1060 breakpoint_cond_eval (exp)
1063 value_ptr mark = value_mark ();
1064 int i = !value_true (evaluate_expression ((struct expression *)exp));
1065 value_free_to_mark (mark);
1069 /* Allocate a new bpstat and chain it to the current one. */
1072 bpstat_alloc (b, cbs)
1073 register struct breakpoint *b;
1074 bpstat cbs; /* Current "bs" value */
1078 bs = (bpstat) xmalloc (sizeof (*bs));
1080 bs->breakpoint_at = b;
1081 /* If the condition is false, etc., don't do the commands. */
1082 bs->commands = NULL;
1084 bs->print_it = print_it_normal;
1088 /* Possible return values for watchpoint_check (this can't be an enum
1089 because of check_errors). */
1090 /* The watchpoint has been deleted. */
1091 #define WP_DELETED 1
1092 /* The value has changed. */
1093 #define WP_VALUE_CHANGED 2
1094 /* The value has not changed. */
1095 #define WP_VALUE_NOT_CHANGED 3
1097 /* Check watchpoint condition. */
1100 watchpoint_check (p)
1103 bpstat bs = (bpstat) p;
1104 struct breakpoint *b;
1105 struct frame_info *saved_frame, *fr;
1106 int within_current_scope, saved_level;
1108 b = bs->breakpoint_at;
1110 if (b->exp_valid_block == NULL)
1111 within_current_scope = 1;
1114 /* There is no current frame at this moment. If we're going to have
1115 any chance of handling watchpoints on local variables, we'll need
1116 the frame chain (so we can determine if we're in scope). */
1117 reinit_frame_cache();
1118 fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
1119 within_current_scope = (fr != NULL);
1120 if (within_current_scope)
1121 /* If we end up stopping, the current frame will get selected
1122 in normal_stop. So this call to select_frame won't affect
1124 select_frame (fr, -1);
1127 if (within_current_scope)
1129 /* We use value_{,free_to_}mark because it could be a
1130 *long* time before we return to the command level and
1131 call free_all_values. We can't call free_all_values because
1132 we might be in the middle of evaluating a function call. */
1134 value_ptr mark = value_mark ();
1135 value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
1136 if (!value_equal (b->val, new_val))
1138 release_value (new_val);
1139 value_free_to_mark (mark);
1140 bs->old_val = b->val;
1142 /* We will stop here */
1143 return WP_VALUE_CHANGED;
1147 /* Nothing changed, don't do anything. */
1148 value_free_to_mark (mark);
1149 /* We won't stop here */
1150 return WP_VALUE_NOT_CHANGED;
1155 /* This seems like the only logical thing to do because
1156 if we temporarily ignored the watchpoint, then when
1157 we reenter the block in which it is valid it contains
1158 garbage (in the case of a function, it may have two
1159 garbage values, one before and one after the prologue).
1160 So we can't even detect the first assignment to it and
1161 watch after that (since the garbage may or may not equal
1162 the first value assigned). */
1164 Watchpoint %d deleted because the program has left the block in\n\
1165 which its expression is valid.\n", bs->breakpoint_at->number);
1166 if (b->related_breakpoint)
1167 delete_breakpoint (b->related_breakpoint);
1168 delete_breakpoint (b);
1174 /* This is used when everything which needs to be printed has
1175 already been printed. But we still want to print the frame. */
1183 /* This is used when nothing should be printed for this bpstat entry. */
1192 /* Get a bpstat associated with having just stopped at address *PC
1193 and frame address CORE_ADDRESS. Update *PC to point at the
1194 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1195 if this is known to not be a real breakpoint (it could still be a
1196 watchpoint, though). */
1198 /* Determine whether we stopped at a breakpoint, etc, or whether we
1199 don't understand this stop. Result is a chain of bpstat's such that:
1201 if we don't understand the stop, the result is a null pointer.
1203 if we understand why we stopped, the result is not null.
1205 Each element of the chain refers to a particular breakpoint or
1206 watchpoint at which we have stopped. (We may have stopped for
1207 several reasons concurrently.)
1209 Each element of the chain has valid next, breakpoint_at,
1210 commands, FIXME??? fields.
1215 bpstat_stop_status (pc, not_a_breakpoint)
1217 int not_a_breakpoint;
1219 register struct breakpoint *b;
1221 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1222 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1223 int real_breakpoint = 0;
1225 /* Root of the chain of bpstat's */
1226 struct bpstat root_bs[1];
1227 /* Pointer to the last thing in the chain currently. */
1228 bpstat bs = root_bs;
1229 static char message1[] =
1230 "Error evaluating expression for watchpoint %d\n";
1231 char message[sizeof (message1) + 30 /* slop */];
1233 /* Get the address where the breakpoint would have been. */
1234 bp_addr = *pc - DECR_PC_AFTER_BREAK;
1238 if (b->enable == disabled)
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 && b->type != bp_hardware_breakpoint
1246 && b->address != bp_addr)
1249 #ifndef DECR_PC_AFTER_HW_BREAK
1250 #define DECR_PC_AFTER_HW_BREAK 0
1252 if (b->type == bp_hardware_breakpoint
1253 && b->address != (bp_addr - DECR_PC_AFTER_HW_BREAK))
1256 if (b->type != bp_watchpoint
1257 && b->type != bp_hardware_watchpoint
1258 && b->type != bp_read_watchpoint
1259 && b->type != bp_access_watchpoint
1260 && not_a_breakpoint)
1263 /* Come here if it's a watchpoint, or if the break address matches */
1267 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
1272 sprintf (message, message1, b->number);
1273 if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint)
1275 switch (catch_errors (watchpoint_check, (char *) bs, message,
1279 /* We've already printed what needs to be printed. */
1280 bs->print_it = print_it_done;
1283 case WP_VALUE_CHANGED:
1286 case WP_VALUE_NOT_CHANGED:
1288 bs->print_it = print_it_noop;
1295 /* Error from catch_errors. */
1296 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1297 if (b->related_breakpoint)
1298 delete_breakpoint (b->related_breakpoint);
1299 delete_breakpoint (b);
1300 /* We've already printed what needs to be printed. */
1301 bs->print_it = print_it_done;
1307 else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint)
1313 addr = target_stopped_data_address();
1314 if (addr == 0) continue;
1315 for (v = b->val_chain; v; v = v->next)
1317 if (v->lval == lval_memory)
1321 vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
1327 switch (catch_errors (watchpoint_check, (char *) bs, message,
1331 /* We've already printed what needs to be printed. */
1332 bs->print_it = print_it_done;
1335 case WP_VALUE_CHANGED:
1336 case WP_VALUE_NOT_CHANGED:
1342 /* Error from catch_errors. */
1343 printf_filtered ("Watchpoint %d deleted.\n", b->number);
1344 if (b->related_breakpoint)
1345 delete_breakpoint (b->related_breakpoint);
1346 delete_breakpoint (b);
1347 /* We've already printed what needs to be printed. */
1348 bs->print_it = print_it_done;
1352 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1354 real_breakpoint = 1;
1357 if (b->frame && b->frame != (get_current_frame ())->frame)
1361 int value_is_zero = 0;
1365 /* Need to select the frame, with all that implies
1366 so that the conditions will have the right context. */
1367 select_frame (get_current_frame (), 0);
1369 = catch_errors (breakpoint_cond_eval, (char *)(b->cond),
1370 "Error in testing breakpoint condition:\n",
1372 /* FIXME-someday, should give breakpoint # */
1375 if (b->cond && value_is_zero)
1379 else if (b->ignore_count > 0)
1386 /* We will stop here */
1387 if (b->disposition == disable)
1388 b->enable = disabled;
1389 bs->commands = b->commands;
1392 if (bs->commands && STREQ ("silent", bs->commands->line))
1394 bs->commands = bs->commands->next;
1399 /* Print nothing for this entry if we dont stop or if we dont print. */
1400 if (bs->stop == 0 || bs->print == 0)
1401 bs->print_it = print_it_noop;
1404 bs->next = NULL; /* Terminate the chain */
1405 bs = root_bs->next; /* Re-grab the head of the chain */
1406 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1409 if (real_breakpoint)
1412 #if defined (SHIFT_INST_REGS)
1414 #else /* No SHIFT_INST_REGS. */
1416 #endif /* No SHIFT_INST_REGS. */
1419 #endif /* DECR_PC_AFTER_BREAK != 0. */
1421 /* The value of a hardware watchpoint hasn't changed, but the
1422 intermediate memory locations we are watching may have. */
1423 if (bs && ! bs->stop &&
1424 (bs->breakpoint_at->type == bp_hardware_watchpoint ||
1425 bs->breakpoint_at->type == bp_read_watchpoint ||
1426 bs->breakpoint_at->type == bp_access_watchpoint))
1428 remove_breakpoints ();
1429 insert_breakpoints ();
1434 /* Tell what to do about this bpstat. */
1439 /* Classify each bpstat as one of the following. */
1441 /* This bpstat element has no effect on the main_action. */
1444 /* There was a watchpoint, stop but don't print. */
1447 /* There was a watchpoint, stop and print. */
1450 /* There was a breakpoint but we're not stopping. */
1453 /* There was a breakpoint, stop but don't print. */
1456 /* There was a breakpoint, stop and print. */
1459 /* We hit the longjmp breakpoint. */
1462 /* We hit the longjmp_resume breakpoint. */
1465 /* We hit the step_resume breakpoint. */
1468 /* We hit the through_sigtramp breakpoint. */
1471 /* This is just used to count how many enums there are. */
1475 /* Here is the table which drives this routine. So that we can
1476 format it pretty, we define some abbreviations for the
1477 enum bpstat_what codes. */
1478 #define keep_c BPSTAT_WHAT_KEEP_CHECKING
1479 #define stop_s BPSTAT_WHAT_STOP_SILENT
1480 #define stop_n BPSTAT_WHAT_STOP_NOISY
1481 #define single BPSTAT_WHAT_SINGLE
1482 #define setlr BPSTAT_WHAT_SET_LONGJMP_RESUME
1483 #define clrlr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1484 #define clrlrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1485 #define sr BPSTAT_WHAT_STEP_RESUME
1486 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1488 /* "Can't happen." Might want to print an error message.
1489 abort() is not out of the question, but chances are GDB is just
1490 a bit confused, not unusable. */
1491 #define err BPSTAT_WHAT_STOP_NOISY
1493 /* Given an old action and a class, come up with a new action. */
1494 /* One interesting property of this table is that wp_silent is the same
1495 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1496 after stopping, the check for whether to step over a breakpoint
1497 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1498 reference to how we stopped. We retain separate wp_silent and bp_silent
1499 codes in case we want to change that someday. */
1501 /* step_resume entries: a step resume breakpoint overrides another
1502 breakpoint of signal handling (see comment in wait_for_inferior
1503 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1504 /* We handle the through_sigtramp_breakpoint the same way; having both
1505 one of those and a step_resume_breakpoint is probably very rare (?). */
1507 static const enum bpstat_what_main_action
1508 table[(int)class_last][(int)BPSTAT_WHAT_LAST] =
1511 /* keep_c stop_s stop_n single setlr clrlr clrlrs sr ts
1513 /*no_effect*/ {keep_c,stop_s,stop_n,single, setlr , clrlr , clrlrs, sr, ts},
1514 /*wp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1515 /*wp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1516 /*bp_nostop*/ {single,stop_s,stop_n,single, setlr , clrlrs, clrlrs, sr, ts},
1517 /*bp_silent*/ {stop_s,stop_s,stop_n,stop_s, stop_s, stop_s, stop_s, sr, ts},
1518 /*bp_noisy*/ {stop_n,stop_n,stop_n,stop_n, stop_n, stop_n, stop_n, sr, ts},
1519 /*long_jump*/ {setlr ,stop_s,stop_n,setlr , err , err , err , sr, ts},
1520 /*long_resume*/ {clrlr ,stop_s,stop_n,clrlrs, err , err , err , sr, ts},
1521 /*step_resume*/ {sr ,sr ,sr ,sr , sr , sr , sr , sr, ts},
1522 /*through_sig*/ {ts ,ts ,ts ,ts , ts , ts , ts , ts, ts}
1534 enum bpstat_what_main_action current_action = BPSTAT_WHAT_KEEP_CHECKING;
1535 struct bpstat_what retval;
1537 retval.call_dummy = 0;
1538 for (; bs != NULL; bs = bs->next)
1540 enum class bs_class = no_effect;
1541 if (bs->breakpoint_at == NULL)
1542 /* I suspect this can happen if it was a momentary breakpoint
1543 which has since been deleted. */
1545 switch (bs->breakpoint_at->type)
1548 case bp_hardware_breakpoint:
1554 bs_class = bp_noisy;
1556 bs_class = bp_silent;
1559 bs_class = bp_nostop;
1562 case bp_hardware_watchpoint:
1563 case bp_read_watchpoint:
1564 case bp_access_watchpoint:
1568 bs_class = wp_noisy;
1570 bs_class = wp_silent;
1573 /* There was a watchpoint, but we're not stopping. This requires
1574 no further action. */
1575 bs_class = no_effect;
1578 bs_class = long_jump;
1580 case bp_longjmp_resume:
1581 bs_class = long_resume;
1583 case bp_step_resume:
1586 bs_class = step_resume;
1589 /* It is for the wrong frame. */
1590 bs_class = bp_nostop;
1592 case bp_through_sigtramp:
1593 bs_class = through_sig;
1595 case bp_watchpoint_scope:
1596 bs_class = bp_nostop;
1600 /* Make sure the action is stop (silent or noisy), so infrun.c
1601 pops the dummy frame. */
1602 bs_class = bp_silent;
1603 retval.call_dummy = 1;
1606 current_action = table[(int)bs_class][(int)current_action];
1608 retval.main_action = current_action;
1612 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1613 without hardware support). This isn't related to a specific bpstat,
1614 just to things like whether watchpoints are set. */
1617 bpstat_should_step ()
1619 struct breakpoint *b;
1621 if (b->enable == enabled && b->type == bp_watchpoint)
1626 /* Print information on breakpoint number BNUM, or -1 if all.
1627 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1628 is nonzero, process only watchpoints. */
1631 breakpoint_1 (bnum, allflag)
1635 register struct breakpoint *b;
1636 register struct command_line *l;
1637 register struct symbol *sym;
1638 CORE_ADDR last_addr = (CORE_ADDR)-1;
1639 int found_a_breakpoint = 0;
1640 static char *bptypes[] = {"breakpoint", "hw breakpoint",
1641 "until", "finish", "watchpoint",
1642 "hw watchpoint", "read watchpoint",
1643 "acc watchpoint", "longjmp",
1644 "longjmp resume", "step resume",
1645 "watchpoint scope", "call dummy" };
1646 static char *bpdisps[] = {"del", "dis", "keep"};
1647 static char bpenables[] = "ny";
1648 char wrap_indent[80];
1652 || bnum == b->number)
1654 /* We only print out user settable breakpoints unless the allflag is set. */
1656 && b->type != bp_breakpoint
1657 && b->type != bp_hardware_breakpoint
1658 && b->type != bp_watchpoint
1659 && b->type != bp_read_watchpoint
1660 && b->type != bp_access_watchpoint
1661 && b->type != bp_hardware_watchpoint)
1664 if (!found_a_breakpoint++)
1666 annotate_breakpoints_headers ();
1669 printf_filtered ("Num ");
1671 printf_filtered ("Type ");
1673 printf_filtered ("Disp ");
1675 printf_filtered ("Enb ");
1679 printf_filtered ("Address ");
1682 printf_filtered ("What\n");
1684 annotate_breakpoints_table ();
1689 printf_filtered ("%-3d ", b->number);
1691 printf_filtered ("%-14s ", bptypes[(int)b->type]);
1693 printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
1695 printf_filtered ("%-3c ", bpenables[(int)b->enable]);
1697 strcpy (wrap_indent, " ");
1699 strcat (wrap_indent, " ");
1703 case bp_hardware_watchpoint:
1704 case bp_read_watchpoint:
1705 case bp_access_watchpoint:
1706 /* Field 4, the address, is omitted (which makes the columns
1707 not line up too nicely with the headers, but the effect
1708 is relatively readable). */
1710 print_expression (b->exp, gdb_stdout);
1714 case bp_hardware_breakpoint:
1718 case bp_longjmp_resume:
1719 case bp_step_resume:
1720 case bp_through_sigtramp:
1721 case bp_watchpoint_scope:
1726 /* FIXME-32x64: need a print_address_numeric with
1730 local_hex_string_custom
1731 ((unsigned long) b->address, "08l"));
1736 last_addr = b->address;
1739 sym = find_pc_function (b->address);
1742 fputs_filtered ("in ", gdb_stdout);
1743 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
1744 wrap_here (wrap_indent);
1745 fputs_filtered (" at ", gdb_stdout);
1747 fputs_filtered (b->source_file, gdb_stdout);
1748 printf_filtered (":%d", b->line_number);
1751 print_address_symbolic (b->address, gdb_stdout, demangle, " ");
1755 printf_filtered ("\n");
1761 printf_filtered ("\tstop only in stack frame at ");
1762 print_address_numeric (b->frame, 1, gdb_stdout);
1763 printf_filtered ("\n");
1770 printf_filtered ("\tstop only if ");
1771 print_expression (b->cond, gdb_stdout);
1772 printf_filtered ("\n");
1775 if (show_breakpoint_hit_counts && b->hit_count)
1777 /* FIXME should make an annotation for this */
1779 printf_filtered ("\tbreakpoint already hit %d time%s\n",
1780 b->hit_count, (b->hit_count == 1 ? "" : "s"));
1783 if (b->ignore_count)
1787 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
1790 if ((l = b->commands))
1796 fputs_filtered ("\t", gdb_stdout);
1797 fputs_filtered (l->line, gdb_stdout);
1798 fputs_filtered ("\n", gdb_stdout);
1804 if (!found_a_breakpoint)
1807 printf_filtered ("No breakpoints or watchpoints.\n");
1809 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
1812 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1813 that a comparison of an unsigned with -1 is always false. */
1814 if (last_addr != (CORE_ADDR)-1)
1815 set_next_address (last_addr);
1817 annotate_breakpoints_table_end ();
1822 breakpoints_info (bnum_exp, from_tty)
1829 bnum = parse_and_eval_address (bnum_exp);
1831 breakpoint_1 (bnum, 0);
1834 #if MAINTENANCE_CMDS
1838 maintenance_info_breakpoints (bnum_exp, from_tty)
1845 bnum = parse_and_eval_address (bnum_exp);
1847 breakpoint_1 (bnum, 1);
1852 /* Print a message describing any breakpoints set at PC. */
1855 describe_other_breakpoints (pc)
1856 register CORE_ADDR pc;
1858 register int others = 0;
1859 register struct breakpoint *b;
1862 if (b->address == pc)
1866 printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1868 if (b->address == pc)
1874 (b->enable == disabled) ? " (disabled)" : "",
1875 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1877 printf_filtered ("also set at pc ");
1878 print_address_numeric (pc, 1, gdb_stdout);
1879 printf_filtered (".\n");
1883 /* Set the default place to put a breakpoint
1884 for the `break' command with no arguments. */
1887 set_default_breakpoint (valid, addr, symtab, line)
1890 struct symtab *symtab;
1893 default_breakpoint_valid = valid;
1894 default_breakpoint_address = addr;
1895 default_breakpoint_symtab = symtab;
1896 default_breakpoint_line = line;
1899 /* Rescan breakpoints at address ADDRESS,
1900 marking the first one as "first" and any others as "duplicates".
1901 This is so that the bpt instruction is only inserted once. */
1904 check_duplicates (address)
1907 register struct breakpoint *b;
1908 register int count = 0;
1910 if (address == 0) /* Watchpoints are uninteresting */
1914 if (b->enable != disabled && b->address == address)
1917 b->duplicate = count > 1;
1921 /* Low level routine to set a breakpoint.
1922 Takes as args the three things that every breakpoint must have.
1923 Returns the breakpoint object so caller can set other things.
1924 Does not set the breakpoint number!
1925 Does not print anything.
1927 ==> This routine should not be called if there is a chance of later
1928 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1929 your arguments BEFORE calling this routine! */
1931 static struct breakpoint *
1932 set_raw_breakpoint (sal)
1933 struct symtab_and_line sal;
1935 register struct breakpoint *b, *b1;
1937 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1938 memset (b, 0, sizeof (*b));
1939 b->address = sal.pc;
1940 if (sal.symtab == NULL)
1941 b->source_file = NULL;
1943 b->source_file = savestring (sal.symtab->filename,
1944 strlen (sal.symtab->filename));
1945 b->language = current_language->la_language;
1946 b->input_radix = input_radix;
1948 b->line_number = sal.line;
1949 b->enable = enabled;
1952 b->ignore_count = 0;
1956 /* Add this breakpoint to the end of the chain
1957 so that a list of breakpoints will come out in order
1958 of increasing numbers. */
1960 b1 = breakpoint_chain;
1962 breakpoint_chain = b;
1970 check_duplicates (sal.pc);
1971 breakpoints_changed ();
1977 create_longjmp_breakpoint(func_name)
1980 struct symtab_and_line sal;
1981 struct breakpoint *b;
1982 static int internal_breakpoint_number = -1;
1984 if (func_name != NULL)
1986 struct minimal_symbol *m;
1988 m = lookup_minimal_symbol(func_name, (struct objfile *)NULL);
1990 sal.pc = SYMBOL_VALUE_ADDRESS (m);
2000 b = set_raw_breakpoint(sal);
2003 b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume;
2004 b->disposition = donttouch;
2005 b->enable = disabled;
2008 b->addr_string = strsave(func_name);
2009 b->number = internal_breakpoint_number--;
2012 /* Call this routine when stepping and nexting to enable a breakpoint if we do
2013 a longjmp(). When we hit that breakpoint, call
2014 set_longjmp_resume_breakpoint() to figure out where we are going. */
2017 enable_longjmp_breakpoint()
2019 register struct breakpoint *b;
2022 if (b->type == bp_longjmp)
2024 b->enable = enabled;
2025 check_duplicates (b->address);
2030 disable_longjmp_breakpoint()
2032 register struct breakpoint *b;
2035 if ( b->type == bp_longjmp
2036 || b->type == bp_longjmp_resume)
2038 b->enable = disabled;
2039 check_duplicates (b->address);
2044 hw_breakpoint_used_count()
2046 register struct breakpoint *b;
2051 if (b->type == bp_hardware_breakpoint && b->enable == enabled)
2059 hw_watchpoint_used_count(type, other_type_used)
2061 int *other_type_used;
2063 register struct breakpoint *b;
2066 *other_type_used = 0;
2069 if (b->enable == enabled)
2071 if (b->type == type) i++;
2072 else if ((b->type == bp_hardware_watchpoint ||
2073 b->type == bp_read_watchpoint ||
2074 b->type == bp_access_watchpoint)
2075 && b->enable == enabled)
2076 *other_type_used = 1;
2082 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2083 breakpoint at the target of the jmp_buf.
2085 FIXME - This ought to be done by setting a temporary breakpoint that gets
2086 deleted automatically...
2090 set_longjmp_resume_breakpoint(pc, frame)
2092 struct frame_info *frame;
2094 register struct breakpoint *b;
2097 if (b->type == bp_longjmp_resume)
2100 b->enable = enabled;
2102 b->frame = frame->frame;
2105 check_duplicates (b->address);
2110 /* Set a breakpoint that will evaporate an end of command
2111 at address specified by SAL.
2112 Restrict it to frame FRAME if FRAME is nonzero. */
2115 set_momentary_breakpoint (sal, frame, type)
2116 struct symtab_and_line sal;
2117 struct frame_info *frame;
2120 register struct breakpoint *b;
2121 b = set_raw_breakpoint (sal);
2123 b->enable = enabled;
2124 b->disposition = donttouch;
2125 b->frame = (frame ? frame->frame : 0);
2131 clear_momentary_breakpoints ()
2133 register struct breakpoint *b;
2135 if (b->disposition == delete)
2137 delete_breakpoint (b);
2143 /* Tell the user we have just set a breakpoint B. */
2147 struct breakpoint *b;
2151 /* FIXME: This is misplaced; mention() is called by things (like hitting a
2152 watchpoint) other than breakpoint creation. It should be possible to
2153 clean this up and at the same time replace the random calls to
2154 breakpoint_changed with this hook, as has already been done for
2155 delete_breakpoint_hook and so on. */
2156 if (create_breakpoint_hook)
2157 create_breakpoint_hook (b);
2162 printf_filtered ("Watchpoint %d: ", b->number);
2163 print_expression (b->exp, gdb_stdout);
2165 case bp_hardware_watchpoint:
2166 printf_filtered ("Hardware watchpoint %d: ", b->number);
2167 print_expression (b->exp, gdb_stdout);
2169 case bp_read_watchpoint:
2170 printf_filtered ("Hardware read watchpoint %d: ", b->number);
2171 print_expression (b->exp, gdb_stdout);
2173 case bp_access_watchpoint:
2174 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b->number);
2175 print_expression (b->exp, gdb_stdout);
2178 printf_filtered ("Breakpoint %d", b->number);
2181 case bp_hardware_breakpoint:
2182 printf_filtered ("Hardware assisted breakpoint %d", b->number);
2188 case bp_longjmp_resume:
2189 case bp_step_resume:
2190 case bp_through_sigtramp:
2192 case bp_watchpoint_scope:
2197 if (addressprint || b->source_file == NULL)
2199 printf_filtered (" at ");
2200 print_address_numeric (b->address, 1, gdb_stdout);
2203 printf_filtered (": file %s, line %d.",
2204 b->source_file, b->line_number);
2206 printf_filtered ("\n");
2210 /* Nobody calls this currently. */
2211 /* Set a breakpoint from a symtab and line.
2212 If TEMPFLAG is nonzero, it is a temporary breakpoint.
2213 ADDR_STRING is a malloc'd string holding the name of where we are
2214 setting the breakpoint. This is used later to re-set it after the
2215 program is relinked and symbols are reloaded.
2216 Print the same confirmation messages that the breakpoint command prints. */
2219 set_breakpoint (s, line, tempflag, addr_string)
2225 register struct breakpoint *b;
2226 struct symtab_and_line sal;
2231 resolve_sal_pc (&sal); /* Might error out */
2232 describe_other_breakpoints (sal.pc);
2234 b = set_raw_breakpoint (sal);
2235 set_breakpoint_count (breakpoint_count + 1);
2236 b->number = breakpoint_count;
2237 b->type = bp_breakpoint;
2239 b->addr_string = addr_string;
2240 b->enable = enabled;
2241 b->disposition = tempflag ? delete : donttouch;
2247 /* Set a breakpoint according to ARG (function, linenum or *address)
2248 flag: first bit : 0 non-temporary, 1 temporary.
2249 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2252 break_command_1 (arg, flag, from_tty)
2256 int tempflag, hardwareflag;
2257 struct symtabs_and_lines sals;
2258 struct symtab_and_line sal;
2259 register struct expression *cond = 0;
2260 register struct breakpoint *b;
2262 /* Pointers in arg to the start, and one past the end, of the condition. */
2263 char *cond_start = NULL;
2264 char *cond_end = NULL;
2265 /* Pointers in arg to the start, and one past the end,
2266 of the address part. */
2267 char *addr_start = NULL;
2268 char *addr_end = NULL;
2269 struct cleanup *old_chain;
2270 struct cleanup *canonical_strings_chain = NULL;
2271 char **canonical = (char **)NULL;
2275 hardwareflag = flag & 2;
2276 tempflag = flag & 1;
2281 sal.line = sal.pc = sal.end = 0;
2284 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2286 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2287 && (arg[2] == ' ' || arg[2] == '\t')))
2289 if (default_breakpoint_valid)
2291 sals.sals = (struct symtab_and_line *)
2292 xmalloc (sizeof (struct symtab_and_line));
2293 sal.pc = default_breakpoint_address;
2294 sal.line = default_breakpoint_line;
2295 sal.symtab = default_breakpoint_symtab;
2300 error ("No default breakpoint address now.");
2306 /* Force almost all breakpoints to be in terms of the
2307 current_source_symtab (which is decode_line_1's default). This
2308 should produce the results we want almost all of the time while
2309 leaving default_breakpoint_* alone. */
2310 if (default_breakpoint_valid
2311 && (!current_source_symtab
2312 || (arg && (*arg == '+' || *arg == '-'))))
2313 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2314 default_breakpoint_line, &canonical);
2316 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical);
2324 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2325 the following `for' loop errors out. */
2326 old_chain = make_cleanup (free, sals.sals);
2327 if (canonical != (char **)NULL)
2329 make_cleanup (free, canonical);
2330 canonical_strings_chain = make_cleanup (null_cleanup, 0);
2331 for (i = 0; i < sals.nelts; i++)
2333 if (canonical[i] != NULL)
2334 make_cleanup (free, canonical[i]);
2338 thread = -1; /* No specific thread yet */
2340 /* Resolve all line numbers to PC's, and verify that conditions
2341 can be parsed, before setting any breakpoints. */
2342 for (i = 0; i < sals.nelts; i++)
2344 char *tok, *end_tok;
2347 resolve_sal_pc (&sals.sals[i]);
2353 while (*tok == ' ' || *tok == '\t')
2358 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2361 toklen = end_tok - tok;
2363 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2365 tok = cond_start = end_tok + 1;
2366 cond = parse_exp_1 (&tok, block_for_pc (sals.sals[i].pc), 0);
2369 else if (toklen >= 1 && strncmp (tok, "thread", toklen) == 0)
2375 thread = strtol (tok, &tok, 0);
2377 error ("Junk after thread keyword.");
2378 if (!valid_thread_id (thread))
2379 error ("Unknown thread %d\n", thread);
2382 error ("Junk at end of arguments.");
2387 int i, target_resources_ok;
2389 i = hw_breakpoint_used_count ();
2390 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
2391 bp_hardware_breakpoint, i + sals.nelts, 0);
2392 if (target_resources_ok == 0)
2393 error ("No hardware breakpoint support in the target.");
2394 else if (target_resources_ok < 0)
2395 error ("Hardware breakpoints used exceeds limit.");
2398 /* Remove the canonical strings from the cleanup, they are needed below. */
2399 if (canonical != (char **)NULL)
2400 discard_cleanups (canonical_strings_chain);
2402 /* Now set all the breakpoints. */
2403 for (i = 0; i < sals.nelts; i++)
2408 describe_other_breakpoints (sal.pc);
2410 b = set_raw_breakpoint (sal);
2411 set_breakpoint_count (breakpoint_count + 1);
2412 b->number = breakpoint_count;
2413 b->type = hardwareflag ? bp_hardware_breakpoint : bp_breakpoint;
2417 /* If a canonical line spec is needed use that instead of the
2419 if (canonical != (char **)NULL && canonical[i] != NULL)
2420 b->addr_string = canonical[i];
2421 else if (addr_start)
2422 b->addr_string = savestring (addr_start, addr_end - addr_start);
2424 b->cond_string = savestring (cond_start, cond_end - cond_start);
2426 b->enable = enabled;
2427 b->disposition = tempflag ? delete : donttouch;
2434 printf_filtered ("Multiple breakpoints were set.\n");
2435 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2437 do_cleanups (old_chain);
2440 /* Helper function for break_command_1 and disassemble_command. */
2443 resolve_sal_pc (sal)
2444 struct symtab_and_line *sal;
2448 if (sal->pc == 0 && sal->symtab != 0)
2450 pc = find_line_pc (sal->symtab, sal->line);
2452 error ("No line %d in file \"%s\".",
2453 sal->line, sal->symtab->filename);
2458 #define BP_TEMPFLAG 1
2459 #define BP_HARDWAREFLAG 2
2461 break_command (arg, from_tty)
2465 break_command_1 (arg, 0, from_tty);
2469 tbreak_command (arg, from_tty)
2473 break_command_1 (arg, BP_TEMPFLAG, from_tty);
2477 hbreak_command (arg, from_tty)
2481 break_command_1 (arg, BP_HARDWAREFLAG, from_tty);
2485 thbreak_command (arg, from_tty)
2489 break_command_1 (arg, (BP_TEMPFLAG | BP_HARDWAREFLAG), from_tty);
2493 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2496 watch_command_1 (arg, accessflag, from_tty)
2501 struct breakpoint *b;
2502 struct symtab_and_line sal;
2503 struct expression *exp;
2504 struct block *exp_valid_block;
2505 struct value *val, *mark;
2506 struct frame_info *frame, *prev_frame;
2507 char *exp_start = NULL;
2508 char *exp_end = NULL;
2509 char *tok, *end_tok;
2511 char *cond_start = NULL;
2512 char *cond_end = NULL;
2513 struct expression *cond = NULL;
2514 int i, other_type_used, target_resources_ok;
2515 enum bptype bp_type;
2522 /* Parse arguments. */
2523 innermost_block = NULL;
2525 exp = parse_exp_1 (&arg, 0, 0);
2527 exp_valid_block = innermost_block;
2528 mark = value_mark ();
2529 val = evaluate_expression (exp);
2530 release_value (val);
2531 if (VALUE_LAZY (val))
2532 value_fetch_lazy (val);
2535 while (*tok == ' ' || *tok == '\t')
2539 while (*end_tok != ' ' && *end_tok != '\t' && *end_tok != '\000')
2542 toklen = end_tok - tok;
2543 if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
2545 tok = cond_start = end_tok + 1;
2546 cond = parse_exp_1 (&tok, 0, 0);
2550 error("Junk at end of command.");
2552 if (accessflag == 1) bp_type = bp_read_watchpoint;
2553 else if (accessflag == 2) bp_type = bp_access_watchpoint;
2554 else bp_type = bp_hardware_watchpoint;
2556 mem_cnt = can_use_hardware_watchpoint (val);
2557 if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint)
2558 error ("Expression cannot be implemented with read/access watchpoint.");
2560 i = hw_watchpoint_used_count (bp_type, &other_type_used);
2561 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2562 bp_type, i + mem_cnt, other_type_used);
2563 if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint)
2564 error ("Target does not have this type of hardware watchpoint support.");
2565 if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint)
2566 error ("Target resources have been allocated for other types of watchpoints.");
2569 /* Now set up the breakpoint. */
2570 b = set_raw_breakpoint (sal);
2571 set_breakpoint_count (breakpoint_count + 1);
2572 b->number = breakpoint_count;
2573 b->disposition = donttouch;
2575 b->exp_valid_block = exp_valid_block;
2576 b->exp_string = savestring (exp_start, exp_end - exp_start);
2580 b->cond_string = savestring (cond_start, cond_end - cond_start);
2584 frame = block_innermost_frame (exp_valid_block);
2587 prev_frame = get_prev_frame (frame);
2588 b->watchpoint_frame = frame->frame;
2591 b->watchpoint_frame = (CORE_ADDR)0;
2593 if (mem_cnt && target_resources_ok > 0)
2596 b->type = bp_watchpoint;
2598 /* If the expression is "local", then set up a "watchpoint scope"
2599 breakpoint at the point where we've left the scope of the watchpoint
2601 if (innermost_block)
2603 struct breakpoint *scope_breakpoint;
2604 struct symtab_and_line scope_sal;
2608 scope_sal.pc = get_frame_pc (prev_frame);
2609 scope_sal.symtab = NULL;
2612 scope_breakpoint = set_raw_breakpoint (scope_sal);
2613 set_breakpoint_count (breakpoint_count + 1);
2614 scope_breakpoint->number = breakpoint_count;
2616 scope_breakpoint->type = bp_watchpoint_scope;
2617 scope_breakpoint->enable = enabled;
2619 /* Automatically delete the breakpoint when it hits. */
2620 scope_breakpoint->disposition = delete;
2622 /* Only break in the proper frame (help with recursion). */
2623 scope_breakpoint->frame = prev_frame->frame;
2625 /* Set the address at which we will stop. */
2626 scope_breakpoint->address = get_frame_pc (prev_frame);
2628 /* The scope breakpoint is related to the watchpoint. We
2629 will need to act on them together. */
2630 b->related_breakpoint = scope_breakpoint;
2633 value_free_to_mark (mark);
2637 /* Return count of locations need to be watched and can be handled
2638 in hardware. If the watchpoint can not be handled
2639 in hardware return zero. */
2642 can_use_hardware_watchpoint (v)
2645 int found_memory_cnt = 0;
2647 /* Make sure all the intermediate values are in memory. Also make sure
2648 we found at least one memory expression. Guards against watch 0x12345,
2649 which is meaningless, but could cause errors if one tries to insert a
2650 hardware watchpoint for the constant expression. */
2651 for ( ; v; v = v->next)
2653 if (v->lval == lval_memory)
2655 if (TYPE_LENGTH (VALUE_TYPE (v)) <= REGISTER_SIZE)
2658 else if (v->lval != not_lval && v->modifiable == 0)
2662 /* The expression itself looks suitable for using a hardware
2663 watchpoint, but give the target machine a chance to reject it. */
2664 return found_memory_cnt;
2667 static void watch_command (arg, from_tty)
2671 watch_command_1 (arg, 0, from_tty);
2674 static void rwatch_command (arg, from_tty)
2678 watch_command_1 (arg, 1, from_tty);
2681 static void awatch_command (arg, from_tty)
2685 watch_command_1 (arg, 2, from_tty);
2689 /* Helper routine for the until_command routine in infcmd.c. Here
2690 because it uses the mechanisms of breakpoints. */
2694 until_break_command (arg, from_tty)
2698 struct symtabs_and_lines sals;
2699 struct symtab_and_line sal;
2700 struct frame_info *prev_frame = get_prev_frame (selected_frame);
2701 struct breakpoint *breakpoint;
2702 struct cleanup *old_chain;
2704 clear_proceed_status ();
2706 /* Set a breakpoint where the user wants it and at return from
2709 if (default_breakpoint_valid)
2710 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
2711 default_breakpoint_line, (char ***)NULL);
2713 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL);
2715 if (sals.nelts != 1)
2716 error ("Couldn't get information on specified line.");
2719 free ((PTR)sals.sals); /* malloc'd, so freed */
2722 error ("Junk at end of arguments.");
2724 resolve_sal_pc (&sal);
2726 breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
2728 old_chain = make_cleanup(delete_breakpoint, breakpoint);
2730 /* Keep within the current frame */
2734 sal = find_pc_line (prev_frame->pc, 0);
2735 sal.pc = prev_frame->pc;
2736 breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
2737 make_cleanup(delete_breakpoint, breakpoint);
2740 proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
2741 do_cleanups(old_chain);
2745 /* These aren't used; I don't konw what they were for. */
2746 /* Set a breakpoint at the catch clause for NAME. */
2748 catch_breakpoint (name)
2754 disable_catch_breakpoint ()
2759 delete_catch_breakpoint ()
2764 enable_catch_breakpoint ()
2771 struct sal_chain *next;
2772 struct symtab_and_line sal;
2776 /* This isn't used; I don't know what it was for. */
2777 /* For each catch clause identified in ARGS, run FUNCTION
2778 with that clause as an argument. */
2779 static struct symtabs_and_lines
2780 map_catch_names (args, function)
2784 register char *p = args;
2786 struct symtabs_and_lines sals;
2788 struct sal_chain *sal_chain = 0;
2792 error_no_arg ("one or more catch names");
2800 /* Don't swallow conditional part. */
2801 if (p1[0] == 'i' && p1[1] == 'f'
2802 && (p1[2] == ' ' || p1[2] == '\t'))
2808 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
2812 if (*p1 && *p1 != ' ' && *p1 != '\t')
2813 error ("Arguments must be catch names.");
2819 struct sal_chain *next
2820 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
2821 next->next = sal_chain;
2822 next->sal = get_catch_sal (p);
2827 printf_unfiltered ("No catch clause for exception %s.\n", p);
2832 while (*p == ' ' || *p == '\t') p++;
2837 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2839 static struct symtabs_and_lines
2840 get_catch_sals (this_level_only)
2841 int this_level_only;
2843 register struct blockvector *bl;
2844 register struct block *block;
2845 int index, have_default = 0;
2847 struct symtabs_and_lines sals;
2848 struct sal_chain *sal_chain = 0;
2849 char *blocks_searched;
2851 /* Not sure whether an error message is always the correct response,
2852 but it's better than a core dump. */
2853 if (selected_frame == NULL)
2854 error ("No selected frame.");
2855 block = get_frame_block (selected_frame);
2856 pc = selected_frame->pc;
2862 error ("No symbol table info available.\n");
2864 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
2865 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2866 memset (blocks_searched, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
2870 CORE_ADDR end = BLOCK_END (block) - 4;
2873 if (bl != blockvector_for_pc (end, &index))
2874 error ("blockvector blotch");
2875 if (BLOCKVECTOR_BLOCK (bl, index) != block)
2876 error ("blockvector botch");
2877 last_index = BLOCKVECTOR_NBLOCKS (bl);
2880 /* Don't print out blocks that have gone by. */
2881 while (index < last_index
2882 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
2885 while (index < last_index
2886 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
2888 if (blocks_searched[index] == 0)
2890 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
2893 register struct symbol *sym;
2895 nsyms = BLOCK_NSYMS (b);
2897 for (i = 0; i < nsyms; i++)
2899 sym = BLOCK_SYM (b, i);
2900 if (STREQ (SYMBOL_NAME (sym), "default"))
2906 if (SYMBOL_CLASS (sym) == LOC_LABEL)
2908 struct sal_chain *next = (struct sal_chain *)
2909 alloca (sizeof (struct sal_chain));
2910 next->next = sal_chain;
2911 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
2915 blocks_searched[index] = 1;
2921 if (sal_chain && this_level_only)
2924 /* After handling the function's top-level block, stop.
2925 Don't continue to its superblock, the block of
2926 per-file symbols. */
2927 if (BLOCK_FUNCTION (block))
2929 block = BLOCK_SUPERBLOCK (block);
2934 struct sal_chain *tmp_chain;
2936 /* Count the number of entries. */
2937 for (index = 0, tmp_chain = sal_chain; tmp_chain;
2938 tmp_chain = tmp_chain->next)
2942 sals.sals = (struct symtab_and_line *)
2943 xmalloc (index * sizeof (struct symtab_and_line));
2944 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
2945 sals.sals[index] = sal_chain->sal;
2951 /* Commands to deal with catching exceptions. */
2954 catch_command_1 (arg, tempflag, from_tty)
2959 /* First, translate ARG into something we can deal with in terms
2962 struct symtabs_and_lines sals;
2963 struct symtab_and_line sal;
2964 register struct expression *cond = 0;
2965 register struct breakpoint *b;
2969 sal.line = sal.pc = sal.end = 0;
2972 /* If no arg given, or if first arg is 'if ', all active catch clauses
2973 are breakpointed. */
2975 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
2976 && (arg[2] == ' ' || arg[2] == '\t')))
2978 /* Grab all active catch clauses. */
2979 sals = get_catch_sals (0);
2983 /* Grab selected catch clauses. */
2984 error ("catch NAME not implemented");
2986 /* This isn't used; I don't know what it was for. */
2987 sals = map_catch_names (arg, catch_breakpoint);
2995 for (i = 0; i < sals.nelts; i++)
2997 resolve_sal_pc (&sals.sals[i]);
3001 if (arg[0] == 'i' && arg[1] == 'f'
3002 && (arg[2] == ' ' || arg[2] == '\t'))
3003 cond = parse_exp_1 ((arg += 2, &arg),
3004 block_for_pc (sals.sals[i].pc), 0);
3006 error ("Junk at end of arguments.");
3011 for (i = 0; i < sals.nelts; i++)
3016 describe_other_breakpoints (sal.pc);
3018 b = set_raw_breakpoint (sal);
3019 set_breakpoint_count (breakpoint_count + 1);
3020 b->number = breakpoint_count;
3021 b->type = bp_breakpoint;
3023 b->enable = enabled;
3024 b->disposition = tempflag ? delete : donttouch;
3031 printf_unfiltered ("Multiple breakpoints were set.\n");
3032 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3034 free ((PTR)sals.sals);
3038 /* These aren't used; I don't know what they were for. */
3039 /* Disable breakpoints on all catch clauses described in ARGS. */
3041 disable_catch (args)
3044 /* Map the disable command to catch clauses described in ARGS. */
3047 /* Enable breakpoints on all catch clauses described in ARGS. */
3052 /* Map the disable command to catch clauses described in ARGS. */
3055 /* Delete breakpoints on all catch clauses in the active scope. */
3060 /* Map the delete command to catch clauses described in ARGS. */
3065 catch_command (arg, from_tty)
3069 catch_command_1 (arg, 0, from_tty);
3073 clear_command (arg, from_tty)
3077 register struct breakpoint *b, *b1;
3078 struct symtabs_and_lines sals;
3079 struct symtab_and_line sal;
3080 register struct breakpoint *found;
3085 sals = decode_line_spec (arg, 1);
3089 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
3090 sal.line = default_breakpoint_line;
3091 sal.symtab = default_breakpoint_symtab;
3093 if (sal.symtab == 0)
3094 error ("No source file specified.");
3100 for (i = 0; i < sals.nelts; i++)
3102 /* If exact pc given, clear bpts at that pc.
3103 But if sal.pc is zero, clear all bpts on specified line. */
3105 found = (struct breakpoint *) 0;
3106 while (breakpoint_chain
3108 ? breakpoint_chain->address == sal.pc
3109 : (breakpoint_chain->source_file != NULL
3110 && sal.symtab != NULL
3111 && STREQ (breakpoint_chain->source_file,
3112 sal.symtab->filename)
3113 && breakpoint_chain->line_number == sal.line)))
3115 b1 = breakpoint_chain;
3116 breakpoint_chain = b1->next;
3123 && b->next->type != bp_watchpoint
3124 && b->next->type != bp_hardware_watchpoint
3125 && b->next->type != bp_read_watchpoint
3126 && b->next->type != bp_access_watchpoint
3128 ? b->next->address == sal.pc
3129 : (b->next->source_file != NULL
3130 && sal.symtab != NULL
3131 && STREQ (b->next->source_file, sal.symtab->filename)
3132 && b->next->line_number == sal.line)))
3143 error ("No breakpoint at %s.", arg);
3145 error ("No breakpoint at this line.");
3148 if (found->next) from_tty = 1; /* Always report if deleted more than one */
3149 if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : "");
3150 breakpoints_changed ();
3153 if (from_tty) printf_unfiltered ("%d ", found->number);
3155 delete_breakpoint (found);
3158 if (from_tty) putchar_unfiltered ('\n');
3160 free ((PTR)sals.sals);
3163 /* Delete breakpoint in BS if they are `delete' breakpoints.
3164 This is called after any breakpoint is hit, or after errors. */
3167 breakpoint_auto_delete (bs)
3170 for (; bs; bs = bs->next)
3171 if (bs->breakpoint_at && bs->breakpoint_at->disposition == delete
3173 delete_breakpoint (bs->breakpoint_at);
3176 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3179 delete_breakpoint (bpt)
3180 struct breakpoint *bpt;
3182 register struct breakpoint *b;
3185 if (delete_breakpoint_hook)
3186 delete_breakpoint_hook (bpt);
3189 remove_breakpoint (bpt);
3191 if (breakpoint_chain == bpt)
3192 breakpoint_chain = bpt->next;
3197 b->next = bpt->next;
3201 check_duplicates (bpt->address);
3202 /* If this breakpoint was inserted, and there is another breakpoint
3203 at the same address, we need to insert the other breakpoint. */
3205 && bpt->type != bp_hardware_watchpoint
3206 && bpt->type != bp_read_watchpoint
3207 && bpt->type != bp_access_watchpoint)
3210 if (b->address == bpt->address
3212 && b->enable != disabled)
3215 val = target_insert_breakpoint (b->address, b->shadow_contents);
3218 target_terminal_ours_for_output ();
3219 fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number);
3220 memory_error (val, b->address); /* which bombs us out */
3227 free_command_lines (&bpt->commands);
3230 if (bpt->cond_string != NULL)
3231 free (bpt->cond_string);
3232 if (bpt->addr_string != NULL)
3233 free (bpt->addr_string);
3234 if (bpt->exp_string != NULL)
3235 free (bpt->exp_string);
3236 if (bpt->source_file != NULL)
3237 free (bpt->source_file);
3239 /* Be sure no bpstat's are pointing at it after it's been freed. */
3240 /* FIXME, how can we find all bpstat's?
3241 We just check stop_bpstat for now. */
3242 for (bs = stop_bpstat; bs; bs = bs->next)
3243 if (bs->breakpoint_at == bpt)
3244 bs->breakpoint_at = NULL;
3249 delete_command (arg, from_tty)
3256 /* Ask user only if there are some breakpoints to delete. */
3258 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
3260 /* No arg; clear all breakpoints. */
3261 while (breakpoint_chain)
3262 delete_breakpoint (breakpoint_chain);
3266 map_breakpoint_numbers (arg, delete_breakpoint);
3269 /* Reset a breakpoint given it's struct breakpoint * BINT.
3270 The value we return ends up being the return value from catch_errors.
3271 Unused in this case. */
3274 breakpoint_re_set_one (bint)
3277 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
3280 struct symtabs_and_lines sals;
3282 enum enable save_enable;
3287 case bp_hardware_breakpoint:
3288 if (b->addr_string == NULL)
3290 /* Anything without a string can't be re-set. */
3291 delete_breakpoint (b);
3294 /* In case we have a problem, disable this breakpoint. We'll restore
3295 its status if we succeed. */
3296 save_enable = b->enable;
3297 b->enable = disabled;
3299 set_language (b->language);
3300 input_radix = b->input_radix;
3302 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL);
3303 for (i = 0; i < sals.nelts; i++)
3305 resolve_sal_pc (&sals.sals[i]);
3307 /* Reparse conditions, they might contain references to the
3309 if (b->cond_string != NULL)
3313 free ((PTR)b->cond);
3314 b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0);
3317 /* We need to re-set the breakpoint if the address changes...*/
3318 if (b->address != sals.sals[i].pc
3319 /* ...or new and old breakpoints both have source files, and
3320 the source file name or the line number changes... */
3321 || (b->source_file != NULL
3322 && sals.sals[i].symtab != NULL
3323 && (!STREQ (b->source_file, sals.sals[i].symtab->filename)
3324 || b->line_number != sals.sals[i].line)
3326 /* ...or we switch between having a source file and not having
3328 || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL))
3331 if (b->source_file != NULL)
3332 free (b->source_file);
3333 if (sals.sals[i].symtab == NULL)
3334 b->source_file = NULL;
3337 savestring (sals.sals[i].symtab->filename,
3338 strlen (sals.sals[i].symtab->filename));
3339 b->line_number = sals.sals[i].line;
3340 b->address = sals.sals[i].pc;
3342 check_duplicates (b->address);
3346 /* Might be better to do this just once per breakpoint_re_set,
3347 rather than once for every breakpoint. */
3348 breakpoints_changed ();
3350 b->enable = save_enable; /* Restore it, this worked. */
3352 free ((PTR)sals.sals);
3356 case bp_hardware_watchpoint:
3357 case bp_read_watchpoint:
3358 case bp_access_watchpoint:
3359 innermost_block = NULL;
3360 /* The issue arises of what context to evaluate this in. The same
3361 one as when it was set, but what does that mean when symbols have
3362 been re-read? We could save the filename and functionname, but
3363 if the context is more local than that, the best we could do would
3364 be something like how many levels deep and which index at that
3365 particular level, but that's going to be less stable than filenames
3366 or functionnames. */
3367 /* So for now, just use a global context. */
3368 b->exp = parse_expression (b->exp_string);
3369 b->exp_valid_block = innermost_block;
3370 mark = value_mark ();
3371 b->val = evaluate_expression (b->exp);
3372 release_value (b->val);
3373 if (VALUE_LAZY (b->val))
3374 value_fetch_lazy (b->val);
3376 if (b->cond_string != NULL)
3379 b->cond = parse_exp_1 (&s, (struct block *)0, 0);
3381 if (b->enable == enabled)
3383 value_free_to_mark (mark);
3387 printf_filtered ("Deleting unknown breakpoint type %d\n", b->type);
3392 case bp_longjmp_resume:
3393 case bp_watchpoint_scope:
3395 delete_breakpoint (b);
3402 /* Re-set all breakpoints after symbols have been re-loaded. */
3404 breakpoint_re_set ()
3406 struct breakpoint *b, *temp;
3407 enum language save_language;
3408 int save_input_radix;
3409 static char message1[] = "Error in re-setting breakpoint %d:\n";
3410 char message[sizeof (message1) + 30 /* slop */];
3412 save_language = current_language->la_language;
3413 save_input_radix = input_radix;
3414 ALL_BREAKPOINTS_SAFE (b, temp)
3416 sprintf (message, message1, b->number); /* Format possible error msg */
3417 catch_errors (breakpoint_re_set_one, (char *) b, message,
3420 set_language (save_language);
3421 input_radix = save_input_radix;
3423 create_longjmp_breakpoint("longjmp");
3424 create_longjmp_breakpoint("_longjmp");
3425 create_longjmp_breakpoint("siglongjmp");
3426 create_longjmp_breakpoint(NULL);
3429 /* Took this out (temporaliy at least), since it produces an extra
3430 blank line at startup. This messes up the gdbtests. -PB */
3431 /* Blank line to finish off all those mention() messages we just printed. */
3432 printf_filtered ("\n");
3436 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3437 If from_tty is nonzero, it prints a message to that effect,
3438 which ends with a period (no newline). */
3441 set_ignore_count (bptnum, count, from_tty)
3442 int bptnum, count, from_tty;
3444 register struct breakpoint *b;
3450 if (b->number == bptnum)
3452 b->ignore_count = count;
3455 else if (count == 0)
3456 printf_filtered ("Will stop next time breakpoint %d is reached.",
3458 else if (count == 1)
3459 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3462 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3464 breakpoints_changed ();
3468 error ("No breakpoint number %d.", bptnum);
3471 /* Clear the ignore counts of all breakpoints. */
3473 breakpoint_clear_ignore_counts ()
3475 struct breakpoint *b;
3478 b->ignore_count = 0;
3481 /* Command to set ignore-count of breakpoint N to COUNT. */
3484 ignore_command (args, from_tty)
3492 error_no_arg ("a breakpoint number");
3494 num = get_number (&p);
3497 error ("Second argument (specified ignore-count) is missing.");
3499 set_ignore_count (num,
3500 longest_to_int (value_as_long (parse_and_eval (p))),
3502 printf_filtered ("\n");
3503 breakpoints_changed ();
3506 /* Call FUNCTION on each of the breakpoints
3507 whose numbers are given in ARGS. */
3510 map_breakpoint_numbers (args, function)
3512 void (*function) PARAMS ((struct breakpoint *));
3514 register char *p = args;
3517 register struct breakpoint *b;
3520 error_no_arg ("one or more breakpoint numbers");
3526 num = get_number (&p1);
3529 if (b->number == num)
3531 struct breakpoint *related_breakpoint = b->related_breakpoint;
3533 if (related_breakpoint)
3534 function (related_breakpoint);
3537 printf_unfiltered ("No breakpoint number %d.\n", num);
3544 enable_breakpoint (bpt)
3545 struct breakpoint *bpt;
3547 struct frame_info *save_selected_frame = NULL;
3548 int save_selected_frame_level = -1;
3549 int target_resources_ok, other_type_used;
3552 if (enable_breakpoint_hook)
3553 enable_breakpoint_hook (bpt);
3555 if (bpt->type == bp_hardware_breakpoint)
3558 i = hw_breakpoint_used_count();
3559 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3560 bp_hardware_breakpoint, i+1, 0);
3561 if (target_resources_ok == 0)
3562 error ("No hardware breakpoint support in the target.");
3563 else if (target_resources_ok < 0)
3564 error ("Hardware breakpoints used exceeds limit.");
3566 bpt->enable = enabled;
3567 check_duplicates (bpt->address);
3569 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3570 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3572 if (bpt->exp_valid_block != NULL)
3574 struct frame_info *fr =
3575 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3579 Cannot enable watchpoint %d because the block in which its expression\n\
3580 is valid is not currently in scope.\n", bpt->number);
3581 bpt->enable = disabled;
3585 save_selected_frame = selected_frame;
3586 save_selected_frame_level = selected_frame_level;
3587 select_frame (fr, -1);
3590 value_free (bpt->val);
3591 mark = value_mark ();
3592 bpt->val = evaluate_expression (bpt->exp);
3593 release_value (bpt->val);
3594 if (VALUE_LAZY (bpt->val))
3595 value_fetch_lazy (bpt->val);
3597 if (bpt->type == bp_hardware_watchpoint ||
3598 bpt->type == bp_read_watchpoint ||
3599 bpt->type == bp_access_watchpoint)
3601 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3602 int mem_cnt = can_use_hardware_watchpoint (bpt->val);
3604 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3605 bpt->type, i + mem_cnt, other_type_used);
3606 /* we can consider of type is bp_hardware_watchpoint, convert to
3607 bp_watchpoint in the following condition */
3608 if (target_resources_ok < 0)
3611 Cannot enable watchpoint %d because target watch resources\n\
3612 have been allocated for other watchpoints.\n", bpt->number);
3613 bpt->enable = disabled;
3614 value_free_to_mark (mark);
3619 if (save_selected_frame_level >= 0)
3620 select_frame (save_selected_frame, save_selected_frame_level);
3621 value_free_to_mark (mark);
3627 enable_command (args, from_tty)
3631 struct breakpoint *bpt;
3633 ALL_BREAKPOINTS (bpt)
3637 case bp_hardware_breakpoint:
3639 case bp_hardware_watchpoint:
3640 case bp_read_watchpoint:
3641 case bp_access_watchpoint:
3642 enable_breakpoint (bpt);
3647 map_breakpoint_numbers (args, enable_breakpoint);
3651 disable_breakpoint (bpt)
3652 struct breakpoint *bpt;
3654 /* Never disable a watchpoint scope breakpoint; we want to
3655 hit them when we leave scope so we can delete both the
3656 watchpoint and its scope breakpoint at that time. */
3657 if (bpt->type == bp_watchpoint_scope)
3660 if (disable_breakpoint_hook)
3661 disable_breakpoint_hook (bpt);
3663 bpt->enable = disabled;
3665 check_duplicates (bpt->address);
3670 disable_command (args, from_tty)
3674 register struct breakpoint *bpt;
3676 ALL_BREAKPOINTS (bpt)
3680 case bp_hardware_breakpoint:
3682 case bp_hardware_watchpoint:
3683 case bp_read_watchpoint:
3684 case bp_access_watchpoint:
3685 disable_breakpoint (bpt);
3690 map_breakpoint_numbers (args, disable_breakpoint);
3694 enable_once_breakpoint (bpt)
3695 struct breakpoint *bpt;
3697 struct frame_info *save_selected_frame = NULL;
3698 int save_selected_frame_level = -1;
3699 int target_resources_ok, other_type_used;
3702 if (bpt->type == bp_hardware_breakpoint)
3705 i = hw_breakpoint_used_count();
3706 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3707 bp_hardware_breakpoint, i+1, 0);
3708 if (target_resources_ok == 0)
3709 error ("No hardware breakpoint support in the target.");
3710 else if (target_resources_ok < 0)
3711 error ("Hardware breakpoints used exceeds limit.");
3714 bpt->enable = enabled;
3715 bpt->disposition = disable;
3716 check_duplicates (bpt->address);
3717 breakpoints_changed ();
3719 if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
3720 bpt->type == bp_read_watchpoint || bpt->type == bp_access_watchpoint)
3722 if (bpt->exp_valid_block != NULL)
3724 struct frame_info *fr =
3725 find_frame_addr_in_frame_chain (bpt->watchpoint_frame);
3729 Cannot enable watchpoint %d because the block in which its expression\n\
3730 is valid is not currently in scope.\n", bpt->number);
3731 bpt->enable = disabled;
3735 save_selected_frame = selected_frame;
3736 save_selected_frame_level = selected_frame_level;
3737 select_frame (fr, -1);
3740 value_free (bpt->val);
3741 mark = value_mark ();
3742 bpt->val = evaluate_expression (bpt->exp);
3743 release_value (bpt->val);
3744 if (VALUE_LAZY (bpt->val))
3745 value_fetch_lazy (bpt->val);
3747 if (bpt->type == bp_hardware_watchpoint ||
3748 bpt->type == bp_read_watchpoint ||
3749 bpt->type == bp_access_watchpoint)
3751 int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
3752 int mem_cnt = can_use_hardware_watchpoint(bpt->val);
3753 target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3754 bpt->type, i+mem_cnt, other_type_used);
3755 /* we can consider of type is bp_hardware_watchpoint, convert to
3756 bp_watchpoint in the following condition */
3757 if (target_resources_ok < 0)
3760 Cannot enable watchpoint %d because target watch resources\n\
3761 have been allocated for other watchpoints.\n", bpt->number);
3762 bpt->enable = disabled;
3763 value_free_to_mark (mark);
3767 if (save_selected_frame_level >= 0)
3768 select_frame (save_selected_frame, save_selected_frame_level);
3769 value_free_to_mark (mark);
3775 enable_once_command (args, from_tty)
3779 map_breakpoint_numbers (args, enable_once_breakpoint);
3783 enable_delete_breakpoint (bpt)
3784 struct breakpoint *bpt;
3786 bpt->enable = enabled;
3787 bpt->disposition = delete;
3789 check_duplicates (bpt->address);
3790 breakpoints_changed ();
3795 enable_delete_command (args, from_tty)
3799 map_breakpoint_numbers (args, enable_delete_breakpoint);
3802 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
3804 struct symtabs_and_lines
3805 decode_line_spec_1 (string, funfirstline)
3809 struct symtabs_and_lines sals;
3811 error ("Empty line specification.");
3812 if (default_breakpoint_valid)
3813 sals = decode_line_1 (&string, funfirstline,
3814 default_breakpoint_symtab, default_breakpoint_line,
3817 sals = decode_line_1 (&string, funfirstline,
3818 (struct symtab *)NULL, 0, (char ***)NULL);
3820 error ("Junk at end of line specification: %s", string);
3825 _initialize_breakpoint ()
3827 breakpoint_chain = 0;
3828 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3829 before a breakpoint is set. */
3830 breakpoint_count = 0;
3832 add_com ("ignore", class_breakpoint, ignore_command,
3833 "Set ignore-count of breakpoint number N to COUNT.\n\
3834 Usage is `ignore N COUNT'.");
3836 add_com ("commands", class_breakpoint, commands_command,
3837 "Set commands to be executed when a breakpoint is hit.\n\
3838 Give breakpoint number as argument after \"commands\".\n\
3839 With no argument, the targeted breakpoint is the last one set.\n\
3840 The commands themselves follow starting on the next line.\n\
3841 Type a line containing \"end\" to indicate the end of them.\n\
3842 Give \"silent\" as the first line to make the breakpoint silent;\n\
3843 then no output is printed when it is hit, except what the commands print.");
3845 add_com ("condition", class_breakpoint, condition_command,
3846 "Specify breakpoint number N to break only if COND is true.\n\
3847 Usage is `condition N COND', where N is an integer and COND is an\n\
3848 expression to be evaluated whenever breakpoint N is reached. ");
3850 add_com ("tbreak", class_breakpoint, tbreak_command,
3851 "Set a temporary breakpoint. Args like \"break\" command.\n\
3852 Like \"break\" except the breakpoint is only temporary,\n\
3853 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3854 by using \"enable delete\" on the breakpoint number.");
3856 add_com ("hbreak", class_breakpoint, hbreak_command,
3857 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3858 Like \"break\" except the breakpoint requires hardware support,\n\
3859 some target hardware may not have this support.");
3861 add_com ("thbreak", class_breakpoint, thbreak_command,
3862 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3863 Like \"hbreak\" except the breakpoint is only temporary,\n\
3864 so it will be deleted when hit.");
3866 add_prefix_cmd ("enable", class_breakpoint, enable_command,
3867 "Enable some breakpoints.\n\
3868 Give breakpoint numbers (separated by spaces) as arguments.\n\
3869 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3870 This is used to cancel the effect of the \"disable\" command.\n\
3871 With a subcommand you can enable temporarily.",
3872 &enablelist, "enable ", 1, &cmdlist);
3874 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
3875 "Enable some breakpoints.\n\
3876 Give breakpoint numbers (separated by spaces) as arguments.\n\
3877 This is used to cancel the effect of the \"disable\" command.\n\
3878 May be abbreviated to simply \"enable\".\n",
3879 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
3881 add_cmd ("once", no_class, enable_once_command,
3882 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3883 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3886 add_cmd ("delete", no_class, enable_delete_command,
3887 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3888 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3891 add_cmd ("delete", no_class, enable_delete_command,
3892 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3893 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3896 add_cmd ("once", no_class, enable_once_command,
3897 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3898 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3901 add_prefix_cmd ("disable", class_breakpoint, disable_command,
3902 "Disable some breakpoints.\n\
3903 Arguments are breakpoint numbers with spaces in between.\n\
3904 To disable all breakpoints, give no argument.\n\
3905 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3906 &disablelist, "disable ", 1, &cmdlist);
3907 add_com_alias ("dis", "disable", class_breakpoint, 1);
3908 add_com_alias ("disa", "disable", class_breakpoint, 1);
3910 add_cmd ("breakpoints", class_alias, disable_command,
3911 "Disable some breakpoints.\n\
3912 Arguments are breakpoint numbers with spaces in between.\n\
3913 To disable all breakpoints, give no argument.\n\
3914 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3915 This command may be abbreviated \"disable\".",
3918 add_prefix_cmd ("delete", class_breakpoint, delete_command,
3919 "Delete some breakpoints or auto-display expressions.\n\
3920 Arguments are breakpoint numbers with spaces in between.\n\
3921 To delete all breakpoints, give no argument.\n\
3923 Also a prefix command for deletion of other GDB objects.\n\
3924 The \"unset\" command is also an alias for \"delete\".",
3925 &deletelist, "delete ", 1, &cmdlist);
3926 add_com_alias ("d", "delete", class_breakpoint, 1);
3928 add_cmd ("breakpoints", class_alias, delete_command,
3929 "Delete some breakpoints or auto-display expressions.\n\
3930 Arguments are breakpoint numbers with spaces in between.\n\
3931 To delete all breakpoints, give no argument.\n\
3932 This command may be abbreviated \"delete\".",
3935 add_com ("clear", class_breakpoint, clear_command,
3936 concat ("Clear breakpoint at specified line or function.\n\
3937 Argument may be line number, function name, or \"*\" and an address.\n\
3938 If line number is specified, all breakpoints in that line are cleared.\n\
3939 If function is specified, breakpoints at beginning of function are cleared.\n\
3940 If an address is specified, breakpoints at that address are cleared.\n\n",
3941 "With no argument, clears all breakpoints in the line that the selected frame\n\
3944 See also the \"delete\" command which clears breakpoints by number.", NULL));
3946 add_com ("break", class_breakpoint, break_command,
3947 concat ("Set breakpoint at specified line or function.\n\
3948 Argument may be line number, function name, or \"*\" and an address.\n\
3949 If line number is specified, break at start of code for that line.\n\
3950 If function is specified, break at start of code for that function.\n\
3951 If an address is specified, break at that exact address.\n",
3952 "With no arg, uses current execution address of selected stack frame.\n\
3953 This is useful for breaking on return to a stack frame.\n\
3955 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
3957 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL));
3958 add_com_alias ("b", "break", class_run, 1);
3959 add_com_alias ("br", "break", class_run, 1);
3960 add_com_alias ("bre", "break", class_run, 1);
3961 add_com_alias ("brea", "break", class_run, 1);
3963 add_info ("breakpoints", breakpoints_info,
3964 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
3965 The \"Type\" column indicates one of:\n\
3966 \tbreakpoint - normal breakpoint\n\
3967 \twatchpoint - watchpoint\n\
3968 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3969 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3970 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3971 address and file/line number respectively.\n\n",
3972 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3973 are set to the address of the last breakpoint listed.\n\n\
3974 Convenience variable \"$bpnum\" contains the number of the last\n\
3975 breakpoint set.", NULL));
3977 #if MAINTENANCE_CMDS
3979 add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints,
3980 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
3981 The \"Type\" column indicates one of:\n\
3982 \tbreakpoint - normal breakpoint\n\
3983 \twatchpoint - watchpoint\n\
3984 \tlongjmp - internal breakpoint used to step through longjmp()\n\
3985 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
3986 \tuntil - internal breakpoint used by the \"until\" command\n\
3987 \tfinish - internal breakpoint used by the \"finish\" command\n",
3988 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
3989 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
3990 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
3991 address and file/line number respectively.\n\n",
3992 "Convenience variable \"$_\" and default examine address for \"x\"\n\
3993 are set to the address of the last breakpoint listed.\n\n\
3994 Convenience variable \"$bpnum\" contains the number of the last\n\
3995 breakpoint set.", NULL),
3996 &maintenanceinfolist);
3998 #endif /* MAINTENANCE_CMDS */
4000 add_com ("catch", class_breakpoint, catch_command,
4001 "Set breakpoints to catch exceptions that are raised.\n\
4002 Argument may be a single exception to catch, multiple exceptions\n\
4003 to catch, or the default exception \"default\". If no arguments\n\
4004 are given, breakpoints are set at all exception handlers catch clauses\n\
4005 within the current scope.\n\
4007 A condition specified for the catch applies to all breakpoints set\n\
4008 with this command\n\
4010 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
4012 add_com ("watch", class_breakpoint, watch_command,
4013 "Set a watchpoint for an expression.\n\
4014 A watchpoint stops execution of your program whenever the value of\n\
4015 an expression changes.");
4017 add_com ("rwatch", class_breakpoint, rwatch_command,
4018 "Set a read watchpoint for an expression.\n\
4019 A watchpoint stops execution of your program whenever the value of\n\
4020 an expression is read.");
4022 add_com ("awatch", class_breakpoint, awatch_command,
4023 "Set a watchpoint for an expression.\n\
4024 A watchpoint stops execution of your program whenever the value of\n\
4025 an expression is either read or written.");
4027 add_info ("watchpoints", breakpoints_info,
4028 "Synonym for ``info breakpoints''.");
4032 /* OK, when we call objfile_relocate, we need to relocate breakpoints
4033 too. breakpoint_re_set is not a good choice--for example, if
4034 addr_string contains just a line number without a file name the
4035 breakpoint might get set in a different file. In general, there is
4036 no need to go all the way back to the user's string (though this might
4037 work if some effort were made to canonicalize it), since symtabs and
4038 everything except addresses are still valid.
4040 Probably the best way to solve this is to have each breakpoint save
4041 the objfile and the section number that was used to set it (if set
4042 by "*addr", probably it is best to use find_pc_line to get a symtab
4043 and use the objfile and block_line_section for that symtab). Then
4044 objfile_relocate can call fixup_breakpoints with the objfile and
4045 the new_offsets, and it can relocate only the appropriate breakpoints. */
4047 #ifdef IBM6000_TARGET
4048 /* But for now, just kludge it based on the concept that before an
4049 objfile is relocated the breakpoint is below 0x10000000, and afterwards
4050 it is higher, so that way we only relocate each breakpoint once. */
4053 fixup_breakpoints (low, high, delta)
4058 struct breakpoint *b;
4062 if (b->address >= low && b->address <= high)
4063 b->address += delta;