From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yb37N3igA2sAES4AWB0awg (envelope-from ) for ; Sun, 22 Nov 2026 21:10:00 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=dxF260xe; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E20151E167; Sun, 22 Nov 2026 21:10:00 -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,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=unavailable 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 3C2231E023 for ; Sun, 22 Nov 2026 21:10:00 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3FAF543BBA36 for ; Mon, 23 Nov 2026 02:09:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FAF543BBA36 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=dxF260xe Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.9]) by sourceware.org (Postfix) with ESMTPS id 53AEE43CA4F7 for ; Mon, 23 Nov 2026 02:09:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53AEE43CA4F7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=126.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 53AEE43CA4F7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=220.197.31.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795399770; cv=none; b=w+IaOeKC3JPoiEr4e+KPSV8nU+Xgt5bCRd7jfayYmHpqz5x/RfEEOK8rmPir/Ued6yXvA5iT7v7WWjvuEoEOZJWz+ALuS0UNDfw0DGuuMIpYQeFAGf/1ggsUoDQpH4EL7/lRcwDFX4QXpEiXA515AEeaD0M0O/NeH7zuqNm2KPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795399770; c=relaxed/simple; bh=Z51dvLVnvJ9JLvJjOMP4HbrBPyUtWDSjQbXiywG8KqQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=dTqowIFodrb8bzQkgP9v2eOLeahcS2plte7SJn0u4e5rij9zIDkbxtG3EaYRDjvYZKZu1Ox9LOKIlzdQkPOYTJS471ww+Hw1ZkOGmNkVM2Lh7JmNhH/S63mwGvQ3Q8R9vEibS9lEMBGlCSFgwTfEf8lyj0b5Ws8+fRapmNcaMV4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=dxF260xe DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53AEE43CA4F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=1d B9B2xLtr25bfUp1UzUifHA3wpN2OkvYIWzUX4D+7g=; b=dxF260xe9JWGTIFwLZ LBhsTJyX+oUDQKlgK8YBljkX29LTusPYR6gY34Umu+fJ9zbjcJWN5CvbGatBB/UI DKFVZ96dS1OWiw5rtmcLKUirfaiF0stW2qnKlyG2Zw8ida9ynrKQmcVpTdg+fQbP WZtUXLyESB6TRdJOMkpj5GXEg= Received: from ubuntu-2204.. (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wD3t14+oANrE5tHBA--.60677S2; Mon, 23 Nov 2026 10:09:03 +0800 (CST) From: Sendao Yan To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess , Keith Seitz , Simon Marchi , yansendao@126.com Subject: [PATCH v4 0/1] [gdb/symtab] Add canonical-name aliases for C++ template static members Date: Mon, 23 Nov 2026 10:09:00 +0800 Message-Id: <20261123020901.2794477-1-yansendao@126.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261122120312.52699-1-yansendao@126.com> References: <20261122120312.52699-1-yansendao@126.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wD3t14+oANrE5tHBA--.60677S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3AF4xGrW8GFy8KryxtFy7KFg_yoW7tw17pa 4fG3Z8CFWDGFsa9w17X3W8Jry3u3yfW3y5JF1kG34xAa1qgFyxJFyFqF4Yya45G340q34a qayYqw1DuFs8ZFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zMWlv9UUUUU= X-CM-SenderInfo: 51dq2vpqgd0qqrswhudrp/xtbBnh-S5GsDoD8KoQAA3r 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 Hi Tom, Simon, Andrew, Keith, This is v4 of the fix for PR symtab/33533 (GCC PR 128817). v3 was sent as [PATCH v3 0/1]; v4 supersedes it. I sent v4 before any human review of v3 because an automated review of v3 flagged that static member functions have the same spelling mismatch, and I confirmed that gdb.lookup_global_symbol("S<1l>::f") missed in v3. Sorry for the extra traffic; the delta is small and is the only change from v3. Changes since v3: - canonicalize_names() now also accepts DW_TAG_subprogram linkage entries, so static member functions get a canonical alias; - functions are demangled without DMGL_PARAMS, so the alias is S<1l>::f rather than S<1l>::f() and matches the parameter-stripped lookup name; - the test covers a class template with only a static member function (call and type lookup, .gdb_index reload, .debug_names emission). Everything else is unchanged from v3. Static member functions have the same DWARF/canonical mismatch as data members: the index has S<1>::f while the canonical lookup uses S<1l>::f. In v3 the expression forms happened to find the function through symtab expansion, but the quick index returned no symbol for gdb.lookup_global_symbol("S<1l>::f"). Tom, thanks for the pointer to PR 30023/32421 and -gsimple-template-names. I agree that rebuilding names from the DW_TAG_template_value_parameter DIEs is the right general direction, and that it is needed anyway for -gsimple-template-names. This version does not attempt that general reconstruction. It is a targeted fix for the quick-lookup miss, and it is not fuzzy matching (no strcmp_iw). What v4 does: for a C++ static data member or static member function, the cooked index contains the DW_AT_name spelling (with GCC, S<1>::v) and a separate entry for the linkage name. v4 adds one synthesized index entry whose name is the demangled linkage name (S<1l>::v), so the quick lookup finds the member without expanding symtabs. Each alias is derived from the symbol's own linkage name, so T<1> (int) and T<1L> (long) get different names and are not conflated. The alias is skipped when the entry built from DW_AT_name already has the canonical spelling, as with a clang-built binary. Only entries whose parent is a type or namespace are considered. Only Itanium-mangled (_Z) names with an I...E argument block are considered. The alias name is produced with the v3 demangler directly (still through gdb_demangle's crash handler), so index construction does not depend on the user's current demangle-style. The demangling and filtering live in cp-support.c, so the index code stays language-agnostic apart from the language_cplus check. The comparison uses the DWARF spelling of the DW_AT_name entry (a new FOR_DWARF_NAME flag) rather than its canonical spelling, because canonicalize_names runs per shard concurrently and a deferred parent can belong to a shard that has not been canonicalized yet. If the DW_AT_name entry is not adjacent (the index came from .debug_names), the alias is skipped rather than added without these checks. The aliases are written to a saved .gdb_index and .debug_names: the synthesized entry does not carry IS_LINKAGE or IS_SYNTHESIZED, and an entry is also added for the canonical spelling of each enclosing template scope (S<1l> for S<1l>::v), because the .gdb_index reader rebuilds qualified names from their components. Those scope entries are parentless and store the full prefix; they are only there for the reader, which re-splits the name itself. Why not reconstruct from the DIEs here: the cooked index is built by scanning raw DWARF with cutu_reader, before die_info trees are created; dwarf2_compute_name is only usable at symtab-expansion time. Rebuilding names in the indexer would mean parsing template parameter DIEs there and printing values with their C++ literal type (the current dwarf2_compute_name prints "1" rather than "1l"), which is the larger -gsimple-template-names work. I am happy to prototype that as a follow-up, but it is a much bigger change than this bug fix. If you would prefer to hold this patch until the general reconstruction lands, please say so; otherwise I think the guarded alias is a small fix that keeps the quick lookup authoritative and does not change lookup semantics. Testing (x86_64 and aarch64): - new test gdb.cp/static-const-template.exp: 22 PASS on both; it checks the long data member, the canonical spelling, that T<1> (int) and T<1L> (long) remain distinct, a member of a template nested in a namespace, a static member function found by its canonical spelling, saving and reloading a .gdb_index, and alias emission in a DWARF-5 .debug_names index; - GCC libstdc++-prettyprinters/chrono.cc: 54/54 PASS on x86_64, including -flto (the aarch64 build has no Python, so the pretty-printer test was not run there); - the six targeted .exp files: 248 PASS, 0 FAIL on both; - gdb.dwarf2/debug-names*.exp: 27 PASS, 0 FAIL on both; - full gdb.cp suite: x86_64 8783 PASS with 70 pre-existing failures in gdb.cp/step-and-next-inline.exp (also with unpatched gdb 16.3); aarch64 8914 PASS, 0 unexpected failures (2 unsupported because that build has no Python). Sendao Yan (1): [gdb/symtab] Add canonical-name aliases for C++ template static members gdb/cp-support.c | 41 +++++- gdb/cp-support.h | 12 +- gdb/dwarf2/cooked-index-entry.c | 14 +- gdb/dwarf2/cooked-index-entry.h | 9 ++ gdb/dwarf2/cooked-index-shard.c | 125 +++++++++++++++++ gdb/testsuite/gdb.cp/static-const-template.cc | 69 ++++++++++ .../gdb.cp/static-const-template.exp | 129 ++++++++++++++++++ 7 files changed, 389 insertions(+), 10 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/static-const-template.cc create mode 100644 gdb/testsuite/gdb.cp/static-const-template.exp -- 2.34.1