[PATCH 2/2] Specialize partial_symtab for DWARF include files
Simon Marchi
simark@simark.ca
Wed Feb 26 16:34:00 GMT 2020
On 2020-02-25 8:09 a.m., Tom Tromey wrote:
> 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-25 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.
Hi Tom,
>From what I understand, this is fine, thanks.
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 8c40ddb727a..d22a53deb25 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -5894,6 +5894,45 @@ read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
> return (sect_offset) read_offset (abfd, info_ptr, offset_size);
> }
>
> +/* A partial symtab that is used only for include files. */
> +struct dwarf2_include_psymtab : public partial_symtab
> +{
> + dwarf2_include_psymtab (const char *filename, struct objfile *objfile)
> + : partial_symtab (filename, objfile)
> + {
> + }
> +
> + void read_symtab (struct objfile *objfile) override
> + {
> + expand_psymtab (objfile);
> + }
> +
> + void expand_psymtab (struct objfile *objfile) override
> + {
> + if (m_readin)
> + return;
> + /* It's an include file, no symbols to read for it.
> + Everything is in the parent symtab. */
> + read_dependencies (objfile);
> + m_readin = true;
> + }
> +
> + bool readin_p () const override
> + {
> + return m_readin;
> + }
> +
> + struct compunit_symtab *get_compunit_symtab () const
> + override
The override can be on the previous line.
Simon
More information about the Gdb-patches
mailing list