All of lore.kernel.org
 help / color / mirror / Atom feed
From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH] Add function name to underlying return probes
Date: Tue,  5 Aug 2025 00:51:11 -0400	[thread overview]
Message-ID: <20250805045111.9607-1-eugene.loh@oracle.com> (raw)

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

In commit 35a4f05c2
("Add support for pid function "-" with absolute offset"),
function names were removed from underlying probe descriptions.
That was so that pid absolute offset probes (pid$pid:a.out:-:$absoff),
with function "-", could sit on the same underlying probes as
pid$pid:$mod:$fun:entry, pid$pid:$mod:$fun:$off, and USDT probes.

While that made sense for those probes, it did not make sense for pid
return probes:  their underlying probes, all with probe name "return",
are no longer distinguishable.  Further, there was no need for any such
change, since no other probes will have the same underlying return probe.

Name underlying return probes with function name.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 libdtrace/dt_prov_uprobe.c           |  7 +++++--
 test/unittest/pid/tst.multi-return.d | 21 +++++++++++++++++++++
 test/unittest/pid/tst.multi-return.r |  7 +++++++
 3 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 test/unittest/pid/tst.multi-return.d
 create mode 100644 test/unittest/pid/tst.multi-return.r

diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
index a633b6fe7..3661f09d9 100644
--- a/libdtrace/dt_prov_uprobe.c
+++ b/libdtrace/dt_prov_uprobe.c
@@ -906,6 +906,7 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
 				     const pid_probespec_t *psp)
 {
 	char			mod[DTRACE_MODNAMELEN];
+	char			fun[DTRACE_FUNCNAMELEN];
 	char			prb[DTRACE_NAMELEN];
 	dtrace_probedesc_t	pd;
 	dt_probe_t		*uprp;
@@ -923,12 +924,14 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
 	 *
 	 * The probe description for return probes is:
 	 *
-	 *	uprobe:<dev>_<inode>::return
+	 *	uprobe:<dev>_<inode>:<func>:return
 	 */
 	snprintf(mod, sizeof(mod), "%lx_%lx", psp->pps_dev, psp->pps_inum);
 
+	fun[0] = '\0';
 	switch (psp->pps_type) {
 	case DTPPT_RETURN:
+		strcpy(fun, psp->pps_fun);
 		strcpy(prb, "return");
 		break;
 	case DTPPT_IS_ENABLED:
@@ -946,7 +949,7 @@ static dt_probe_t *create_underlying(dtrace_hdl_t *dtp,
 	pd.id = DTRACE_IDNONE;
 	pd.prv = prvname;
 	pd.mod = mod;
-	pd.fun = "";
+	pd.fun = fun;
 	pd.prb = prb;
 
 	dt_dprintf("Providing underlying probe %s:%s:%s:%s @ %lx\n", psp->pps_prv,
diff --git a/test/unittest/pid/tst.multi-return.d b/test/unittest/pid/tst.multi-return.d
new file mode 100644
index 000000000..0f81f343c
--- /dev/null
+++ b/test/unittest/pid/tst.multi-return.d
@@ -0,0 +1,21 @@
+/*
+ * 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: profile-tst-ufuncsort */
+/* @@nosort */
+
+#pragma D option quiet
+
+pid$target:a.out::return
+{
+	@[probefunc] = count();
+}
+
+tick-2s
+{
+	exit(0);
+}
diff --git a/test/unittest/pid/tst.multi-return.r b/test/unittest/pid/tst.multi-return.r
new file mode 100644
index 000000000..bf885b28c
--- /dev/null
+++ b/test/unittest/pid/tst.multi-return.r
@@ -0,0 +1,7 @@
+
+  f_b                                                               1
+  f_e                                                               1
+  f_d                                                               2
+  f_a                                                               3
+  f_c                                                               4
+  fN                                                               11
-- 
2.43.5


             reply	other threads:[~2025-08-05  4:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  4:51 eugene.loh [this message]
2025-08-06 18:35 ` [DTrace-devel] [PATCH] Add function name to underlying return probes Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250805045111.9607-1-eugene.loh@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.