dtrace(8)
π dtrace(8) β Linux Programmer's Manual π
NAME
dtrace β DTrace dynamic tracing compiler and tracing utility. No cap, that's the whole name.
SYNOPSIS
dtrace [-CeFGHhlqSvVwZ] [-b bufsz] [-c cmd]
[-D name [=value]] [-I path] [-L path] [-o output]
[-s script] [-U name] [-x arg [=val]]
[-X a | c | s | t] [-p pid]
[-P provider [[predicate] action]]
[-m [provider:] module [[predicate] action]]
[-f [[provider:] module:] function [[predicate] action]]
[-n [[[provider:] module:] function:]name [[predicate] action]]
[-i probe-id [[predicate] action]]
DESCRIPTION
DTrace is a comprehensive dynamic tracing framework for the Linux operating system. It's giving powerful infrastructure, fr fr. DTrace provides a powerful infrastructure that permits administrators, developers, and service personnel to concisely answer arbitrary questions about the behavior of the operating system and user programs.
The Oracle Linux DTrace Guide describes how to use DTrace to observe, debug, and tune system behavior. Refer to this book for a detailed description of DTrace features, including the bundled DTrace observability tools, instrumentation providers, and the D programming language.
The dtrace command provides a generic interface to the essential services provided by the DTrace facility, including:
- Options that list the set of probes and providers currently published by DTrace
- Options that enable probes directly using any of the probe description specifiers (provider, module, function, name)
- Options that run the D compiler and compile one or more D program files or programs written directly on the command line
- Options that generate anonymous tracing programs
- Options that generate program stability reports
- Options that modify DTrace tracing and buffering behavior and enable additional D compiler features
You can use dtrace to create D scripts by using it in a #! declaration to create an interpreter file. You can also use dtrace to attempt to compile D programs and determine their properties without actually enabling tracing using the -e option. See OPTIONS. See the Oracle Linux DTrace Guide for detailed examples of how to use the dtrace utility to perform these tasks.
OPTIONS
Okay so bestie, the arguments accepted by the -P, -m, -f, -n, and -i options can include an optional D language predicate enclosed in slashes // and optional D language action statement list enclosed in braces {}. D program code specified on the command line must be appropriately quoted to avoid interpretation of meta-characters by the shell. Periodt.
The following options are supported:
-b bufszβ Sets the principal trace buffer size, akabufsz. You can throw in any of the size suffixesk,m,g, ortβ slay. If the buffer space can't be allocated,dtracewill try to shrink the buffer size or just exit, depending on how thebufresizeproperty is set.-c cmdβ Runs the command you gave ascmd, then dips out when it's done. If you stack more than one-con the command line,dtracewaits until all the commands have exited, and it reports the exit status for each child process as it terminates. The process-ID of the first command gets handed to any D programs you specified on the command line or with-s, through the$targetmacro variable. The Oracle Linux DTrace Guide has more on macro variables, iykyk.-Cβ Runs the C preprocessorcpp(1)over your D programs before compiling them. You can pass options tocppwith-D,-U,-I, and-H. If you want to pick how hard it conforms to C standard, use-X. For the tea on the set of tokens the D compiler defines when it invokes the C preprocessor, go look at-X.-D name [=value]β Definesnamewhen invokingcpp(1)(this is enabled by-C). If you add the equals sign (=) plus avalue, thennamegets assigned that value. This option passes-Dto everycppinvocation.-eβ Exits after compiling any requests, but before enabling any probes. You can pair it with D compiler options. This combo checks that the programs compile without actually running them or turning on the matching instrumentation.-f[[provider:]module:]function[[predicate]action]]β Says whichfunctionto trace or list (listing needs-l). The argument can be any of these probe description forms:provider:module:function,module:function, orfunction. Fields you leave unspecified stay blank and match any probes no matter what's in those fields. If you only specifyfunctionand no other qualifiers, every probe with that function gets matched. You can tack an optional D probe clause onto the-fargument. And yes, you can use more than one-fon the command line at a time.-Fβ Coalesces trace output by spotting function entry and return. Function entry probe reports get indented and their output starts with->. Function return probe reports get unindented and their output starts with<-. System call entry probe reports get indented and their output starts with=>. System call return probe reports get unindented and their output starts with<=.-Gβ Generates an ELF file with an embedded DTrace program. The DTrace probes you named in the program get saved inside a relocatable ELF object that can be linked into another program. If-ois present, the ELF file is saved using the pathname you gave as that operand. If-ois not present and the DTrace program lives in a file namedfilename.d, the ELF file is saved asfilename.o. Otherwise the ELF file is saved asd.out.-Hβ Prints the pathnames of included files when invokingcpp(1)(enabled by-C). This passes-Hto eachcppinvocation, so it shows the list of pathnames, one per line, tostderr.-hβ Generates a header file with macros that correspond to probes in the provider definitions you specified. Use this when you want a header file that other source files can include, for later use with-G. If-ois present, the header file is saved using the pathname you gave for that option. If-ois not present and the DTrace program lives in a file namedfilename.d, the header file is saved asfilename.h.-i probe-id[[predicate] action]β Says which probe identifier (probe-id) to trace or list (listing needs-l). You can write probe IDs as decimal integers, exactly likedtrace -lshows them. You can suffix the-iargument with an optional D probe clause. And you can use more than one-iat a time.-I pathβ Adds the directorypathto the search path for#includefiles when invokingcpp(1)(enabled by-C). This passes-Ito everycppinvocation. The path you give gets inserted into the search path ahead of the default directory list.-L pathβ Adds the directorypathto the search path for DTrace libraries. DTrace libraries hold common definitions you can use when writing D programs. Thepathyou give is added after the default library search path. If it exists, a subdirectory ofpathnamed after the minor version of the running kernel (e.g.3.8) gets searched immediately beforepath. (But lowkey take note: dependency analysis happens only within each directory, not across directories.)-lβ Lists probes instead of enabling them. If you use-l,dtracespits out a report of the probes that match the descriptions you gave with-P,-m,-f,-n,-i, and-s. If you gave none of those options, this lists all probes.-m [[provider:] module: [[predicate] action]]β Says whichmoduleto trace or list (listing needs-l). The argument can be any of these probe description forms:provider:moduleormodule. Fields you leave unspecified stay blank and match any probes no matter what's in those fields. If you only specifymoduleand no other qualifiers, every probe with a matching module gets matched. You can tack an optional D probe clause onto the-margument. More than one-mcan go on the command line at a time.-n [[[provider:] module:] function:] name [[predicate] action]β Says which probenameto trace or list (listing needs-l). The argument can be any of these probe description forms:provider:module:function:name,module:function:name,function:name, orname. Fields you leave unspecified stay blank and match any probes no matter what's in those fields. If you only specifynameand no other qualifiers, every probe with a matching name gets matched. You can tack an optional D probe clause onto the-nargument. More than one-ncan go on the command line at a time.-o outputβ Sets the output file for the-G,-h, and-loptions, or for the traced data itself. If-Gis present and the-soption's argument looks likefilename.dand-ois not present, the default output file isfilename.o. Otherwise the default output file isd.out.-p pidβ Grabs the process-IDpid, caches its symbol tables, and exits when it's done. If you put more than one-pon the command line,dtraceexits when all commands have exited, and it reports the exit status for each process as it terminates. The first process-ID gets handed to any D programs you specified on the command line or with-s, through the$targetmacro variable. The Oracle Linux DTrace Guide has more on macro variables.-Pprovider[[predicate] action]β okay so this one says "trace or list (with-l) this provider." The leftover probe description fields βmodule,function, andnameβ are left blank and match any probes no matter what those fields say. The-Pargument can be suffixed with an optional D probe clause. And yes, you can specify more than one-Poption on the command line at a time. π-qβ quiet mode, bestie.dtracesuppresses messages like the number of probes matched by the specified options and D programs. It also does not print column headers, the CPU ID, the probe ID, or insert newlines into the output. Only data traced and formatted by D program statements such astrace()andprintf()is displayed to stdout. π€«-sβ compile the specified D program source file. If the-eoption is present, the program is compiled but instrumentation is not enabled. If the-loption is present, the program is compiled and the set of probes matched by it is listed, but instrumentation is not enabled. If none of-e,-l, or-Gare present, the instrumentation specified by the D program is enabled and tracing begins. β¨-Sβ show D compiler intermediate code. The D compiler produces a report of the intermediate code generated for each D program tostderr. π-Uname β undefine the specified name when invokingcpp(1)(enabled using the-Coption). This option passes the-Uoption to eachcppinvocation. π«Ά-vβ set verbose mode. If the-voption is specified,dtraceproduces a program stability report showing the minimum interface stability and dependency level for the specified D programs. DTrace stability levels are explained in further detail in the Oracle Linux DTrace Guide. π-Vβ report the highest D programming interface version supported bydtrace. The version information is printed to stdout and thedtracecommand exits. Refer to the Oracle Linux DTrace Guide for more information about DTrace versioning features. In conjunction with-v, also reports information on the version of thedtrace(1)tool and associated library. π-wβ permit destructive actions in D programs specified using the-s,-P,-m,-f,-n, or-ioptions. If the-woption is not specified,dtracedoes not permit the compilation or enabling of a D program that contains destructive actions. β οΈ-xarg[=val]β enable or modify a DTrace runtime option or D compiler option. The list of options is found in the Oracle Linux DTrace Guide. Boolean options are enabled by specifying their name. Options with values are set by separating the option name and value with an equals sign (=). π§-Zβ permit probe descriptions that match zero probes. If the-Zoption is not specified,dtracereports an error and exits if any probe descriptions specified in D program files (-soption) or on the command line (-P,-m,-f,-n, or-ioptions) contain descriptions that do not match any known probes. π
π OPERANDS π
You can specify zero or more additional arguments on the dtrace command line to define a set of macro variables ($1, $2, and so forth). The additional arguments can be used in D programs specified using the -s option or on the command line. The use of macro variables is described further in the Oracle Linux DTrace Guide. π§
π EXIT STATUS π
The following exit values are returned:
0β Successful completion. For D program requests, an exit status of0indicates that programs were successfully compiled, probes were successfully enabled, or anonymous state was successfully retrieved.dtracereturns0even if the specified tracing requests encountered errors or drops. β1β An error occurred. For D program requests, an exit status of1indicates that program compilation failed or that the specified request could not be satisfied. π2β Invalid command line options or arguments were specified. π
π¦ ENVIRONMENT VARIABLES π¦
The following environment variables are consulted:
DTRACE_DEBUGβ Printlibdtracedebugging output on standard error. πLIBCTF_DEBUGβ Print CTF type library debugging output on standard error. πDTRACE_OPT_*β Set a given DTrace option. Options set this way are overridden both by options specified via-xon the command line, and bysetoptstatements. π
π SEE ALSO π
πΈ USAGE πΈ
When using the -p flag, dtrace stops the target processes while it is inspecting them and reporting results. A process can do nothing while it is stopped. This means that, if, for example, the X server is inspected by dtrace running in a window under the X server's control, the whole window system can become deadlocked, because the dtrace tool would be attempting to display its results to a window that cannot be refreshed. In such a case, logging in from another system using ssh(1) and killing the offending dtrace tool clears the deadlock. π¨
This whole masterpiece is from Oracle Linux, dated 22 Oct 2014, and it's the dtrace(8) page. Periodt. π
π¦ where this page comes from
- ubuntu resolute: dtrace 2.0.6-1 Β· UPL-1.0
- ubuntu stonking: dtrace 2.0.7-3 Β· UPL-1.0
- Copyright (c) 2009, 2024, Oracle and/or its affiliates. All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms