Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Apr 2024 18:03:00 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 278489] dtrace; pid probe; unable to match constructor functions
Message-ID:  <bug-278489-227-1P1dUzPZ9B@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-278489-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-278489-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D278489

--- Comment #2 from martin <martin@bxlr.sk> ---
Indeed evaltime works in that scenario.

The issue was originally shared on forums here:
https://forums.freebsd.org/threads/tracing-shared-library-functions-using-d=
trace.93172/

I tried to simplified is as much as possible before opening PR. I didn't te=
st
it with the evaltime for my simplified version.

Original issue is that these constructors are not matched on custom librari=
es.
Simple "mylib" demo lib:

#include <stdio.h>
#include "mylib.h"

static int rc;

void __attribute__((constructor)) mysetup(void) {
        printf("*** %s exec\n", __func__);
        rc =3D 666;
}

void __attribute__((destructor)) leave(void) {
        rc =3D 0;
}

int hello(char* s) {
        printf("%s: %s\n", __func__, s);
        return rc;
}

Still lists the functions as expected:

# dtrace -ln 'pid$target:mylib.so::entry' -c ./test
*** mysetup exec
hidden stuff
   ID   PROVIDER            MODULE                          FUNCTION NAME
82966    pid1096          mylib.so             __do_global_dtors_aux entry
82967    pid1096          mylib.so                  register_classes entry
82968    pid1096          mylib.so             __do_global_ctors_aux entry
82969    pid1096          mylib.so                           mysetup entry
82970    pid1096          mylib.so                             leave entry
82971    pid1096          mylib.so                             hello entry

But doesn't match it:

# dtrace -n 'pid$target:mylib.so::entry' -c ./test
*** mysetup exec
hidden stuff
dtrace: description 'pid$target:mylib.so::entry' matched 6 probes
hello: my hello program

return value: 666
dtrace: pid 1098 has exited
CPU     ID                    FUNCTION:NAME
  7  82971                      hello:entry
  7  82970                      leave:entry
  7  82966      __do_global_dtors_aux:entry

Specifying evaltime fails to match any probes:

# dtrace -x evaltime=3Dexec -n 'pid$target:mylib.so::entry' -c ./test
dtrace: invalid probe specifier pid$target:mylib.so::entry: probe descripti=
on
pid1100:mylib.so::entry does not match any probes

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-278489-227-1P1dUzPZ9B>