DTRACE(1)
π DTRACE(1) β General Commands Manual β¨
okay bestie, sit down, hydrate, and let me tell you about dtrace β the Dtrace compatible user application static probe generation tool. yes that's a mouthful. it's fine. she's iconic and she knows it. π«Ά
πΈ NAME πΈ
dtrace β the Dtrace compatible user application static probe generation tool. that's it, that's her whole job, and she does it flawlessly. π
π¦ SYNOPSIS π¦
dtrace -s file [OPTIONS]
literally that's the shape of it. -s gives her the file, and then [OPTIONS] is where you get to be a little extra. π
β¨ DESCRIPTION β¨
so here's the tea: the dtrace command takes probe descriptions that you defined over in file.d and converts them into⦠something useful. specifically:
- a probe header file, if you pass the
-hoption π - a probe description file, if you pass the
-Goption π
that's the whole vibe. you write the probes, she does the translating. main character energy fr fr.
π OPTIONS π
-hβ generate a systemtap header file. slay.-Gβ generate a systemtap probe definition object file. she invokes the C compiler with a sensible set of compiler flags, because she's thoughtful like that. need to add more? flags chillin' in theCFLAGSenvironment variable get transcribed over to the compiler. and if that's still not enough control for you (valid, love that for you), use the-koption to capture the generated C file and compile it however you need. π-ofile β this is the name of the output file. and here's the cute part: if you gave-G, the output file will be called file.o; if you gave-h, the output file will be called file.h. β¨-Cβ run thecpppreprocessor on the input file when the-hoption is given.-Ifile β give this include path tocppwhen the-Coption is given.-kβ keep temporary files, for example the C language source for the-Goption. no takebacks, no cleanup, we keep the receipts. π
π₯ EXAMPLES π₯
Systemtap is source compatible with dtrace user application static probe support. ngl that's the whole point.
so say you've got a file test.d containing this:
provider sdt_probes
{
probe test_0 (int type);
probe test_1 (struct astruct node);
};
struct astruct {int a; int b;};
then boom:
- the command
dtrace -s test.d -Gwill create the probe definition filetest.oπ₯ - the command
dtrace -stest.d -hwill create the probe header filetest.hβ¨
subsequently (love that word, very fancy) the application can use the generated macros this way:
#include "test.h"
...
struct astruct s;
...
SDT_PROBES_TEST_0(value);
...
if (SDT_PROBES_TEST_1_ENABLED())
SDT_PROBES_TEST_1(expensive_function(s));
look at those macros go. we love a generated-macro moment. π
π§ SEMAPHORES π§
okay so semaphores. they're flag variables that probes use as a way of bypassing potentially costly processing β specifically, the work of preparing arguments for probes that may not even be active. why do all that cooking if nobody's eating, right? π
they are automatically set/cleared by systemtap when a relevant script is running, so the argument setup cost is only paid when it's actually necessary. those semaphore variables are defined within the test.o object file β which means that object file must therefore be linked into an application. no test.o, no semaphores. periodt. π
but sometimes? semaphore variables are not necessary nor helpful. and skipping them can simplify the build process, by omitting the extra test.o file. to skip dependence upon semaphore variables, include <sys/sdt.h> within the application before test.h:
#include <sys/sdt.h>
#include "test.h"
...
struct astruct s;
...
SDT_PROBES_TEST_0(value);
...
if (SDT_PROBES_TEST_1_ENABLED())
SDT_PROBES_TEST_1(cheap_function(s));
heads up bestie: in this mode, theENABLED()test is fixed at1. so yeah. it's giving "always on." π«Ά
π SEE ALSO π
go read them, i'll wait. π
π BUGS π
found a bug? use the Bugzilla link of the project web page or our mailing list:
http://sourceware.org/systemtap/<systemtap@sourceware.org>error::reporting(7stap)https://sourceware.org/systemtap/wiki/HowToReportBugs
please actually report it and don't just suffer in silence, that's not the vibe. π
and that's the whole page, bestie! this one came out of the General Commands Manual under the name DTRACE(1) β so yeah, dtrace(1), section 1, general commands, that's our girl. no date or version stamp on this footer, just her name in lights. k bye, go write some probes πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- arch rolling: systemtap 5.6-1 Β· GPL-2.0-or-later
- centos-stream 10: systemtap-sdt-dtrace 5.6-3.el10 Β· GPL-2.0-or-later AND CC0-1.0
- centos-stream 9: systemtap-sdt-dtrace 5.6-3.el9 Β· GPL-2.0-or-later AND CC0-1.0
- fedora 43: systemtap-sdt-dtrace 5.3-4.fc43 Β· GPL-2.0-or-later AND CC0-1.0
- fedora 43: systemtap-sdt-dtrace 5.6-1.fc43 Β· GPL-2.0-or-later AND CC0-1.0
- fedora 44: systemtap-sdt-dtrace 5.4-3.fc44 Β· GPL-2.0-or-later AND CC0-1.0
- fedora 44: systemtap-sdt-dtrace 5.6-1.fc44 Β· GPL-2.0-or-later AND CC0-1.0
- nixos 26.05: systemtap 5.4
- nixpkgs unstable: systemtap 5.5
- ubuntu resolute: systemtap-sdt-dev 5.3-2
- ubuntu stonking: systemtap-sdt-dev 5.5-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms