public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol
@ 2023-10-23 18:05 Simon Marchi
  2023-10-23 18:05 ` [PATCH 2/2] gdb: make get_symbol_address a private method of symbol Simon Marchi
  2023-10-25 14:46 ` [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Marchi @ 2023-10-23 18:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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

Change-Id: I3f30e1b9d89ace6682fb08a7ebb91746db0ccf0f
---
 gdb/symtab.c | 12 ++++++------
 gdb/symtab.h | 16 +++++++---------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 46547f8b0ae4..96bc481dbf5f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -439,7 +439,7 @@ CORE_ADDR
 minimal_symbol::value_address (objfile *objfile) const
 {
   if (this->maybe_copied (objfile))
-    return get_msymbol_address (objfile, this);
+    return this->get_maybe_copied_address (objfile);
   else
     return (CORE_ADDR (this->unrelocated_address ())
 	    + objfile->section_offsets[this->section_index ()]);
@@ -6533,18 +6533,18 @@ get_symbol_address (const struct symbol *sym)
 /* See symtab.h.  */
 
 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);
 
-  const char *linkage_name = minsym->linkage_name ();
+  const char *linkage_name = this->linkage_name ();
   bound_minimal_symbol found = lookup_minimal_symbol_linkage (linkage_name,
 							      true);
   if (found.minsym != nullptr)
     return found.value_address ();
-  return (minsym->m_value.address
-	  + objf->section_offsets[minsym->section_index ()]);
+  return (this->m_value.address
+	  + objf->section_offsets[this->section_index ()]);
 }
 
 \f
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 365743384e17..07f13e8952fc 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -716,15 +716,6 @@ enum minimal_symbol_type
 #define MINSYM_TYPE_BITS 4
 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
    all defined global symbols (text, data, bss, abs, etc).  The only required
    information is the general_symbol_info.
@@ -885,6 +876,13 @@ struct minimal_symbol : public general_symbol_info
      address in this symbol is used.  */
 
   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"

base-commit: 093c25c488ad6826d29d9345422c7845658ef383
-- 
2.42.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] gdb: make get_symbol_address a private method of symbol
  2023-10-23 18:05 [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Simon Marchi
@ 2023-10-23 18:05 ` Simon Marchi
  2023-10-25 14:47   ` Tom Tromey
  2023-10-25 14:46 ` [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Tom Tromey
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2023-10-23 18:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

get_symbol_address is only used symbol::value_address, make it a private
helper method.

Change-Id: I318ddcfcf1269d95045b8efe9137812df9c5113c
---
 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 96bc481dbf5f..5ec56f4f2afe 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 07f13e8952fc..8dfc873b1c94 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.42.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol
  2023-10-23 18:05 [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Simon Marchi
  2023-10-23 18:05 ` [PATCH 2/2] gdb: make get_symbol_address a private method of symbol Simon Marchi
@ 2023-10-25 14:46 ` Tom Tromey
  2023-10-25 15:49   ` Simon Marchi
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2023-10-25 14:46 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

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

Thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] gdb: make get_symbol_address a private method of symbol
  2023-10-23 18:05 ` [PATCH 2/2] gdb: make get_symbol_address a private method of symbol Simon Marchi
@ 2023-10-25 14:47   ` Tom Tromey
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2023-10-25 14:47 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:

Simon> get_symbol_address is only used symbol::value_address, make it a private
Simon> helper method.

Thank you, looks good.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol
  2023-10-25 14:46 ` [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Tom Tromey
@ 2023-10-25 15:49   ` Simon Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2023-10-25 15:49 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/25/23 10:46, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
> 
> Simon> get_msymbol_address is only used in minimal_symbol::value_address.  Make
> Simon> it a private helper method.
> 
> Thanks.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks, pushed.

Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-25 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 18:05 [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Simon Marchi
2023-10-23 18:05 ` [PATCH 2/2] gdb: make get_symbol_address a private method of symbol Simon Marchi
2023-10-25 14:47   ` Tom Tromey
2023-10-25 14:46 ` [PATCH 1/2] gdb: make get_msymbol_address a private method of minimal_symbol Tom Tromey
2023-10-25 15:49   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).