Output Formats

The print, rprint, and display commands and the $[] construct take a flag (-f or -F (see also print Command) that sets the output format for integer, string, or floating point types. This format is used when dbx is about to print an integer (long or short), string (char * or wchar_t *), or floating-point (float, double, long double) expression. That is, the expression itself may be a structure or array; each integer, string, or floating-point member will be printed using the given format, if applicable. If the format does not apply to the given type, the format string is silently ignored and dbx uses its built-in printing mechanism.

The allowed formats are a subset of those used by printf(3S). The following restrictions apply:

The allowed forms are defined by the following simple grammar:

FORMAT  ::=  CHARS % FLAGS WIDTH PREC MOD SPEC CHARS
CHARS ::= <any character sequence not containing a %>
        | %%
        |    <empty>
        | CHARS CHARS
FLAGS ::= + | - | <space> | # | 0 | <empty>
WIDTH ::= <decimal_number> | <empty>
PREC ::= . | . <decimal_number> | <empty>
MOD ::= h | l | L | ll | <empty>
SPEC ::= d | i | o | u | x | X | f | e | E | g | G |
                 c | wc | s | ws | p

If the given format string does not contain a %, dbx automatically prepends one. If the format string contains spaces, semicolons, or tabs, the entire format string must be surrounded by double quotes.

Examples

(dbx) print i
i = 31
(dbx) print -fx i ;# the format string may be concatenated with the -f
i = 1f
(dbx) print -f 0x%12.12X 1234
0x0000000004D2
(dbx) print -f "The value of 0x1000 is %o in octal" 0x1000
The value of 0x1000 is 10000 in octal
(dbx) print x/10.0 ;# compare with following
x/10 = 12.3
(dbx) print -F"10%% of x is %.2e" x/10.0;# suppress printing of left
                                         # side
10% of x is 1.23e+01
(dbx) print -fx struct1 ;# it even applies to members...
struct1 = {
   x = 7b
}