Skip to contentSkip to conversation

Deferred attach of underlying USDT probes

PATCH Superseded [email protected] 2 participants 9 messages Sep 28, 2024 – Oct 28, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 Deferred attach of underlying USDT probes

From: Eugene Loh <[email protected]>

We would like dtrace to trace USDT processes that start even after the dtrace session has been launched. In that case, the underlying probe cannot be attached when dtrace starts up; rather, the BPF program must be attached once the USDT process has been detected.

Therefore:

*) Make dt_bpf_load_prog() callable outside of dt_bpf.c.

*) Have update_uprobe() call dt_construct(), dt_link(),
dt_bpf_load_prog(), and attach() for any new underlying probes.

---
 libdtrace/dt_bpf.c         |  2 +-
 libdtrace/dt_bpf.h         |  3 ++
 libdtrace/dt_prov_uprobe.c | 65 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 67 insertions(+), 3 deletions(-)
libdtrace/dt_bpf.c +1 -1
index 90881e398..ab97be2cf 100644
@@ -1134,7 +1134,7 @@ dt_bpf_reloc_prog(dtrace_hdl_t *dtp, const dtrace_difo_t *dp)
  *
  * Note that DTrace generates BPF programs that are licensed under the GPL.
  */
-static int
+int
 dt_bpf_load_prog(dtrace_hdl_t *dtp, const dt_probe_t *prp,
 		 const dtrace_difo_t *dp, uint_t cflags)
 {
libdtrace/dt_bpf.h +3 -0
index 5716d2320..115adfbf0 100644
@@ -14,6 +14,7 @@
 #include <dtrace/difo.h>
 #include <dt_btf.h>
 #include <dt_impl.h>
+#include <dt_probe.h>
 
 struct dtrace_hdl;
 
@@ -88,6 +89,8 @@ extern int dt_bpf_prog_load(struct dtrace_hdl *, const struct dt_probe *prp,
 			    size_t sz);
 extern int dt_bpf_raw_tracepoint_open(const void *tp, int fd);
 extern int dt_bpf_make_progs(struct dtrace_hdl *, uint_t);
+extern int dt_bpf_load_prog(dtrace_hdl_t *dtp, const dt_probe_t *prp,
+			    const dtrace_difo_t *dp, uint_t cflags);
 extern int dt_bpf_load_progs(struct dtrace_hdl *, uint_t);
 extern void dt_bpf_init(struct dtrace_hdl *dtp);
 
libdtrace/dt_prov_uprobe.c +63 -2

84 lines not on this page · raw message

Signature · 1 line
2.43.5
#1 lore raw

PATCH 2/6 test: Correct long-standing dt_flags typo

From: Eugene Loh <[email protected]>

---
 test/unittest/ip/tst.ipv4localudp.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/unittest/ip/tst.ipv4localudp.sh +2 -2
index 0e357c3d2..4ee584400 100755
@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2024, 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.
 #
@@ -33,7 +33,7 @@ fi
 dtrace=$1
 testdir="$(dirname $_test)"
 local=127.0.0.1
-$dtrace $dt_cflags -c "$testdir/perlping.pl udp $local" -qs /dev/stdin <<EOF
+$dtrace $dt_flags -c "$testdir/perlping.pl udp $local" -qs /dev/stdin <<EOF
 BEGIN
 {
 	send = receive = 0;
Signature · 1 line
2.43.5
Reviewed-by on v1 2/6
#2 lore raw

Re: [PATCH 2/6] test: Correct long-standing dt_flags typo

Quoted 3 lines · On Fri, Sep 27, 2024 at 10:21:54PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 29 lines
---
 test/unittest/ip/tst.ipv4localudp.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/unittest/ip/tst.ipv4localudp.sh +2 -2
index 0e357c3d2..4ee584400 100755
@@ -1,7 +1,7 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2024, 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.
 #
@@ -33,7 +33,7 @@ fi
 dtrace=$1
 testdir="$(dirname $_test)"
 local=127.0.0.1
-$dtrace $dt_cflags -c "$testdir/perlping.pl udp $local" -qs /dev/stdin <<EOF
+$dtrace $dt_flags -c "$testdir/perlping.pl udp $local" -qs /dev/stdin <<EOF
 BEGIN
 {
 	send = receive = 0;
Signature · 1 line
2.43.5
#3 lore raw

PATCH 3/6 test: Remove some outdated and unhelpful comments

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/triggers/Build | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
test/triggers/Build +4 -4
index 0e8660e59..db80b30ed 100644
@@ -192,18 +192,18 @@ pid-tst-weak1_CFLAGS := -O0
 pid-tst-weak2_CFLAGS := -O0
 profile-tst-ufuncsort_CFLAGS := -O0
 
-# usdt-tst-argmap calls USDT probes (defined in argmap.d) using sys/sdt.h
+# usdt-tst-argmap calls USDT probes using sys/sdt.h
 usdt-tst-argmap_CFLAGS := -Iuts/common
 usdt-tst-argmap_PROV := usdt-tst-argmap-prov.d
 
-# usdt-tst-args calls USDT probes (defined in args.d) using sys/sdt.h
+# usdt-tst-args calls USDT probes using sys/sdt.h
 usdt-tst-args_CFLAGS := -Iuts/common
 usdt-tst-args_PROV := usdt-tst-args-prov.d
 
-# usdt-tst-forker calls USDT probes (defined in args.d) based on dtrace -h
+# usdt-tst-forker calls USDT probes based on dtrace -h
 usdt-tst-forker_PROV := usdt-tst-forker-prov.d
 
-# usdt-tst-special calls USDT probes (defined in prov.d) based on dtrace -h
+# usdt-tst-special calls USDT probes based on dtrace -h
 usdt-tst-special_CFLAGS := -fno-inline -O2
 usdt-tst-special_PROV := usdt-tst-special-prov.d
 
Signature · 1 line
2.43.5
Reviewed-by on v1 3/6
#4 lore raw

Re: [PATCH 3/6] test: Remove some outdated and unhelpful comments

Quoted 3 lines · On Fri, Sep 27, 2024 at 10:21:55PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 34 lines
---
 test/triggers/Build | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
test/triggers/Build +4 -4
index 0e8660e59..db80b30ed 100644
@@ -192,18 +192,18 @@ pid-tst-weak1_CFLAGS := -O0
 pid-tst-weak2_CFLAGS := -O0
 profile-tst-ufuncsort_CFLAGS := -O0
 
-# usdt-tst-argmap calls USDT probes (defined in argmap.d) using sys/sdt.h
+# usdt-tst-argmap calls USDT probes using sys/sdt.h
 usdt-tst-argmap_CFLAGS := -Iuts/common
 usdt-tst-argmap_PROV := usdt-tst-argmap-prov.d
 
-# usdt-tst-args calls USDT probes (defined in args.d) using sys/sdt.h
+# usdt-tst-args calls USDT probes using sys/sdt.h
 usdt-tst-args_CFLAGS := -Iuts/common
 usdt-tst-args_PROV := usdt-tst-args-prov.d
 
-# usdt-tst-forker calls USDT probes (defined in args.d) based on dtrace -h
+# usdt-tst-forker calls USDT probes based on dtrace -h
 usdt-tst-forker_PROV := usdt-tst-forker-prov.d
 
-# usdt-tst-special calls USDT probes (defined in prov.d) based on dtrace -h
+# usdt-tst-special calls USDT probes based on dtrace -h
 usdt-tst-special_CFLAGS := -fno-inline -O2
 usdt-tst-special_PROV := usdt-tst-special-prov.d
 
Signature · 1 line
2.43.5
#5 lore raw

PATCH 4/6 test: Add a USDT "deferred" test trigger

In reply to [email protected]

From: Eugene Loh <[email protected]>

After a dtrace session has started, it is possible for new USDT processes to start and for there to be a delay before dtprobed and then dtrace becomes aware of the new process.

Add a test trigger with USDT probes that waits for dtrace to discover it and send it USR1. Once the USR1 is received, a short workload is run to completion.

---
 test/triggers/Build                      |  5 +-
 test/triggers/usdt-tst-defer-prov.d      | 11 ++++
 test/triggers/usdt-tst-defer.c           | 79 ++++++++++++++++++++++++
 test/unittest/usdt/tst.defer-nodtrace.r  |  1 +
 test/unittest/usdt/tst.defer-nodtrace.sh | 49 +++++++++++++++
 5 files changed, 144 insertions(+), 1 deletion(-)
 create mode 100644 test/triggers/usdt-tst-defer-prov.d
 create mode 100644 test/triggers/usdt-tst-defer.c
 create mode 100644 test/unittest/usdt/tst.defer-nodtrace.r
 create mode 100755 test/unittest/usdt/tst.defer-nodtrace.sh
test/triggers/Build +4 -1
index db80b30ed..107b3b4d1 100644
@@ -13,7 +13,7 @@ EXTERNAL_64BIT_TRIGGERS = testprobe readwholedir mmap bogus-ioctl open delaydie
     ustack-tst-spin ustack-tst-mtspin \
     visible-constructor visible-constructor-static visible-constructor-static-unstripped
 
-EXTERNAL_64BIT_SDT_TRIGGERS = usdt-tst-argmap usdt-tst-args usdt-tst-forker usdt-tst-special
+EXTERNAL_64BIT_SDT_TRIGGERS = usdt-tst-argmap usdt-tst-args usdt-tst-forker usdt-tst-defer usdt-tst-special
 EXTERNAL_64BIT_TRIGGERS += $(EXTERNAL_64BIT_SDT_TRIGGERS)
 
 EXTERNAL_32BIT_TRIGGERS := visible-constructor-32
@@ -203,6 +203,9 @@ usdt-tst-args_PROV := usdt-tst-args-prov.d
 # usdt-tst-forker calls USDT probes based on dtrace -h
 usdt-tst-forker_PROV := usdt-tst-forker-prov.d
 
+# usdt-tst-defer calls USDT probes based on dtrace -h
+usdt-tst-defer_PROV := usdt-tst-defer-prov.d
+
 # usdt-tst-special calls USDT probes based on dtrace -h
 usdt-tst-special_CFLAGS := -fno-inline -O2
 usdt-tst-special_PROV := usdt-tst-special-prov.d
test/triggers/usdt-tst-defer-prov.d new file +11 -0
new file mode 100644
index 000000000..a4ef8323d
@@ -0,0 +1,11 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2024, 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.
+ */
+
+provider testprov {
+	probe foo();
+	probe bar(int, int, int);
+};
test/triggers/usdt-tst-defer.c new file +79 -0

79 lines not on this page · raw message

test/unittest/usdt/tst.defer-nodtrace.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/usdt/tst.defer-nodtrace.sh new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.43.5
Reviewed-by on v1 4/6
#6 lore raw

Re: [PATCH 4/6] test: Add a USDT "deferred" test trigger

Quoted 11 lines · On Fri, Sep 27, 2024 at 10:21:56PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

After a dtrace session has started, it is possible for new USDT processes to start and for there to be a delay before dtprobed and then dtrace becomes aware of the new process.

Add a test trigger with USDT probes that waits for dtrace to discover it and send it USR1. Once the USR1 is received, a short workload is run to completion.

Quoted 202 lines
---
 test/triggers/Build                      |  5 +-
 test/triggers/usdt-tst-defer-prov.d      | 11 ++++
 test/triggers/usdt-tst-defer.c           | 79 ++++++++++++++++++++++++
 test/unittest/usdt/tst.defer-nodtrace.r  |  1 +
 test/unittest/usdt/tst.defer-nodtrace.sh | 49 +++++++++++++++
 5 files changed, 144 insertions(+), 1 deletion(-)
 create mode 100644 test/triggers/usdt-tst-defer-prov.d
 create mode 100644 test/triggers/usdt-tst-defer.c
 create mode 100644 test/unittest/usdt/tst.defer-nodtrace.r
 create mode 100755 test/unittest/usdt/tst.defer-nodtrace.sh
test/triggers/Build +4 -1
index db80b30ed..107b3b4d1 100644
@@ -13,7 +13,7 @@ EXTERNAL_64BIT_TRIGGERS = testprobe readwholedir mmap bogus-ioctl open delaydie
     ustack-tst-spin ustack-tst-mtspin \
     visible-constructor visible-constructor-static visible-constructor-static-unstripped
 
-EXTERNAL_64BIT_SDT_TRIGGERS = usdt-tst-argmap usdt-tst-args usdt-tst-forker usdt-tst-special
+EXTERNAL_64BIT_SDT_TRIGGERS = usdt-tst-argmap usdt-tst-args usdt-tst-forker usdt-tst-defer usdt-tst-special
 EXTERNAL_64BIT_TRIGGERS += $(EXTERNAL_64BIT_SDT_TRIGGERS)
 
 EXTERNAL_32BIT_TRIGGERS := visible-constructor-32
@@ -203,6 +203,9 @@ usdt-tst-args_PROV := usdt-tst-args-prov.d
 # usdt-tst-forker calls USDT probes based on dtrace -h
 usdt-tst-forker_PROV := usdt-tst-forker-prov.d
 
+# usdt-tst-defer calls USDT probes based on dtrace -h
+usdt-tst-defer_PROV := usdt-tst-defer-prov.d
+
 # usdt-tst-special calls USDT probes based on dtrace -h
 usdt-tst-special_CFLAGS := -fno-inline -O2
 usdt-tst-special_PROV := usdt-tst-special-prov.d
test/triggers/usdt-tst-defer-prov.d new file +11 -0
new file mode 100644
index 000000000..a4ef8323d
@@ -0,0 +1,11 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2024, 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.
+ */
+
+provider testprov {
+	probe foo();
+	probe bar(int, int, int);
+};
test/triggers/usdt-tst-defer.c new file +79 -0
new file mode 100644
index 000000000..2df5401b2
@@ -0,0 +1,79 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2024, 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.
+ */
+
+/*
+ * The main characteristic of this trigger code is that it allows deferred
+ * DTrace detection of the trigger.  That is, the trigger spins in "phase 1",
+ * waiting for DTrace to detect it and send it USR1.  Only then does "phase 2"
+ * run a short workload to completion.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
+#include "usdt-tst-defer-prov.h"
+
+static int phase = 1;
+
+static void
+interrupt(int sig)
+{
+	phase = 2;
+}
+
+int
+main(int argc, char **argv)
+{
+	struct sigaction act;
+	int i;
+	int nphase1 = 0, nphase1foo = 0, nphase1bar = 0;
+	int nphase2 = 0, nphase2foo = 0, nphase2bar = 0;
+
+	/* set the handler to listen for SIGUSR1 */
+	act.sa_handler = interrupt;
+	act.sa_flags = 0;
+	if (sigaction(SIGUSR1, &act, NULL)) {
+		printf("set handler failed\n");
+		return 1;
+	}
+
+	/* in phase 1, loop on probe "foo" to wait on USR1 */
+	while (phase == 1) {
+		nphase1++;
+		if (TESTPROV_FOO_ENABLED()) {
+			nphase1foo++;
+			phase = 2;
+		}
+		if (TESTPROV_BAR_ENABLED()) {
+			nphase1bar++;
+			phase = 2;
+		}
+		TESTPROV_FOO();
+	}
+
+	/* wait for probes to get set up */
+	usleep(100000);
+
+	/* in phase 2, just loop over probe "bar" a fixed number of times */
+	for (i = 0; i < 10; i++) {
+		nphase2++;
+		usleep(2000);
+		if (TESTPROV_FOO_ENABLED())
+			nphase2foo++;
+		usleep(2000);
+		if (TESTPROV_BAR_ENABLED())
+			nphase2bar++;
+		usleep(2000);
+		TESTPROV_BAR(i, i + 2, i * 2);
+	}
+
+	printf("%d: %d %d %d %d %d %d\n", getpid(),
+	    nphase1, nphase1foo, nphase1bar, nphase2, nphase2foo, nphase2bar);
+
+	return 0;
+}
test/unittest/usdt/tst.defer-nodtrace.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/usdt/tst.defer-nodtrace.sh new file +49 -0
new file mode 100755
index 000000000..e5fd2855c
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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.
+#
+# There are various tests that use the usdt-tst-defer trigger.  As a
+# baseline, let us run the trigger without enabling any USDT probes
+# and check that the counts are as expected.
+
+dtrace=$1
+trigger=`pwd`/test/triggers/usdt-tst-defer
+
+# Set up test directory.
+
+DIRNAME=$tmpdir/defer-nodtrace.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Make a private copy of the trigger executable so that we get our
+# own DOF stash.
+
+cp $trigger main
+
+# Check that the is-enabled probes are false when the USDT probes are not enabled.
+# That is, nphase1foo == nphase1bar == nphase2foo == nphase2bar == 0.
+# Also, nphase2 == 10.
+# Note that nphase1 will be undefined.
+
+./main > main.out &
+pid=$!
+sleep 1
+kill -USR1 $pid
+wait
+
+echo "$pid: undefined 0 0 10 0 0" > main.out.expected
+if ! awk '{ $2 = "undefined"; print }' main.out | diff -q - main.out.expected; then
+	echo program output looks wrong for the no-DTrace case
+	echo === got ===
+	cat main.out
+	echo === expected ===
+	cat main.out.expected
+	exit 1
+fi
+
+echo success
+
+exit 0
Signature · 1 line
2.43.5
#7 lore raw

PATCH 5/6 test: Add USDT tests for deferred detection

In reply to [email protected]

From: Eugene Loh <[email protected]>

When new USDT processes start up, we do not immediately trace them. First, dtprobed has to see these processes and then dtrace has to find them. Hence, many of our tests XFAIL.

Add some tests that check USDT tracing on processes that start after the dtrace session has started, allowing for the possibility that tracing does not start until after the trigger is already underway.

There are two cases to consider. One is when there is a USDT process running when the dtrace session starts. In this case, an underlying probe is attached and later USDT processes just get added on. Another case is when no USDT processes are running when the dtrace session starts. In this case, -Z must be specified, and the underlying probe will not be attached until one of the USDT processes is detected.

---
 test/unittest/usdt/tst.defer-Z.r  |   1 +
 test/unittest/usdt/tst.defer-Z.sh | 153 +++++++++++++++++++++++++++++
 test/unittest/usdt/tst.defer.r    |   1 +
 test/unittest/usdt/tst.defer.sh   | 158 ++++++++++++++++++++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 test/unittest/usdt/tst.defer-Z.r
 create mode 100755 test/unittest/usdt/tst.defer-Z.sh
 create mode 100644 test/unittest/usdt/tst.defer.r
 create mode 100755 test/unittest/usdt/tst.defer.sh
test/unittest/usdt/tst.defer-Z.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/usdt/tst.defer-Z.sh new file +153 -0

153 lines not on this page · raw message

test/unittest/usdt/tst.defer.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/usdt/tst.defer.sh new file +158 -0

158 lines not on this page · raw message

Signature · 1 line
2.43.5
#8 lore raw

PATCH 6/6 test: Add USDT error tests for -w and -Z

In reply to [email protected]

From: Eugene Loh <[email protected]>

Error checking for USDT probes can be different from other probes. So add specific USDT tests for -Z and -w. Specifically:

err.no-Z No USDT process yet when dtrace is launched
and -Z is not specified. Therefore, dtrace will not start up.

err.no-w A USDT process is running when dtrace is
launched, so -Z is not needed. However, the action is destructive and -w is not specified. Therefore, dtrace will not start up.

err.Z_no-w No USDT process yet when dtrace is launched,
but -Z is specified. So, dtrace starts successfully. But the action is destructive and -w is not specified. So when the USDT process starts, dtrace fails.

---
 test/unittest/usdt/err.Z_no-w.r  |  4 ++
 test/unittest/usdt/err.Z_no-w.sh | 65 ++++++++++++++++++++++++++++++++
 test/unittest/usdt/err.no-Z.r    | 13 +++++++
 test/unittest/usdt/err.no-Z.sh   | 31 +++++++++++++++
 test/unittest/usdt/err.no-w.r    |  3 ++
 test/unittest/usdt/err.no-w.sh   | 31 +++++++++++++++
 6 files changed, 147 insertions(+)
 create mode 100644 test/unittest/usdt/err.Z_no-w.r
 create mode 100755 test/unittest/usdt/err.Z_no-w.sh
 create mode 100644 test/unittest/usdt/err.no-Z.r
 create mode 100755 test/unittest/usdt/err.no-Z.sh
 create mode 100644 test/unittest/usdt/err.no-w.r
 create mode 100755 test/unittest/usdt/err.no-w.sh
test/unittest/usdt/err.Z_no-w.r new file +4 -0
new file mode 100644
index 000000000..b81622481
@@ -0,0 +1,4 @@
+dtrace is running so start the trigger
+dtrace died as expected after trigger started
+-- @@stderr --
+dtrace: processing aborted: Destructive actions not allowed
test/unittest/usdt/err.Z_no-w.sh new file +65 -0

65 lines not on this page · raw message

test/unittest/usdt/err.no-Z.r new file +13 -0
new file mode 100644
index 000000000..52d9492ab
@@ -0,0 +1,13 @@
+expected failure
+-- @@stderr --
+dtrace: invalid probe specifier 
+BEGIN
+{
+	exit(0);
+}
+
+testprov*:::foo
+{
+	raise(SIGUSR1);
+	exit(0);
+}: probe description testprov*:::foo does not match any probes
test/unittest/usdt/err.no-Z.sh new file +31 -0
new file mode 100755
index 000000000..29d63d9ce
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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 verifies that dtrace will not wait for USDT processes to
+# appear if -Z is not used.
+
+dtrace=$1
+
+$dtrace $dt_flags -qn '
+BEGIN
+{
+	exit(0);
+}
+
+testprov*:::foo
+{
+	raise(SIGUSR1);
+	exit(0);
+}'
+if [ $? -ne 0 ]; then
+	echo expected failure
+	exit 1
+fi
+
+echo unexpected success
+
+exit 0
test/unittest/usdt/err.no-w.r new file +3 -0
new file mode 100644
index 000000000..7a4d60cd0
@@ -0,0 +1,3 @@
+expected failure
+-- @@stderr --
+dtrace: could not enable tracing: Destructive actions not allowed
test/unittest/usdt/err.no-w.sh new file +31 -0
new file mode 100755
index 000000000..407654981
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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 verifies that dtrace will not run a destructive script
+# for USDT probes if -w is not specified.
+
+dtrace=$1
+
+$dtrace $dt_flags -c test/triggers/usdt-tst-defer -qn '
+BEGIN
+{
+	exit(0);
+}
+
+testprov*:::foo
+{
+	raise(SIGUSR1);
+	exit(0);
+}'
+if [ $? -ne 0 ]; then
+	echo expected failure
+	exit 1
+fi
+
+echo unexpected success
+
+exit 0
Signature · 1 line
2.43.5