diff options
author | Tom Tromey <tom@tromey.com> | 2021-03-20 17:23:40 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-03-20 17:23:44 -0600 |
commit | d1eef86d12f5aa2f8461add1180df9db4b59a39d (patch) | |
tree | 085a1f465fc21fd51c7d8b03fa35e44bc660a1f6 | |
parent | eb00e4686dd1a1530737e2de7eae971d61332da1 (diff) | |
download | gdb-d1eef86d12f5aa2f8461add1180df9db4b59a39d.zip gdb-d1eef86d12f5aa2f8461add1180df9db4b59a39d.tar.gz gdb-d1eef86d12f5aa2f8461add1180df9db4b59a39d.tar.bz2 |
Introduce objfile::require_partial_symbols
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-03-20 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.
-rw-r--r-- | gdb/ChangeLog | 25 | ||||
-rw-r--r-- | gdb/objfiles.h | 3 | ||||
-rw-r--r-- | gdb/psymtab.c | 63 | ||||
-rw-r--r-- | gdb/psymtab.h | 8 | ||||
-rw-r--r-- | gdb/symfile-debug.c | 21 | ||||
-rw-r--r-- | gdb/symfile.c | 4 |
6 files changed, 75 insertions, 49 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1640270..f647ac4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,30 @@ 2021-03-20 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. + +2021-03-20 Tom Tromey <tom@tromey.com> + * xcoffread.c (xcoff_sym_fns): Update. * symfile.h (struct sym_fns) <sym_read_psymbols>: Remove. * symfile-debug.c (objfile::has_partial_symbols): Use diff --git a/gdb/objfiles.h b/gdb/objfiles.h index ff60e18..c51217b 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -615,6 +615,9 @@ public: 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 b5ddef9..302ef9a 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<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 18b47c5..e19cac6 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -146,14 +146,6 @@ private: }; -/* 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 94559c7..9997453 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 0130452..d2ea04e 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. */ |