From patchwork Sun Jan 26 23:41:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 37564 Received: (qmail 43638 invoked by alias); 26 Jan 2020 23:41:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 43158 invoked by uid 89); 26 Jan 2020 23:41:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=Internal X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Jan 2020 23:41:32 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 38F3C20187; Sun, 26 Jan 2020 18:41:29 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id CE9382053E; Sun, 26 Jan 2020 18:41:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id A1406218A2; Sun, 26 Jan 2020 18:41:11 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Sun, 26 Jan 2020 18:41:07 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] Virtualize "readin" and "compunit_symtab" X-Gerrit-Change-Id: Idb923f196d7e03bf7cb9cfc8134ed06dd3f211ce X-Gerrit-Change-Number: 383 X-Gerrit-ChangeURL: X-Gerrit-Commit: 128a391fe45a234587dc585e03a7726cd6ee0255 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20200126234111.A1406218A2@gnutoolchain-gerrit.osci.io> The original change was created by Tom Tromey. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/383 ...................................................................... Virtualize "readin" and "compunit_symtab" This patch removes the "readin" and "compunit_symtab" members from partial_symtab, replacing them with methods. Then it introduces a new "standard_psymtab" class, which restores these members; and changes the symbol readers to use this intermediate class as the base class of their partial symtab subclasses. The reason for this is to make it possible for a symbol reader to implement an alternate mapping between partial and full symbol tables. This is important in order to be able to share psymtabs across objfiles -- whether a psymtab has been "readin" is objfile-dependent, as are the pointers to the full symbol tables. gdb/ChangeLog 2020-01-26 Tom Tromey * psymtab.c (partial_map_expand_apply) (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol) (psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab) (psym_print_stats, psym_expand_symtabs_for_function) (psym_map_symbol_filenames, psym_map_matching_symbols) (psym_expand_symtabs_matching) (partial_symtab::read_dependencies, maintenance_info_psymtabs) (maintenance_check_psymtabs): Use new methods. * psympriv.h (struct partial_symtab) : New methods. : Remove members. (struct standard_psymtab): New. (struct legacy_psymtab): Derive from standard_psymtab. * dwarf2read.h (struct dwarf2_psymtab): Derive from standard_psymtab. * ctfread.c (struct ctf_psymtab): Derive from standard_psymtab. Change-Id: Idb923f196d7e03bf7cb9cfc8134ed06dd3f211ce --- M gdb/ChangeLog M gdb/ctfread.c M gdb/dwarf2read.h M gdb/psympriv.h M gdb/psymtab.c 5 files changed, 90 insertions(+), 35 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 69f2689..77e52f3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,24 @@ 2020-01-26 Tom Tromey + * psymtab.c (partial_map_expand_apply) + (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol) + (psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab) + (psym_print_stats, psym_expand_symtabs_for_function) + (psym_map_symbol_filenames, psym_map_matching_symbols) + (psym_expand_symtabs_matching) + (partial_symtab::read_dependencies, maintenance_info_psymtabs) + (maintenance_check_psymtabs): Use new methods. + * psympriv.h (struct partial_symtab) : New methods. + : Remove members. + (struct standard_psymtab): New. + (struct legacy_psymtab): Derive from standard_psymtab. + * dwarf2read.h (struct dwarf2_psymtab): Derive from + standard_psymtab. + * ctfread.c (struct ctf_psymtab): Derive from standard_psymtab. + +2020-01-26 Tom Tromey + * xcoffread.c (xcoff_psymtab_to_symtab_1): Call read_dependencies. Add assert. * psymtab.c (partial_symtab::read_dependencies): New method. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 77cdcd4..d363ce6 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -116,10 +116,10 @@ }; /* A partial symtab, specialized for this module. */ -struct ctf_psymtab : public partial_symtab +struct ctf_psymtab : public standard_psymtab { ctf_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr) - : partial_symtab (filename, objfile, addr) + : standard_psymtab (filename, objfile, addr) { } diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index c5b6902..3f9731f 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -271,16 +271,16 @@ dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile); /* A partial symtab specialized for DWARF. */ -struct dwarf2_psymtab : public partial_symtab +struct dwarf2_psymtab : public standard_psymtab { dwarf2_psymtab (const char *filename, struct objfile *objfile) - : partial_symtab (filename, objfile) + : standard_psymtab (filename, objfile) { } dwarf2_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr) - : partial_symtab (filename, objfile, addr) + : standard_psymtab (filename, objfile, addr) { } diff --git a/gdb/psympriv.h b/gdb/psympriv.h index e4b2330..1b1f57c 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -137,6 +137,15 @@ /* Ensure that all the dependencies are read in. */ void read_dependencies (struct objfile *); + /* Return true if the symtab corresponding to this psymtab has been + readin. */ + virtual bool readin_p () const = 0; + + /* Return a pointer to the compunit allocated for this source file. + Return nullptr if !readin or if there was no symtab. */ + virtual struct compunit_symtab *get_compunit_symtab () const = 0; + + /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const { @@ -265,12 +274,6 @@ int statics_offset = 0; int n_static_syms = 0; - /* True if the symtab corresponding to this psymtab has been readin. - This is located here so that this structure packs better on - 64-bit systems. */ - - bool readin = false; - /* True iff objfile->psymtabs_addrmap is properly populated for this partial_symtab. For discontiguous overlapping psymtabs is the only usable info in PSYMTABS_ADDRMAP. */ @@ -289,6 +292,40 @@ unsigned int text_low_valid : 1; unsigned int text_high_valid : 1; +}; + +/* A partial symtab that tracks the "readin" and "compunit_symtab" + information in the ordinary way -- by storing it directly in this + object. */ +struct standard_psymtab : public partial_symtab +{ + standard_psymtab (const char *filename, struct objfile *objfile) + : partial_symtab (filename, objfile) + { + } + + standard_psymtab (const char *filename, struct objfile *objfile, + CORE_ADDR addr) + : partial_symtab (filename, objfile, addr) + { + } + + bool readin_p () const override + { + return readin; + } + + /* Return a pointer to the compunit allocated for this source file. + Return nullptr if !readin or if there was no symtab. */ + struct compunit_symtab *get_compunit_symtab () const override + { + return compunit_symtab; + } + + /* True if the symtab corresponding to this psymtab has been + readin. */ + + bool readin = false; /* Pointer to compunit eventually allocated for this source file, 0 if !readin or if we haven't looked for the symtab after it was readin. */ @@ -300,16 +337,16 @@ not be used in new code, but exists to transition the somewhat unmaintained "legacy" debug formats. */ -struct legacy_psymtab : public partial_symtab +struct legacy_psymtab : public standard_psymtab { legacy_psymtab (const char *filename, struct objfile *objfile) - : partial_symtab (filename, objfile) + : standard_psymtab (filename, objfile) { } legacy_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr) - : partial_symtab (filename, objfile, addr) + : standard_psymtab (filename, objfile, addr) { } diff --git a/gdb/psymtab.c b/gdb/psymtab.c index c020d15..56576b3 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -131,7 +131,7 @@ gdb_assert (pst->user == NULL); /* Don't visit already-expanded psymtabs. */ - if (pst->readin) + if (pst->readin_p ()) return 0; /* This may expand more than one symtab, and we want to iterate over @@ -385,7 +385,7 @@ msymbol); if (ps != NULL) { - if (warn_if_readin && ps->readin) + if (warn_if_readin && ps->readin_p ()) /* Might want to error() here (in case symtab is corrupt and will cause a core dump), but maybe we can successfully continue, so let's not. */ @@ -393,7 +393,7 @@ (Internal error: pc %s in read in psymtab, but not in symtab.)\n"), paddress (get_objfile_arch (objfile), pc)); psymtab_to_symtab (objfile, ps); - return ps->compunit_symtab; + return ps->get_compunit_symtab (); } return NULL; } @@ -484,8 +484,8 @@ for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (!ps->readin && lookup_partial_symbol (objfile, ps, name, - psymtab_index, domain)) + if (!ps->readin_p () && lookup_partial_symbol (objfile, ps, name, + psymtab_index, domain)) { struct symbol *sym, *with_opaque = NULL; struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps); @@ -750,11 +750,11 @@ pst = pst->user; /* If it's been looked up before, return it. */ - if (pst->compunit_symtab) - return pst->compunit_symtab; + if (pst->get_compunit_symtab ()) + return pst->get_compunit_symtab (); /* If it has not yet been read in, read it. */ - if (!pst->readin) + if (!pst->readin_p ()) { scoped_restore decrementer = increment_reading_symtab (); @@ -772,7 +772,7 @@ printf_filtered (_("done.\n")); } - return pst->compunit_symtab; + return pst->get_compunit_symtab (); } /* Psymtab version of find_last_source_symtab. See its definition in @@ -795,7 +795,7 @@ if (cs_pst) { - if (cs_pst->readin) + if (cs_pst->readin_p ()) { internal_error (__FILE__, __LINE__, _("select_source_symtab: " @@ -952,11 +952,11 @@ gdb_print_host_address (objfile, outfile); fprintf_filtered (outfile, ")\n"); - if (psymtab->readin) + if (psymtab->readin_p ()) { fprintf_filtered (outfile, " Full symtab was read (at "); - gdb_print_host_address (psymtab->compunit_symtab, outfile); + gdb_print_host_address (psymtab->get_compunit_symtab (), outfile); fprintf_filtered (outfile, ")\n"); } @@ -1010,7 +1010,7 @@ i = 0; for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (!ps->readin) + if (!ps->readin_p ()) i++; } printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i); @@ -1050,7 +1050,7 @@ { for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (ps->readin) + if (ps->readin_p ()) continue; if ((lookup_partial_symbol (objfile, ps, func_name, 1, VAR_DOMAIN) @@ -1105,7 +1105,7 @@ { const char *fullname; - if (ps->readin) + if (ps->readin_p ()) continue; /* We can skip shared psymtabs here, because any file name will be @@ -1185,7 +1185,7 @@ for (partial_symtab *ps : require_partial_symbols (objfile, true)) { QUIT; - if (ps->readin + if (ps->readin_p () || match_partial_symbol (objfile, ps, global, name, domain, ordered_compare)) { @@ -1320,7 +1320,7 @@ { QUIT; - if (ps->readin) + if (ps->readin_p ()) continue; /* We skip shared psymtabs because file-matching doesn't apply @@ -1659,7 +1659,6 @@ filename = ((const char *) objfile->per_bfd->filename_cache.insert (filename_, strlen (filename_) + 1)); - compunit_symtab = NULL; if (symtab_create_debug) { @@ -1689,7 +1688,7 @@ { for (int i = 0; i < number_of_dependencies; ++i) { - if (!dependencies[i]->readin) + if (!dependencies[i]->readin_p ()) { /* Inform about additional files to be read in. */ if (info_verbose) @@ -2001,7 +2000,7 @@ host_address_to_string (psymtab)); printf_filtered (" readin %s\n", - psymtab->readin ? "yes" : "no"); + psymtab->readin_p () ? "yes" : "no"); printf_filtered (" fullname %s\n", psymtab->fullname ? psymtab->fullname : "(null)"); @@ -2092,7 +2091,7 @@ /* We don't call psymtab_to_symtab here because that may cause symtab expansion. When debugging a problem it helps if checkers leave things unchanged. */ - cust = ps->compunit_symtab; + cust = ps->get_compunit_symtab (); /* First do some checks that don't require the associated symtab. */ if (ps->text_high (objfile) < ps->text_low (objfile))