p *array@len
The left operand of '@' must reside in memory. Array values made with '@' in this way behave just like other arrays in terms of subscripting, and are coerced to pointers when used in expressions. Artificial arrays most often appear in expressions via the value history (see “Value history” (page 95)), after printing one out.
Another way to create an artificial array is to use a cast. This
((gdb)) p/x (short[2])0x12345678 $1 = {0x1234, 0x5678}
As a convenience, if you leave the array length out (as in '(type[])value'), GDB calculates the size to fill the value (as 'sizeof(value)/sizeof(type)':
((gdb)) p/x (short[])0x12345678 $2 = {0x1234, 0x5678}
Sometimes the artificial array mechanism is not quite enough; in moderately complex data structures, the elements of interest may not actually be adjacent―for example, if you are interested in the values of pointers in an array. One useful
set $i = 0
p
<RET>
...
8.4Output formats
By default, GDB prints a value according to its data type. 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 as an instruction. To do these things, specify an output format when you print a value.
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:
xRegard the bits of the value as an integer, and print the integer in hexadecimal.
dPrint as integer in signed decimal.
uPrint as integer in unsigned decimal.
oPrint as integer in octal.
86 Examining Data