[DTrace-devel] [PATCH v2] dtprobed: use /proc/$pid/map_files, not the filename of the mapping
Kris Van Hees
kris.van.hees at oracle.com
Thu Feb 12 18:51:45 UTC 2026
On Thu, Feb 12, 2026 at 01:49:54PM -0500, Eugene Loh wrote:
> On 2/12/26 13:43, Kris Van Hees wrote:
>
> > I believe the following on top of the original patch should resolve this:
> >
> > diff --git a/dtprobed/dtprobed.c b/dtprobed/dtprobed.c
> > index 9a692805..34349deb 100644
> > --- a/dtprobed/dtprobed.c
> > +++ b/dtprobed/dtprobed.c
> > @@ -487,16 +487,17 @@ handle_usdt_notes(pid_t pid, uintptr_t addr)
> > fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapping (process dead?)\n",
> > pid);
> > goto out;
> > - } else if ((fn = Pmap_mapfile_name(P, mapp)) == NULL) {
> > + } else if (prf->prf_mapname == NULL ||
> > + (fn = Pmap_mapfile_name(P, mapp)) == NULL) {
> > fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapname (process dead?)\n",
> > pid);
> > goto out;
> > }
> > - mod = strrchr(fn, '/');
> > + mod = strrchr(prf->prf_mapname, '/');
> > if (mod)
> > mod++;
> > else
> > - mod = fn;
>
> Is that a '-' on the last line?
Yes, but it is missing the last line (sorry about that):
+ mod = prf->prf_mapname;
> > On Thu, Feb 12, 2026 at 01:37:06PM -0500, Kris Van Hees wrote:
> > > Oh, easy solution.... determine the mod name from prf->prf_mapname like we
> > > did before. I.e. work with two filenames, one from prf->prf_mapname to get
> > > the module name, and one from Pmap_mapfile_name() to access the mapping data.
> > >
> > > On Thu, Feb 12, 2026 at 01:28:08PM -0500, Kris Van Hees via DTrace-devel wrote:
> > > > Here is the problem:
> > > >
> > > > prf = mapp->pr_file;
> > > > if (prf == NULL || (mapp = prf->first_segment) == NULL) {
> > > > fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapping (process dead?)\n",
> > > > pid);
> > > > goto out;
> > > > } else if ((fn = Pmap_mapfile_name(P, mapp)) == NULL) {
> > > > fuse_log(FUSE_LOG_ERR, "%i: dtprobed: cannot look up mapname (process dead?)\n",
> > > > pid);
> > > > goto out;
> > > > }
> > > > mod = strrchr(fn, '/');
> > > > if (mod)
> > > > mod++;
> > > > else
> > > > mod = fn;
> > > >
> > > > Since you changed this to get the mapping filename in map_files, you get a
> > > > name that has the address range as its filename, and since that gets used as
> > > > the module name, you end up with the wrong module name in the probe spec.
> > > >
> > > > It needs to be the actual filename of the source file that the mapping came
> > > > from.
> > > >
> > > > On Thu, Feb 12, 2026 at 06:18:25PM +0000, Nick Alcock wrote:
> > > > > On 12 Feb 2026, Eugene Loh outgrape:
> > > > >
> > > > > > I do not know what went wrong here. I would have bet big money that I
> > > > > > tested this, but here is what I find now with this patch:
> > > > > So did I!
> > > > >
> > > > > > test/unittest/usdt/tst.enabled.sh: Running timeout --signal=TERM 41 test/unittest/usdt/tst.enabled.sh /home/.../build/dtrace
> > > > > > FAIL: expected results differ.
> > > > > > 400000-401000:main:go
> > > > > >
> > > > > > Diff against expected:
> > > > > > --- test/unittest/usdt/tst.enabled.r 2026-02-12 05:31:24.000000000 +0000
> > > > > > +++ /tmp/runtest.6196/test.out 2026-02-12 18:09:58.980466976 +0000
> > > > > > @@ -1,2 +1,2 @@
> > > > > > -test:main:go
> > > > > > +400000-401000:main:go
> > > > > This suggests that symbol lookup is failing, which it shouldn't be,
> > > > > because that *too* uses /proc/$pid/map_files, or should.
> > > > >
> > > > > I clearly need to debug this. Got a system on which it goes wrong?
> > > > _______________________________________________
> > > > 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