All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add function name to underlying return probes
@ 2025-08-05  4:51 eugene.loh
  2025-08-06 18:35 ` [DTrace-devel] " Kris Van Hees
  0 siblings, 1 reply; 2+ messages in thread
From: eugene.loh @ 2025-08-05  4:51 UTC (permalink / raw)
  To: dtrace, dtrace-devel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-06 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05  4:51 [PATCH] Add function name to underlying return probes eugene.loh
2025-08-06 18:35 ` [DTrace-devel] " Kris Van Hees

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.