public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Nick Alcock <nick.alcock@oracle.com>
To: Kris Van Hees <kris.van.hees@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 2/4] btf: use dt_btf_real_type_by_id() to resolve types
Date: Fri, 17 Apr 2026 18:05:19 +0100	[thread overview]
Message-ID: <87ik9pzfe8.fsf@esperi.org.uk> (raw)
In-Reply-To: <IA0PR10MB732561FE075BF04C79C5CA54C2252@IA0PR10MB7325.namprd10.prod.outlook.com> (Kris Van Hees's message of "Tue, 14 Apr 2026 02:27:46 -0400")

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?

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.)

-- 
NULL && (void)

  reply	other threads:[~2026-04-17 17:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14  6:27 [PATCH 2/4] btf: use dt_btf_real_type_by_id() to resolve types Kris Van Hees
2026-04-17 17:05 ` Nick Alcock [this message]
2026-04-17 19:00   ` Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ik9pzfe8.fsf@esperi.org.uk \
    --to=nick.alcock@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=kris.van.hees@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox