[DTrace-devel] [PATCH 2/2] test: Account for pid:::entry ustack() being correct

eugene.loh at oracle.com eugene.loh at oracle.com
Sat Feb 8 23:21:06 UTC 2025


From: Eugene Loh <eugene.loh at oracle.com>

The pid:::entry uprobe fires so early in the function preamble
that the frame pointer is not yet set and the caller is not (yet)
correctly identified.  In Linux 6.11, x86-specific heuristics
address this problem.

Post process results from this test to accommodate both cases --
missing caller and not missing caller.

Orabug: 37459289
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 test/unittest/ustack/tst.ustack25_pid.r   |  1 +
 test/unittest/ustack/tst.ustack25_pid.r.p | 37 +++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100755 test/unittest/ustack/tst.ustack25_pid.r.p

diff --git a/test/unittest/ustack/tst.ustack25_pid.r b/test/unittest/ustack/tst.ustack25_pid.r
index 89b35c028..e7732fb81 100644
--- a/test/unittest/ustack/tst.ustack25_pid.r
+++ b/test/unittest/ustack/tst.ustack25_pid.r
@@ -1,5 +1,6 @@
 
               ustack-tst-basic`myfunc_z
+              ustack-tst-basic`myfunc_y+{ptr}
               ustack-tst-basic`myfunc_x+{ptr}
               ustack-tst-basic`myfunc_w+{ptr}
               ustack-tst-basic`myfunc_v+{ptr}
diff --git a/test/unittest/ustack/tst.ustack25_pid.r.p b/test/unittest/ustack/tst.ustack25_pid.r.p
new file mode 100755
index 000000000..6486f7ec6
--- /dev/null
+++ b/test/unittest/ustack/tst.ustack25_pid.r.p
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# A pid entry probe places a uprobe on the first instruction of a function.
+# Unfortunately, this is so early in the function preamble that the function
+# frame pointer has not yet been established and the actual caller of the
+# traced function is missed.
+#
+# In Linux 6.11, x86-specific heuristics are introduced to fix this problem.
+# See commit cfa7f3d
+# ("perf,x86: avoid missing caller address in stack traces captured in uprobe")
+# for both a description of the problem and an explanation of the heuristics.
+#
+# Add post processing to these test results to allow for both cases:
+# caller frame is missing or not missing.
+
+missing_caller=1
+if [ $(uname -m) == "x86_64" ]; then
+        read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+        if [ $MAJOR -ge 6 ]; then
+                if [ $MAJOR -gt 6 -o $MINOR -ge 11 ]; then
+                        missing_caller=0
+                fi
+        fi
+fi
+
+if [ $missing_caller -eq 1 ]; then
+        # Add the missing caller function after the current function.
+        awk '{ print }
+             /myfunc_z/ { print "              ustack-tst-basic`myfunc_y+{ptr}" }'
+else
+        # The .r results file has an extra frame at the end in case
+        # the caller frame is missing and the 25-frame limit goes
+        # "too far."  If the caller is not missing, fake that extra frame.
+        awk '{ print }
+             /myfunc_b/ { print "              ustack-tst-basic`myfunc_a+{ptr}" }'
+fi
-- 
2.43.5




More information about the DTrace-devel mailing list