* [PATCH v4 0/9] stapsdt provider: simple system-wide probing
@ 2026-01-19 14:22 Alan Maguire
2026-01-19 14:22 ` [PATCH v4 1/9] dt_lex: support '/' in probe descriptors Alan Maguire
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
This series adds wildcard support to stapsdt probes to allow
tracing system-wide; this has caveats due to the way the kernel
implements probe addition. In essence, probes are added on a
per-inode basis (actually in the VMA associated with the inode)
so it is necessary to identify the file where probes are found.
Probes will fire for existing and new processes (the RFC incorrectly
said they will not work for existing binaries; they in fact do).
Patch 2 describes the approach; to facilitate systemwide tracing
we need to tell DTrace the name of the binary/library via either
using module absolute path (patch 1 updates parsing to support use
of a '/' in a module descriptor to faciliate this support) or an
module name; to expand this we then use [LD_LIBRARY_]PATH
to resolve the full path. ELF reading of the file and insertion
of probes then proceeds in a similar manner to per-pid tracing.
Patches 3-8 test various aspects of systemwide probes; basic
binary support, library support, listing support and is-enabled
probes support, and use of absolute paths.
Tests ensure wildcards work for
1. a process started prior to DTrace
2. a process started by DTrace (-c)
3. two processes started after DTrace is running
(via system())
Patch 9 updates docs to describe stapsdt wildcard support.
Changes since v3:
- Semaphores need to be more carefully declared to handle
the is-enabled case where the process is not running when
DTrace starts tracing; the kernel handles reference counts
so the probes must be added to the ".probes" section; see
patches 8/9 for how this is done.
- Modified tests to start an instance of the test program
prior to DTrace execution and start two further during
DTrace execution; ensure we see probe firings for all
4 of these processes before declaring success (Kris,
patches 3, 4, 5, 8)
Changes since v2:
- support absolute paths (patch 1, 2)
- add tests for absolute paths (patch 4, 7)
- document systemwide probe support for listing/using absolute
paths (patch 9)
Changes since RFC:
- update documentation/commit messages to reflect that we also
catch existing programs/libraries when probes are enabled
- fixup provider name for wildcard probes to be 'provider*'
rather than using the confusing 'provider-1' since the
latter is the concatenation of probename and pid (-1 is
used to connote all pids)
- add test for is-enabled systemwide probes
*** BLURB HERE ***
Alan Maguire (9):
dt_lex: support '/' in probe descriptors
stapsdt provider: support systemwide probing
test: add systemwide stapsdt note test
test: add systemwide stapsdt note test using absolute path
test: add systemwide stapsdt note test for library
stapsdt: add test for listing systemwide probes in object
stapsdt: add test for listing systemwide probes in absolute path
object
stapsdt: add systemwide test for is-enabled probes
documentation: update stapsdt docs to describe wildcard support
.../reference/dtrace_providers_stapsdt.md | 91 +++++-
libdtrace/dt_lex.l | 2 +-
libdtrace/dt_pid.c | 177 +++++++++---
libdtrace/dt_prov_uprobe.c | 17 +-
.../tst.stapsdt-notes-systemwide-abspath.r | 5 +
.../tst.stapsdt-notes-systemwide-abspath.sh | 89 ++++++
.../tst.stapsdt-notes-systemwide-isenabled.r | 13 +
.../tst.stapsdt-notes-systemwide-isenabled.sh | 266 ++++++++++++++++++
.../tst.stapsdt-notes-systemwide-l-abspath.sh | 48 ++++
.../usdt/tst.stapsdt-notes-systemwide-l.sh | 48 ++++
.../usdt/tst.stapsdt-notes-systemwide-lib.r | 14 +
.../usdt/tst.stapsdt-notes-systemwide-lib.sh | 215 ++++++++++++++
...tst.stapsdt-notes-systemwide-lv-abspath.sh | 48 ++++
.../usdt/tst.stapsdt-notes-systemwide-lv.sh | 48 ++++
.../usdt/tst.stapsdt-notes-systemwide.r | 5 +
.../usdt/tst.stapsdt-notes-systemwide.sh | 89 ++++++
16 files changed, 1123 insertions(+), 52 deletions(-)
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide.sh
--
2.43.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 1/9] dt_lex: support '/' in probe descriptors
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 2/9] stapsdt provider: support systemwide probing Alan Maguire
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
This will allow us to support paths in module descriptions.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
libdtrace/dt_lex.l | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libdtrace/dt_lex.l b/libdtrace/dt_lex.l
index fd70aa0a..a8268c44 100644
--- a/libdtrace/dt_lex.l
+++ b/libdtrace/dt_lex.l
@@ -48,7 +48,7 @@ static size_t dt_input(char *buf, size_t max_size);
%s S0 S1 S2 S3 S4 S5 SIDENT
RGX_AGG "@"[a-zA-Z_][0-9a-zA-Z_]*
-RGX_PSPEC [-$:a-zA-Z_.?*\\\[\]!][-$:0-9a-zA-Z_.`?*\\\[\]!]*
+RGX_PSPEC [-$:a-zA-Z_.?*\\\[\]!][-$:0-9a-zA-Z_.`/?*\\\[\]!]*
RGX_IDENT ([a-zA-Z_`][0-9a-zA-Z_`]*)|([0-9][0-9a-zA-Z_]*`[0-9a-zA-Z_`]*)
RGX_INT ([0-9]+|0[xX][0-9A-Fa-f]+)[uU]?[lL]?[lL]?
RGX_FP ([0-9]+("."?)[0-9]*|"."[0-9]+)((e|E)("+"|-)?[0-9]+)?[fFlL]?
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 2/9] stapsdt provider: support systemwide probing
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
2026-01-19 14:22 ` [PATCH v4 1/9] dt_lex: support '/' in probe descriptors Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 3/9] test: add systemwide stapsdt note test Alan Maguire
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
For stapsdt probes we can do systemwide probing by having
the kernel insert traps into the VMAs associated with a file.
The key problem for DTrace is how to specify a file path in
a module in a provider:module:function:probe specification.
Here the approach (also used by libbpf) is to support both
absolute paths and to expand binary/library names into full
paths using [LD_LIBRARY_]PATH from a binary/library name; so
specifying
myprov*:myprog::myprobe
causes us to search /usr/bin, /usr/sbin and PATH directories
to find myprog to instrument it. If the module contains .so
we check /usr/lib, /usr/lib64 and LD_LIBRARY_PATH. This is
beneficial as it allows scripts to be interoperable across
distros that use different directories for locating binaries.
The other part that was needed was fixups to offsets that are
optionally provided in .stapsdt.base and the addrs[1] value.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
libdtrace/dt_pid.c | 177 ++++++++++++++++++++++++++++---------
libdtrace/dt_prov_uprobe.c | 17 ++--
2 files changed, 148 insertions(+), 46 deletions(-)
diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
index 36a5883b..bd352455 100644
--- a/libdtrace/dt_pid.c
+++ b/libdtrace/dt_pid.c
@@ -7,7 +7,9 @@
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/sysmacros.h>
+#include <unistd.h>
#include <stddef.h>
#include <assert.h>
#include <ctype.h>
@@ -34,11 +36,13 @@
#include <dt_impl.h>
#include <dt_program.h>
+#include <dt_probe.h>
#include <dt_provider.h>
#include <dt_pid.h>
#include <dt_string.h>
#define SEC_STAPSDT_NOTE ".note.stapsdt"
+#define SEC_STAPSDT_BASE ".stapsdt.base"
#define NAME_STAPSDT_NOTE "stapsdt"
/*
@@ -1267,9 +1271,10 @@ dt_stapsdt_parse(dtrace_hdl_t *dtp, dt_proc_t *dpr, dtrace_probedesc_t *pdp,
unsigned long addr_start)
{
size_t shstrndx, noff, doff, off, n;
+ Elf_Scn *scn = NULL, *nscn = NULL;
const prmap_t *pmp = NULL;
+ unsigned long base = 0;
char *mapfile = NULL;
- Elf_Scn *scn = NULL;
Elf *elf = NULL;
GElf_Shdr shdr;
GElf_Ehdr ehdr;
@@ -1287,11 +1292,16 @@ dt_stapsdt_parse(dtrace_hdl_t *dtp, dt_proc_t *dpr, dtrace_probedesc_t *pdp,
path, strerror(errno));
return -1;
}
- mod = strrchr(path, '/');
- if (mod)
- mod++;
- else
- mod = path;
+
+ if (strlen(pdp->mod) == 0) {
+ mod = strrchr(path, '/');
+ if (mod)
+ mod++;
+ else
+ mod = path;
+ } else {
+ mod = (char *)pdp->mod;
+ }
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); // ELF_C_READ ?
@@ -1323,12 +1333,14 @@ dt_stapsdt_parse(dtrace_hdl_t *dtp, dt_proc_t *dpr, dtrace_probedesc_t *pdp,
secname = elf_strptr(elf, shstrndx, shdr.sh_name);
if (strcmp(secname, SEC_STAPSDT_NOTE) == 0 &&
shdr.sh_type == SHT_NOTE)
- break;
+ nscn = scn;
+ if (strcmp(secname, SEC_STAPSDT_BASE) == 0)
+ base = shdr.sh_addr;
}
/* No ELF notes, just bail. */
- if (scn == NULL)
+ if (nscn == NULL)
goto out;
- data = elf_getdata(scn, 0);
+ data = elf_getdata(nscn, 0);
for (off = 0;
(off = gelf_getnote(data, off, &nhdr, &noff, &doff)) > 0;) {
char prvname[DTRACE_PROVNAMELEN];
@@ -1385,38 +1397,59 @@ dt_stapsdt_parse(dtrace_hdl_t *dtp, dt_proc_t *dpr, dtrace_probedesc_t *pdp,
psp.pps_refcntr_off = addrs[2] - phdr.p_vaddr + phdr.p_offset;
}
+ /* readjust based on optional .stapsdt.base, note base addr. */
+ if (base && addrs[1])
+ psp.pps_off += base - addrs[1];
+
if (!psp.pps_off)
continue;
psp.pps_nameoff = 0;
- if (!pmp)
- pmp = Paddr_to_map(dpr->dpr_proc, addr_start + addrs[0]);
- if (!pmp) {
- dt_dprintf("%i: cannot determine 0x%lx's mapping\n",
- Pgetpid(dpr->dpr_proc), psp.pps_off);
- continue;
- }
- if (!mapfile)
- mapfile = Pmap_mapfile_name(dpr->dpr_proc, pmp);
+ if (dpr) {
+ if (!pmp)
+ pmp = Paddr_to_map(dpr->dpr_proc, addr_start + addrs[0]);
+ if (!pmp) {
+ dt_dprintf("%i: cannot determine 0x%lx's mapping\n",
+ Pgetpid(dpr->dpr_proc), psp.pps_off);
+ continue;
+ }
+ if (!mapfile)
+ mapfile = Pmap_mapfile_name(dpr->dpr_proc, pmp);
- if (!mapfile) {
- dt_pid_error(dtp, pcb, dpr, D_PROC_USDT,
- "Cannot get name of mapping containing probe %s for pid %d\n",
- psp.pps_prb, dpr->dpr_pid);
- err = -1;
- break;
- }
- psp.pps_fn = mapfile;
- if (dt_Plookup_by_addr(dtp, dpr->dpr_pid, addr_start + addrs[0],
- &fun, &sym) == 0)
- psp.pps_fun = (char *)fun;
- else
- psp.pps_fun = no_fun;
- psp.pps_dev = pmp->pr_dev;
- psp.pps_inum = pmp->pr_inum;
- psp.pps_pid = dpr->dpr_pid;
- psp.pps_nameoff = 0;
+ if (!mapfile) {
+ dt_pid_error(dtp, pcb, dpr, D_PROC_USDT,
+ "Cannot get name of mapping containing probe %s for pid %d\n",
+ psp.pps_prb, dpr->dpr_pid);
+ err = -1;
+ break;
+ }
+ psp.pps_fn = mapfile;
+ if (dt_Plookup_by_addr(dtp, dpr->dpr_pid, addr_start + addrs[0],
+ &fun, &sym) == 0)
+ psp.pps_fun = (char *)fun;
+ else
+ psp.pps_fun = no_fun;
+ psp.pps_dev = pmp->pr_dev;
+ psp.pps_inum = pmp->pr_inum;
+ psp.pps_pid = dpr->dpr_pid;
+ psp.pps_nameoff = 0;
+ } else {
+ struct stat stats = {};
+ if (stat(path, &stats)) {
+ dt_pid_error(dtp, pcb, dpr, D_PROC_USDT,
+ "failed to stat() %s", path);
+ dtrace_errmsg(dtp, dtrace_errno(dtp));
+ err = -1;
+ break;
+ }
+ psp.pps_mod = mod;
+ psp.pps_dev = stats.st_dev;
+ psp.pps_inum = stats.st_ino;
+ psp.pps_fn = path;
+ psp.pps_fun = no_fun;
+ psp.pps_pid = -1;
+ }
if (pvp->impl->provide_probe(dtp, &psp) < 0) {
dt_pid_error(dtp, pcb, dpr, D_PROC_USDT,
"failed to instantiate probe %s for pid %d: %s",
@@ -1506,6 +1539,52 @@ dt_pid_create_stapsdt_probes_proc(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
fclose(fp);
}
+static int expand_modpath(const char *mod, char *path, size_t pathsz)
+{
+ const char *searches[2] = {};
+ int perm, i;
+
+ if (mod[0] == '/') {
+ strlcpy(path, mod, pathsz);
+ return 0;
+ }
+ if (strstr(mod, ".so")) {
+ searches[0] = getenv("LD_LIBRARY_PATH");
+ searches[1] = "/usr/lib64:/usr/lib";
+ perm = R_OK;
+ } else {
+ searches[0] = getenv("PATH");
+ searches[1] = "/usr/bin/:/usr/sbin";
+ perm = R_OK | X_OK;
+ }
+
+ for (i = 0; i < sizeof(searches)/sizeof(const char *); i++) {
+ const char *s, *n;
+
+ if (!searches[i])
+ continue;
+
+ for (s = searches[i]; s != NULL; s = n) {
+ int len;
+
+ if (*s == ':')
+ s++;
+ n = strchr(s, ':');
+ if (n)
+ len = n - s;
+ else
+ len = strlen(s);
+ snprintf(path, pathsz, "%.*s/%s", len, s, mod);
+ /* make sure accessible */
+ if (faccessat(AT_FDCWD, path, perm, AT_EACCESS) < 0)
+ continue;
+ dt_dprintf("%s: found full path '%s'\n", mod, path);
+ return 0;
+ }
+ }
+ return -ENOENT;
+}
+
static int
dt_pid_create_stapsdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
{
@@ -1522,14 +1601,25 @@ dt_pid_create_stapsdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_
pidstr = &pdp->prv[len];
- while (isdigit(*(pidstr - 1)))
- pidstr--;
- if (strlen(pidstr) == 0)
- return 0;
-
pvp = dt_provider_lookup(dtp, "stapsdt");
assert(pvp != NULL);
+ while (isdigit(*(pidstr - 1)))
+ pidstr--;
+ if (strlen(pidstr) == 0) {
+ char m[PATH_MAX];
+
+ /* only full pid wildcards are supported. */
+ if (*(pidstr - 1) != '*')
+ return 0;
+ if (isdigit(*(pidstr - 2)))
+ return 0;
+ if (dt_probe_lookup(dtp, pdp) != NULL)
+ return 0;
+ if (expand_modpath(pdp->mod, m, sizeof(m)))
+ return 0;
+ return dt_stapsdt_parse(dtp, NULL, pdp, pcb, pvp, m, 0);
+ }
pid = atoll(pidstr);
if (pid <= 0)
return 0;
@@ -1612,8 +1702,13 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *
free(globpat);
globfree(&globbuf);
- if (err == 0)
+ if (err == 0) {
err = dt_pid_create_stapsdt_probes(pdp, dtp, pcb);
+ if (err != 0) {
+ dt_dprintf("stapsdt probe creation %s:%s:%s:%s failed: %d\n",
+ pdp->prv, pdp->mod, pdp->fun, pdp->prb, err);
+ }
+ }
/* If no errors, report success. */
if (err == 0)
diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
index e94827f2..7b41270a 100644
--- a/libdtrace/dt_prov_uprobe.c
+++ b/libdtrace/dt_prov_uprobe.c
@@ -507,7 +507,7 @@ clean_usdt_probes(dtrace_hdl_t *dtp)
list_probe_t *pup = prp->prv_data;
dt_uprobe_t *upp = pup->probe->prv_data;
- if (Pexists(upp->pid))
+ if (upp->pid == -1 || Pexists(upp->pid))
continue;
}
@@ -629,7 +629,7 @@ static int add_probe_usdt(dtrace_hdl_t *dtp, dt_probe_t *prp)
assert(0); // FIXME do something here
/* Even though we just enabled this, check it's still live. */
- if (!Pexists(pid)) {
+ if (pid != -1 && !Pexists(pid)) {
probe_disable(dtp, prp);
dt_bpf_map_delete(fd, &pdp->id);
@@ -919,7 +919,10 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
dt_probe_t *prp, *uprp;
list_probe_t *pop, *pup;
- snprintf(prv, sizeof(prv), "%s%d", psp->pps_prv, psp->pps_pid);
+ if (psp->pps_pid == -1)
+ snprintf(prv, sizeof(prv), "%s*", psp->pps_prv);
+ else
+ snprintf(prv, sizeof(prv), "%s%d", psp->pps_prv, psp->pps_pid);
pd.id = DTRACE_IDNONE;
pd.prv = prv;
@@ -944,6 +947,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
return -1;
upp = uprp->prv_data;
+ upp->pid = psp->pps_pid;
upp->flags |= flags;
/* Look up the overlying probe. */
@@ -1552,7 +1556,7 @@ static int uprobe_create(dtrace_hdl_t *dtp, const dt_uprobe_t *upp,
attr.uprobe_path = (uint64_t)upp->fn;
attr.probe_offset = upp->off;
- return dt_perf_event_open(&attr, upp->pid, -1, -1, 0);
+ return dt_perf_event_open(&attr, upp->pid, upp->pid == -1 ? 0 : -1, -1, 0);
}
static int attach(dtrace_hdl_t *dtp, const dt_probe_t *uprp, int bpf_fd)
@@ -1563,7 +1567,10 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *uprp, int bpf_fd)
assert(upp->fn != NULL);
upp->fd = uprobe_create(dtp, upp, upp->refcntr_off);
-
+ if (upp->fd < 0) {
+ dt_dprintf("uprobe_create failed: %d\n", upp->fd);
+ return upp->fd;
+ }
/* attach BPF program to the probe */
if (ioctl(upp->fd, PERF_EVENT_IOC_SET_BPF, bpf_fd) < 0)
return -errno;
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 3/9] test: add systemwide stapsdt note test
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
2026-01-19 14:22 ` [PATCH v4 1/9] dt_lex: support '/' in probe descriptors Alan Maguire
2026-01-19 14:22 ` [PATCH v4 2/9] stapsdt provider: support systemwide probing Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 4/9] test: add systemwide stapsdt note test using absolute path Alan Maguire
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Add test verifying that systemwide stapsdt probe firing
is detected and we retrieve arguments correctly.
We launch multiple instances of the program:
- one before DTrace starts
- one with -c
- two via system() when DTrace is already running
We ensure that we see 4 sets of firings for 4 different
probes to ensure we catch previously-running programs
and programs run after DTrace starts.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../usdt/tst.stapsdt-notes-systemwide.r | 5 ++
.../usdt/tst.stapsdt-notes-systemwide.sh | 89 +++++++++++++++++++
2 files changed, 94 insertions(+)
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide.r b/test/unittest/usdt/tst.stapsdt-notes-systemwide.r
new file mode 100644
index 00000000..679d835c
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide.r
@@ -0,0 +1,5 @@
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide.sh
new file mode 100755
index 00000000..5d5c6f09
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing various argument forms (constant, register, deref etc).
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <unistd.h>
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+ sleep(1);
+ }
+ return 0;
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+export PATH=.:$PATH
+
+# Launch one program before DTrace starts
+
+./test arg1val &
+
+sleep 1
+
+# Launch another with dtrace -c
+$dtrace -w -c './test arg1val' -qs /dev/stdin <<EOF
+
+BEGIN
+{
+ pids = 0;
+ afters = 0;
+}
+
+test_prov*:test::args
+/ !done[pid] /
+{
+ printf("%s:%s:%li:%s:%s:%li\n", probemod, probename,
+ arg0, copyinstr(arg1), copyinstr(arg2), arg3);
+ done[pid] = 1;
+ pids++;
+}
+
+/* And launch two more with system() */
+profile:::tick-1s
+/ afters < 2 /
+{
+ system("./test arg1val &");
+ afters++;
+}
+
+profile:::tick-1s
+/ pids == 4 && afters == 2 /
+{
+ exit(0);
+}
+
+EOF
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 4/9] test: add systemwide stapsdt note test using absolute path
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (2 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 3/9] test: add systemwide stapsdt note test Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 5/9] test: add systemwide stapsdt note test for library Alan Maguire
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Add test verifying that systemwide stapsdt probe firing
is detected and we retrieve arguments correctly where
the specified module path is an absolute path.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../tst.stapsdt-notes-systemwide-abspath.r | 5 ++
.../tst.stapsdt-notes-systemwide-abspath.sh | 89 +++++++++++++++++++
2 files changed, 94 insertions(+)
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r b/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r
new file mode 100644
index 00000000..679d835c
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r
@@ -0,0 +1,5 @@
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+test:args:2:./test:val:18
+
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh
new file mode 100755
index 00000000..fe36df90
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing various argument forms (constant, register, deref etc).
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <unistd.h>
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+ sleep(1);
+ }
+ return 0;
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+export TESTPROG="$(pwd)/test"
+
+# Launch one program before DTrace starts
+
+./test arg1val &
+
+sleep 1
+
+# Launch another with dtrace -c
+$dtrace -w -c './test arg1val' -qs /dev/stdin <<EOF
+
+BEGIN
+{
+ pids = 0;
+ afters = 0;
+}
+
+test_prov*:$TESTPROG::args
+/ !done[pid] /
+{
+ printf("%s:%s:%li:%s:%s:%li\n", basename(probemod), probename,
+ arg0, copyinstr(arg1), copyinstr(arg2), arg3);
+ done[pid] = 1;
+ pids++;
+}
+
+/* And launch two more with system() */
+profile:::tick-1s
+/ afters < 2 /
+{
+ system("./test arg1val &");
+ afters++;
+}
+
+profile:::tick-1s
+/ pids == 4 && afters == 2 /
+{
+ exit(0);
+}
+
+EOF
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 5/9] test: add systemwide stapsdt note test for library
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (3 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 4/9] test: add systemwide stapsdt note test using absolute path Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 6/9] stapsdt: add test for listing systemwide probes in object Alan Maguire
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Add test verifying that systemwide stapsdt probe firing
is detected and we retrieve arguments correctly for
a shared library. Do this for program with library
that is started before, during (via -c) and two after
(using system) to ensure we see probe firings in all cases.
Count probe firings uniquely per pid for each probe until
we see last one; then print probe arguments.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../usdt/tst.stapsdt-notes-systemwide-lib.r | 14 ++
.../usdt/tst.stapsdt-notes-systemwide-lib.sh | 215 ++++++++++++++++++
2 files changed, 229 insertions(+)
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r
new file mode 100644
index 00000000..c85121c4
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r
@@ -0,0 +1,14 @@
+libstapsdttest.so:zero
+libstapsdttest.so:one:1
+libstapsdttest.so:two:2:3
+libstapsdttest.so:three:4:5:7
+libstapsdttest.so:four:7:8:9:10
+libstapsdttest.so:five:11:12:13:14:15
+libstapsdttest.so:six:16:17:18:19:20:21
+libstapsdttest.so:seven:22:23:24:25:26:27:28
+libstapsdttest.so:eight:29:30:31:32:33:34:35:36
+libstapsdttest.so:nine:37:38:39:40:41:42:43:44:45
+libstapsdttest.so:ten:46:47:48:49:50:51:52:53:54:55
+libstapsdttest.so:eleven:56:57:58:59:60:61:62:63:64:65
+libstapsdttest.so:twelve:67:68:69:70:71:72:73:74:75:76
+
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh
new file mode 100755
index 00000000..d1ac0af8
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh
@@ -0,0 +1,215 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers all stapsdt probes fired by the STAP_PROBEn macros.
+# Arguments values are checked only for first 10 arguments because
+# there is support for arg0 ... arg9 only at this moment.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > libstapsdttest.c <<EOF
+#include <sdt_notes.h>
+
+void
+libfn(int argc, char **argv)
+{
+ if (argc == 0 && argv == 0)
+ return;
+ STAP_PROBE(test_prov, zero);
+ STAP_PROBE1(test_prov, one, argc);
+ STAP_PROBE2(test_prov, two, 2, 3);
+ STAP_PROBE3(test_prov, three, 4, 5, 7);
+ STAP_PROBE4(test_prov, four, 7, 8, 9, 10);
+ STAP_PROBE5(test_prov, five, 11, 12, 13, 14, 15);
+ STAP_PROBE6(test_prov, six, 16, 17, 18, 19, 20, 21);
+ STAP_PROBE7(test_prov, seven, 22, 23, 24, 25, 26, 27, 28);
+ STAP_PROBE8(test_prov, eight, 29, 30, 31, 32, 33, 34, 35, 36);
+ STAP_PROBE9(test_prov, nine, 37, 38, 39, 40, 41, 42, 43, 44, 45);
+ STAP_PROBE10(test_prov, ten, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55);
+ STAP_PROBE11(test_prov, eleven, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66);
+ STAP_PROBE12(test_prov, twelve, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78);
+}
+EOF
+
+cat > test.c <<EOF
+
+#include <unistd.h>
+
+extern void libfn(int argc, char **argv);
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ libfn(argc, argv);
+ sleep(1);
+ }
+ return 0;
+}
+EOF
+
+${CC} ${CFLAGS} -c -fpic libstapsdttest.c
+${CC} -shared -o libstapsdttest.so libstapsdttest.o
+${CC} -L. ${CFLAGS} -o test test.c -lstapsdttest
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+export LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}
+
+# Launch one program before DTrace starts
+
+./test &
+
+sleep 1
+
+# Launch another with dtrace -c
+$dtrace -w -c './test' -qs /dev/stdin <<EOF
+
+BEGIN
+{
+ donecount = 0;
+ afters = 0;
+}
+
+/* And launch two more with system() */
+profile:::tick-1s
+/ afters < 2 /
+{
+ system("./test &");
+ afters++;
+}
+
+test_prov*:libstapsdttest.so::*
+/ !done[probename, pid] && fired[probename] < 4 /
+{
+ fired[probename]++;
+ done[probename, pid] = 1;
+}
+
+test_prov*:libstapsdttest.so::zero
+/ fired[probename] == 4 /
+{
+ printf("%s:%s\n", probemod, probename);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::one
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li\n", probemod, probename, arg0);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::two
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li\n", probemod, probename, arg0, arg1);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::three
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li\n", probemod, probename, arg0, arg1,
+ arg2);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::four
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li\n", probemod, probename, arg0, arg1,
+ arg2, arg3);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::five
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::six
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::seven
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::eight
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::nine
+/ fired[probename] == 4/
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::ten,
+test_prov*:libstapsdttest.so::eleven,
+test_prov*:libstapsdttest.so::twelve
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+ fired[probename]++;
+ donecount;
+}
+
+profile:::tick-1s
+/ donecount == 12 && afters == 2 /
+{
+ exit(0);
+}
+
+EOF
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 6/9] stapsdt: add test for listing systemwide probes in object
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (4 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 5/9] test: add systemwide stapsdt note test for library Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 7/9] stapsdt: add test for listing systemwide probes in absolute path object Alan Maguire
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Need to use -lm since we need to specify module level to
identify the object.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../usdt/tst.stapsdt-notes-systemwide-l.sh | 48 +++++++++++++++++++
.../usdt/tst.stapsdt-notes-systemwide-lv.sh | 48 +++++++++++++++++++
2 files changed, 96 insertions(+)
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh
new file mode 100755
index 00000000..fab71973
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing listing probes.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ STAP_PROBE(test_prov, zero);
+ STAP_PROBE1(test_prov, one, argc);
+ STAP_PROBE2(test_prov, two, 2, 3);
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+export PATH=.:$PATH
+
+$dtrace -c './test arg1val' -lm test_prov\*:test
+status=$?
+
+exit $status
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh
new file mode 100755
index 00000000..e77eaf38
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing listing probes.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ STAP_PROBE(test_prov, zero);
+ STAP_PROBE1(test_prov, one, argc);
+ STAP_PROBE2(test_prov, two, argc, argv[0][0]);
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+export PATH=.:$PATH
+
+$dtrace -c './test arg1val' -lvm test_prov\*:test
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 7/9] stapsdt: add test for listing systemwide probes in absolute path object
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (5 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 6/9] stapsdt: add test for listing systemwide probes in object Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:22 ` [PATCH v4 8/9] stapsdt: add systemwide test for is-enabled probes Alan Maguire
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Verify using an absolute path for listing succeeds for -l and -lv.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../tst.stapsdt-notes-systemwide-l-abspath.sh | 48 +++++++++++++++++++
...tst.stapsdt-notes-systemwide-lv-abspath.sh | 48 +++++++++++++++++++
2 files changed, 96 insertions(+)
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh
new file mode 100755
index 00000000..878e8502
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing listing probes.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ STAP_PROBE(test_prov, zero);
+ STAP_PROBE1(test_prov, one, argc);
+ STAP_PROBE2(test_prov, two, 2, 3);
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+TEST_PROG=$(pwd)/test
+
+$dtrace -lm test_prov\*:$TEST_PROG
+status=$?
+
+exit $status
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh
new file mode 100755
index 00000000..d0ff3e84
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers stapsdt probes fired by the STAP_PROBEn macros,
+# testing listing probes.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > test.c <<EOF
+#include <sdt_notes.h>
+
+int
+main(int argc, char **argv)
+{
+ STAP_PROBE(test_prov, zero);
+ STAP_PROBE1(test_prov, one, argc);
+ STAP_PROBE2(test_prov, two, argc, argv[0][0]);
+ STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
+}
+EOF
+
+${CC} ${CFLAGS} -o test test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+TEST_PROG=$(pwd)/test
+
+$dtrace -lvm test_prov\*:$TEST_PROG
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 8/9] stapsdt: add systemwide test for is-enabled probes
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (6 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 7/9] stapsdt: add test for listing systemwide probes in absolute path object Alan Maguire
@ 2026-01-19 14:22 ` Alan Maguire
2026-01-19 14:23 ` [PATCH v4 9/9] documentation: update stapsdt docs to describe wildcard support Alan Maguire
2026-02-11 23:29 ` [PATCH v4 0/9] stapsdt provider: simple system-wide probing Kris Van Hees
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:22 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
Add is-enabled probes to library and ensure they fire with expected
arguments when enabled.
Same approach is taken as is used for system-wide libs, but
semaphores must be placed in .probes section to ensure they
work correctly for both existing and new processes (the
semaphore counts are managed by the kernel).
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../tst.stapsdt-notes-systemwide-isenabled.r | 13 +
.../tst.stapsdt-notes-systemwide-isenabled.sh | 266 ++++++++++++++++++
2 files changed, 279 insertions(+)
create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r
create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r b/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r
new file mode 100644
index 00000000..d7824fb5
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r
@@ -0,0 +1,13 @@
+libstapsdttest.so:zero
+libstapsdttest.so:one:1
+libstapsdttest.so:two:2:3
+libstapsdttest.so:three:4:5:7
+libstapsdttest.so:four:7:8:9:10
+libstapsdttest.so:five:11:12:13:14:15
+libstapsdttest.so:six:16:17:18:19:20:21
+libstapsdttest.so:seven:22:23:24:25:26:27:28
+libstapsdttest.so:eight:29:30:31:32:33:34:35:36
+libstapsdttest.so:nine:37:38:39:40:41:42:43:44:45
+libstapsdttest.so:eleven:56:57:58:59:60:61:62:63:64:65
+libstapsdttest.so:twelve:67:68:69:70:71:72:73:74:75:76
+
diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh
new file mode 100755
index 00000000..80c7c83c
--- /dev/null
+++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh
@@ -0,0 +1,266 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+# Licensed under the Universal Permissive License v 1.0 as shown at
+# http://oss.oracle.com/licenses/upl.
+
+# This test covers all stapsdt probes fired by the STAP_PROBEn macros.
+# Arguments values are checked only for first 10 arguments because
+# there is support for arg0 ... arg9 only at this moment.
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS="-I${PWD}/test/unittest/usdt"
+
+DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > libstapsdttest.c <<EOF
+#include <stdio.h>
+#define _SDT_HAS_SEMAPHORES 1
+#include <sdt_notes.h>
+
+#define SEC(name) __attribute__((section(name), used))
+
+#define SEMA_DEFINE(name) \
+ __extension__ unsigned short test_prov_##name##_semaphore \
+ __attribute__((unused)) SEC(".probes")
+
+#define SEMA_ENABLED(name) \
+ __builtin_expect (test_prov_##name##_semaphore, 0)
+
+SEMA_DEFINE(zero);
+SEMA_DEFINE(one);
+SEMA_DEFINE(two);
+SEMA_DEFINE(three);
+SEMA_DEFINE(four);
+SEMA_DEFINE(five);
+SEMA_DEFINE(six);
+SEMA_DEFINE(seven);
+SEMA_DEFINE(eight);
+SEMA_DEFINE(nine);
+SEMA_DEFINE(ten);
+SEMA_DEFINE(eleven);
+SEMA_DEFINE(twelve);
+
+void
+libfn(int argc, char **argv)
+{
+ if (argc == 0 && argv == 0)
+ return;
+ if (SEMA_ENABLED(zero))
+ STAP_PROBE(test_prov, zero);
+ if (SEMA_ENABLED(one))
+ STAP_PROBE1(test_prov, one, argc);
+ if (SEMA_ENABLED(two))
+ STAP_PROBE2(test_prov, two, 2, 3);
+ if (SEMA_ENABLED(three))
+ STAP_PROBE3(test_prov, three, 4, 5, 7);
+ if (SEMA_ENABLED(four))
+ STAP_PROBE4(test_prov, four, 7, 8, 9, 10);
+ if (SEMA_ENABLED(five))
+ STAP_PROBE5(test_prov, five, 11, 12, 13, 14, 15);
+ if (SEMA_ENABLED(six))
+ STAP_PROBE6(test_prov, six, 16, 17, 18, 19, 20, 21);
+ if (SEMA_ENABLED(seven))
+ STAP_PROBE7(test_prov, seven, 22, 23, 24, 25, 26, 27, 28);
+ if (SEMA_ENABLED(eight))
+ STAP_PROBE8(test_prov, eight, 29, 30, 31, 32, 33, 34, 35, 36);
+ if (SEMA_ENABLED(nine))
+ STAP_PROBE9(test_prov, nine, 37, 38, 39, 40, 41, 42, 43, 44, 45);
+ if (SEMA_ENABLED(ten)) {
+ printf("should not see this since ten probe is not enabled!\n");
+ STAP_PROBE10(test_prov, ten, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55);
+ fflush(stdout);
+ }
+ if (SEMA_ENABLED(eleven))
+ STAP_PROBE11(test_prov, eleven, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66);
+ if (SEMA_ENABLED(twelve))
+ STAP_PROBE12(test_prov, twelve, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78);
+}
+EOF
+
+cat > test.c <<EOF
+
+#include <unistd.h>
+
+extern void libfn(int argc, char **argv);
+
+int
+main(int argc, char **argv)
+{
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ libfn(argc, argv);
+ sleep(1);
+ }
+ return 0;
+}
+EOF
+
+${CC} ${CFLAGS} -c -fpic libstapsdttest.c
+${CC} -shared -o libstapsdttest.so libstapsdttest.o
+${CC} -L. ${CFLAGS} -o test test.c -lstapsdttest
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+
+export LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}
+
+# Launch one program before DTrace starts
+
+./test &
+
+sleep 1
+
+# Launch another with dtrace -c
+$dtrace -w -c './test' -qs /dev/stdin <<EOF
+
+BEGIN
+{
+ donecount = 0;
+ afters = 0;
+}
+
+/* And launch two more with system() */
+profile:::tick-1s
+/ afters < 2 /
+{
+ system("./test &");
+ afters++;
+}
+
+test_prov*:libstapsdttest.so::zero,
+test_prov*:libstapsdttest.so::one,
+test_prov*:libstapsdttest.so::two,
+test_prov*:libstapsdttest.so::three,
+test_prov*:libstapsdttest.so::four,
+test_prov*:libstapsdttest.so::five,
+test_prov*:libstapsdttest.so::six,
+test_prov*:libstapsdttest.so::seven,
+test_prov*:libstapsdttest.so::eight,
+test_prov*:libstapsdttest.so::nine,
+test_prov*:libstapsdttest.so::eleven,
+test_prov*:libstapsdttest.so::twelve
+/ !done[probename, pid] && fired[probename] < 4 /
+{
+ fired[probename]++;
+ done[probename, pid] = 1;
+}
+
+test_prov*:libstapsdttest.so::zero
+/ fired[probename] == 4 /
+{
+ printf("%s:%s\n", probemod, probename);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::one
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li\n", probemod, probename, arg0);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::two
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li\n", probemod, probename, arg0, arg1);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::three
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li\n", probemod, probename, arg0, arg1,
+ arg2);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::four
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li\n", probemod, probename, arg0, arg1,
+ arg2, arg3);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::five
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::six
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::seven
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::eight
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::nine
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ fired[probename]++;
+ donecount++;
+}
+
+test_prov*:libstapsdttest.so::eleven,
+test_prov*:libstapsdttest.so::twelve
+/ fired[probename] == 4 /
+{
+ printf("%s:%s:%li:%li:%li:%li:%li:%li:%li:%li:%li:%li\n", probemod, probename,
+ arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+ fired[probename]++;
+ donecount++;
+}
+
+profile:::tick-1s
+/ donecount == 12 && afters == 2 /
+{
+ exit(0);
+}
+
+EOF
+status=$?
+
+exit $status
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 9/9] documentation: update stapsdt docs to describe wildcard support
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (7 preceding siblings ...)
2026-01-19 14:22 ` [PATCH v4 8/9] stapsdt: add systemwide test for is-enabled probes Alan Maguire
@ 2026-01-19 14:23 ` Alan Maguire
2026-02-11 23:29 ` [PATCH v4 0/9] stapsdt provider: simple system-wide probing Kris Van Hees
9 siblings, 0 replies; 11+ messages in thread
From: Alan Maguire @ 2026-01-19 14:23 UTC (permalink / raw)
To: dtrace; +Cc: dtrace-devel, Alan Maguire
We now have a limited form of wildcard support; document it.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
.../reference/dtrace_providers_stapsdt.md | 91 ++++++++++++++++++-
1 file changed, 86 insertions(+), 5 deletions(-)
diff --git a/doc/userguide/reference/dtrace_providers_stapsdt.md b/doc/userguide/reference/dtrace_providers_stapsdt.md
index cb6ce71f..9bbeb060 100644
--- a/doc/userguide/reference/dtrace_providers_stapsdt.md
+++ b/doc/userguide/reference/dtrace_providers_stapsdt.md
@@ -29,9 +29,29 @@ library source code as follows:
#define _SDT_HAS_SEMAPHORES 1
#include <sys/sdt.h>
+/* This complicated declaration of semaphores is needed to ensure that
+ * they work correctly; the kernel manages the semaphore count.
+ * The first three definitions simplify semaphore definiton and use;
+ * after these are defined, new semaphores are added by adding
+ *
+ * SEMA_DEFINE(provider_probename_semaphore);
+ *
+ * and used to guard probes with
+ *
+ * if (SEMA_ENABLED(provider_probename_semaphore)) ...
+ */
+#define SEC(name) __attribute__((section(name), used))
+#define SEMA_DEFINE(name) \
+ __extension__ unsigned short name __attribute__((unused)) \
+ SEC(".probes")
+#define SEMA_ENABLED(name) \
+ __builtin_expect (name, 0)
+
+SEMA_DEFINE(myprovider_myprobe_semaphore);
+
unsigned short myprovider_myprobe_semaphore = 0;
- if (myprovider_myprobe_semaphore) {
+ if (SEMA_ENABED(myprovider_myprobe)) {
STAP_PROBEn(myprovider, myprobe, ...);
}
```
@@ -52,12 +72,25 @@ 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 path or name of binary or library. In the case
+where only a binary or library name is specified, 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
@@ -73,12 +106,19 @@ might place in application or library source code:
#define _SDT_HAS_SEMAPHORES 1
#include <sys/sdt.h>
-unsigned short myprovider_myprobe_semaphore = 0;
+#define SEC(name) __attribute__((section(name), used))
+#define SEMA_DEFINE(name) \
+ __extension__ unsigned short name __attribute__((unused)) \
+ SEC(".probes")
+#define SEMA_ENABLED(name) \
+ __builtin_expect (name, 0)
+
+SEMA_DEFINE(myprovider_myprobe_semaphore);
int
main(int argc, char **argv)
{
- if (myprovider_myprobe_semaphore) {
+ if (SEMA_ENABLED(myprovider_myprobe_semaphore)) {
printf("the probe is enabled\n");
[... do something expensive to prepare probe arguments? ...]
STAP_PROBE3(myprovider, myprobe, argc, argv[0], 18);
@@ -147,6 +187,13 @@ Displaying notes found in: .note.stapsdt
Arguments: -4@-4(%rbp) 8@%rax -4@$18
```
+Alternatively we can list the probes in the object via DTrace
+provided we know the provider name:
+
+```
+$ dtrace -lm 'myprovider*:/path2/a.out'
+```
+
Notice that the instrumented source code includes the header file
`<sys/sdt.h>`. On Oracle Linux, this file is installed
by the RPM package `systemtap-sdt-devel`, but the package also
@@ -154,6 +201,40 @@ 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 tracing; for example when
+Python 3 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. To determine
+probe location we can use `dtrace -lm` as described above.
+
+DTrace will expand the paths of programs and libraries using
+PATH and LD_LIBRARY_PATH respectively; the absolute path can
+also be used if needed.
+
## stapsdt Stability <a id="dt_ref_stapsdtstab_prov">
The `stapsdt` provider uses DTrace's stability mechanism to describe its stabilities.
--
2.43.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 0/9] stapsdt provider: simple system-wide probing
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
` (8 preceding siblings ...)
2026-01-19 14:23 ` [PATCH v4 9/9] documentation: update stapsdt docs to describe wildcard support Alan Maguire
@ 2026-02-11 23:29 ` Kris Van Hees
9 siblings, 0 replies; 11+ messages in thread
From: Kris Van Hees @ 2026-02-11 23:29 UTC (permalink / raw)
To: Alan Maguire; +Cc: dtrace, dtrace-devel
I am reviewing this series, and there are a few preiminary comments:
This still introduces the issue of allowing /-characters to occur in the
other fields of the probe specification. Allowing it in the module field
makes sense, but it really should be restricted to that.
The current implementation poses several issues that go against the overall
design in DTrace. E.g. with the current design, when two executables trigger
an stapsdt probe that has been specified with a wildcard like
test_prov*:/some/path::args, the probe firing is reported with provider name
'test_prov*' which is not a valid provider name in DTrace. Per convention,
the two would be expected to have PID-specific provider names as is typical
for DTrace userspace probes. They would then also have unique probe IDs
rather than sharing the same probe ID. In other words, userspace probes are
always per-PID and never shared (even if the underlying probe is shared).
The current implementation also results in a probe 'uprobe-1' to get created
due to the fact that you set pid = -1 to indicate that this is a wildcard
probe.
Non-PID specific userspace probes is something that is foreign to DTrace, so
if we want to go that route we need to put some design behind it.
Otherwise, we really ought to ensure we keep providing per-PID probes at the
DTrace level (even if they are implemented as a single uprobe at the OS level).
A thought... is it possible to use something like inotify to know that a
newly started exeutable is using a particular dev/inode, and use that to
notify DTrace to grab the process, instantiate probes, and then let the process
continue?
On Mon, Jan 19, 2026 at 02:22:51PM +0000, Alan Maguire wrote:
> This series adds wildcard support to stapsdt probes to allow
> tracing system-wide; this has caveats due to the way the kernel
> implements probe addition. In essence, probes are added on a
> per-inode basis (actually in the VMA associated with the inode)
> so it is necessary to identify the file where probes are found.
> Probes will fire for existing and new processes (the RFC incorrectly
> said they will not work for existing binaries; they in fact do).
>
> Patch 2 describes the approach; to facilitate systemwide tracing
> we need to tell DTrace the name of the binary/library via either
> using module absolute path (patch 1 updates parsing to support use
> of a '/' in a module descriptor to faciliate this support) or an
> module name; to expand this we then use [LD_LIBRARY_]PATH
> to resolve the full path. ELF reading of the file and insertion
> of probes then proceeds in a similar manner to per-pid tracing.
>
> Patches 3-8 test various aspects of systemwide probes; basic
> binary support, library support, listing support and is-enabled
> probes support, and use of absolute paths.
>
> Tests ensure wildcards work for
>
> 1. a process started prior to DTrace
> 2. a process started by DTrace (-c)
> 3. two processes started after DTrace is running
> (via system())
>
> Patch 9 updates docs to describe stapsdt wildcard support.
>
> Changes since v3:
>
> - Semaphores need to be more carefully declared to handle
> the is-enabled case where the process is not running when
> DTrace starts tracing; the kernel handles reference counts
> so the probes must be added to the ".probes" section; see
> patches 8/9 for how this is done.
> - Modified tests to start an instance of the test program
> prior to DTrace execution and start two further during
> DTrace execution; ensure we see probe firings for all
> 4 of these processes before declaring success (Kris,
> patches 3, 4, 5, 8)
>
> Changes since v2:
>
> - support absolute paths (patch 1, 2)
> - add tests for absolute paths (patch 4, 7)
> - document systemwide probe support for listing/using absolute
> paths (patch 9)
>
> Changes since RFC:
>
> - update documentation/commit messages to reflect that we also
> catch existing programs/libraries when probes are enabled
> - fixup provider name for wildcard probes to be 'provider*'
> rather than using the confusing 'provider-1' since the
> latter is the concatenation of probename and pid (-1 is
> used to connote all pids)
> - add test for is-enabled systemwide probes
>
>
> *** BLURB HERE ***
>
> Alan Maguire (9):
> dt_lex: support '/' in probe descriptors
> stapsdt provider: support systemwide probing
> test: add systemwide stapsdt note test
> test: add systemwide stapsdt note test using absolute path
> test: add systemwide stapsdt note test for library
> stapsdt: add test for listing systemwide probes in object
> stapsdt: add test for listing systemwide probes in absolute path
> object
> stapsdt: add systemwide test for is-enabled probes
> documentation: update stapsdt docs to describe wildcard support
>
> .../reference/dtrace_providers_stapsdt.md | 91 +++++-
> libdtrace/dt_lex.l | 2 +-
> libdtrace/dt_pid.c | 177 +++++++++---
> libdtrace/dt_prov_uprobe.c | 17 +-
> .../tst.stapsdt-notes-systemwide-abspath.r | 5 +
> .../tst.stapsdt-notes-systemwide-abspath.sh | 89 ++++++
> .../tst.stapsdt-notes-systemwide-isenabled.r | 13 +
> .../tst.stapsdt-notes-systemwide-isenabled.sh | 266 ++++++++++++++++++
> .../tst.stapsdt-notes-systemwide-l-abspath.sh | 48 ++++
> .../usdt/tst.stapsdt-notes-systemwide-l.sh | 48 ++++
> .../usdt/tst.stapsdt-notes-systemwide-lib.r | 14 +
> .../usdt/tst.stapsdt-notes-systemwide-lib.sh | 215 ++++++++++++++
> ...tst.stapsdt-notes-systemwide-lv-abspath.sh | 48 ++++
> .../usdt/tst.stapsdt-notes-systemwide-lv.sh | 48 ++++
> .../usdt/tst.stapsdt-notes-systemwide.r | 5 +
> .../usdt/tst.stapsdt-notes-systemwide.sh | 89 ++++++
> 16 files changed, 1123 insertions(+), 52 deletions(-)
> create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.r
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-abspath.sh
> create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.r
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-isenabled.sh
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l-abspath.sh
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh
> create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.r
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lib.sh
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv-abspath.sh
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh
> create mode 100644 test/unittest/usdt/tst.stapsdt-notes-systemwide.r
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide.sh
>
> --
> 2.43.5
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-02-11 23:29 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 14:22 [PATCH v4 0/9] stapsdt provider: simple system-wide probing Alan Maguire
2026-01-19 14:22 ` [PATCH v4 1/9] dt_lex: support '/' in probe descriptors Alan Maguire
2026-01-19 14:22 ` [PATCH v4 2/9] stapsdt provider: support systemwide probing Alan Maguire
2026-01-19 14:22 ` [PATCH v4 3/9] test: add systemwide stapsdt note test Alan Maguire
2026-01-19 14:22 ` [PATCH v4 4/9] test: add systemwide stapsdt note test using absolute path Alan Maguire
2026-01-19 14:22 ` [PATCH v4 5/9] test: add systemwide stapsdt note test for library Alan Maguire
2026-01-19 14:22 ` [PATCH v4 6/9] stapsdt: add test for listing systemwide probes in object Alan Maguire
2026-01-19 14:22 ` [PATCH v4 7/9] stapsdt: add test for listing systemwide probes in absolute path object Alan Maguire
2026-01-19 14:22 ` [PATCH v4 8/9] stapsdt: add systemwide test for is-enabled probes Alan Maguire
2026-01-19 14:23 ` [PATCH v4 9/9] documentation: update stapsdt docs to describe wildcard support Alan Maguire
2026-02-11 23:29 ` [PATCH v4 0/9] stapsdt provider: simple system-wide probing Kris Van Hees
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox