public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Specialize partial_symtab for DWARF include files Date: Wed, 26 Feb 2020 22:56:00 -0000 [thread overview] Message-ID: <20200226225620.120882.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b83470bfa7ca200b1c99caac5f6d56bffe0261d0 commit b83470bfa7ca200b1c99caac5f6d56bffe0261d0 Author: Tom Tromey <tom@tromey.com> Date: Wed Feb 26 15:41:07 2020 -0700 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. Diff: --- gdb/ChangeLog | 8 ++++++++ gdb/dwarf2/read.c | 60 +++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2bb65e7..2f92b0a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 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. + +2020-02-26 Tom Tromey <tom@tromey.com> + * dwarf2/index-write.c (psym_index_map): Change type. (add_address_entry_worker, write_one_signatured_type) (recursively_count_psymbols, recursively_write_psymbols) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d6b34d8..c5f0ffa 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5918,6 +5918,44 @@ 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 + { + return nullptr; + } + +private: + + bool m_readin = false; +}; + /* Allocate a new partial symtab for file named NAME and mark this new partial symtab as being an include of PST. */ @@ -5925,7 +5963,7 @@ static void dwarf2_create_include_psymtab (const char *name, dwarf2_psymtab *pst, struct objfile *objfile) { - dwarf2_psymtab *subpst = new dwarf2_psymtab (name, objfile); + dwarf2_include_psymtab *subpst = new dwarf2_include_psymtab (name, objfile); if (!IS_ABSOLUTE_PATH (subpst->filename)) { @@ -5936,11 +5974,6 @@ dwarf2_create_include_psymtab (const char *name, dwarf2_psymtab *pst, subpst->dependencies = objfile->partial_symtabs->allocate_dependencies (1); subpst->dependencies[0] = pst; subpst->number_of_dependencies = 1; - - /* No private part is necessary for include psymtabs. This property - can be used to differentiate between such include psymtabs and - the regular ones. */ - subpst->per_cu_data = nullptr; } /* Read the Line Number Program data and extract the list of files @@ -8851,24 +8884,13 @@ process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile) void dwarf2_psymtab::expand_psymtab (struct objfile *objfile) { - struct dwarf2_per_cu_data *per_cu; - if (readin) return; read_dependencies (objfile); - per_cu = per_cu_data; - - if (per_cu == NULL) - { - /* It's an include file, no symbols to read for it. - Everything is in the parent symtab. */ - readin = true; - return; - } - - dw2_do_instantiate_symtab (per_cu, false); + dw2_do_instantiate_symtab (per_cu_data, false); + gdb_assert (get_compunit_symtab () != nullptr); } /* Trivial hash function for die_info: the hash value of a DIE
reply other threads:[~2020-02-26 22:56 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200226225620.120882.qmail@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).