[DTrace-devel] [PATCH 01/13] Change use of dtrace_probe_iter()
Kris Van Hees
kris.van.hees at oracle.com
Mon Jul 6 08:09:18 PDT 2020
On Wed, Jul 01, 2020 at 10:41:06PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> In DTrace v1, dtrace_probe_iter() was used to iterate over probes,
> using dt_probe_iter() as a callback function.
>
> In the current release, dtrace_probe_iter() will be used as an external
> API, with dt_probe_iter() the "internal" (to libdtrace) interface.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
> libdtrace/dt_probe.c | 26 +++++++++-----------------
> 1 file changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/libdtrace/dt_probe.c b/libdtrace/dt_probe.c
> index b6c79354..46c47fbe 100644
> --- a/libdtrace/dt_probe.c
> +++ b/libdtrace/dt_probe.c
> @@ -960,10 +960,10 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
>
> /*ARGSUSED*/
> static int
> -dt_probe_desc(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
> +dt_probe_representative(dtrace_hdl_t *dtp, const dt_probe_t *prp, void *arg)
I think dt_probe_first_match would be a more appropriate name since that is
what this callback provides. Also, change the last arg type to be dt_probe_t **
so you dont't have to do the cast twice below.
> {
> - if (((dtrace_probedesc_t *)arg)->id == DTRACE_IDNONE) {
> - memcpy(arg, pdp, sizeof (dtrace_probedesc_t));
> + if (*((dt_probe_t **)arg) == NULL) {
> + *((dt_probe_t **)arg) = prp;
See above concerning the type of arg and avoiding the casts..
> return (0);
> }
>
> @@ -982,24 +982,20 @@ dt_probe_info(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
> dt_probe_t *prp = NULL;
> const dtrace_pattr_t *pap;
> dt_provider_t *pvp;
> - dtrace_probedesc_t pd;
> int m;
>
> - memset(&pd, 0, sizeof (pd));
> - pd.id = DTRACE_IDNONE;
> -
> /*
> - * Call dtrace_probe_iter() to find matching probes. Our
> + * Call dt_probe_iter() to find matching probes. Our
> * dt_probe_desc() callback will produce the following results:
> *
> - * m < 0 dtrace_probe_iter() found zero matches (or failed).
> - * m > 0 dtrace_probe_iter() found more than one match.
> - * m = 0 dtrace_probe_iter() found exactly one match.
> + * m < 0 dt_probe_iter() found zero matches (or failed).
> + * m > 0 dt_probe_iter() found more than one match.
> + * m = 0 dt_probe_iter() found exactly one match.
> */
The comment block needs fixing. You kept the reference to dt_probe_desc as a
callback, but the point is that it isn't a callback at all in DTrace v2. I
expect you want dt_probe_first_match() here.
> - if ((m = dtrace_probe_iter(dtp, pdp, dt_probe_desc, &pd)) < 0)
> + if ((m = dt_probe_iter(dtp, pdp, dt_probe_representative, NULL, &prp)) < 0)
Adjust name of callback function.
> return NULL; /* dt_errno is set for us */
>
> - if ((pvp = dt_provider_lookup(dtp, pd.prv)) == NULL)
> + if ((pvp = prp->prov) == NULL)
> return NULL; /* dt_errno is set for us */
>
> /*
> @@ -1043,10 +1039,6 @@ dt_probe_info(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
> }
> }
>
> - prp = dt_probe_lookup(dtp, &pd);
> - if (!prp)
> - return NULL; /* dt_errno is set for us */
> -
> /*
> * Compute the probe description attributes by taking the minimum of
> * the attributes of the specified fields. If no provider is specified
> --
> 2.18.2
>
>
> _______________________________________________
> 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