From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id PNmoMegytWqkFD0AWB0awg (envelope-from ) for ; Thu, 24 Sep 2026 10:25:44 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=ssoGtkvr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AC9BA1E01F; Thu, 24 Sep 2026 10:25:44 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 94B521E01F for ; Thu, 24 Sep 2026 10:25:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC1744BB58C7 for ; Thu, 24 Sep 2026 14:25:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC1744BB58C7 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=ssoGtkvr Received: from YT3PR01CU008.outbound.protection.outlook.com (mail-canadacentralazon11020088.outbound.protection.outlook.com [52.101.189.88]) by sourceware.org (Postfix) with ESMTPS id BB5D54BB589F for ; Thu, 24 Sep 2026 14:25:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB5D54BB589F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BB5D54BB589F Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=52.101.189.88 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790259905; cv=pass; b=qy8VcgNf8UR8cl2SsJuWcVKdkR2WRjGG0pi46P+OTaFmfhRCfVGVPD7nAVC8Pwi7p/l9Bb0rYUeAjT5LOAjSN5S9ilS7woJqcpGrJn1Du2qqPanIEffjXFvCjAFptVSjtuVBhiEp08Dg5SHUsV/XO9+2pOIENWUQ76h7YsF0TGY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790259905; c=relaxed/simple; bh=b3fv9y0RuXLDaPjupuwtDCf32BIB1RK3wNXMmObzD9c=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=BR9u4SB2yDGwsA1NIbRQ0S2hpcNF7aZQDAEtYP6onf3bpv9kzptH3K1kcg9Q2hTTwxeShrVhZ29TgWK/GJB1TWAP4e5osojq/Eb29pRp08PWpGaJr7QYEludZjMp6+qt5jkzz3qsyKigne3VzQ75hQVMQRcdsTk8C7RJCuYbuIE= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=selector1 header.b=ssoGtkvr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB5D54BB589F ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bq5vcdEzC1joOgDTf5GFjVuBPdSrfoKGhY8BrE5NKRX4uMZ8ag/KMbX4cilbsU2EzsozK5+QwpU/cR2hPKqRDDhsApTQ3965V0U5u3XbbWg0V/N7ikQMiHgUssPxdQNwXG41FUpVuS7EILmcdN5HMkHig8bGSPpAcks5qgnM+x3O7VcWQrnRhx8fErmhRHdnrq/2r9dilOKzvPtWxT6IFJ7wHRYZYMtVCp3oPWErUS/fWD0MY2vIrGxFQMO1CxW4IOpfdPgsGe5k042FMTf/yNMPHDTCpvyg0udYeerHhRntzEgEwqi5zuXA2XsFjKXCY7MBB0UVctCoD9QbxHAbig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ag60VjSV1rdNnMIkL0j/0KHh1TeWpliQyT++lFqQjZ4=; b=Cp/0EfE3eALMc0fAF5tLdt+i027o+U28ryioebc4cYUWrTY6Yd+oBti34Mr3YbFws2ayWIFCgbI9c8v6I/gsiK+mhtThKo6xTnxSYQ7FhgMgjYgPLOFsQ1mebi6UoBp0hGrjRz7JN3P7zemDTxWifZSQcTgLTKgCxNSnvIgP41kFrOWEpTq90/gtgsDNFILkeVoxk/RH/BRHQCKSWPvv8r/2e6kBm3ZRI59/BzEZL61vLHk0JpMyXLtyG2tGe47VbNflRpZUyO0JGWYY+diPb6I+/ZYg4o9YHZgzpBGtzfJ+v1k5ETQqcy/Y1JY2jkcs4+NrYSrckLPquQs5i89bJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ag60VjSV1rdNnMIkL0j/0KHh1TeWpliQyT++lFqQjZ4=; b=ssoGtkvrbVnlCj6zGyTsdWZRnjqYHyoaOWC67AZhYGR53fYFFZLepMo6cUOwJRs4IYqITr1vgZfFE+f6raMjkF+vomgQFnMc8patFOpjoptLxsmgbR7/+lwOor/5mhf63eS3O/yLN7gPGhB8q7s0df8mn6zpgX8RdWG2OsBS2Tx3XqNmImQBq0GG27Oc7BhWuRiSeGCHOYFx0gaiPw4tRGru9R7DfDyZCzO7CKJZO6iEf8v1nSzfnNiNJ4hcUSFP3p6ti5Davjd3v4CCvZIOqGs2VzYBVj7sOBnZLkHLWnBzdTS0QDDw40+vxmEmiNwjoQSwUlgfMgiGiVtJJ030Qw== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2c::6) by YT3PR01MB9595.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:8b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.14; Thu, 24 Sep 2026 14:25:01 +0000 Received: from YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM ([fe80::bbfa:179f:fdc8:b15d]) by YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM ([fe80::bbfa:179f:fdc8:b15d%7]) with mapi id 15.21.0451.014; Thu, 24 Sep 2026 14:25:01 +0000 Message-ID: <39aafeb0-9eb5-4862-bb6f-36b8173203b2@efficios.com> Date: Thu, 24 Sep 2026 10:24:59 -0400 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] gdb: split cooked index finalization into separate steps To: Andrew Burgess , gdb-patches@sourceware.org References: <20260924050002.1539783-2-simon.marchi@efficios.com> <877bkb2buz.fsf@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <877bkb2buz.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: YQBPR0101CA0130.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:5::33) To YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2c::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YQXPR01MB5418:EE_|YT3PR01MB9595:EE_ X-MS-Office365-Filtering-Correlation-Id: ca094857-3a70-418e-8fb9-08df1a479e62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|23010399003|376014|10067099003|56012099006|6133799003|22082099003|18002099003|4143699003|5023799004; X-Microsoft-Antispam-Message-Info: E8s1jPZCsLC1hhMGh+YIVwzzU/vqM4AMjxk+Ivq3kjX+wdwsPVOwtCq19e/zobxcOs6Gc6wXXf5nDJmyyLm9FENgh1V8AghF9bGstW5qJ+J92pH2iB4Hvel+SI41aoUhXWok/pqmWQzLomiBm0nsXxSHCcvhEdj6AzulwLOjEAg98q17HeQne/CUkROMnIOTp8b4CqiP+OnqB2G7T/7V7m/AAeST8pdlG6q6LCzGmmoDkD3+EiTUHrG9MoJnzfSFtc36yy+eM1Wj0U5rTyTA2JVFcp76lUYcWF0Sh6TDnLopsNZxbA8zSHxkCejrmR6hmHR1cEwZ4QX+mph690Oh4wNRedHcTMivNLDVNfjKk1wr5eS1Z18e+mORWEHzHUWaRET8Zy0iSNdU/uANyKOOr8KJEMmRwHsMXiSieHhT1aoQvXeU3OJfoRT2PmYpV/v6aSeiWq2Rzw8Ayq+jWqljwLeyiunEyfuOljcAe9kyiw9PYpzpBSN2fdBQPGc1wG82bE46LZ9Mz6jStDTsSb1HZTp5c+1X67Ct/SDNc05f+omzNGwI4oFY1JRsHrERC//n76Xj6Z1eSkZRDCEcypqLIbb9RFbb2V0ubIdGxzUE/WmAC4KO0/mODDpnINjhHHuPWd2Sg24yY8G2DtZCgubU+z9NyivX2xAo4AIElrzWqw8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(10067099003)(56012099006)(6133799003)(22082099003)(18002099003)(4143699003)(5023799004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UkNGLzl2cGVZV0xtc0k3dzZSRG1RQUlzL0Q0SUpaVE44R2YyaFBRWUFmYzFW?= =?utf-8?B?MHNWVVJyNmJHODdTa1lCMUtCbU92Mkx1YSsrT0pRR0tpb3hSV2YwYnB0TXE3?= =?utf-8?B?MFI3aHlWdDY1K1FzVktPcXZ0SW1FRlZkMU1tVDJWTzJFak1kN0JpWktpamhP?= =?utf-8?B?cHR6cm9VYVhjLzJ1NnZMMDdvZ1hzYmpQOGhWS0IwYnpoSW5PdjlXbkpnT2Zi?= =?utf-8?B?S0VjbGpQOGd1T1dGakFORzVnbDBSQTVFaVAxL2x0NWd1QU1aUlpCN3hDemNM?= =?utf-8?B?U21FRGpodEdBcjVUU0x5cUJ2NU91T0xoeFJ0WWtoL29PcFpzd2JYNUdUYlB5?= =?utf-8?B?NklrdTBQbDlrZEJpWmxjY0dtcy9FeURMK0pjUUo4UlVkYndFSnVMV2FrM2R1?= =?utf-8?B?QTJ4bWJ3blc2K0NudkIrbzlJVnExbk9KbmdZUi9UdThTSzJXRGc4QnRUdXVB?= =?utf-8?B?MFpuZGhnV0JpbGpSS3VCTC9hbVdIdEtReEJXckhCWGV5ck5KODh0a3haUm5Q?= =?utf-8?B?Y3FnaUs3czgxMFNiQldJZ2hXL3FmZkh0QktWSzFxWk0vNHp6OUtPRHErZDlZ?= =?utf-8?B?NXZrOVM3bGhQTzFkTEwrNXpPR3l6SGpMaWNSZGIrbURnbVF2SGlVWXBxSUtZ?= =?utf-8?B?OUV1eHZyTC9VQjhnL0x2QUVkWDZsdW00Vm9LSC82Z2dhN3RBQ0Fzb0VTVHNj?= =?utf-8?B?d3NIakRwSGdsVE1zRmVXWHdXQ0pPa29SbWZ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dUxUMTFNUjNqZWthQ0lyaDNveER4YUhZQVJ0YUpGT2t5?= =?utf-8?B?dmdpT0xISFA4TkpSUlN4Z0NlTXlzb1ZHKyt0UEV5TnlPUFNtVDJsQXFwYS9Y?= =?utf-8?B?dlV0OTdNRVVmczZEaWk2Q0RkblUyWHM3SGMrSmJQMUptVnQ5U1NuV0NOUERj?= =?utf-8?B?R0lLNHdHS1o1eXF2S2cxZUU2bk01bGZpalVscDJNMTdqYWo3bjZ2SzAvRlJ2?= =?utf-8?B?OVY4MTBVZ0s5aEROT09VTXFLODF5RmhSU2I3aTBoRy9SazJnbnR3eHFBNXY1?= =?utf-8?B?NmhYR2hyVkZXYU56RFFwSENlRmsvS2c4YWRScnVxZVF1L0hKYmUrNWVwUUli?= =?utf-8?B?RFlqOS9MVG91TUQrMVM4TWV6NkcxWTlGMkpiQlhMUU9paUkrZVo0Z1AyWkJw?= =?utf-8?B?d0VteTI4ZVVEdXRmSHdWNFdoSkNCdmcxSWcrU1hoWDNua0QxdE81UW5BYk5O?= =?utf-8?B?MFhHZUpHMDlkdGRYekRwdE9rMDR2RnUrbDJ4VGVTeWRMb0lrUHREL0twSk1M?= =?utf-8?B?amxQb1N4ZHFhelNMVXl3eUpOYUVmVE95NXNjZW1oNm1JN3J4Z1VQWFo5MXR6?= =?utf-8?B?VUJDSmN5Y3BIK1N4Y2JPdCszNEdva3JkVnI3elMwYlhqMkdkcG10bEhRMThH?= =?utf-8?B?N3FscklLZ1F1SWF0WWxqTEVabmdKemFrZXV5NitQcEJTNTlQcWlEUT09?= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca094857-3a70-418e-8fb9-08df1a479e62 X-MS-Exchange-CrossTenant-AuthSource: YQXPR01MB5418.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2026 14:25:01.4027 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T7EEmICA0zrPMESrqvQQljKEaqjTLCOYzua8Q7FNLnl5jVXV/tf+4k7OyCiYjYsVbAJ22urBfu0Kw/nwQL3dXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT3PR01MB9595 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 9/24/26 6:16 AM, Andrew Burgess wrote: > Simon Marchi writes: > >> This patch refactors the existing cooked index "finalize" step into >> multiple steps. This is a preparatory patch for the following patch, >> which will add some more steps. I believe that using this pattern will >> help keep the code readable and easy to understand, despite the >> increasing amount of work done. >> >> The following patch introduces a step that needs to run after the >> deferred parents have been resolved, but before the name >> canonicalization happens, so factor out the deferred parents code into a >> step of its own. >> >> The code that remains in cooked_index_shard::finalize is all about name >> canonicalization (if we consider the Ada stuff to be a special case of >> that), so rename that step to cooked_index_shard::canonicalize_names(). >> >> For clarity, move the "write to cache" code out of the "done" callback >> to make it clear that it is logically a separate step. >> >> So as of this patch, we have the steps: >> >> - resolve deferred parents >> - canonicalize names >> - write to cache >> >> The term "finalization" now refers to all these steps. Or, depending on >> your definition, it could refer to all but "write to cache", since the >> index reaches the FINALIZED state (i.e. becomes fully usable) just >> before that one. >> >> Here are the implementation details: >> >> - The first step is called by cooked_index::set_contents(), then each >> step is responsible for calling the next one (thus forming a chain), >> until we are done. >> >> - Steps that involve per-shard parallel processing use gdb::task_group, >> the "done" callback of the task_group starts the next task. >> >> A special case of that is: if some steps are able to detect ahead of >> time that it's unnecessary to run the step for a given shard, they >> can omit adding a task for that shard. >> >> An even more special case of that is: if no tasks are added to a task >> group, the "done" callback for that task group is invoked >> immediately when the group is started. This allows easily and >> cheaply skipping entire steps when they are not needed. >> >> This is used in this patch for the new "resolve deferred parents" >> step. Each shard records whether it has at least one deferred parent >> during the initial scan. If a shard has none (which is a common >> case), then cooked_index_shard::resolve_deferred_parents would >> iterate the index entries for nothing. The step therefore omits >> adding a task for that shard in that case. If no shards have any >> deferred parents that require resolving, we go directly to the next >> step with very little cost. >> >> During review, Claude pointed out that my change actually fixes a >> potential problem. The current code resolves the deferred parent of an >> entry in the same loop where it potentially calls "full_name" for that >> entry (to create the special Ada entries). "full_name" walks up the >> parent chain, and thus requires all grand-parents to be resolved. >> Depending on the order of DIEs in the file, it might not be true. >> Having the "resolve deferred parents" step run completely before the >> name canonicalization step avoids this. >> >> I built a gdb.dwarf2 test case around the DWARF structure it proposed to >> hit the bug. It is perhaps not something we expect from real-world >> producers, but it's also not completely unthinkable. It hits this >> assert when the patch is not applied: >> >> gdb/dwarf2/cooked-index-entry.h:217: internal-error: get_parent: Assertion `(flags & IS_PARENT_DEFERRED) == 0' failed. >> >> ... and passes with it. > > Simon, > > Thanks for doing this. My reworked series (unposted) had a patch just > like this, but your addition of the new test is a bonus I didn't have, > so I think yours is better. I only had one minor suggestion from my > take on this change, see below... > >> + >> +void >> +cooked_index_shard::canonicalize_names () >> { >> gdb::unordered_set> cooked_index_entry_name_ptr_hash, >> @@ -216,13 +236,6 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps) >> >> for (cooked_index_entry *entry : m_entries) >> { >> - if ((entry->flags & IS_PARENT_DEFERRED) != 0) >> - { >> - const cooked_index_entry *new_parent >> - = parent_maps->find (entry->get_deferred_parent ()); >> - entry->resolve_parent (new_parent); >> - } >> - > > I replaced this block with: > > /* Deferred parents should not reach this point. */ > gdb_assert ((entry->flags & IS_PARENT_DEFERRED) == 0); > > I think the assert is worth keeping. With that: > > Approved-By: Andrew Burgess Good idea, applied locally. Simon