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

David Blaikie dblaikie@gmail.com
Wed Jan 18 22:01:35 GMT 2023


On Wed, Jan 11, 2023 at 5:46 PM Simon Marchi <simark@simark.ca> wrote:
> Digging in the history leads me to:
>
>   https://inbox.sourceware.org/gdb-patches/201007302017.41074.pedro@codesourcery.com/
>
> So RVCT, the RealView compiler.  I don't have access to that,
> unfortunately.  It seems obsolete, also.

Oh, that's satisfying/interesting to know - figured /someone/ had done
this before, judging by gdb's behavior.

> If you end up merging this, it will be interesting to run the full GDB
> testsuite against clang with that flag, it would cover a lot of things.

Oh, it's already in Clang, under `-gsimple-template-names`, I think
even Clang 15's functionality is well baked enough - I finished up the
work about a year ago now. Here's a very small example:
https://godbolt.org/z/r8zMf5qvr showing the shortened name in the
.debug_info, and in the .debug_gdb_pubnames (which ends up in the
index, which turns out was the bug I came across... filed here:
https://sourceware.org/bugzilla/show_bug.cgi?id=30023 )

As I mentioned, though, there's a bunch of cases where Clang doesn't
simplify names because they don't roundtrip well/DWARF is
lossy/problematic in some way in the way it describes the template
parameters. Some of the interesting (positive and negative/simplified
and unsimplified) test cases I encountered were:
https://github.com/llvm/llvm-project/blob/main/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
- this checks that I could easily rebuild the original name from
llvm-dwarfdump. So, things like templates with lambda parameters
aren't simplified because there isn't necessarily enough info to
rebuild the name as clang generates them (also GCC generates those
names differently - and those are probably harder to roundtrip, but
more likely to be canonical/unique/unambiguous), operator overloads
were not simplified because it was hard to tell if they were/weren't
simplified with all the <> involved in some operator names even
without template parameters - etc...


More information about the Gdb mailing list