[DTrace-devel] [PATCH 2/4] btf: use dt_btf_real_type_by_id() to resolve types
Kris Van Hees
kris.van.hees at oracle.com
Fri Apr 17 19:00:27 UTC 2026
On Fri, Apr 17, 2026 at 06:05:19PM +0100, Nick Alcock wrote:
> On 14 Apr 2026, Kris Van Hees said:
>
> > Functions that need to check type data operate on the real type rather
> > than a typedef or a type with modifiers. Similarly, when a type of a
> > function is needed, the prototype (BTF type BTF_KIND_PROTO) is what is
> > really needed.
> >
> > Introducing dt_btf_real_type_by_id() removed duplication of code in other
> > functions.
>
> Perhaps dt_btf_resolve_type(), for consistency with the libctf function
> naming?
Hm, no, I don't think that would be what we want here because I think they
do have slightly different semantics.
> Other than that...
>
> > ---
> > libdtrace/dt_btf.c | 43 +++++++++++++++++++++++++++++--------------
> > 1 file changed, 29 insertions(+), 14 deletions(-)
> >
> > diff --git a/libdtrace/dt_btf.c b/libdtrace/dt_btf.c
> > index d08599192..56eb96a4e 100644
> > --- a/libdtrace/dt_btf.c
> > +++ b/libdtrace/dt_btf.c
> > @@ -848,6 +848,26 @@ dt_btf_type_by_id(dtrace_hdl_t *dtp, const dt_btf_t *btf, int32_t id)
> > return btf->types[id - (dtp->dt_shared_btf->type_cnt - 1)];
> > }
> >
> > +static btf_type_t *
> > +dt_btf_real_type_by_id(dtrace_hdl_t *dtp, const dt_btf_t *btf, int32_t id)
> > +{
> > + btf_type_t *type = dt_btf_type_by_id(dtp, btf, id);
> > +
> > + do {
> > + switch (BTF_INFO_KIND(type->info)) {
> > + case BTF_KIND_CONST:
> > + case BTF_KIND_FUNC:
> > + case BTF_KIND_TYPEDEF:
> > + case BTF_KIND_VOLATILE:
>
> Probably this should traverse BTF_KIND_RESTRICT as well. (The kernel
> *does* use restrict qualifiers in some places. I was surprised too.)
Ah yes, thanks.
More information about the DTrace-devel
mailing list