Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sendao Yan <yansendao@126.com>
To: gdb-patches@sourceware.org
Cc: tom@tromey.com, aburgess@redhat.com, keiths@redhat.com,
	simark@simark.ca,  yansendao@126.com
Subject: Re: [PATCH v2] [gdb/symtab] Add canonical-name aliases for C++ template static members
Date: Sat, 21 Nov 2026 23:07:06 +0800 (CST)	[thread overview]
Message-ID: <6B01B399.0DFCF8.05874@m16.mail.126.com> (raw)
In-Reply-To: <20261121145930.1048662-1-yansendao@126.com>

Hi Simon, Andrew, Tom, Keith,

Sorry for the delayed reply -- v2 was sent before I saw Simon's message,
and the cover text did not make it into the v2 email (git send-email sent
the patch file as the body).

Andrew asked why this cannot be fixed in the quick lookup path, and
whether a fallback bakes in a known limitation.  v2 answers that: the
quick lookup path can be fixed, and v2 does fix it there.  v1's symtab
fallback was not needed.  The root cause is that the cooked index only
contained the DWARF spelling (S<1>::v), while the lookup uses the
canonical spelling from the demangled linkage name (S<1l>::v).  The
lookup algorithm itself is fine; it misses because the index does not
contain the spelling being looked up.  v2 adds that spelling as a
synthesized cooked-index entry, so there is no reliance on expanded
symtabs and no known limitation to document.

Simon: you are right that S<1> and S<1L> are different types, and that a
plain alias would be wrong if both types exist.  v2 only adds the alias
for the DWARF spelling that lacks the integer suffix; I agree it needs to
be disambiguated.  Some options:

1. Only add the alias when no exact canonical entry for S<1L> exists in
   the index.  A real S<1L> entry then always wins; the alias is only a
   fallback for compilers that omit the suffix.  This is a small change,
   but not a general fuzzy match.

2. Reconstruct the type name from the DW_TAG_template_value_parameter
   DIEs using the parameter type's spelling, as you suggested.  The
   existing dwarf2_compute_name path does something similar for
   functions, but it prints the value without the integer suffix; we
   would need to print it using the C++ type spelling (S<1L>) and use
   that name for the class type.

3. Implement fuzzy matching with ranking in the index lookup.

I think (2) is the most robust.  Before I rework the patch: would you
prefer (2), or is a guarded (1) acceptable as a first step?  I can test
both with GCC- and clang-built binaries (including a program that
instantiates both S<1> and S<1L>).

For the other comments:
- Tom: v2 no longer touches lookup_symbol_in_objfile; the symtab fallback
  is gone.
- Andrew: `return -1` removed; no new NULL; `print s.v` is the actual
  regression test, and the alias lives in the cooked index, so it does
  not depend on symtab expansion.
- Keith: the canonical spelling comes from the demangled linkage name;
  GCC's DW_AT_name omits the integer suffix.

Thanks,
Sendao


      reply	other threads:[~2026-11-21 15:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  9:18 [PATCH] [gdb/symtab] Fall back to symtabs when the quick lookup misses Sendao Yan
2026-11-20 18:26 ` Andrew Burgess
2026-11-20 19:46   ` Keith Seitz
2026-11-21  0:50   ` Tom Tromey
2026-11-21  3:53     ` Simon Marchi
2026-11-21 16:31       ` Tom Tromey
2026-11-22 12:03         ` [PATCH v3 0/1] [gdb/symtab] Add canonical-name aliases for C++ template static members Sendao Yan
2026-11-22 12:03           ` [PATCH v3 1/1] " Sendao Yan
2026-11-23  2:09           ` [PATCH v4 0/1] " Sendao Yan
2026-11-23  2:09             ` [PATCH v4 1/1] " Sendao Yan
2026-11-21 14:59 ` [PATCH v2] " Sendao Yan
2026-11-21 15:07   ` Sendao Yan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6B01B399.0DFCF8.05874@m16.mail.126.com \
    --to=yansendao@126.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox