[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2022-10-21 Thread tromey at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #10 from Tom Tromey  ---
See also bug #49130 and bug #49537, which we filed when
gdb hit these same problems.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2021-04-22 Thread robert at ocallahan dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #9 from robert at ocallahan dot org  
---
That makes sense ... well, except implementing a full C++ parser and
reserializer is horrific.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2021-04-22 Thread tromey at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #8 from Tom Tromey  ---
(In reply to rob...@ocallahan.org from comment #7)
> So gdb reads DW_AT_name "func", parses it, reserializes it to
> "func", and uses that?

Yeah.  (Actually it's even worse than that, because at least one
compiler doesn't emit the template parameters in the name, so
in that case gdb will read the children of the DIE to try to
construct this form.)

I think the reasoning behind the canonicalization is two-fold.
First, I think we tried to get g++ changed, back in the day,
without success.

Second, gdb has to canonicalize user input anyway, so that
things like "print func(3)" or "break func"
work.  And once you have a canonicalizer it is simpler to just
use it to work around the problem.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2021-04-22 Thread robert at ocallahan dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #7 from robert at ocallahan dot org  
---
So gdb reads DW_AT_name "func", parses it, reserializes it to
"func", and uses that?

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2021-04-22 Thread tromey at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

Tom Tromey  changed:

   What|Removed |Added

 CC||tromey at gcc dot gnu.org

--- Comment #6 from Tom Tromey  ---
gdb does this canonicalization precisely because the form
in the DWARF cannot be relied upon.
It would be great to remove this, because it is expensive.

One idea for a migration route would be for g++ to promise
to emit the same form that the demangler emits; then
add an attribute to the comp-unit DIE saying that the names
have been canonicalized.  (Or, I suppose gdb could use
producer sniffing; but I'd rather avoid that as much as possible.)

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2020-04-29 Thread robert at ocallahan dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #5 from robert at ocallahan dot org  
---
We do our best to consume what g++ produces, but in the situation of comment #1
that is difficult. Whether or not it's "correct DWARF" is really irrelevant;
not matching the demangler causes real problems.

Thanks for the link to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932. That
is very similar to the problem I'm facing. No strategy was decided on there,
but it seems to me that matching the demanged name would be a clear step in the
right direction. I can't see how it could *hurt*.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2020-04-29 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #4 from Andrew Pinski  ---
See also PR 81932 where we talked about 2 and 2u

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2020-04-29 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #3 from Andrew Pinski  ---
But that is just best practices, that does not mean an consumer of the dwarf
does not need to consume slightly different but still correct dwarf code.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2020-04-29 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #2 from Andrew Pinski  ---
Hmm from http://wiki.dwarfstd.org/index.php?title=Best_Practices
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.

[Bug c++/94845] DWARF function name doesn't match demangled name in base type template parameters

2020-04-29 Thread robert at ocallahan dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94845

--- Comment #1 from robert at ocallahan dot org  
---
One case where this causes problems is implementing a debugger where you want
to be able to evaluate expressions containing type names. Type names containing
template type parameters that are base types need to be normalized to match the
type names in the debuginfo. g++ requires us to normalize those type names in a
way that's different from the C++ demangler and from clang++.