xref: /freebsd/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
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 February 25, 2020
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 aACeFGhHlqSvVwZ
33.Op Fl b Ar bufsz
34.Op Fl c Ar cmd
35.Op Fl D Ar name Op Ns = Ns value
36.Op Fl I Ar path
37.Op Fl L Ar path
38.Op Fl o Ar output
39.Op Fl s Ar script
40.Op Fl U Ar name
41.Op Fl x Ar arg Op Ns = Ns value
42.Op Fl X Cm a | c | s | t
43.Op Fl p Ar pid
44.Op Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc
45.Op Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc
46.Op Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \
47    Oc Ar action Oc
48.Op Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \
49    Oo Oo Ar predicate Oc Ar action Oc
50.Op Fl i Ar probe-id Oo Oo Ar predicate Oc Ar action Oc
51.Sh DESCRIPTION
52DTrace is a comprehensive dynamic tracing framework ported from Solaris.
53DTrace provides a powerful infrastructure that permits administrators,
54developers, and service personnel to concisely answer arbitrary questions about
55the behavior of the operating system and user programs.
56.Pp
57The
58.Nm
59command provides a generic interface to the essential services provided by the
60DTrace facility, including:
61.Bl -bullet -offset indent
62.It
63Options that list the set of probes and providers currently published by DTrace
64.It
65Options that enable probes directly using any of the probe description
66specifiers (provider, module, function, name)
67.It
68Options that run the D compiler and compile one or more D program files or
69programs written directly on the command line
70.It
71Options that generate anonymous tracing programs
72.It
73Options that generate program stability reports
74.It
75Options that modify DTrace tracing and buffering behavior and enable
76additional D compiler features
77.El
78.Pp
79You can use
80.Nm
81to create D scripts by using it in a shebang declaration to create an
82interpreter file.
83You can also use
84.Nm
85to attempt to compile D programs and determine their properties without
86actually enabling traces using the
87.Fl e
88option.
89.Sh OPTIONS
90The arguments accepted by the
91.Fl P ,
92.Fl m ,
93.Fl f ,
94.Fl n ,
95and
96.Fl i
97options can include an optional D language
98.Ar predicate
99enclosed in slashes and an optional D language
100.Ar action
101statement list enclosed in braces.
102D program code specified on the command line must be appropriately quoted to
103avoid interpretation of meta-characters by the shell.
104.Pp
105The following options are supported:
106.Bl -tag -width indent
107.It Fl 32 | Fl 64
108The D compiler produces programs using the native data model of the operating
109system kernel.
110If the
111.Fl 32
112option is specified,
113.Nm
114forces the D compiler to compile a D program using the 32-bit data model.
115If the
116.Fl 64
117option is specified,
118.Nm
119forces the D compiler to compile a D program using the 64-bit data model.
120These options are typically not required as
121.Nm
122selects the native data model as the default.
123The data model affects the sizes of integer types and other language properties.
124D programs compiled for either data model can be executed on both 32-bit and
12564-bit kernels.
126The
127.Fl 32
128and
129.Fl 64
130options also determine the
131.Xr elf 5
132file format (ELF32 or ELF64) produced by the
133.Fl G
134option.
135.It Fl a
136Claim anonymous tracing state and display the traced data.
137You can combine the
138.Fl a
139option with the
140.Fl e
141option to force
142.Nm
143to exit immediately after consuming the anonymous tracing state rather than
144continuing to wait for new data.
145.It Fl A
146Generate directives for anonymous tracing and write them to
147.Pa /boot/dtrace.dof .
148This option constructs a set of dtrace configuration file directives to enable
149the specified probes for anonymous tracing and then exits.
150By default,
151.Nm
152attempts to store the directives to the file
153.Pa /boot/dtrace.dof .
154This behavior can be modified using the
155.Fl o
156option to specify an alternate output file.
157.It Fl b Ar bufsz
158Set the principal trace buffer size to
159.Ar bufsz .
160The trace buffer size can include any of the size suffixes k, m, g, or t.
161If the buffer space cannot be allocated,
162.Nm dtrace
163attempts to reduce the buffer size or exit depending on the setting of the
164bufresize property.
165.It Fl c Ar cmd
166Run the specified command
167.Ar cmd
168and exit upon its completion.
169If more than one
170.Fl c
171option is present on the command line,
172.Nm dtrace
173exits when all commands have exited, reporting the exit status for each child
174process as it terminates.
175The process ID of the first command is made available to any D programs
176specified on the command line or using the
177.Fl s
178option through the
179.Li $target
180macro variable.
181.It Fl C
182Run the C preprocessor
183.Xr cpp 1
184over D programs before compiling them.
185You can pass options to the C preprocessor using the
186.Fl D ,
187.Fl U ,
188.Fl I ,
189and
190.Fl H
191options.
192You can select the degree of C standard conformance if you use the
193.Fl X
194option.
195For a description of the set of tokens defined by the D compiler when invoking
196the C preprocessor, see
197.Fl X .
198.It Fl D Ar name Op Ns = Ns value
199Define
200.Ar name
201when invoking
202.Xr cpp 1
203(enabled using the
204.Fl C
205option).
206If you specify an additional
207.Ar value ,
208the name is assigned the corresponding value.
209This option passes the
210.Fl D
211option to each
212.Xr cpp 1
213invocation.
214.It Fl e
215Exit after compiling any requests and consuming anonymous tracing state
216.Fl ( a
217option) but prior to enabling any probes.
218You can combine this option with the
219.Fl a
220option to print anonymous tracing data and exit.
221You can also combine this option with D compiler options.
222This combination verifies that the programs compile without actually executing
223them and enabling the corresponding instrumentation.
224.It Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \
225    Oc Ar action Oc
226Specify function name to trace or list
227.Fl ( l
228option).
229The corresponding argument can include any of the probe description forms
230.Ar provider:module:function ,
231.Ar module:function ,
232or
233.Ar function .
234Unspecified probe description fields are left blank and match any probes
235regardless of the values in those fields.
236If no qualifiers other than
237.Ar function
238are specified in the description, all probes with the corresponding
239.Ar function
240are matched.
241The
242.Fl f
243argument can be suffixed with an optional D probe clause.
244You can specify more than one
245.Fl f
246option on the command line at a time.
247.It Fl F
248Coalesce trace output by identifying function entry and return.
249Function entry probe reports are indented and their output is prefixed with
250.Ql -> .
251Function return probe reports are unindented and their output is prefixed with
252.Ql <- .
253System call entry probe reports are indented and their output is prefixed with
254.Ql => .
255System call return probe reports are unindented and their output is prefixed
256with
257.Ql <= .
258.It Fl G
259Generate an ELF file containing an embedded DTrace program.
260The DTrace probes specified in the program are saved inside of a relocatable ELF
261object which can be linked into another program.
262If the
263.Fl o
264option is present, the ELF file is saved using the pathname specified as the
265argument for this operand.
266If the
267.Fl o
268option is not present and the DTrace program is contained with a file whose name
269is
270.Ar filename.d ,
271then the ELF file is saved using the name
272.Ar filename.o .
273Otherwise the ELF file is saved using the name d.out.
274.It Fl h
275Generate a header file containing macros that correspond to probes in the
276specified provider definitions.
277This option should be used to generate a header file that is included by other
278source files for later use with the
279.Fl G
280option.
281If the
282.Fl o
283option is present, the header file is saved using the pathname specified as the
284argument for that option.
285If the
286.Fl o
287option is not present and the DTrace program is contained within a file whose
288name is
289.Ar filename.d ,
290then the header file is saved using the name
291.Ar filename.h .
292.It Fl H
293Print the pathnames of included files when invoking
294.Xr cpp 1
295(enabled using the
296.Fl C
297option).
298This option passes the
299.Fl H
300option to each
301.Xr cpp 1
302invocation, causing it to display the list of pathnames, one for each line, to
303standard error.
304.It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action
305Specify probe identifier
306.Ar ( probe-id )
307to trace or list
308.Ar ( l
309option).
310You can specify probe IDs using decimal integers as shown by `dtrace -l`.
311The
312.Fl i
313argument can be suffixed with an optional D probe clause.
314You can specify more than one
315.Fl i
316option at a time.
317.It Fl I Ar path
318Add the specified directory
319.Ar path
320to the search path for #include files when invoking
321.Xr cpp 1
322(enabled using the
323.Fl C
324option).
325This option passes the
326.Fl I
327option to each
328.Xr cpp 1
329invocation.
330The specified
331.Ar path
332is inserted into the search path ahead of the default directory list.
333.It Fl l
334List probes instead of enabling them.
335If the
336.Fl l
337option is specified,
338.Nm
339produces a report of the probes matching the descriptions given using the
340.Fl P , m , f , n , i ,
341and
342.Fl s
343options.
344If none of these options are specified, this option lists all probes.
345.It Fl L Ar path
346Add the specified directory
347.Ar path
348to the search path for DTrace libraries.
349DTrace libraries are used to contain common definitions that can be used when
350writing D programs.
351The specified
352.Ar path
353is added after the default library search path.
354.It Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc
355Specify module name to trace or list
356.Fl ( l
357option).
358The corresponding argument can include any of the probe description forms
359.Ar provider:module
360or
361.Ar module .
362Unspecified probe description fields are left blank and match any probes
363regardless of the values in those fields.
364If no qualifiers other than
365.Ar module
366are specified in the description, all probes with a corresponding
367.Ar module
368are matched.
369The
370.Fl m
371argument can be suffixed with an optional D probe clause.
372More than one
373.Fl m
374option can be specified on the command line at a time.
375.It Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \
376    Oo Oo Ar predicate Oc Ar action Oc
377Specify probe name to trace or list
378.Fl ( l
379option).
380The corresponding argument can include any of the probe description forms
381.Ar provider:module:function:name , module:function:name , function:name ,
382or
383.Ar name .
384Unspecified probe description fields are left blank and match any probes
385regardless of the values in those fields.
386If no qualifiers other than
387.Ar name
388are specified in the description, all probes with a corresponding
389.Ar name
390are matched.
391The
392.Fl n
393argument can be suffixed with an optional D probe clause.
394More than one
395.Fl n
396option can be specified on the command line at a time.
397.It Fl o Ar output
398Specify the
399.Ar output
400file for the
401.Fl A , G ,
402and
403.Fl l
404options, or for the traced data itself.
405If the
406.Fl A
407option is present and
408.Fl o
409is not present, the default output file is
410.Pa /boot/dtrace.dof .
411If the
412.Fl G
413option is present and the
414.Fl s
415option's argument is of the form
416.Ar filename.d
417and
418.Fl o
419is not present, the default output file is
420.Ar filename.o .
421Otherwise the default output file is
422.Ar d.out .
423.It Fl p Ar pid
424Grab the specified process-ID
425.Ar pid ,
426cache its symbol tables, and exit upon its completion.
427If more than one
428.Fl p
429option is present on the command line,
430.Nm
431exits when all commands have exited, reporting the exit status for each process
432as it terminates.
433The first process-ID is made available to any D programs specified on the
434command line or using the
435.Fl s
436option through the
437.Li $target
438macro variable.
439.It Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc
440Specify provider name to trace or list
441.Fl ( l
442option).
443The remaining probe description fields module, function, and name are left
444blank and match any probes regardless of the values in those fields.
445The
446.Fl P
447argument can be suffixed with an optional D probe clause.
448You can specify more than one
449.Fl P
450option on the command line at a time.
451.It Fl q
452Set quiet mode.
453.Nm
454suppresses messages such as the number of probes matched by the specified
455options and D programs and does not print column headers, the CPU ID, the probe
456ID, or insert newlines into the output.
457Only data traced and formatted by D program statements such as
458.Ql dtrace()
459and
460.Ql printf()
461is displayed to standard output.
462.It Fl s Ar script
463Compile the specified D program source file.
464If the
465.Fl e
466option is present, the program is compiled but instrumentation is not enabled.
467If the
468.Fl l
469option is present, the program is compiled and the set of probes matched by it
470is listed, but instrumentation is not enabled.
471If none of
472.Fl e , l , G ,
473or
474.Fl A
475are present, the instrumentation specified by the D program is enabled and
476tracing begins.
477.It Fl S
478Show D compiler intermediate code.
479The D compiler produces a report of the intermediate code generated for each D
480program to standard error.
481.It Fl U Ar name
482Undefine the specified
483.Ar name
484when invoking
485.Xr cpp 1
486(enabled using the
487.Fl C
488option).
489This option passes the
490.Fl U
491option to each
492.Xr cpp 1
493invocation.
494.It Fl v
495Set verbose mode.
496If the
497.Fl v
498option is specified,
499.Nm
500produces a program stability report showing the minimum interface stability and
501dependency level for the specified D programs.
502.It Fl V
503Report the highest D programming interface version supported by
504.Nm .
505The version information is printed to standard output and the
506.Nm
507command exits.
508.It Fl w
509Permit destructive actions in D programs specified using the
510.Fl s , P , m , f , n ,
511or
512.Fl i
513options.
514If the
515.Fl w
516option is not specified,
517.Nm
518does not permit the compilation or enabling of a D program that contains
519destructive actions.
520.It Fl x Ar arg Op Ns = Ns value
521Enable or modify a DTrace runtime option or D compiler option.
522Boolean options are enabled by specifying their name.
523Options with values are set by separating the option name and value with an
524equals sign (=).
525.Pp
526A
527.Ar size
528argument may be suffixed with one of
529.Cm K ,
530.Cm M ,
531.Cm G
532or
533.Cm T
534(either upper or lower case) to indicate a multiple of
535Kilobytes, Megabytes, Gigabytes or Terabytes
536respectively.
537.Pp
538A
539.Ar time
540argument may be suffixed with one of
541.Cm ns ,
542.Cm nsec ,
543.Cm us ,
544.Cm usec ,
545.Cm ms ,
546.Cm msec ,
547.Cm s  ,
548.Cm sec ,
549.Cm m ,
550.Cm min ,
551.Cm h ,
552.Cm hour ,
553.Cm d  ,
554.Cm day ,
555.Cm hz .
556If no suffix is specified
557.Cm hz
558will be used as the unit.
559.Bl -tag -width indent
560.It Sy aggrate Ns = Ns Ar time
561Rate of aggregation reading.
562.It Sy aggsize Ns = Ns Ar size
563Size of the aggregation buffer.
564.It Sy bufpolicy Ns = Ns Cm fill Ns | Ns Cm switch Ns | Ns Cm ring
565Specifies the buffer policy for the principal buffer.
566.It Sy bufresize Ns = Ns Cm auto Ns | Ns Cm manual
567Buffer resizing policy.
568.It Sy bufsize Ns = Ns Ar size
569Size of the per-CPU principal buffer.
570Same as the
571.Fl b
572flag.
573.It Sy cleanrate Ns = Ns Ar time
574Cleaning rate.
575Must be specified in number-per-second with the
576.Dq Li hz
577suffix.
578.It Sy cpu Ns = Ns Ar scalar
579Specifies the CPU on which to enable tracing.
580.It Sy defaultargs
581Allow references to unspecified macro arguments.
582.It Sy destructive
583Allow destructive actions.
584Same as the
585.Fl w
586flag.
587.It Sy dynvarsize Ns = Ns Ar size
588Size of the dynamic variable space.
589.It Sy flowindent
590Turn on flow indentation.
591Same as the
592.Fl F
593flag.
594.It Sy grabanon
595Claim anonymous state.
596Same as the
597.Fl a
598flag.
599.It Sy jstackframes Ns = Ns Ar scalar
600Number of default stack frames for
601.Fn jstack .
602.It Sy jstackstrsize Ns = Ns Ar scalar
603Default string space size for
604.Fn jstack .
605.It Sy nspec Ns = Ns Ar scalar
606Number of speculations.
607.It Sy quiet
608Set quiet mode.
609Same as the
610.Fl q
611flag.
612.It Sy specsize Ns = Ns Ar size
613Size of the speculation buffer.
614.It Sy strsize Ns = Ns Ar size
615Maximum size of strings.
616.It Sy stackframes Ns = Ns Ar scalar
617Maximum number of kernelspace stack frames to unwind when executing the
618.Fn stack
619action.
620.It Sy stackindent Ns = Ns Ar scalar
621Number of whitespace characters to use when indenting
622.Fn stack
623and
624.Fn ustack
625output.
626.It Sy statusrate Ns = Ns Ar time
627Rate of status checking.
628.It Sy switchrate Ns = Ns Ar time
629Rate of buffer switching.
630.It Sy ustackframes Ns = Ns Ar scalar
631Maximum number of userspace stack frames to unwind when executing the
632.Fn ustack
633action.
634.El
635.It Fl X Cm a | c | s | t
636Specify the degree of conformance to the ISO C standard that should be selected
637when invoking
638.Xr cpp 1
639(enabled using the
640.Fl C
641option).
642The
643.Fl X
644option argument affects the value and presence of the __STDC__ macro depending
645upon the value of the argument letter.
646.sp
647The
648.Fl X
649option supports the following arguments:
650.Bl -tag -width indent
651.It a
652Default.
653ISO C plus K&R compatibility extensions, with semantic changes required by ISO
654C.
655This is the default mode if
656.Fl X
657is not specified.
658The predefined macro __STDC__ has a value of 0 when
659.Xr cpp 1
660is invoked in conjunction with the
661.Fl Xa
662option.
663.It c
664Conformance.
665Strictly conformant ISO C, without K&R C compatibility extensions.
666The predefined macro __STDC__ has a value of 1 when
667.Xr cpp 1
668is invoked in conjunction with the
669.Fl \&Xc
670option.
671.It s
672K&R C only.
673The macro __STDC__ is not defined when
674.Xr cpp 1
675is invoked in conjunction with the
676.Fl Xs
677option.
678.It t
679Transition.
680ISO C plus K&R C compatibility extensions, without semantic changes required by
681ISO C.
682The predefined macro __STDC__ has a value of 0 when
683.Xr cpp 1
684is invoked in conjunction with the
685.Fl Xt
686option.
687.El
688.Pp
689As the
690.Fl X
691option only affects how the D compiler invokes the C preprocessor, the
692.Fl Xa
693and
694.Fl Xt
695options are equivalent from the perspective of D and both are provided only to
696ease re-use of settings from a C build environment.
697.Pp
698Regardless of the
699.Fl X
700mode, the following additional C preprocessor definitions are always specified
701and valid in all modes:
702.Bl -bullet -offset indent
703.It
704__sun
705.It
706__unix
707.It
708__SVR4
709.It
710__sparc (on SPARC systems only)
711.It
712__sparcv9 (on SPARC systems only when 64-bit programs are compiled)
713.It
714__i386 (on x86 systems only when 32-bit programs are compiled)
715.It
716__amd64 (on x86 systems only when 64-bit programs are compiled)
717.It
718__`uname -s`_`uname -r` (for example,
719.Ql FreeBSD_9.2-RELEASE .
720.It
721__SUNW_D=1
722.It
723.No __SUNW_D_VERSION=0x Ns Ar MMmmmuuu
724.Pp
725Where
726.Ar MM
727is the major release value in hexadecimal,
728.Ar mmm
729is the minor release value in hexadecimal, and
730.Ar uuu
731is the micro release value in hexadecimal.
732.El
733.It Fl Z
734Permit probe descriptions that match zero probes.
735If the
736.Fl Z
737option is not specified,
738.Nm
739reports an error and exits if any probe descriptions specified in D program
740files
741.Fl ( s
742option) or on the command line
743.Fl ( P , m , f , n ,
744or
745.Fl i
746options) contain descriptions that do not match any known probes.
747.El
748.Sh OPERANDS
749You can specify zero or more additional arguments on the
750.Nm
751command line to define a set of macro variables and so forth).
752The additional arguments can be used in D programs specified using the
753.Fl s
754option or on the command line.
755.Sh FILES
756.Bl -tag -width /boot/dtrace.dof -compact
757.It Pa /boot/dtrace.dof
758File for anonymous tracing directives.
759.El
760.Sh EXIT STATUS
761The following exit statuses are returned:
762.Bl -tag -width indent
763.It 0
764Successful completion.
765.Pp
766For D program requests, an exit status of 0 indicates that programs were
767successfully compiled, probes were successfully enabled, or anonymous state
768was successfully retrieved.
769.Nm
770returns 0 even if the specified tracing requests encountered errors or drops.
771.It 1
772An error occurred.
773.Pp
774For D program requests, an exit status of 1 indicates that program compilation
775failed or that the specified request could not be satisfied.
776.It 2
777Invalid command line options or arguments were specified.
778.El
779.Sh HISTORY
780The
781.Nm
782utility first appeared in
783.Fx 7.1 .
784.Sh SEE ALSO
785.Xr cpp 1 ,
786.Xr elf 5 ,
787.Xr SDT 9
788.Rs
789.%T Solaris Dynamic Tracing Guide
790.Re
791