[DTrace-devel] [PATCH] cg: allow non-fatal dt_cg_ctf_offsetof() failures

Kris Van Hees kris.van.hees at oracle.com
Thu Nov 30 20:18:17 UTC 2023


On Thu, Nov 30, 2023 at 03:01:51PM -0500, Eugene Loh via DTrace-devel wrote:
> Sorry.  I don't think this ever hit my inbox.
> 
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> 
> How about non-fatal if the struct itself cannot be found???

If we encounter that as a needed case, we can certainly add that, but I have
not yet encountered that.  In fact, I have been thinking about changing this
to be a function that takes a type and member name, because there are quite
a few cases where we have repeated lookups for members in the same struct.

We could still have one that takes structname and membername for the cases
we only need a single lookup, that uses a type / membername combination as
the one that does the actual work.

Anyway, this is only thoughts - not implemented yet.

> Wed Nov 22 20:57:08 UTC 2023 patch:
> > Lookup failures for a struct member should not always be fatal.  There
> > is a need to be able to try again (e.g. to support the case where a
> > struct member was renamed between two kernel versions).
> > 
> > diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> > @@ -1650,8 +1651,13 @@ dt_cg_ctf_offsetof(const char *structname, const
> > char *membername, size_t *sizep
> >   ctfp = sym.dtt_ctfp;
> >   if (!ctfp) /* Should never happen. */
> >   longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> > - if (ctf_member_info(ctfp, sym.dtt_type, membername, &ctm) == CTF_ERR)
> > - longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> > + if (ctf_member_info(ctfp, sym.dtt_type, membername, &ctm) == CTF_ERR) {
> > + if (relaxed)
> > + return -1;
> > + else
> 
> Looks fine, though could also drop the "else".

True, I will drop the "else" to make it more explicit that the longjmp is the
default.

> > + longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> > + }
> > +
> >   if (sizep)
> >   *sizep = ctf_type_size(ctfp, ctm.ctm_type);
> > 
> 
> _______________________________________________
> 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