[PATCH] [gdb/symtab] Fall back to symtabs when the quick lookup misses

Tom Tromey tom@tromey.com
Sat Nov 21 16:31:28 GMT 2026


>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Strictly speaking, S<1> and S<1l> mean two different types.  One has
Simon> an "int" template parameter and the other a "long int" template
Simon> parameter.  I don't think it would make sense for them to canonicalize
Simon> to the same thing, as (1) the conversion would be lossy and (2) the
Simon> type names would become ambiguous.  I think that what we want is... more
Simon> approximate/fuzzy matching.

I don't truly dislike fuzzy matching; but what I do strongly dislike is
strcmp_iw, which is basically C++-isms getting into the gdb core.

I'd prefer that the symbol tables be dumber and, if necessary, the logic
be pushed into the C++ parser or some other place where it doesn't
require the core of gdb to have language-specific treatment.

I tend to think that instead of "lookup", gdb would be better if access
to the symtabs looked more like iteration.  Then the C++ parser could do
whatever weird stuff it needs -- in the C++ support files.

This could maybe be done with some kind of callback thing instead.

This would solve the best_symbol thing as well.

Simon>  - gcc does not put the integer suffix, so gives it DW_AT_name "S<1>"
Simon>  - clang puts the integer suffix, so gives it DW_AT_name "S<1L>"

Simon> So the cooked index contains either "S<1>" or "S<1L>", depending on the
Simon> compiler.  Knowing this, we want lookups of either "S<1>" or "S<1L>" to
Simon> work, because they are both legitimate queries.  How do we achieve that?

Simon> It does sound tempting to just canonicalize everything to "S<1>" (i.e.
Simon> drop the suffixes), but then what if you have both "S<1>" and "S<1L>" in
Simon> your program, how do you differentiate them?  Perhaps it's fine for the
Simon> index to store "simplified" names that don't include the suffixes,
Simon> but I wouldn't call that a "canonical" name.

Yeah, that's a real problem.  I think you hit on a solution below.

Simon> Regarding the DW_AT_names given by gcc: given that they lack potentially
Simon> crucial information to know the type of the value parameters, maybe we
Simon> should consider rebuilding the names from the
Simon> DW_TAG_template_value_parameter DIEs.

We already need to do this due to -gsimple-template-names.  Relevant
bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=30023
https://sourceware.org/bugzilla/show_bug.cgi?id=32421

Tom


More information about the Gdb-patches mailing list