From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 272363953424 for ; Tue, 12 May 2020 21:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 272363953424 X-ASG-Debug-ID: 1589317755-0c856e18f31444b60001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id fyyBFTrNUeCnYAc3 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 May 2020 17:09:15 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 6E26F441D67; Tue, 12 May 2020 17:09:15 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 X-Barracuda-RBL-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 02/42] Add "objfile" parameter to two partial_symtab methods Date: Tue, 12 May 2020 17:08:33 -0400 X-ASG-Orig-Subj: [PATCH v2 02/42] Add "objfile" parameter to two partial_symtab methods Message-Id: <20200512210913.5593-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512210913.5593-1-simon.marchi@efficios.com> References: <20200512210913.5593-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1589317755 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 10461 X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.81805 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-30.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 21:09:19 -0000 From: Tom Tromey This series will cause partial symtabs to be shared across objfiles. However, full symtabs and symbols will still be objfile-dependent, so will be expanded separately for each objfile. So, a debug info reader will need to know which objfile to consult when expanding a partial symtab. This patch adds an objfile parameter to the two relevant methods of partial_symtab. Current implementations simply ignore them. 2020-02-21 Tom Tromey * psymtab.c (partial_map_expand_apply) (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol) (psym_lookup_global_symbol_language) (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): Update. * psympriv.h (struct partial_symtab) : Add objfile parameter. (struct standard_psymtab) : Likewise. * dwarf2/read.c (struct dwarf2_include_psymtab) : Likewise. (dwarf2_psymtab::expand_psymtab): Pass objfile argument. --- gdb/dwarf2/read.c | 8 ++++---- gdb/psympriv.h | 19 ++++++++++--------- gdb/psymtab.c | 44 ++++++++++++++++++++++---------------------- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0c28fd2cfc7..664520fbb4c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6004,12 +6004,12 @@ struct dwarf2_include_psymtab : public partial_symtab gdb_assert (false); } - bool readin_p () const override + bool readin_p (struct objfile *objfile) const override { - return includer ()->readin_p (); + return includer ()->readin_p (objfile); } - struct compunit_symtab *get_compunit_symtab () const override + compunit_symtab *get_compunit_symtab (struct objfile *objfile) const override { return nullptr; } @@ -8951,7 +8951,7 @@ dwarf2_psymtab::expand_psymtab (struct objfile *objfile) expand_dependencies (objfile); dw2_do_instantiate_symtab (per_cu_data, false); - gdb_assert (get_compunit_symtab () != nullptr); + gdb_assert (get_compunit_symtab (objfile) != nullptr); } /* Trivial hash function for die_info: the hash value of a DIE diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 6f0307e05b7..4622be389bd 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -147,13 +147,16 @@ struct partial_symtab void expand_dependencies (struct objfile *); /* Return true if the symtab corresponding to this psymtab has been - readin. */ - virtual bool readin_p () const = 0; + read in in the context of this objfile. */ + virtual bool readin_p (struct objfile *) 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 a pointer to the compunit allocated for this source file + in the context of this objfile. + Return nullptr if the compunit was not read in or if there was no + symtab. */ + virtual struct compunit_symtab *get_compunit_symtab + (struct objfile *) const = 0; /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const @@ -319,14 +322,12 @@ struct standard_psymtab : public partial_symtab { } - bool readin_p () const override + bool readin_p (struct objfile *) 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 + struct compunit_symtab *get_compunit_symtab (struct objfile *) const override { return compunit_symtab; } diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 1fce7a39838..5960c593fcf 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -132,7 +132,7 @@ partial_map_expand_apply (struct objfile *objfile, gdb_assert (pst->user == NULL); /* Don't visit already-expanded psymtabs. */ - if (pst->readin_p ()) + if (pst->readin_p (objfile)) return 0; /* This may expand more than one symtab, and we want to iterate over @@ -384,7 +384,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile, msymbol); if (ps != NULL) { - if (warn_if_readin && ps->readin_p ()) + if (warn_if_readin && ps->readin_p (objfile)) /* 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. */ @@ -392,7 +392,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile, (Internal error: pc %s in read in psymtab, but not in symtab.)\n"), paddress (objfile->arch (), pc)); psymtab_to_symtab (objfile, ps); - return ps->get_compunit_symtab (); + return ps->get_compunit_symtab (objfile); } return NULL; } @@ -485,9 +485,9 @@ psym_lookup_symbol (struct objfile *objfile, for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (!ps->readin_p () && lookup_partial_symbol (objfile, ps, - psym_lookup_name, - psymtab_index, domain)) + if (!ps->readin_p (objfile) + && lookup_partial_symbol (objfile, ps, psym_lookup_name, + psymtab_index, domain)) { struct symbol *sym, *with_opaque = NULL; struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps); @@ -535,7 +535,7 @@ psym_lookup_global_symbol_language (struct objfile *objfile, const char *name, for (partial_symtab *ps : require_partial_symbols (objfile, true)) { struct partial_symbol *psym; - if (ps->readin_p ()) + if (ps->readin_p (objfile)) continue; psym = lookup_partial_symbol (objfile, ps, lookup_name, 1, domain); @@ -748,11 +748,11 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst) pst = pst->user; /* If it's been looked up before, return it. */ - if (pst->get_compunit_symtab ()) - return pst->get_compunit_symtab (); + if (pst->get_compunit_symtab (objfile)) + return pst->get_compunit_symtab (objfile); /* If it has not yet been read in, read it. */ - if (!pst->readin_p ()) + if (!pst->readin_p (objfile)) { scoped_restore decrementer = increment_reading_symtab (); @@ -766,7 +766,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst) pst->read_symtab (objfile); } - return pst->get_compunit_symtab (); + return pst->get_compunit_symtab (objfile); } /* Psymtab version of find_last_source_symtab. See its definition in @@ -789,7 +789,7 @@ psym_find_last_source_symtab (struct objfile *ofp) if (cs_pst) { - if (cs_pst->readin_p ()) + if (cs_pst->readin_p (ofp)) { internal_error (__FILE__, __LINE__, _("select_source_symtab: " @@ -946,11 +946,11 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, gdb_print_host_address (objfile, outfile); fprintf_filtered (outfile, ")\n"); - if (psymtab->readin_p ()) + if (psymtab->readin_p (objfile)) { fprintf_filtered (outfile, " Full symtab was read (at "); - gdb_print_host_address (psymtab->get_compunit_symtab (), outfile); + gdb_print_host_address (psymtab->get_compunit_symtab (objfile), outfile); fprintf_filtered (outfile, ")\n"); } @@ -1004,7 +1004,7 @@ psym_print_stats (struct objfile *objfile) i = 0; for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (!ps->readin_p ()) + if (!ps->readin_p (objfile)) i++; } printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i); @@ -1047,7 +1047,7 @@ psym_expand_symtabs_for_function (struct objfile *objfile, for (partial_symtab *ps : require_partial_symbols (objfile, true)) { - if (ps->readin_p ()) + if (ps->readin_p (objfile)) continue; if ((lookup_partial_symbol (objfile, ps, lookup_name, 1, VAR_DOMAIN) @@ -1102,7 +1102,7 @@ psym_map_symbol_filenames (struct objfile *objfile, { const char *fullname; - if (ps->readin_p ()) + if (ps->readin_p (objfile)) continue; /* We can skip shared psymtabs here, because any file name will be @@ -1182,7 +1182,7 @@ psym_map_matching_symbols for (partial_symtab *ps : require_partial_symbols (objfile, true)) { QUIT; - if (ps->readin_p () + if (ps->readin_p (objfile) || match_partial_symbol (objfile, ps, global, name, domain, ordered_compare)) { @@ -1315,7 +1315,7 @@ psym_expand_symtabs_matching { QUIT; - if (ps->readin_p ()) + if (ps->readin_p (objfile)) continue; /* We skip shared psymtabs because file-matching doesn't apply @@ -1717,7 +1717,7 @@ partial_symtab::expand_dependencies (struct objfile *objfile) { for (int i = 0; i < number_of_dependencies; ++i) { - if (!dependencies[i]->readin_p () + if (!dependencies[i]->readin_p (objfile) && dependencies[i]->user == NULL) { /* Inform about additional files to be read in. */ @@ -2028,7 +2028,7 @@ maintenance_info_psymtabs (const char *regexp, int from_tty) host_address_to_string (psymtab)); printf_filtered (" readin %s\n", - psymtab->readin_p () ? "yes" : "no"); + psymtab->readin_p (objfile) ? "yes" : "no"); printf_filtered (" fullname %s\n", psymtab->fullname ? psymtab->fullname : "(null)"); @@ -2124,7 +2124,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) /* 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->get_compunit_symtab (); + cust = ps->get_compunit_symtab (objfile); /* First do some checks that don't require the associated symtab. */ if (ps->text_high (objfile) < ps->text_low (objfile)) -- 2.26.2