From: Simon Marchi Date: Wed, 17 Jul 2024 03:52:04 +0000 (-0400) Subject: gdb: add program_space parameter to lookup_minimal_symbol_linkage X-Git-Tag: gdb-16-branchpoint~1179 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e7c4d0fe5b7d28af9c6ba94e76c42fe8ca08eb7;p=thirdparty%2Fbinutils-gdb.git gdb: add program_space parameter to lookup_minimal_symbol_linkage Make the current_program_space reference bubble up one level. Change-Id: Ic349dc96b7d375ad7c66022d84657136f0de8c87 Reviewed-by: Keith Seitz Approved-By: Andrew Burgess --- diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index 9ec0d51e920..eabbab181c9 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -20,6 +20,7 @@ #include "symtab.h" #include "value.h" #include "dwarf2/loc.h" +#include "objfiles.h" /* Helper to get the imported symbol's real name. */ static const char * @@ -34,7 +35,8 @@ static struct value * ada_imported_read_variable (struct symbol *symbol, const frame_info_ptr &frame) { const char *name = get_imported_name (symbol); - bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (name, false); + bound_minimal_symbol minsym + = lookup_minimal_symbol_linkage (symbol->objfile ()->pspace (), name, false); if (minsym.minsym == nullptr) error (_("could not find imported name %s"), name); return value_at (symbol->type (), minsym.value_address ()); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4c68d071ac0..40d63404fce 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -584,9 +584,10 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf) /* See minsyms.h. */ bound_minimal_symbol -lookup_minimal_symbol_linkage (const char *name, bool only_main) +lookup_minimal_symbol_linkage (program_space *pspace, const char *name, + bool only_main) { - for (objfile *objfile : current_program_space->objfiles ()) + for (objfile *objfile : pspace->objfiles ()) { if (objfile->separate_debug_objfile_backlink != nullptr) continue; diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 0d9b9ad51ce..f84d3e81848 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -234,11 +234,11 @@ extern bound_minimal_symbol lookup_minimal_symbol_linkage (const char *name, ATTRIBUTE_NONNULL (1) ATTRIBUTE_NONNULL (2); /* A variant of lookup_minimal_symbol_linkage that iterates over all - objfiles. If ONLY_MAIN is true, then only an objfile with + objfiles of PSPACE. If ONLY_MAIN is true, then only an objfile with OBJF_MAINLINE will be considered. */ -extern bound_minimal_symbol lookup_minimal_symbol_linkage (const char *name, - bool only_main) +extern bound_minimal_symbol lookup_minimal_symbol_linkage + (program_space *pspace, const char *name, bool only_main) ATTRIBUTE_NONNULL (1); /* Look through all the current minimal symbol tables and find the diff --git a/gdb/symtab.c b/gdb/symtab.c index c77537f121a..9da148b3394 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6775,10 +6775,12 @@ symbol::get_maybe_copied_address () const gdb_assert (this->aclass () == LOC_STATIC); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name, - false); + bound_minimal_symbol minsym + = lookup_minimal_symbol_linkage (this->objfile ()->pspace (), linkage_name, + false); if (minsym.minsym != nullptr) return minsym.value_address (); + return this->m_value.address; } @@ -6791,10 +6793,11 @@ minimal_symbol::get_maybe_copied_address (objfile *objf) const gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); const char *linkage_name = this->linkage_name (); - bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, - true); + bound_minimal_symbol found + = lookup_minimal_symbol_linkage (objf->pspace (), linkage_name, true); if (found.minsym != nullptr) return found.value_address (); + return (this->m_value.address + objf->section_offsets[this->section_index ()]); }