Add psymbols for nested types
authorKeith Seitz <keiths@redhat.com>
Thu, 22 Mar 2018 23:49:48 +0000 (16:49 -0700)
committerKeith Seitz <keiths@redhat.com>
Fri, 23 Mar 2018 18:58:32 +0000 (11:58 -0700)
commitb7fee5a3268c340975a1dddb131733abfd153d5e
treee395d189a6f96df9dbd1b7148ab303c7d6b4eece
parent291158a341260e97125db5638cd47c1e9aea5e8f
Add psymbols for nested types

c++/22968 involves the inability of ptype to find a type definition for
a type defined inside another type.  I recently added some additional
support for nested type definitions, but I apparently overlooked psymbols.

The user reports that using -readnow fixes the problem:

$ gdb 22968 -ex "ptype Outer::Inner"
There is no field named Inner

$ gdb -readnow 22968 -ex "ptype Outer::Inner"
type = struct Outer::Inner {
  <no data field>
}

We clearly did not find a psymbol for Outer::Inner because it was located
in another CU.  This patch addresses this problem by scanning structs
for additional psymbols.  Rust is already doing this.

With this patch, the identical result to "-readnow" is given (without
using `-readnow', of course).

gdb/ChangeLog:

PR c++/22968
* dwarf2read.c (scan_partial_symbols): Scan structs/classes for
nested type definitions for C++, too.

gdb/testsuite/ChangeLog:

PR c++/22968
* gdb.cp/subtypes.exp: New file.
* gdb.cp/subtypes.h: New file.
* gdb.cp/subtypes.cc: New file.
* gdb.cp/subtypes-2.cc: New file.
gdb/ChangeLog
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/subtypes-2.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/subtypes.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/subtypes.exp [new file with mode: 0644]
gdb/testsuite/gdb.cp/subtypes.h [new file with mode: 0644]