Next: Ambiguous Expressions, Up: Data
print
and many other gdb commands accept an expression and
compute its value. Any kind of constant, variable or operator defined
by the programming language you are using is valid in an expression in
gdb. This includes conditional expressions, function calls,
casts, and string constants. It also includes preprocessor macros, if
you compiled your program to include this information; see
Compilation.
gdb supports array constants in expressions input by
the user. The syntax is {element, element...}. For example,
you can use the command print {1, 2, 3}
to create an array
of three integers. If you pass an array to a function or assign it
to a program variable, gdb copies the array to memory that
is malloc
ed in the target program.
Because C is so widespread, most of the expressions shown in examples in this manual are in C. See Using gdb with Different Languages, for information on how to use expressions in other languages.
In this section, we discuss operators that you can use in gdb expressions regardless of your programming language.
Casts are supported in all languages, not just in C, because it is so useful to cast a number into a pointer in order to examine a structure at that address in memory.
gdb supports these operators, in addition to those common to programming languages:
@
::
{
type}
addr