Next: Break Commands, Previous: Set Breaks, Up: Breakpoints [Contents][Index]
You can use a watchpoint to stop execution whenever the value of an
expression changes, without having to predict a particular place where
this may happen. As with the print (see Examining
Data), the idiosyncrasies of a BASH or any POSIX shell
derivative suggest using two commands. The watch command is
just for a single variables; the watche command uses the
builtin “let” command to evaluate an expression. If the variable you
are tracking can take a string value, issuing something like
‘watch foo’ will not have the desired effect—any string
assignment to foo will have a value 0 when it is assigned via
“let.”
watch varSet a watchpoint for a variable. the BASH debugger will break when the value of var changes. In this command do not add a leading dollar symbol to var.
watche exprSet a watchpoint for an expression via the builtin “let” command.
the BASH debugger will break when expr is written into by the program
and its value changes. Not that this may not work for tracking
arbitrary string value changes. For that use watch described
earlier.