xref: /freebsd/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 (revision 9f0f30bc1f5f08d25243952bad3fdc6e13a75c2a)
1.\" CDDL HEADER START
2.\"
3.\" The contents of this file are subject to the terms of the
4.\" Common Development and Distribution License (the "License").
5.\" You may not use this file except in compliance with the License.
6.\"
7.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8.\" or http://www.opensolaris.org/os/licensing.
9.\" See the License for the specific language governing permissions
10.\" and limitations under the License.
11.\"
12.\" When distributing Covered Code, include this CDDL HEADER in each
13.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14.\" If applicable, add the following below this CDDL HEADER, with the
15.\" fields enclosed by brackets "[]" replaced with your own identifying
16.\" information: Portions Copyright [yyyy] [name of copyright owner]
17.\"
18.\" CDDL HEADER END
19.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
20.\"
21.\" $FreeBSD$
22.\"
23.Dd July 16, 2025
24.Dt DTRACE 1
25.Os
26.Sh NAME
27.Nm dtrace
28.Nd dynamic tracing compiler and tracing utility
29.Sh SYNOPSIS
30.Nm
31.Op Fl 32 | Fl 64
32.Op Fl aACdeFGhHlOqSvVwZ
33.Op Fl -libxo
34.Op Fl b Ar bufsz
35.Op Fl c Ar cmd
36.Op Fl D Ar name Op Ns = Ns value
37.Op Fl I Ar path
38.Op Fl L Ar path
39.Op Fl o Ar output
40.Op Fl s Ar script
41.Op Fl U Ar name
42.Op Fl x Ar arg Op Ns = Ns value
43.Op Fl X Cm a | c | s | t
44.Op Fl p Ar pid
45.Op Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc
46.Op Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc
47.Op Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \
48    Oc Ar action Oc
49.Op Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \
50    Oo Oo Ar predicate Oc Ar action Oc
51.Op Fl i Ar probe-id Oo Oo Ar predicate Oc Ar action Oc
52.Sh DESCRIPTION
53DTrace is a comprehensive dynamic tracing framework ported from Solaris.
54DTrace provides a powerful infrastructure that permits administrators,
55developers, and service personnel to concisely answer arbitrary questions about
56the behavior of the operating system and user programs.
57.Pp
58The
59.Nm
60command provides a generic interface to the essential services provided by the
61DTrace facility, including:
62.Bl -bullet -offset indent
63.It
64Options that list the set of probes and providers currently published by DTrace
65.It
66Options that enable probes directly using any of the probe description
67specifiers (provider, module, function, name)
68.It
69Options that run the D compiler and compile one or more D program files or
70programs written directly on the command line
71.It
72Options that generate anonymous tracing programs
73.It
74Options that generate program stability reports
75.It
76Options that modify DTrace tracing and buffering behavior and enable
77additional D compiler features
78.El
79.Pp
80You can use
81.Nm
82to create D scripts by using it in a shebang declaration to create an
83interpreter file.
84You can also use
85.Nm
86to attempt to compile D programs and determine their properties without
87actually enabling traces using the
88.Fl e
89option.
90.Sh OPTIONS
91The arguments accepted by the
92.Fl P ,
93.Fl m ,
94.Fl f ,
95.Fl n ,
96and
97.Fl i
98options can include an optional D language
99.Ar predicate
100enclosed in slashes and an optional D language
101.Ar action
102statement list enclosed in braces.
103D program code specified on the command line must be appropriately quoted to
104avoid interpretation of meta-characters by the shell.
105.Pp
106The following options are supported:
107.Bl -tag -width indent
108.It Fl 32 | Fl 64
109The D compiler produces programs using the native data model of the operating
110system kernel.
111If the
112.Fl 32
113option is specified,
114.Nm
115forces the D compiler to compile a D program using the 32-bit data model.
116If the
117.Fl 64
118option is specified,
119.Nm
120forces the D compiler to compile a D program using the 64-bit data model.
121These options are typically not required as
122.Nm
123selects the native data model as the default.
124The data model affects the sizes of integer types and other language properties.
125D programs compiled for either data model can be executed on both 32-bit and
12664-bit kernels.
127The
128.Fl 32
129and
130.Fl 64
131options also determine the
132.Xr elf 5
133file format (ELF32 or ELF64) produced by the
134.Fl G
135option.
136.It Fl a
137Claim anonymous tracing state and display the traced data.
138You can combine the
139.Fl a
140option with the
141.Fl e
142option to force
143.Nm
144to exit immediately after consuming the anonymous tracing state rather than
145continuing to wait for new data.
146.It Fl A
147Generate directives for anonymous tracing and write them to
148.Pa /boot/dtrace.dof .
149This option constructs a set of dtrace configuration file directives to enable
150the specified probes for anonymous tracing and then exits.
151By default,
152.Nm
153attempts to store the directives to the file
154.Pa /boot/dtrace.dof .
155This behavior can be modified using the
156.Fl o
157option to specify an alternate output file.
158.It Fl b Ar bufsz
159Set the principal trace buffer size to
160.Ar bufsz .
161The trace buffer size can include any of the size suffixes k, m, g, or t.
162If the buffer space cannot be allocated,
163.Nm dtrace
164attempts to reduce the buffer size or exit depending on the setting of the
165bufresize property.
166.It Fl c Ar cmd
167Run the specified command
168.Ar cmd
169and exit upon its completion.
170If more than one
171.Fl c
172option is present on the command line,
173.Nm dtrace
174exits when all commands have exited, reporting the exit status for each child
175process as it terminates.
176The process ID of the first command is made available to any D programs
177specified on the command line or using the
178.Fl s
179option through the
180.Li $target
181macro variable.
182.It Fl C
183Run the C preprocessor
184.Xr cpp 1
185over D programs before compiling them.
186You can pass options to the C preprocessor using the
187.Fl D ,
188.Fl U ,
189.Fl I ,
190and
191.Fl H
192options.
193You can select the degree of C standard conformance if you use the
194.Fl X
195option.
196For a description of the set of tokens defined by the D compiler when invoking
197the C preprocessor, see
198.Fl X .
199.It Fl d
200Dump the D script to standard output, after syntactic transformations have been
201applied.
202For example, if-statements in D are implemented using such transformations: a
203conditional clause in a probe body is replaced at compile-time by a separate
204probe predicated on the original condition.
205.It Fl D Ar name Op Ns = Ns value
206Define
207.Ar name
208when invoking
209.Xr cpp 1
210(enabled using the
211.Fl C
212option).
213If you specify an additional
214.Ar value ,
215the name is assigned the corresponding value.
216This option passes the
217.Fl D
218option to each
219.Xr cpp 1
220invocation.
221.It Fl e
222Exit after compiling any requests and consuming anonymous tracing state
223.Fl ( a
224option) but prior to enabling any probes.
225You can combine this option with the
226.Fl a
227option to print anonymous tracing data and exit.
228You can also combine this option with D compiler options.
229This combination verifies that the programs compile without actually executing
230them and enabling the corresponding instrumentation.
231.It Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \
232    Oc Ar action Oc
233Specify function name to trace or list
234.Fl ( l
235option).
236The corresponding argument can include any of the probe description forms
237.Ar provider:module:function ,
238.Ar module:function ,
239or
240.Ar function .
241Unspecified probe description fields are left blank and match any probes
242regardless of the values in those fields.
243If no qualifiers other than
244.Ar function
245are specified in the description, all probes with the corresponding
246.Ar function
247are matched.
248The
249.Fl f
250argument can be suffixed with an optional D probe clause.
251You can specify more than one
252.Fl f
253option on the command line at a time.
254.It Fl F
255Coalesce trace output by identifying function entry and return.
256Function entry probe reports are indented and their output is prefixed with
257.Ql -> .
258Function return probe reports are unindented and their output is prefixed with
259.Ql <- .
260System call entry probe reports are indented and their output is prefixed with
261.Ql => .
262System call return probe reports are unindented and their output is prefixed
263with
264.Ql <= .
265.It Fl G
266Generate an ELF file containing an embedded DTrace program.
267The DTrace probes specified in the program are saved inside of a relocatable ELF
268object which can be linked into another program.
269If the
270.Fl o
271option is present, the ELF file is saved using the pathname specified as the
272argument for this operand.
273If the
274.Fl o
275option is not present and the DTrace program is contained with a file whose name
276is
277.Ar filename.d ,
278then the ELF file is saved using the name
279.Ar filename.o .
280Otherwise the ELF file is saved using the name d.out.
281.It Fl h
282Generate a header file containing macros that correspond to probes in the
283specified provider definitions.
284This option should be used to generate a header file that is included by other
285source files for later use with the
286.Fl G
287option.
288If the
289.Fl o
290option is present, the header file is saved using the pathname specified as the
291argument for that option.
292If the
293.Fl o
294option is not present and the DTrace program is contained within a file whose
295name is
296.Ar filename.d ,
297then the header file is saved using the name
298.Ar filename.h .
299.It Fl H
300Print the pathnames of included files when invoking
301.Xr cpp 1
302(enabled using the
303.Fl C
304option).
305This option passes the
306.Fl H
307option to each
308.Xr cpp 1
309invocation, causing it to display the list of pathnames, one for each line, to
310standard error.
311.It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action
312Specify probe identifier
313.Ar ( probe-id )
314to trace or list
315.Ar ( l
316option).
317You can specify probe IDs using decimal integers as shown by `dtrace -l`.
318The
319.Fl i
320argument can be suffixed with an optional D probe clause.
321You can specify more than one
322.Fl i
323option at a time.
324.It Fl I Ar path
325Add the specified directory
326.Ar path
327to the search path for #include files when invoking
328.Xr cpp 1
329(enabled using the
330.Fl C
331option).
332This option passes the
333.Fl I
334option to each
335.Xr cpp 1
336invocation.
337The specified
338.Ar path
339is inserted into the search path ahead of the default directory list.
340.It Fl l
341List probes instead of enabling them.
342If the
343.Fl l
344option is specified,
345.Nm
346produces a report of the probes matching the descriptions given using the
347.Fl P , m , f , n , i ,
348and
349.Fl s
350options.
351If none of these options are specified, this option lists all probes.
352.It Fl L Ar path
353Add the specified directory
354.Ar path
355to the search path for DTrace libraries.
356DTrace libraries are used to contain common definitions that can be used when
357writing D programs.
358The specified
359.Ar path
360is added after the default library search path.
361.It Fl -libxo
362Generate output via
363.Xr libxo 3 .
364This option is the same as specifying
365.Sy oformat .
366.It Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc
367Specify module name to trace or list
368.Fl ( l
369option).
370The corresponding argument can include any of the probe description forms
371.Ar provider:module
372or
373.Ar module .
374Unspecified probe description fields are left blank and match any probes
375regardless of the values in those fields.
376If no qualifiers other than
377.Ar module
378are specified in the description, all probes with a corresponding
379.Ar module
380are matched.
381The
382.Fl m
383argument can be suffixed with an optional D probe clause.
384More than one
385.Fl m
386option can be specified on the command line at a time.
387.It Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \
388    Oo Oo Ar predicate Oc Ar action Oc
389Specify probe name to trace or list
390.Fl ( l
391option).
392The corresponding argument can include any of the probe description forms
393.Ar provider:module:function:name , module:function:name , function:name ,
394or
395.Ar name .
396Unspecified probe description fields are left blank and match any probes
397regardless of the values in those fields.
398If no qualifiers other than
399.Ar name
400are specified in the description, all probes with a corresponding
401.Ar name
402are matched.
403The
404.Fl n
405argument can be suffixed with an optional D probe clause.
406More than one
407.Fl n
408option can be specified on the command line at a time.
409.It Fl O
410This option causes
411.Nm
412to print all the aggregations upon exiting if
413.Sy oformat
414or
415.Fl -libxo
416are specified.
417.It Fl o Ar output
418Specify the
419.Ar output
420file for the
421.Fl A , G ,
422and
423.Fl l
424options, or for the traced data itself.
425If the
426.Fl A
427option is present and
428.Fl o
429is not present, the default output file is
430.Pa /boot/dtrace.dof .
431If the
432.Fl G
433option is present and the
434.Fl s
435option's argument is of the form
436.Ar filename.d
437and
438.Fl o
439is not present, the default output file is
440.Ar filename.o .
441Otherwise the default output file is
442.Ar d.out .
443.It Fl p Ar pid
444Grab the specified process-ID
445.Ar pid ,
446cache its symbol tables, and exit upon its completion.
447If more than one
448.Fl p
449option is present on the command line,
450.Nm
451exits when all commands have exited, reporting the exit status for each process
452as it terminates.
453The first process-ID is made available to any D programs specified on the
454command line or using the
455.Fl s
456option through the
457.Li $target
458macro variable.
459.It Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc
460Specify provider name to trace or list
461.Fl ( l
462option).
463The remaining probe description fields module, function, and name are left
464blank and match any probes regardless of the values in those fields.
465The
466.Fl P
467argument can be suffixed with an optional D probe clause.
468You can specify more than one
469.Fl P
470option on the command line at a time.
471.It Fl q
472Set quiet mode.
473.Nm
474suppresses messages such as the number of probes matched by the specified
475options and D programs and does not print column headers, the CPU ID, the probe
476ID, or insert newlines into the output.
477Only data traced and formatted by D program statements such as
478.Ql dtrace()
479and
480.Ql printf()
481is displayed to standard output.
482.It Fl s Ar script
483Compile the specified D program source file.
484If the
485.Fl e
486option is present, the program is compiled but instrumentation is not enabled.
487If the
488.Fl l
489option is present, the program is compiled and the set of probes matched by it
490is listed, but instrumentation is not enabled.
491If none of
492.Fl e , l , G ,
493or
494.Fl A
495are present, the instrumentation specified by the D program is enabled and
496tracing begins.
497.It Fl S
498Show D compiler intermediate code.
499The D compiler produces a report of the intermediate code generated for each D
500program to standard error.
501.It Fl U Ar name
502Undefine the specified
503.Ar name
504when invoking
505.Xr cpp 1
506(enabled using the
507.Fl C
508option).
509This option passes the
510.Fl U
511option to each
512.Xr cpp 1
513invocation.
514.It Fl v
515Set verbose mode.
516If the
517.Fl v
518option is specified,
519.Nm
520produces a program stability report showing the minimum interface stability and
521dependency level for the specified D programs.
522.It Fl V
523Report the highest D programming interface version supported by
524.Nm .
525The version information is printed to standard output and the
526.Nm
527command exits.
528.It Fl w
529Permit destructive actions in D programs specified using the
530.Fl s , P , m , f , n ,
531or
532.Fl i
533options.
534If the
535.Fl w
536option is not specified,
537.Nm
538does not permit the compilation or enabling of a D program that contains
539destructive actions.
540.It Fl x Ar arg Op Ns = Ns value
541Enable or modify a DTrace runtime option or D compiler option.
542Boolean options are enabled by specifying their name.
543Options with values are set by separating the option name and value with an
544equals sign (=).
545.Pp
546A
547.Ar size
548argument may be suffixed with one of
549.Cm K ,
550.Cm M ,
551.Cm G
552or
553.Cm T
554(either upper or lower case) to indicate a multiple of
555Kilobytes, Megabytes, Gigabytes or Terabytes
556respectively.
557.Pp
558A
559.Ar time
560argument may be suffixed with one of
561.Cm ns ,
562.Cm nsec ,
563.Cm us ,
564.Cm usec ,
565.Cm ms ,
566.Cm msec ,
567.Cm s  ,
568.Cm sec ,
569.Cm m ,
570.Cm min ,
571.Cm h ,
572.Cm hour ,
573.Cm d  ,
574.Cm day ,
575.Cm hz .
576If no suffix is specified
577.Cm hz
578will be used as the unit.
579.Bl -tag -width indent
580.It Sy aggrate Ns = Ns Ar time
581Rate of aggregation reading.
582.It Sy aggsize Ns = Ns Ar size
583Size of the aggregation buffer.
584.It Sy bufpolicy Ns = Ns Cm fill Ns | Ns Cm switch Ns | Ns Cm ring
585Specifies the buffer policy for the principal buffer.
586.It Sy bufresize Ns = Ns Cm auto Ns | Ns Cm manual
587Buffer resizing policy.
588.It Sy bufsize Ns = Ns Ar size
589Size of the per-CPU principal buffer.
590Same as the
591.Fl b
592flag.
593.It Sy cleanrate Ns = Ns Ar time
594Cleaning rate.
595Must be specified in number-per-second with the
596.Dq Li hz
597suffix.
598.It Sy cpu Ns = Ns Ar scalar
599Specifies the CPU on which to enable tracing.
600.It Sy cpp
601Run a C preprocessor over input files.
602Same as the
603.Fl C
604flag.
605.It Sy cpppath Ns = Ns Ar path
606Use the specified path for the C preprocessor rather than
607searching for
608.Dq cpp
609in
610.Ev PATH .
611.It Sy defaultargs
612Allow references to unspecified macro arguments.
613.It Sy destructive
614Allow destructive actions.
615Same as the
616.Fl w
617flag.
618.It Sy dynvarsize Ns = Ns Ar size
619Size of the dynamic variable space.
620.Sm off
621.It Sy evaltime = Cm exec | preinit | postinit | main
622.Sm on
623Process create mode.
624When using
625.Fl c Ar cmd
626to start a command,
627.Nm
628will first stop the newly started
629.Ar cmd ,
630evaluate the
631.Xr d 7
632program,
633and then resume the
634.Ar cmd .
635The
636.Cm evaltime
637option controls the exact moment when this happens.
638.Pp
639The following table describes supported modes.
640.Bl -column -offset indent "postinit" "D Program Evaluation Time"
641.It Sy Mode Ta Sy D Program Evaluation Time
642.It Cm exec Ta
643Right at the first instruction of the command
644.Ar cmd
645execution.
646.It Cm preinit Ta
647Before
648.Xr elf 5 Ap s
649.Dq .init
650sections.
651.It Cm postinit Ta
652After
653.Xr elf 5 Ap s
654.Dq .init
655sections.
656Default on
657.Fx .
658.It Cm main Ta
659Before the first instruction of the
660.Fn main
661function.
662.El
663.Pp
664Usually, there is no reason to change the default mode,
665but it might be handy in situations such as shared library tracing.
666.It Sy flowindent
667Turn on flow indentation.
668Same as the
669.Fl F
670flag.
671.It Sy grabanon
672Claim anonymous state.
673Same as the
674.Fl a
675flag.
676.It Sy jstackframes Ns = Ns Ar scalar
677Number of default stack frames for
678.Fn jstack .
679.It Sy jstackstrsize Ns = Ns Ar scalar
680Default string space size for
681.Fn jstack .
682.It Sy ldpath Ns = Ns Ar path
683When
684.Fl G
685is specified, use the specified path for a static linker
686rather than searching for
687.Dq "ld"
688in
689.Ev PATH .
690.It Sy libdir Ns = Ns Ar path
691Add a directory to the system library path.
692.It Sy nspec Ns = Ns Ar scalar
693Number of speculations.
694.It Sy nolibs
695Do not load D system libraries.
696.It Sy quiet
697Set quiet mode.
698Same as the
699.Fl q
700flag.
701.It Sy specsize Ns = Ns Ar size
702Size of the speculation buffer.
703.It Sy strsize Ns = Ns Ar size
704Maximum size of strings.
705.It Sy stackframes Ns = Ns Ar scalar
706Maximum number of kernelspace stack frames to unwind when executing the
707.Fn stack
708action.
709.It Sy stackindent Ns = Ns Ar scalar
710Number of whitespace characters to use when indenting
711.Fn stack
712and
713.Fn ustack
714output.
715.It Sy oformat Ns = Ns Ar format
716Specify the format to use for output.
717Setting
718.Sy oformat
719to
720.Ql text
721makes
722.Nm
723use regular human-readable output which is its default behavior.
724The options passed to
725.Sy oformat
726are directly forwarded to
727.Xr libxo 3 .
728Some of the supported formatters include
729.Ql json ,
730.Ql xml
731and
732.Ql html .
733Note that this option will cause
734.Nm
735to not produce any output unless printing functions are explicitly called,
736or the
737.Fl O
738flag is specified.
739For more information see
740.Sx STRUCTURED OUTPUT .
741.It Sy statusrate Ns = Ns Ar time
742Rate of status checking.
743.It Sy switchrate Ns = Ns Ar time
744Rate of buffer switching.
745.It Sy syslibdir Ns = Ns Ar path
746Path to system libraries.
747Defaults to
748.Pa /usr/lib/dtrace .
749.It Sy ustackframes Ns = Ns Ar scalar
750Maximum number of userspace stack frames to unwind when executing the
751.Fn ustack
752action.
753.El
754.It Fl X Cm a | c | s | t
755Specify the degree of conformance to the ISO C standard that should be selected
756when invoking
757.Xr cpp 1
758(enabled using the
759.Fl C
760option).
761The
762.Fl X
763option argument affects the value and presence of the __STDC__ macro depending
764upon the value of the argument letter.
765.sp
766The
767.Fl X
768option supports the following arguments:
769.Bl -tag -width indent
770.It a
771Default.
772ISO C plus K&R compatibility extensions, with semantic changes required by ISO
773C.
774This is the default mode if
775.Fl X
776is not specified.
777The predefined macro __STDC__ has a value of 0 when
778.Xr cpp 1
779is invoked in conjunction with the
780.Fl Xa
781option.
782.It c
783Conformance.
784Strictly conformant ISO C, without K&R C compatibility extensions.
785The predefined macro __STDC__ has a value of 1 when
786.Xr cpp 1
787is invoked in conjunction with the
788.Fl \&Xc
789option.
790.It s
791K&R C only.
792The macro __STDC__ is not defined when
793.Xr cpp 1
794is invoked in conjunction with the
795.Fl Xs
796option.
797.It t
798Transition.
799ISO C plus K&R C compatibility extensions, without semantic changes required by
800ISO C.
801The predefined macro __STDC__ has a value of 0 when
802.Xr cpp 1
803is invoked in conjunction with the
804.Fl Xt
805option.
806.El
807.Pp
808As the
809.Fl X
810option only affects how the D compiler invokes the C preprocessor, the
811.Fl Xa
812and
813.Fl Xt
814options are equivalent from the perspective of D and both are provided only to
815ease re-use of settings from a C build environment.
816.Pp
817Regardless of the
818.Fl X
819mode, the following additional C preprocessor definitions are always specified
820and valid in all modes:
821.Bl -bullet -offset indent
822.It
823__sun
824.It
825__unix
826.It
827__SVR4
828.It
829__sparc (on SPARC systems only)
830.It
831__sparcv9 (on SPARC systems only when 64-bit programs are compiled)
832.It
833__i386 (on x86 systems only when 32-bit programs are compiled)
834.It
835__amd64 (on x86 systems only when 64-bit programs are compiled)
836.It
837__`uname -s`_`uname -r` (for example,
838.Ql FreeBSD_9.2-RELEASE .
839.It
840__SUNW_D=1
841.It
842.No __SUNW_D_VERSION=0x Ns Ar MMmmmuuu
843.Pp
844Where
845.Ar MM
846is the major release value in hexadecimal,
847.Ar mmm
848is the minor release value in hexadecimal, and
849.Ar uuu
850is the micro release value in hexadecimal.
851.El
852.It Fl Z
853Permit probe descriptions that match zero probes.
854If the
855.Fl Z
856option is not specified,
857.Nm
858reports an error and exits if any probe descriptions specified in D program
859files
860.Fl ( s
861option) or on the command line
862.Fl ( P , m , f , n ,
863or
864.Fl i
865options) contain descriptions that do not match any known probes.
866.El
867.Sh STRUCTURED OUTPUT
868.Nm
869supports structured output using
870.Xr libxo 3 .
871The output will always have a top-level object called
872.Dq dtrace ,
873followed by a list of objects
874.Dq probes .
875Each of the probe objects will to have a timestamp which is generated at
876output time rather than probe firing time, an identifier for the CPU on
877which the probe was executed, and the probe's full specification:
878.Bd -literal
879{
880  "dtrace": {
881    "probes": [
882      {
883        "timestamp": ...,
884        "cpu": ...,
885        "id": ...,
886        "provider": ...,
887        "module": ...,
888        "function": ...,
889        "name": ...,
890        "output": [
891           ... (script-specific output)
892        ]
893      }
894    ]
895  }
896}
897
898<?xml version="1.0"?>
899<dtrace>
900  <probes>
901    <timestamp>...</timestamp>
902    <cpu>...</cpu>
903    <id>...</id>
904    <provider>...</provider>
905    <module>...</module>
906    <function>...</function>
907    <name>...</name>
908    <output>
909      ... (script-specific output)
910    </output>
911  </probes>
912</dtrace>
913.Ed
914.Pp
915It is also possible for XML output to take the following form if some
916of the fields are empty (in this example, module and function values
917are absent):
918.Bd -literal
919<?xml version="1.0"?>
920<dtrace>
921  <probes>
922    ...
923    <module/>
924    <function/>
925    ...
926    <output>
927      ... (script-specific output)
928    </output>
929  </probes>
930</dtrace>
931.Ed
932.Pp
933Similarly,
934.Sy oformat
935can be used to generate HTML:
936.Bd -literal
937<div class="line">
938<div class="data" data-tag="timestamp">...</div>
939<div class="text"></div>
940<div class="data" data-tag="cpu">...</div>
941<div class="text"></div>
942<div class="data" data-tag="id">...</div>
943<div class="text"></div>
944<div class="data" data-tag="provider">...</div>
945<div class="text"></div>
946<div class="data" data-tag="module">...</div>
947<div class="text"></div>
948<div class="data" data-tag="function">...</div>
949<div class="text"></div>
950<div class="data" data-tag="name">...</div>
951<div class="data" data-tag="... (script-specific output)">...</div>
952</div>
953.Ed
954.Pp
955Unlike JSON and XML, the
956.Dq output
957array is not present.
958Instead, data is simply formatted into a div of class
959.Dq data
960and a data-tag is associated with each of the keys.
961.Pp
962The
963.Dq output
964array's contents depend on the probes' actions and is explained below.
965The examples here are presented in JSON form as opposed to XML or HTML,
966however the conversion explained above applies for all output formats.
967.Pp
968Any scalar output, such as output produced by the
969.Fn trace
970action is of form:
971.Bd -literal
972{
973  "value": ...
974}
975.Ed
976.Pp
977The
978.Fn printf
979action begins with an object containing the formatted output of the
980.Fn printf
981action.
982Subsequent objects contains the value of each of the arguments to
983.Fn printf
984in its raw form as if the
985.Fn trace
986action was used instead.
987A
988.Fn printf
989statement which contains no arguments other than the message will only have
990one object following the message object and its value will always be 0.
991This is an artefact of the implementation and can safely be ignored.
992.Bd -literal
993# dtrace --libxo json,pretty -n 'BEGIN { printf("... %Y, ..", walltimestamp); }'
994
995{
996  "message": "... 2023 Sep  7 16:49:02, .."
997},
998{
999  "value": 1694105342633402400
1000},
1001{
1002  ...
1003}
1004.Ed
1005.Pp
1006Scalar aggregations are aggregations which produce a single value for a given
1007key.
1008These aggregations include
1009.Fn count ,
1010.Fn min ,
1011.Fn max ,
1012.Fn stddev
1013and
1014.Fn sum .
1015Each one of them is represented by the key containing their name.
1016For example, the output of a
1017.Fn stddev
1018aggregation will contain a key
1019.Dq stddev
1020inside an
1021.Dq aggregation-data
1022object:
1023.Bd -literal
1024{
1025  "aggregation-data": [
1026    {
1027      "keys": [
1028        ...
1029      ],
1030      "stddev": ...
1031    }
1032  ],
1033  "aggregation-name": ...
1034}
1035.Ed
1036.Pp
1037The
1038.Dq keys
1039field remains consistent across all aggregations, however
1040.Fn quantize ,
1041.Fn lquantize
1042and
1043.Fn llquantize
1044need to be treated differently.
1045.Sy oformat
1046will create a new array of objects called
1047.Dq buckets .
1048Each of the objects contains a
1049.Dq value
1050and a
1051.Dq count
1052field which are
1053the left-hand side and the right-hand side of human-readable
1054.Nm
1055output respectively.
1056The full object has the following format:
1057.Bd -literal
1058{
1059  "aggregation-data": [
1060    ...
1061    {
1062      "keys": [
1063        ...
1064      ],
1065      "buckets": [
1066        {
1067          "value": 32,
1068          "count": 0
1069        },
1070        {
1071          "value": 64,
1072          "count": 17
1073        },
1074        ...
1075      ],
1076    },
1077    ...
1078  ]
1079  "aggregation-name": ...
1080}
1081.Ed
1082.Pp
1083Similar to scalar aggregations, named scalar actions such as
1084.Fn mod ,
1085.Fn umod ,
1086.Fn usym ,
1087.Fn tracemem
1088and
1089.Fn printm
1090will output an object with the key being equal to the
1091name of the action.
1092For example,
1093.Fn printm
1094output would produce the following object:
1095.Bd -literal
1096{
1097  "printm": "0x4054171100"
1098}
1099.Ed
1100.Pp
1101.Fn sym
1102is slightly different.
1103While it will create a
1104.Dq sym
1105field which contains its value, in some cases it will also create additional
1106fields
1107.Dq object ,
1108.Dq name
1109and
1110.Dq offset :
1111.Bd -literal
1112# dtrace -x oformat=json,pretty -On 'BEGIN { sym((uintptr_t)&`prison0); }'
1113
1114{
1115  "sym": "kernel`prison0",
1116  "object": "kernel",
1117  "name": "prison0"
1118}
1119
1120# dtrace --libxo json,pretty -On 'BEGIN { sym((uintptr_t)curthread); }'
1121
1122{
1123  "sym": "0xfffffe00c18d2000",
1124  "offset": "0xfffffe00c18d2000"
1125}
1126.Ed
1127.Pp
1128.Fn stack
1129and
1130.Fn ustack
1131actions unroll each of the stack frames into its own object in an array.
1132The only real difference between them is that the
1133.Fn stack
1134action will produce a list called
1135.Dq stack-frames
1136while
1137.Fn ustack
1138will produce one called
1139.Dq ustack-frames .
1140The following is an example of their
1141.Sy oformat
1142output:
1143.Bd -literal
1144{
1145  "stack-frames": [
1146    {
1147      "symbol": "dtrace.ko`dtrace_dof_create+0x35",
1148      "module": "dtrace.ko",
1149      "name": "dtrace_dof_create",
1150      "offset": "0x35"
1151    },
1152    {
1153      "symbol": "dtrace.ko`dtrace_ioctl+0x81c",
1154      "module": "dtrace.ko",
1155      "name": "dtrace_ioctl",
1156      "offset": "0x81c"
1157    },
1158    ...
1159  ]
1160}
1161
1162{
1163  "ustack-frames": [
1164    {
1165      "symbol": "libc.so.7`ioctl+0xa",
1166      "module": "libc.so.7",
1167      "name": "ioctl",
1168      "offset": "0xa"
1169    },
1170    {
1171      "symbol": "libdtrace.so.2`dtrace_go+0xf3",
1172      "module": "libdtrace.so.2",
1173      "name": "dtrace_go",
1174      "offset": "0xf3"
1175    },
1176    ...
1177  ]
1178}
1179.Ed
1180.Pp
1181The
1182.Fn print
1183action produces a
1184.Dq type
1185list in the following form:
1186.Bd -literal
1187{
1188  "type": [
1189    {
1190      "object-name": "kernel",
1191      "name": "struct thread",
1192      "ctfid": 2372
1193    },
1194    {
1195      "member-name": "td_lock",
1196      "name": "struct mtx *volatile",
1197      "ctfid": 2035,
1198      "value": "0xffffffff82158440"
1199    },
1200    ...
1201}
1202.Ed
1203.Pp
1204If the type is invalid, a
1205.Dq warning
1206object will be produced containing the diagnostic message as well as two
1207possible optional fields:
1208.Dq type-identifier
1209which contains the CTF identifier of the type and
1210.Dq size containing the size of an integer, enum or float.
1211The fields generated will depend on the kind of error that was encountered
1212while processing the trace data.
1213.Pp
1214Finally,
1215.Sy oformat
1216provides a special pseudo-probe to represent drops.
1217As
1218.Nm
1219polls for various kinds of drops
1220.Sy oformat
1221will produce output similar to the following in order to represent drops:
1222.Bd -literal
1223{
1224  "cpu": -1,
1225  "id": -1,
1226  "provider": "dtrace",
1227  "module": "INTERNAL",
1228  "function": "INTERNAL",
1229  "name": "DROP",
1230  "timestamp": ...,
1231  "count": ...,
1232  "total": ...,
1233  "kind": 2,
1234  "msg": "... dynamic variable drops\n"
1235}
1236.Ed
1237.Sh OPERANDS
1238You can specify zero or more additional arguments on the
1239.Nm
1240command line to define a set of macro variables and so forth).
1241The additional arguments can be used in D programs specified using the
1242.Fl s
1243option or on the command line.
1244.Sh FILES
1245.Bl -tag -width /boot/dtrace.dof -compact
1246.It Pa /boot/dtrace.dof
1247File for anonymous tracing directives.
1248.El
1249.Sh EXIT STATUS
1250The following exit statuses are returned:
1251.Bl -tag -width indent
1252.It 0
1253Successful completion.
1254.Pp
1255For D program requests, an exit status of 0 indicates that programs were
1256successfully compiled, probes were successfully enabled, or anonymous state
1257was successfully retrieved.
1258.Nm
1259returns 0 even if the specified tracing requests encountered errors or drops.
1260.It 1
1261An error occurred.
1262.Pp
1263For D program requests, an exit status of 1 indicates that program compilation
1264failed or that the specified request could not be satisfied.
1265.It 2
1266Invalid command line options or arguments were specified.
1267.El
1268.Sh SEE ALSO
1269.Xr cpp 1 ,
1270.Xr dwatch 1 ,
1271.Xr dtrace_audit 4 ,
1272.Xr dtrace_dtrace 4 ,
1273.Xr dtrace_fbt 4 ,
1274.Xr dtrace_io 4 ,
1275.Xr dtrace_ip 4 ,
1276.Xr dtrace_kinst 4 ,
1277.Xr dtrace_lockstat 4 ,
1278.Xr dtrace_proc 4 ,
1279.Xr dtrace_profile 4 ,
1280.Xr dtrace_sched 4 ,
1281.Xr dtrace_sctp 4 ,
1282.Xr dtrace_tcp 4 ,
1283.Xr dtrace_udp 4 ,
1284.Xr dtrace_udplite 4 ,
1285.Xr elf 5 ,
1286.Xr d 7 ,
1287.Xr tracing 7 ,
1288.Xr SDT 9
1289.Rs
1290.%T Solaris Dynamic Tracing Guide
1291.Re
1292.Sh HISTORY
1293The
1294.Nm
1295utility first appeared in
1296.Fx 7.1 .
1297