Skip to content

Instantly share code, notes, and snippets.

@jclulow
Created May 10, 2012 09:24
Show Gist options
  • Select an option

  • Save jclulow/2652100 to your computer and use it in GitHub Desktop.

Select an option

Save jclulow/2652100 to your computer and use it in GitHub Desktop.
::help printf
leftwing@onbld0 illumos-gate $ proto/root_i386/usr/bin/mdb
> ::help printf
NAME
printf - print and format the member(s) of a data structure
SYNOPSIS
[ addr ] ::printf format type member ...
DESCRIPTION
The format string argument is a printf(3C)-like format string that is a
subset of the format strings supported by mdb_printf(). The type argument
is the name of a type to be used to interpret the memory referenced by dot.
The member should either be a field in the specified structure, or the
special member '.', denoting the value of dot (and treated as a pointer).
The number of members must match the number of format specifiers in the
format string.
The following format specifiers are recognized by ::printf:
%% Prints the '%' symbol.
%a Prints the member in symbolic form.
%d Prints the member as a decimal integer. If the member is a signed
integer type, the output will be signed.
%I Prints the member a IPv4 address (must be a 32-bit integer type).
%N Prints the member an IPv6 address (must be of type in6_addr_t).
%o Prints the member as an unsigned octal integer.
%p Prints the member as a pointer, in hexadecimal.
%q Prints the member in signed octal. Honk if you ever use this!
%r Prints the member as an unsigned value in the current output radix.
%R Prints the member as a signed value in the current output radix.
%s Prints the member as a string (requires a pointer or an array of
characters).
%u Prints the member as an unsigned decimal integer.
%x Prints the member in hexadecimal.
%X Prints the member in hexadecimal, using the characters A-F as the
digits for the values 10-15.
%Y Prints the member as a time_t as the string 'year month day HH:MM:SS'.
The following field width specifiers are recognized by ::printf:
%n Field width is set to the specified decimal value.
%? Field width is set to the maximum width of a hexadecimal pointer
value. This is 8 in an ILP32 environment, and 16 in an LP64
environment.
The following flag specifers are recognized by ::printf:
%- Left-justify the output within the specified field width. If the
width of the output is less than the specified field width, the
output will be padded with blanks on the right-hand side. Without
%-, values are right-justified by default.
%0 Zero-fill the output field if the output is right-justified and the
width of the output is less than the specified field width. Without
%0, right-justified values are prepended with blanks in order to
fill the field.
Examples:
::walk proc | ::printf "%-6d %s\n" proc_t p_pidp->pid_id p_user.u_psargs
::walk thread | ::printf "%?p %3d %a\n" kthread_t . t_pri t_startpc
::walk zone | ::printf "%-40s %20s\n" zone_t zone_name zone_nodename
::walk ire | ::printf "%Y %I\n" ire_t ire_create_time ire_u.ire4_u.ire4_addr
ATTRIBUTES
Target: proc
Module: mdb
Interface Stability: Evolving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment