Debugging with GDB (February 2008)

Table Of Contents
64 Debugging with GDB
@ @ is a binary operator for treating parts of memory as arrays. Refer to See
Section 8.3 [Artificial arrays], page 65, for more information.
:: :: allows you to specify a variable in terms of the file or function where it is
defined. See Section 8.2 [Program variables], page 64.
{type } addr
Refers to an object of type type stored at address addr in memory. addr may
be any expression whose value is an integer or pointer (but parentheses are
required around binary operators, just as in a cast). This construct is allowed
regardless of what kind of data is normally supposed to reside at addr.
8.2 Program variables
The most common kind of expression to use is the name of a variable in your program.
Variables in expressions are understood in the selected stack frame (see Section 6.5
[Selecting a frame], page 53); they must be either:
global (or file-static)
or
visible according to the scope rules of the programming language from the point of
execution in that frame
This means that in the function
foo (a)
int a;
{
bar (a);
{
int b = test ();
bar (b);
}
}
you can examine and use the variable a whenever your program is executing within the
function foo, but you can only use or examine the variable b while your program is executing
inside the block where b is declared.
However, you can refer to a variable or function whose scope is a single source file even if
the current execution point is not in this file. But it is possible to have more than one such
variable or function with the same name (in different source files). If that happens, referring
to that name has unpredictable effects. If you wish, you can specify a static variable in a
particular function or file, using the colon-colon notation:
file ::variable
function ::variable
Here file or function is the name of the context for the static variable. In the case of file
names, you can use quotes to make sure GDB parses the file name as a single word. For
example, to print a global value of x defined in f2.c’: