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:45 -0600 |
commit | e11145903f25b7ac91dd12e6330df3faec0a3f1b (patch) | |
tree | 921a7ace0f6baf95a09d3063413050f213b947f1 | |
parent | de909f0b765dbe6223292c2d05e97631136df42b (diff) | |
download | gdb-e11145903f25b7ac91dd12e6330df3faec0a3f1b.zip gdb-e11145903f25b7ac91dd12e6330df3faec0a3f1b.tar.gz gdb-e11145903f25b7ac91dd12e6330df3faec0a3f1b.tar.bz2 |
Switch objfile to hold a list of psymbol readers
This changes objfile::qf to be a forward_list, and then updates all
the uses to iterate over the list. Note that there is still only ever
a single element in the list; this is handled by clearing the list
whenever an object is added.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
* symfile.c (syms_from_objfile_1, reread_symbols): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language)
(objfile::require_partial_symbols): Update.
* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
* objfiles.h (struct objfile) <qf>: Now a forward_list.
* objfiles.c (objfile_relocate1): Update.
* elfread.c (elf_symfile_read): Update.
-rw-r--r-- | gdb/ChangeLog | 25 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 2 | ||||
-rw-r--r-- | gdb/elfread.c | 9 | ||||
-rw-r--r-- | gdb/objfiles.c | 4 | ||||
-rw-r--r-- | gdb/objfiles.h | 3 | ||||
-rw-r--r-- | gdb/psymtab.c | 412 | ||||
-rw-r--r-- | gdb/symfile-debug.c | 137 | ||||
-rw-r--r-- | gdb/symfile.c | 7 |
8 files changed, 337 insertions, 262 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 68f40d9..e87cb76 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,30 @@ 2021-03-20 Tom Tromey <tom@tromey.com> + * dwarf2/read.c (dwarf2_build_psymtabs): Update. + * symfile.c (syms_from_objfile_1, reread_symbols): Update. + * symfile-debug.c (objfile::has_partial_symbols) + (objfile::find_last_source_symtab) + (objfile::forget_cached_source_info) + (objfile::map_symtabs_matching_filename, objfile::lookup_symbol) + (objfile::print_stats, objfile::dump) + (objfile::expand_symtabs_for_function) + (objfile::expand_all_symtabs) + (objfile::expand_symtabs_with_fullname) + (objfile::map_matching_symbols) + (objfile::expand_symtabs_matching) + (objfile::find_pc_sect_compunit_symtab) + (objfile::map_symbol_filenames) + (objfile::find_compunit_symtab_by_address) + (objfile::lookup_global_symbol_language) + (objfile::require_partial_symbols): Update. + * psymtab.c (maintenance_print_psymbols) + (maintenance_info_psymtabs, maintenance_check_psymtabs): Update. + * objfiles.h (struct objfile) <qf>: Now a forward_list. + * objfiles.c (objfile_relocate1): Update. + * elfread.c (elf_symfile_read): Update. + +2021-03-20 Tom Tromey <tom@tromey.com> + * objfiles.h (struct objfile) <psymtabs>: Remove method. 2021-03-20 Tom Tromey <tom@tromey.com> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 4271398..9453848 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6131,7 +6131,7 @@ dwarf2_build_psymtabs (struct objfile *objfile) /* This is a temporary hack to ensure that the objfile and 'qf' psymtabs are identical. */ psymbol_functions *psf - = dynamic_cast<psymbol_functions *> (objfile->qf.get ()); + = dynamic_cast<psymbol_functions *> (objfile->qf.front ().get ()); gdb_assert (psf != nullptr); psf->set_partial_symtabs (per_bfd->partial_symtabs); per_objfile->resize_symtabs (); diff --git a/gdb/elfread.c b/gdb/elfread.c index 157a071..1cf9b2a 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1287,10 +1287,12 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) switch (index_kind) { case dw_index_kind::GDB_INDEX: - objfile->qf = make_dwarf_gdb_index (); + objfile->qf.clear (); + objfile->qf.push_front (make_dwarf_gdb_index ()); break; case dw_index_kind::DEBUG_NAMES: - objfile->qf = make_dwarf_debug_names (); + objfile->qf.clear (); + objfile->qf.push_front (make_dwarf_debug_names ()); break; } } @@ -1300,7 +1302,8 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) partial symbols, because OBJF_PSYMTABS_READ has not been set, and so our lazy reader function will still be called when needed. */ - objfile->qf.reset + objfile->qf.clear (); + objfile->qf.emplace_front (new lazy_dwarf_reader (objfile->partial_symtabs)); } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index ca135dd..ed51c31 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -703,8 +703,8 @@ objfile_relocate1 (struct objfile *objfile, } /* Notify the quick symbol object. */ - if (objfile->qf) - objfile->qf->relocated (); + for (const auto &iter : objfile->qf) + iter->relocated (); /* Relocate isolated symbols. */ { diff --git a/gdb/objfiles.h b/gdb/objfiles.h index cb441b1..2f56670 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -38,6 +38,7 @@ #include "gdbsupport/refcounted-object.h" #include "jit.h" #include "quick-symbol.h" +#include <forward_list> struct htab; struct objfile_data; @@ -668,7 +669,7 @@ public: /* The "quick" (aka partial) symbol functions for this symbol reader. */ - quick_symbol_functions_up qf; + std::forward_list<quick_symbol_functions_up> qf; /* Per objfile data-pointers required by other GDB modules. */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 3f3b559..785eda0 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1810,49 +1810,25 @@ maintenance_print_psymbols (const char *args, int from_tty) if (!print_for_objfile) continue; - psymbol_functions *psf - = dynamic_cast<psymbol_functions *> (objfile->qf.get ()); - if (psf == nullptr) - continue; - - psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get (); - - if (address_arg != NULL) + for (const auto &iter : objfile->qf) { - struct bound_minimal_symbol msymbol = { NULL, NULL }; + psymbol_functions *psf + = dynamic_cast<psymbol_functions *> (iter.get ()); + if (psf == nullptr) + continue; - /* We don't assume each pc has a unique objfile (this is for - debugging). */ - struct partial_symtab *ps - = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol); - if (ps != NULL) - { - if (!printed_objfile_header) - { - outfile->printf ("\nPartial symtabs for objfile %s\n", - objfile_name (objfile)); - printed_objfile_header = 1; - } - dump_psymtab (objfile, ps, outfile); - dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile); - found = 1; - } - } - else - { - for (partial_symtab *ps : psf->require_partial_symbols (objfile)) + psymtab_storage *partial_symtabs + = psf->get_partial_symtabs ().get (); + + if (address_arg != NULL) { - int print_for_source = 0; + struct bound_minimal_symbol msymbol = { NULL, NULL }; - QUIT; - if (source_arg != NULL) - { - print_for_source - = compare_filenames_for_search (ps->filename, source_arg); - found = 1; - } - if (source_arg == NULL - || print_for_source) + /* We don't assume each pc has a unique objfile (this is for + debugging). */ + struct partial_symtab *ps + = psf->find_pc_sect_psymtab (objfile, pc, section, msymbol); + if (ps != NULL) { if (!printed_objfile_header) { @@ -1861,20 +1837,48 @@ maintenance_print_psymbols (const char *args, int from_tty) printed_objfile_header = 1; } dump_psymtab (objfile, ps, outfile); - dump_psymtab_addrmap (objfile, partial_symtabs, ps, - outfile); + dump_psymtab_addrmap (objfile, partial_symtabs, ps, outfile); + found = 1; + } + } + else + { + for (partial_symtab *ps : psf->require_partial_symbols (objfile)) + { + int print_for_source = 0; + + QUIT; + if (source_arg != NULL) + { + print_for_source + = compare_filenames_for_search (ps->filename, source_arg); + found = 1; + } + if (source_arg == NULL + || print_for_source) + { + if (!printed_objfile_header) + { + outfile->printf ("\nPartial symtabs for objfile %s\n", + objfile_name (objfile)); + printed_objfile_header = 1; + } + dump_psymtab (objfile, ps, outfile); + dump_psymtab_addrmap (objfile, partial_symtabs, ps, + outfile); + } } } - } - /* If we're printing all the objfile's symbols dump the full addrmap. */ + /* If we're printing all the objfile's symbols dump the full addrmap. */ - if (address_arg == NULL - && source_arg == NULL - && partial_symtabs->psymtabs_addrmap != NULL) - { - outfile->puts ("\n"); - dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile); + if (address_arg == NULL + && source_arg == NULL + && partial_symtabs->psymtabs_addrmap != NULL) + { + outfile->puts ("\n"); + dump_psymtab_addrmap (objfile, partial_symtabs, NULL, outfile); + } } } @@ -1904,91 +1908,94 @@ maintenance_info_psymtabs (const char *regexp, int from_tty) actually find a symtab whose name matches. */ int printed_objfile_start = 0; - psymbol_functions *psf - = dynamic_cast<psymbol_functions *> (objfile->qf.get ()); - if (psf == nullptr) - continue; - for (partial_symtab *psymtab : psf->require_partial_symbols (objfile)) + for (const auto &iter : objfile->qf) { - QUIT; - - if (! regexp - || re_exec (psymtab->filename)) + psymbol_functions *psf + = dynamic_cast<psymbol_functions *> (iter.get ()); + if (psf == nullptr) + continue; + for (partial_symtab *psymtab : psf->require_partial_symbols (objfile)) { - if (! printed_objfile_start) - { - printf_filtered ("{ objfile %s ", objfile_name (objfile)); - wrap_here (" "); - printf_filtered ("((struct objfile *) %s)\n", - host_address_to_string (objfile)); - printed_objfile_start = 1; - } + QUIT; - printf_filtered (" { psymtab %s ", psymtab->filename); - wrap_here (" "); - printf_filtered ("((struct partial_symtab *) %s)\n", - host_address_to_string (psymtab)); - - printf_filtered (" readin %s\n", - psymtab->readin_p (objfile) ? "yes" : "no"); - printf_filtered (" fullname %s\n", - psymtab->fullname - ? psymtab->fullname : "(null)"); - printf_filtered (" text addresses "); - fputs_filtered (paddress (gdbarch, - psymtab->text_low (objfile)), - gdb_stdout); - printf_filtered (" -- "); - fputs_filtered (paddress (gdbarch, - psymtab->text_high (objfile)), - gdb_stdout); - printf_filtered ("\n"); - printf_filtered (" psymtabs_addrmap_supported %s\n", - (psymtab->psymtabs_addrmap_supported - ? "yes" : "no")); - printf_filtered (" globals "); - if (!psymtab->global_psymbols.empty ()) - printf_filtered - ("(* (struct partial_symbol **) %s @ %d)\n", - host_address_to_string (psymtab->global_psymbols.data ()), - (int) psymtab->global_psymbols.size ()); - else - printf_filtered ("(none)\n"); - printf_filtered (" statics "); - if (!psymtab->static_psymbols.empty ()) - printf_filtered - ("(* (struct partial_symbol **) %s @ %d)\n", - host_address_to_string (psymtab->static_psymbols.data ()), - (int) psymtab->static_psymbols.size ()); - else - printf_filtered ("(none)\n"); - if (psymtab->user) - printf_filtered (" user %s " - "((struct partial_symtab *) %s)\n", - psymtab->user->filename, - host_address_to_string (psymtab->user)); - printf_filtered (" dependencies "); - if (psymtab->number_of_dependencies) + if (! regexp + || re_exec (psymtab->filename)) { - int i; + if (! printed_objfile_start) + { + printf_filtered ("{ objfile %s ", objfile_name (objfile)); + wrap_here (" "); + printf_filtered ("((struct objfile *) %s)\n", + host_address_to_string (objfile)); + printed_objfile_start = 1; + } - printf_filtered ("{\n"); - for (i = 0; i < psymtab->number_of_dependencies; i++) + printf_filtered (" { psymtab %s ", psymtab->filename); + wrap_here (" "); + printf_filtered ("((struct partial_symtab *) %s)\n", + host_address_to_string (psymtab)); + + printf_filtered (" readin %s\n", + psymtab->readin_p (objfile) ? "yes" : "no"); + printf_filtered (" fullname %s\n", + psymtab->fullname + ? psymtab->fullname : "(null)"); + printf_filtered (" text addresses "); + fputs_filtered (paddress (gdbarch, + psymtab->text_low (objfile)), + gdb_stdout); + printf_filtered (" -- "); + fputs_filtered (paddress (gdbarch, + psymtab->text_high (objfile)), + gdb_stdout); + printf_filtered ("\n"); + printf_filtered (" psymtabs_addrmap_supported %s\n", + (psymtab->psymtabs_addrmap_supported + ? "yes" : "no")); + printf_filtered (" globals "); + if (!psymtab->global_psymbols.empty ()) + printf_filtered + ("(* (struct partial_symbol **) %s @ %d)\n", + host_address_to_string (psymtab->global_psymbols.data ()), + (int) psymtab->global_psymbols.size ()); + else + printf_filtered ("(none)\n"); + printf_filtered (" statics "); + if (!psymtab->static_psymbols.empty ()) + printf_filtered + ("(* (struct partial_symbol **) %s @ %d)\n", + host_address_to_string (psymtab->static_psymbols.data ()), + (int) psymtab->static_psymbols.size ()); + else + printf_filtered ("(none)\n"); + if (psymtab->user) + printf_filtered (" user %s " + "((struct partial_symtab *) %s)\n", + psymtab->user->filename, + host_address_to_string (psymtab->user)); + printf_filtered (" dependencies "); + if (psymtab->number_of_dependencies) { - struct partial_symtab *dep = psymtab->dependencies[i]; - - /* Note the string concatenation there --- no - comma. */ - printf_filtered (" psymtab %s " - "((struct partial_symtab *) %s)\n", - dep->filename, - host_address_to_string (dep)); + int i; + + printf_filtered ("{\n"); + for (i = 0; i < psymtab->number_of_dependencies; i++) + { + struct partial_symtab *dep = psymtab->dependencies[i]; + + /* Note the string concatenation there --- no + comma. */ + printf_filtered (" psymtab %s " + "((struct partial_symtab *) %s)\n", + dep->filename, + host_address_to_string (dep)); + } + printf_filtered (" }\n"); } - printf_filtered (" }\n"); + else + printf_filtered ("(none)\n"); + printf_filtered (" }\n"); } - else - printf_filtered ("(none)\n"); - printf_filtered (" }\n"); } } @@ -2009,93 +2016,96 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) for (objfile *objfile : current_program_space->objfiles ()) { - psymbol_functions *psf - = dynamic_cast<psymbol_functions *> (objfile->qf.get ()); - if (psf == nullptr) - continue; - - for (partial_symtab *ps : psf->require_partial_symbols (objfile)) + for (const auto &iter : objfile->qf) { - struct gdbarch *gdbarch = objfile->arch (); - - /* 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 (objfile); + psymbol_functions *psf + = dynamic_cast<psymbol_functions *> (iter.get ()); + if (psf == nullptr) + continue; - /* First do some checks that don't require the associated symtab. */ - if (ps->text_high (objfile) < ps->text_low (objfile)) + for (partial_symtab *ps : psf->require_partial_symbols (objfile)) { - printf_filtered ("Psymtab "); - puts_filtered (ps->filename); - printf_filtered (" covers bad range "); - fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), - gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), - gdb_stdout); - printf_filtered ("\n"); - continue; - } + struct gdbarch *gdbarch = objfile->arch (); - /* Now do checks requiring the associated symtab. */ - if (cust == NULL) - continue; - bv = COMPUNIT_BLOCKVECTOR (cust); - b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - for (partial_symbol *psym : ps->static_psymbols) - { - /* Skip symbols for inlined functions without address. These may - or may not have a match in the full symtab. */ - if (psym->aclass == LOC_BLOCK - && psym->ginfo.value.address == 0) - continue; + /* 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 (objfile); - sym = block_lookup_symbol (b, psym->ginfo.search_name (), - symbol_name_match_type::SEARCH_NAME, - psym->domain); - if (!sym) + /* First do some checks that don't require the associated symtab. */ + if (ps->text_high (objfile) < ps->text_low (objfile)) { - printf_filtered ("Static symbol `"); - puts_filtered (psym->ginfo.linkage_name ()); - printf_filtered ("' only found in "); + printf_filtered ("Psymtab "); puts_filtered (ps->filename); - printf_filtered (" psymtab\n"); + printf_filtered (" covers bad range "); + fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), + gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), + gdb_stdout); + printf_filtered ("\n"); + continue; } - } - b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - for (partial_symbol *psym : ps->global_psymbols) - { - sym = block_lookup_symbol (b, psym->ginfo.search_name (), - symbol_name_match_type::SEARCH_NAME, - psym->domain); - if (!sym) + + /* Now do checks requiring the associated symtab. */ + if (cust == NULL) + continue; + bv = COMPUNIT_BLOCKVECTOR (cust); + b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); + for (partial_symbol *psym : ps->static_psymbols) + { + /* Skip symbols for inlined functions without address. These may + or may not have a match in the full symtab. */ + if (psym->aclass == LOC_BLOCK + && psym->ginfo.value.address == 0) + continue; + + sym = block_lookup_symbol (b, psym->ginfo.search_name (), + symbol_name_match_type::SEARCH_NAME, + psym->domain); + if (!sym) + { + printf_filtered ("Static symbol `"); + puts_filtered (psym->ginfo.linkage_name ()); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + } + b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + for (partial_symbol *psym : ps->global_psymbols) + { + sym = block_lookup_symbol (b, psym->ginfo.search_name (), + symbol_name_match_type::SEARCH_NAME, + psym->domain); + if (!sym) + { + printf_filtered ("Global symbol `"); + puts_filtered (psym->ginfo.linkage_name ()); + printf_filtered ("' only found in "); + puts_filtered (ps->filename); + printf_filtered (" psymtab\n"); + } + } + if (ps->raw_text_high () != 0 + && (ps->text_low (objfile) < BLOCK_START (b) + || ps->text_high (objfile) > BLOCK_END (b))) { - printf_filtered ("Global symbol `"); - puts_filtered (psym->ginfo.linkage_name ()); - printf_filtered ("' only found in "); + printf_filtered ("Psymtab "); puts_filtered (ps->filename); - printf_filtered (" psymtab\n"); + printf_filtered (" covers "); + fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), + gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), + gdb_stdout); + printf_filtered (" but symtab covers only "); + fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); + printf_filtered (" - "); + fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); + printf_filtered ("\n"); } } - if (ps->raw_text_high () != 0 - && (ps->text_low (objfile) < BLOCK_START (b) - || ps->text_high (objfile) > BLOCK_END (b))) - { - printf_filtered ("Psymtab "); - puts_filtered (ps->filename); - printf_filtered (" covers "); - fputs_filtered (paddress (gdbarch, ps->text_low (objfile)), - gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, ps->text_high (objfile)), - gdb_stdout); - printf_filtered (" but symtab covers only "); - fputs_filtered (paddress (gdbarch, BLOCK_START (b)), gdb_stdout); - printf_filtered (" - "); - fputs_filtered (paddress (gdbarch, BLOCK_END (b)), gdb_stdout); - printf_filtered ("\n"); - } } } } diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 9997453..3daede8 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -80,12 +80,16 @@ objfile::has_partial_symbols () them, then that is an indication that they are in fact available. Without this function the symbols may have been already read in but they also may not be present in this objfile. */ - if ((flags & OBJF_PSYMTABS_READ) == 0 - && qf != nullptr - && qf->can_lazily_read_symbols ()) - retval = true; - else if (qf != nullptr) - retval = qf->has_symbols (this); + for (const auto &iter : qf) + { + if ((flags & OBJF_PSYMTABS_READ) == 0 + && iter->can_lazily_read_symbols ()) + retval = true; + else + retval = iter->has_symbols (this); + if (retval) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n", @@ -103,8 +107,12 @@ objfile::find_last_source_symtab () fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n", objfile_debug_name (this)); - if (qf != nullptr) - retval = qf->find_last_source_symtab (this); + for (const auto &iter : qf) + { + retval = iter->find_last_source_symtab (this); + if (retval != nullptr) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n", @@ -120,8 +128,8 @@ objfile::forget_cached_source_info () fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n", objfile_debug_name (this)); - if (qf != nullptr) - qf->forget_cached_source_info (this); + for (const auto &iter : qf) + iter->forget_cached_source_info (this); } bool @@ -138,9 +146,13 @@ objfile::map_symtabs_matching_filename host_address_to_string (&callback)); bool retval = false; - if (qf != nullptr) - retval = (qf->map_symtabs_matching_filename - (this, name, real_path, callback)); + for (const auto &iter : qf) + { + retval = (iter->map_symtabs_matching_filename + (this, name, real_path, callback)); + if (retval) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, @@ -161,8 +173,12 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) objfile_debug_name (this), kind, name, domain_name (domain)); - if (qf != nullptr) - retval = qf->lookup_symbol (this, kind, name, domain); + for (const auto &iter : qf) + { + retval = iter->lookup_symbol (this, kind, name, domain); + if (retval != nullptr) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n", @@ -180,8 +196,8 @@ objfile::print_stats (bool print_bcache) fprintf_filtered (gdb_stdlog, "qf->print_stats (%s, %d)\n", objfile_debug_name (this), print_bcache); - if (qf != nullptr) - qf->print_stats (this, print_bcache); + for (const auto &iter : qf) + iter->print_stats (this, print_bcache); } void @@ -191,8 +207,8 @@ objfile::dump () fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n", objfile_debug_name (this)); - if (qf != nullptr) - qf->dump (this); + for (const auto &iter : qf) + iter->dump (this); } void @@ -203,8 +219,8 @@ objfile::expand_symtabs_for_function (const char *func_name) "qf->expand_symtabs_for_function (%s, \"%s\")\n", objfile_debug_name (this), func_name); - if (qf != nullptr) - qf->expand_symtabs_for_function (this, func_name); + for (const auto &iter : qf) + iter->expand_symtabs_for_function (this, func_name); } void @@ -214,8 +230,8 @@ objfile::expand_all_symtabs () fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n", objfile_debug_name (this)); - if (qf != nullptr) - qf->expand_all_symtabs (this); + for (const auto &iter : qf) + iter->expand_all_symtabs (this); } void @@ -226,8 +242,8 @@ objfile::expand_symtabs_with_fullname (const char *fullname) "qf->expand_symtabs_with_fullname (%s, \"%s\")\n", objfile_debug_name (this), fullname); - if (qf != nullptr) - qf->expand_symtabs_with_fullname (this, fullname); + for (const auto &iter : qf) + iter->expand_symtabs_with_fullname (this, fullname); } void @@ -244,9 +260,9 @@ objfile::map_matching_symbols domain_name (domain), global, host_address_to_string (ordered_compare)); - if (qf != nullptr) - qf->map_matching_symbols (this, name, domain, global, - callback, ordered_compare); + for (const auto &iter : qf) + iter->map_matching_symbols (this, name, domain, global, + callback, ordered_compare); } void @@ -266,9 +282,9 @@ objfile::expand_symtabs_matching host_address_to_string (&expansion_notify), search_domain_name (kind)); - if (qf != nullptr) - qf->expand_symtabs_matching (this, file_matcher, lookup_name, - symbol_matcher, expansion_notify, kind); + for (const auto &iter : qf) + iter->expand_symtabs_matching (this, file_matcher, lookup_name, + symbol_matcher, expansion_notify, kind); } struct compunit_symtab * @@ -288,9 +304,13 @@ objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol, host_address_to_string (section), warn_if_readin); - if (qf != nullptr) - retval = qf->find_pc_sect_compunit_symtab (this, msymbol, pc, section, - warn_if_readin); + for (const auto &iter : qf) + { + retval = iter->find_pc_sect_compunit_symtab (this, msymbol, pc, section, + warn_if_readin); + if (retval != nullptr) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, @@ -314,8 +334,8 @@ objfile::map_symbol_filenames (symbol_filename_ftype *fun, void *data, host_address_to_string (data), need_fullname); - if (qf != nullptr) - qf->map_symbol_filenames (this, fun, data, need_fullname); + for (const auto &iter : qf) + iter->map_symbol_filenames (this, fun, data, need_fullname); } struct compunit_symtab * @@ -328,8 +348,12 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address) hex_string (address)); struct compunit_symtab *result = NULL; - if (qf != nullptr) - result = qf->find_compunit_symtab_by_address (this, address); + for (const auto &iter : qf) + { + result = iter->find_compunit_symtab_by_address (this, address); + if (result != nullptr) + break; + } if (debug_symfile) fprintf_filtered (gdb_stdlog, @@ -347,12 +371,15 @@ objfile::lookup_global_symbol_language (const char *name, bool *symbol_found_p) { enum language result = language_unknown; + *symbol_found_p = false; - if (qf != nullptr) - result = qf->lookup_global_symbol_language (this, name, domain, - symbol_found_p); - else - *symbol_found_p = false; + for (const auto &iter : qf) + { + result = iter->lookup_global_symbol_language (this, name, domain, + symbol_found_p); + if (*symbol_found_p) + break; + } return result; } @@ -364,17 +391,23 @@ objfile::require_partial_symbols (bool verbose) { flags |= OBJF_PSYMTABS_READ; - if (qf->can_lazily_read_symbols ()) + bool printed = false; + for (const auto &iter : qf) { - 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)); + if (iter->can_lazily_read_symbols ()) + { + if (verbose && !printed) + { + printf_filtered (_("Reading symbols from %s...\n"), + objfile_name (this)); + printed = true; + } + iter->read_partial_symbols (this); + } } + if (printed && !objfile_has_symbols (this)) + printf_filtered (_("(No debugging symbols found in %s)\n"), + objfile_name (this)); } } diff --git a/gdb/symfile.c b/gdb/symfile.c index d2ea04e..244565f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -903,7 +903,8 @@ syms_from_objfile_1 (struct objfile *objfile, objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd)); objfile->reset_psymtabs (); - objfile->qf = make_psymbol_functions (objfile->partial_symtabs); + objfile->qf.clear (); + objfile->qf.push_front (make_psymbol_functions (objfile->partial_symtabs)); if (objfile->sf == NULL) { @@ -2553,7 +2554,9 @@ reread_symbols (void) start over. PR symtab/15885 */ objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd)); objfile->reset_psymtabs (); - objfile->qf = make_psymbol_functions (objfile->partial_symtabs); + objfile->qf.clear (); + objfile->qf.push_front + (make_psymbol_functions (objfile->partial_symtabs)); build_objfile_section_table (objfile); |