From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GQfjB0LaAmtjXywAWB0awg (envelope-from ) for ; Sun, 22 Nov 2026 07:04:18 -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=fwf64DF7; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1D0051E09B; Sun, 22 Nov 2026 07:04:18 -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 [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 4AB161E09B for ; Sun, 22 Nov 2026 07:04:17 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70D9142A80DC for ; Sun, 22 Nov 2026 12:04:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70D9142A80DC 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=fwf64DF7 Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.9]) by sourceware.org (Postfix) with ESMTPS id 5F62F42A949C for ; Sun, 22 Nov 2026 12:03:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F62F42A949C 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 5F62F42A949C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=117.135.210.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795349031; cv=none; b=xzF4cvI10WyifblXkYlSVD6/rPjqzY9wWwEZ8nHxXPS3Dp3iekNBz4fuqmAXfhqZdf09VdJDx41ALJewMhN8s3+AYGuVx/IY1FcpIYJ9ABeTQn/6k07tglPkeWseFPfB89lk7RNTeuSA7a/jsvC3gm8R+LyrppXX7gyKb/6P5pw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795349031; c=relaxed/simple; bh=+sIN6AK8Wfe/xZnZSRLPoVJ6+aJl+hgjcDWytXnCemg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XvTCho4QZQRp0IwYVDbmgs7adPgTy7cFmtAGJsXUjULZOsRWo3XmnrlVPVE/YmmLnnmTELjPVQxtA9A41IaajtFWKxhpLdDoEH5+3cHlkFIbwak+SOKzI+RmgkeAZVU+4F9iGJ97yPJPwGLGdrGDs0gmR5mkMEjrKvT64EWUJfQ= 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=fwf64DF7 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F62F42A949C 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=I/ tguCxYEj9XFMvQ9N8k/uZL4kDmc7mR3pExtWMDa3U=; b=fwf64DF7L4Dn6sP7YS KNYKn/ZKP1lSlY5h3kCqv5aGAHWmpY0ImzIalRipx0rpvQmFywgCJccsa16F0JRi ZQL0sjNh/biJjX4yD/lN+hpbGoz8SOXG6gSh92iTeW3QoDChoPEId7C1kiSDOcyz w71ZpsD9He2/qObEeXDY9uO4c= Received: from ubuntu-2204.. (unknown []) by gzsmtp3 (Coremail) with SMTP id PikvCgDnF+8D2gJrLJmqDw--.48949S2; Sun, 22 Nov 2026 20:03:16 +0800 (CST) From: Sendao Yan To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess , Keith Seitz , Simon Marchi , yansendao@126.com Subject: [PATCH v3 0/1] [gdb/symtab] Add canonical-name aliases for C++ template static members Date: Sun, 22 Nov 2026 20:03:11 +0800 Message-Id: <20261122120312.52699-1-yansendao@126.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <874idarvrz.fsf@tromey.com> References: <874idarvrz.fsf@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: PikvCgDnF+8D2gJrLJmqDw--.48949S2 X-Coremail-Antispam: 1Uf129KBjvJXoW3JFyxJrykAry8GFy8JF18Krg_yoW7GF45pa yfKFnxAF4kGFyI9w17J3W7Jryfuw4fG3yUArWkGrWxAasIgFyUJFyFqFWayFW5G3y0qa4a qa1Fq34DuFn8ZFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zE_Ma-UUUUU= X-CM-SenderInfo: 51dq2vpqgd0qqrswhudrp/xtbBrAQTJWsC2gRhfAAA30 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 v3 of the fix for PR symtab/33533 (GCC PR 128817), where the libstdc++ chrono pretty-printer reports a static constexpr member as . 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 v3 does: for a C++ static data member, the cooked index contains the DW_AT_name spelling (with GCC, S<1>::v) and a separate entry for the linkage name. v3 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, which excludes function-local statics. 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. 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. The aliases are written to a saved .gdb_index: 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. Because the alias is not IS_SYNTHESIZED, it is also written by save gdb-index -dwarf-5 and survives a .debug_names reload. 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: - new test gdb.cp/static-const-template.exp: 18 PASS; it checks the long member, the canonical spelling, that T<1> (int) and T<1L> (long) remain distinct (whatis reports const int vs const long), a member of a template nested in a namespace, that the canonical spellings survive saving and reloading a .gdb_index, and that the alias is emitted in a DWARF-5 .debug_names index; - GCC libstdc++-prettyprinters/chrono.cc: 54/54 PASS, including -flto; - gdb.cp/static-const-template.exp, gdb.dwarf2/static-const-member.exp, gdb.dwarf2/forward-spec-inter-cu.exp, gdb.cp/m-static.exp, gdb.cp/namespace.exp and gdb.base/condbreak-multi-context.exp: 244 PASS, 0 FAIL; - gdb.dwarf2/debug-names*.exp: 27 PASS, 0 FAIL; - full gdb.cp suite: 8779 PASS and 70 failures, all in gdb.cp/step-and-next-inline.exp. Unpatched gdb 16.3 fails the same way, so this is a testsuite/compiler environment issue. Sendao Yan (1): [gdb/symtab] Add canonical-name aliases for C++ template static members gdb/cp-support.c | 40 +++++- 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 | 124 ++++++++++++++++++ gdb/testsuite/gdb.cp/static-const-template.cc | 58 ++++++++ .../gdb.cp/static-const-template.exp | 118 +++++++++++++++++ 7 files changed, 365 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