next up previous

Imprimer les variables

The usual way of examining data in your program is with the `print'
command (abbreviated `p').  It evaluates and prints the value of any
valid expression of the language the program is written in (for now, C).
You type

     print EXP

where EXP is any valid expression, and the value of EXP
is printed in a format appropriate to its data type.


GDB normally prints all values according to their data types.  Sometimes
this is not what you want.  For example, you might want to print a number
in hex, or a pointer in decimal.  Or you might want to view data in memory
at a certain address as a character string or an instruction.  These things
can be done with "output formats".

The simplest use of output formats is to say how to print a value
already computed.  This is done by starting the arguments of the
`print' command with a slash and a format letter.  The format
letters supported are:

     Regard the bits of the value as an integer, and print the integer in
     Print as integer in signed decimal.
     Print as integer in unsigned decimal.
     Print as integer in octal.
     Print as an address, both absolute in hex and then relative
     to a symbol defined as an address below it.
     Regard as an integer and print it as a character constant.
     Regard the bits of the value as a floating point number and print
     using typical floating point syntax.

For example, to print the program counter in hex (*Note Registers::), type

     p/x $pc

Note that no space is required before the slash; this is because command
names in GDB cannot contain a slash.

To reprint the last value in the value history with a different format,
you can use the `print' command with just a format and no
expression.  For example, `p/x' reprints the last value in hex.