From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv3] gdb: resolve class name via DW_AT_signature in cooked index
Date: Tue, 15 Sep 2026 11:55:36 -0400 [thread overview]
Message-ID: <8ff7fcd2-f79c-48fc-9730-fbaf4dc17ec3@simark.ca> (raw)
In-Reply-To: <87y0d2v9rt.fsf@tromey.com>
On 2026-09-15 11:01, Tom Tromey wrote:
>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
>>> We would have to delete the name-less entries, and any child
>>> entry that refers to them, not sure how to do that efficiently though.
>
> Andrew> This is the problem I'm currently trying to solve.
>
> Andrew> The problem with this approach is that the parent might be from another
> Andrew> shard, potentially resolved due to the IS_PARENT_DEFERRED flag from the
> Andrew> parent map. The race is on the read of the parent's name field, the
> Andrew> parent might appear nameless, but it might in fact be the case that the
> Andrew> name hasn't been assigned yet.
>
> Andrew> The other possibility is that, because this is an error case, we could
> Andrew> have a serial action that cleans up the mess, deleting child entries
> Andrew> with nameless parents. This would be done in
> Andrew> cooked_index::set_contents, as part of this code:
>
> Right now your patch is fixing up these entries in parallel, in each
> shard. But if this is uncommon enough, it could be done in
> cooked_index::set_contents instead, say when setting up the finalizer
> tasks:
>
> for (auto &shard : m_shards)
> {
> auto this_shard = shard.get ();
> const parent_map_map *parent_maps = m_state->get_parent_map_map ();
> ... signature->entry lookup here
>
> Then entries could be filtered out in cooked_index_shard::finalize if
> they have a "bad" parent somewhere in their "parent" chain.
Having a bad parent is rare, that would only happen when some
(nameless) type has a DW_AT_signature and the matching type unit can't
be found. That would be a buggy producer that "forgets" to add the
necessary type units.
But the basic case where the name fixup is needed isn't an error case,
it's just what happens when using clang with -fdebug-types-section,
since structures/classes are nameless:
0x0000099e: DW_TAG_structure_type
DW_AT_declaration [DW_FORM_flag_present] (true)
DW_AT_signature [DW_FORM_ref_sig8] (0xdf1329ababfff8ca)
So I suppose you'll get one fixup to do per structure/class type.
Doing the fixups in parallel is easy, since it's just looking up the
signature -> maps, and the "finalize" step already exists, so why not.
>
> I'm not sure if this would work or not. TBH I find all this stuff in
> DWARF pretty maddening and also difficult to reason about. Like, even
> constructing the case you are talking about seems very tricky, seeing
> that it has to involve type signatures and somehow also cross-CU parent
> references.
>
> A different option might be to ignore such entries at lookup time. That
> is, let the child entries stay in the vector and just skip them in the
> relevant lookup loops. My intuition generally is that DWARF reading is
> slow and user-visible, as is CU expansion -- but the lookups themselves
> are not.
>
> This would probably just mean touching the index writers and
> cooked_index_functions::search. Perhaps the bad entries themselves (an
> entry with a signature that couldn't be found) could simply not appear
> in the shard vector, to avoid problems with their anonymity.
>
> In cooked_index_functions::search you could just stick a check here:
>
> if (!entry->matches (search_flags)
> || !entry->matches (domain))
> continue;
>
> Like "entry->valid () || ..."
This was our earlier suggestion. Leave the name nullptr (or set a flag,
whatever), marking them as invalid. When you need to compute the full
name of an entry, you walk up the parent chain. If one of those parents
is invalid, bail out. You can't correctly an entry's full name if the
name of a parent is missing, as simple as that. And then you have to
handle invalid entries in a few other locations (like
cooked_index_functions::search and the index writers, as you said), but
it shouldn't be too bad. That sounds simpler than trying to remove the
entries.
Simon
next prev parent reply other threads:[~2026-09-15 15:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 10:03 [PATCH] [GDB 18] " Andrew Burgess
2026-08-21 17:07 ` Tom Tromey
2026-08-28 21:30 ` [PATCHv2] " Andrew Burgess
2026-09-01 13:31 ` [PATCHv3] " Andrew Burgess
2026-09-10 16:11 ` Simon Marchi
2026-09-11 19:18 ` Tom Tromey
2026-09-12 2:06 ` Simon Marchi
2026-09-14 13:23 ` Andrew Burgess
2026-09-14 14:57 ` Simon Marchi
2026-09-14 15:38 ` Tom Tromey
2026-09-15 10:25 ` Andrew Burgess
2026-09-15 15:01 ` Tom Tromey
2026-09-15 15:55 ` Simon Marchi [this message]
2026-09-15 17:21 ` Simon Marchi
2026-09-14 15:36 ` Tom Tromey
2026-09-10 16:18 ` Simon Marchi
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=8ff7fcd2-f79c-48fc-9730-fbaf4dc17ec3@simark.ca \
--to=simark@simark.ca \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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