Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi <simark@simark.ca>, Tom Tromey <tom@tromey.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:25:12 +0100	[thread overview]
Message-ID: <875x06dd6f.fsf@redhat.com> (raw)
In-Reply-To: <dd8656be-da3d-4353-8cdd-faf02a9becaf@simark.ca>

Simon Marchi <simark@simark.ca> writes:

> On 9/14/26 9:23 AM, Andrew Burgess wrote:
>>>> I would much prefer a new cooked_index_flag_enum value over allowing
>>>> NULL pointers.
>>>
>>> Why?  Just wondering.
>> 
>> Also, in this case, the point is that we end up creating the
>> cooked_index_entry before we know the name, so what value should the
>> name pointer hold?
>> 
>> My V1 patch tried to find the name before the entry was created, but Tom
>> correctly pointed out that this was not thread safe, and would fail to
>> find the name in some cases.
>> 
>> My V2 used the empty string in order to avoid NULL pointers, but empty
>> name strings cannot usually (outside of this patch) be created, and as
>> Simon pointed out, if these empty strings "escape" into the rest of GDB
>> then problems arise.
>> 
>> So V3 switched to NULL pointers as something that is fairly obviously an
>> "unset" string.
>> 
>> I haven't looked into it, but I'm sure I could add an enum flag, but
>> this would still leave the question of what value to give NAME until
>> it's actually filled in.
>
> That's why I was wondering, but really I am not opposed to a flag, I
> just wanted to know the rationale.  We have 1 bit free in
> cooked_index_flag, so it wouldn't take up any more space.  It's just
> that having a flag that says "this entry has no name and is therefore
> invalid" seems redundant with the name being nullptr.
>
> Instead of leaving them nullptr, another option would be delete those
> cooked_index_entries from the vectors, if we never plan to do anything
> with them.

This is what I'm doing in v4.  The entries all live on the obstack, so I
can just remove them from the vector without concern.  But ....

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

This is the problem I'm currently trying to solve.

I also reached the conclusion that deleting the child entries would be
too expensive, so my second plan was to just delete the parent pointer
from child entries if the parent is nameless.  This would leave the
child entries in a weird state, e.g. 'the_type::method' would appear in
the index as just 'method', but I think this would be fine.  This isn't
"normal" behaviour, and only triggers in the case where the parent's
name cannot be found.

The problem with this approach is that the parent might be from another
shard, potentially resolved due to the IS_PARENT_DEFERRED flag from the
parent map.  The race is on the read of the parent's name field, the
parent might appear nameless, but it might in fact be the case that the
name hasn't been assigned yet.

So the current idea I'm considering is leaving "nameless" entries
around, but giving them a non-empty name, something like
"__signature_0x..._not_found__".  This name would then show up in the
index, and a user could, in theory, say:

  (gdb) print __signature_0x..._not_found__::method

which seems weird, but remember, this really is an edge case, for when a
referenced signature isn't found.

The other possibility is that, because this is an error case, we could
have a serial action that cleans up the mess, deleting child entries
with nameless parents.  This would be done in
cooked_index::set_contents, as part of this code:

  gdb::task_group finalizers ([this] ()
  {
    // TODO: Fix up the state here.
    m_state->set (cooked_state::FINALIZED);
    m_state->write_to_cache (index_for_writing ());
    m_state->set (cooked_state::CACHE_DONE);
  });

The fix up would be cheap if there was nothing to do, which would be the
normal case, but in the error case, we'd search through and delete any
child with a nameless parent, and their children, and their children,
etc.  Or maybe just clear the parent pointer at this point?  I'm not
really sure yet.

Anyway, if you have any thoughts, I'd love to hear them.

Thanks,
Andrew


  parent reply	other threads:[~2026-09-15 10:25 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 [this message]
2026-09-15 15:01                 ` Tom Tromey
2026-09-15 15:55                   ` Simon Marchi
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=875x06dd6f.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    --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