Specialize partial_symtab for DWARF include files
authorTom Tromey <tom@tromey.com>
Wed, 26 Feb 2020 22:41:07 +0000 (15:41 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 26 Feb 2020 22:49:50 +0000 (15:49 -0700)
commitb83470bfa7ca200b1c99caac5f6d56bffe0261d0
tree9fed46954796dca3bd59b98c97c7da205010cbe1
parentedfe0a0c6561cf838f3f885c22940025a826d900
Specialize partial_symtab for DWARF include files

Include files are represented by a partial symtab, but don't expand to
anything.  From dwarf2_psymtab::expand_psymtab:

  if (per_cu == NULL)
    {
      /* It's an include file, no symbols to read for it.
         Everything is in the parent symtab.  */
      readin = true;
      return;
    }

This patch introduces a new specialization of partial_symtab to handle
this case.  In addition to being slightly smaller, I believe an
include file is the only situation where a DWARF psymtab can result in
a null compunit_symtab.  This adds an assert to that effect as well.
This change will simplify one of the psymtab sharing patches.

gdb/ChangeLog
2020-02-26  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (struct dwarf2_include_psymtab): New.
(dwarf2_create_include_psymtab): Use dwarf2_include_psymtab.
(dwarf2_psymtab::expand_psymtab, dwarf2_psymtab::readin_p)
(dwarf2_psymtab::get_compunit_symtab): Remove null checks for
per_cu_data.
gdb/ChangeLog
gdb/dwarf2/read.c