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 September 8, 2023 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.It Sy flowindent 621Turn on flow indentation. 622Same as the 623.Fl F 624flag. 625.It Sy grabanon 626Claim anonymous state. 627Same as the 628.Fl a 629flag. 630.It Sy jstackframes Ns = Ns Ar scalar 631Number of default stack frames for 632.Fn jstack . 633.It Sy jstackstrsize Ns = Ns Ar scalar 634Default string space size for 635.Fn jstack . 636.It Sy ldpath Ns = Ns Ar path 637When 638.Fl G 639is specified, use the specified path for a static linker 640rather than searching for 641.Dq "ld" 642in 643.Ev PATH . 644.It Sy libdir Ns = Ns Ar path 645Add a directory to the system library path. 646.It Sy nspec Ns = Ns Ar scalar 647Number of speculations. 648.It Sy nolibs 649Do not load D system libraries. 650.It Sy quiet 651Set quiet mode. 652Same as the 653.Fl q 654flag. 655.It Sy specsize Ns = Ns Ar size 656Size of the speculation buffer. 657.It Sy strsize Ns = Ns Ar size 658Maximum size of strings. 659.It Sy stackframes Ns = Ns Ar scalar 660Maximum number of kernelspace stack frames to unwind when executing the 661.Fn stack 662action. 663.It Sy stackindent Ns = Ns Ar scalar 664Number of whitespace characters to use when indenting 665.Fn stack 666and 667.Fn ustack 668output. 669.It Sy oformat Ns = Ns Ar format 670Specify the format to use for output. 671Setting 672.Sy oformat 673to 674.Ql text 675makes 676.Nm 677use regular human-readable output which is its default behavior. 678The options passed to 679.Sy oformat 680are directly forwarded to 681.Xr libxo 3 . 682Some of the supported formatters include 683.Ql json , 684.Ql xml 685and 686.Ql html . 687Note that this option will cause 688.Nm 689to not produce any output unless printing functions are explicitly called, 690or the 691.Fl O 692flag is specified. 693For more information see 694.Sx STRUCTURED OUTPUT . 695.It Sy statusrate Ns = Ns Ar time 696Rate of status checking. 697.It Sy switchrate Ns = Ns Ar time 698Rate of buffer switching. 699.It Sy syslibdir Ns = Ns Ar path 700Path to system libraries. 701Defaults to 702.Pa /usr/lib/dtrace . 703.It Sy ustackframes Ns = Ns Ar scalar 704Maximum number of userspace stack frames to unwind when executing the 705.Fn ustack 706action. 707.El 708.It Fl X Cm a | c | s | t 709Specify the degree of conformance to the ISO C standard that should be selected 710when invoking 711.Xr cpp 1 712(enabled using the 713.Fl C 714option). 715The 716.Fl X 717option argument affects the value and presence of the __STDC__ macro depending 718upon the value of the argument letter. 719.sp 720The 721.Fl X 722option supports the following arguments: 723.Bl -tag -width indent 724.It a 725Default. 726ISO C plus K&R compatibility extensions, with semantic changes required by ISO 727C. 728This is the default mode if 729.Fl X 730is not specified. 731The predefined macro __STDC__ has a value of 0 when 732.Xr cpp 1 733is invoked in conjunction with the 734.Fl Xa 735option. 736.It c 737Conformance. 738Strictly conformant ISO C, without K&R C compatibility extensions. 739The predefined macro __STDC__ has a value of 1 when 740.Xr cpp 1 741is invoked in conjunction with the 742.Fl \&Xc 743option. 744.It s 745K&R C only. 746The macro __STDC__ is not defined when 747.Xr cpp 1 748is invoked in conjunction with the 749.Fl Xs 750option. 751.It t 752Transition. 753ISO C plus K&R C compatibility extensions, without semantic changes required by 754ISO C. 755The predefined macro __STDC__ has a value of 0 when 756.Xr cpp 1 757is invoked in conjunction with the 758.Fl Xt 759option. 760.El 761.Pp 762As the 763.Fl X 764option only affects how the D compiler invokes the C preprocessor, the 765.Fl Xa 766and 767.Fl Xt 768options are equivalent from the perspective of D and both are provided only to 769ease re-use of settings from a C build environment. 770.Pp 771Regardless of the 772.Fl X 773mode, the following additional C preprocessor definitions are always specified 774and valid in all modes: 775.Bl -bullet -offset indent 776.It 777__sun 778.It 779__unix 780.It 781__SVR4 782.It 783__sparc (on SPARC systems only) 784.It 785__sparcv9 (on SPARC systems only when 64-bit programs are compiled) 786.It 787__i386 (on x86 systems only when 32-bit programs are compiled) 788.It 789__amd64 (on x86 systems only when 64-bit programs are compiled) 790.It 791__`uname -s`_`uname -r` (for example, 792.Ql FreeBSD_9.2-RELEASE . 793.It 794__SUNW_D=1 795.It 796.No __SUNW_D_VERSION=0x Ns Ar MMmmmuuu 797.Pp 798Where 799.Ar MM 800is the major release value in hexadecimal, 801.Ar mmm 802is the minor release value in hexadecimal, and 803.Ar uuu 804is the micro release value in hexadecimal. 805.El 806.It Fl Z 807Permit probe descriptions that match zero probes. 808If the 809.Fl Z 810option is not specified, 811.Nm 812reports an error and exits if any probe descriptions specified in D program 813files 814.Fl ( s 815option) or on the command line 816.Fl ( P , m , f , n , 817or 818.Fl i 819options) contain descriptions that do not match any known probes. 820.El 821.Sh STRUCTURED OUTPUT 822.Nm 823supports structured output using 824.Xr libxo 3 . 825The output will always have a top-level object called 826.Dq dtrace , 827followed by a list of objects 828.Dq probes . 829Each of the probe objects will to have a timestamp which is generated at 830output time rather than probe firing time, an identifier for the CPU on 831which the probe was executed, and the probe's full specification: 832.Bd -literal 833{ 834 "dtrace": { 835 "probes": [ 836 { 837 "timestamp": ..., 838 "cpu": ..., 839 "id": ..., 840 "provider": ..., 841 "module": ..., 842 "function": ..., 843 "name": ..., 844 "output": [ 845 ... (script-specific output) 846 ] 847 } 848 ] 849 } 850} 851 852<?xml version="1.0"?> 853<dtrace> 854 <probes> 855 <timestamp>...</timestamp> 856 <cpu>...</cpu> 857 <id>...</id> 858 <provider>...</provider> 859 <module>...</module> 860 <function>...</function> 861 <name>...</name> 862 <output> 863 ... (script-specific output) 864 </output> 865 </probes> 866</dtrace> 867.Ed 868.Pp 869It is also possible for XML output to take the following form if some 870of the fields are empty (in this example, module and function values 871are absent): 872.Bd -literal 873<?xml version="1.0"?> 874<dtrace> 875 <probes> 876 ... 877 <module/> 878 <function/> 879 ... 880 <output> 881 ... (script-specific output) 882 </output> 883 </probes> 884</dtrace> 885.Ed 886.Pp 887Similarly, 888.Sy oformat 889can be used to generate HTML: 890.Bd -literal 891<div class="line"> 892<div class="data" data-tag="timestamp">...</div> 893<div class="text"></div> 894<div class="data" data-tag="cpu">...</div> 895<div class="text"></div> 896<div class="data" data-tag="id">...</div> 897<div class="text"></div> 898<div class="data" data-tag="provider">...</div> 899<div class="text"></div> 900<div class="data" data-tag="module">...</div> 901<div class="text"></div> 902<div class="data" data-tag="function">...</div> 903<div class="text"></div> 904<div class="data" data-tag="name">...</div> 905<div class="data" data-tag="... (script-specific output)">...</div> 906</div> 907.Ed 908.Pp 909Unlike JSON and XML, the 910.Dq output 911array is not present. 912Instead, data is simply formatted into a div of class 913.Dq data 914and a data-tag is associated with each of the keys. 915.Pp 916The 917.Dq output 918array's contents depend on the probes' actions and is explained below. 919The examples here are presented in JSON form as opposed to XML or HTML, 920however the conversion explained above applies for all output formats. 921.Pp 922Any scalar output, such as output produced by the 923.Fn trace 924action is of form: 925.Bd -literal 926{ 927 "value": ... 928} 929.Ed 930.Pp 931The 932.Fn printf 933action begins with an object containing the formatted output of the 934.Fn printf 935action. 936Subsequent objects contains the value of each of the arguments to 937.Fn printf 938in its raw form as if the 939.Fn trace 940action was used instead. 941A 942.Fn printf 943statement which contains no arguments other than the message will only have 944one object following the message object and its value will always be 0. 945This is an artefact of the implementation and can safely be ignored. 946.Bd -literal 947# dtrace --libxo json,pretty -n 'BEGIN { printf("... %Y, ..", walltimestamp); }' 948 949{ 950 "message": "... 2023 Sep 7 16:49:02, .." 951}, 952{ 953 "value": 1694105342633402400 954}, 955{ 956 ... 957} 958.Ed 959.Pp 960Scalar aggregations are aggregations which produce a single value for a given 961key. 962These aggregations include 963.Fn count , 964.Fn min , 965.Fn max , 966.Fn stddev 967and 968.Fn sum . 969Each one of them is represented by the key containing their name. 970For example, the output of a 971.Fn stddev 972aggregation will contain a key 973.Dq stddev 974inside an 975.Dq aggregation-data 976object: 977.Bd -literal 978{ 979 "aggregation-data": [ 980 { 981 "keys": [ 982 ... 983 ], 984 "stddev": ... 985 } 986 ], 987 "aggregation-name": ... 988} 989.Ed 990.Pp 991The 992.Dq keys 993field remains consistent across all aggregations, however 994.Fn quantize , 995.Fn lquantize 996and 997.Fn llquantize 998need to be treated differently. 999.Sy oformat 1000will create a new array of objects called 1001.Dq buckets . 1002Each of the objects contains a 1003.Dq value 1004and a 1005.Dq count 1006field which are 1007the left-hand side and the right-hand side of human-readable 1008.Nm 1009output respectively. 1010The full object has the following format: 1011.Bd -literal 1012{ 1013 "aggregation-data": [ 1014 ... 1015 { 1016 "keys": [ 1017 ... 1018 ], 1019 "buckets": [ 1020 { 1021 "value": 32, 1022 "count": 0 1023 }, 1024 { 1025 "value": 64, 1026 "count": 17 1027 }, 1028 ... 1029 ], 1030 }, 1031 ... 1032 ] 1033 "aggregation-name": ... 1034} 1035.Ed 1036.Pp 1037Similar to scalar aggregations, named scalar actions such as 1038.Fn mod , 1039.Fn umod , 1040.Fn usym , 1041.Fn tracemem 1042and 1043.Fn printm 1044will output an object with the key being equal to the 1045name of the action. 1046For example, 1047.Fn printm 1048output would produce the following object: 1049.Bd -literal 1050{ 1051 "printm": "0x4054171100" 1052} 1053.Ed 1054.Pp 1055.Fn sym 1056is slightly different. 1057While it will create a 1058.Dq sym 1059field which contains its value, in some cases it will also create additional 1060fields 1061.Dq object , 1062.Dq name 1063and 1064.Dq offset : 1065.Bd -literal 1066# dtrace -x oformat=json,pretty -On 'BEGIN { sym((uintptr_t)&`prison0); }' 1067 1068{ 1069 "sym": "kernel`prison0", 1070 "object": "kernel", 1071 "name": "prison0" 1072} 1073 1074# dtrace --libxo json,pretty -On 'BEGIN { sym((uintptr_t)curthread); }' 1075 1076{ 1077 "sym": "0xfffffe00c18d2000", 1078 "offset": "0xfffffe00c18d2000" 1079} 1080.Ed 1081.Pp 1082.Fn stack 1083and 1084.Fn ustack 1085actions unroll each of the stack frames into its own object in an array. 1086The only real difference between them is that the 1087.Fn stack 1088action will produce a list called 1089.Dq stack-frames 1090while 1091.Fn ustack 1092will produce one called 1093.Dq ustack-frames . 1094The following is an example of their 1095.Sy oformat 1096output: 1097.Bd -literal 1098{ 1099 "stack-frames": [ 1100 { 1101 "symbol": "dtrace.ko`dtrace_dof_create+0x35", 1102 "module": "dtrace.ko", 1103 "name": "dtrace_dof_create", 1104 "offset": "0x35" 1105 }, 1106 { 1107 "symbol": "dtrace.ko`dtrace_ioctl+0x81c", 1108 "module": "dtrace.ko", 1109 "name": "dtrace_ioctl", 1110 "offset": "0x81c" 1111 }, 1112 ... 1113 ] 1114} 1115 1116{ 1117 "ustack-frames": [ 1118 { 1119 "symbol": "libc.so.7`ioctl+0xa", 1120 "module": "libc.so.7", 1121 "name": "ioctl", 1122 "offset": "0xa" 1123 }, 1124 { 1125 "symbol": "libdtrace.so.2`dtrace_go+0xf3", 1126 "module": "libdtrace.so.2", 1127 "name": "dtrace_go", 1128 "offset": "0xf3" 1129 }, 1130 ... 1131 ] 1132} 1133.Ed 1134.Pp 1135The 1136.Fn print 1137action produces a 1138.Dq type 1139list in the following form: 1140.Bd -literal 1141{ 1142 "type": [ 1143 { 1144 "object-name": "kernel", 1145 "name": "struct thread", 1146 "ctfid": 2372 1147 }, 1148 { 1149 "member-name": "td_lock", 1150 "name": "struct mtx *volatile", 1151 "ctfid": 2035, 1152 "value": "0xffffffff82158440" 1153 }, 1154 ... 1155} 1156.Ed 1157.Pp 1158If the type is invalid, a 1159.Dq warning 1160object will be produced containing the diagnostic message as well as two 1161possible optional fields: 1162.Dq type-identifier 1163which contains the CTF identifier of the type and 1164.Dq size containing the size of an integer, enum or float. 1165The fields generated will depend on the kind of error that was encountered 1166while processing the trace data. 1167.Pp 1168Finally, 1169.Sy oformat 1170provides a special pseudo-probe to represent drops. 1171As 1172.Nm 1173polls for various kinds of drops 1174.Sy oformat 1175will produce output similar to the following in order to represent drops: 1176.Bd -literal 1177{ 1178 "cpu": -1, 1179 "id": -1, 1180 "provider": "dtrace", 1181 "module": "INTERNAL", 1182 "function": "INTERNAL", 1183 "name": "DROP", 1184 "timestamp": ..., 1185 "count": ..., 1186 "total": ..., 1187 "kind": 2, 1188 "msg": "... dynamic variable drops\n" 1189} 1190.Ed 1191.Sh OPERANDS 1192You can specify zero or more additional arguments on the 1193.Nm 1194command line to define a set of macro variables and so forth). 1195The additional arguments can be used in D programs specified using the 1196.Fl s 1197option or on the command line. 1198.Sh FILES 1199.Bl -tag -width /boot/dtrace.dof -compact 1200.It Pa /boot/dtrace.dof 1201File for anonymous tracing directives. 1202.El 1203.Sh EXIT STATUS 1204The following exit statuses are returned: 1205.Bl -tag -width indent 1206.It 0 1207Successful completion. 1208.Pp 1209For D program requests, an exit status of 0 indicates that programs were 1210successfully compiled, probes were successfully enabled, or anonymous state 1211was successfully retrieved. 1212.Nm 1213returns 0 even if the specified tracing requests encountered errors or drops. 1214.It 1 1215An error occurred. 1216.Pp 1217For D program requests, an exit status of 1 indicates that program compilation 1218failed or that the specified request could not be satisfied. 1219.It 2 1220Invalid command line options or arguments were specified. 1221.El 1222.Sh SEE ALSO 1223.Xr cpp 1 , 1224.Xr elf 5 , 1225.Xr SDT 9 1226.Rs 1227.%T Solaris Dynamic Tracing Guide 1228.Re 1229.Sh HISTORY 1230The 1231.Nm 1232utility first appeared in 1233.Fx 7.1 . 1234