From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 20/26] Introduce objfile::require_partial_symbols
Date: Sun, 28 Feb 2021 13:37:57 -0700 [thread overview]
Message-ID: <20210228203803.1693413-21-tom@tromey.com> (raw)
In-Reply-To: <20210228203803.1693413-1-tom@tromey.com>
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 <tom@tromey.com>
* 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) <require_partial_symbols>: 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)
\f
-/* 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<CORE_ADDR> 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<psymtab_storage> &);
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));
+ }
+ }
+}
+
\f
/* 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 <chrono>
#include <algorithm>
-#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
next prev parent reply other threads:[~2021-02-28 20:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-28 20:37 [PATCH 00/26] Allow multiple "partial" symtab readers per objfile Tom Tromey
2021-02-28 20:37 ` [PATCH 01/26] Move some DWARF code out of symfile.h Tom Tromey
2021-02-28 20:37 ` [PATCH 02/26] Introduce dwarf2/public.h Tom Tromey
2021-02-28 20:37 ` [PATCH 03/26] Change objfile_has_partial_symbols to a method Tom Tromey
2021-02-28 20:37 ` [PATCH 04/26] Change objfile::has_partial_symbols to return bool Tom Tromey
2021-02-28 20:37 ` [PATCH 05/26] Introduce method wrappers for quick_symbol_functions Tom Tromey
2021-03-22 13:52 ` Simon Marchi
2021-02-28 20:37 ` [PATCH 06/26] Move quick_symbol_functions to a new header Tom Tromey
2021-02-28 20:37 ` [PATCH 07/26] Move sym_fns::qf to objfile Tom Tromey
2021-02-28 20:37 ` [PATCH 08/26] Convert quick_symbol_functions to use methods Tom Tromey
2021-02-28 20:37 ` [PATCH 09/26] Move psymbol_map out of objfile Tom Tromey
2021-02-28 20:37 ` [PATCH 10/26] Change how some psymbol readers access the psymtab storage Tom Tromey
2021-02-28 20:37 ` [PATCH 11/26] Do not pass objfile to psymtab_discarder Tom Tromey
2021-02-28 20:37 ` [PATCH 12/26] Set per_bfd->partial_symtabs earlier Tom Tromey
2021-02-28 20:37 ` [PATCH 13/26] Change how DWARF indices use addrmap Tom Tromey
2021-02-28 20:37 ` [PATCH 14/26] Move psymtab statistics printing to psymtab.c Tom Tromey
2021-02-28 20:37 ` [PATCH 15/26] Change how DWARF index writer finds address map Tom Tromey
2021-02-28 20:37 ` [PATCH 16/26] Reference psymtabs via per_bfd in DWARF reader Tom Tromey
2021-02-28 20:37 ` [PATCH 17/26] Attach partial symtab storage to psymbol_functions Tom Tromey
2021-02-28 20:37 ` [PATCH 18/26] Rearrange psymtab_storage construction Tom Tromey
2021-02-28 20:37 ` [PATCH 19/26] Remove sym_fns::sym_read_psymbols Tom Tromey
2021-02-28 20:37 ` Tom Tromey [this message]
2021-02-28 20:37 ` [PATCH 21/26] Add partial_symtabs parameter to psymtab construction functions Tom Tromey
2021-02-28 20:37 ` [PATCH 22/26] Remove last objfile partial_symtab references from psymtab.c Tom Tromey
2021-02-28 20:38 ` [PATCH 23/26] Change count_psyms to be a method on psymbol_functions Tom Tromey
2021-02-28 20:38 ` [PATCH 24/26] Remove objfile::psymtabs Tom Tromey
2021-02-28 20:38 ` [PATCH 25/26] Switch objfile to hold a list of psymbol readers Tom Tromey
2021-02-28 20:38 ` [PATCH 26/26] Allow multiple partial symbol readers per objfile Tom Tromey
2021-03-20 23:33 ` [PATCH 00/26] Allow multiple "partial" symtab " Tom Tromey
2021-03-22 14:13 ` Simon Marchi
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=20210228203803.1693413-21-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@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: link
Be 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).