Skip to contentSkip to conversation

Fix stack-skip counts for caller and stackdepth

PATCH New [email protected] 1 participant 14 messages Jun 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/14 Fix stack-skip counts for caller and stackdepth

From: Eugene Loh <[email protected]>

Apparently, when we call the BPF get_stack() helper function, it generally knows how many frames to skip to get the real kernel stack. For fentry/fexit, however, this is apparently not the case, and commit bc65cb44d
("cg: allow providers to specify a skip count for stack retrieval") added the ability to skip frames for fentry/fexit probes.

When this "skip" is needed, however, it must must be even deeper when we descend further frames, such as when we call dt_bpf_*() precompiled functions.

Add this support for dt_bpf_caller() and dt_bpf_stackdepth(). That is, if there are stack-skip frames, skip yet one more frame when inside a bpf/get_bvar.c function.

Note that we declare the skip count volatile. The compiler might optimize code that uses the STACK_SKIP value, but we will subsequently perform relocations that adjust this value.

---
 bpf/get_bvar.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
bpf/get_bvar.c +14 -3
index 9625e764e..99a6503d5 100644
@@ -53,12 +53,17 @@ noinline uint64_t dt_bvar_args(const dt_dctx_t *dctx, uint32_t idx)
 
 noinline uint64_t dt_bvar_caller(const dt_dctx_t *dctx)
 {
-	uint64_t	buf[2] = { 0, };
+	uint64_t	buf[3] = { 0, };
+	volatile uint64_t
+			skip = (uint64_t)(&STACK_SKIP);
 
 	if (bpf_get_stack(dctx->ctx, buf, sizeof(buf),
-			  (uint64_t)(&STACK_SKIP) & BPF_F_SKIP_FIELD_MASK) < 0)
+			  skip & BPF_F_SKIP_FIELD_MASK) < 0)
 		return 0;
 
+	/* If we had to skip any frames, account for the dt_bvar_caller() frame. */
+	if (skip)
+		return buf[2];
 	return buf[1];
 }
 
@@ -203,9 +208,11 @@ noinline uint64_t dt_bvar_stackdepth(const dt_dctx_t *dctx)
 	uint32_t	bufsiz = (uint32_t) (uint64_t) (&STKSIZ);
 	char		*buf = dctx->mem + (uint64_t)(&STACK_OFF);
 	uint64_t	retv;
+	volatile uint64_t
+			skip = (uint64_t)(&STACK_SKIP);
 
 	retv = bpf_get_stack(dctx->ctx, buf, bufsiz,
-			     (uint64_t)(&STACK_SKIP) & BPF_F_SKIP_FIELD_MASK);
+			     skip & BPF_F_SKIP_FIELD_MASK);
 	if (retv < 0)
 		return error(dctx, DTRACEFLT_BADSTACK, 0 /* FIXME */);
 
@@ -217,7 +224,11 @@ noinline uint64_t dt_bvar_stackdepth(const dt_dctx_t *dctx)
 	 * If retv==bufsiz, presumably the stack is larger than what we
 	 * can retrieve.  But it's also possible that the buffer was exactly
 	 * large enough.  So, leave it to the user to interpret the result.
+	 *
+	 * If we had to skip any frames, account for the dt_bvar_stackdepth() frame.
 	 */
+	if (skip)
+		return retv / sizeof(uint64_t) - 1;
 	return retv / sizeof(uint64_t);
 }
 
Signature · 1 line
2.43.5
#1 lore raw

PATCH v2 2/14 Add stack-skip frame count for rawtp provider

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_prov_rawtp.c | 1 +
 1 file changed, 1 insertion(+)
libdtrace/dt_prov_rawtp.c +1 -0
index f1d3b6bc4..a36bb51f4 100644
@@ -296,6 +296,7 @@ use_alt:
 dt_provimpl_t	dt_rawtp = {
 	.name		= prvname,
 	.prog_type	= BPF_PROG_TYPE_RAW_TRACEPOINT,
+	.stack_skip	= 4,
 	.populate	= &populate,
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
Signature · 1 line
2.43.5
#2 lore raw

PATCH v2 3/14 test: remove unnecessary "unstable" tag

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/sched/tst.stackdepth.d | 1 -
 1 file changed, 1 deletion(-)
test/unittest/sched/tst.stackdepth.d +0 -1
index 02a878bea..e6ffca01c 100644
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@tags: unstable */
 
 #pragma D option switchrate=100hz
 
Signature · 1 line
2.43.5
#3 lore raw

PATCH v2 4/14 test: caller and stackdepth tests for fbt provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

We will introduce a set of tests for the caller and stackdepth built-in variables for a wide selection of providers.

For the caller test, we will essentially call

        stack(2);
        sym(caller);

and then compare the caller to the second stack frame using the new script check_caller_to_stack2.awk.

For the stackdepth test, we will essentially call

        printf("%d\n", stackdepth);
        stack();

and then compare the stackdepth to the reported frames using the new script check_stackdepth_to_stack.awk.

In this patch, introduce tests for the fbt provider, along with the support scripts they need. Subsequent patches will handle other providers.

The old tst.caller2.d and tst.stackdepth2.d, which tested fbt, become obsolete. Remove them.

---
 .../variables/bvar/check_caller_to_stack2.awk | 32 +++++++++++++++++
 ...pth2.r.p => check_stackdepth_to_stack.awk} | 16 ++++++---
 test/unittest/variables/bvar/tst.caller-fbt.d | 26 ++++++++++++++
 test/unittest/variables/bvar/tst.caller-fbt.r |  1 +
 .../variables/bvar/tst.caller-fbt.r.p         |  1 +
 test/unittest/variables/bvar/tst.caller2.d    | 31 ----------------
 test/unittest/variables/bvar/tst.caller2.r    |  1 -
 test/unittest/variables/bvar/tst.caller2.r.p  | 11 ------
 .../variables/bvar/tst.stackdepth-fbt.d       | 28 +++++++++++++++
 ...tst.stackdepth2.r => tst.stackdepth-fbt.r} |  0
 .../variables/bvar/tst.stackdepth-fbt.r.p     |  1 +
 .../unittest/variables/bvar/tst.stackdepth2.d | 36 -------------------
 12 files changed, 101 insertions(+), 83 deletions(-)
 create mode 100755 test/unittest/variables/bvar/check_caller_to_stack2.awk
 rename test/unittest/variables/bvar/{tst.stackdepth2.r.p => check_stackdepth_to_stack.awk} (63%)
 create mode 100644 test/unittest/variables/bvar/tst.caller-fbt.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-fbt.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-fbt.r.p
 delete mode 100644 test/unittest/variables/bvar/tst.caller2.d
 delete mode 100644 test/unittest/variables/bvar/tst.caller2.r
 delete mode 100755 test/unittest/variables/bvar/tst.caller2.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-fbt.d
 rename test/unittest/variables/bvar/{tst.stackdepth2.r => tst.stackdepth-fbt.r} (100%)
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-fbt.r.p
 delete mode 100644 test/unittest/variables/bvar/tst.stackdepth2.d
test/unittest/variables/bvar/check_caller_to_stack2.awk new file +32 -0
new file mode 100755
index 000000000..8499852a7
@@ -0,0 +1,32 @@
+#!/usr/bin/gawk -f
+
+# Check output of tst.caller-$provider.d tests of the form
+#
+# {
+#     stack(2);
+#     sym(caller);
+# }
+#
+# Confirm that the caller information matches the stack information.
+
+# Look for the first nonblank line.
+NF != 0 {
+	# It is the current frame.  Skip it.
+	if (getline != 1) { print "ERROR: missing expected output"; exit(1); }
+
+	# Now we have the caller frame.  Strip off the offset.
+	expect=$1
+	sub("+0x[0-9a-f]*$", "", expect);
+
+	# Finally, get the sym(caller) output.
+	if (getline != 1) { print "ERROR: missing expected output"; exit(1); }
+
+	# Compare.
+	if (expect == $1) {
+		print "success";
+		exit(0);
+	} else {
+		print "ERROR: expect", expect, "but got", $1;
+		exit(1);
+	}
+}
test/unittest/variables/bvar/check_stackdepth_to_stack.awk renamed from test/unittest/variables/bvar/tst.stackdepth2.r.p +12 -4
similarity index 63%
rename from test/unittest/variables/bvar/tst.stackdepth2.r.p
rename to test/unittest/variables/bvar/check_stackdepth_to_stack.awk
index 9b071181f..fba1f4242 100755
@@ -1,8 +1,16 @@
 #!/usr/bin/gawk -f
-# Oracle Linux DTrace.
-# Copyright (c) 2016, 2021, 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.
+#
+# Check output of tst.stackdepth-$provider.d tests of the form
+#
+# {
+#     printf("DEPTH %d\n", stackdepth);
+#     printf("TRACE BEGIN\n");
+#     stack();
+#     printf("TRACE END\n");
+#     exit(0);
+# }
+#
+# Confirm that the stackdepth information matches the stack information.
 
 /^DEPTH/ {
 	depth = int($2);
test/unittest/variables/bvar/tst.caller-fbt.d new file +26 -0
new file mode 100644
index 000000000..a81353335
@@ -0,0 +1,26 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+fbt::ksys_write:entry
+/pid == $target/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-fbt.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-fbt.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.caller2.d deleted +0 -31
deleted file mode 100644
index ca6dbfd22..000000000
@@ -1,31 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2021, 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.
- */
-
-/*
- * ASSERTION: The 'caller' should be consistent with stack().
- *
- * SECTION: Variables/Built-in Variables/caller
- */
-
-#pragma D option quiet
-#pragma D option destructive
-
-BEGIN
-{
-        system("echo write something > /dev/null");
-}
-
-fbt::ksys_write:entry
-{
-	stack(2);
-	sym(caller);
-	exit(0);
-}
-
-ERROR {
-	exit(1);
-}
test/unittest/variables/bvar/tst.caller2.r deleted +0 -1
deleted file mode 100644
index 0cfbf0888..000000000
@@ -1 +0,0 @@
-2
test/unittest/variables/bvar/tst.caller2.r.p deleted +0 -11
deleted file mode 100755
index 1a26a4df2..000000000
@@ -1,11 +0,0 @@
-#!/bin/bash
-
-# sed:  remove +0x{ptr} offsets
-# awk:  look for the ksys_write frame, then write the next two lines
-# uniq:  count unique lines
-# awk:  report the counts
-
-sed 's/+0x.*$//' \
-| /usr/bin/gawk '/ksys_write/ {getline; print $1; getline; print $1; exit(0)}' \
-| uniq -c \
-| /usr/bin/gawk '{print $1}'
test/unittest/variables/bvar/tst.stackdepth-fbt.d new file +28 -0
new file mode 100644
index 000000000..d33897a5f
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+fbt::ksys_write:entry
+/pid == $target/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-fbt.r renamed from test/unittest/variables/bvar/tst.stackdepth2.r +0 -0
similarity index 100%
rename from test/unittest/variables/bvar/tst.stackdepth2.r
rename to test/unittest/variables/bvar/tst.stackdepth-fbt.r
test/unittest/variables/bvar/tst.stackdepth-fbt.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth2.d deleted +0 -36
deleted file mode 100644
index 2b1c0866a..000000000
@@ -1,36 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, 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.
- */
-
-#pragma D option destructive
-#pragma D option quiet
-
-/*
- * ASSERTION:
- *   Test the stackdepth variable.  Verify its value against the stack trace.
- *
- * SECTION: Variables/Built-in Variables
- *
- */
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::ksys_write:entry
-{
-	printf("DEPTH %d\n", stackdepth);
-	printf("TRACE BEGIN\n");
-	stack();
-	printf("TRACE END\n");
-	exit(0);
-}
-
-ERROR
-{
-	exit(1);
-}
Signature · 1 line
2.43.5
#4 lore raw

PATCH v2 5/14 test: caller and stackdepth tests for dtrace provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

Also, a few old tests, which tested caller and stackdepth using the dtrace provider, are now superfluous given the new, provider-named tests. The old tests were extremely lenient -- e.g., simply checking that these built-in variables were not -1, even though both variables are unsigned anyhow!

---
 test/unittest/builtinvar/tst.caller.d         | 25 -------------------
 .../variables/bvar/tst.caller-dtrace.d        | 20 +++++++++++++++
 .../variables/bvar/tst.caller-dtrace.r        |  1 +
 test/unittest/variables/bvar/tst.caller.d     | 23 -----------------
 .../variables/bvar/tst.stackdepth-dtrace.d    | 23 +++++++++++++++++
 .../variables/bvar/tst.stackdepth-dtrace.r    |  5 ++++
 test/unittest/variables/bvar/tst.stackdepth.d | 23 -----------------
 7 files changed, 49 insertions(+), 71 deletions(-)
 delete mode 100644 test/unittest/builtinvar/tst.caller.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-dtrace.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-dtrace.r
 delete mode 100644 test/unittest/variables/bvar/tst.caller.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-dtrace.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-dtrace.r
 delete mode 100644 test/unittest/variables/bvar/tst.stackdepth.d
test/unittest/builtinvar/tst.caller.d deleted +0 -25
deleted file mode 100644
index 19a4bab9e..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, 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.
- */
-
-/*
- * ASSERTION: print 'caller' and make sure it succeeds.
- *
- * SECTION: Variables/Built-in Variables
- */
-
-#pragma D option quiet
-
-BEGIN
-{
-	printf("The caller is %u\n", caller);
-	exit(0);
-}
-
-ERROR
-{
-	exit(1);
-}
test/unittest/variables/bvar/tst.caller-dtrace.d new file +20 -0
new file mode 100644
index 000000000..d726f38ac
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check 'caller'. */
+
+#pragma D option quiet
+
+BEGIN {
+	trace(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-dtrace.r new file +1 -0
new file mode 100644
index 000000000..573541ac9
@@ -0,0 +1 @@
+0
test/unittest/variables/bvar/tst.caller.d deleted +0 -23
deleted file mode 100644
index 3d64fa98c..000000000
@@ -1,23 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, 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.
- */
-
-/*
- * ASSERTION: The 'caller' variable can be accessed and is not -1.
- *
- * SECTION: Variables/Built-in Variables/caller
- */
-
-#pragma D option quiet
-
-BEGIN {
-	trace(caller);
-	exit(caller != -1 ? 0 : 1);
-}
-
-ERROR {
-	exit(1);
-}
test/unittest/variables/bvar/tst.stackdepth-dtrace.d new file +23 -0
new file mode 100644
index 000000000..1026006eb
@@ -0,0 +1,23 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check 'stackdepth'. */
+
+#pragma D option quiet
+
+BEGIN {
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack();
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-dtrace.r new file +5 -0
new file mode 100644
index 000000000..1afb1f057
@@ -0,0 +1,5 @@
+DEPTH 0
+TRACE BEGIN
+
+TRACE END
+
test/unittest/variables/bvar/tst.stackdepth.d deleted +0 -23
deleted file mode 100644
index ad728fd85..000000000
@@ -1,23 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, 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.
- */
-
-/*
- * ASSERTION: The 'stackdepth' variable can be accessed and is not -1.
- *
- * SECTION: Variables/Built-in Variables/stackdepth
- */
-
-#pragma D option quiet
-
-BEGIN {
-	trace(stackdepth);
-	exit(stackdepth != -1 ? 0 : 1);
-}
-
-ERROR {
-	exit(1);
-}
Signature · 1 line
2.43.5
#5 lore raw

PATCH v2 6/14 test: caller and stackdepth tests for rawtp provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

Also, add skip_rawtp_old.x, to skip rawtp testing on older kernels for the reasons described in the file.

---
 test/unittest/variables/bvar/skip_rawtp_old.x | 31 +++++++++++++++++++
 .../variables/bvar/tst.caller-rawtp.d         | 25 +++++++++++++++
 .../variables/bvar/tst.caller-rawtp.r         |  1 +
 .../variables/bvar/tst.caller-rawtp.r.p       |  1 +
 .../variables/bvar/tst.caller-rawtp.x         |  1 +
 .../variables/bvar/tst.stackdepth-rawtp.d     | 27 ++++++++++++++++
 .../variables/bvar/tst.stackdepth-rawtp.r     |  1 +
 .../variables/bvar/tst.stackdepth-rawtp.r.p   |  1 +
 .../variables/bvar/tst.stackdepth-rawtp.x     |  1 +
 9 files changed, 89 insertions(+)
 create mode 100755 test/unittest/variables/bvar/skip_rawtp_old.x
 create mode 100644 test/unittest/variables/bvar/tst.caller-rawtp.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-rawtp.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-rawtp.r.p
 create mode 120000 test/unittest/variables/bvar/tst.caller-rawtp.x
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawtp.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawtp.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-rawtp.x
test/unittest/variables/bvar/skip_rawtp_old.x new file +31 -0
new file mode 100755
index 000000000..bf7970832
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+#
+# In older kernels (e.g., UEK6), the BPF helper function had a bug with
+# skipping stack frames.  While that many stack frames were correctly
+# skipped on the leaf end of the stack, that many frames were also
+# incorrectly skipped at the root end of the output buffer.
+#
+# Only two DTrace providers ask for a nonzero skip count.  One is the
+# fentry/fexit implementation of fbt, but it was not used on such older
+# kernels.
+#
+# The other is rawtp.  Therefore, rawtp stack(), caller, and stackdepth
+# results on such older kernels can be incorrect.
+#
+# A few other providers also have some or most probes implemented in
+# terms of rawtp probes.  They could have similar problems, depending
+# on which probes are used.
+#
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -gt 5 ]; then
+	exit 0
+fi
+if [ $MAJOR -eq 5 -a $MINOR -ge 10 ]; then
+	exit 0
+fi
+
+echo "rawtp caller, stack(), and stackdepth problematic in old kernels"
+exit 2
test/unittest/variables/bvar/tst.caller-rawtp.d new file +25 -0
new file mode 100644
index 000000000..9bc91b67a
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawtp:sched::
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-rawtp.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-rawtp.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.caller-rawtp.x new file +1 -0
new file mode 120000
index 000000000..37b3ef9f8
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-rawtp.d new file +27 -0
new file mode 100644
index 000000000..b99ada9a3
@@ -0,0 +1,27 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawtp:sched::
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-rawtp.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-rawtp.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-rawtp.x new file +1 -0
new file mode 120000
index 000000000..37b3ef9f8
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
Signature · 1 line
2.43.5
#6 lore raw

PATCH v2 7/14 test: caller and stackdepth tests for cpc provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/variables/bvar/tst.caller-cpc.d | 23 +++++++++++++++++
 test/unittest/variables/bvar/tst.caller-cpc.r |  1 +
 .../variables/bvar/tst.caller-cpc.r.p         |  1 +
 .../variables/bvar/tst.stackdepth-cpc.d       | 25 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-cpc.r       |  1 +
 .../variables/bvar/tst.stackdepth-cpc.r.p     |  1 +
 6 files changed, 52 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-cpc.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-cpc.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-cpc.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-cpc.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-cpc.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-cpc.r.p
test/unittest/variables/bvar/tst.caller-cpc.d new file +23 -0
new file mode 100644
index 000000000..ff275e8ad
@@ -0,0 +1,23 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+cpc:::cpu_clock-all-100000000
+/stackdepth > 1/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-cpc.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-cpc.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-cpc.d new file +25 -0
new file mode 100644
index 000000000..5adae23a7
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+cpc:::cpu_clock-all-100000000
+/stackdepth > 1/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-cpc.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-cpc.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
Signature · 1 line
2.43.5
#7 lore raw

PATCH v2 8/14 test: caller and stackdepth tests for ip provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/variables/bvar/tst.caller-ip.d  | 22 ++++++++++++++++
 test/unittest/variables/bvar/tst.caller-ip.r  |  1 +
 .../unittest/variables/bvar/tst.caller-ip.r.p |  1 +
 test/unittest/variables/bvar/tst.caller-ip.t  |  6 +++++
 .../variables/bvar/tst.stackdepth-ip.d        | 25 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-ip.r        |  1 +
 .../variables/bvar/tst.stackdepth-ip.r.p      |  1 +
 .../variables/bvar/tst.stackdepth-ip.t        |  6 +++++
 8 files changed, 63 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-ip.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-ip.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-ip.r.p
 create mode 100755 test/unittest/variables/bvar/tst.caller-ip.t
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-ip.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-ip.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-ip.r.p
 create mode 100755 test/unittest/variables/bvar/tst.stackdepth-ip.t
test/unittest/variables/bvar/tst.caller-ip.d new file +22 -0
new file mode 100644
index 000000000..05ca5c671
@@ -0,0 +1,22 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+ip:::
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-ip.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-ip.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.caller-ip.t new file +6 -0
new file mode 100755
index 000000000..1ce076b86
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+testdir="$(dirname $_test)"
+local=127.0.0.1
+
+$testdir/../../ip/perlping.pl icmp $local
test/unittest/variables/bvar/tst.stackdepth-ip.d new file +25 -0
new file mode 100644
index 000000000..a35d1e517
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+ip:::
+/stackdepth > 0/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-ip.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-ip.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-ip.t new file +6 -0
new file mode 100755
index 000000000..1ce076b86
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+testdir="$(dirname $_test)"
+local=127.0.0.1
+
+$testdir/../../ip/perlping.pl icmp $local
Signature · 1 line
2.43.5
#8 lore raw

PATCH v2 9/14 test: caller and stackdepth tests for profile provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/builtinvar/tst.caller1.d        | 29 -------------------
 .../variables/bvar/tst.caller-profile.d       | 23 +++++++++++++++
 .../variables/bvar/tst.caller-profile.r       |  1 +
 .../variables/bvar/tst.caller-profile.r.p     |  1 +
 .../variables/bvar/tst.stackdepth-profile.d   | 25 ++++++++++++++++
 .../variables/bvar/tst.stackdepth-profile.r   |  1 +
 .../variables/bvar/tst.stackdepth-profile.r.p |  1 +
 7 files changed, 52 insertions(+), 29 deletions(-)
 delete mode 100644 test/unittest/builtinvar/tst.caller1.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-profile.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-profile.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-profile.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-profile.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-profile.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-profile.r.p
test/unittest/builtinvar/tst.caller1.d deleted +0 -29
deleted file mode 100644
index ca0f098f3..000000000
@@ -1,29 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, 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.
- */
-
-/*
- * ASSERTION: To print caller from profile and make sure it succeeds.
- *
- * SECTION: Variables/Built-in Variables
- */
-
-#pragma D option quiet
-
-BEGIN
-{
-}
-
-tick-10ms
-{
-	printf("The caller is %u\n", caller);
-	exit (0);
-}
-
-ERROR
-{
-	exit(1);
-}
test/unittest/variables/bvar/tst.caller-profile.d new file +23 -0
new file mode 100644
index 000000000..82d21f784
@@ -0,0 +1,23 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+profile:::tick-50ms
+/stackdepth > 1/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-profile.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-profile.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-profile.d new file +25 -0
new file mode 100644
index 000000000..614c43a08
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+profile:::tick-50ms
+/stackdepth > 1/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-profile.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-profile.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
Signature · 1 line
2.43.5
#9 lore raw

PATCH v2 10/14 test: caller and stackdepth tests for sched provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 .../variables/bvar/tst.caller-sched.d         | 32 +++++++++++++++++
 .../variables/bvar/tst.caller-sched.r         |  1 +
 .../variables/bvar/tst.caller-sched.r.p       |  1 +
 .../variables/bvar/tst.stackdepth-sched.d     | 34 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-sched.r     |  1 +
 .../variables/bvar/tst.stackdepth-sched.r.p   |  1 +
 6 files changed, 70 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-sched.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-sched.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-sched.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-sched.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-sched.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-sched.r.p
test/unittest/variables/bvar/tst.caller-sched.d new file +32 -0
new file mode 100644
index 000000000..bf73608ff
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+
+/*
+ * Some probes are implemented in terms of rawtp probes.  Avoid them
+ * due to stack-skip issues on older kernels.
+ */
+sched:::dequeue,
+sched:::enqueue,
+sched:::tick
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-sched.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-sched.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-sched.d new file +34 -0
new file mode 100644
index 000000000..05be31721
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+
+/*
+ * Some probes are implemented in terms of rawtp probes.  Avoid them
+ * due to stack-skip issues on older kernels.
+ */
+sched:::dequeue,
+sched:::enqueue,
+sched:::tick
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-sched.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-sched.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
Signature · 1 line
2.43.5
#10 lore raw

PATCH v2 11/14 test: caller and stackdepth tests for proc provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 .../unittest/variables/bvar/tst.caller-proc.d | 34 ++++++++++++++++++
 .../unittest/variables/bvar/tst.caller-proc.r |  1 +
 .../variables/bvar/tst.caller-proc.r.p        |  1 +
 .../variables/bvar/tst.stackdepth-proc.d      | 36 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-proc.r      |  1 +
 .../variables/bvar/tst.stackdepth-proc.r.p    |  1 +
 6 files changed, 74 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-proc.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-proc.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-proc.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-proc.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-proc.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-proc.r.p
test/unittest/variables/bvar/tst.caller-proc.d new file +34 -0
new file mode 100644
index 000000000..7c3557e2c
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+
+#pragma D option quiet
+
+/*
+ * Some probes are implemented in terms of rawtp probes.  Avoid them
+ * due to stack-skip issues on older kernels.
+ */
+proc:::exec,
+proc:::exec-failure,
+proc:::exec-success,
+proc:::lwp-start,
+proc:::signal-clear,
+proc:::signal-send,
+proc:::start
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-proc.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-proc.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-proc.d new file +36 -0
new file mode 100644
index 000000000..75f720370
@@ -0,0 +1,36 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+
+#pragma D option quiet
+
+/*
+ * Some probes are implemented in terms of rawtp probes.  Avoid them
+ * due to stack-skip issues on older kernels.
+ */
+proc:::exec,
+proc:::exec-failure,
+proc:::exec-success,
+proc:::lwp-start,
+proc:::signal-clear,
+proc:::signal-send,
+proc:::start
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-proc.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-proc.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
Signature · 1 line
2.43.5
#11 lore raw

PATCH v2 12/14 test: caller and stackdepth tests for rawfbt provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 .../variables/bvar/tst.caller-rawfbt.d        | 26 +++++++++++++++++
 .../variables/bvar/tst.caller-rawfbt.r        |  1 +
 .../variables/bvar/tst.caller-rawfbt.r.p      |  1 +
 .../variables/bvar/tst.stackdepth-rawfbt.d    | 28 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-rawfbt.r    |  1 +
 .../variables/bvar/tst.stackdepth-rawfbt.r.p  |  1 +
 6 files changed, 58 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-rawfbt.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-rawfbt.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-rawfbt.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawfbt.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-rawfbt.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-rawfbt.r.p
test/unittest/variables/bvar/tst.caller-rawfbt.d new file +26 -0
new file mode 100644
index 000000000..9be644ecc
@@ -0,0 +1,26 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawfbt::ksys_write:entry
+/pid == $target/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-rawfbt.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-rawfbt.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-rawfbt.d new file +28 -0
new file mode 100644
index 000000000..1c0afffe8
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/*
+ * @@trigger: periodic_output
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+rawfbt::ksys_write:entry
+/pid == $target/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-rawfbt.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-rawfbt.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
Signature · 1 line
2.43.5
#12 lore raw

PATCH v2 13/14 test: caller and stackdepth tests for io provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/variables/bvar/tst.caller-io.r  |  1 +
 .../unittest/variables/bvar/tst.caller-io.r.p |  1 +
 test/unittest/variables/bvar/tst.caller-io.sh | 39 ++++++++++++++++++
 test/unittest/variables/bvar/tst.caller-io.x  |  1 +
 .../variables/bvar/tst.stackdepth-io.r        |  1 +
 .../variables/bvar/tst.stackdepth-io.r.p      |  1 +
 .../variables/bvar/tst.stackdepth-io.sh       | 41 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-io.x        |  1 +
 8 files changed, 86 insertions(+)
 create mode 100644 test/unittest/variables/bvar/tst.caller-io.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-io.r.p
 create mode 100755 test/unittest/variables/bvar/tst.caller-io.sh
 create mode 120000 test/unittest/variables/bvar/tst.caller-io.x
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-io.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-io.r.p
 create mode 100755 test/unittest/variables/bvar/tst.stackdepth-io.sh
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-io.x
test/unittest/variables/bvar/tst.caller-io.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-io.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.caller-io.sh new file +39 -0
new file mode 100755
index 000000000..957406da4
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2025, 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.
+
+# Check that 'caller' is consistent with stack().
+
+dtrace=$1
+nblocks=1024
+filesize=$((1024*$nblocks))
+fsoptions="defaults,atime,diratime,nosuid,nodev"
+iodir=$tmpdir/tst-caller-io.$$
+tempfile=`mktemp -u -p $iodir`
+
+trap "umount $iodir; rmdir $iodir; rm -f $iodir.img" QUIT EXIT
+
+# create loopback file system
+dd if=/dev/zero of=$iodir.img bs=1024 count=$((300*$nblocks)) status=none
+mkfs.xfs $iodir.img > /dev/null
+mkdir $iodir
+test/triggers/io-mount-local.sh $iodir xfs $fsoptions
+
+$dtrace $dt_flags -c "test/triggers/doio.sh $tempfile $filesize test/triggers/io-mount-local.sh $iodir xfs $fsoptions" -qn '
+io:::
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}'
+
+exit $?
test/unittest/variables/bvar/tst.caller-io.x new file +1 -0
new file mode 120000
index 000000000..37b3ef9f8
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-io.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-io.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-io.sh new file +41 -0

41 lines not on this page · raw message

test/unittest/variables/bvar/tst.stackdepth-io.x new file +1 -0
new file mode 120000
index 000000000..37b3ef9f8
@@ -0,0 +1 @@
+skip_rawtp_old.x
\ No newline at end of file
Signature · 1 line
2.43.5
#13 lore raw

PATCH v2 14/14 test: caller and stackdepth tests for lockstat provider

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 .../variables/bvar/skip_lockstat_5.10.x       | 13 ++++++++++
 .../variables/bvar/tst.caller-lockstat.d      | 23 +++++++++++++++++
 .../variables/bvar/tst.caller-lockstat.r      |  1 +
 .../variables/bvar/tst.caller-lockstat.r.p    |  1 +
 .../variables/bvar/tst.caller-lockstat.t      |  3 +++
 .../variables/bvar/tst.caller-lockstat.x      |  1 +
 .../variables/bvar/tst.stackdepth-lockstat.d  | 25 +++++++++++++++++++
 .../variables/bvar/tst.stackdepth-lockstat.r  |  1 +
 .../bvar/tst.stackdepth-lockstat.r.p          |  1 +
 .../variables/bvar/tst.stackdepth-lockstat.t  |  3 +++
 .../variables/bvar/tst.stackdepth-lockstat.x  |  1 +
 11 files changed, 73 insertions(+)
 create mode 100755 test/unittest/variables/bvar/skip_lockstat_5.10.x
 create mode 100644 test/unittest/variables/bvar/tst.caller-lockstat.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-lockstat.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-lockstat.r.p
 create mode 100755 test/unittest/variables/bvar/tst.caller-lockstat.t
 create mode 120000 test/unittest/variables/bvar/tst.caller-lockstat.x
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-lockstat.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-lockstat.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p
 create mode 100755 test/unittest/variables/bvar/tst.stackdepth-lockstat.t
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-lockstat.x
test/unittest/variables/bvar/skip_lockstat_5.10.x new file +13 -0
new file mode 100755
index 000000000..146443fd2
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -gt 5 ]; then
+	exit 0
+fi
+if [ $MAJOR -eq 5 -a $MINOR -ge 10 ]; then
+	exit 0
+fi
+
+echo "lockstat disabled prior to 5.10"
+exit 1
test/unittest/variables/bvar/tst.caller-lockstat.d new file +23 -0
new file mode 100644
index 000000000..fbd1f1ae0
@@ -0,0 +1,23 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+lockstat:::*acquire
+/pid == $target/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.caller-lockstat.r new file +1 -0
new file mode 100644
index 000000000..2e9ba477f
@@ -0,0 +1 @@
+success
test/unittest/variables/bvar/tst.caller-lockstat.r.p new file +1 -0
new file mode 120000
index 000000000..954ca96aa
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.caller-lockstat.t new file +3 -0
new file mode 100755
index 000000000..fec0d2715
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sleep 10s
test/unittest/variables/bvar/tst.caller-lockstat.x new file +1 -0
new file mode 120000
index 000000000..539f14255
@@ -0,0 +1 @@
+skip_lockstat_5.10.x
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-lockstat.d new file +25 -0
new file mode 100644
index 000000000..de2b33dd4
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+lockstat:::*acquire
+/pid == $target/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
test/unittest/variables/bvar/tst.stackdepth-lockstat.r new file +1 -0
new file mode 100644
index 000000000..3bd29b8ed
@@ -0,0 +1 @@
+Stack depth OK
test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p new file +1 -0
new file mode 120000
index 000000000..e50f12822
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
test/unittest/variables/bvar/tst.stackdepth-lockstat.t new file +3 -0
new file mode 100755
index 000000000..fec0d2715
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sleep 10s
test/unittest/variables/bvar/tst.stackdepth-lockstat.x new file +1 -0
new file mode 120000
index 000000000..539f14255
@@ -0,0 +1 @@
+skip_lockstat_5.10.x
\ No newline at end of file
Signature · 1 line
2.43.5