printa

The printa function is used to format the results of aggregations in a D program. The function is invoked using one of two forms:

printa(@aggregation-name);
printa(format-string, @
aggregation-name);

If the first form of the function is used, the dtrace ( 1M ) command takes a consistent snapshot of the aggregation data and produces output equivalent to the default output format used for aggregations, described in Chapter 9, Aggregations.

If the second form of the function is used, the dtrace ( 1M ) command takes a consistent snapshot of the aggregation data and produces output according to the conversions specified in the format string, according to the following rules:

The following D program shows a complete example of printa , using the profile provider to sample the value of caller and then formatting the results as a simple table:

profile:::profile-997
{
	@a[caller] = count();
}

END
{
	printa("%@8u %a\n", @a);
}

If you use dtrace to execute this program, wait a few seconds, and press Control-C, you will see output similar to the following example:

# dtrace -s printa.d
^C
CPU     ID                    FUNCTION:NAME
  1      2                             :END        1 0x1
       1 ohci`ohci_handle_root_hub_status_change+0x148
       1 specfs`spec_write+0xe0
       1 0xff14f950
       1 genunix`cyclic_softint+0x588
       1 0xfef2280c
       1 genunix`getf+0xdc
       1 ufs`ufs_icheck+0x50
       1 genunix`infpollinfo+0x80
       1 genunix`kmem_log_enter+0x1e8
       ...