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 April 2, 2021 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 libdir Ns = Ns Ar path 606Add a directory to the system library path. 607.It Sy nspec Ns = Ns Ar scalar 608Number of speculations. 609.It Sy nolibs 610Do not load D system libraries. 611.It Sy quiet 612Set quiet mode. 613Same as the 614.Fl q 615flag. 616.It Sy specsize Ns = Ns Ar size 617Size of the speculation buffer. 618.It Sy strsize Ns = Ns Ar size 619Maximum size of strings. 620.It Sy stackframes Ns = Ns Ar scalar 621Maximum number of kernelspace stack frames to unwind when executing the 622.Fn stack 623action. 624.It Sy stackindent Ns = Ns Ar scalar 625Number of whitespace characters to use when indenting 626.Fn stack 627and 628.Fn ustack 629output. 630.It Sy statusrate Ns = Ns Ar time 631Rate of status checking. 632.It Sy switchrate Ns = Ns Ar time 633Rate of buffer switching. 634.It Sy syslibdir Ns = Ns Ar path 635Path to system libraries. 636Defaults to 637.Pa /usr/lib/dtrace . 638.It Sy ustackframes Ns = Ns Ar scalar 639Maximum number of userspace stack frames to unwind when executing the 640.Fn ustack 641action. 642.El 643.It Fl X Cm a | c | s | t 644Specify the degree of conformance to the ISO C standard that should be selected 645when invoking 646.Xr cpp 1 647(enabled using the 648.Fl C 649option). 650The 651.Fl X 652option argument affects the value and presence of the __STDC__ macro depending 653upon the value of the argument letter. 654.sp 655The 656.Fl X 657option supports the following arguments: 658.Bl -tag -width indent 659.It a 660Default. 661ISO C plus K&R compatibility extensions, with semantic changes required by ISO 662C. 663This is the default mode if 664.Fl X 665is not specified. 666The predefined macro __STDC__ has a value of 0 when 667.Xr cpp 1 668is invoked in conjunction with the 669.Fl Xa 670option. 671.It c 672Conformance. 673Strictly conformant ISO C, without K&R C compatibility extensions. 674The predefined macro __STDC__ has a value of 1 when 675.Xr cpp 1 676is invoked in conjunction with the 677.Fl \&Xc 678option. 679.It s 680K&R C only. 681The macro __STDC__ is not defined when 682.Xr cpp 1 683is invoked in conjunction with the 684.Fl Xs 685option. 686.It t 687Transition. 688ISO C plus K&R C compatibility extensions, without semantic changes required by 689ISO C. 690The predefined macro __STDC__ has a value of 0 when 691.Xr cpp 1 692is invoked in conjunction with the 693.Fl Xt 694option. 695.El 696.Pp 697As the 698.Fl X 699option only affects how the D compiler invokes the C preprocessor, the 700.Fl Xa 701and 702.Fl Xt 703options are equivalent from the perspective of D and both are provided only to 704ease re-use of settings from a C build environment. 705.Pp 706Regardless of the 707.Fl X 708mode, the following additional C preprocessor definitions are always specified 709and valid in all modes: 710.Bl -bullet -offset indent 711.It 712__sun 713.It 714__unix 715.It 716__SVR4 717.It 718__sparc (on SPARC systems only) 719.It 720__sparcv9 (on SPARC systems only when 64-bit programs are compiled) 721.It 722__i386 (on x86 systems only when 32-bit programs are compiled) 723.It 724__amd64 (on x86 systems only when 64-bit programs are compiled) 725.It 726__`uname -s`_`uname -r` (for example, 727.Ql FreeBSD_9.2-RELEASE . 728.It 729__SUNW_D=1 730.It 731.No __SUNW_D_VERSION=0x Ns Ar MMmmmuuu 732.Pp 733Where 734.Ar MM 735is the major release value in hexadecimal, 736.Ar mmm 737is the minor release value in hexadecimal, and 738.Ar uuu 739is the micro release value in hexadecimal. 740.El 741.It Fl Z 742Permit probe descriptions that match zero probes. 743If the 744.Fl Z 745option is not specified, 746.Nm 747reports an error and exits if any probe descriptions specified in D program 748files 749.Fl ( s 750option) or on the command line 751.Fl ( P , m , f , n , 752or 753.Fl i 754options) contain descriptions that do not match any known probes. 755.El 756.Sh OPERANDS 757You can specify zero or more additional arguments on the 758.Nm 759command line to define a set of macro variables and so forth). 760The additional arguments can be used in D programs specified using the 761.Fl s 762option or on the command line. 763.Sh FILES 764.Bl -tag -width /boot/dtrace.dof -compact 765.It Pa /boot/dtrace.dof 766File for anonymous tracing directives. 767.El 768.Sh EXIT STATUS 769The following exit statuses are returned: 770.Bl -tag -width indent 771.It 0 772Successful completion. 773.Pp 774For D program requests, an exit status of 0 indicates that programs were 775successfully compiled, probes were successfully enabled, or anonymous state 776was successfully retrieved. 777.Nm 778returns 0 even if the specified tracing requests encountered errors or drops. 779.It 1 780An error occurred. 781.Pp 782For D program requests, an exit status of 1 indicates that program compilation 783failed or that the specified request could not be satisfied. 784.It 2 785Invalid command line options or arguments were specified. 786.El 787.Sh HISTORY 788The 789.Nm 790utility first appeared in 791.Fx 7.1 . 792.Sh SEE ALSO 793.Xr cpp 1 , 794.Xr elf 5 , 795.Xr SDT 9 796.Rs 797.%T Solaris Dynamic Tracing Guide 798.Re 799