[DTrace-devel] [PATCH 1/5] Allow dtrace provider's uprobe_spec to use pid other than mine
Kris Van Hees
kris.van.hees at oracle.com
Wed Dec 20 15:52:23 UTC 2023
On Tue, Sep 05, 2023 at 12:11:38AM -0400, eugene.loh at oracle.com wrote:
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
... although I would change the subject a little to not refer to 'mine'.
How about "Pass pid explicitly to dtrace provider's uprobe_spec" ?
> ---
> libdtrace/dt_prov_dtrace.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/libdtrace/dt_prov_dtrace.c b/libdtrace/dt_prov_dtrace.c
> index 0c3bb135..a8ea66d6 100644
> --- a/libdtrace/dt_prov_dtrace.c
> +++ b/libdtrace/dt_prov_dtrace.c
> @@ -167,7 +167,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
> return 0;
> }
>
> -static char *uprobe_spec(const char *prb)
> +static char *uprobe_spec(pid_t pid, const char *prb)
> {
> struct ps_prochandle *P;
> int perr = 0;
> @@ -178,8 +178,8 @@ static char *uprobe_spec(const char *prb)
> if (asprintf(&fun, "%s%s", prb, PROBE_FUNC_SUFFIX) < 0)
> return NULL;
>
> - /* grab our process */
> - P = Pgrab(getpid(), 2, 0, NULL, &perr);
> + /* grab the process */
> + P = Pgrab(pid, 2, 0, NULL, &perr);
> if (P == NULL) {
> free(fun);
> return NULL;
> @@ -187,7 +187,7 @@ static char *uprobe_spec(const char *prb)
>
> /* look up function and thus addr */
> if (Pxlookup_by_name(P, -1, PR_OBJ_EVERY, fun, &sym, NULL) == 0)
> - spec = uprobe_spec_by_addr(getpid(), P, sym.st_value, NULL);
> + spec = uprobe_spec_by_addr(pid, P, sym.st_value, NULL);
>
> free(fun);
> Prelease(P, PS_RELEASE_NORMAL);
> @@ -208,7 +208,7 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
> int fd, rc = -1;
>
> /* get a uprobe specification for this probe */
> - spec = uprobe_spec(prp->desc->prb);
> + spec = uprobe_spec(getpid(), prp->desc->prb);
> if (spec == NULL)
> return -ENOENT;
>
> --
> 2.18.4
>
>
More information about the DTrace-devel
mailing list