If you have a pointer and you are not sure where it points, try 'set print symbol-filename on'. Then you can determine the name and source file location of the variable where it points, using 'p/a pointer'. This interprets the address in symbolic form. For example, here GDB shows that a variable ptt points at another variable t, defined in 'hi2.c':

((gdb)) set print symbol-filename on

((gdb)) p/a ptt

$4 = 0xe008 <t in hi2.c>

WARNING! For pointers that point to a local variable, 'p/a' does not show the symbol name and filename of the referent, even with the appropriate set print options turned on.

Other settings to control how different kinds of objects are printed:

set print array, set print

Pretty print arrays. This format is more

array on

convenient to read, but uses more space. The

 

default is off.

set print array off

Return to compressed format for arrays.

show print array

Show whether compressed or pretty format is

 

selected for displaying arrays.

set print elements

Set a limit on how many elements of an array

number-of-elements

GDB will print. If GDB is printing a large array,

 

it stops printing after it has printed the number

 

of elements set by the set print elements

 

command. This limit also applies to the display

 

of strings. When GDB starts, this limit is set to

 

200. Setting number-of-elementsto zero

 

means that the printing is unlimited.

show print elements

Display the number of elements of a large array

 

that GDB will print. If the number is 0, then the

 

printing is unlimited.

set print null-stop

Cause GDB to stop printing the characters of an

 

array when the first NULL is encountered. This

 

is useful when large arrays actually contain only

 

short strings. The default is off.

set print pretty on

Cause GDB to print structures in an indented

 

format with one member per line, like this:

 

$1 = {

 

next = 0x0,

 

flags = {

 

sweet = 1,

 

sour = 1

92 Examining Data