From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.180]) by sourceware.org (Postfix) with ESMTPS id 41A99388A80D for ; Sun, 28 Feb 2021 20:38:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41A99388A80D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id DC814D7F8 for ; Sun, 28 Feb 2021 14:38:15 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpTldsKv4HRaGSpTllWY2; Sun, 28 Feb 2021 14:38:15 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DROMoyDCb4aJ40zcKMSfaY70K8b/C0u+5AWFAI1xPKw=; b=IA/wOiHlH9PY3sFH8mjg9hMsc2 Ea0r0DTC00pFrPFx7M9dffB+EWlJ9JNkmtrGQX0/65Sd5ci1Chyu6rPIDgqxosuL+0+tZHYDIYRx3 dndUhmrwUhgeZ43dhwkDIrgEx; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:36736 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lGSpT-000Xpk-Bq for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 20/26] Introduce objfile::require_partial_symbols Date: Sun, 28 Feb 2021 13:37:57 -0700 Message-Id: <20210228203803.1693413-21-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210228203803.1693413-1-tom@tromey.com> References: <20210228203803.1693413-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.70.152 X-Source-L: No X-Exim-ID: 1lGSpT-000Xpk-Bq X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:36736 X-Source-Auth: tom+tromey.com X-Email-Count: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3034.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, 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: Sun, 28 Feb 2021 20:38:18 -0000 This adds a new method, objfile::require_partial_symbols. This reuses most of the code from the old function in psymtab.c. That function is now made static, and simplified. gdb/ChangeLog 2021-02-28 Tom Tromey * symfile.c (read_symbols): Use objfile method. * symfile-debug.c (objfile::require_partial_symbols): New method. * psymtab.h (require_partial_symbols): Don't declare. * psymtab.c (require_partial_symbols): Use objfile method. Now static. (psymbol_functions::map_symtabs_matching_filename, OBJFILE) (psymbol_functions::lookup_symbol) (psymbol_functions::lookup_global_symbol_language) (psymbol_functions::find_last_source_symtab) (psymbol_functions::forget_cached_source_info) (psymbol_functions::print_stats) (psymbol_functions::expand_symtabs_for_function) (psymbol_functions::expand_all_symtabs) (psymbol_functions::expand_symtabs_with_fullname) (psymbol_functions::map_symbol_filenames) (psymbol_functions::map_matching_symbols) (psymbol_functions::expand_symtabs_matching) (psymbol_functions::find_compunit_symtab_by_address) (maintenance_print_psymbols, maintenance_info_psymtabs) (maintenance_check_psymtabs): Update. * objfiles.h (struct objfile) : Declare new method. --- gdb/ChangeLog | 25 ++++++++++++++++++ gdb/objfiles.h | 3 +++ gdb/psymtab.c | 63 ++++++++++++++++++--------------------------- gdb/psymtab.h | 8 ------ gdb/symfile-debug.c | 21 +++++++++++++++ gdb/symfile.c | 4 +-- 6 files changed, 75 insertions(+), 49 deletions(-) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index ff60e18bca4..c51217be6f0 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -615,6 +615,9 @@ struct objfile domain_enum domain, bool *symbol_found_p); + /* See quick_symbol_functions. */ + void require_partial_symbols (bool verbose); + /* The object file's original name as specified by the user, made absolute, and tilde-expanded. However, it is not canonicalized diff --git a/gdb/psymtab.c b/gdb/psymtab.c index b5ddef90878..302ef9a192f 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -75,28 +75,15 @@ psymtab_storage::install_psymtab (partial_symtab *pst) -/* See psymtab.h. */ +/* Ensure that the partial symbols for OBJFILE have been loaded. This + will print a message when symbols are loaded. This function + returns a range adapter suitable for iterating over the psymtabs of + OBJFILE. */ -psymtab_storage::partial_symtab_range -require_partial_symbols (struct objfile *objfile, bool verbose) +static psymtab_storage::partial_symtab_range +require_partial_symbols (struct objfile *objfile) { - if ((objfile->flags & OBJF_PSYMTABS_READ) == 0) - { - objfile->flags |= OBJF_PSYMTABS_READ; - - if (objfile->qf->can_lazily_read_symbols ()) - { - if (verbose) - printf_filtered (_("Reading symbols from %s...\n"), - objfile_name (objfile)); - objfile->qf->read_partial_symbols (objfile); - - if (verbose && !objfile_has_symbols (objfile)) - printf_filtered (_("(No debugging symbols found in %s)\n"), - objfile_name (objfile)); - } - } - + objfile->require_partial_symbols (true); return objfile->psymtabs (); } @@ -140,7 +127,7 @@ psymbol_functions::map_symtabs_matching_filename { const char *name_basename = lbasename (name); - for (partial_symtab *pst : require_partial_symbols (objfile, true)) + for (partial_symtab *pst : require_partial_symbols (objfile)) { /* Anonymous psymtabs don't have a file name. */ if (pst->anonymous) @@ -342,7 +329,7 @@ find_pc_sect_psymtab (struct objfile *objfile, its CUs may be missing in PSYMTABS_ADDRMAP as they may be varying debug info type in single OBJFILE. */ - for (partial_symtab *pst : require_partial_symbols (objfile, true)) + for (partial_symtab *pst : require_partial_symbols (objfile)) if (!pst->psymtabs_addrmap_supported && pc >= pst->text_low (objfile) && pc < pst->text_high (objfile)) { @@ -465,7 +452,7 @@ psymbol_functions::lookup_symbol (struct objfile *objfile, lookup_name_info psym_lookup_name = lookup_name.make_ignore_params (); - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { if (!ps->readin_p (objfile) && lookup_partial_symbol (objfile, ps, psym_lookup_name, @@ -516,7 +503,7 @@ psymbol_functions::lookup_global_symbol_language (struct objfile *objfile, lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { struct partial_symbol *psym; if (ps->readin_p (objfile)) @@ -765,7 +752,7 @@ psymbol_functions::find_last_source_symtab (struct objfile *ofp) { struct partial_symtab *cs_pst = NULL; - for (partial_symtab *ps : require_partial_symbols (ofp, true)) + for (partial_symtab *ps : require_partial_symbols (ofp)) { const char *name = ps->filename; int len = strlen (name); @@ -801,7 +788,7 @@ psymbol_functions::find_last_source_symtab (struct objfile *ofp) void psymbol_functions::forget_cached_source_info (struct objfile *objfile) { - for (partial_symtab *pst : require_partial_symbols (objfile, true)) + for (partial_symtab *pst : require_partial_symbols (objfile)) { if (pst->fullname != NULL) { @@ -1008,7 +995,7 @@ psymbol_functions::print_stats (struct objfile *objfile, bool print_bcache) n_psyms); i = 0; - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { if (!ps->readin_p (objfile)) i++; @@ -1061,7 +1048,7 @@ psymbol_functions::expand_symtabs_for_function (struct objfile *objfile, lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL); lookup_name_info lookup_name = base_lookup.make_ignore_params (); - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { if (ps->readin_p (objfile)) continue; @@ -1080,7 +1067,7 @@ psymbol_functions::expand_symtabs_for_function (struct objfile *objfile, void psymbol_functions::expand_all_symtabs (struct objfile *objfile) { - for (partial_symtab *psymtab : require_partial_symbols (objfile, true)) + for (partial_symtab *psymtab : require_partial_symbols (objfile)) psymtab_to_symtab (objfile, psymtab); } @@ -1091,7 +1078,7 @@ void psymbol_functions::expand_symtabs_with_fullname (struct objfile *objfile, const char *fullname) { - for (partial_symtab *p : require_partial_symbols (objfile, true)) + for (partial_symtab *p : require_partial_symbols (objfile)) { /* Anonymous psymtabs don't have a name of a source file. */ if (p->anonymous) @@ -1115,7 +1102,7 @@ psymbol_functions::map_symbol_filenames (struct objfile *objfile, void *data, int need_fullname) { - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { const char *fullname; @@ -1196,7 +1183,7 @@ psymbol_functions::map_matching_symbols { const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { QUIT; if (ps->readin_p (objfile) @@ -1321,7 +1308,7 @@ psymbol_functions::expand_symtabs_matching enum search_domain domain) { /* Clear the search flags. */ - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) ps->searched_flag = PST_NOT_SEARCHED; for (partial_symtab *ps : m_partial_symtabs->range ()) @@ -1414,7 +1401,7 @@ psymbol_functions::find_compunit_symtab_by_address (struct objfile *objfile, { std::set seen_addrs; - for (partial_symtab *pst : require_partial_symbols (objfile, true)) + for (partial_symtab *pst : require_partial_symbols (objfile)) { fill_psymbol_map (objfile, pst, &seen_addrs, @@ -1861,7 +1848,7 @@ maintenance_print_psymbols (const char *args, int from_tty) } else { - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { int print_for_source = 0; @@ -1892,7 +1879,7 @@ maintenance_print_psymbols (const char *args, int from_tty) if (address_arg == NULL && source_arg == NULL - && objfile->partial_symtabs->psymtabs_addrmap != NULL) + && partial_symtabs->psymtabs_addrmap != NULL) { outfile->puts ("\n"); dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile); @@ -1925,7 +1912,7 @@ maintenance_info_psymtabs (const char *regexp, int from_tty) actually find a symtab whose name matches. */ int printed_objfile_start = 0; - for (partial_symtab *psymtab : require_partial_symbols (objfile, true)) + for (partial_symtab *psymtab : require_partial_symbols (objfile)) { QUIT; @@ -2025,7 +2012,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) const struct block *b; for (objfile *objfile : current_program_space->objfiles ()) - for (partial_symtab *ps : require_partial_symbols (objfile, true)) + for (partial_symtab *ps : require_partial_symbols (objfile)) { struct gdbarch *gdbarch = objfile->arch (); diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 18b47c55b3c..e19cac64aa4 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -146,14 +146,6 @@ class psymtab_storage }; -/* Ensure that the partial symbols for OBJFILE have been loaded. If - VERBOSE is true, then this will print a message when symbols - are loaded. This function returns a range adapter suitable for - iterating over the psymtabs of OBJFILE. */ - -extern psymtab_storage::partial_symtab_range require_partial_symbols - (struct objfile *objfile, bool verbose); - extern quick_symbol_functions_up make_psymbol_functions (const std::shared_ptr &); diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 94559c7370c..99974536bf4 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -357,6 +357,27 @@ objfile::lookup_global_symbol_language (const char *name, return result; } +void +objfile::require_partial_symbols (bool verbose) +{ + if ((flags & OBJF_PSYMTABS_READ) == 0) + { + flags |= OBJF_PSYMTABS_READ; + + if (qf->can_lazily_read_symbols ()) + { + if (verbose) + printf_filtered (_("Reading symbols from %s...\n"), + objfile_name (this)); + qf->read_partial_symbols (this); + + if (verbose && !objfile_has_symbols (this)) + printf_filtered (_("(No debugging symbols found in %s)\n"), + objfile_name (this)); + } + } +} + /* Debugging version of struct sym_probe_fns. */ diff --git a/gdb/symfile.c b/gdb/symfile.c index 01304523c0d..d2ea04ed149 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -69,8 +69,6 @@ #include #include -#include "psymtab.h" - int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num); void (*deprecated_show_load_progress) (const char *section, @@ -793,7 +791,7 @@ read_symbols (struct objfile *objfile, symfile_add_flags add_flags) } } if ((add_flags & SYMFILE_NO_READ) == 0) - require_partial_symbols (objfile, false); + objfile->require_partial_symbols (false); } /* Initialize entry point information for this objfile. */ -- 2.26.2