BPF List
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Vineet Gupta" <vineet.gupta@linux.dev>, <dwarves@vger.kernel.org>
Cc: <bpf@vger.kernel.org>, "Andrii Nakryiko" <andrii@kernel.org>,
	<acme@kernel.org>, "Alan Maguire" <alan.maguire@oracle.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	<jose.marchesi@oracle.com>,
	"David Faust" <david.faust@oracle.com>,
	"Yonghong Song" <yonghong.song@linux.dev>
Subject: Re: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
Date: Thu, 18 Jun 2026 00:46:50 -0400	[thread overview]
Message-ID: <DJBWI249TH74.C8BAB4SRRTXB@etsalapatis.com> (raw)
In-Reply-To: <20260618005731.273181-2-vineet.gupta@linux.dev>

On Wed Jun 17, 2026 at 8:57 PM EDT, Vineet Gupta wrote:
> From: Alan Maguire <alan.maguire@oracle.com>
>
> A BTF_KIND_DECL_TAG with a non-negative component_idx applies to a
> specific function parameter (or struct/union member), not to the
> function itself. btf_loader.c however attached every decl tag to the
> type named by btf_type->type, so parameter decl tags were recorded on
> the function rather than on the parameter, and pfunct never printed
> them with the parameter.
>
> Resolve a non-negative component_idx to the corresponding parameter via
> new helpers ftype__parameter()/function__parameter(), and attach the
> tag there. Teach the pretty printer to emit a parameter's attributes by
> factoring the function-level attribute loop into tag__attributes_fprintf()
> and calling it from ftype__fprintf_parms() for each parameter.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>

With one nit:

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>

(Also feel free to keep the tags for the other 3 patches since the 
changes are minimal).

</SNIP>

> +	if (component_idx >= 0) {
> +		struct tag *func_tag = cu__function(cu, tp->type);
> +
> +		if (func_tag != NULL) {
> +			tag = function__parameter(tag__function(func_tag), cu,
> +						  component_idx);
> +			if (tag == NULL) {
> +				fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n",
> +					component_idx, tp->type);
> +				return 0;
> +			}
> +		}
> +	}
> +
> +	if (tag == NULL && component_idx < 0)
>  		tag = cu__function(cu, tp->type);

Nit, I think this can be simplified as follows:

tag = cu__function(cu, tp->type);
if (component_idx >= 0 && tag != NULL) {
	tag = function__parameter(tag__function(tag), cu, component_idx);
	if (tag == NULL) {
		fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n",
			component_idx, tp->type);
		return 0;
	}
}

<SNIP>

  reply	other threads:[~2026-06-18  4:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18  0:57 [PAHOLE v5 0/5] support for DW_TAG_GNU_annotation and fixes Vineet Gupta
2026-06-18  0:57 ` [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters Vineet Gupta
2026-06-18  4:46   ` Emil Tsalapatis [this message]
2026-06-18  0:57 ` [PAHOLE v5 2/5] dwarf_loader: Extract die__add_btf_type_tag() helper [NFC] Vineet Gupta
2026-06-18  0:57 ` [PAHOLE v5 3/5] dwarf_loader: Add support for DW_TAG_GNU_annotation Vineet Gupta
2026-06-18  0:57 ` [PAHOLE v5 4/5] tests: Support GCC in pfunct-btf-decl-tags test Vineet Gupta
2026-06-18  0:57 ` [PAHOLE v5 5/5] tests: Add btf_type_tag ordering test Vineet Gupta
2026-06-18  4:47   ` Emil Tsalapatis

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=DJBWI249TH74.C8BAB4SRRTXB@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=david.faust@oracle.com \
    --cc=dwarves@vger.kernel.org \
    --cc=jose.marchesi@oracle.com \
    --cc=vineet.gupta@linux.dev \
    --cc=yonghong.song@linux.dev \
    /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