public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Remove a couple of SYMBOL related macros
@ 2021-02-08  9:55 Andrew Burgess
  2021-02-08  9:55 ` [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION Andrew Burgess
  2021-02-08  9:55 ` [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros Andrew Burgess
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Burgess @ 2021-02-08  9:55 UTC (permalink / raw)
  To: gdb-patches

Convert a couple of symbol related macros into member functions on
general_symbol_info.


---

Andrew Burgess (2):
  gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
  gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros

 gdb/ChangeLog      | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/breakpoint.c   |  5 ++--
 gdb/coff-pe-read.c |  2 +-
 gdb/coffread.c     |  4 +--
 gdb/ctfread.c      |  2 +-
 gdb/dwarf2/read.c  | 10 ++++----
 gdb/findvar.c      | 18 ++++++--------
 gdb/infcmd.c       |  2 +-
 gdb/language.c     |  2 +-
 gdb/linespec.c     |  2 +-
 gdb/maint.c        |  2 +-
 gdb/minsyms.c      | 19 ++++++++-------
 gdb/objfiles.c     |  4 +--
 gdb/parse.c        |  5 ++--
 gdb/printcmd.c     |  6 ++---
 gdb/psympriv.h     |  7 +++---
 gdb/psymtab.c      |  2 +-
 gdb/stabsread.c    |  2 +-
 gdb/symmisc.c      |  6 ++---
 gdb/symtab.c       | 32 +++++++++++++++---------
 gdb/symtab.h       | 36 +++++++++++++++++----------
 gdb/xcoffread.c    |  8 +++---
 22 files changed, 157 insertions(+), 80 deletions(-)

-- 
2.25.4


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

* [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
  2021-02-08  9:55 [PATCH 0/2] Remove a couple of SYMBOL related macros Andrew Burgess
@ 2021-02-08  9:55 ` Andrew Burgess
  2021-02-09 20:27   ` Tom Tromey
  2021-02-08  9:55 ` [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros Andrew Burgess
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-02-08  9:55 UTC (permalink / raw)
  To: gdb-patches

Replace the two macros SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION with
a member function on general_symbol_info.

There should be no user visible change after this commit.

gdb/ChangeLog:

	* breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and
	MSYMBOL_OBJ_SECTION.
	* findvar.c (language_defn::read_var_value): Likewise.
	* infcmd.c (jump_command): Likewise.
	* linespec.c (minsym_found): Likewise.
	* maint.c (maintenance_translate_address): Likewise.
	* minsyms.c (lookup_minimal_symbol_by_pc_section): Likewise.
	(minimal_symbol_upper_bound): Likewise.
	* parse.c (find_minsym_type_and_address): Likewise.
	(operator_check_standard): Likewise.
	* printcmd.c (info_address_command): Likewise.
	* symmisc.c (dump_msymbols): Likewise.
	(print_symbol): Likewise.
	* symtab.c (general_symbol_info::obj_section): Define new
	function.
	(fixup_symbol_section): Replace SYMBOL_OBJ_SECTION.
	(find_pc_sect_compunit_symtab): Likewise.
	(find_function_start_sal): Likewise.
	(skip_prologue_sal): Replace SYMBOL_OBJ_SECTION and
	MSYMBOL_OBJ_SECTION.
	* symtab.h (struct general_symbol_info) <obj_section>: Declare new
	function.
	(SYMBOL_OBJ_SECTION): Delete.
	(MSYMBOL_OBJ_SECTION): Delete.
---
 gdb/ChangeLog    | 27 +++++++++++++++++++++++++++
 gdb/breakpoint.c |  5 ++---
 gdb/findvar.c    | 18 ++++++++----------
 gdb/infcmd.c     |  2 +-
 gdb/linespec.c   |  2 +-
 gdb/maint.c      |  2 +-
 gdb/minsyms.c    | 10 +++++-----
 gdb/parse.c      |  5 ++---
 gdb/printcmd.c   |  6 +++---
 gdb/symmisc.c    |  4 ++--
 gdb/symtab.c     | 21 +++++++++++++++------
 gdb/symtab.h     | 14 ++++++--------
 12 files changed, 73 insertions(+), 43 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c20c0d7d649..5f1914e0eb7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9677,8 +9677,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
 	  if (sym != NULL)
 	    {
 	      fixup_symbol_section (sym, SYMTAB_OBJFILE (sal->symtab));
-	      sal->section = SYMBOL_OBJ_SECTION (SYMTAB_OBJFILE (sal->symtab),
-						 sym);
+	      sal->section = sym->obj_section (SYMTAB_OBJFILE (sal->symtab));
 	    }
 	  else
 	    {
@@ -9692,7 +9691,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
 
 	      bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (sal->pc);
 	      if (msym.minsym)
-		sal->section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
+		sal->section = msym.minsym->obj_section (msym.objfile);
 	    }
 	}
     }
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 6abcd3a946f..fcd97191c14 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -638,11 +638,9 @@ language_defn::read_var_value (struct symbol *var,
       v = allocate_value (type);
       if (overlay_debugging)
 	{
-	  addr
-	    = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
-					SYMBOL_OBJ_SECTION (symbol_objfile (var),
-							    var));
-
+	  struct objfile *var_objfile = symbol_objfile (var);
+	  addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+					   var->obj_section (var_objfile));
 	  store_typed_address (value_contents_raw (v), type, addr);
 	}
       else
@@ -665,9 +663,9 @@ language_defn::read_var_value (struct symbol *var,
 
     case LOC_STATIC:
       if (overlay_debugging)
-	addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
-					 SYMBOL_OBJ_SECTION (symbol_objfile (var),
-							     var));
+	addr
+	  = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+				      var->obj_section (symbol_objfile (var)));
       else
 	addr = SYMBOL_VALUE_ADDRESS (var);
       break;
@@ -709,7 +707,7 @@ language_defn::read_var_value (struct symbol *var,
       if (overlay_debugging)
 	addr = symbol_overlayed_address
 	  (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)),
-	   SYMBOL_OBJ_SECTION (symbol_objfile (var), var));
+	   var->obj_section (symbol_objfile (var)));
       else
 	addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var));
       break;
@@ -777,7 +775,7 @@ language_defn::read_var_value (struct symbol *var,
 	    error (_("Missing %s symbol \"%s\"."),
 		   flavour_name, var->linkage_name ());
 	  }
-	obj_section = MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym);
+	obj_section = msym->obj_section (lookup_data.result.objfile);
 	/* Relocate address, unless there is no section or the variable is
 	   a TLS variable. */
 	if (obj_section == NULL
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index ebaf57592ef..80e6ad3048f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1110,7 +1110,7 @@ jump_command (const char *arg, int from_tty)
       struct obj_section *section;
 
       fixup_symbol_section (sfn, 0);
-      section = SYMBOL_OBJ_SECTION (symbol_objfile (sfn), sfn);
+      section = sfn->obj_section (symbol_objfile (sfn));
       if (section_is_overlay (section)
 	  && !section_is_mapped (section))
 	{
diff --git a/gdb/linespec.c b/gdb/linespec.c
index a9809a5dc78..9bfa159514e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4258,7 +4258,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
       sal.pspace = current_program_space;
     }
 
-  sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
+  sal.section = msymbol->obj_section (objfile);
 
   if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
     add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0);
diff --git a/gdb/maint.c b/gdb/maint.c
index d718d707134..7495cab0ec0 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -509,7 +509,7 @@ maintenance_translate_address (const char *arg, int from_tty)
       const char *symbol_offset
 	= pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym));
 
-      sect = MSYMBOL_OBJ_SECTION(sym.objfile, sym.minsym);
+      sect = sym.minsym->obj_section (sym.objfile);
       if (sect != NULL)
 	{
 	  const char *section_name;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 5c719f902ba..b861f939fdb 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -800,9 +800,9 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 		      /* Some types of debug info, such as COFF,
 			 don't fill the bfd_section member, so don't
 			 throw away symbols on those platforms.  */
-		      && MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) != NULL
+		      && msymbol[hi].obj_section (objfile) != nullptr
 		      && (!matching_obj_sections
-			  (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]),
+			  (msymbol[hi].obj_section (objfile),
 			   section)))
 		    {
 		      hi--;
@@ -820,8 +820,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 			  == MSYMBOL_SIZE (&msymbol[hi - 1]))
 		      && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi])
 			  == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi - 1]))
-		      && (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi])
-			  == MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1])))
+		      && (msymbol[hi].obj_section (objfile)
+			  == msymbol[hi - 1].obj_section (objfile)))
 		    {
 		      hi--;
 		      continue;
@@ -1560,7 +1560,7 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
 	break;
     }
 
-  obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
+  obj_section = minsym.minsym->obj_section (minsym.objfile);
   if (iter != past_the_end
       && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter)
 	  < obj_section_endaddr (obj_section)))
diff --git a/gdb/parse.c b/gdb/parse.c
index 08fde89d8f3..d634a4f736c 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -416,7 +416,7 @@ find_minsym_type_and_address (minimal_symbol *msymbol,
 			      CORE_ADDR *address_p)
 {
   bound_minimal_symbol bound_msym = {msymbol, objfile};
-  struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
+  struct obj_section *section = msymbol->obj_section (objfile);
   enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol);
 
   bool is_tls = (section != NULL
@@ -1359,8 +1359,7 @@ operator_check_standard (struct expression *exp, int pos,
 	const struct block *const block = elts[pos + 1].block;
 	const struct symbol *const symbol = elts[pos + 2].symbol;
 
-	/* Check objfile where the variable itself is placed.
-	   SYMBOL_OBJ_SECTION (symbol) may be NULL.  */
+	/* Check objfile where the variable itself is placed.  */
 	if ((*objfile_func) (symbol_objfile (symbol), data))
 	  return 1;
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 332d971a05c..1e328a71160 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1534,7 +1534,7 @@ info_address_command (const char *exp, int from_tty)
 	  fputs_styled (paddress (gdbarch, load_addr), address_style.style (),
 			gdb_stdout);
 	  printf_filtered (" in a file compiled without debugging");
-	  section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
+	  section = msymbol.minsym->obj_section (objfile);
 	  if (section_is_overlay (section))
 	    {
 	      load_addr = overlay_unmapped_address (load_addr, section);
@@ -1558,7 +1558,7 @@ info_address_command (const char *exp, int from_tty)
   printf_filtered ("\" is ");
   val = SYMBOL_VALUE (sym);
   if (SYMBOL_OBJFILE_OWNED (sym))
-    section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym);
+    section = sym->obj_section (symbol_objfile (sym));
   else
     section = NULL;
   gdbarch = symbol_arch (sym);
@@ -1678,7 +1678,7 @@ info_address_command (const char *exp, int from_tty)
 	  printf_filtered ("unresolved");
 	else
 	  {
-	    section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
+	    section = msym.minsym->obj_section (msym.objfile);
 
 	    if (section
 		&& (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index fe353bc0ff7..ec4758c264e 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -196,7 +196,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
   index = 0;
   for (minimal_symbol *msymbol : objfile->msymbols ())
     {
-      struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
+      struct obj_section *section = msymbol->obj_section (objfile);
 
       switch (MSYMBOL_TYPE (msymbol))
 	{
@@ -543,7 +543,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
   struct obj_section *section;
 
   if (SYMBOL_OBJFILE_OWNED (symbol))
-    section = SYMBOL_OBJ_SECTION (symbol_objfile (symbol), symbol);
+    section = symbol->obj_section (symbol_objfile (symbol));
   else
     section = NULL;
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7ffb52a9435..9ad7c1f589d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1012,6 +1012,16 @@ general_symbol_info::search_name () const
 
 /* See symtab.h.  */
 
+struct obj_section *
+general_symbol_info::obj_section (const struct objfile *objfile) const
+{
+  if (section >= 0)
+    return &objfile->sections[section];
+  return nullptr;
+}
+
+/* See symtab.h.  */
+
 bool
 symbol_matches_search_name (const struct general_symbol_info *gsymbol,
 			    const lookup_name_info &name)
@@ -1730,7 +1740,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
   if (objfile == NULL)
     objfile = symbol_objfile (sym);
 
-  if (SYMBOL_OBJ_SECTION (objfile, sym))
+  if (sym->obj_section (objfile) != nullptr)
     return sym;
 
   /* We should have an objfile by now.  */
@@ -2972,8 +2982,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
 		  ALL_BLOCK_SYMBOLS (b, iter, sym)
 		    {
 		      fixup_symbol_section (sym, obj_file);
-		      if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file,
-								     sym),
+		      if (matching_obj_sections (sym->obj_section (obj_file),
 						 section))
 			break;
 		    }
@@ -3732,7 +3741,7 @@ find_function_start_sal (symbol *sym, bool funfirstline)
   fixup_symbol_section (sym, NULL);
   symtab_and_line sal
     = find_function_start_sal_1 (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)),
-				 SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym),
+				 sym->obj_section (symbol_objfile (sym)),
 				 funfirstline);
   sal.symbol = sym;
   return sal;
@@ -3823,7 +3832,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 
       objfile = symbol_objfile (sym);
       pc = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
-      section = SYMBOL_OBJ_SECTION (objfile, sym);
+      section = sym->obj_section (objfile);
       name = sym->linkage_name ();
     }
   else
@@ -3836,7 +3845,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 
       objfile = msymbol.objfile;
       pc = BMSYMBOL_VALUE_ADDRESS (msymbol);
-      section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
+      section = msymbol.minsym->obj_section (objfile);
       name = msymbol.minsym->linkage_name ();
     }
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f060e0ebc15..e85ae684c71 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -540,6 +540,12 @@ struct general_symbol_info
      does not get relocated relative to a section.  */
 
   short section;
+
+  /* Return the obj_section from OBJFILE for this symbol.  The symbol
+     returned is based on the SECTION member variable, and can be nullptr
+     if SECTION is negative.  */
+
+  struct obj_section *obj_section (const struct objfile *objfile) const;
 };
 
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
@@ -565,10 +571,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
 #define SYMBOL_BLOCK_VALUE(symbol)	(symbol)->value.block
 #define SYMBOL_VALUE_CHAIN(symbol)	(symbol)->value.chain
 #define SYMBOL_SECTION(symbol)		(symbol)->section
-#define SYMBOL_OBJ_SECTION(objfile, symbol)			\
-  (((symbol)->section >= 0)				\
-   ? (&(((objfile)->sections)[(symbol)->section]))	\
-   : NULL)
 
 /* Try to determine the demangled name for a symbol, based on the
    language of that symbol.  If the language is set to language_auto,
@@ -763,10 +765,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_BLOCK_VALUE(symbol)	(symbol)->value.block
 #define MSYMBOL_VALUE_CHAIN(symbol)	(symbol)->value.chain
 #define MSYMBOL_SECTION(symbol)		(symbol)->section
-#define MSYMBOL_OBJ_SECTION(objfile, symbol)			\
-  (((symbol)->section >= 0)				\
-   ? (&(((objfile)->sections)[(symbol)->section]))	\
-   : NULL)
 
 #include "minsyms.h"
 
-- 
2.25.4


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

* [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros
  2021-02-08  9:55 [PATCH 0/2] Remove a couple of SYMBOL related macros Andrew Burgess
  2021-02-08  9:55 ` [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION Andrew Burgess
@ 2021-02-08  9:55 ` Andrew Burgess
  2021-02-09 20:29   ` Tom Tromey
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-02-08  9:55 UTC (permalink / raw)
  To: gdb-patches

Delete two more symbol/section related macros.  This time it's
SYMBOL_SECTION and MSYMBOL_SECTION.

As with general_symbol_info::m_name it is not currently possible to
make general_symbol_info::m_section private as general_symbol_info
must remain a POD type.

But other than failing to make the new m_section private, this change
does what you'd expect, adds a get and set member function and updates
all users to use the new functions instead of the previous wrapper
macros.

There should be no user visible change after this commit.

gdb/ChangeLog:

	* coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
	and set_section_index member functions where appropriate.
	* coffread.c (coff_symtab_read): Likewise.
	(process_coff_symbol): Likewise.
	* ctfread.c (set_symbol_address): Likewise.
	* dwarf2/read.c (add_partial_symbol): Likewise.
	(var_decode_location): Likewise.
	* language.c: Likewise.
	* minsyms.c (minimal_symbol_reader::record_full): Likewise.
	(compact_minimal_symbols): Likewise.
	(minimal_symbol_upper_bound): Likewise.
	* objfiles.c (relocate_one_symbol): Likewise.
	* psympriv.h (partial_symbol::obj_section): Likewise.
	(partial_symbol::address): Likewise.
	* psymtab.c (partial_symtab::add_psymbol): Likewise.
	* stabsread.c (scan_file_globals): Likewise.
	* symmisc.c (dump_msymbols): Likewise.
	* symtab.c (general_symbol_info::obj_section): Likewise.
	(fixup_section): Likewise.
	(get_msymbol_address): Likewise.
	* symtab.h (general_symbol_info::section): Rename to...
	(general_symbol_info::m_section): ...this.
	(general_symbol_info::set_section_index): New member function.
	(general_symbol_info::section_index): Likewise.
	(SYMBOL_SECTION): Delete.
	(MSYMBOL_VALUE_ADDRESS): Make use of section_index and
	set_section_index member functions where appropriate.
	(MSYMBOL_SECTION): Delete.
	(symbol::symbol): Update to initialize 'm_section'.
	* xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
	(process_xcoff_symbol): Likewise.
---
 gdb/ChangeLog      | 34 ++++++++++++++++++++++++++++++++++
 gdb/coff-pe-read.c |  2 +-
 gdb/coffread.c     |  4 ++--
 gdb/ctfread.c      |  2 +-
 gdb/dwarf2/read.c  | 10 +++++-----
 gdb/language.c     |  2 +-
 gdb/minsyms.c      |  9 +++++----
 gdb/objfiles.c     |  4 ++--
 gdb/psympriv.h     |  7 +++----
 gdb/psymtab.c      |  2 +-
 gdb/stabsread.c    |  2 +-
 gdb/symmisc.c      |  2 +-
 gdb/symtab.c       | 15 ++++++++-------
 gdb/symtab.h       | 22 +++++++++++++++++-----
 gdb/xcoffread.c    |  8 ++++----
 15 files changed, 86 insertions(+), 39 deletions(-)

diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 70eb7a04251..90b406f140e 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -246,7 +246,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
 
   vma = BMSYMBOL_VALUE_ADDRESS (msymbol);
   msymtype = MSYMBOL_TYPE (msymbol.minsym);
-  section = MSYMBOL_SECTION (msymbol.minsym);
+  section = msymbol.minsym->section_index ();
 
   /* Generate a (hopefully unique) qualified name using the first part
      of the dll name, e.g. KERNEL32!AddAtomA.  This matches the style
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 77752bc9111..49a2485d38c 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1026,7 +1026,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
 		sym = process_coff_symbol
 		  (cs, &main_aux, objfile);
 		SYMBOL_VALUE (sym) = tmpaddr + offset;
-		SYMBOL_SECTION (sym) = sec;
+		sym->set_section_index (sec);
 	      }
 	  }
 	  break;
@@ -1565,7 +1565,7 @@ process_coff_symbol (struct coff_symbol *cs,
   /* default assumptions */
   SYMBOL_VALUE (sym) = cs->c_value;
   SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-  SYMBOL_SECTION (sym) = cs_to_section (cs, objfile);
+  sym->set_section_index (cs_to_section (cs, objfile));
 
   if (ISFCN (cs->c_type))
     {
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 866977a43cd..928cb3025c3 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -297,7 +297,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym, BMSYMBOL_VALUE_ADDRESS (msym));
       SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
-      SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msym.minsym);
+      sym->set_section_index (msym.minsym->section_index ());
     }
 }
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3f60ce6a4f1..e42f1d1a7e6 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8612,7 +8612,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
   partial_symbol psymbol;
   memset (&psymbol, 0, sizeof (psymbol));
   psymbol.ginfo.set_language (cu->language, &objfile->objfile_obstack);
-  psymbol.ginfo.section = -1;
+  psymbol.ginfo.set_section_index (-1);
 
   /* The code below indicates that the psymbol should be installed by
      setting this.  */
@@ -8641,7 +8641,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 
       psymbol.domain = VAR_DOMAIN;
       psymbol.aclass = LOC_BLOCK;
-      psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+      psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
       psymbol.ginfo.value.address = addr;
 
       if (pdi->main_subprogram && actual_name != NULL)
@@ -8686,7 +8686,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 	    {
 	      psymbol.domain = VAR_DOMAIN;
 	      psymbol.aclass = LOC_STATIC;
-	      psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+	      psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
 	      psymbol.ginfo.value.address = addr;
 	      where = psymbol_placement::GLOBAL;
 	    }
@@ -8702,7 +8702,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
 
 	  psymbol.domain = VAR_DOMAIN;
 	  psymbol.aclass = LOC_STATIC;
-	  psymbol.ginfo.section = SECT_OFF_TEXT (objfile);
+	  psymbol.ginfo.set_section_index (SECT_OFF_TEXT (objfile));
 	  if (has_loc)
 	    psymbol.ginfo.value.address = addr;
 	  where = psymbol_placement::STATIC;
@@ -22090,7 +22090,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
 	  SET_SYMBOL_VALUE_ADDRESS
 	    (sym,
 	     SYMBOL_VALUE_ADDRESS (sym)
-	     + objfile->section_offsets[SYMBOL_SECTION (sym)]);
+	     + objfile->section_offsets[sym->section_index ()]);
 	  return;
 	}
     }
diff --git a/gdb/language.c b/gdb/language.c
index c23f29169ae..0eff76e12f4 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1052,7 +1052,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->set_language (lang, nullptr);
   symbol->owner.arch = gdbarch;
   SYMBOL_OBJFILE_OWNED (symbol) = 0;
-  SYMBOL_SECTION (symbol) = 0;
+  symbol->set_section_index (0);
   SYMBOL_TYPE (symbol) = type;
   SYMBOL_DOMAIN (symbol) = VAR_DOMAIN;
   SYMBOL_ACLASS_INDEX (symbol) = LOC_TYPEDEF;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index b861f939fdb..8b8e11a83d0 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1157,7 +1157,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
     msymbol->m_name = name.data ();
 
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
-  MSYMBOL_SECTION (msymbol) = section;
+  msymbol->set_section_index (section);
 
   MSYMBOL_TYPE (msymbol) = ms_type;
 
@@ -1246,7 +1246,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
 	{
 	  if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom)
 	      == MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1))
-	      && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1)
+	      && (copyfrom->section_index ()
+		  == (copyfrom + 1)->section_index ())
 	      && strcmp (copyfrom->linkage_name (),
 			 (copyfrom + 1)->linkage_name ()) == 0)
 	    {
@@ -1551,12 +1552,12 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
     = (minsym.objfile->per_bfd->msymbols.get ()
        + minsym.objfile->per_bfd->minimal_symbol_count);
   msymbol = minsym.minsym;
-  section = MSYMBOL_SECTION (msymbol);
+  section = msymbol->section_index ();
   for (iter = msymbol + 1; iter != past_the_end; ++iter)
     {
       if ((MSYMBOL_VALUE_RAW_ADDRESS (iter)
 	   != MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
-	  && MSYMBOL_SECTION (iter) == section)
+	  && iter->section_index () == section)
 	break;
     }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 18dc8fabaf1..2a513d82f1a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -621,11 +621,11 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
      they can't possibly pass the tests below.  */
   if ((SYMBOL_CLASS (sym) == LOC_LABEL
        || SYMBOL_CLASS (sym) == LOC_STATIC)
-      && SYMBOL_SECTION (sym) >= 0)
+      && sym->section_index () >= 0)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym,
 				SYMBOL_VALUE_ADDRESS (sym)
-				+ delta[SYMBOL_SECTION (sym)]);
+				+ delta[sym->section_index ()]);
     }
 }
 
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index b5080e37370..1f35ef2a44b 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -40,9 +40,7 @@ struct partial_symbol
      section has been set.  */
   struct obj_section *obj_section (struct objfile *objfile) const
   {
-    if (ginfo.section >= 0)
-      return &objfile->sections[ginfo.section];
-    return nullptr;
+    return ginfo.obj_section (objfile);
   }
 
   /* Return the unrelocated address of this partial symbol.  */
@@ -55,7 +53,8 @@ struct partial_symbol
      the offsets provided in OBJFILE.  */
   CORE_ADDR address (const struct objfile *objfile) const
   {
-    return ginfo.value.address + objfile->section_offsets[ginfo.section];
+    return (ginfo.value.address
+	    + objfile->section_offsets[ginfo.section_index ()]);
   }
 
   /* Set the address of this partial symbol.  The address must be
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 58fd067905d..7f41c010e39 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1556,7 +1556,7 @@ partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
   memset (&psymbol, 0, sizeof (psymbol));
 
   psymbol.set_unrelocated_address (coreaddr);
-  psymbol.ginfo.section = section;
+  psymbol.ginfo.set_section_index (section);
   psymbol.domain = domain;
   psymbol.aclass = theclass;
   psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 33f200abf59..d83f4b40a6a 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -4590,7 +4590,7 @@ scan_file_globals (struct objfile *objfile)
 			    (sym, MSYMBOL_VALUE_ADDRESS (resolve_objfile,
 							 msymbol));
 			}
-		      SYMBOL_SECTION (sym) = MSYMBOL_SECTION (msymbol);
+		      sym->set_section_index (msymbol->section_index ());
 		    }
 
 		  if (prev)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index ec4758c264e..3703e50c6de 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -240,7 +240,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       /* Use the relocated address as shown in the symbol here -- do
 	 not try to respect copy relocations.  */
       CORE_ADDR addr = (msymbol->value.address
-			+ objfile->section_offsets[msymbol->section]);
+			+ objfile->section_offsets[msymbol->section_index ()]);
       fputs_filtered (paddress (gdbarch, addr), outfile);
       fprintf_filtered (outfile, " %s", msymbol->linkage_name ());
       if (section)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9ad7c1f589d..3650b49832e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1015,8 +1015,8 @@ general_symbol_info::search_name () const
 struct obj_section *
 general_symbol_info::obj_section (const struct objfile *objfile) const
 {
-  if (section >= 0)
-    return &objfile->sections[section];
+  if (section_index () >= 0)
+    return &objfile->sections[section_index ()];
   return nullptr;
 }
 
@@ -1655,7 +1655,7 @@ fixup_section (struct general_symbol_info *ginfo,
   msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
 					   objfile);
   if (msym)
-    ginfo->section = MSYMBOL_SECTION (msym);
+    ginfo->set_section_index (msym->section_index ());
   else
     {
       /* Static, function-local variables do appear in the linker
@@ -1707,7 +1707,7 @@ fixup_section (struct general_symbol_info *ginfo,
 	  if (obj_section_addr (s) - offset <= addr
 	      && addr < obj_section_endaddr (s) - offset)
 	    {
-	      ginfo->section = idx;
+	      ginfo->set_section_index (idx);
 	      return;
 	    }
 	}
@@ -1716,9 +1716,9 @@ fixup_section (struct general_symbol_info *ginfo,
 	 section.  If there is no allocated section, then it hardly
 	 matters what we pick, so just pick zero.  */
       if (fallback == -1)
-	ginfo->section = 0;
+	ginfo->set_section_index (0);
       else
-	ginfo->section = fallback;
+	ginfo->set_section_index (fallback);
     }
 }
 
@@ -6472,7 +6472,8 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
 	    return BMSYMBOL_VALUE_ADDRESS (found);
 	}
     }
-  return minsym->value.address + objf->section_offsets[minsym->section];
+  return (minsym->value.address
+	  + objf->section_offsets[minsym->section_index ()]);
 }
 
 \f
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e85ae684c71..efdbada9761 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -539,7 +539,21 @@ struct general_symbol_info
      section_offsets for this objfile.  Negative means that the symbol
      does not get relocated relative to a section.  */
 
-  short section;
+  short m_section;
+
+  /* Set the index into the obj_section list (within the containing
+     objfile) for the section that contains this symbol.  See M_SECTION
+     for more details.  */
+
+  void set_section_index (short idx)
+  { m_section = idx; }
+
+  /* Return the index into the obj_section list (within the containing
+     objfile) for the section that contains this symbol.  See M_SECTION
+     for more details.  */
+
+  short section_index () const
+  { return m_section; }
 
   /* Return the obj_section from OBJFILE for this symbol.  The symbol
      returned is based on the SECTION member variable, and can be nullptr
@@ -570,7 +584,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
 #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
 #define SYMBOL_BLOCK_VALUE(symbol)	(symbol)->value.block
 #define SYMBOL_VALUE_CHAIN(symbol)	(symbol)->value.chain
-#define SYMBOL_SECTION(symbol)		(symbol)->section
 
 /* Try to determine the demangled name for a symbol, based on the
    language of that symbol.  If the language is set to language_auto,
@@ -755,7 +768,7 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)				\
   (((symbol)->maybe_copied) ? get_msymbol_address (objfile, symbol)	\
    : ((symbol)->value.address						\
-      + (objfile)->section_offsets[(symbol)->section]))
+      + (objfile)->section_offsets[(symbol)->section_index ()]))
 /* For a bound minsym, we can easily compute the address directly.  */
 #define BMSYMBOL_VALUE_ADDRESS(symbol) \
   MSYMBOL_VALUE_ADDRESS ((symbol).objfile, (symbol).minsym)
@@ -764,7 +777,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf,
 #define MSYMBOL_VALUE_BYTES(symbol)	(symbol)->value.bytes
 #define MSYMBOL_BLOCK_VALUE(symbol)	(symbol)->value.block
 #define MSYMBOL_VALUE_CHAIN(symbol)	(symbol)->value.chain
-#define MSYMBOL_SECTION(symbol)		(symbol)->section
 
 #include "minsyms.h"
 
@@ -1118,7 +1130,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       language_specific.obstack = nullptr;
       m_language = language_unknown;
       ada_mangled = 0;
-      section = -1;
+      m_section = -1;
       /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
 	 initialization of unions, so we initialize it manually here.  */
       owner.symtab = nullptr;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 8a2348c1df5..cd93943a812 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1372,7 +1372,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
 		(fcn_cs_saved.c_value + off,
 		 fcn_stab_saved.c_name, 0, 0, objfile);
 	      if (newobj->name != NULL)
-		SYMBOL_SECTION (newobj->name) = SECT_OFF_TEXT (objfile);
+		newobj->name->set_section_index (SECT_OFF_TEXT (objfile));
 	    }
 	  else if (strcmp (cs->c_name, ".ef") == 0)
 	    {
@@ -1559,7 +1559,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
   /* default assumptions */
   SET_SYMBOL_VALUE_ADDRESS (sym, cs->c_value + off);
   SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-  SYMBOL_SECTION (sym) = secnum_to_section (cs->c_secnum, objfile);
+  sym->set_section_index (secnum_to_section (cs->c_secnum, objfile));
 
   if (ISFCN (cs->c_type))
     {
@@ -1625,7 +1625,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
 	    sym = define_symbol (cs->c_value + off, cs->c_name, 0, 0, objfile);
 	    if (sym != NULL)
 	      {
-		SYMBOL_SECTION (sym) = sec;
+		sym->set_section_index (sec);
 	      }
 	    return sym;
 	  }
@@ -1657,7 +1657,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
 	      SET_SYMBOL_VALUE_ADDRESS (sym,
 					SYMBOL_VALUE_ADDRESS (sym)
 					+ static_block_base);
-	      SYMBOL_SECTION (sym) = static_block_section;
+	      sym->set_section_index (static_block_section);
 	    }
 	  return sym;
 
-- 
2.25.4


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

* Re: [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
  2021-02-08  9:55 ` [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION Andrew Burgess
@ 2021-02-09 20:27   ` Tom Tromey
  2021-02-10 16:18     ` Andrew Burgess
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2021-02-09 20:27 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> Replace the two macros SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION with
Andrew> a member function on general_symbol_info.

Andrew> There should be no user visible change after this commit.

Looks good.

Andrew> -		sal->section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
Andrew> +		sal->section = msym.minsym->obj_section (msym.objfile);

This kind of transform could be a little simpler if an obj_section
helper method were added to bound_minimal_symbol.
I don't know if this happens enough to be worth doing.

Tom

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

* Re: [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros
  2021-02-08  9:55 ` [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros Andrew Burgess
@ 2021-02-09 20:29   ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-02-09 20:29 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> Delete two more symbol/section related macros.  This time it's
Andrew> SYMBOL_SECTION and MSYMBOL_SECTION.

Andrew> As with general_symbol_info::m_name it is not currently possible to
Andrew> make general_symbol_info::m_section private as general_symbol_info
Andrew> must remain a POD type.

Andrew> But other than failing to make the new m_section private, this change
Andrew> does what you'd expect, adds a get and set member function and updates
Andrew> all users to use the new functions instead of the previous wrapper
Andrew> macros.

Andrew> There should be no user visible change after this commit.

Looks good.  Thanks for doing this.

Tom

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

* Re: [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
  2021-02-09 20:27   ` Tom Tromey
@ 2021-02-10 16:18     ` Andrew Burgess
  2021-02-10 17:06       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2021-02-10 16:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey <tom@tromey.com> [2021-02-09 13:27:59 -0700]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
> 
> Andrew> Replace the two macros SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION with
> Andrew> a member function on general_symbol_info.
> 
> Andrew> There should be no user visible change after this commit.
> 
> Looks good.
> 
> Andrew> -		sal->section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym);
> Andrew> +		sal->section = msym.minsym->obj_section (msym.objfile);
> 
> This kind of transform could be a little simpler if an obj_section
> helper method were added to bound_minimal_symbol.
> I don't know if this happens enough to be worth doing.

It doesn't happen often, but it does look a little neater.

How about the patch below?

Thank,
Andrew

---

commit 19e02488fe90ffcb2440c56ea6da105dea20ce36
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Wed Feb 10 15:07:04 2021 +0000

    gdb: add obj_section function to bound_minimal_symbol
    
    Add a new obj_section function to bound_minimal_symbol, this just
    calls obj_section on the contained minimal_symbol passing in the
    contained objfile.
    
    This allows some minor code simplification in a few places.
    
    There should be no user visible changes after this commit.
    
    gdb/ChangeLog:
    
            * breakpoint.c (resolve_sal_pc): Make use of
            bound_minimal_symbol::obj_section.
            * maint.c (maintenance_translate_address): Likewise.
            * minsyms.c (minimal_symbol_upper_bound): Likewise.
            * minsyms.h (struct bound_minimal_symbol) <obj_section>: New
            member function.
            * printcmd.c (info_address_command): Make use of
            bound_minimal_symbol::obj_section.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5f1914e0eb7..e9aba79e40f 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9691,7 +9691,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
 
 	      bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (sal->pc);
 	      if (msym.minsym)
-		sal->section = msym.minsym->obj_section (msym.objfile);
+		sal->section = msym.obj_section ();
 	    }
 	}
     }
diff --git a/gdb/maint.c b/gdb/maint.c
index 7495cab0ec0..f6e42f6a7e3 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -509,7 +509,7 @@ maintenance_translate_address (const char *arg, int from_tty)
       const char *symbol_offset
 	= pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym));
 
-      sect = sym.minsym->obj_section (sym.objfile);
+      sect = sym.obj_section ();
       if (sect != NULL)
 	{
 	  const char *section_name;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 8b8e11a83d0..3cf849f48bf 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1561,7 +1561,7 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
 	break;
     }
 
-  obj_section = minsym.minsym->obj_section (minsym.objfile);
+  obj_section = minsym.obj_section ();
   if (iter != past_the_end
       && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter)
 	  < obj_section_endaddr (obj_section)))
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 75de98c7554..7f218719d46 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -37,6 +37,13 @@ struct bound_minimal_symbol
      symbol is defined.  */
 
   struct objfile *objfile;
+
+  /* Return the obj_section from OBJFILE for MINSYM.  */
+
+  struct obj_section *obj_section () const
+  {
+    return minsym->obj_section (objfile);
+  }
 };
 
 /* This header declares most of the API for dealing with minimal
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 1e328a71160..58e39c7365f 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1678,7 +1678,7 @@ info_address_command (const char *exp, int from_tty)
 	  printf_filtered ("unresolved");
 	else
 	  {
-	    section = msym.minsym->obj_section (msym.objfile);
+	    section = msym.obj_section ();
 
 	    if (section
 		&& (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)

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

* Re: [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
  2021-02-10 16:18     ` Andrew Burgess
@ 2021-02-10 17:06       ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-02-10 17:06 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> How about the patch below?

I like it.  Thank you.

Tom

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

end of thread, other threads:[~2021-02-10 17:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08  9:55 [PATCH 0/2] Remove a couple of SYMBOL related macros Andrew Burgess
2021-02-08  9:55 ` [PATCH 1/2] gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION Andrew Burgess
2021-02-09 20:27   ` Tom Tromey
2021-02-10 16:18     ` Andrew Burgess
2021-02-10 17:06       ` Tom Tromey
2021-02-08  9:55 ` [PATCH 2/2] gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros Andrew Burgess
2021-02-09 20:29   ` Tom Tromey

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).