Examining data

The usual way to examine data in your program is with the print (p) command or its synonym inspect. It evaluates and prints the value of an expression of the language your program is written in.

print exp or print / f exp
exp is an expression (in the source language). By default, the value of exp is printed in a format appropriate to its data type; you can choose a different format by specifying / f, where f is a letter specifying the format; see "Output formats."
print or print / f
If you omit exp, GDB displays the last value again (from the value history; see "Value history"). This lets you conveniently inspect the same value in an alternative format.

A lower-level way of examining data is with the x command. It examines data in memory at a specified address and prints it in a specified format. See "Examining memory."

If you're interested in information about types, or about how the fields of a structure or class are declared, use the ptype exp command rather than print. See "Examining the symbol table."