Conversion Formats
Each conversion character sequence results in fetching zero or more arguments. If insufficient arguments are provided for the format string, or if the format string is exhausted and arguments remain, the D compiler issues an appropriate error message. If an undefined conversion format is specified, the D compiler issues an appropriate error message. The following conversion character sequences are available:
-
a
-
The pointer or
uintptr_t
argument is printed as a kernel symbol name in the form module`symbol-name plus an optional hexadecimal byte offset. If the value does not fall within the range defined by a known kernel symbol, the value is printed as a hexadecimal integer. -
A
-
A
is similar to%a
, but for user addresses. The exact behaviour is determined by theuresolve
option. For more information, see DTrace User Address Symbol Resolution. -
c
-
The
char
,short
, orint
argument is printed as an ASCII character. -
C
-
The
char
,short
, orint
argument is printed as an ASCII character if the character is a printable ASCII character. If the character is not a printable character, it is printed using the corresponding escape sequence as shown in D Character Escape Sequences. -
d
-
The
char
,short
,int
,long
, orlong long
argument is printed as a decimal (base 10) integer. If the argument issigned
, it will be printed as a signed value. If the argument isunsigned
, it will be printed as an unsigned value. This conversion has the same meaning asi
. -
e
,E
-
The
float
,double
, orlong double
argument is converted to the style [-]d.ddde+/-dd, where there is one digit before the radix character and the number of digits after it is equal to the precision. The radix character is non-zero if the argument is non-zero. If the precision is not specified, the default precision value is 6. If the precision is 0 and the#
flag is not specified, no radix character appears. TheE
conversion format produces a number withE
instead ofe
introducing the exponent. The exponent always contains at least two digits. The value is rounded up to the appropriate number of digits. -
f
-
The
float
,double
, orlong double
argument is converted to the style [-]ddd.ddd, where the number of digits after the radix character is equal to the precision specification. If the precision is not specified, the default precision value is 6. If the precision is0
and the#
flag is not specified, no radix character appears. If a radix character appears, at least one digit appears before it. The value is rounded up to the appropriate number of digits. -
g
,G
-
The
float
,double
, orlong double
argument is printed in the stylef
ore
(or in styleE
in the case of aG
conversion character), with the precision specifying the number of significant digits. If an explicit precision is 0, it is taken as 1. The style used depends on the value converted: stylee
(orE
) is used only if the exponent resulting from the conversion is less than -4 or greater than or equal to the precision. Trailing zeroes are removed from the fractional part of the result. A radix character appears only if it is followed by a digit. If the#
flag is specified, trailing zeroes are not removed from the result. -
i
-
The
char
,short
,int
,long
, orlong long
argument is printed as a decimal (base 10) integer. If the argument issigned
, it will be printed as a signed value. If the argument isunsigned
, it will be printed as an unsigned value. This conversion has the same meaning asd
. -
k
-
The
stack
argument is printed as if by a call totrace
(). Handles both user and kernel-level stacks. Valid only withprinta
() because, according to the D compiler,stack
() andustack
() may not be called from a D expression (D program context required). - o
-
The
char
,short
,int
,long
, orlong long
argument is printed as an unsigned octal (base 8) integer. Arguments that aresigned
orunsigned
may be used with this conversion. If the#
flag is specified, the precision of the result will be increased if necessary to force the first digit of the result to be a zero. -
p
-
The pointer or
uintptr_t
argument is printed as a hexadecimal (base 16) integer. D accepts pointer arguments of any type. If the#
flag is specified, a non-zero result will have0x
prepended to it. -
s
-
The argument must be an array of
char
or astring
. Bytes from the array orstring
are read up to a terminating null character or the end of the data and interpreted and printed as ASCII characters. If the precision is not specified, it is taken to be infinite, so all characters up to the first null character are printed. If the precision is specified, only that portion of the character array that will display in the corresponding number of screen columns is printed. If an argument of typechar *
is to be formatted, it should be cast tostring
or prefixed with the Dstringof
operator to indicate that DTrace should trace the bytes of the string and format them. - S
-
The argument must be an array of
char
or astring
. The argument is processed as if by the%s
conversion, but any ASCII characters that are not printable are replaced by the corresponding escape sequence described in D Character Escape Sequences. - u
-
The
char
,short
,int
,long
, orlong long
argument is printed as an unsigned decimal (base 10) integer. Arguments that aresigned
orunsigned
may be used with this conversion, and the result is always formatted asunsigned
. -
wc
-
The
int
argument is converted to a wide character (wchar_t
) and the resulting wide character is printed. -
ws
-
The argument must be an array of
wchar_t
. Bytes from the array are read up to a terminating null character or the end of the data and interpreted and printed as wide characters. If the precision is not specified, it is taken to be infinite, so all wide characters up to the first null character are printed. If the precision is specified, only that portion of the wide character array that will display in the corresponding number of screen columns is printed. -
x
,X
-
The
char
,short
,int
,long
, orlong long
argument is printed as an unsigned hexadecimal (base 16) integer. Arguments that aresigned
orunsigned
may be used with this conversion. If thex
form of the conversion is used, the letter digitsabcdef
are used. If the X form of the conversion is used, the letter digitsABCDEF
are used. If the#
flag is specified, a non-zero result will have0x
(for%x
) or0X
(for%X
) prepended to it. -
Y
-
The
uint64_t
argument is interpreted to be the number of nanoseconds since 00:00 Universal Coordinated Time, January 1, 1970, and is printed in the following cftime(3C) form: "%Y
%a
%b
%e
%T
%Z
." The current number of nanoseconds since 00:00 UTC, January 1, 1970 is available in thewalltimestamp
variable. -
%
-
Print a literal
%
character. No argument is converted. The entire conversion specification must be%%
.