From f9b96f673e6c442fe81cd1b5c27cb83ae50ae63b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 23 Oct 2023 14:05:03 -0400 Subject: [PATCH] gdb: make get_symbol_address a private method of symbol get_symbol_address is only used symbol::value_address, make it a private helper method. Change-Id: I318ddcfcf1269d95045b8efe9137812df9c5113c Approved-By: Tom Tromey --- gdb/symtab.c | 10 +++++----- gdb/symtab.h | 17 ++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 96bc481dbf5..5ec56f4f2af 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6517,17 +6517,17 @@ symbol::set_symtab (struct symtab *symtab) /* See symtab.h. */ CORE_ADDR -get_symbol_address (const struct symbol *sym) +symbol::get_maybe_copied_address () const { - gdb_assert (sym->maybe_copied); - gdb_assert (sym->aclass () == LOC_STATIC); + gdb_assert (this->maybe_copied); + gdb_assert (this->aclass () == LOC_STATIC); - const char *linkage_name = sym->linkage_name (); + const char *linkage_name = this->linkage_name (); bound_minimal_symbol minsym = lookup_minimal_symbol_linkage (linkage_name, false); if (minsym.minsym != nullptr) return minsym.value_address (); - return sym->m_value.address; + return this->m_value.address; } /* See symtab.h. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 07f13e8952f..8dfc873b1c9 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -630,14 +630,6 @@ struct general_symbol_info extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); -/* Return the address of SYM. The MAYBE_COPIED flag must be set on - SYM. If SYM appears in the main program's minimal symbols, then - that minsym's address is returned; otherwise, SYM's address is - returned. This should generally only be used via the - SYMBOL_VALUE_ADDRESS macro. */ - -extern CORE_ADDR get_symbol_address (const struct symbol *sym); - /* Try to determine the demangled name for a symbol, based on the language of that symbol. If the language is set to language_auto, it will attempt to find any demangling algorithm that works and @@ -1359,7 +1351,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack CORE_ADDR value_address () const { if (this->maybe_copied) - return get_symbol_address (this); + return this->get_maybe_copied_address (); else return m_value.address; } @@ -1520,6 +1512,13 @@ struct symbol : public general_symbol_info, public allocate_on_obstack void *aux_value = nullptr; struct symbol *hash_next = nullptr; + +private: + /* Return the address of this symbol. The MAYBE_COPIED flag must be set. + If the symbol appears in the main program's minimal symbols, then + that minsym's address is returned; otherwise, this symbol's address is + returned. */ + CORE_ADDR get_maybe_copied_address () const; }; /* Several lookup functions return both a symbol and the block in which the -- 2.30.2