usdt, stapsdt: fix argument handling for multi-location probes
PATCH v3 2/2 usdt, stapsdt: fix argument handling for multi-location probes
When a USDT probe has multiple call sites in the same function, only one of the probe programs retrieves the argument values correctly. The probe argument data is collected for the first underlying probe, and then skipped for any subsequent underlying probes.
Since it is not guaranteed that the argument description is identical for all underlying probes (although it is almost always that way), we need to process the argument description string for each underlying probe.
Orabug: 38922360
Signed-off-by Kris Van Hees <[email protected]>
--- libdtrace/dt_pid.c | 9 ++- libdtrace/dt_prov_uprobe.c | 10 +-- test/unittest/usdt/tst.multiloc.r | 4 ++ test/unittest/usdt/tst.multiloc.sh | 69 +++++++++++++++++++ .../usdt/tst.stapsdt-notes-bug38922360.r | 4 ++ .../usdt/tst.stapsdt-notes-bug38922360.sh | 54 +++++++++++++++ 6 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 test/unittest/usdt/tst.multiloc.r create mode 100755 test/unittest/usdt/tst.multiloc.sh create mode 100644 test/unittest/usdt/tst.stapsdt-notes-bug38922360.r create mode 100755 test/unittest/usdt/tst.stapsdt-notes-bug38922360.sh
libdtrace/dt_pid.c +8 -1
@@ -1350,9 +1350,16 @@ dt_stapsdt_parse(dtrace_hdl_t *dtp, dt_proc_t *dpr, dtrace_probedesc_t *pdp,if (strcmp (pdp->prb,"*" ) !=0 && (strlen (pdp->prb) >0 &&strcmp (pdp->prb, prbname) !=0 ))continue ; -if (prb +strlen (prb) +1 < dbuf + doff + nhdr.n_descsz) +if (prb +strlen (prb) +1 < dbuf + doff + nhdr.n_descsz) { +char *p; + psp.pps_sargv = prb +strlen (prb) +1 ; +for (p = psp.pps_sargv; (p =strchr (p,'@' )) !=NULL ; + p++) + psp.pps_nargc++; + } + psp.pps_type =DTPPT_STAPSDT ; psp.pps_prv = prvname; psp.pps_mod = mod;
libdtrace/dt_prov_uprobe.c +1 -9
@@ -1659,15 +1659,7 @@ static int probe_info_stap(dtrace_hdl_t *dtp, const dt_probe_t *prp,if (!upp || upp->sargv ==NULL ) goto done; -/* First count the arguments. */ -for (p = upp->sargv; p !=NULL ; argc++) { - p =strchr (p,'@' ); -if (p++ ==NULL ) -break ; - } - -/* Record number of arguments, and allocate descriptors. */ - upp->sargc = argc; + argc = upp->sargc;if (argc ==0 ) goto done;
test/unittest/usdt/tst.multiloc.r new file +4 -0
@@ -0,0 +1,4 @@ +main +test:main:args main +test:main:args main +
test/unittest/usdt/tst.multiloc.sh new file +69 -0
69 lines not on this page · raw message
test/unittest/usdt/tst.stapsdt-notes-bug38922360.r new file +4 -0
@@ -0,0 +1,4 @@ +main +test:main:args main +test:main:args main +
test/unittest/usdt/tst.stapsdt-notes-bug38922360.sh new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.51.0