Skip to content

Commit

Permalink
probe: propagate dt_probe_args_info() failures to dt_probe_info()
Browse files Browse the repository at this point in the history
Failures in dt_probe_args_info() were ignored by dt_probe_info() and
that could lead to strange behaviour.  E.g. if lockmem issues cause
the logic in the raw tracepoint argument count determination to fail,
the probe was reported as not having any arguments.  This patch will
make it possible to add code to accurately report such failures
rather than silently ignoring them.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
  • Loading branch information
kvanhees committed Jan 3, 2024
1 parent 7da9e5b commit 8d9ae28
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
16 changes: 12 additions & 4 deletions cmd/dtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ info_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,

if (dtrace_probe_info(dtp, pdp, &p) == 0)
print_probe_info(&p);
else
return -1;

*last = edp;
return 0;
Expand Down Expand Up @@ -417,8 +419,12 @@ list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
oprintf("%5d %10s %17s %33s %s\n",
pdp->id, pdp->prv, pdp->mod, pdp->fun, pdp->prb);

if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0)
print_probe_info(&p);
if (g_verbose) {
if (dtrace_probe_info(dtp, pdp, &p) == 0)
print_probe_info(&p);
else
return -1;
}

return 0;
}
Expand Down Expand Up @@ -1426,8 +1432,10 @@ main(int argc, char *argv[])
for (i = 0; i < g_cmdc; i++)
list_prog(&g_cmdv[i]);

if (g_cmdc == 0)
dtrace_probe_iter(g_dtp, NULL, list_probe, NULL);
if (g_cmdc == 0) {
if (dtrace_probe_iter(g_dtp, NULL, list_probe, NULL) < 0)
dfatal(NULL); /* dtrace_errmsg() only */
}

dtrace_close(g_dtp);
return g_status;
Expand Down
1 change: 1 addition & 0 deletions libdtrace/dt_bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/bpf.h>
#include <linux/perf_event.h>
#include <dtrace/difo.h>
#include <dt_impl.h>

struct dtrace_hdl;

Expand Down
22 changes: 13 additions & 9 deletions libdtrace/dt_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,25 +881,26 @@ dt_probe_delete(dtrace_hdl_t *dtp, dt_probe_t *prp)
/* FIXME: Add cleanup code for the dt_probe_t itself. */
}

static void
static int
dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
{
int argc = 0;
dt_argdesc_t *argv = NULL;
int i, nc, xc;
int rc, i, nc, xc;
dtrace_typeinfo_t dtt;

/* Only retrieve probe argument information once per probe. */
if (prp->argc != -1)
return;
return 0;
if (!prp->prov->impl->probe_info)
return;
if (prp->prov->impl->probe_info(dtp, prp, &argc, &argv) < 0)
return;
return 0;
rc = prp->prov->impl->probe_info(dtp, prp, &argc, &argv);
if (rc == -1)
return rc;

if (!argc || !argv) {
prp->argc = 0;
return;
return 0;
}

nc = 0;
Expand All @@ -915,7 +916,7 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
dt_probe_alloc_args(prp, nc, xc);

if ((xc != 0 && prp->xargs == NULL) || (nc != 0 && prp->nargs == NULL))
return;
return 0;

/*
* Iterate over the arguments and assign their types to prp->nargv[],
Expand Down Expand Up @@ -964,6 +965,8 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
}

dt_free(dtp, argv);

return 0;
}

/*ARGSUSED*/
Expand Down Expand Up @@ -1066,7 +1069,8 @@ dt_probe_info(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
if (!n_is_glob)
pip->dtp_attr = dt_attr_min(pip->dtp_attr, pap->dtpa_name);

dt_probe_args_info(dtp, prp);
if (dt_probe_args_info(dtp, prp) == -1)
return NULL;

pip->dtp_arga = pap->dtpa_args;
pip->dtp_argv = prp->argv;
Expand Down

0 comments on commit 8d9ae28

Please sign in to comment.