From: Vineet Gupta <vineet.gupta@linux.dev>
To: Alan Maguire <alan.maguire@oracle.com>, dwarves@vger.kernel.org
Cc: bpf@vger.kernel.org, Andrii Nakryiko <andrii@kernel.org>,
acme@kernel.org, jose.marchesi@oracle.com,
David Faust <david.faust@oracle.com>
Subject: Re: [PAHOLE Patch v2 2/2] Add support for DW_TAG_GNU_annotation
Date: Fri, 29 May 2026 18:31:10 -0700 [thread overview]
Message-ID: <767b89e4-baba-459d-80d2-2b6dd0c01a1b@linux.dev> (raw)
In-Reply-To: <7497e2f5-024b-41ff-8d9b-6e26bd46d954@linux.dev>
On 5/29/26 16:32, Vineet Gupta wrote:
> On 5/29/26 06:37, Alan Maguire wrote:
>> thanks for this Vineet! I'm building gcc-16 to manually test now but
>> I have a few
>> suggestions below in the meantime. Changes look good in CI [1]
>>
>> [1] https://github.com/alan-maguire/dwarves/actions/runs/26632028538
>
> Cool.
>>> +static int add_gnu_annotation_chain(Dwarf_Die *die, int component_idx,
>>> + struct conf_load *conf, struct list_head *head)
>>> +{
>>> + Dwarf_Attribute attr;
>>> + Dwarf_Die annot_die;
>>> +
>>> + if (dwarf_attr(die, DW_AT_GNU_annotation, &attr) == NULL ||
>>> + dwarf_formref_die(&attr, &annot_die) == NULL)
>>> + return 0;
>>> +
>>> + for (;;) {
>>> + if (dwarf_tag(&annot_die) != DW_TAG_GNU_annotation)
>>> + break;
>>> +
>>> + int ret = add_llvm_annotation(&annot_die, component_idx,
>>> conf, head);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + if (dwarf_attr(&annot_die, DW_AT_GNU_annotation, &attr) ==
>>> NULL ||
>>> + dwarf_formref_die(&attr, &annot_die) == NULL)
>>> + break;
>>> + }
>> the pointer tag handling below uses bookkeeping to track visited
>> dies; is there a need
>> for that here too? maybe a bit paranoid but perhaps we could haul the
>> loop detection
>> logic out and reuse in both places?
>
> Looking back now, the loop detection seems excessive. It was from the
> initial attempt to triage what seemed like an infinite loop in pahole
> but just turned out to be excessive match failures and bails and
> retries due to the gcc bug [1] which was generating variants of same
> core struct, causing failures pretty much everywhere due to the core
> struct being embedded all over. If we want to add loop detection that
> should be addon as it unconditional additional processing. I agree
> that even with that out of picture this function and the opencoded
> check_gnu_attr code seem to share a lot of structure - but they have
> their own *thing* to do and it would be unwieldy and awkward to factor
> out into a shared loop body with a call back or an additional arg to
> call add_llvm_annotation or die__add_btf_type_tag for either of those
> cases.
>
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125421
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125421>
>
>>> +check_gnu_attr:
>>> + /* Check for GCC-style DW_AT_GNU_annotation attribute */
>>> + if (tag != NULL ||
>>> + dwarf_attr(die, DW_AT_GNU_annotation, &attr) == NULL ||
>>> + dwarf_formref_die(&attr, &annot_die) == NULL)
>>> + goto out;
>>> +
>>> + Dwarf_Off visited[256];
>>> + int nr_visited = 0;
>>> +
>>> + for (;;) {
>>> + Dwarf_Off off = dwarf_dieoffset(&annot_die);
>>> + bool cycle = false;
>>> + int i;
>>> +
>>> + for (i = 0; i < nr_visited; i++) {
>>> + if (visited[i] == off) {
>>> + cycle = true;
>>> + break;
>>> + }
>>> + }
>>> + if (cycle || nr_visited >= (int)ARRAY_SIZE(visited))
>>> + break;
>>> + visited[nr_visited++] = off;
>
> I'm thinking of ripping this all out. Rest of dwarf machinery feels
> robust enough.
>
>>> +
>>> + if (dwarf_tag(&annot_die) != DW_TAG_GNU_annotation)
>>> + break;
>>> +
>>> + name = attr_string(&annot_die, DW_AT_name, conf);
>>> + if (strcmp(name, "btf_type_tag") != 0)
>>> + break;
>> should we "continue;" here instead; if we encounter a non-type tag
>> annotation
>> might we miss subsequent btf type tag annotations? might not be an
>> issue today
>> but might be more future-proof to continue here maybe?
>
> Good point. Will do.
Claude suggests break is the right thing to do for precisely the reason
you mention.
This code only handles DW_TAG_pointer_type DIEs which currently don't
expect non-type tag, and this pertains to a single chain it could point
to a potential issue as of now.
But up to you what you feel is better.
Thx,
-Vineet
next prev parent reply other threads:[~2026-05-30 1:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 22:36 [PAHOLE Patch v2 1/2] dwarf_loader: Extract die__add_btf_type_tag() helper [NFC] Vineet Gupta
2026-05-28 22:36 ` [PAHOLE Patch v2 2/2] Add support for DW_TAG_GNU_annotation Vineet Gupta
2026-05-29 13:37 ` Alan Maguire
2026-05-29 23:32 ` Vineet Gupta
2026-05-30 1:31 ` Vineet Gupta [this message]
2026-05-29 13:23 ` [PAHOLE Patch v2 1/2] dwarf_loader: Extract die__add_btf_type_tag() helper [NFC] Alan Maguire
2026-05-29 18:11 ` Vineet Gupta
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=767b89e4-baba-459d-80d2-2b6dd0c01a1b@linux.dev \
--to=vineet.gupta@linux.dev \
--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 \
/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