Decl/def matching with templates without template parameters in the DW_AT_name

Simon Marchi
Thu Jan 12 02:32:38 GMT 2023

> Yeah, this is a case where DWARF is like "here are some tools you
> could use to express some language features, have at!" and doesn't say
> "to describe this particular language feature you must use DWARF in
> this particular way"
I just found this:

    For template instantiations, the DW_AT_name attribute should contain
    both the source language name of the object and the template
    parameters that distinguish one instantiation from another. The
    resulting string should be in the natural form for the language, and
    should have a canonical representation (i.e., different producers
    should generate the same representation). For C++, the string should
    match that produced by the target platform's canonical demangler;
    spaces should only be inserted where syntactically required by the

Of course, it's not normative.  According to the wiki history, this
particular bit was added by Cary Coutant, in case you want to ask him
why it is considered best practice.

I Googled bits of the previous quote, and found this bug about template
string canonicalization, and not including template parameters in the

And this one, that sounds like the 2 vs 2u thing I talked about earler:

Ah, and the thread that was on the GDB list about that:

And the corresponding one on llvm-dev, to which you participated:

It's not all relevant, but I re-read those to remember what the trouble
with the name strings with template parameters was.

My thought on all this is that if the name strings with template
parameters are not reliable and take a lot of space, and the same
information is described in a more structured way (as DIEs), then it
makes sense to drop the parameters from the string.


More information about the Gdb mailing list