[DTrace-devel] [PATCH 4/4] Do not register handlers when not executing probe clauses
Kris Van Hees
kris.van.hees at oracle.com
Wed Jun 10 09:42:06 PDT 2020
On Wed, Jun 10, 2020 at 09:14:34AM -0700, Eugene Loh wrote:
> This raises a question I've been curious about. Why do we even compile
> clauses if, say, we're in "list" mode? In that case, we only care about
> the probe descriptions, and the clauses don't matter.
Excellent question and one I have pondered for quite a long time myself...
And the main reason seems to be that -l is an operation mode where all probes
that are used by scripts (and/or command line clauses) are listed. A script
may include other scripts and thereby end up with a larger probe set than can
be seen from just the script itself. That is one example where compilation
(or in this case at least pre-processing) matters in terms of being able to
capture the complete set of probes.
> On 06/10/2020 08:23 AM, Kris Van Hees wrote:
> > The various handlers that are used by consumers only apply to the
> > execution of probe clauses. For operating modes that do not execute
> > clauses there is no need to register handlers. Even worse, if e.g.
> > the error handler is being registered with the default error clause
> > and -xnolibs is used (which is common with the -h option to generate
> > a header file), an error will occur because bpf_get_bvar() cannot be
> > found.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> > cmd/dtrace.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/dtrace.c b/cmd/dtrace.c
> > index cef86ef2..17d5692a 100644
> > --- a/cmd/dtrace.c
> > +++ b/cmd/dtrace.c
> > @@ -1337,7 +1337,11 @@ main(int argc, char *argv[])
> > for (i = 0; i < g_cmdc; i++)
> > g_cmdv[i].dc_func(&g_cmdv[i]);
> >
> > - if (g_mode != DMODE_LIST) {
> > + /*
> > + * We only need to register handler if we are going to execute probe
> > + * clauses.
> > + */
> > + if (g_mode == DMODE_EXEC) {
> > if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1)
> > dfatal("failed to establish error handler");
> >
>
>
> _______________________________________________
> 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