From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9djGN5NqqWowyg4AWB0awg (envelope-from ) for ; Tue, 15 Sep 2026 11:56:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1789487763; bh=of/finoVMeO1qFm7E5uMeu9BSqctb0OHjxhZY313ONw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=f+Uyzk5swamZq83PLgdCBugmLFLh1xV8VqHx4qxCc70SEHKQwiuBbBJbyzhQsISP3 1g5uU9sVc/xB5D/QTQnIFK6fQY40g00niL6P/0VEg6C6z1dGZZiCXWoKm+mqbirKyx UDJnq6ZC2zm/l91Q9Xb7vZqx5Xus/rSryglnovDY= Received: by simark.ca (Postfix, from userid 112) id CD0151E01F; Tue, 15 Sep 2026 11:56:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=UgrVq3rc; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5E98F1E01F for ; Tue, 15 Sep 2026 11:56:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8FB44BA902D for ; Tue, 15 Sep 2026 15:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8FB44BA902D Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=UgrVq3rc Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 730444B9DB6B for ; Tue, 15 Sep 2026 15:55:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 730444B9DB6B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 730444B9DB6B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789487738; cv=none; b=sOtN6evVLraUkYr5qCLtLz/ilMHZno+5g9D+x2Kr6kXC9bRol7kNtUqy9hW8vboXVWMTqs/SK63ULwugItADEvhW6lGH1/ekw6OThC90h0pUpYBlCu5a3xd24HV5G1Y205dHkjW9E0uvGseb4kKlq7Jad9HntQwZAn06CloG1R0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789487738; c=relaxed/simple; bh=of/finoVMeO1qFm7E5uMeu9BSqctb0OHjxhZY313ONw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=Cj5GwYEEGRcWkd5IUB5gXofXrgbVBsX1VWFCIc+kW96XEHDjpmOj+LwOqSYa247PFsKMxHEOpEHWZ/9u7r5xfJu7pSxINOp6TvOAxv8WSk4Gm5fBm+ulp+m72+VVgZJGPsUwicuZtn6t2Qv7gayIRmatjjPuPDBtxppSgZPsS14= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=UgrVq3rc DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 730444B9DB6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1789487737; bh=of/finoVMeO1qFm7E5uMeu9BSqctb0OHjxhZY313ONw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=UgrVq3rcClIZv9l9GX+HmEyRlEJLzyJuLIMnCVhUZa0YllWEfQk2fn2MLQBskIC+C 1vJYose+wwrzU1HpDS0GNKia320PcJi7EF/W4LXsfi3rkHjyfmRLaM7tDw+VyZLrTO aD2xqvZfBkaV/8qlbXUINDLG05Lm5d5mZJbj5K14= Received: by simark.ca (Postfix) id 9B41E1E01F; Tue, 15 Sep 2026 11:55:36 -0400 (EDT) Message-ID: <8ff7fcd2-f79c-48fc-9730-fbaf4dc17ec3@simark.ca> Date: Tue, 15 Sep 2026 11:55:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv3] gdb: resolve class name via DW_AT_signature in cooked index To: Tom Tromey , Andrew Burgess Cc: gdb-patches@sourceware.org References: <295672ce0ea0bf20911fbbc997f38fe9f62b19be.1787952498.git.aburgess@redhat.com> <897f5eb957bdfd90cd3fd5efa662021ed5c2aef2.1788269262.git.aburgess@redhat.com> <1a67b29f-e2f1-480a-ae2b-e0d0d5acfdca@simark.ca> <874ifvy4u7.fsf@tromey.com> <87ecewc6gn.fsf@redhat.com> <875x06dd6f.fsf@redhat.com> <87y0d2v9rt.fsf@tromey.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <87y0d2v9rt.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2026-09-15 11:01, Tom Tromey wrote: >>>>>> "Andrew" == Andrew Burgess 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