print

Print the value of an expression.

Syntax

GDB Mode:

print [/format] [expr]

IDB Mode:

printradix  expr[,...]
print printable_type

Parameters

format

GDB Mode:

Specifies the format in which to print the expression. Use one of the following values:

x

Regard the bits of the value as an integer, and print the integer in hexadecimal.

d

Print as integer in signed decimal.

u

Print as integer in unsigned decimal.

o

Print as integer in octal.

t

Print as integer in binary. The letter t stands for two.

a

Print as an address, both absolute in hexadecimal and as an offset from the nearest preceding symbol.

c

Regard as an integer and print it as a character constant.

f

Regard the bits of the value as a floating-point number and print using typical floating point syntax.

expr

The expression to print.

Expressions in the debugger are valid expressions in the language in which your program is written.

The debugger attempts to duplicate the standard language semantics for expressions.

An expression can include a qualifier and a tick mark, which can help identify ambiguous expressions. For example, if both a.cxx and b.cxx inlcude a file level variable, x, you can use the syntax "a.cxx"x to specify the variable x in a.cxx. Use the same syntax to specify object hierarchy.

IDB Mode:

Use commas to separate multiple expressions.

To print an expression including the C/C++ comma operator, you must enclose the expression in parentheses.

radix

IDB Mode:

x

Regard the bits of the value as an integer, and print the integer in hexadecimal.

d

Print as integer in signed decimal.

o

Print as integer in octal.

b

Print as integer in binary.

filename

IDB Mode:

The name of the file containing the expression to print.

printable_type

IDB Mode:

A user-defined type for which you have debug information.

Description

This command prints the value of an expression. You can print the values of one or more expressions or all local variables. You can also use the print command to evaluate complex expressions involving typecasts, pointer dereferences, multiple variables, constants, and any legal operators allowed by the language of the program you are debugging.

For an array, the debugger prints every cell in the array if you do not specify a specific cell.

GDB Mode:

Use the set output-radix x command to select a radix for the output of the print command, where x can be 8, 10 or 16.

IDB Mode:

Use the $hexints, $decints, or $octints variables to select a radix for the output of the print command. If you do not want to change the radix permanently, use the printx, printd, printo, and printb commands to print expressions in hexadecimal, decimal, octal, or binary base format, respectively.

Note iconNote

Only signed characters are printed as string.

Example

Consider the following declarations in a C++ program:

GDB Mode:

(idb) list 59,+2
59 const unsigned int biggestCount = 10; 
60 static Moon *biggestMoons[biggestCount]; 

IDB Mode:

(idb) list 59:2
59 const unsigned int biggestCount = 10; 
60 static Moon *biggestMoons[biggestCount]; 

The following example uses the print command to display a non-string array:

GDB Mode:

(idb) print biggestMoons
$4 = {0x8067998, 0x8067cb0, 0x80679f0, 0x80678e8, 0x8067730, 0x8067940, 0x8068020, 0x8067f18, 0x8067c58, 0x8067f70} 

IDB Mode:

(idb) print biggestMoons
[0] = 0x8067998,[1] = 0x8067cb0,[2] = 0x80679f0,[3] = 0x80678e8,[4] = 0x8067730,[5] = 0x8067940,[6] = 0x8068020,[7] = 0x8067f18,[8] = 0x8067c58,[9] = 0x8067f70 

The following example shows how to print individual values of an array:

GDB Mode:

(idb) print biggestMoons[3]
$7 = (Moon *) 0x80678e8 
(idb) print *biggestMoons[3]
$8 = {<Planet> = {<HeavenlyBody> = {_name = 0x805a514 "Io", _innerNeighbor = 0x0, _outerNeighbor = 0x8067940, _firstSatellite = 0x0, _lastSatellite = 0x0}, <Orbit> = {_primary = 0x8067890, _distance = 422, _name = 0x8067918 "Jupiter 1"}}, _radius = 1815} 

IDB Mode:

(idb) print biggestMoons[3]
0x80678e8 
(idb) print *biggestMoons[3]
class Moon { 
_radius = 1815; 
_name = 0x805a514="Io"; // class Planet::HeavenlyBody 
_innerNeighbor = 0x0; // class Planet::HeavenlyBody 
_outerNeighbor = 0x8067940; // class Planet::HeavenlyBody 
_firstSatellite = 0x0; // class Planet::HeavenlyBody 
_lastSatellite = 0x0; // class Planet::HeavenlyBody 
_primary = 0x8067890; // class Planet::Orbit 
_distance = 422; // class Planet::Orbit 
_name = 0x8067918="Jupiter 1"; // class Planet::Orbit 

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.