27.6.5.7 Watch Expressions

If you want to see how a variable changes each time your program
stops, move point into the variable name and click on the watch icon
in the tool bar (gud-watch) or type C-x C-a C-w. If you
specify a prefix argument, you can enter the variable name in the
minibuffer.

Each watch expression is displayed in the speedbar
(see Speedbar). Complex data types, such as arrays, structures
and unions are represented in a tree format. Leaves and simple data
types show the name of the expression and its value and, when the
speedbar frame is selected, display the type as a tooltip. Higher
levels show the name, type and address value for pointers and just the
name and type otherwise. Root expressions also display the frame
address as a tooltip to help identify the frame in which they were
defined.

To expand or contract a complex data type, click Mouse-2 or
press SPC on the tag to the left of the expression. Emacs asks
for confirmation before expanding the expression if its number of
immediate children exceeds the value of the variable
gdb-max-children.

To delete a complex watch expression, move point to the root
expression in the speedbar and type D (gdb-var-delete).

To edit a variable with a simple data type, or a simple element of a
complex data type, move point there in the speedbar and type RET
(gdb-edit-value). Or you can click Mouse-2 on a value to
edit it. Either way, this reads the new value using the minibuffer.

If you set the variable gdb-show-changed-values to
non-nil (the default value), Emacs uses
font-lock-warning-face to highlight values that have recently
changed and shadow face to make variables which have gone out of
scope less noticeable. When a variable goes out of scope you can’t
edit its value.

If the variable gdb-delete-out-of-scope is non-nil
(the default value), Emacs automatically deletes watch expressions
which go out of scope. Sometimes, when re-entering the same function,
it may be useful to set this value to nil so that you don’t
need to recreate the watch expression.

If the variable gdb-use-colon-colon-notation is
non-nil, Emacs uses the ‘function::variable’
format. This allows the user to display watch expressions which share
the same variable name. The default value is nil.

To automatically raise the speedbar every time the display of watch
expressions updates, set gdb-speedbar-auto-raise to
non-nil. This can be useful if you are debugging with a full
screen Emacs frame.