[DTrace-devel] [PATCH 05/12] cc: use dt_node_root() in trampline compilation for clarity

Kris Van Hees kris.van.hees at oracle.com
Sat Jan 6 06:30:57 UTC 2024


On Sat, Jan 06, 2024 at 01:01:27AM -0500, Eugene Loh via DTrace-devel wrote:
> I can't claim to understand this, but looks safe enough.
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> 
> But couldn't the entire patch be done more simply with this one change:
>         dt_setcontext(dtp, yypcb->pcb_pdesc);
> -       tnp = dt_node_trampoline(prp);
> +       dt_node_root(dt_node_trampoline(prp));
> +       tnp = yypcb->pcb_root;
>         dt_node_type_assign(tnp, dtp->dt_ints[0].did_ctfp,
> 
> That makes the change easier to see and arguably simplifies the resulting
> code.

The benefit is very minor though and results in code that is different from
other places where dt_cg() in invoked on the root node.  I went for consistency
with existing code.

> On 1/5/24 00:27, Kris Van Hees via DTrace-devel wrote:
> 
> > Node trees roots are typically (in the parser) registered with the PCB
> > for compilation.  While the trampoline generation does not strictly
> > need it, it is the proper way to do this.
> > 
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_cc.c | 11 +++++------
> >   1 file changed, 5 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> > index 2f9f1574..1e830472 100644
> > --- a/libdtrace/dt_cc.c
> > +++ b/libdtrace/dt_cc.c
> > @@ -1,6 +1,6 @@
> >   /*
> >    * Oracle Linux DTrace.
> > - * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
> > + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
> >    * Licensed under the Universal Permissive License v 1.0 as shown at
> >    * http://oss.oracle.com/licenses/upl.
> >    */
> > @@ -782,7 +782,6 @@ dtrace_difo_t *
> >   dt_construct(dtrace_hdl_t *dtp, dt_probe_t *prp, uint_t cflags, dt_ident_t *idp)
> >   {
> >   	dt_pcb_t	pcb;
> > -	dt_node_t	*tnp;
> >   	dtrace_difo_t	*dp = NULL;
> >   	int		err;
> > @@ -836,10 +835,10 @@ dt_construct(dtrace_hdl_t *dtp, dt_probe_t *prp, uint_t cflags, dt_ident_t *idp)
> >   		dt_idhash_iter(yypcb->pcb_pragmas, dt_idpragma, NULL);
> >   	dt_setcontext(dtp, yypcb->pcb_pdesc);
> > -	tnp = dt_node_trampoline(prp);
> > -	dt_node_type_assign(tnp, dtp->dt_ints[0].did_ctfp,
> > -				 dtp->dt_ints[0].did_type);
> > -	dt_cg(yypcb, tnp);
> > +	dt_node_root(dt_node_trampoline(prp));
> > +	dt_node_type_assign(yypcb->pcb_root, dtp->dt_ints[0].did_ctfp,
> > +					     dtp->dt_ints[0].did_type);
> > +	dt_cg(yypcb, yypcb->pcb_root);
> >   	dp = dt_as(yypcb);
> >   	/*
> 
> _______________________________________________
> 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