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