[DTrace-devel] [PATCH v2 6/6] documentation: update stapsdt docs to describe wildcard support
Alan Maguire
alan.maguire at oracle.com
Mon Jan 5 12:27:28 UTC 2026
We now have a limited form of wildcard support; document it.
Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
---
.../reference/dtrace_providers_stapsdt.md | 45 ++++++++++++++++++-
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/doc/userguide/reference/dtrace_providers_stapsdt.md b/doc/userguide/reference/dtrace_providers_stapsdt.md
index cb6ce71f..a7351609 100644
--- a/doc/userguide/reference/dtrace_providers_stapsdt.md
+++ b/doc/userguide/reference/dtrace_providers_stapsdt.md
@@ -52,12 +52,24 @@ DTrace will pass semaphore details to the kernel for reference counting.)
The `stapsdt` provider also supports probes created dynamically via `libstapsdt`.
See [https://github.com/linux-usdt/libstapsdt](https://github.com/linux-usdt/libstapsdt).
-In your D scripts, the provider name must have the pid for your process
+In your D scripts, two forms of provider specification are supported.
+
+In the first, the provider name must have the pid for your process
appended. For the provider shown above, you might have `myprovider12345` for
-pid 12345. No wildcard may be used, but a symbolic value like `$target` may.
+pid 12345. A symbolic value like `$target` may be used also.
+
+In the second approach, a wildcard may be used, but it must be used
+in combination with the name of binary or library. DTrace will use
+PATH or LD_LIBRARY_PATH to find the absolute path and add instrumentation.
+Probes are added on a file basis, so it is vital to specify the correct
+file that contains the probe; unlike in the per-process case we need to
+know if a probe is delivered in a library or in a program for example.
In your D scripts, the `stapsdt` module name may be `a.out`, just as with
the [`pid` provider](dtrace_providers_pid.md#dt_ref_pidprobes_prov).
+However as noted above, for a wildcarded pid a filename discoverable
+via PATH or LD_LIBRARY_PATH must be specified so that DTrace can find
+the file to instrument.
In probe names, two consecutive underscores \(`__`\) become a dash \(`-`\)
just as with USDT probe names. For example, if a probe is defined in source
@@ -154,6 +166,35 @@ installs `/usr/bin/dtrace`. So be sure to have `/usr/sbin`
in front of `/usr/bin` in your path, or explicitly specify
`/usr/sbin/dtrace` whenever you want to use `dtrace`.
+We can also specify systemwide probes; for example when Python 3.6 is
+built `--with-dtrace` we can do the following to show the top 5
+function-entry calls system-wide:
+
+```
+$ sudo dtrace -qn 'python*:libpython3.6m.so::function-entry {
+ @c[execname,stringof(arg0),stringof(arg1)] = count();
+}
+END {
+ trunc(@c, 5);
+ printf("%10s %35s %20s %10s\n", "PROG", "FILE", "FUNC", "COUNT");
+ printa("%10s %35s %20s %@10d\n", @c);
+}'
+^C
+ PROG FILE FUNC COUNT
+ tuned /usr/lib64/python3.6/threading.py __exit__ 5
+ tuned /usr/lib64/python3.6/threading.py _acquire_restore 5
+ tuned /usr/lib64/python3.6/threading.py _is_owned 5
+ tuned /usr/lib64/python3.6/threading.py _release_save 5
+ tuned /usr/lib64/python3.6/threading.py wait 10
+```
+
+So we see the top 5 functions called were all called by `tuned`.
+
+We specified `libpython.3.6m.so` because that is where the probes are
+defined; in some cases they are in the python3 program itself, and cavets
+mentioned above about identifying whether probes are in a library or a
+program (in this case libypthon3.6.m.so or python3.6) apply.
+
## stapsdt Stability <a id="dt_ref_stapsdtstab_prov">
The `stapsdt` provider uses DTrace's stability mechanism to describe its stabilities.
--
2.43.5
More information about the DTrace-devel
mailing list