public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32421] New: gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs
@ 2024-12-05 22:04 dblaikie at gmail dot com
  2024-12-10 16:19 ` [Bug c++/32421] " tromey at sourceware dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dblaikie at gmail dot com @ 2024-12-05 22:04 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 32421
           Summary: gdb can't search template specializations without
                    parameters in the DW_AT_name across CUs/TUs
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: dblaikie at gmail dot com
  Target Milestone: ---

Clang has a mode (-gsimple-template-names) that omits template parameters from
the DW_AT_name when the DWARF is sufficient to describe the parameters
unambiguously (this feature exists to reduce the size of .debug_str -
substantially in some large applications, helping to keep string offsets below
the 32 bit limit of DWARF32).

GDB seems to be able to do the work to associate a type declaration with a type
definition that uses this representation - avoiding ambiguity (it does avoid
making a mistake of resolving t1<int> to t1<float> just because both are called
t1) - but what gdb doesn't seem to do, is search for t1<int> definition given
t1<int> declaration.

Examples. This shows that the resolution fails initially, but does happen if
the DWARF is explicitly parsed:
`a.h`:
```
template<typename T>
struct t1 {
  T m;
  t1() { }
};
t1<int> *get();
```
`a.cpp`:
```
#include "a.h"
t1<int> *v1 = get();
int main() {
}
```
`b.cpp`:
```
#include "a.h"
t1<int> *get() {
  static t1<int> v;
  return &v;
}
```
```
$ clang++ -g a.cpp b.cpp -gsimple-template-names
$ gdb ./a.out -batch -ex "start" -ex "p *v1" -ex "p get" -ex "p *v1"
...
$1 = <incomplete type>
$2 = {t1<int> *(void)} 0x5555555551b0 <get()>
$3 = {
  m = 0
}
```


I know this is rather novel DWARF, and makes debugger implementations slower
and more complex trying to do this kind of ambiguous search (though some
ambiguity in the search already exists - handling different ways that DWARF
producers encode names (eg: "t1<const int>" or "t1<int const>" or whitespace
changes, etc) - so perhaps this parameter ambiguity could be part of this kind
of handling (by parsing the DWARF DIEs representing the parameters, and
building a canonical name from them)). It is a really valuable size
optimization, and changes the scaling factors of DWARF for some kinds of
template heavy code (especially expression template libraries, like Eigen or
Tensorflow).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/32421] gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs
  2024-12-05 22:04 [Bug c++/32421] New: gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs dblaikie at gmail dot com
@ 2024-12-10 16:19 ` tromey at sourceware dot org
  2024-12-10 19:01 ` dblaikie at gmail dot com
  2024-12-10 19:02 ` sam at gentoo dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2024-12-10 16:19 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-12-10
             Status|UNCONFIRMED                 |NEW
                 CC|                            |tromey at sourceware dot org
     Ever confirmed|0                           |1

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I feel like you maybe reported this somewhere before, but I didn't
dig for it.

Anyway, yeah, the full symbol reader seemingly has code to compute
this info; see dwarf2_compute_name.

However the indexer does not do this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/32421] gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs
  2024-12-05 22:04 [Bug c++/32421] New: gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs dblaikie at gmail dot com
  2024-12-10 16:19 ` [Bug c++/32421] " tromey at sourceware dot org
@ 2024-12-10 19:01 ` dblaikie at gmail dot com
  2024-12-10 19:02 ` sam at gentoo dot org
  2 siblings, 0 replies; 4+ messages in thread
From: dblaikie at gmail dot com @ 2024-12-10 19:01 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from David Blaikie <dblaikie at gmail dot com> ---
(In reply to Tom Tromey from comment #1)
> I feel like you maybe reported this somewhere before, but I didn't
> dig for it.

Oh, fair - https://sourceware.org/bugzilla/show_bug.cgi?id=30023 is close,
probably amounts to the same thing, though that's specifically about an
externally provided index. I guess, probably, a fix to how the index is looked
up would address both cases (externally provided index with simplified names,
and whatever index gdb auto-generates (I guess it'd also have simplified names
today, which is why it has similar problems))

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/32421] gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs
  2024-12-05 22:04 [Bug c++/32421] New: gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs dblaikie at gmail dot com
  2024-12-10 16:19 ` [Bug c++/32421] " tromey at sourceware dot org
  2024-12-10 19:01 ` dblaikie at gmail dot com
@ 2024-12-10 19:02 ` sam at gentoo dot org
  2 siblings, 0 replies; 4+ messages in thread
From: sam at gentoo dot org @ 2024-12-10 19:02 UTC (permalink / raw)
  To: gdb-prs

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

Sam James <sam at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://sourceware.org/bugz
                   |                            |illa/show_bug.cgi?id=30023
                 CC|                            |sam at gentoo dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-10 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-05 22:04 [Bug c++/32421] New: gdb can't search template specializations without parameters in the DW_AT_name across CUs/TUs dblaikie at gmail dot com
2024-12-10 16:19 ` [Bug c++/32421] " tromey at sourceware dot org
2024-12-10 19:01 ` dblaikie at gmail dot com
2024-12-10 19:02 ` sam at gentoo dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).