1 /* Everything about breakpoints, for GDB.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "breakpoint.h"
27 #include "expression.h"
33 #include "gdbthread.h"
36 #include "gdb_string.h"
40 /* local function prototypes */
43 catch_command_1
PARAMS ((char *, int, int));
46 enable_delete_command
PARAMS ((char *, int));
49 enable_delete_breakpoint
PARAMS ((struct breakpoint
*));
52 enable_once_command
PARAMS ((char *, int));
55 enable_once_breakpoint
PARAMS ((struct breakpoint
*));
58 disable_command
PARAMS ((char *, int));
61 enable_command
PARAMS ((char *, int));
64 map_breakpoint_numbers
PARAMS ((char *, void (*)(struct breakpoint
*)));
67 ignore_command
PARAMS ((char *, int));
70 breakpoint_re_set_one
PARAMS ((char *));
73 delete_command
PARAMS ((char *, int));
76 clear_command
PARAMS ((char *, int));
79 catch_command
PARAMS ((char *, int));
81 static struct symtabs_and_lines
82 get_catch_sals
PARAMS ((int));
85 watch_command
PARAMS ((char *, int));
88 can_use_hardware_watchpoint
PARAMS ((struct value
*));
91 tbreak_command
PARAMS ((char *, int));
94 break_command_1
PARAMS ((char *, int, int));
97 mention
PARAMS ((struct breakpoint
*));
99 static struct breakpoint
*
100 set_raw_breakpoint
PARAMS ((struct symtab_and_line
));
103 check_duplicates
PARAMS ((CORE_ADDR
));
106 describe_other_breakpoints
PARAMS ((CORE_ADDR
));
109 breakpoints_info
PARAMS ((char *, int));
112 breakpoint_1
PARAMS ((int, int));
115 bpstat_alloc
PARAMS ((struct breakpoint
*, bpstat
));
118 breakpoint_cond_eval
PARAMS ((char *));
121 cleanup_executing_breakpoints
PARAMS ((PTR
));
124 commands_command
PARAMS ((char *, int));
127 condition_command
PARAMS ((char *, int));
130 get_number
PARAMS ((char **));
133 set_breakpoint_count
PARAMS ((int));
136 remove_breakpoint
PARAMS ((struct breakpoint
*));
139 print_it_normal
PARAMS ((bpstat
));
142 watchpoint_check
PARAMS ((char *));
145 print_it_done
PARAMS ((bpstat
));
148 print_it_noop
PARAMS ((bpstat
));
151 maintenance_info_breakpoints
PARAMS ((char *, int));
153 #ifdef GET_LONGJMP_TARGET
155 create_longjmp_breakpoint
PARAMS ((char *));
159 hw_breakpoint_used_count
PARAMS ((void));
162 hw_watchpoint_used_count
PARAMS ((enum bptype
, int *));
165 hbreak_command
PARAMS ((char *, int));
168 thbreak_command
PARAMS ((char *, int));
171 watch_command_1
PARAMS ((char *, int, int));
174 rwatch_command
PARAMS ((char *, int));
177 awatch_command
PARAMS ((char *, int));
180 do_enable_breakpoint
PARAMS ((struct breakpoint
*, enum bpdisp
));
182 extern int addressprint
; /* Print machine addresses? */
184 /* Are we executing breakpoint commands? */
185 static int executing_breakpoint_commands
;
187 /* Walk the following statement or block through all breakpoints.
188 ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
191 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
193 #define ALL_BREAKPOINTS_SAFE(b,tmp) \
194 for (b = breakpoint_chain; \
195 b? (tmp=b->next, 1): 0; \
198 /* True if breakpoint hit counts should be displayed in breakpoint info. */
200 int show_breakpoint_hit_counts
= 1;
202 /* Chain of all breakpoints defined. */
204 struct breakpoint
*breakpoint_chain
;
206 /* Number of last breakpoint made. */
208 static int breakpoint_count
;
210 /* Set breakpoint count to NUM. */
213 set_breakpoint_count (num
)
216 breakpoint_count
= num
;
217 set_internalvar (lookup_internalvar ("bpnum"),
218 value_from_longest (builtin_type_int
, (LONGEST
) num
));
221 /* Used in run_command to zero the hit count when a new run starts. */
224 clear_breakpoint_hit_counts ()
226 struct breakpoint
*b
;
232 /* Default address, symtab and line to put a breakpoint at
233 for "break" command with no arg.
234 if default_breakpoint_valid is zero, the other three are
235 not valid, and "break" with no arg is an error.
237 This set by print_stack_frame, which calls set_default_breakpoint. */
239 int default_breakpoint_valid
;
240 CORE_ADDR default_breakpoint_address
;
241 struct symtab
*default_breakpoint_symtab
;
242 int default_breakpoint_line
;
244 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
245 Advance *PP after the string and any trailing whitespace.
247 Currently the string can either be a number or "$" followed by the name
248 of a convenience variable. Making it an expression wouldn't work well
249 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
258 /* Empty line means refer to the last breakpoint. */
259 return breakpoint_count
;
262 /* Make a copy of the name, so we can null-terminate it
263 to pass to lookup_internalvar(). */
268 while (isalnum (*p
) || *p
== '_')
270 varname
= (char *) alloca (p
- start
+ 1);
271 strncpy (varname
, start
, p
- start
);
272 varname
[p
- start
] = '\0';
273 val
= value_of_internalvar (lookup_internalvar (varname
));
274 if (TYPE_CODE (VALUE_TYPE (val
)) != TYPE_CODE_INT
)
276 "Convenience variables used to specify breakpoints must have integer values."
278 retval
= (int) value_as_long (val
);
284 while (*p
>= '0' && *p
<= '9')
287 /* There is no number here. (e.g. "cond a == b"). */
288 error_no_arg ("breakpoint number");
291 if (!(isspace (*p
) || *p
== '\0'))
292 error ("breakpoint number expected");
299 /* condition N EXP -- set break condition of breakpoint N to EXP. */
302 condition_command (arg
, from_tty
)
306 register struct breakpoint
*b
;
311 error_no_arg ("breakpoint number");
314 bnum
= get_number (&p
);
317 if (b
->number
== bnum
)
324 if (b
->cond_string
!= NULL
)
325 free ((PTR
)b
->cond_string
);
330 b
->cond_string
= NULL
;
332 printf_filtered ("Breakpoint %d now unconditional.\n", bnum
);
337 /* I don't know if it matters whether this is the string the user
338 typed in or the decompiled expression. */
339 b
->cond_string
= savestring (arg
, strlen (arg
));
340 b
->cond
= parse_exp_1 (&arg
, block_for_pc (b
->address
), 0);
342 error ("Junk at end of expression");
344 breakpoints_changed ();
348 error ("No breakpoint number %d.", bnum
);
353 commands_command (arg
, from_tty
)
357 register struct breakpoint
*b
;
360 struct command_line
*l
;
362 /* If we allowed this, we would have problems with when to
363 free the storage, if we change the commands currently
366 if (executing_breakpoint_commands
)
367 error ("Can't use the \"commands\" command among a breakpoint's commands.");
370 bnum
= get_number (&p
);
372 error ("Unexpected extra arguments following breakpoint number.");
375 if (b
->number
== bnum
)
378 sprintf (tmpbuf
, "Type commands for when breakpoint %d is hit, one per line.", bnum
);
379 l
= read_command_lines (tmpbuf
, from_tty
);
380 free_command_lines (&b
->commands
);
382 breakpoints_changed ();
385 error ("No breakpoint number %d.", bnum
);
388 extern int memory_breakpoint_size
; /* from mem-break.c */
390 /* Like target_read_memory() but if breakpoints are inserted, return
391 the shadow contents instead of the breakpoints themselves.
393 Read "memory data" from whatever target or inferior we have.
394 Returns zero if successful, errno value if not. EIO is used
395 for address out of bounds. If breakpoints are inserted, returns
396 shadow contents, not the breakpoints themselves. From breakpoint.c. */
399 read_memory_nobpt (memaddr
, myaddr
, len
)
405 struct breakpoint
*b
;
407 if (memory_breakpoint_size
< 0)
408 /* No breakpoints on this machine. FIXME: This should be
409 dependent on the debugging target. Probably want
410 target_insert_breakpoint to return a size, saying how many
411 bytes of the shadow contents are used, or perhaps have
412 something like target_xfer_shadow. */
413 return target_read_memory (memaddr
, myaddr
, len
);
417 if (b
->type
== bp_watchpoint
418 || b
->type
== bp_hardware_watchpoint
419 || b
->type
== bp_read_watchpoint
420 || b
->type
== bp_access_watchpoint
423 else if (b
->address
+ memory_breakpoint_size
<= memaddr
)
424 /* The breakpoint is entirely before the chunk of memory
427 else if (b
->address
>= memaddr
+ len
)
428 /* The breakpoint is entirely after the chunk of memory we
433 /* Copy the breakpoint from the shadow contents, and recurse
434 for the things before and after. */
436 /* Addresses and length of the part of the breakpoint that
438 CORE_ADDR membpt
= b
->address
;
439 unsigned int bptlen
= memory_breakpoint_size
;
440 /* Offset within shadow_contents. */
443 if (membpt
< memaddr
)
445 /* Only copy the second part of the breakpoint. */
446 bptlen
-= memaddr
- membpt
;
447 bptoffset
= memaddr
- membpt
;
451 if (membpt
+ bptlen
> memaddr
+ len
)
453 /* Only copy the first part of the breakpoint. */
454 bptlen
-= (membpt
+ bptlen
) - (memaddr
+ len
);
457 memcpy (myaddr
+ membpt
- memaddr
,
458 b
->shadow_contents
+ bptoffset
, bptlen
);
460 if (membpt
> memaddr
)
462 /* Copy the section of memory before the breakpoint. */
463 status
= read_memory_nobpt (memaddr
, myaddr
, membpt
- memaddr
);
468 if (membpt
+ bptlen
< memaddr
+ len
)
470 /* Copy the section of memory after the breakpoint. */
471 status
= read_memory_nobpt
473 myaddr
+ membpt
+ bptlen
- memaddr
,
474 memaddr
+ len
- (membpt
+ bptlen
));
481 /* Nothing overlaps. Just call read_memory_noerr. */
482 return target_read_memory (memaddr
, myaddr
, len
);
485 /* insert_breakpoints is used when starting or continuing the program.
486 remove_breakpoints is used when the program stops.
487 Both return zero if successful,
488 or an `errno' value if could not write the inferior. */
491 insert_breakpoints ()
493 register struct breakpoint
*b
, *temp
;
495 int disabled_breaks
= 0;
497 ALL_BREAKPOINTS_SAFE (b
, temp
)
498 if (b
->type
!= bp_watchpoint
499 && b
->type
!= bp_hardware_watchpoint
500 && b
->type
!= bp_read_watchpoint
501 && b
->type
!= bp_access_watchpoint
502 && b
->enable
!= disabled
503 && b
->enable
!= shlib_disabled
507 if (b
->type
== bp_hardware_breakpoint
)
508 val
= target_insert_hw_breakpoint(b
->address
, b
->shadow_contents
);
510 val
= target_insert_breakpoint(b
->address
, b
->shadow_contents
);
513 /* Can't set the breakpoint. */
514 #if defined (DISABLE_UNSETTABLE_BREAK)
515 if (DISABLE_UNSETTABLE_BREAK (b
->address
))
518 b
->enable
= shlib_disabled
;
519 if (!disabled_breaks
)
521 target_terminal_ours_for_output ();
522 fprintf_unfiltered (gdb_stderr
,
523 "Cannot insert breakpoint %d:\n", b
->number
);
524 printf_filtered ("Temporarily disabling shared library breakpoints:\n");
527 printf_filtered ("%d ", b
->number
);
532 target_terminal_ours_for_output ();
533 fprintf_unfiltered (gdb_stderr
, "Cannot insert breakpoint %d:\n", b
->number
);
534 #ifdef ONE_PROCESS_WRITETEXT
535 fprintf_unfiltered (gdb_stderr
,
536 "The same program may be running in another process.\n");
538 memory_error (val
, b
->address
); /* which bombs us out */
544 else if ((b
->type
== bp_hardware_watchpoint
||
545 b
->type
== bp_read_watchpoint
||
546 b
->type
== bp_access_watchpoint
)
547 && b
->enable
== enabled
551 struct frame_info
*saved_frame
;
552 int saved_level
, within_current_scope
;
553 value_ptr mark
= value_mark ();
556 /* Save the current frame and level so we can restore it after
557 evaluating the watchpoint expression on its own frame. */
558 saved_frame
= selected_frame
;
559 saved_level
= selected_frame_level
;
561 /* Determine if the watchpoint is within scope. */
562 if (b
->exp_valid_block
== NULL
)
563 within_current_scope
= 1;
566 struct frame_info
*fi
=
567 find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
568 within_current_scope
= (fi
!= NULL
);
569 if (within_current_scope
)
570 select_frame (fi
, -1);
573 if (within_current_scope
)
575 /* Evaluate the expression and cut the chain of values
576 produced off from the value chain. */
577 v
= evaluate_expression (b
->exp
);
578 value_release_to_mark (mark
);
583 /* Look at each value on the value chain. */
584 for ( ; v
; v
=v
->next
)
586 /* If it's a memory location, then we must watch it. */
587 if (v
->lval
== lval_memory
)
591 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
592 len
= TYPE_LENGTH (VALUE_TYPE (v
));
594 if (b
->type
== bp_read_watchpoint
)
596 else if (b
->type
== bp_access_watchpoint
)
599 val
= target_insert_watchpoint (addr
, len
, type
);
608 /* Failure to insert a watchpoint on any memory value in the
609 value chain brings us here. */
611 warning ("Hardware watchpoint %d: Could not insert watchpoint\n",
617 Hardware watchpoint %d deleted because the program has left the block in\n\
618 which its expression is valid.\n", b
->number
);
619 if (b
->related_breakpoint
)
621 b
->related_breakpoint
->enable
= disable
;
622 b
->related_breakpoint
->disposition
= del_at_next_stop
;
625 b
->disposition
= del_at_next_stop
;
628 /* Restore the frame and level. */
629 select_frame (saved_frame
, saved_level
);
632 printf_filtered ("\n");
638 remove_breakpoints ()
640 register struct breakpoint
*b
;
647 val
= remove_breakpoint (b
);
657 remove_breakpoint (b
)
658 struct breakpoint
*b
;
662 if (b
->type
!= bp_watchpoint
663 && b
->type
!= bp_hardware_watchpoint
664 && b
->type
!= bp_read_watchpoint
665 && b
->type
!= bp_access_watchpoint
)
667 if (b
->type
== bp_hardware_breakpoint
)
668 val
= target_remove_hw_breakpoint(b
->address
, b
->shadow_contents
);
670 val
= target_remove_breakpoint(b
->address
, b
->shadow_contents
);
675 else if ((b
->type
== bp_hardware_watchpoint
||
676 b
->type
== bp_read_watchpoint
||
677 b
->type
== bp_access_watchpoint
)
678 && b
->enable
== enabled
684 /* Walk down the saved value chain. */
685 for (v
= b
->val_chain
; v
; v
= v
->next
)
687 /* For each memory reference remove the watchpoint
689 if (v
->lval
== lval_memory
)
693 addr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
694 len
= TYPE_LENGTH (VALUE_TYPE (v
));
695 val
= target_remove_watchpoint (addr
, len
, b
->type
);
701 /* Failure to remove any of the hardware watchpoints comes here. */
703 warning ("Hardware watchpoint %d: Could not remove watchpoint\n",
706 /* Free the saved value chain. We will construct a new one
707 the next time the watchpoint is inserted. */
708 for (v
= b
->val_chain
; v
; v
= n
)
718 /* Clear the "inserted" flag in all breakpoints. */
721 mark_breakpoints_out ()
723 register struct breakpoint
*b
;
729 /* Clear the "inserted" flag in all breakpoints and delete any breakpoints
730 which should go away between runs of the program. */
733 breakpoint_init_inferior ()
735 register struct breakpoint
*b
, *temp
;
737 ALL_BREAKPOINTS_SAFE (b
, temp
)
744 case bp_watchpoint_scope
:
746 /* If the call dummy breakpoint is at the entry point it will
747 cause problems when the inferior is rerun, so we better
750 Also get rid of scope breakpoints. */
751 delete_breakpoint (b
);
755 case bp_hardware_watchpoint
:
756 case bp_read_watchpoint
:
757 case bp_access_watchpoint
:
759 /* Likewise for watchpoints on local expressions. */
760 if (b
->exp_valid_block
!= NULL
)
761 delete_breakpoint (b
);
770 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
771 When continuing from a location with a breakpoint,
772 we actually single step once before calling insert_breakpoints. */
775 breakpoint_here_p (pc
)
778 register struct breakpoint
*b
;
781 if (b
->enable
!= disabled
782 && b
->enable
!= shlib_disabled
789 /* Return nonzero if FRAME is a dummy frame. We can't use PC_IN_CALL_DUMMY
790 because figuring out the saved SP would take too much time, at least using
791 get_saved_register on the 68k. This means that for this function to
792 work right a port must use the bp_call_dummy breakpoint. */
795 frame_in_dummy (frame
)
796 struct frame_info
*frame
;
798 struct breakpoint
*b
;
803 static unsigned LONGEST dummy
[] = CALL_DUMMY
;
805 if (b
->type
== bp_call_dummy
806 && b
->frame
== frame
->frame
808 /* We need to check the PC as well as the frame on the sparc,
809 for signals.exp in the testsuite. */
812 - sizeof (dummy
) / sizeof (LONGEST
) * REGISTER_SIZE
))
813 && frame
->pc
<= b
->address
)
816 #endif /* CALL_DUMMY */
820 /* breakpoint_match_thread (PC, PID) returns true if the breakpoint at PC
821 is valid for process/thread PID. */
824 breakpoint_thread_match (pc
, pid
)
828 struct breakpoint
*b
;
831 thread
= pid_to_thread_id (pid
);
834 if (b
->enable
!= disabled
835 && b
->enable
!= shlib_disabled
837 && (b
->thread
== -1 || b
->thread
== thread
))
844 /* bpstat stuff. External routines' interfaces are documented
847 /* Clear a bpstat so that it says we are not at any breakpoint.
848 Also free any storage that is part of a bpstat. */
863 if (p
->old_val
!= NULL
)
864 value_free (p
->old_val
);
871 /* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that
872 is part of the bpstat is copied as well. */
880 bpstat retval
= NULL
;
885 for (; bs
!= NULL
; bs
= bs
->next
)
887 tmp
= (bpstat
) xmalloc (sizeof (*tmp
));
888 memcpy (tmp
, bs
, sizeof (*tmp
));
890 /* This is the first thing in the chain. */
900 /* Find the bpstat associated with this breakpoint */
903 bpstat_find_breakpoint(bsp
, breakpoint
)
905 struct breakpoint
*breakpoint
;
907 if (bsp
== NULL
) return NULL
;
909 for (;bsp
!= NULL
; bsp
= bsp
->next
) {
910 if (bsp
->breakpoint_at
== breakpoint
) return bsp
;
915 /* Return the breakpoint number of the first breakpoint we are stopped
916 at. *BSP upon return is a bpstat which points to the remaining
917 breakpoints stopped at (but which is not guaranteed to be good for
918 anything but further calls to bpstat_num).
919 Return 0 if passed a bpstat which does not indicate any breakpoints. */
925 struct breakpoint
*b
;
928 return 0; /* No more breakpoint values */
931 b
= (*bsp
)->breakpoint_at
;
934 return -1; /* breakpoint that's been deleted since */
936 return b
->number
; /* We have its number */
940 /* Modify BS so that the actions will not be performed. */
943 bpstat_clear_actions (bs
)
946 for (; bs
!= NULL
; bs
= bs
->next
)
949 if (bs
->old_val
!= NULL
)
951 value_free (bs
->old_val
);
957 /* Stub for cleaning up our state if we error-out of a breakpoint command */
960 cleanup_executing_breakpoints (ignore
)
963 executing_breakpoint_commands
= 0;
966 /* Execute all the commands associated with all the breakpoints at this
967 location. Any of these commands could cause the process to proceed
968 beyond this point, etc. We look out for such changes by checking
969 the global "breakpoint_proceeded" after each command. */
972 bpstat_do_actions (bsp
)
976 struct cleanup
*old_chain
;
977 struct command_line
*cmd
;
979 /* Avoid endless recursion if a `source' command is contained
981 if (executing_breakpoint_commands
)
984 executing_breakpoint_commands
= 1;
985 old_chain
= make_cleanup (cleanup_executing_breakpoints
, 0);
990 breakpoint_proceeded
= 0;
991 for (; bs
!= NULL
; bs
= bs
->next
)
996 execute_control_command (cmd
);
999 if (breakpoint_proceeded
)
1000 /* The inferior is proceeded by the command; bomb out now.
1001 The bpstat chain has been blown away by wait_for_inferior.
1002 But since execution has stopped again, there is a new bpstat
1003 to look at, so start over. */
1006 bs
->commands
= NULL
;
1009 executing_breakpoint_commands
= 0;
1010 discard_cleanups (old_chain
);
1013 /* This is the normal print_it function for a bpstat. In the future,
1014 much of this logic could (should?) be moved to bpstat_stop_status,
1015 by having it set different print_it functions. */
1018 print_it_normal (bs
)
1021 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
1022 which has since been deleted. */
1023 if (bs
->breakpoint_at
== NULL
1024 || (bs
->breakpoint_at
->type
!= bp_breakpoint
1025 && bs
->breakpoint_at
->type
!= bp_hardware_breakpoint
1026 && bs
->breakpoint_at
->type
!= bp_watchpoint
1027 && bs
->breakpoint_at
->type
!= bp_read_watchpoint
1028 && bs
->breakpoint_at
->type
!= bp_access_watchpoint
1029 && bs
->breakpoint_at
->type
!= bp_hardware_watchpoint
))
1032 if (bs
->breakpoint_at
->type
== bp_breakpoint
||
1033 bs
->breakpoint_at
->type
== bp_hardware_breakpoint
)
1035 /* I think the user probably only wants to see one breakpoint
1036 number, not all of them. */
1037 annotate_breakpoint (bs
->breakpoint_at
->number
);
1038 printf_filtered ("\nBreakpoint %d, ", bs
->breakpoint_at
->number
);
1041 else if ((bs
->old_val
!= NULL
) &&
1042 (bs
->breakpoint_at
->type
== bp_watchpoint
||
1043 bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1044 bs
->breakpoint_at
->type
== bp_hardware_watchpoint
))
1046 annotate_watchpoint (bs
->breakpoint_at
->number
);
1047 mention (bs
->breakpoint_at
);
1048 printf_filtered ("\nOld value = ");
1049 value_print (bs
->old_val
, gdb_stdout
, 0, Val_pretty_default
);
1050 printf_filtered ("\nNew value = ");
1051 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1052 Val_pretty_default
);
1053 printf_filtered ("\n");
1054 value_free (bs
->old_val
);
1056 /* More than one watchpoint may have been triggered. */
1059 else if (bs
->breakpoint_at
->type
== bp_access_watchpoint
||
1060 bs
->breakpoint_at
->type
== bp_read_watchpoint
)
1062 mention (bs
->breakpoint_at
);
1063 printf_filtered ("\nValue = ");
1064 value_print (bs
->breakpoint_at
->val
, gdb_stdout
, 0,
1065 Val_pretty_default
);
1066 printf_filtered ("\n");
1069 /* We can't deal with it. Maybe another member of the bpstat chain can. */
1073 /* Print a message indicating what happened. Returns nonzero to
1074 say that only the source line should be printed after this (zero
1075 return means print the frame as well as the source line). */
1076 /* Currently we always return zero. */
1086 val
= (*bs
->print_it
) (bs
);
1090 /* Maybe another breakpoint in the chain caused us to stop.
1091 (Currently all watchpoints go on the bpstat whether hit or
1092 not. That probably could (should) be changed, provided care is taken
1093 with respect to bpstat_explains_signal). */
1095 return bpstat_print (bs
->next
);
1097 /* We reached the end of the chain without printing anything. */
1101 /* Evaluate the expression EXP and return 1 if value is zero.
1102 This is used inside a catch_errors to evaluate the breakpoint condition.
1103 The argument is a "struct expression *" that has been cast to char * to
1104 make it pass through catch_errors. */
1107 breakpoint_cond_eval (exp
)
1110 value_ptr mark
= value_mark ();
1111 int i
= !value_true (evaluate_expression ((struct expression
*)exp
));
1112 value_free_to_mark (mark
);
1116 /* Allocate a new bpstat and chain it to the current one. */
1119 bpstat_alloc (b
, cbs
)
1120 register struct breakpoint
*b
;
1121 bpstat cbs
; /* Current "bs" value */
1125 bs
= (bpstat
) xmalloc (sizeof (*bs
));
1127 bs
->breakpoint_at
= b
;
1128 /* If the condition is false, etc., don't do the commands. */
1129 bs
->commands
= NULL
;
1131 bs
->print_it
= print_it_normal
;
1135 /* Possible return values for watchpoint_check (this can't be an enum
1136 because of check_errors). */
1137 /* The watchpoint has been deleted. */
1138 #define WP_DELETED 1
1139 /* The value has changed. */
1140 #define WP_VALUE_CHANGED 2
1141 /* The value has not changed. */
1142 #define WP_VALUE_NOT_CHANGED 3
1144 #define BP_TEMPFLAG 1
1145 #define BP_HARDWAREFLAG 2
1147 /* Check watchpoint condition. */
1150 watchpoint_check (p
)
1153 bpstat bs
= (bpstat
) p
;
1154 struct breakpoint
*b
;
1155 struct frame_info
*fr
;
1156 int within_current_scope
;
1158 b
= bs
->breakpoint_at
;
1160 if (b
->exp_valid_block
== NULL
)
1161 within_current_scope
= 1;
1164 /* There is no current frame at this moment. If we're going to have
1165 any chance of handling watchpoints on local variables, we'll need
1166 the frame chain (so we can determine if we're in scope). */
1167 reinit_frame_cache();
1168 fr
= find_frame_addr_in_frame_chain (b
->watchpoint_frame
);
1169 within_current_scope
= (fr
!= NULL
);
1170 if (within_current_scope
)
1171 /* If we end up stopping, the current frame will get selected
1172 in normal_stop. So this call to select_frame won't affect
1174 select_frame (fr
, -1);
1177 if (within_current_scope
)
1179 /* We use value_{,free_to_}mark because it could be a
1180 *long* time before we return to the command level and
1181 call free_all_values. We can't call free_all_values because
1182 we might be in the middle of evaluating a function call. */
1184 value_ptr mark
= value_mark ();
1185 value_ptr new_val
= evaluate_expression (bs
->breakpoint_at
->exp
);
1186 if (!value_equal (b
->val
, new_val
))
1188 release_value (new_val
);
1189 value_free_to_mark (mark
);
1190 bs
->old_val
= b
->val
;
1192 /* We will stop here */
1193 return WP_VALUE_CHANGED
;
1197 /* Nothing changed, don't do anything. */
1198 value_free_to_mark (mark
);
1199 /* We won't stop here */
1200 return WP_VALUE_NOT_CHANGED
;
1205 /* This seems like the only logical thing to do because
1206 if we temporarily ignored the watchpoint, then when
1207 we reenter the block in which it is valid it contains
1208 garbage (in the case of a function, it may have two
1209 garbage values, one before and one after the prologue).
1210 So we can't even detect the first assignment to it and
1211 watch after that (since the garbage may or may not equal
1212 the first value assigned). */
1214 Watchpoint %d deleted because the program has left the block in\n\
1215 which its expression is valid.\n", bs
->breakpoint_at
->number
);
1216 if (b
->related_breakpoint
)
1218 b
->related_breakpoint
->enable
= disable
;
1219 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1221 b
->enable
= disable
;
1222 b
->disposition
= del_at_next_stop
;
1228 /* This is used when everything which needs to be printed has
1229 already been printed. But we still want to print the frame. */
1237 /* This is used when nothing should be printed for this bpstat entry. */
1246 /* Get a bpstat associated with having just stopped at address *PC
1247 and frame address CORE_ADDRESS. Update *PC to point at the
1248 breakpoint (if we hit a breakpoint). NOT_A_BREAKPOINT is nonzero
1249 if this is known to not be a real breakpoint (it could still be a
1250 watchpoint, though). */
1252 /* Determine whether we stopped at a breakpoint, etc, or whether we
1253 don't understand this stop. Result is a chain of bpstat's such that:
1255 if we don't understand the stop, the result is a null pointer.
1257 if we understand why we stopped, the result is not null.
1259 Each element of the chain refers to a particular breakpoint or
1260 watchpoint at which we have stopped. (We may have stopped for
1261 several reasons concurrently.)
1263 Each element of the chain has valid next, breakpoint_at,
1264 commands, FIXME??? fields.
1269 bpstat_stop_status (pc
, not_a_breakpoint
)
1271 int not_a_breakpoint
;
1273 register struct breakpoint
*b
, *temp
;
1275 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1276 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
1277 int real_breakpoint
= 0;
1279 /* Root of the chain of bpstat's */
1280 struct bpstats root_bs
[1];
1281 /* Pointer to the last thing in the chain currently. */
1282 bpstat bs
= root_bs
;
1283 static char message1
[] =
1284 "Error evaluating expression for watchpoint %d\n";
1285 char message
[sizeof (message1
) + 30 /* slop */];
1287 /* Get the address where the breakpoint would have been. */
1288 bp_addr
= *pc
- DECR_PC_AFTER_BREAK
;
1290 ALL_BREAKPOINTS_SAFE (b
, temp
)
1292 if (b
->enable
== disabled
1293 || b
->enable
== shlib_disabled
)
1296 if (b
->type
!= bp_watchpoint
1297 && b
->type
!= bp_hardware_watchpoint
1298 && b
->type
!= bp_read_watchpoint
1299 && b
->type
!= bp_access_watchpoint
1300 && b
->type
!= bp_hardware_breakpoint
1301 && b
->address
!= bp_addr
)
1304 if (b
->type
== bp_hardware_breakpoint
1305 && b
->address
!= (bp_addr
- DECR_PC_AFTER_HW_BREAK
))
1308 if (b
->type
!= bp_watchpoint
1309 && b
->type
!= bp_hardware_watchpoint
1310 && b
->type
!= bp_read_watchpoint
1311 && b
->type
!= bp_access_watchpoint
1312 && not_a_breakpoint
)
1315 /* Come here if it's a watchpoint, or if the break address matches */
1319 bs
= bpstat_alloc (b
, bs
); /* Alloc a bpstat to explain stop */
1324 sprintf (message
, message1
, b
->number
);
1325 if (b
->type
== bp_watchpoint
|| b
->type
== bp_hardware_watchpoint
)
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
:
1338 case WP_VALUE_NOT_CHANGED
:
1340 bs
->print_it
= print_it_noop
;
1347 /* Error from catch_errors. */
1348 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
1349 if (b
->related_breakpoint
)
1351 b
->related_breakpoint
->enable
= disable
;
1352 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1354 b
->enable
= disable
;
1355 b
->disposition
= del_at_next_stop
;
1356 /* We've already printed what needs to be printed. */
1357 bs
->print_it
= print_it_done
;
1363 else if (b
->type
== bp_read_watchpoint
|| b
->type
== bp_access_watchpoint
)
1369 addr
= target_stopped_data_address();
1370 if (addr
== 0) continue;
1371 for (v
= b
->val_chain
; v
; v
= v
->next
)
1373 if (v
->lval
== lval_memory
)
1377 vaddr
= VALUE_ADDRESS (v
) + VALUE_OFFSET (v
);
1383 switch (catch_errors (watchpoint_check
, (char *) bs
, message
,
1387 /* We've already printed what needs to be printed. */
1388 bs
->print_it
= print_it_done
;
1391 case WP_VALUE_CHANGED
:
1392 case WP_VALUE_NOT_CHANGED
:
1398 /* Error from catch_errors. */
1399 printf_filtered ("Watchpoint %d deleted.\n", b
->number
);
1400 if (b
->related_breakpoint
)
1402 b
->related_breakpoint
->enable
= disable
;
1403 b
->related_breakpoint
->disposition
= del_at_next_stop
;
1405 b
->enable
= disable
;
1406 b
->disposition
= del_at_next_stop
;
1407 /* We've already printed what needs to be printed. */
1408 bs
->print_it
= print_it_done
;
1412 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1414 real_breakpoint
= 1;
1417 if (b
->frame
&& b
->frame
!= (get_current_frame ())->frame
)
1421 int value_is_zero
= 0;
1425 /* Need to select the frame, with all that implies
1426 so that the conditions will have the right context. */
1427 select_frame (get_current_frame (), 0);
1429 = catch_errors (breakpoint_cond_eval
, (char *)(b
->cond
),
1430 "Error in testing breakpoint condition:\n",
1432 /* FIXME-someday, should give breakpoint # */
1435 if (b
->cond
&& value_is_zero
)
1439 else if (b
->ignore_count
> 0)
1446 /* We will stop here */
1447 if (b
->disposition
== disable
)
1448 b
->enable
= disabled
;
1449 bs
->commands
= b
->commands
;
1452 if (bs
->commands
&& STREQ ("silent", bs
->commands
->line
))
1454 bs
->commands
= bs
->commands
->next
;
1459 /* Print nothing for this entry if we dont stop or if we dont print. */
1460 if (bs
->stop
== 0 || bs
->print
== 0)
1461 bs
->print_it
= print_it_noop
;
1464 bs
->next
= NULL
; /* Terminate the chain */
1465 bs
= root_bs
->next
; /* Re-grab the head of the chain */
1466 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
1469 if (real_breakpoint
)
1472 #if defined (SHIFT_INST_REGS)
1474 #else /* No SHIFT_INST_REGS. */
1476 #endif /* No SHIFT_INST_REGS. */
1479 #endif /* DECR_PC_AFTER_BREAK != 0. */
1481 /* The value of a hardware watchpoint hasn't changed, but the
1482 intermediate memory locations we are watching may have. */
1483 if (bs
&& ! bs
->stop
&&
1484 (bs
->breakpoint_at
->type
== bp_hardware_watchpoint
||
1485 bs
->breakpoint_at
->type
== bp_read_watchpoint
||
1486 bs
->breakpoint_at
->type
== bp_access_watchpoint
))
1488 remove_breakpoints ();
1489 insert_breakpoints ();
1494 /* Tell what to do about this bpstat. */
1499 /* Classify each bpstat as one of the following. */
1501 /* This bpstat element has no effect on the main_action. */
1504 /* There was a watchpoint, stop but don't print. */
1507 /* There was a watchpoint, stop and print. */
1510 /* There was a breakpoint but we're not stopping. */
1513 /* There was a breakpoint, stop but don't print. */
1516 /* There was a breakpoint, stop and print. */
1519 /* We hit the longjmp breakpoint. */
1522 /* We hit the longjmp_resume breakpoint. */
1525 /* We hit the step_resume breakpoint. */
1528 /* We hit the through_sigtramp breakpoint. */
1531 /* We hit the shared library event breakpoint. */
1534 /* This is just used to count how many enums there are. */
1538 /* Here is the table which drives this routine. So that we can
1539 format it pretty, we define some abbreviations for the
1540 enum bpstat_what codes. */
1541 #define kc BPSTAT_WHAT_KEEP_CHECKING
1542 #define ss BPSTAT_WHAT_STOP_SILENT
1543 #define sn BPSTAT_WHAT_STOP_NOISY
1544 #define sgl BPSTAT_WHAT_SINGLE
1545 #define slr BPSTAT_WHAT_SET_LONGJMP_RESUME
1546 #define clr BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
1547 #define clrs BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
1548 #define sr BPSTAT_WHAT_STEP_RESUME
1549 #define ts BPSTAT_WHAT_THROUGH_SIGTRAMP
1550 #define shl BPSTAT_WHAT_CHECK_SHLIBS
1552 /* "Can't happen." Might want to print an error message.
1553 abort() is not out of the question, but chances are GDB is just
1554 a bit confused, not unusable. */
1555 #define err BPSTAT_WHAT_STOP_NOISY
1557 /* Given an old action and a class, come up with a new action. */
1558 /* One interesting property of this table is that wp_silent is the same
1559 as bp_silent and wp_noisy is the same as bp_noisy. That is because
1560 after stopping, the check for whether to step over a breakpoint
1561 (BPSTAT_WHAT_SINGLE type stuff) is handled in proceed() without
1562 reference to how we stopped. We retain separate wp_silent and bp_silent
1563 codes in case we want to change that someday. */
1565 /* step_resume entries: a step resume breakpoint overrides another
1566 breakpoint of signal handling (see comment in wait_for_inferior
1567 at first IN_SIGTRAMP where we set the step_resume breakpoint). */
1568 /* We handle the through_sigtramp_breakpoint the same way; having both
1569 one of those and a step_resume_breakpoint is probably very rare (?). */
1571 static const enum bpstat_what_main_action
1572 table
[(int)class_last
][(int)BPSTAT_WHAT_LAST
] =
1575 /* kc ss sn sgl slr clr clrs sr ts shl
1577 /*no_effect*/ {kc
, ss
, sn
, sgl
, slr
, clr
, clrs
, sr
, ts
, shl
},
1578 /*wp_silent*/ {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
},
1579 /*wp_noisy*/ {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
},
1580 /*bp_nostop*/ {sgl
, ss
, sn
, sgl
, slr
, clrs
, clrs
, sr
, ts
, shl
},
1581 /*bp_silent*/ {ss
, ss
, sn
, ss
, ss
, ss
, ss
, sr
, ts
, shl
},
1582 /*bp_noisy*/ {sn
, sn
, sn
, sn
, sn
, sn
, sn
, sr
, ts
, shl
},
1583 /*long_jump*/ {slr
, ss
, sn
, slr
, err
, err
, err
, sr
, ts
, shl
},
1584 /*long_resume*/ {clr
, ss
, sn
, clrs
, err
, err
, err
, sr
, ts
, shl
},
1585 /*step_resume*/ {sr
, sr
, sr
, sr
, sr
, sr
, sr
, sr
, ts
, shl
},
1586 /*through_sig*/ {ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, ts
, shl
},
1587 /*shlib*/ {shl
, shl
, shl
, shl
, shl
, shl
, shl
, shl
, ts
, shl
}
1600 enum bpstat_what_main_action current_action
= BPSTAT_WHAT_KEEP_CHECKING
;
1601 struct bpstat_what retval
;
1603 retval
.call_dummy
= 0;
1604 for (; bs
!= NULL
; bs
= bs
->next
)
1606 enum class bs_class
= no_effect
;
1607 if (bs
->breakpoint_at
== NULL
)
1608 /* I suspect this can happen if it was a momentary breakpoint
1609 which has since been deleted. */
1611 switch (bs
->breakpoint_at
->type
)
1614 case bp_hardware_breakpoint
:
1620 bs_class
= bp_noisy
;
1622 bs_class
= bp_silent
;
1625 bs_class
= bp_nostop
;
1628 case bp_hardware_watchpoint
:
1629 case bp_read_watchpoint
:
1630 case bp_access_watchpoint
:
1634 bs_class
= wp_noisy
;
1636 bs_class
= wp_silent
;
1639 /* There was a watchpoint, but we're not stopping. This requires
1640 no further action. */
1641 bs_class
= no_effect
;
1644 bs_class
= long_jump
;
1646 case bp_longjmp_resume
:
1647 bs_class
= long_resume
;
1649 case bp_step_resume
:
1652 bs_class
= step_resume
;
1655 /* It is for the wrong frame. */
1656 bs_class
= bp_nostop
;
1658 case bp_through_sigtramp
:
1659 bs_class
= through_sig
;
1661 case bp_watchpoint_scope
:
1662 bs_class
= bp_nostop
;
1664 case bp_shlib_event
:
1665 bs_class
= shlib_event
;
1668 /* Make sure the action is stop (silent or noisy), so infrun.c
1669 pops the dummy frame. */
1670 bs_class
= bp_silent
;
1671 retval
.call_dummy
= 1;
1674 current_action
= table
[(int)bs_class
][(int)current_action
];
1676 retval
.main_action
= current_action
;
1680 /* Nonzero if we should step constantly (e.g. watchpoints on machines
1681 without hardware support). This isn't related to a specific bpstat,
1682 just to things like whether watchpoints are set. */
1685 bpstat_should_step ()
1687 struct breakpoint
*b
;
1689 if (b
->enable
== enabled
&& b
->type
== bp_watchpoint
)
1694 /* Print information on breakpoint number BNUM, or -1 if all.
1695 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
1696 is nonzero, process only watchpoints. */
1699 breakpoint_1 (bnum
, allflag
)
1703 register struct breakpoint
*b
;
1704 register struct command_line
*l
;
1705 register struct symbol
*sym
;
1706 CORE_ADDR last_addr
= (CORE_ADDR
)-1;
1707 int found_a_breakpoint
= 0;
1708 static char *bptypes
[] = {"breakpoint", "hw breakpoint",
1709 "until", "finish", "watchpoint",
1710 "hw watchpoint", "read watchpoint",
1711 "acc watchpoint", "longjmp",
1712 "longjmp resume", "step resume",
1714 "watchpoint scope", "call dummy",
1716 static char *bpdisps
[] = {"del", "dstp", "dis", "keep"};
1717 static char bpenables
[] = "nyn";
1718 char wrap_indent
[80];
1722 || bnum
== b
->number
)
1724 /* We only print out user settable breakpoints unless the allflag is set. */
1726 && b
->type
!= bp_breakpoint
1727 && b
->type
!= bp_hardware_breakpoint
1728 && b
->type
!= bp_watchpoint
1729 && b
->type
!= bp_read_watchpoint
1730 && b
->type
!= bp_access_watchpoint
1731 && b
->type
!= bp_hardware_watchpoint
)
1734 if (!found_a_breakpoint
++)
1736 annotate_breakpoints_headers ();
1739 printf_filtered ("Num ");
1741 printf_filtered ("Type ");
1743 printf_filtered ("Disp ");
1745 printf_filtered ("Enb ");
1749 printf_filtered ("Address ");
1752 printf_filtered ("What\n");
1754 annotate_breakpoints_table ();
1759 printf_filtered ("%-3d ", b
->number
);
1761 printf_filtered ("%-14s ", bptypes
[(int)b
->type
]);
1763 printf_filtered ("%-4s ", bpdisps
[(int)b
->disposition
]);
1765 printf_filtered ("%-3c ", bpenables
[(int)b
->enable
]);
1767 strcpy (wrap_indent
, " ");
1769 strcat (wrap_indent
, " ");
1773 case bp_hardware_watchpoint
:
1774 case bp_read_watchpoint
:
1775 case bp_access_watchpoint
:
1776 /* Field 4, the address, is omitted (which makes the columns
1777 not line up too nicely with the headers, but the effect
1778 is relatively readable). */
1780 print_expression (b
->exp
, gdb_stdout
);
1784 case bp_hardware_breakpoint
:
1788 case bp_longjmp_resume
:
1789 case bp_step_resume
:
1790 case bp_through_sigtramp
:
1791 case bp_watchpoint_scope
:
1793 case bp_shlib_event
:
1797 /* FIXME-32x64: need a print_address_numeric with
1801 local_hex_string_custom
1802 ((unsigned long) b
->address
, "08l"));
1807 last_addr
= b
->address
;
1810 sym
= find_pc_function (b
->address
);
1813 fputs_filtered ("in ", gdb_stdout
);
1814 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), gdb_stdout
);
1815 wrap_here (wrap_indent
);
1816 fputs_filtered (" at ", gdb_stdout
);
1818 fputs_filtered (b
->source_file
, gdb_stdout
);
1819 printf_filtered (":%d", b
->line_number
);
1822 print_address_symbolic (b
->address
, gdb_stdout
, demangle
, " ");
1826 printf_filtered ("\n");
1832 printf_filtered ("\tstop only in stack frame at ");
1833 print_address_numeric (b
->frame
, 1, gdb_stdout
);
1834 printf_filtered ("\n");
1841 printf_filtered ("\tstop only if ");
1842 print_expression (b
->cond
, gdb_stdout
);
1843 printf_filtered ("\n");
1846 if (b
->thread
!= -1)
1848 /* FIXME should make an annotation for this */
1849 printf_filtered ("\tstop only in thread %d\n", b
->thread
);
1852 if (show_breakpoint_hit_counts
&& b
->hit_count
)
1854 /* FIXME should make an annotation for this */
1856 printf_filtered ("\tbreakpoint already hit %d time%s\n",
1857 b
->hit_count
, (b
->hit_count
== 1 ? "" : "s"));
1860 if (b
->ignore_count
)
1864 printf_filtered ("\tignore next %d hits\n", b
->ignore_count
);
1867 if ((l
= b
->commands
))
1873 print_command_line (l
, 4);
1879 if (!found_a_breakpoint
)
1882 printf_filtered ("No breakpoints or watchpoints.\n");
1884 printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum
);
1887 /* Compare against (CORE_ADDR)-1 in case some compiler decides
1888 that a comparison of an unsigned with -1 is always false. */
1889 if (last_addr
!= (CORE_ADDR
)-1)
1890 set_next_address (last_addr
);
1892 annotate_breakpoints_table_end ();
1897 breakpoints_info (bnum_exp
, from_tty
)
1904 bnum
= parse_and_eval_address (bnum_exp
);
1906 breakpoint_1 (bnum
, 0);
1909 #if MAINTENANCE_CMDS
1913 maintenance_info_breakpoints (bnum_exp
, from_tty
)
1920 bnum
= parse_and_eval_address (bnum_exp
);
1922 breakpoint_1 (bnum
, 1);
1927 /* Print a message describing any breakpoints set at PC. */
1930 describe_other_breakpoints (pc
)
1931 register CORE_ADDR pc
;
1933 register int others
= 0;
1934 register struct breakpoint
*b
;
1937 if (b
->address
== pc
)
1941 printf_filtered ("Note: breakpoint%s ", (others
> 1) ? "s" : "");
1943 if (b
->address
== pc
)
1949 ((b
->enable
== disabled
|| b
->enable
== shlib_disabled
)
1950 ? " (disabled)" : ""),
1951 (others
> 1) ? "," : ((others
== 1) ? " and" : ""));
1953 printf_filtered ("also set at pc ");
1954 print_address_numeric (pc
, 1, gdb_stdout
);
1955 printf_filtered (".\n");
1959 /* Set the default place to put a breakpoint
1960 for the `break' command with no arguments. */
1963 set_default_breakpoint (valid
, addr
, symtab
, line
)
1966 struct symtab
*symtab
;
1969 default_breakpoint_valid
= valid
;
1970 default_breakpoint_address
= addr
;
1971 default_breakpoint_symtab
= symtab
;
1972 default_breakpoint_line
= line
;
1975 /* Rescan breakpoints at address ADDRESS,
1976 marking the first one as "first" and any others as "duplicates".
1977 This is so that the bpt instruction is only inserted once. */
1980 check_duplicates (address
)
1983 register struct breakpoint
*b
;
1984 register int count
= 0;
1986 if (address
== 0) /* Watchpoints are uninteresting */
1990 if (b
->enable
!= disabled
1991 && b
->enable
!= shlib_disabled
1992 && b
->address
== address
)
1995 b
->duplicate
= count
> 1;
1999 /* Low level routine to set a breakpoint.
2000 Takes as args the three things that every breakpoint must have.
2001 Returns the breakpoint object so caller can set other things.
2002 Does not set the breakpoint number!
2003 Does not print anything.
2005 ==> This routine should not be called if there is a chance of later
2006 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
2007 your arguments BEFORE calling this routine! */
2009 static struct breakpoint
*
2010 set_raw_breakpoint (sal
)
2011 struct symtab_and_line sal
;
2013 register struct breakpoint
*b
, *b1
;
2015 b
= (struct breakpoint
*) xmalloc (sizeof (struct breakpoint
));
2016 memset (b
, 0, sizeof (*b
));
2017 b
->address
= sal
.pc
;
2018 if (sal
.symtab
== NULL
)
2019 b
->source_file
= NULL
;
2021 b
->source_file
= savestring (sal
.symtab
->filename
,
2022 strlen (sal
.symtab
->filename
));
2023 b
->language
= current_language
->la_language
;
2024 b
->input_radix
= input_radix
;
2026 b
->line_number
= sal
.line
;
2027 b
->enable
= enabled
;
2030 b
->ignore_count
= 0;
2034 /* Add this breakpoint to the end of the chain
2035 so that a list of breakpoints will come out in order
2036 of increasing numbers. */
2038 b1
= breakpoint_chain
;
2040 breakpoint_chain
= b
;
2048 check_duplicates (sal
.pc
);
2049 breakpoints_changed ();
2054 static int internal_breakpoint_number
= -1;
2056 #ifdef GET_LONGJMP_TARGET
2059 create_longjmp_breakpoint (func_name
)
2062 struct symtab_and_line sal
;
2063 struct breakpoint
*b
;
2065 if (func_name
!= NULL
)
2067 struct minimal_symbol
*m
;
2069 m
= lookup_minimal_symbol_text (func_name
, NULL
, (struct objfile
*)NULL
);
2071 sal
.pc
= SYMBOL_VALUE_ADDRESS (m
);
2081 b
= set_raw_breakpoint (sal
);
2084 b
->type
= func_name
!= NULL
? bp_longjmp
: bp_longjmp_resume
;
2085 b
->disposition
= donttouch
;
2086 b
->enable
= disabled
;
2089 b
->addr_string
= strsave(func_name
);
2090 b
->number
= internal_breakpoint_number
--;
2093 #endif /* #ifdef GET_LONGJMP_TARGET */
2095 /* Call this routine when stepping and nexting to enable a breakpoint if we do
2096 a longjmp(). When we hit that breakpoint, call
2097 set_longjmp_resume_breakpoint() to figure out where we are going. */
2100 enable_longjmp_breakpoint()
2102 register struct breakpoint
*b
;
2105 if (b
->type
== bp_longjmp
)
2107 b
->enable
= enabled
;
2108 check_duplicates (b
->address
);
2113 disable_longjmp_breakpoint()
2115 register struct breakpoint
*b
;
2118 if ( b
->type
== bp_longjmp
2119 || b
->type
== bp_longjmp_resume
)
2121 b
->enable
= disabled
;
2122 check_duplicates (b
->address
);
2128 remove_solib_event_breakpoints ()
2130 register struct breakpoint
*b
, *temp
;
2132 ALL_BREAKPOINTS_SAFE (b
, temp
)
2133 if (b
->type
== bp_shlib_event
)
2134 delete_breakpoint (b
);
2138 create_solib_event_breakpoint (address
)
2141 struct breakpoint
*b
;
2142 struct symtab_and_line sal
;
2147 b
= set_raw_breakpoint (sal
);
2148 b
->number
= internal_breakpoint_number
--;
2149 b
->disposition
= donttouch
;
2150 b
->type
= bp_shlib_event
;
2153 /* Try to reenable any breakpoints in shared libraries. */
2155 re_enable_breakpoints_in_shlibs ()
2157 struct breakpoint
*b
;
2160 if (b
->enable
== shlib_disabled
)
2164 /* Do not reenable the breakpoint if the shared library
2165 is still not mapped in. */
2166 if (target_read_memory (b
->address
, buf
, 1) == 0)
2167 b
->enable
= enabled
;
2174 hw_breakpoint_used_count()
2176 register struct breakpoint
*b
;
2181 if (b
->type
== bp_hardware_breakpoint
&& b
->enable
== enabled
)
2189 hw_watchpoint_used_count(type
, other_type_used
)
2191 int *other_type_used
;
2193 register struct breakpoint
*b
;
2196 *other_type_used
= 0;
2199 if (b
->enable
== enabled
)
2201 if (b
->type
== type
) i
++;
2202 else if ((b
->type
== bp_hardware_watchpoint
||
2203 b
->type
== bp_read_watchpoint
||
2204 b
->type
== bp_access_watchpoint
)
2205 && b
->enable
== enabled
)
2206 *other_type_used
= 1;
2212 /* Call this after hitting the longjmp() breakpoint. Use this to set a new
2213 breakpoint at the target of the jmp_buf.
2215 FIXME - This ought to be done by setting a temporary breakpoint that gets
2216 deleted automatically...
2220 set_longjmp_resume_breakpoint(pc
, frame
)
2222 struct frame_info
*frame
;
2224 register struct breakpoint
*b
;
2227 if (b
->type
== bp_longjmp_resume
)
2230 b
->enable
= enabled
;
2232 b
->frame
= frame
->frame
;
2235 check_duplicates (b
->address
);
2240 /* Set a breakpoint that will evaporate an end of command
2241 at address specified by SAL.
2242 Restrict it to frame FRAME if FRAME is nonzero. */
2245 set_momentary_breakpoint (sal
, frame
, type
)
2246 struct symtab_and_line sal
;
2247 struct frame_info
*frame
;
2250 register struct breakpoint
*b
;
2251 b
= set_raw_breakpoint (sal
);
2253 b
->enable
= enabled
;
2254 b
->disposition
= donttouch
;
2255 b
->frame
= (frame
? frame
->frame
: 0);
2257 /* If we're debugging a multi-threaded program, then we
2258 want momentary breakpoints to be active in only a
2259 single thread of control. */
2260 if (in_thread_list (inferior_pid
))
2261 b
->thread
= pid_to_thread_id (inferior_pid
);
2267 /* Tell the user we have just set a breakpoint B. */
2271 struct breakpoint
*b
;
2275 /* FIXME: This is misplaced; mention() is called by things (like hitting a
2276 watchpoint) other than breakpoint creation. It should be possible to
2277 clean this up and at the same time replace the random calls to
2278 breakpoint_changed with this hook, as has already been done for
2279 delete_breakpoint_hook and so on. */
2280 if (create_breakpoint_hook
)
2281 create_breakpoint_hook (b
);
2286 printf_filtered ("Watchpoint %d: ", b
->number
);
2287 print_expression (b
->exp
, gdb_stdout
);
2289 case bp_hardware_watchpoint
:
2290 printf_filtered ("Hardware watchpoint %d: ", b
->number
);
2291 print_expression (b
->exp
, gdb_stdout
);
2293 case bp_read_watchpoint
:
2294 printf_filtered ("Hardware read watchpoint %d: ", b
->number
);
2295 print_expression (b
->exp
, gdb_stdout
);
2297 case bp_access_watchpoint
:
2298 printf_filtered ("Hardware access(read/write) watchpoint %d: ",b
->number
);
2299 print_expression (b
->exp
, gdb_stdout
);
2302 printf_filtered ("Breakpoint %d", b
->number
);
2305 case bp_hardware_breakpoint
:
2306 printf_filtered ("Hardware assisted breakpoint %d", b
->number
);
2312 case bp_longjmp_resume
:
2313 case bp_step_resume
:
2314 case bp_through_sigtramp
:
2316 case bp_watchpoint_scope
:
2317 case bp_shlib_event
:
2322 if (addressprint
|| b
->source_file
== NULL
)
2324 printf_filtered (" at ");
2325 print_address_numeric (b
->address
, 1, gdb_stdout
);
2328 printf_filtered (": file %s, line %d.",
2329 b
->source_file
, b
->line_number
);
2331 printf_filtered ("\n");
2335 /* Set a breakpoint according to ARG (function, linenum or *address)
2336 flag: first bit : 0 non-temporary, 1 temporary.
2337 second bit : 0 normal breakpoint, 1 hardware breakpoint. */
2340 break_command_1 (arg
, flag
, from_tty
)
2344 int tempflag
, hardwareflag
;
2345 struct symtabs_and_lines sals
;
2346 struct symtab_and_line sal
;
2347 register struct expression
*cond
= 0;
2348 register struct breakpoint
*b
;
2350 /* Pointers in arg to the start, and one past the end, of the condition. */
2351 char *cond_start
= NULL
;
2352 char *cond_end
= NULL
;
2353 /* Pointers in arg to the start, and one past the end,
2354 of the address part. */
2355 char *addr_start
= NULL
;
2356 char *addr_end
= NULL
;
2357 struct cleanup
*old_chain
;
2358 struct cleanup
*canonical_strings_chain
= NULL
;
2359 char **canonical
= (char **)NULL
;
2363 hardwareflag
= flag
& BP_HARDWAREFLAG
;
2364 tempflag
= flag
& BP_TEMPFLAG
;
2369 sal
.line
= sal
.pc
= sal
.end
= 0;
2372 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
2374 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
2375 && (arg
[2] == ' ' || arg
[2] == '\t')))
2377 if (default_breakpoint_valid
)
2379 sals
.sals
= (struct symtab_and_line
*)
2380 xmalloc (sizeof (struct symtab_and_line
));
2381 sal
.pc
= default_breakpoint_address
;
2382 sal
.line
= default_breakpoint_line
;
2383 sal
.symtab
= default_breakpoint_symtab
;
2388 error ("No default breakpoint address now.");
2394 /* Force almost all breakpoints to be in terms of the
2395 current_source_symtab (which is decode_line_1's default). This
2396 should produce the results we want almost all of the time while
2397 leaving default_breakpoint_* alone. */
2398 if (default_breakpoint_valid
2399 && (!current_source_symtab
2400 || (arg
&& (*arg
== '+' || *arg
== '-'))))
2401 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
2402 default_breakpoint_line
, &canonical
);
2404 sals
= decode_line_1 (&arg
, 1, (struct symtab
*)NULL
, 0, &canonical
);
2412 /* Make sure that all storage allocated in decode_line_1 gets freed in case
2413 the following `for' loop errors out. */
2414 old_chain
= make_cleanup (free
, sals
.sals
);
2415 if (canonical
!= (char **)NULL
)
2417 make_cleanup (free
, canonical
);
2418 canonical_strings_chain
= make_cleanup (null_cleanup
, 0);
2419 for (i
= 0; i
< sals
.nelts
; i
++)
2421 if (canonical
[i
] != NULL
)
2422 make_cleanup (free
, canonical
[i
]);
2426 thread
= -1; /* No specific thread yet */
2428 /* Resolve all line numbers to PC's, and verify that conditions
2429 can be parsed, before setting any breakpoints. */
2430 for (i
= 0; i
< sals
.nelts
; i
++)
2432 char *tok
, *end_tok
;
2435 resolve_sal_pc (&sals
.sals
[i
]);
2441 while (*tok
== ' ' || *tok
== '\t')
2446 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
2449 toklen
= end_tok
- tok
;
2451 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
2453 tok
= cond_start
= end_tok
+ 1;
2454 cond
= parse_exp_1 (&tok
, block_for_pc (sals
.sals
[i
].pc
), 0);
2457 else if (toklen
>= 1 && strncmp (tok
, "thread", toklen
) == 0)
2463 thread
= strtol (tok
, &tok
, 0);
2465 error ("Junk after thread keyword.");
2466 if (!valid_thread_id (thread
))
2467 error ("Unknown thread %d\n", thread
);
2470 error ("Junk at end of arguments.");
2475 int i
, target_resources_ok
;
2477 i
= hw_breakpoint_used_count ();
2478 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT (
2479 bp_hardware_breakpoint
, i
+ sals
.nelts
, 0);
2480 if (target_resources_ok
== 0)
2481 error ("No hardware breakpoint support in the target.");
2482 else if (target_resources_ok
< 0)
2483 error ("Hardware breakpoints used exceeds limit.");
2486 /* Remove the canonical strings from the cleanup, they are needed below. */
2487 if (canonical
!= (char **)NULL
)
2488 discard_cleanups (canonical_strings_chain
);
2490 /* Now set all the breakpoints. */
2491 for (i
= 0; i
< sals
.nelts
; i
++)
2496 describe_other_breakpoints (sal
.pc
);
2498 b
= set_raw_breakpoint (sal
);
2499 set_breakpoint_count (breakpoint_count
+ 1);
2500 b
->number
= breakpoint_count
;
2501 b
->type
= hardwareflag
? bp_hardware_breakpoint
: bp_breakpoint
;
2505 /* If a canonical line spec is needed use that instead of the
2507 if (canonical
!= (char **)NULL
&& canonical
[i
] != NULL
)
2508 b
->addr_string
= canonical
[i
];
2509 else if (addr_start
)
2510 b
->addr_string
= savestring (addr_start
, addr_end
- addr_start
);
2512 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
2514 b
->enable
= enabled
;
2515 b
->disposition
= tempflag
? del
: donttouch
;
2522 printf_filtered ("Multiple breakpoints were set.\n");
2523 printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
2525 do_cleanups (old_chain
);
2528 /* Helper function for break_command_1 and disassemble_command. */
2531 resolve_sal_pc (sal
)
2532 struct symtab_and_line
*sal
;
2536 if (sal
->pc
== 0 && sal
->symtab
!= 0)
2538 pc
= find_line_pc (sal
->symtab
, sal
->line
);
2540 error ("No line %d in file \"%s\".",
2541 sal
->line
, sal
->symtab
->filename
);
2547 break_command (arg
, from_tty
)
2551 break_command_1 (arg
, 0, from_tty
);
2555 tbreak_command (arg
, from_tty
)
2559 break_command_1 (arg
, BP_TEMPFLAG
, from_tty
);
2563 hbreak_command (arg
, from_tty
)
2567 break_command_1 (arg
, BP_HARDWAREFLAG
, from_tty
);
2571 thbreak_command (arg
, from_tty
)
2575 break_command_1 (arg
, (BP_TEMPFLAG
| BP_HARDWAREFLAG
), from_tty
);
2579 /* accessflag: 0: watch write, 1: watch read, 2: watch access(read or write)
2582 watch_command_1 (arg
, accessflag
, from_tty
)
2587 struct breakpoint
*b
;
2588 struct symtab_and_line sal
;
2589 struct expression
*exp
;
2590 struct block
*exp_valid_block
;
2591 struct value
*val
, *mark
;
2592 struct frame_info
*frame
;
2593 struct frame_info
*prev_frame
= NULL
;
2594 char *exp_start
= NULL
;
2595 char *exp_end
= NULL
;
2596 char *tok
, *end_tok
;
2598 char *cond_start
= NULL
;
2599 char *cond_end
= NULL
;
2600 struct expression
*cond
= NULL
;
2601 int i
, other_type_used
, target_resources_ok
;
2602 enum bptype bp_type
;
2609 /* Parse arguments. */
2610 innermost_block
= NULL
;
2612 exp
= parse_exp_1 (&arg
, 0, 0);
2614 exp_valid_block
= innermost_block
;
2615 mark
= value_mark ();
2616 val
= evaluate_expression (exp
);
2617 release_value (val
);
2618 if (VALUE_LAZY (val
))
2619 value_fetch_lazy (val
);
2622 while (*tok
== ' ' || *tok
== '\t')
2626 while (*end_tok
!= ' ' && *end_tok
!= '\t' && *end_tok
!= '\000')
2629 toklen
= end_tok
- tok
;
2630 if (toklen
>= 1 && strncmp (tok
, "if", toklen
) == 0)
2632 tok
= cond_start
= end_tok
+ 1;
2633 cond
= parse_exp_1 (&tok
, 0, 0);
2637 error("Junk at end of command.");
2639 if (accessflag
== 1) bp_type
= bp_read_watchpoint
;
2640 else if (accessflag
== 2) bp_type
= bp_access_watchpoint
;
2641 else bp_type
= bp_hardware_watchpoint
;
2643 mem_cnt
= can_use_hardware_watchpoint (val
);
2644 if (mem_cnt
== 0 && bp_type
!= bp_hardware_watchpoint
)
2645 error ("Expression cannot be implemented with read/access watchpoint.");
2647 i
= hw_watchpoint_used_count (bp_type
, &other_type_used
);
2648 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT(
2649 bp_type
, i
+ mem_cnt
, other_type_used
);
2650 if (target_resources_ok
== 0 && bp_type
!= bp_hardware_watchpoint
)
2651 error ("Target does not have this type of hardware watchpoint support.");
2652 if (target_resources_ok
< 0 && bp_type
!= bp_hardware_watchpoint
)
2653 error ("Target resources have been allocated for other types of watchpoints.");
2656 /* Now set up the breakpoint. */
2657 b
= set_raw_breakpoint (sal
);
2658 set_breakpoint_count (breakpoint_count
+ 1);
2659 b
->number
= breakpoint_count
;
2660 b
->disposition
= donttouch
;
2662 b
->exp_valid_block
= exp_valid_block
;
2663 b
->exp_string
= savestring (exp_start
, exp_end
- exp_start
);
2667 b
->cond_string
= savestring (cond_start
, cond_end
- cond_start
);
2671 frame
= block_innermost_frame (exp_valid_block
);
2674 prev_frame
= get_prev_frame (frame
);
2675 b
->watchpoint_frame
= frame
->frame
;
2678 b
->watchpoint_frame
= (CORE_ADDR
)0;
2680 if (mem_cnt
&& target_resources_ok
> 0)
2683 b
->type
= bp_watchpoint
;
2685 /* If the expression is "local", then set up a "watchpoint scope"
2686 breakpoint at the point where we've left the scope of the watchpoint
2688 if (innermost_block
)
2690 struct breakpoint
*scope_breakpoint
;
2691 struct symtab_and_line scope_sal
;
2695 scope_sal
.pc
= get_frame_pc (prev_frame
);
2696 scope_sal
.symtab
= NULL
;
2699 scope_breakpoint
= set_raw_breakpoint (scope_sal
);
2700 set_breakpoint_count (breakpoint_count
+ 1);
2701 scope_breakpoint
->number
= breakpoint_count
;
2703 scope_breakpoint
->type
= bp_watchpoint_scope
;
2704 scope_breakpoint
->enable
= enabled
;
2706 /* Automatically delete the breakpoint when it hits. */
2707 scope_breakpoint
->disposition
= del
;
2709 /* Only break in the proper frame (help with recursion). */
2710 scope_breakpoint
->frame
= prev_frame
->frame
;
2712 /* Set the address at which we will stop. */
2713 scope_breakpoint
->address
= get_frame_pc (prev_frame
);
2715 /* The scope breakpoint is related to the watchpoint. We
2716 will need to act on them together. */
2717 b
->related_breakpoint
= scope_breakpoint
;
2720 value_free_to_mark (mark
);
2724 /* Return count of locations need to be watched and can be handled
2725 in hardware. If the watchpoint can not be handled
2726 in hardware return zero. */
2729 can_use_hardware_watchpoint (v
)
2732 int found_memory_cnt
= 0;
2734 /* Make sure all the intermediate values are in memory. Also make sure
2735 we found at least one memory expression. Guards against watch 0x12345,
2736 which is meaningless, but could cause errors if one tries to insert a
2737 hardware watchpoint for the constant expression. */
2738 for ( ; v
; v
= v
->next
)
2740 if (v
->lval
== lval_memory
)
2742 if (TYPE_LENGTH (VALUE_TYPE (v
)) <= REGISTER_SIZE
)
2745 else if (v
->lval
!= not_lval
&& v
->modifiable
== 0)
2749 /* The expression itself looks suitable for using a hardware
2750 watchpoint, but give the target machine a chance to reject it. */
2751 return found_memory_cnt
;
2754 static void watch_command (arg
, from_tty
)
2758 watch_command_1 (arg
, 0, from_tty
);
2761 static void rwatch_command (arg
, from_tty
)
2765 watch_command_1 (arg
, 1, from_tty
);
2768 static void awatch_command (arg
, from_tty
)
2772 watch_command_1 (arg
, 2, from_tty
);
2776 /* Helper routine for the until_command routine in infcmd.c. Here
2777 because it uses the mechanisms of breakpoints. */
2781 until_break_command (arg
, from_tty
)
2785 struct symtabs_and_lines sals
;
2786 struct symtab_and_line sal
;
2787 struct frame_info
*prev_frame
= get_prev_frame (selected_frame
);
2788 struct breakpoint
*breakpoint
;
2789 struct cleanup
*old_chain
;
2791 clear_proceed_status ();
2793 /* Set a breakpoint where the user wants it and at return from
2796 if (default_breakpoint_valid
)
2797 sals
= decode_line_1 (&arg
, 1, default_breakpoint_symtab
,
2798 default_breakpoint_line
, (char ***)NULL
);
2800 sals
= decode_line_1 (&arg
, 1, (struct symtab
*)NULL
, 0, (char ***)NULL
);
2802 if (sals
.nelts
!= 1)
2803 error ("Couldn't get information on specified line.");
2806 free ((PTR
)sals
.sals
); /* malloc'd, so freed */
2809 error ("Junk at end of arguments.");
2811 resolve_sal_pc (&sal
);
2813 breakpoint
= set_momentary_breakpoint (sal
, selected_frame
, bp_until
);
2815 old_chain
= make_cleanup(delete_breakpoint
, breakpoint
);
2817 /* Keep within the current frame */
2821 sal
= find_pc_line (prev_frame
->pc
, 0);
2822 sal
.pc
= prev_frame
->pc
;
2823 breakpoint
= set_momentary_breakpoint (sal
, prev_frame
, bp_until
);
2824 make_cleanup(delete_breakpoint
, breakpoint
);
2827 proceed (-1, TARGET_SIGNAL_DEFAULT
, 0);
2828 do_cleanups(old_chain
);
2832 /* These aren't used; I don't konw what they were for. */
2833 /* Set a breakpoint at the catch clause for NAME. */
2835 catch_breakpoint (name
)
2841 disable_catch_breakpoint ()
2846 delete_catch_breakpoint ()
2851 enable_catch_breakpoint ()
2858 struct sal_chain
*next
;
2859 struct symtab_and_line sal
;
2863 /* This isn't used; I don't know what it was for. */
2864 /* For each catch clause identified in ARGS, run FUNCTION
2865 with that clause as an argument. */
2866 static struct symtabs_and_lines
2867 map_catch_names (args
, function
)
2871 register char *p
= args
;
2873 struct symtabs_and_lines sals
;
2875 struct sal_chain
*sal_chain
= 0;
2879 error_no_arg ("one or more catch names");
2887 /* Don't swallow conditional part. */
2888 if (p1
[0] == 'i' && p1
[1] == 'f'
2889 && (p1
[2] == ' ' || p1
[2] == '\t'))
2895 while (isalnum (*p1
) || *p1
== '_' || *p1
== '$')
2899 if (*p1
&& *p1
!= ' ' && *p1
!= '\t')
2900 error ("Arguments must be catch names.");
2906 struct sal_chain
*next
2907 = (struct sal_chain
*)alloca (sizeof (struct sal_chain
));
2908 next
->next
= sal_chain
;
2909 next
->sal
= get_catch_sal (p
);
2914 printf_unfiltered ("No catch clause for exception %s.\n", p
);
2919 while (*p
== ' ' || *p
== '\t') p
++;
2924 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
2926 static struct symtabs_and_lines
2927 get_catch_sals (this_level_only
)
2928 int this_level_only
;
2930 register struct blockvector
*bl
;
2931 register struct block
*block
;
2932 int index
, have_default
= 0;
2934 struct symtabs_and_lines sals
;
2935 struct sal_chain
*sal_chain
= 0;
2936 char *blocks_searched
;
2938 /* Not sure whether an error message is always the correct response,
2939 but it's better than a core dump. */
2940 if (selected_frame
== NULL
)
2941 error ("No selected frame.");
2942 block
= get_frame_block (selected_frame
);
2943 pc
= selected_frame
->pc
;
2949 error ("No symbol table info available.\n");
2951 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
2952 blocks_searched
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
2953 memset (blocks_searched
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
2957 CORE_ADDR end
= BLOCK_END (block
) - 4;
2960 if (bl
!= blockvector_for_pc (end
, &index
))
2961 error ("blockvector blotch");
2962 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
2963 error ("blockvector botch");
2964 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
2967 /* Don't print out blocks that have gone by. */
2968 while (index
< last_index
2969 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
2972 while (index
< last_index
2973 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
2975 if (blocks_searched
[index
] == 0)
2977 struct block
*b
= BLOCKVECTOR_BLOCK (bl
, index
);
2980 register struct symbol
*sym
;
2982 nsyms
= BLOCK_NSYMS (b
);
2984 for (i
= 0; i
< nsyms
; i
++)
2986 sym
= BLOCK_SYM (b
, i
);
2987 if (STREQ (SYMBOL_NAME (sym
), "default"))
2993 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
2995 struct sal_chain
*next
= (struct sal_chain
*)
2996 alloca (sizeof (struct sal_chain
));
2997 next
->next
= sal_chain
;
2998 next
->sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
), 0);
3002 blocks_searched
[index
] = 1;
3008 if (sal_chain
&& this_level_only
)
3011 /* After handling the function's top-level block, stop.
3012 Don't continue to its superblock, the block of
3013 per-file symbols. */
3014 if (BLOCK_FUNCTION (block
))
3016 block
= BLOCK_SUPERBLOCK (block
);
3021 struct sal_chain
*tmp_chain
;
3023 /* Count the number of entries. */
3024 for (index
= 0, tmp_chain
= sal_chain
; tmp_chain
;
3025 tmp_chain
= tmp_chain
->next
)
3029 sals
.sals
= (struct symtab_and_line
*)
3030 xmalloc (index
* sizeof (struct symtab_and_line
));
3031 for (index
= 0; sal_chain
; sal_chain
= sal_chain
->next
, index
++)
3032 sals
.sals
[index
] = sal_chain
->sal
;
3038 /* Commands to deal with catching exceptions. */
3041 catch_command_1 (arg
, tempflag
, from_tty
)
3046 /* First, translate ARG into something we can deal with in terms
3049 struct symtabs_and_lines sals
;
3050 struct symtab_and_line sal
;
3051 register struct expression
*cond
= 0;
3052 register struct breakpoint
*b
;
3056 sal
.line
= sal
.pc
= sal
.end
= 0;
3059 /* If no arg given, or if first arg is 'if ', all active catch clauses
3060 are breakpointed. */
3062 if (!arg
|| (arg
[0] == 'i' && arg
[1] == 'f'
3063 && (arg
[2] == ' ' || arg
[2] == '\t')))
3065 /* Grab all active catch clauses. */
3066 sals
= get_catch_sals (0);
3070 /* Grab selected catch clauses. */
3071 error ("catch NAME not implemented");
3073 /* This isn't used; I don't know what it was for. */
3074 sals
= map_catch_names (arg
, catch_breakpoint
);
3082 for (i
= 0; i
< sals
.nelts
; i
++)
3084 resolve_sal_pc (&sals
.sals
[i
]);
3088 if (arg
[0] == 'i' && arg
[1] == 'f'
3089 && (arg
[2] == ' ' || arg
[2] == '\t'))
3090 cond
= parse_exp_1 ((arg
+= 2, &arg
),
3091 block_for_pc (sals
.sals
[i
].pc
), 0);
3093 error ("Junk at end of arguments.");
3098 for (i
= 0; i
< sals
.nelts
; i
++)
3103 describe_other_breakpoints (sal
.pc
);
3105 b
= set_raw_breakpoint (sal
);
3106 set_breakpoint_count (breakpoint_count
+ 1);
3107 b
->number
= breakpoint_count
;
3108 b
->type
= bp_breakpoint
;
3110 b
->enable
= enabled
;
3111 b
->disposition
= tempflag
? del
: donttouch
;
3118 printf_unfiltered ("Multiple breakpoints were set.\n");
3119 printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n");
3121 free ((PTR
)sals
.sals
);
3124 /* Used by the gui, could be made a worker for other things. */
3127 set_breakpoint_sal (sal
)
3128 struct symtab_and_line sal
;
3130 struct breakpoint
*b
;
3131 b
= set_raw_breakpoint (sal
);
3132 set_breakpoint_count (breakpoint_count
+ 1);
3133 b
->number
= breakpoint_count
;
3134 b
->type
= bp_breakpoint
;
3141 /* These aren't used; I don't know what they were for. */
3142 /* Disable breakpoints on all catch clauses described in ARGS. */
3144 disable_catch (args
)
3147 /* Map the disable command to catch clauses described in ARGS. */
3150 /* Enable breakpoints on all catch clauses described in ARGS. */
3155 /* Map the disable command to catch clauses described in ARGS. */
3158 /* Delete breakpoints on all catch clauses in the active scope. */
3163 /* Map the delete command to catch clauses described in ARGS. */
3168 catch_command (arg
, from_tty
)
3172 catch_command_1 (arg
, 0, from_tty
);
3176 clear_command (arg
, from_tty
)
3180 register struct breakpoint
*b
, *b1
;
3181 struct symtabs_and_lines sals
;
3182 struct symtab_and_line sal
;
3183 register struct breakpoint
*found
;
3188 sals
= decode_line_spec (arg
, 1);
3192 sals
.sals
= (struct symtab_and_line
*) xmalloc (sizeof (struct symtab_and_line
));
3193 sal
.line
= default_breakpoint_line
;
3194 sal
.symtab
= default_breakpoint_symtab
;
3196 if (sal
.symtab
== 0)
3197 error ("No source file specified.");
3203 for (i
= 0; i
< sals
.nelts
; i
++)
3205 /* If exact pc given, clear bpts at that pc.
3206 But if sal.pc is zero, clear all bpts on specified line. */
3208 found
= (struct breakpoint
*) 0;
3209 while (breakpoint_chain
3211 ? breakpoint_chain
->address
== sal
.pc
3212 : (breakpoint_chain
->source_file
!= NULL
3213 && sal
.symtab
!= NULL
3214 && STREQ (breakpoint_chain
->source_file
,
3215 sal
.symtab
->filename
)
3216 && breakpoint_chain
->line_number
== sal
.line
)))
3218 b1
= breakpoint_chain
;
3219 breakpoint_chain
= b1
->next
;
3226 && b
->next
->type
!= bp_watchpoint
3227 && b
->next
->type
!= bp_hardware_watchpoint
3228 && b
->next
->type
!= bp_read_watchpoint
3229 && b
->next
->type
!= bp_access_watchpoint
3231 ? b
->next
->address
== sal
.pc
3232 : (b
->next
->source_file
!= NULL
3233 && sal
.symtab
!= NULL
3234 && STREQ (b
->next
->source_file
, sal
.symtab
->filename
)
3235 && b
->next
->line_number
== sal
.line
)))
3246 error ("No breakpoint at %s.", arg
);
3248 error ("No breakpoint at this line.");
3251 if (found
->next
) from_tty
= 1; /* Always report if deleted more than one */
3252 if (from_tty
) printf_unfiltered ("Deleted breakpoint%s ", found
->next
? "s" : "");
3253 breakpoints_changed ();
3256 if (from_tty
) printf_unfiltered ("%d ", found
->number
);
3258 delete_breakpoint (found
);
3261 if (from_tty
) putchar_unfiltered ('\n');
3263 free ((PTR
)sals
.sals
);
3266 /* Delete breakpoint in BS if they are `delete' breakpoints and
3267 all breakpoints that are marked for deletion, whether hit or not.
3268 This is called after any breakpoint is hit, or after errors. */
3271 breakpoint_auto_delete (bs
)
3274 struct breakpoint
*b
, *temp
;
3276 for (; bs
; bs
= bs
->next
)
3277 if (bs
->breakpoint_at
&& bs
->breakpoint_at
->disposition
== del
3279 delete_breakpoint (bs
->breakpoint_at
);
3281 ALL_BREAKPOINTS_SAFE (b
, temp
)
3283 if (b
->disposition
== del_at_next_stop
)
3284 delete_breakpoint (b
);
3288 /* Delete a breakpoint and clean up all traces of it in the data structures. */
3291 delete_breakpoint (bpt
)
3292 struct breakpoint
*bpt
;
3294 register struct breakpoint
*b
;
3297 if (delete_breakpoint_hook
)
3298 delete_breakpoint_hook (bpt
);
3301 remove_breakpoint (bpt
);
3303 if (breakpoint_chain
== bpt
)
3304 breakpoint_chain
= bpt
->next
;
3309 b
->next
= bpt
->next
;
3313 check_duplicates (bpt
->address
);
3314 /* If this breakpoint was inserted, and there is another breakpoint
3315 at the same address, we need to insert the other breakpoint. */
3317 && bpt
->type
!= bp_hardware_watchpoint
3318 && bpt
->type
!= bp_read_watchpoint
3319 && bpt
->type
!= bp_access_watchpoint
)
3322 if (b
->address
== bpt
->address
3324 && b
->enable
!= disabled
3325 && b
->enable
!= shlib_disabled
)
3328 val
= target_insert_breakpoint (b
->address
, b
->shadow_contents
);
3331 target_terminal_ours_for_output ();
3332 fprintf_unfiltered (gdb_stderr
, "Cannot insert breakpoint %d:\n", b
->number
);
3333 memory_error (val
, b
->address
); /* which bombs us out */
3340 free_command_lines (&bpt
->commands
);
3343 if (bpt
->cond_string
!= NULL
)
3344 free (bpt
->cond_string
);
3345 if (bpt
->addr_string
!= NULL
)
3346 free (bpt
->addr_string
);
3347 if (bpt
->exp
!= NULL
)
3349 if (bpt
->exp_string
!= NULL
)
3350 free (bpt
->exp_string
);
3351 if (bpt
->val
!= NULL
)
3352 value_free (bpt
->val
);
3353 if (bpt
->source_file
!= NULL
)
3354 free (bpt
->source_file
);
3356 /* Be sure no bpstat's are pointing at it after it's been freed. */
3357 /* FIXME, how can we find all bpstat's?
3358 We just check stop_bpstat for now. */
3359 for (bs
= stop_bpstat
; bs
; bs
= bs
->next
)
3360 if (bs
->breakpoint_at
== bpt
)
3361 bs
->breakpoint_at
= NULL
;
3366 delete_command (arg
, from_tty
)
3373 /* Ask user only if there are some breakpoints to delete. */
3375 || (breakpoint_chain
&& query ("Delete all breakpoints? ")))
3377 /* No arg; clear all breakpoints. */
3378 while (breakpoint_chain
)
3379 delete_breakpoint (breakpoint_chain
);
3383 map_breakpoint_numbers (arg
, delete_breakpoint
);
3386 /* Reset a breakpoint given it's struct breakpoint * BINT.
3387 The value we return ends up being the return value from catch_errors.
3388 Unused in this case. */
3391 breakpoint_re_set_one (bint
)
3394 struct breakpoint
*b
= (struct breakpoint
*)bint
; /* get past catch_errs */
3397 struct symtabs_and_lines sals
;
3399 enum enable save_enable
;
3404 case bp_hardware_breakpoint
:
3405 if (b
->addr_string
== NULL
)
3407 /* Anything without a string can't be re-set. */
3408 delete_breakpoint (b
);
3411 /* In case we have a problem, disable this breakpoint. We'll restore
3412 its status if we succeed. */
3413 save_enable
= b
->enable
;
3414 b
->enable
= disabled
;
3416 set_language (b
->language
);
3417 input_radix
= b
->input_radix
;
3419 sals
= decode_line_1 (&s
, 1, (struct symtab
*)NULL
, 0, (char ***)NULL
);
3420 for (i
= 0; i
< sals
.nelts
; i
++)
3422 resolve_sal_pc (&sals
.sals
[i
]);
3424 /* Reparse conditions, they might contain references to the
3426 if (b
->cond_string
!= NULL
)
3430 free ((PTR
)b
->cond
);
3431 b
->cond
= parse_exp_1 (&s
, block_for_pc (sals
.sals
[i
].pc
), 0);
3434 /* We need to re-set the breakpoint if the address changes...*/
3435 if (b
->address
!= sals
.sals
[i
].pc
3436 /* ...or new and old breakpoints both have source files, and
3437 the source file name or the line number changes... */
3438 || (b
->source_file
!= NULL
3439 && sals
.sals
[i
].symtab
!= NULL
3440 && (!STREQ (b
->source_file
, sals
.sals
[i
].symtab
->filename
)
3441 || b
->line_number
!= sals
.sals
[i
].line
)
3443 /* ...or we switch between having a source file and not having
3445 || ((b
->source_file
== NULL
) != (sals
.sals
[i
].symtab
== NULL
))
3448 if (b
->source_file
!= NULL
)
3449 free (b
->source_file
);
3450 if (sals
.sals
[i
].symtab
== NULL
)
3451 b
->source_file
= NULL
;
3454 savestring (sals
.sals
[i
].symtab
->filename
,
3455 strlen (sals
.sals
[i
].symtab
->filename
));
3456 b
->line_number
= sals
.sals
[i
].line
;
3457 b
->address
= sals
.sals
[i
].pc
;
3459 check_duplicates (b
->address
);
3463 /* Might be better to do this just once per breakpoint_re_set,
3464 rather than once for every breakpoint. */
3465 breakpoints_changed ();
3467 b
->enable
= save_enable
; /* Restore it, this worked. */
3469 free ((PTR
)sals
.sals
);
3473 case bp_hardware_watchpoint
:
3474 case bp_read_watchpoint
:
3475 case bp_access_watchpoint
:
3476 innermost_block
= NULL
;
3477 /* The issue arises of what context to evaluate this in. The same
3478 one as when it was set, but what does that mean when symbols have
3479 been re-read? We could save the filename and functionname, but
3480 if the context is more local than that, the best we could do would
3481 be something like how many levels deep and which index at that
3482 particular level, but that's going to be less stable than filenames
3483 or functionnames. */
3484 /* So for now, just use a global context. */
3487 b
->exp
= parse_expression (b
->exp_string
);
3488 b
->exp_valid_block
= innermost_block
;
3489 mark
= value_mark ();
3491 value_free (b
->val
);
3492 b
->val
= evaluate_expression (b
->exp
);
3493 release_value (b
->val
);
3494 if (VALUE_LAZY (b
->val
))
3495 value_fetch_lazy (b
->val
);
3497 if (b
->cond_string
!= NULL
)
3501 free ((PTR
)b
->cond
);
3502 b
->cond
= parse_exp_1 (&s
, (struct block
*)0, 0);
3504 if (b
->enable
== enabled
)
3506 value_free_to_mark (mark
);
3510 printf_filtered ("Deleting unknown breakpoint type %d\n", b
->type
);
3512 /* Delete longjmp breakpoints, they will be reset later by
3513 breakpoint_re_set. */
3515 case bp_longjmp_resume
:
3516 delete_breakpoint (b
);
3519 /* This breakpoint is special, it's set up when the inferior
3520 starts and we really don't want to touch it. */
3521 case bp_shlib_event
:
3523 /* Keep temporary breakpoints, which can be encountered when we step
3524 over a dlopen call and SOLIB_ADD is resetting the breakpoints.
3525 Otherwise these should have been blown away via the cleanup chain
3526 or by breakpoint_init_inferior when we rerun the executable. */
3529 case bp_watchpoint_scope
:
3531 case bp_step_resume
:
3538 /* Re-set all breakpoints after symbols have been re-loaded. */
3540 breakpoint_re_set ()
3542 struct breakpoint
*b
, *temp
;
3543 enum language save_language
;
3544 int save_input_radix
;
3545 static char message1
[] = "Error in re-setting breakpoint %d:\n";
3546 char message
[sizeof (message1
) + 30 /* slop */];
3548 save_language
= current_language
->la_language
;
3549 save_input_radix
= input_radix
;
3550 ALL_BREAKPOINTS_SAFE (b
, temp
)
3552 sprintf (message
, message1
, b
->number
); /* Format possible error msg */
3553 catch_errors (breakpoint_re_set_one
, (char *) b
, message
,
3556 set_language (save_language
);
3557 input_radix
= save_input_radix
;
3559 #ifdef GET_LONGJMP_TARGET
3560 create_longjmp_breakpoint ("longjmp");
3561 create_longjmp_breakpoint ("_longjmp");
3562 create_longjmp_breakpoint ("siglongjmp");
3563 create_longjmp_breakpoint (NULL
);
3567 /* Took this out (temporarily at least), since it produces an extra
3568 blank line at startup. This messes up the gdbtests. -PB */
3569 /* Blank line to finish off all those mention() messages we just printed. */
3570 printf_filtered ("\n");
3574 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
3575 If from_tty is nonzero, it prints a message to that effect,
3576 which ends with a period (no newline). */
3579 set_ignore_count (bptnum
, count
, from_tty
)
3580 int bptnum
, count
, from_tty
;
3582 register struct breakpoint
*b
;
3588 if (b
->number
== bptnum
)
3590 b
->ignore_count
= count
;
3593 else if (count
== 0)
3594 printf_filtered ("Will stop next time breakpoint %d is reached.",
3596 else if (count
== 1)
3597 printf_filtered ("Will ignore next crossing of breakpoint %d.",
3600 printf_filtered ("Will ignore next %d crossings of breakpoint %d.",
3602 breakpoints_changed ();
3606 error ("No breakpoint number %d.", bptnum
);
3609 /* Clear the ignore counts of all breakpoints. */
3611 breakpoint_clear_ignore_counts ()
3613 struct breakpoint
*b
;
3616 b
->ignore_count
= 0;
3619 /* Command to set ignore-count of breakpoint N to COUNT. */
3622 ignore_command (args
, from_tty
)
3630 error_no_arg ("a breakpoint number");
3632 num
= get_number (&p
);
3635 error ("Second argument (specified ignore-count) is missing.");
3637 set_ignore_count (num
,
3638 longest_to_int (value_as_long (parse_and_eval (p
))),
3640 printf_filtered ("\n");
3641 breakpoints_changed ();
3644 /* Call FUNCTION on each of the breakpoints
3645 whose numbers are given in ARGS. */
3648 map_breakpoint_numbers (args
, function
)
3650 void (*function
) PARAMS ((struct breakpoint
*));
3652 register char *p
= args
;
3655 register struct breakpoint
*b
;
3658 error_no_arg ("one or more breakpoint numbers");
3664 num
= get_number (&p1
);
3667 if (b
->number
== num
)
3669 struct breakpoint
*related_breakpoint
= b
->related_breakpoint
;
3671 if (related_breakpoint
)
3672 function (related_breakpoint
);
3675 printf_unfiltered ("No breakpoint number %d.\n", num
);
3682 disable_breakpoint (bpt
)
3683 struct breakpoint
*bpt
;
3685 /* Never disable a watchpoint scope breakpoint; we want to
3686 hit them when we leave scope so we can delete both the
3687 watchpoint and its scope breakpoint at that time. */
3688 if (bpt
->type
== bp_watchpoint_scope
)
3691 bpt
->enable
= disabled
;
3693 check_duplicates (bpt
->address
);
3695 if (modify_breakpoint_hook
)
3696 modify_breakpoint_hook (bpt
);
3701 disable_command (args
, from_tty
)
3705 register struct breakpoint
*bpt
;
3707 ALL_BREAKPOINTS (bpt
)
3711 case bp_hardware_breakpoint
:
3713 case bp_hardware_watchpoint
:
3714 case bp_read_watchpoint
:
3715 case bp_access_watchpoint
:
3716 disable_breakpoint (bpt
);
3721 map_breakpoint_numbers (args
, disable_breakpoint
);
3725 do_enable_breakpoint (bpt
, disposition
)
3726 struct breakpoint
*bpt
;
3727 enum bpdisp disposition
;
3729 struct frame_info
*save_selected_frame
= NULL
;
3730 int save_selected_frame_level
= -1;
3731 int target_resources_ok
, other_type_used
;
3734 if (bpt
->type
== bp_hardware_breakpoint
)
3737 i
= hw_breakpoint_used_count();
3738 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3739 bp_hardware_breakpoint
, i
+1, 0);
3740 if (target_resources_ok
== 0)
3741 error ("No hardware breakpoint support in the target.");
3742 else if (target_resources_ok
< 0)
3743 error ("Hardware breakpoints used exceeds limit.");
3746 bpt
->enable
= enabled
;
3747 bpt
->disposition
= disposition
;
3748 check_duplicates (bpt
->address
);
3749 breakpoints_changed ();
3751 if (bpt
->type
== bp_watchpoint
|| bpt
->type
== bp_hardware_watchpoint
||
3752 bpt
->type
== bp_read_watchpoint
|| bpt
->type
== bp_access_watchpoint
)
3754 if (bpt
->exp_valid_block
!= NULL
)
3756 struct frame_info
*fr
=
3757 find_frame_addr_in_frame_chain (bpt
->watchpoint_frame
);
3761 Cannot enable watchpoint %d because the block in which its expression\n\
3762 is valid is not currently in scope.\n", bpt
->number
);
3763 bpt
->enable
= disabled
;
3767 save_selected_frame
= selected_frame
;
3768 save_selected_frame_level
= selected_frame_level
;
3769 select_frame (fr
, -1);
3772 value_free (bpt
->val
);
3773 mark
= value_mark ();
3774 bpt
->val
= evaluate_expression (bpt
->exp
);
3775 release_value (bpt
->val
);
3776 if (VALUE_LAZY (bpt
->val
))
3777 value_fetch_lazy (bpt
->val
);
3779 if (bpt
->type
== bp_hardware_watchpoint
||
3780 bpt
->type
== bp_read_watchpoint
||
3781 bpt
->type
== bp_access_watchpoint
)
3783 int i
= hw_watchpoint_used_count (bpt
->type
, &other_type_used
);
3784 int mem_cnt
= can_use_hardware_watchpoint (bpt
->val
);
3786 target_resources_ok
= TARGET_CAN_USE_HARDWARE_WATCHPOINT(
3787 bpt
->type
, i
+ mem_cnt
, other_type_used
);
3788 /* we can consider of type is bp_hardware_watchpoint, convert to
3789 bp_watchpoint in the following condition */
3790 if (target_resources_ok
< 0)
3793 Cannot enable watchpoint %d because target watch resources\n\
3794 have been allocated for other watchpoints.\n", bpt
->number
);
3795 bpt
->enable
= disabled
;
3796 value_free_to_mark (mark
);
3801 if (save_selected_frame_level
>= 0)
3802 select_frame (save_selected_frame
, save_selected_frame_level
);
3803 value_free_to_mark (mark
);
3805 if (modify_breakpoint_hook
)
3806 modify_breakpoint_hook (bpt
);
3810 enable_breakpoint (bpt
)
3811 struct breakpoint
*bpt
;
3813 do_enable_breakpoint (bpt
, donttouch
);
3816 /* The enable command enables the specified breakpoints (or all defined
3817 breakpoints) so they once again become (or continue to be) effective
3818 in stopping the inferior. */
3822 enable_command (args
, from_tty
)
3826 register struct breakpoint
*bpt
;
3828 ALL_BREAKPOINTS (bpt
)
3832 case bp_hardware_breakpoint
:
3834 case bp_hardware_watchpoint
:
3835 case bp_read_watchpoint
:
3836 case bp_access_watchpoint
:
3837 enable_breakpoint (bpt
);
3842 map_breakpoint_numbers (args
, enable_breakpoint
);
3846 enable_once_breakpoint (bpt
)
3847 struct breakpoint
*bpt
;
3849 do_enable_breakpoint (bpt
, disable
);
3854 enable_once_command (args
, from_tty
)
3858 map_breakpoint_numbers (args
, enable_once_breakpoint
);
3862 enable_delete_breakpoint (bpt
)
3863 struct breakpoint
*bpt
;
3865 do_enable_breakpoint (bpt
, del
);
3870 enable_delete_command (args
, from_tty
)
3874 map_breakpoint_numbers (args
, enable_delete_breakpoint
);
3877 /* Use default_breakpoint_'s, or nothing if they aren't valid. */
3879 struct symtabs_and_lines
3880 decode_line_spec_1 (string
, funfirstline
)
3884 struct symtabs_and_lines sals
;
3886 error ("Empty line specification.");
3887 if (default_breakpoint_valid
)
3888 sals
= decode_line_1 (&string
, funfirstline
,
3889 default_breakpoint_symtab
, default_breakpoint_line
,
3892 sals
= decode_line_1 (&string
, funfirstline
,
3893 (struct symtab
*)NULL
, 0, (char ***)NULL
);
3895 error ("Junk at end of line specification: %s", string
);
3900 _initialize_breakpoint ()
3902 breakpoint_chain
= 0;
3903 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
3904 before a breakpoint is set. */
3905 breakpoint_count
= 0;
3907 add_com ("ignore", class_breakpoint
, ignore_command
,
3908 "Set ignore-count of breakpoint number N to COUNT.\n\
3909 Usage is `ignore N COUNT'.");
3911 add_com ("commands", class_breakpoint
, commands_command
,
3912 "Set commands to be executed when a breakpoint is hit.\n\
3913 Give breakpoint number as argument after \"commands\".\n\
3914 With no argument, the targeted breakpoint is the last one set.\n\
3915 The commands themselves follow starting on the next line.\n\
3916 Type a line containing \"end\" to indicate the end of them.\n\
3917 Give \"silent\" as the first line to make the breakpoint silent;\n\
3918 then no output is printed when it is hit, except what the commands print.");
3920 add_com ("condition", class_breakpoint
, condition_command
,
3921 "Specify breakpoint number N to break only if COND is true.\n\
3922 Usage is `condition N COND', where N is an integer and COND is an\n\
3923 expression to be evaluated whenever breakpoint N is reached. ");
3925 add_com ("tbreak", class_breakpoint
, tbreak_command
,
3926 "Set a temporary breakpoint. Args like \"break\" command.\n\
3927 Like \"break\" except the breakpoint is only temporary,\n\
3928 so it will be deleted when hit. Equivalent to \"break\" followed\n\
3929 by using \"enable delete\" on the breakpoint number.");
3931 add_com ("hbreak", class_breakpoint
, hbreak_command
,
3932 "Set a hardware assisted breakpoint. Args like \"break\" command.\n\
3933 Like \"break\" except the breakpoint requires hardware support,\n\
3934 some target hardware may not have this support.");
3936 add_com ("thbreak", class_breakpoint
, thbreak_command
,
3937 "Set a temporary hardware assisted breakpoint. Args like \"break\" command.\n\
3938 Like \"hbreak\" except the breakpoint is only temporary,\n\
3939 so it will be deleted when hit.");
3941 add_prefix_cmd ("enable", class_breakpoint
, enable_command
,
3942 "Enable some breakpoints.\n\
3943 Give breakpoint numbers (separated by spaces) as arguments.\n\
3944 With no subcommand, breakpoints are enabled until you command otherwise.\n\
3945 This is used to cancel the effect of the \"disable\" command.\n\
3946 With a subcommand you can enable temporarily.",
3947 &enablelist
, "enable ", 1, &cmdlist
);
3949 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint
, enable_command
,
3950 "Enable some breakpoints.\n\
3951 Give breakpoint numbers (separated by spaces) as arguments.\n\
3952 This is used to cancel the effect of the \"disable\" command.\n\
3953 May be abbreviated to simply \"enable\".\n",
3954 &enablebreaklist
, "enable breakpoints ", 1, &enablelist
);
3956 add_cmd ("once", no_class
, enable_once_command
,
3957 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3958 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3961 add_cmd ("delete", no_class
, enable_delete_command
,
3962 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3963 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3966 add_cmd ("delete", no_class
, enable_delete_command
,
3967 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
3968 If a breakpoint is hit while enabled in this fashion, it is deleted.",
3971 add_cmd ("once", no_class
, enable_once_command
,
3972 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
3973 If a breakpoint is hit while enabled in this fashion, it becomes disabled.",
3976 add_prefix_cmd ("disable", class_breakpoint
, disable_command
,
3977 "Disable some breakpoints.\n\
3978 Arguments are breakpoint numbers with spaces in between.\n\
3979 To disable all breakpoints, give no argument.\n\
3980 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
3981 &disablelist
, "disable ", 1, &cmdlist
);
3982 add_com_alias ("dis", "disable", class_breakpoint
, 1);
3983 add_com_alias ("disa", "disable", class_breakpoint
, 1);
3985 add_cmd ("breakpoints", class_alias
, disable_command
,
3986 "Disable some breakpoints.\n\
3987 Arguments are breakpoint numbers with spaces in between.\n\
3988 To disable all breakpoints, give no argument.\n\
3989 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
3990 This command may be abbreviated \"disable\".",
3993 add_prefix_cmd ("delete", class_breakpoint
, delete_command
,
3994 "Delete some breakpoints or auto-display expressions.\n\
3995 Arguments are breakpoint numbers with spaces in between.\n\
3996 To delete all breakpoints, give no argument.\n\
3998 Also a prefix command for deletion of other GDB objects.\n\
3999 The \"unset\" command is also an alias for \"delete\".",
4000 &deletelist
, "delete ", 1, &cmdlist
);
4001 add_com_alias ("d", "delete", class_breakpoint
, 1);
4003 add_cmd ("breakpoints", class_alias
, delete_command
,
4004 "Delete some breakpoints or auto-display expressions.\n\
4005 Arguments are breakpoint numbers with spaces in between.\n\
4006 To delete all breakpoints, give no argument.\n\
4007 This command may be abbreviated \"delete\".",
4010 add_com ("clear", class_breakpoint
, clear_command
,
4011 concat ("Clear breakpoint at specified line or function.\n\
4012 Argument may be line number, function name, or \"*\" and an address.\n\
4013 If line number is specified, all breakpoints in that line are cleared.\n\
4014 If function is specified, breakpoints at beginning of function are cleared.\n\
4015 If an address is specified, breakpoints at that address are cleared.\n\n",
4016 "With no argument, clears all breakpoints in the line that the selected frame\n\
4019 See also the \"delete\" command which clears breakpoints by number.", NULL
));
4021 add_com ("break", class_breakpoint
, break_command
,
4022 concat ("Set breakpoint at specified line or function.\n\
4023 Argument may be line number, function name, or \"*\" and an address.\n\
4024 If line number is specified, break at start of code for that line.\n\
4025 If function is specified, break at start of code for that function.\n\
4026 If an address is specified, break at that exact address.\n",
4027 "With no arg, uses current execution address of selected stack frame.\n\
4028 This is useful for breaking on return to a stack frame.\n\
4030 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
4032 Do \"help breakpoints\" for info on other commands dealing with breakpoints.", NULL
));
4033 add_com_alias ("b", "break", class_run
, 1);
4034 add_com_alias ("br", "break", class_run
, 1);
4035 add_com_alias ("bre", "break", class_run
, 1);
4036 add_com_alias ("brea", "break", class_run
, 1);
4038 add_info ("breakpoints", breakpoints_info
,
4039 concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\
4040 The \"Type\" column indicates one of:\n\
4041 \tbreakpoint - normal breakpoint\n\
4042 \twatchpoint - watchpoint\n\
4043 The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
4044 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
4045 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
4046 address and file/line number respectively.\n\n",
4047 "Convenience variable \"$_\" and default examine address for \"x\"\n\
4048 are set to the address of the last breakpoint listed.\n\n\
4049 Convenience variable \"$bpnum\" contains the number of the last\n\
4050 breakpoint set.", NULL
));
4052 #if MAINTENANCE_CMDS
4054 add_cmd ("breakpoints", class_maintenance
, maintenance_info_breakpoints
,
4055 concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\
4056 The \"Type\" column indicates one of:\n\
4057 \tbreakpoint - normal breakpoint\n\
4058 \twatchpoint - watchpoint\n\
4059 \tlongjmp - internal breakpoint used to step through longjmp()\n\
4060 \tlongjmp resume - internal breakpoint at the target of longjmp()\n\
4061 \tuntil - internal breakpoint used by the \"until\" command\n\
4062 \tfinish - internal breakpoint used by the \"finish\" command\n",
4063 "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\
4064 the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\
4065 breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\
4066 address and file/line number respectively.\n\n",
4067 "Convenience variable \"$_\" and default examine address for \"x\"\n\
4068 are set to the address of the last breakpoint listed.\n\n\
4069 Convenience variable \"$bpnum\" contains the number of the last\n\
4070 breakpoint set.", NULL
),
4071 &maintenanceinfolist
);
4073 #endif /* MAINTENANCE_CMDS */
4075 add_com ("catch", class_breakpoint
, catch_command
,
4076 "Set breakpoints to catch exceptions that are raised.\n\
4077 Argument may be a single exception to catch, multiple exceptions\n\
4078 to catch, or the default exception \"default\". If no arguments\n\
4079 are given, breakpoints are set at all exception handlers catch clauses\n\
4080 within the current scope.\n\
4082 A condition specified for the catch applies to all breakpoints set\n\
4083 with this command\n\
4085 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
4087 add_com ("watch", class_breakpoint
, watch_command
,
4088 "Set a watchpoint for an expression.\n\
4089 A watchpoint stops execution of your program whenever the value of\n\
4090 an expression changes.");
4092 add_com ("rwatch", class_breakpoint
, rwatch_command
,
4093 "Set a read watchpoint for an expression.\n\
4094 A watchpoint stops execution of your program whenever the value of\n\
4095 an expression is read.");
4097 add_com ("awatch", class_breakpoint
, awatch_command
,
4098 "Set a watchpoint for an expression.\n\
4099 A watchpoint stops execution of your program whenever the value of\n\
4100 an expression is either read or written.");
4102 add_info ("watchpoints", breakpoints_info
,
4103 "Synonym for ``info breakpoints''.");