Add function name to underlying return probes
PATCH 1/1 Add function name to underlying return probes
From: Eugene Loh <[email protected]>
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.
--- 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
libdtrace/dt_prov_uprobe.c +5 -2
@@ -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,
test/unittest/pid/tst.multi-return.d new file +21 -0
@@ -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); +}
test/unittest/pid/tst.multi-return.r new file +7 -0
@@ -0,0 +1,7 @@ + + f_b 1 + f_e 1 + f_d 2 + f_a 3 + f_c 4 + fN 11
Signature · 1 line
2.43.5
Quoted 9 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
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.
Quoted 8 lines
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 <[email protected]>
Quoted 93 lines
--- 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.rlibdtrace/dt_prov_uprobe.c +5
-2@@ -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,test/unittest/pid/tst.multi-return.d new file +21
-0@@ -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); +}test/unittest/pid/tst.multi-return.r new file +7
-0@@ -0,0 +1,7 @@ + + f_b 1 + f_e 1 + f_d 2 + f_a 3 + f_c 4 + fN 11Signature · 7 lines
2.43.5 _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel