From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nTscGssVAWsjKiYAWB0awg (envelope-from ) for ; Fri, 20 Nov 2026 22:53:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1795233227; bh=UEU4AmDgtZy/VrBLKCUyfveqEmj5EiPI0aKVFTdOBto=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XI1wVFCiM2tAidaBIb83GqmFpsMkY5HoTitIE/nRcvlB/lvpf89QOq1dp/OsJU/qQ fCCtM8HF4gcVus2rGWpeHF23577iD9vG8+kJEuKJAf8vr3ciKCW1F6mib9Upp0aW1v IcLfXX6eSD0dcn+GWKHECjvLl2lhOkM7Po6QVqDE= Received: by simark.ca (Postfix, from userid 112) id 4BBED1E0CE; Fri, 20 Nov 2026 22:53:47 -0500 (EST) 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 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=OZ1N+Vi+; dkim-atps=neutral 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 7438B1E052 for ; Fri, 20 Nov 2026 22:53:46 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 461CD4BCA406 for ; Sat, 21 Nov 2026 03:53:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 461CD4BCA406 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=OZ1N+Vi+ Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 78A004BCA2CC for ; Sat, 21 Nov 2026 03:53:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78A004BCA2CC 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 78A004BCA2CC 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=1795233199; cv=none; b=S5JVG80AG6LIx939MlvBbAZIdx2UdGrW7JzhuIczWldm981+vR0F1/LKrmn0A647SHHUy78ZhaBlM77R4OetYKGPtZMNxLW+GWvwr9Uaeq1nUFgAY4qH+Frk4dcUVJGirx3CHwJZduGKNujwjjb1dautR2oZlac2FQnOaUygQIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795233199; c=relaxed/simple; bh=UEU4AmDgtZy/VrBLKCUyfveqEmj5EiPI0aKVFTdOBto=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=KosMdO3/DO13Q7qaLYeFx2aEwNJhnTG7UtWZZGYhU7hvnPNEbF1MQcOrT2UQ2al9Z8RG6ZcZc2INnAXoDXeUN7z0MwU2wgUEE0xsDzYp1wGEy0WHGYblXDAl8wPBw9i1JY+LjX6WnQ0mbd18pZfeZPi5Ans7W5IZnSTMilMvGMQ= 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=OZ1N+Vi+ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78A004BCA2CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1795233198; bh=UEU4AmDgtZy/VrBLKCUyfveqEmj5EiPI0aKVFTdOBto=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OZ1N+Vi+MsguHUT+TLp+/kUYgNh2lZlw2F3ktorqBV8zMKwDFqVkMvdTXe9tO4YX5 yPVK+bGkEaqutL97qvS6NKRRsQD0P0s2bD2orRWuR5gwwPFPV1j1MM/a0WQF2LLaSz FoJ+WXzihozPUq5OGMRdc9jDEWv36SV3kyosmQ58= Received: by simark.ca (Postfix) id 3C17B1E052; Fri, 20 Nov 2026 22:53:17 -0500 (EST) Message-ID: <111d5ee6-2113-408b-8880-e73f2cdf0865@simark.ca> Date: Fri, 20 Nov 2026 22:53:16 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/symtab] Fall back to symtabs when the quick lookup misses To: Tom Tromey , Andrew Burgess Cc: Sendao Yan , gdb-patches@sourceware.org References: <20261120091803.89033-1-yansendao@126.com> <87bj7jros1.fsf@tromey.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87bj7jros1.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 11/20/26 7:50 PM, Tom Tromey wrote: >>>>>> "Andrew" == Andrew Burgess writes: > >>> + /* The cooked index does not necessarily contain every symbol that >>> + the expanded symtabs do. In particular, GCC emits a DWARF5 >>> + DW_TAG_variable for a static constexpr member using the DWARF >>> + spelling of the enclosing template arguments (e.g. >>> + std::ratio<1, 1>), while the C++ expression evaluator looks the >>> + member up using the canonical spelling (std::ratio<1l, 1l>), so >>> + the quick lookup misses it. Fall back to walking the symtabs, >>> + which was the behaviour before commit 86ac8c546235. >>> + >>> + PR symtab/33533. */ >>> + result = lookup_symbol_in_objfile_symtabs (objfile, block_index, >>> + name, domain); > > I don't think we want to go back to doing this. I hate to NAK a patch > but I think I will have to for this one. > > Andrew> My concern here is that if you *rely* on finding symbols in the expanded > Andrew> symtabs, then the lookup only works if something else first expands the > Andrew> symtab. This means we have random bugs where things don't work, then > Andrew> they'll suddenly start working (once the symtab has expanded). > > ... and this is why. This was basically the reason for commit > 86ac8c546235. > > I think the fix has to involve the lookup succeeding in the cooked > index. > > One question I have is why the name isn't canonicalized in the cooked > index, or to put it another way, why the C++ expression lookup and the > cooked index disagree -- since the idea behind canonicalization is that > there's a single spelling. I don't know the whole story behind this particular bug, but the std::ratio<1, 1> vs std::ratio<1l, 1l> thing is: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932 Strictly speaking, S<1> and S<1l> mean two different types. One has an "int" template parameter and the other a "long int" template parameter. I don't think it would make sense for them to canonicalize to the same thing, as (1) the conversion would be lossy and (2) the type names would become ambiguous. I think that what we want is... more approximate/fuzzy matching. To illustrate the problem again, using the type from the test: template struct S {}; S<1> s; - gcc does not put the integer suffix, so gives it DW_AT_name "S<1>" - clang puts the integer suffix, so gives it DW_AT_name "S<1L>" So the cooked index contains either "S<1>" or "S<1L>", depending on the compiler. Knowing this, we want lookups of either "S<1>" or "S<1L>" to work, because they are both legitimate queries. How do we achieve that? It does sound tempting to just canonicalize everything to "S<1>" (i.e. drop the suffixes), but then what if you have both "S<1>" and "S<1L>" in your program, how do you differentiate them? Perhaps it's fine for the index to store "simplified" names that don't include the suffixes, but I wouldn't call that a "canonical" name. If the program contains both "S<1>" and "S<1L>", then I'd want a lookup of "S<1>" to find the former and a lookup of "S<1L>" to find the latter. To achieve this, it sounds like we need some ranking system ("this match is better than this match"), a bit like when looking for the best function overload to call. We would therefore need a way to tell the two types apart. Admittedly, this is a bit of a corner case, but I believe that if we try to fix the problem generally, we'll end up with a more robust solution and less trouble in the long term. Regarding the DW_AT_names given by gcc: given that they lack potentially crucial information to know the type of the value parameters, maybe we should consider rebuilding the names from the DW_TAG_template_value_parameter DIEs. Those DIEs point to the exact type of each parameter, so we could reconstruct "S<1L>". I think the path already exists in the DWARF reader, we just don't take it because it is more expensive and we trust that DW_AT_name is correct. Simon