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

Simon Marchi simark@simark.ca
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:

http://wiki.dwarfstd.org/index.php?title=Best_Practices#Names_of_Program_Entities

    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
    compiler.

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
string:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845#c8

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

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932

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

https://inbox.sourceware.org/gdb/CAATAM3ED7B3wEJFmaZA_MaOtN5EGKSGFmusAf-Mg5hX35D2r6A@mail.gmail.com/

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

https://lists.llvm.org/pipermail/llvm-dev/2018-March/121541.html

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.

Simon



More information about the Gdb mailing list