Chapter Contents

Previous

Next
Command Directory

print

Print the Value of an Expression

ABBREVIATION
p{rint}

FORMATS

Format 1: print

Format 2: print
EXPRESSION
Format 3: print
EXPRESSION [%FMT] [COUNT] [,EXPRESSION [%FMT ] [COUNT] ]

DESCRIPTION
The print command prints the value of various program elements. The specific elements printed depend on the format of the print command that you use.

Format 1: With Format 1, what is printed depends on where execution is interrupted when you issue print, as shown in Output from the print Command with No Arguments.

The left column in the table describes different places in a program where execution can be interrupted. The right column gives the output of Format 1 for each location.

Output from the print Command with No Arguments
Where Execution Stopped What Is Printed
calls from a function (calling function context) the parameters as viewed by the called function
entry to a called function (called function context) the parameters as viewed by the called function
normal return to a function (calling or called function context) the return value
longjmp from a function (The context is that of the function you are jumping from.) the value of the argument to longjmp
line-number hook all automatic scalars of the function in scope

Format 2: This format of the print command displays the value of the expression identifier. The value is displayed according to its type, as declared in the source code. If the EXPRESSION contains a modulus ( % ) operator, see Format 3.

When you issue Format 2 of the print command, the value of EXPRESSION is printed according to its type shown in Output Format for Values of Expressions Using the print Command.

Output Format for Values of Expressions Using the print Command
Type
Print Output Format
1 arithmetic char type: the hexadecimal value is always printed. If printable, the value is printed as is. If not printable and if the value is an escape character, the escape sequence is shown. If the value is not an escape character, only the hexadecimal value is shown.

Types other than char: the value is printed in decimal and hexadecimal format. float and double types are printed in the most appropriate form, as determined by the rules for the g format used by the printf, sprintf, and fprintf functions.

enum variable: The value is printed in decimal. The enumeration constant symbol is printed in parentheses following the value.

2 pointer The value is printed as eight hexadecimal digits with leading 0p.
3 structurer, union, or class All members are printed according to their declared type: types 1, 2, or 7. (Arrays, structures, classes, and unions contained in the structure are fully expanded to show the values of their members.) The address of a structure or union is printed also.
4 array The address of the array is printed as eight hexadecimal digits with leading 0p.
5 The address is printed as eight hexadecimal digits with leading 0p. An address cannot be monitored. Storage at an address, however, can be monitored. For example, monitor *0p12345678 20 monitors 20 bytes of storage, starting at the address 0p12345678.
6 enum constant The value of the constant is printed in decimal digits.
7 bitfield The value of a bitfield is printed in both binary and decimal formats. If the number of bits in the bitfield is a multiple of eight, then the value of the bitfield is also printed in hexadecimal format.
8 function A function cannot be printed. However, indirection through a function pointer is supported and prints the function name, section name, and, if located in a different load module, the load module name.

Format 3: Format 3 prints the value of the expression (or expressions) identified by EXPRESSION. COUNT specifies the number of values to be printed. If the EXPRESSION argument contains a modulus (%) operator, you must escape the operator with a backslash (\); otherwise, the debugger interprets the modulus operator as a format specifier.

The %FMT argument can be any of the format specifiers that you use with the sprintf function. These are
c single character
d decimal signed integer
e or E exponential floating point
f fixed decimal floating point
g or G f format or e format
o octal integer
s character string
u decimal unsigned integer
x hexadecimal integer (lowercase)
X hexadecimal integer (uppercase)

The print command supports any % format specification that results in the item being formatted in 256 or fewer bytes. If the %FMT argument is not specified, the debugger uses a format determined by the type of the expression (as in Format 2).

COUNT is an integer that specifies the number of items to be printed. If not specified, COUNT defaults to 1.

If more than one EXPRESSION is specified, any (or all) of the %FM and COUNT arguments can be used for each value to be printed. Each EXPRESSION argument and its list of associated %FMT and COUNT arguments (if any) are separated by a comma from the next EXPRESSION argument and its list of %FMT and COUNT arguments.

EXAMPLES
The debugger print command examples are based on the following declarations:
   int i;  double d;
   struct XYZ {int a; double b; } xyz;
   struct INT2 {int a,b;} int2;
   struct XYZ * pxyz;
   int arr[10] ;

print i
displays the value of i .

print i, d
displays the values of i and d .

print i + d
displays the value of i plus d .

print xyz.a
displays the value of xyz.a .

print pxyz --> b
displays pxyz --> b .

print arr[i]
displays the ith element of the arr array.

print *(arr+i) + int2.a
displays the value of the sum of the ith element of arr plus the value of member a in struct int2 .

print *arr 5
displays first 5 elements in arr .

print ::xyz
allows the file scope variable to be accessed in any command that supports expressions by using the C++ unary operator ::.

SYSTEM DEPENDENCIES
none

SCOPE
The print command uses command scope to resolve references to all identifiers.

RETURN CODES SET
Successful: 0
Unsuccessful: 1

SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.