[DTrace-devel] [PATCH] Add function name to underlying return probes
Kris Van Hees
kris.van.hees at oracle.com
Wed Aug 6 18:35:48 UTC 2025
On Tue, Aug 05, 2025 at 12:51:11AM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at 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 at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at 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
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list