gdb: make get_msymbol_address a private method of minimal_symbol

get_msymbol_address is only used in minimal_symbol::value_address.  Make
it a private helper method.

Change-Id: I3f30e1b9d89ace6682fb08a7ebb91746db0ccf0f
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Simon Marchi 2023-10-23 14:05:02 -04:00
parent 53beac2e23
commit 23e6f78151
2 changed files with 13 additions and 15 deletions

View file

@ -439,7 +439,7 @@ CORE_ADDR
minimal_symbol::value_address (objfile *objfile) const minimal_symbol::value_address (objfile *objfile) const
{ {
if (this->maybe_copied (objfile)) if (this->maybe_copied (objfile))
return get_msymbol_address (objfile, this); return this->get_maybe_copied_address (objfile);
else else
return (CORE_ADDR (this->unrelocated_address ()) return (CORE_ADDR (this->unrelocated_address ())
+ objfile->section_offsets[this->section_index ()]); + objfile->section_offsets[this->section_index ()]);
@ -6533,18 +6533,18 @@ get_symbol_address (const struct symbol *sym)
/* See symtab.h. */ /* See symtab.h. */
CORE_ADDR CORE_ADDR
get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym) minimal_symbol::get_maybe_copied_address (objfile *objf) const
{ {
gdb_assert (minsym->maybe_copied (objf)); gdb_assert (this->maybe_copied (objf));
gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); gdb_assert ((objf->flags & OBJF_MAINLINE) == 0);
const char *linkage_name = minsym->linkage_name (); const char *linkage_name = this->linkage_name ();
bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name, bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name,
true); true);
if (found.minsym != nullptr) if (found.minsym != nullptr)
return found.value_address (); return found.value_address ();
return (minsym->m_value.address return (this->m_value.address
+ objf->section_offsets[minsym->section_index ()]); + objf->section_offsets[this->section_index ()]);
} }

View file

@ -716,15 +716,6 @@ enum minimal_symbol_type
#define MINSYM_TYPE_BITS 4 #define MINSYM_TYPE_BITS 4
gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS)); gdb_static_assert (nr_minsym_types <= (1 << MINSYM_TYPE_BITS));
/* Return the address of MINSYM, which comes from OBJF. The
MAYBE_COPIED flag must be set on MINSYM. If MINSYM appears in the
main program's minimal symbols, then that minsym's address is
returned; otherwise, MINSYM's address is returned. This should
generally only be used via the MSYMBOL_VALUE_ADDRESS macro. */
extern CORE_ADDR get_msymbol_address (struct objfile *objf,
const struct minimal_symbol *minsym);
/* Define a simple structure used to hold some very basic information about /* Define a simple structure used to hold some very basic information about
all defined global symbols (text, data, bss, abs, etc). The only required all defined global symbols (text, data, bss, abs, etc). The only required
information is the general_symbol_info. information is the general_symbol_info.
@ -885,6 +876,13 @@ struct minimal_symbol : public general_symbol_info
address in this symbol is used. */ address in this symbol is used. */
bool maybe_copied (objfile *objfile) const; bool maybe_copied (objfile *objfile) const;
private:
/* Return the address of this minimal symbol, in the context of OBJF. The
MAYBE_COPIED flag must be set. If the minimal symbol appears in the
main program's minimal symbols, then that minsym's address is
returned; otherwise, this minimal symbol's address is returned. */
CORE_ADDR get_maybe_copied_address (objfile *objf) const;
}; };
#include "minsyms.h" #include "minsyms.h"