Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 00/33] Remove some more accessor macros
@ 2022-01-28 12:44 Simon Marchi via Gdb-patches
  2022-01-28 12:44 ` [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi via Gdb-patches
                   ` (33 more replies)
  0 siblings, 34 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:44 UTC (permalink / raw)
  To: gdb-patches

Most of this is mechanical, so probably doesn't need too much review.
But there are some changes near the beginning that move compunit
functions and methods, that's probably worth looking at.

Simon Marchi (33):
  gdb: add getter/setter for compunit_symtab::objfile
  gdb: remove COMPUNIT_OBJFILE macro
  gdb: rename compunit_primary_filetab to
    compunit_symtab::primary_filetab
  gdb: add compunit_symtab::add_filetab method
  gdb: add compunit_symtab::set_primary_filetab method
  gdb: move compunit_filetabs to compunit_symtab::filetabs
  gdb: remove COMPUNIT_FILETABS macro
  gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter
  gdb: remove COMPUNIT_PRODUCER macro, add getter/setter
  gdb: remove COMPUNIT_DIRNAME macro, add getter/setter
  gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter
  gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
  gdb: remove COMPUNIT_LOCATIONS_VALID macro, add getter/setter
  gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID macro, add getter/setter
  gdb: remove COMPUNIT_MACRO_TABLE macro, add getter/setter
  gdb: remove SYMTAB_COMPUNIT macro, add getter/setter
  gdb: remove SYMTAB_LINETABLE macro, add getter/setter
  gdb: remove SYMTAB_LANGUAGE macro, add getter/setter
  gdb: remove SYMTAB_BLOCKVECTOR macro
  gdb: remove SYMTAB_OBJFILE macro
  gdb: remove SYMTAB_PSPACE macro
  gdb: remove SYMTAB_DIRNAME macro
  gdb: remove SYMBOL_MATCHES_SEARCH_NAME
  gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter
  gdb: remove SYMBOL_IMPL macro, add method
  gdb: remove SYMBOL_CLASS macro, add getter
  gdb: remove SYMBOL_DOMAIN macro
  gdb: remove SYMBOL_OBJFILE_OWNED macro
  gdb: remove SYMBOL_IS_ARGUMENT macro
  gdb: remove SYMBOL_INLINED macro
  gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro
  gdb: remove SYMBOL_TYPE macro
  gdb: remove SYMBOL_LINE macro

 gdb/ada-exp.y                       |  30 +--
 gdb/ada-lang.c                      | 154 ++++++------
 gdb/ada-tasks.c                     |  24 +-
 gdb/amd64-tdep.c                    |  12 +-
 gdb/annotate.c                      |   4 +-
 gdb/arm-tdep.c                      |   6 +-
 gdb/ax-gdb.c                        |   4 +-
 gdb/block.c                         |  42 ++--
 gdb/blockframe.c                    |   2 +-
 gdb/breakpoint.c                    |  10 +-
 gdb/buildsym-legacy.c               |   4 +-
 gdb/buildsym.c                      |  66 ++---
 gdb/c-exp.y                         |  20 +-
 gdb/c-typeprint.c                   |  10 +-
 gdb/c-valprint.c                    |   2 +-
 gdb/cli/cli-cmds.c                  |   8 +-
 gdb/coffread.c                      |  74 +++---
 gdb/compile/compile-c-symbols.c     |  24 +-
 gdb/compile/compile-cplus-symbols.c |  26 +-
 gdb/compile/compile-cplus-types.c   |  14 +-
 gdb/compile/compile-object-load.c   |  10 +-
 gdb/compile/compile-object-run.c    |   2 +-
 gdb/compile/compile.c               |   8 +-
 gdb/cp-namespace.c                  |   6 +-
 gdb/cp-support.c                    |  14 +-
 gdb/ctfread.c                       |  40 +--
 gdb/d-exp.y                         |  12 +-
 gdb/d-namespace.c                   |   4 +-
 gdb/disasm.c                        |  16 +-
 gdb/dwarf2/frame.c                  |   2 +-
 gdb/dwarf2/loc.c                    |  20 +-
 gdb/dwarf2/read.c                   | 126 +++++-----
 gdb/eval.c                          |  20 +-
 gdb/expop.h                         |   2 +-
 gdb/f-exp.y                         |   4 +-
 gdb/f-valprint.c                    |   4 +-
 gdb/fbsd-tdep.c                     |   4 +-
 gdb/findvar.c                       |   8 +-
 gdb/frame.c                         |   4 +-
 gdb/gdbtypes.c                      |  28 +--
 gdb/gnu-v3-abi.c                    |   2 +-
 gdb/go-exp.y                        |   6 +-
 gdb/guile/scm-block.c               |   8 +-
 gdb/guile/scm-symbol.c              |  24 +-
 gdb/guile/scm-symtab.c              |  12 +-
 gdb/i386-tdep.c                     |   8 +-
 gdb/infcmd.c                        |   6 +-
 gdb/infrun.c                        |   2 +-
 gdb/jit.c                           |  21 +-
 gdb/language.c                      |  10 +-
 gdb/linespec.c                      |  78 +++---
 gdb/m2-exp.y                        |   6 +-
 gdb/m2-typeprint.c                  |   4 +-
 gdb/macroscope.c                    |   7 +-
 gdb/macrotab.c                      |   2 +-
 gdb/maint.c                         |   6 +-
 gdb/mdebugread.c                    | 149 +++++------
 gdb/mi/mi-cmd-file.c                |   2 +-
 gdb/mi/mi-cmd-stack.c               |  18 +-
 gdb/mi/mi-symbol-cmds.c             |  16 +-
 gdb/mips-tdep.c                     |   2 +-
 gdb/objc-lang.c                     |   4 +-
 gdb/objfiles.c                      |  16 +-
 gdb/or1k-tdep.c                     |   4 +-
 gdb/p-exp.y                         |  16 +-
 gdb/p-valprint.c                    |   2 +-
 gdb/parse.c                         |   2 +-
 gdb/printcmd.c                      |   6 +-
 gdb/psymtab.c                       |   4 +-
 gdb/python/py-finishbreakpoint.c    |   2 +-
 gdb/python/py-framefilter.c         |   6 +-
 gdb/python/py-linetable.c           |  20 +-
 gdb/python/py-progspace.c           |   6 +-
 gdb/python/py-symbol.c              |  28 +--
 gdb/python/py-symtab.c              |  28 +--
 gdb/python/py-type.c                |   6 +-
 gdb/record-btrace.c                 |   2 +-
 gdb/rust-lang.c                     |   2 +-
 gdb/rust-parse.c                    |   8 +-
 gdb/source-cache.c                  |   4 +-
 gdb/source.c                        |  43 ++--
 gdb/sparc-tdep.c                    |   2 +-
 gdb/stabsread.c                     | 302 +++++++++++-----------
 gdb/stack.c                         |  26 +-
 gdb/symfile-debug.c                 |  12 +-
 gdb/symfile.c                       |  25 +-
 gdb/symmisc.c                       | 104 ++++----
 gdb/symtab.c                        | 216 +++++++++-------
 gdb/symtab.h                        | 373 ++++++++++++++++++++++------
 gdb/tracepoint.c                    |  28 +--
 gdb/tui/tui-source.c                |   2 +-
 gdb/tui/tui-winsource.c             |   2 +-
 gdb/typeprint.c                     |   4 +-
 gdb/valops.c                        |  14 +-
 gdb/xcoffread.c                     |   8 +-
 gdb/z80-tdep.c                      |   4 +-
 96 files changed, 1402 insertions(+), 1188 deletions(-)


base-commit: 2f49159cfbf74fd8fed13e023c7e9e9c90a5b22d
-- 
2.34.1


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

* [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
@ 2022-01-28 12:44 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 02/33] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi via Gdb-patches
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Rename the field to m_objfile, and add a getter and a setter.  Update
all users.

Change-Id: If7e2f763ee3e70570140d9af9261b1b056253317
---
 gdb/symfile.c |  8 ++++----
 gdb/symmisc.c |  2 +-
 gdb/symtab.c  |  2 +-
 gdb/symtab.h  | 14 ++++++++++++--
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 9bd4f48d0b02..a660422b51e0 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2774,7 +2774,7 @@ deduce_language_from_filename (const char *filename)
 struct symtab *
 allocate_symtab (struct compunit_symtab *cust, const char *filename)
 {
-  struct objfile *objfile = cust->objfile;
+  struct objfile *objfile = cust->objfile ();
   struct symtab *symtab
     = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
 
@@ -2832,7 +2832,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 					       struct compunit_symtab);
   const char *saved_name;
 
-  cu->objfile = objfile;
+  cu->set_objfile (objfile);
 
   /* The name we record here is only for display/debugging purposes.
      Just save the basename to avoid path issues (too long for display,
@@ -2858,8 +2858,8 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 void
 add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
 {
-  cu->next = cu->objfile->compunit_symtabs;
-  cu->objfile->compunit_symtabs = cu;
+  cu->next = cu->objfile ()->compunit_symtabs;
+  cu->objfile ()->compunit_symtabs = cu;
 }
 \f
 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index cd51f6645c56..19c387d852d7 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -957,7 +957,7 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
   struct linetable *linetable;
   struct objfile *objfile;
 
-  objfile = symtab->compunit_symtab->objfile;
+  objfile = symtab->compunit_symtab->objfile ();
   printf_filtered (_("objfile: %ps ((struct objfile *) %s)\n"),
 		   styled_string (file_name_style.style (),
 				  objfile_name (objfile)),
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a32e561ed774..44b5bfb43bbf 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -338,7 +338,7 @@ compunit_symtab::find_call_site (CORE_ADDR pc) const
     return nullptr;
 
   CORE_ADDR delta
-    = this->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
+    = this->objfile ()->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
   CORE_ADDR unrelocated_pc = pc - delta;
 
   struct call_site call_site_local (unrelocated_pc, nullptr, nullptr);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 55d1b772c457..995026bbf82f 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1449,6 +1449,16 @@ struct symtab
 
 struct compunit_symtab
 {
+  struct objfile *objfile () const
+  {
+    return m_objfile;
+  }
+
+  void set_objfile (struct objfile *objfile)
+  {
+    m_objfile = objfile;
+  }
+
   /* Set m_call_site_htab.  */
   void set_call_site_htab (htab_t call_site_htab);
 
@@ -1459,7 +1469,7 @@ struct compunit_symtab
   struct compunit_symtab *next;
 
   /* Object file from which this symtab information was read.  */
-  struct objfile *objfile;
+  struct objfile *m_objfile;
 
   /* Name of the symtab.
      This is *not* intended to be a usable filename, and is
@@ -1535,7 +1545,7 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_OBJFILE(cust) ((cust)->objfile)
+#define COMPUNIT_OBJFILE(cust) ((cust)->objfile ())
 #define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
 #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
-- 
2.34.1


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

* [PATCH 02/33] gdb: remove COMPUNIT_OBJFILE macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
  2022-01-28 12:44 ` [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 03/33] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab Simon Marchi via Gdb-patches
                   ` (31 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Remove the macro, update all users to use the getter directly.

Change-Id: I3f0fd6f4455d1c4ebd5da73b561eb18a979ef1f6
---
 gdb/block.c               | 2 +-
 gdb/buildsym-legacy.c     | 2 +-
 gdb/dwarf2/read.c         | 6 +++---
 gdb/guile/scm-block.c     | 6 +++---
 gdb/python/py-progspace.c | 6 +++---
 gdb/source.c              | 2 +-
 gdb/symtab.h              | 3 +--
 7 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index 2b6196c09aa4..617164584578 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -51,7 +51,7 @@ block_objfile (const struct block *block)
     return symbol_objfile (BLOCK_FUNCTION (block));
 
   global_block = (struct global_block *) block_global_block (block);
-  return COMPUNIT_OBJFILE (global_block->compunit_symtab);
+  return global_block->compunit_symtab->objfile ();
 }
 
 /* See block.  */
diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index 8f00902f490f..aa7b8b56b89a 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -301,7 +301,7 @@ restart_symtab (struct compunit_symtab *cust,
   gdb_assert (buildsym_compunit == nullptr);
 
   buildsym_compunit
-    = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
+    = new struct buildsym_compunit (cust->objfile (),
 				    name,
 				    COMPUNIT_DIRNAME (cust),
 				    compunit_language (cust),
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1a749eac334f..fe274ed3a1f8 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10722,7 +10722,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
 	  gdb_assert (m_builder == nullptr);
 	  struct compunit_symtab *cust = tug_unshare->compunit_symtab;
 	  m_builder.reset (new struct buildsym_compunit
-			   (COMPUNIT_OBJFILE (cust), "",
+			   (cust->objfile (), "",
 			    COMPUNIT_DIRNAME (cust),
 			    compunit_language (cust),
 			    0, cust));
@@ -10744,7 +10744,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
 	 time.  */
 
       tug_unshare->symtabs
-	= XOBNEWVEC (&COMPUNIT_OBJFILE (cust)->objfile_obstack,
+	= XOBNEWVEC (&cust->objfile ()->objfile_obstack,
 		     struct symtab *, line_header->file_names_size ());
 
       auto &file_names = line_header->file_names ();
@@ -10774,7 +10774,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
       gdb_assert (m_builder == nullptr);
       struct compunit_symtab *cust = tug_unshare->compunit_symtab;
       m_builder.reset (new struct buildsym_compunit
-		       (COMPUNIT_OBJFILE (cust), "",
+		       (cust->objfile (), "",
 			COMPUNIT_DIRNAME (cust),
 			compunit_language (cust),
 			0, cust));
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 80cadbe15267..0c63dfb25f82 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -685,7 +685,7 @@ gdbscm_lookup_block (SCM pc_scm)
     {
       cust = find_pc_compunit_symtab (pc);
 
-      if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
+      if (cust != NULL && cust->objfile () != NULL)
 	block = block_for_pc (pc);
     }
   catch (const gdb_exception &except)
@@ -694,14 +694,14 @@ gdbscm_lookup_block (SCM pc_scm)
     }
 
   GDBSCM_HANDLE_GDB_EXCEPTION (exc);
-  if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
+  if (cust == NULL || cust->objfile () == NULL)
     {
       gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, pc_scm,
 				 _("cannot locate object file for block"));
     }
 
   if (block != NULL)
-    return bkscm_scm_from_block (block, COMPUNIT_OBJFILE (cust));
+    return bkscm_scm_from_block (block, cust->objfile ());
   return SCM_BOOL_F;
 }
 \f
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index b27ebf4a6665..1e01068c59b0 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -388,7 +388,7 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
       set_current_program_space (self->pspace);
       cust = find_pc_compunit_symtab (pc);
 
-      if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
+      if (cust != NULL && cust->objfile () != NULL)
 	block = block_for_pc (pc);
     }
   catch (const gdb_exception &except)
@@ -396,11 +396,11 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
       GDB_PY_HANDLE_EXCEPTION (except);
     }
 
-  if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
+  if (cust == NULL || cust->objfile () == NULL)
     Py_RETURN_NONE;
 
   if (block)
-    return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
+    return block_to_block_object (block, cust->objfile ());
 
   Py_RETURN_NONE;
 }
diff --git a/gdb/source.c b/gdb/source.c
index f749dd64e3b8..73c1c1d5188f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1186,7 +1186,7 @@ open_source_file (struct symtab *s)
     {
       if (SYMTAB_COMPUNIT (s) != nullptr)
 	{
-	  const objfile *ofp = COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (s));
+	  const objfile *ofp = SYMTAB_COMPUNIT (s)->objfile ();
 
 	  std::string srcpath;
 	  if (IS_ABSOLUTE_PATH (s->filename))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 995026bbf82f..dc15c49ec8ec 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1407,7 +1407,7 @@ struct symtab
 #define SYMTAB_BLOCKVECTOR(symtab) \
   COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
 #define SYMTAB_OBJFILE(symtab) \
-  COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (symtab))
+  (SYMTAB_COMPUNIT (symtab)->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
 #define SYMTAB_DIRNAME(symtab) \
   COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab))
@@ -1545,7 +1545,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_OBJFILE(cust) ((cust)->objfile ())
 #define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
 #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
-- 
2.34.1


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

* [PATCH 03/33] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
  2022-01-28 12:44 ` [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 02/33] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 04/33] gdb: add compunit_symtab::add_filetab method Simon Marchi via Gdb-patches
                   ` (30 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Make compunit_primary_filetab a method of compunit_symtab.

Change-Id: Iee3c4f7e36d579bf763c5bba146e5e10d6766768
---
 gdb/dwarf2/read.c     |  2 +-
 gdb/guile/scm-block.c |  2 +-
 gdb/psymtab.c         |  2 +-
 gdb/symfile-debug.c   |  6 +++---
 gdb/symmisc.c         |  2 +-
 gdb/symtab.c          | 10 +++++-----
 gdb/symtab.h          |  8 +++-----
 7 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index fe274ed3a1f8..84877e6c7fe0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -3113,7 +3113,7 @@ dwarf2_base_index_functions::find_last_source_symtab (struct objfile *objfile)
   if (cust == NULL)
     return NULL;
 
-  return compunit_primary_filetab (cust);
+  return cust->primary_filetab ();
 }
 
 /* See read.h.  */
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 0c63dfb25f82..df0ef7f0b1f0 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -554,7 +554,7 @@ bkscm_print_block_syms_progress_smob (SCM self, SCM port,
 		    : i_smob->iter.d.compunit_symtab->includes[i_smob->iter.idx]);
 	    gdbscm_printf (port, " %s",
 			   symtab_to_filename_for_display
-			     (compunit_primary_filetab (cust)));
+			     (cust->primary_filetab ()));
 	    break;
 	  }
 	case FIRST_LOCAL_BLOCK:
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index ce077c67cbbe..fcbf54ab2bdd 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -631,7 +631,7 @@ psymbol_functions::find_last_source_symtab (struct objfile *ofp)
 
 	  if (cust == NULL)
 	    return NULL;
-	  return compunit_primary_filetab (cust);
+	  return cust->primary_filetab ();
 	}
     }
   return NULL;
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index ab5fc0d02728..cd25789ba9b0 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -289,7 +289,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
   if (debug_symfile)
     fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
 		      retval
-		      ? debug_symtab_name (compunit_primary_filetab (retval))
+		      ? debug_symtab_name (retval->primary_filetab ())
 		      : "NULL");
 
   return retval;
@@ -454,7 +454,7 @@ objfile::find_pc_sect_compunit_symtab (struct bound_minimal_symbol msymbol,
     fprintf_filtered (gdb_stdlog,
 		      "qf->find_pc_sect_compunit_symtab (...) = %s\n",
 		      retval
-		      ? debug_symtab_name (compunit_primary_filetab (retval))
+		      ? debug_symtab_name (retval->primary_filetab ())
 		      : "NULL");
 
   return retval;
@@ -495,7 +495,7 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address)
     fprintf_filtered (gdb_stdlog,
 		      "qf->find_compunit_symtab_by_address (...) = %s\n",
 		      result
-		      ? debug_symtab_name (compunit_primary_filetab (result))
+		      ? debug_symtab_name (result->primary_filetab ())
 		      : "NULL");
 
   return result;
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 19c387d852d7..8b57434e84fc 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -860,7 +860,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
 	for (compunit_symtab *cust : objfile->compunits ())
 	  {
 	    int found_something = 0;
-	    struct symtab *symtab = compunit_primary_filetab (cust);
+	    struct symtab *symtab = cust->primary_filetab ();
 
 	    QUIT;
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 44b5bfb43bbf..2028e837f0f1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -362,12 +362,12 @@ compunit_symtab::set_call_site_htab (htab_t call_site_htab)
 /* See symtab.h.  */
 
 struct symtab *
-compunit_primary_filetab (const struct compunit_symtab *cust)
+compunit_symtab::primary_filetab () const
 {
-  gdb_assert (COMPUNIT_FILETABS (cust) != NULL);
+  gdb_assert (this->filetabs != nullptr);
 
   /* The primary file symtab is the first one in the list.  */
-  return COMPUNIT_FILETABS (cust);
+  return this->filetabs;
 }
 
 /* See symtab.h.  */
@@ -375,7 +375,7 @@ compunit_primary_filetab (const struct compunit_symtab *cust)
 enum language
 compunit_language (const struct compunit_symtab *cust)
 {
-  struct symtab *symtab = compunit_primary_filetab (cust);
+  struct symtab *symtab = cust->primary_filetab ();
 
 /* The language of the compunit symtab is the language of its primary
    source file.  */
@@ -2376,7 +2376,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
 (if a template, try specifying an instantiation: %s<type>)."),
 	 block_index == GLOBAL_BLOCK ? "global" : "static",
 	 name,
-	 symtab_to_filename_for_display (compunit_primary_filetab (cust)),
+	 symtab_to_filename_for_display (cust->primary_filetab ()),
 	 name, name);
 }
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index dc15c49ec8ec..f6d787c45c84 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1459,6 +1459,9 @@ struct compunit_symtab
     m_objfile = objfile;
   }
 
+  /* Return the primary filetab of the compunit.  */
+  symtab *primary_filetab () const;
+
   /* Set m_call_site_htab.  */
   void set_call_site_htab (htab_t call_site_htab);
 
@@ -1566,11 +1569,6 @@ compunit_filetabs (compunit_symtab *cu)
   return symtab_range (cu->filetabs);
 }
 
-/* Return the primary symtab of CUST.  */
-
-extern struct symtab *
-  compunit_primary_filetab (const struct compunit_symtab *cust);
-
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
-- 
2.34.1


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

* [PATCH 04/33] gdb: add compunit_symtab::add_filetab method
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (2 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 03/33] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method Simon Marchi via Gdb-patches
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a method to append a filetab/symtab to a compunit_symtab.  There is
a single place where this is done currently, in allocate_symtab.

Change-Id: Ie86c6e34d175728173d1cffdce44acd6cff6c31d
---
 gdb/symfile.c | 11 +----------
 gdb/symtab.h  | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index a660422b51e0..8ec214fb8e65 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2804,16 +2804,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
     }
 
   /* Add it to CUST's list of symtabs.  */
-  if (cust->filetabs == NULL)
-    {
-      cust->filetabs = symtab;
-      cust->last_filetab = symtab;
-    }
-  else
-    {
-      cust->last_filetab->next = symtab;
-      cust->last_filetab = symtab;
-    }
+  cust->add_filetab (symtab);
 
   /* Backlink to the containing compunit symtab.  */
   symtab->compunit_symtab = cust;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f6d787c45c84..3fa4d5f5d0eb 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1459,6 +1459,20 @@ struct compunit_symtab
     m_objfile = objfile;
   }
 
+  void add_filetab (symtab *filetab)
+  {
+    if (this->filetabs == nullptr)
+      {
+	this->filetabs = filetab;
+	this->last_filetab = filetab;
+      }
+    else
+      {
+	this->last_filetab->next = filetab;
+	this->last_filetab = filetab;
+      }
+  }
+
   /* Return the primary filetab of the compunit.  */
   symtab *primary_filetab () const;
 
-- 
2.34.1


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

* [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (3 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 04/33] gdb: add compunit_symtab::add_filetab method Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi via Gdb-patches
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a method to set the primary filetab of the CU.  This is currently
done in buildsym_compunit::end_symtab_with_blockvector.

Change-Id: I16c51a6b90a4cb4c0c5f183b0f2e12bc64b6fd74
---
 gdb/buildsym.c | 24 ++----------------------
 gdb/symtab.c   | 28 ++++++++++++++++++++++++++++
 gdb/symtab.h   |  6 ++++++
 3 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 1754f5ffe6ed..914834f8e51f 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -996,28 +996,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
       symtab->language = subfile->language;
     }
 
-  /* Make sure the symtab of main_subfile is the first in its list.  */
-  {
-    struct symtab *main_symtab, *prev_symtab;
-
-    main_symtab = m_main_subfile->symtab;
-    prev_symtab = NULL;
-    for (symtab *symtab : compunit_filetabs (cu))
-      {
-	if (symtab == main_symtab)
-	  {
-	    if (prev_symtab != NULL)
-	      {
-		prev_symtab->next = main_symtab->next;
-		main_symtab->next = COMPUNIT_FILETABS (cu);
-		COMPUNIT_FILETABS (cu) = main_symtab;
-	      }
-	    break;
-	  }
-	prev_symtab = symtab;
-      }
-    gdb_assert (main_symtab == COMPUNIT_FILETABS (cu));
-  }
+  /* Make sure the filetab of main_subfile is the primary filetab of the CU.  */
+  cu->set_primary_filetab (m_main_subfile->symtab);
 
   /* Fill out the compunit symtab.  */
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2028e837f0f1..f4f5f09f215a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -361,6 +361,34 @@ compunit_symtab::set_call_site_htab (htab_t call_site_htab)
 
 /* See symtab.h.  */
 
+void
+compunit_symtab::set_primary_filetab (symtab *primary_filetab)
+{
+  symtab *prev_filetab = nullptr;
+
+  /* Move PRIMARY_FILETAB to the head of the filetab list.  */
+  for (symtab *filetab : compunit_filetabs (this))
+    {
+      if (filetab == primary_filetab)
+	{
+	  if (prev_filetab != nullptr)
+	    {
+	      prev_filetab->next = primary_filetab->next;
+	      primary_filetab->next = this->filetabs;
+	      this->filetabs = primary_filetab;
+	    }
+
+	  break;
+	}
+
+      prev_filetab = filetab;
+    }
+
+  gdb_assert (primary_filetab == this->filetabs);
+}
+
+/* See symtab.h.  */
+
 struct symtab *
 compunit_symtab::primary_filetab () const
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3fa4d5f5d0eb..23a348a381ce 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1473,6 +1473,12 @@ struct compunit_symtab
       }
   }
 
+  /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
+
+     PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
+
+  void set_primary_filetab (symtab *primary_filetab);
+
   /* Return the primary filetab of the compunit.  */
   symtab *primary_filetab () const;
 
-- 
2.34.1


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

* [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (4 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Simon Marchi via Gdb-patches
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Make compunit_filetabs, used to iterate a compunit_symtab's filetabs, a
method of compunit_symtab.  The name filetabs conflicts with the current
name of the field.  Rename the field to m_filetabs, since at this point
nothing outside of compunit_symtab uses it, so we should treat it as
private (even though it's not actually private).  Rename the
last_filetab field to m_last_filetab as well (it's only used on
compunit_symtab::add_filetab).

Adjust the COMPUNIT_FILETABS macro to keep its current behavior of
returning the first filetab.

Change-Id: I537b553a44451c52d24b18ee1bfa47e23747cfc3
---
 gdb/coffread.c |  2 +-
 gdb/maint.c    |  4 ++--
 gdb/objfiles.c |  2 +-
 gdb/source.c   |  4 ++--
 gdb/symmisc.c  | 10 +++++-----
 gdb/symtab.c   | 22 +++++++++++-----------
 gdb/symtab.h   | 36 +++++++++++++++++-------------------
 7 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index 921cfce1053a..f6bf973e9f75 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader,
   {
     for (compunit_symtab *cu : objfile->compunits ())
       {
-	for (symtab *s : compunit_filetabs (cu))
+	for (symtab *s : cu->filetabs ())
 	  patch_opaque_types (s);
       }
   }
diff --git a/gdb/maint.c b/gdb/maint.c
index 189b14643a82..f7e1828e2810 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -947,8 +947,8 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
 	    {
 	      ++nr_compunit_symtabs;
 	      nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
-	      nr_symtabs += std::distance (compunit_filetabs (cu).begin (),
-					   compunit_filetabs (cu).end ());
+	      nr_symtabs += std::distance (cu->filetabs ().begin (),
+					   cu->filetabs ().end ());
 	    }
 	}
     }
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 219dd0175cbc..d0c7ac83d379 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -651,7 +651,7 @@ objfile_relocate1 (struct objfile *objfile,
   {
     for (compunit_symtab *cust : objfile->compunits ())
       {
-	for (symtab *s : compunit_filetabs (cust))
+	for (symtab *s : cust->filetabs ())
 	  {
 	    struct linetable *l;
 
diff --git a/gdb/source.c b/gdb/source.c
index 73c1c1d5188f..2160619b34ff 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -344,7 +344,7 @@ select_source_symtab (struct symtab *s)
     {
       for (compunit_symtab *cu : ofp->compunits ())
 	{
-	  for (symtab *symtab : compunit_filetabs (cu))
+	  for (symtab *symtab : cu->filetabs ())
 	    {
 	      const char *name = symtab->filename;
 	      int len = strlen (name);
@@ -424,7 +424,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile)
 {
   for (compunit_symtab *cu : objfile->compunits ())
     {
-      for (symtab *s : compunit_filetabs (cu))
+      for (symtab *s : cu->filetabs ())
 	{
 	  if (s->fullname != NULL)
 	    {
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 8b57434e84fc..b4b58f6e0f51 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -74,7 +74,7 @@ print_objfile_statistics (void)
 	i = linetables = 0;
 	for (compunit_symtab *cu : objfile->compunits ())
 	  {
-	    for (symtab *s : compunit_filetabs (cu))
+	    for (symtab *s : cu->filetabs ())
 	      {
 		i++;
 		if (SYMTAB_LINETABLE (s) != NULL)
@@ -126,7 +126,7 @@ dump_objfile (struct objfile *objfile)
       printf_filtered ("Symtabs:\n");
       for (compunit_symtab *cu : objfile->compunits ())
 	{
-	  for (symtab *symtab : compunit_filetabs (cu))
+	  for (symtab *symtab : cu->filetabs ())
 	    {
 	      printf_filtered ("%s at %s",
 			       symtab_to_filename_for_display (symtab),
@@ -469,7 +469,7 @@ maintenance_print_symbols (const char *args, int from_tty)
 
 	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
-	      for (symtab *s : compunit_filetabs (cu))
+	      for (symtab *s : cu->filetabs ())
 		{
 		  int print_for_source = 0;
 
@@ -756,7 +756,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 	  {
 	    int printed_compunit_symtab_start = 0;
 
-	    for (symtab *symtab : compunit_filetabs (cust))
+	    for (symtab *symtab : cust->filetabs ())
 	      {
 		QUIT;
 
@@ -1025,7 +1025,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty)
       {
 	for (compunit_symtab *cust : objfile->compunits ())
 	  {
-	    for (symtab *symtab : compunit_filetabs (cust))
+	    for (symtab *symtab : cust->filetabs ())
 	      {
 		QUIT;
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f4f5f09f215a..6626ee8d36ca 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -367,15 +367,15 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab)
   symtab *prev_filetab = nullptr;
 
   /* Move PRIMARY_FILETAB to the head of the filetab list.  */
-  for (symtab *filetab : compunit_filetabs (this))
+  for (symtab *filetab : this->filetabs ())
     {
       if (filetab == primary_filetab)
 	{
 	  if (prev_filetab != nullptr)
 	    {
 	      prev_filetab->next = primary_filetab->next;
-	      primary_filetab->next = this->filetabs;
-	      this->filetabs = primary_filetab;
+	      primary_filetab->next = m_filetabs;
+	      m_filetabs = primary_filetab;
 	    }
 
 	  break;
@@ -384,7 +384,7 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab)
       prev_filetab = filetab;
     }
 
-  gdb_assert (primary_filetab == this->filetabs);
+  gdb_assert (primary_filetab == m_filetabs);
 }
 
 /* See symtab.h.  */
@@ -392,10 +392,10 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab)
 struct symtab *
 compunit_symtab::primary_filetab () const
 {
-  gdb_assert (this->filetabs != nullptr);
+  gdb_assert (m_filetabs != nullptr);
 
   /* The primary file symtab is the first one in the list.  */
-  return this->filetabs;
+  return m_filetabs;
 }
 
 /* See symtab.h.  */
@@ -533,7 +533,7 @@ iterate_over_some_symtabs (const char *name,
 
   for (cust = first; cust != NULL && cust != after_last; cust = cust->next)
     {
-      for (symtab *s : compunit_filetabs (cust))
+      for (symtab *s : cust->filetabs ())
 	{
 	  if (compare_filenames_for_search (s->filename, name))
 	    {
@@ -3282,7 +3282,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
      They all have the same apriori range, that we found was right;
      but they have different line tables.  */
 
-  for (symtab *iter_s : compunit_filetabs (cust))
+  for (symtab *iter_s : cust->filetabs ())
     {
       /* Find the best line in this symtab.  */
       l = SYMTAB_LINETABLE (iter_s);
@@ -3483,7 +3483,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
 	{
 	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
-	      for (symtab *s : compunit_filetabs (cu))
+	      for (symtab *s : cu->filetabs ())
 		{
 		  struct linetable *l;
 		  int ind;
@@ -4531,7 +4531,7 @@ info_sources_worker (struct ui_out *uiout,
 
       for (compunit_symtab *cu : objfile->compunits ())
 	{
-	  for (symtab *s : compunit_filetabs (cu))
+	  for (symtab *s : cu->filetabs ())
 	    {
 	      const char *file = symtab_to_filename_for_display (s);
 	      const char *fullname = symtab_to_fullname (s);
@@ -6190,7 +6190,7 @@ make_source_files_completion_list (const char *text, const char *word)
     {
       for (compunit_symtab *cu : objfile->compunits ())
 	{
-	  for (symtab *s : compunit_filetabs (cu))
+	  for (symtab *s : cu->filetabs ())
 	    {
 	      if (not_interesting_fname (s->filename))
 		continue;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 23a348a381ce..670826dd1832 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1401,6 +1401,10 @@ struct symtab
   char *fullname;
 };
 
+/* A range adapter to allowing iterating over all the file tables in a list.  */
+
+using symtab_range = next_range<symtab>;
+
 #define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab)
 #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
 #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
@@ -1459,17 +1463,22 @@ struct compunit_symtab
     m_objfile = objfile;
   }
 
+  symtab_range filetabs () const
+  {
+    return symtab_range (m_filetabs);
+  }
+
   void add_filetab (symtab *filetab)
   {
-    if (this->filetabs == nullptr)
+    if (m_filetabs == nullptr)
       {
-	this->filetabs = filetab;
-	this->last_filetab = filetab;
+	m_filetabs = filetab;
+	m_last_filetab = filetab;
       }
     else
       {
-	this->last_filetab->next = filetab;
-	this->last_filetab = filetab;
+	m_last_filetab->next = filetab;
+	m_last_filetab = filetab;
       }
   }
 
@@ -1503,14 +1512,14 @@ struct compunit_symtab
      source file (e.g., .c, .cc) is guaranteed to be first.
      Each symtab is a file, either the "main" source file (e.g., .c, .cc)
      or header (e.g., .h).  */
-  struct symtab *filetabs;
+  symtab *m_filetabs;
 
   /* Last entry in FILETABS list.
      Subfiles are added to the end of the list so they accumulate in order,
      with the main source subfile living at the front.
      The main reason is so that the main source file symtab is at the head
      of the list, and the rest appear in order for debugging convenience.  */
-  struct symtab *last_filetab;
+  symtab *m_last_filetab;
 
   /* Non-NULL string that identifies the format of the debugging information,
      such as "stabs", "dwarf 1", "dwarf 2", "coff", etc.  This is mostly useful
@@ -1568,7 +1577,7 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
+#define COMPUNIT_FILETABS(cust) (*(cust)->filetabs ().begin ())
 #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
@@ -1578,17 +1587,6 @@ using compunit_symtab_range = next_range<compunit_symtab>;
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
 
-/* A range adapter to allowing iterating over all the file tables
-   within a compunit.  */
-
-using symtab_range = next_range<symtab>;
-
-static inline symtab_range
-compunit_filetabs (compunit_symtab *cu)
-{
-  return symtab_range (cu->filetabs);
-}
-
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
-- 
2.34.1


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

* [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (5 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter Simon Marchi via Gdb-patches
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

I think that most remaining uses of COMPUNIT_FILETABS intend to get the
primary filetab of the compunit_symtab specifically (and not to iterate
over all filetabs, for example, those cases would use compunit_filetabs,
which has been converted to compunit_symtab::filetabs), so replace mosts
uses with compunit_symtab::primary_filetab.

In jit.c, function finalize_symtab, we can save the symtab object
returned by allocate_symtab and use it, it makes things simpler.

Change-Id: I4e51d6d4b40759de8768b61292e5e13c8eae2e38
---
 gdb/buildsym.c    |  4 ++--
 gdb/dwarf2/read.c |  8 ++++----
 gdb/jit.c         |  8 ++++----
 gdb/linespec.c    |  2 +-
 gdb/mdebugread.c  | 16 ++++++++--------
 gdb/symmisc.c     |  7 ++++---
 gdb/symtab.h      |  3 +--
 7 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 914834f8e51f..855d84bd27a6 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1031,7 +1031,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     int block_i;
 
     /* The main source file's symtab.  */
-    struct symtab *symtab = COMPUNIT_FILETABS (cu);
+    struct symtab *symtab = cu->primary_filetab ();
 
     for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++)
       {
@@ -1150,7 +1150,7 @@ set_missing_symtab (struct pending *pending_list,
       for (i = 0; i < pending->nsyms; ++i)
 	{
 	  if (symbol_symtab (pending->symbol[i]) == NULL)
-	    symbol_set_symtab (pending->symbol[i], COMPUNIT_FILETABS (cu));
+	    symbol_set_symtab (pending->symbol[i], cu->primary_filetab ());
 	}
     }
 }
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 84877e6c7fe0..7e62d11aa2cc 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9477,8 +9477,8 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
 	 compilation is from a C file generated by language preprocessors, do
 	 not set the language if it was already deduced by start_subfile.  */
       if (!(cu->per_cu->lang == language_c
-	    && COMPUNIT_FILETABS (cust)->language != language_unknown))
-	COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang;
+	    && cust->primary_filetab ()->language != language_unknown))
+	cust->primary_filetab ()->language = cu->per_cu->lang;
 
       /* GCC-4.0 has started to support -fvar-tracking.  GCC-3.x still can
 	 produce DW_AT_location with location lists but it can be possibly
@@ -9562,8 +9562,8 @@ process_full_type_unit (dwarf2_cu *cu,
 	     do not set the language if it was already deduced by
 	     start_subfile.  */
 	  if (!(cu->per_cu->lang == language_c
-		&& COMPUNIT_FILETABS (cust)->language != language_c))
-	    COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang;
+		&& cust->primary_filetab ()->language != language_c))
+	    cust->primary_filetab ()->language = cu->per_cu->lang;
 	}
     }
   else
diff --git a/gdb/jit.c b/gdb/jit.c
index 42776b956832..007313d3b800 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -500,7 +500,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
     });
 
   cust = allocate_compunit_symtab (objfile, stab->file_name.c_str ());
-  allocate_symtab (cust, stab->file_name.c_str ());
+  symtab *filetab = allocate_symtab (cust, stab->file_name.c_str ());
   add_compunit_symtab_to_objfile (cust);
 
   /* JIT compilers compile in memory.  */
@@ -512,9 +512,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       size_t size = ((stab->linetable->nitems - 1)
 		     * sizeof (struct linetable_entry)
 		     + sizeof (struct linetable));
-      SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust))
+      SYMTAB_LINETABLE (filetab)
 	= (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size);
-      memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)),
+      memcpy (SYMTAB_LINETABLE (filetab),
 	      stab->linetable.get (), size);
     }
 
@@ -553,7 +553,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       /* The name.  */
       SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
       SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK;
-      symbol_set_symtab (block_name, COMPUNIT_FILETABS (cust));
+      symbol_set_symtab (block_name, filetab);
       SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
       SYMBOL_BLOCK_VALUE (block_name) = new_block;
 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b24cf30dc712..f8b4b86a1e8e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1179,7 +1179,7 @@ iterate_over_all_matching_symtabs
 
 	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
-	      struct symtab *symtab = COMPUNIT_FILETABS (cu);
+	      struct symtab *symtab = cu->primary_filetab ();
 
 	      iterate_over_file_blocks (symtab, lookup_name, name_domain,
 					callback);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 1b327ad61153..836da8a3b8ca 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4084,17 +4084,17 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 
 	  /* The proper language was already determined when building
 	     the psymtab, use it.  */
-	  COMPUNIT_FILETABS (cust)->language = PST_PRIVATE (pst)->pst_language;
+	  cust->primary_filetab ()->language = PST_PRIVATE (pst)->pst_language;
 	}
 
-      psymtab_language = COMPUNIT_FILETABS (cust)->language;
+      psymtab_language = cust->primary_filetab ()->language;
 
-      lines = SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust));
+      lines = SYMTAB_LINETABLE (cust->primary_filetab ());
 
       /* Get a new lexical context.  */
 
       push_parse_stack ();
-      top_stack->cur_st = COMPUNIT_FILETABS (cust);
+      top_stack->cur_st = cust->primary_filetab ();
       top_stack->cur_block
 	= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
       BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
@@ -4173,7 +4173,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       size = lines->nitems;
       if (size > 1)
 	--size;
-      SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust))
+      SYMTAB_LINETABLE (cust->primary_filetab ())
 	= ((struct linetable *)
 	   obstack_copy (&mdebugread_objfile->objfile_obstack,
 			 lines, (sizeof (struct linetable)
@@ -4183,7 +4183,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       /* .. and our share of externals.
 	 XXX use the global list to speed up things here.  How?
 	 FIXME, Maybe quit once we have found the right number of ext's?  */
-      top_stack->cur_st = COMPUNIT_FILETABS (cust);
+      top_stack->cur_st = cust->primary_filetab ();
       top_stack->cur_block
 	= BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st),
 			     GLOBAL_BLOCK);
@@ -4201,7 +4201,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 	{
 	  printf_filtered (_("File %s contains %d unresolved references:"),
 			   symtab_to_filename_for_display
-			     (COMPUNIT_FILETABS (cust)),
+			     (cust->primary_filetab ()),
 			   n_undef_symbols);
 	  printf_filtered ("\n\t%4d variables\n\t%4d "
 			   "procedures\n\t%4d labels\n",
@@ -4211,7 +4211,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 	}
       pop_parse_stack ();
 
-      sort_blocks (COMPUNIT_FILETABS (cust));
+      sort_blocks (cust->primary_filetab ());
     }
 
   /* Now link the psymtab and the symtab.  */
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index b4b58f6e0f51..61e3eff562e5 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -329,8 +329,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
     }
   else
     {
+      compunit_symtab *compunit = SYMTAB_COMPUNIT (symtab);
       const char *compunit_filename
-	= symtab_to_filename_for_display (COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)));
+	= symtab_to_filename_for_display (compunit->primary_filetab ());
 
       fprintf_filtered (outfile,
 			"\nBlockvector same as owning compunit: %s\n\n",
@@ -346,7 +347,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
       if (cust->user != nullptr)
 	{
 	  const char *addr
-	    = host_address_to_string (COMPUNIT_FILETABS (cust->user));
+	    = host_address_to_string (cust->user->primary_filetab ());
 	  fprintf_filtered (outfile, "Compunit user: %s\n", addr);
 	}
       if (cust->includes != nullptr)
@@ -356,7 +357,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 	    if (include == nullptr)
 	      break;
 	    const char *addr
-	      = host_address_to_string (COMPUNIT_FILETABS (include));
+	      = host_address_to_string (include->primary_filetab ());
 	    fprintf_filtered (outfile, "Compunit include: %s\n", addr);
 	  }
     }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 670826dd1832..45d4bc4dc299 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1577,7 +1577,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_FILETABS(cust) (*(cust)->filetabs ().begin ())
 #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
@@ -1596,7 +1595,7 @@ extern enum language compunit_language (const struct compunit_symtab *cust);
 static inline bool
 is_main_symtab_of_compunit_symtab (struct symtab *symtab)
 {
-  return symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab));
+  return symtab == SYMTAB_COMPUNIT (symtab)->primary_filetab ();
 }
 \f
 
-- 
2.34.1


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

* [PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (6 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 09/33] gdb: remove COMPUNIT_PRODUCER " Simon Marchi via Gdb-patches
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's debugformat.  Remove
the corresponding macro and adjust all callers.

Change-Id: I1667b02d5322346f8e23abd9f8a584afbcd75975
---
 gdb/buildsym.c   |  2 +-
 gdb/mdebugread.c |  2 +-
 gdb/or1k-tdep.c  |  2 +-
 gdb/source.c     |  2 +-
 gdb/symfile.c    |  2 +-
 gdb/symmisc.c    |  2 +-
 gdb/symtab.h     | 13 +++++++++++--
 gdb/z80-tdep.c   |  2 +-
 8 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 855d84bd27a6..267b9462abd4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1010,7 +1010,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     }
 
   /* Save the debug format string (if any) in the symtab.  */
-  COMPUNIT_DEBUGFORMAT (cu) = m_debugformat;
+  cu->set_debugformat (m_debugformat);
 
   /* Similarly for the producer.  */
   COMPUNIT_PRODUCER (cu) = m_producer;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 836da8a3b8ca..44c7bc306d07 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4634,7 +4634,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
     BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
   COMPUNIT_BLOCKVECTOR (cust) = bv;
 
-  COMPUNIT_DEBUGFORMAT (cust) = "ECOFF";
+  cust->set_debugformat ("ECOFF");
   return cust;
 }
 
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 1e01df223add..5670a623024f 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -472,7 +472,7 @@ or1k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0);
 	  struct compunit_symtab *compunit
 	    = SYMTAB_COMPUNIT (prologue_sal.symtab);
-	  const char *debug_format = COMPUNIT_DEBUGFORMAT (compunit);
+	  const char *debug_format = compunit->debugformat ();
 
 	  if ((NULL != debug_format)
 	      && (strlen ("dwarf") <= strlen (debug_format))
diff --git a/gdb/source.c b/gdb/source.c
index 2160619b34ff..3f047467b2eb 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -727,7 +727,7 @@ info_source_command (const char *ignore, int from_tty)
 		   COMPUNIT_PRODUCER (cust) != NULL
 		   ? COMPUNIT_PRODUCER (cust) : _("unknown"));
   printf_filtered (_("Compiled with %s debugging format.\n"),
-		   COMPUNIT_DEBUGFORMAT (cust));
+		   cust->debugformat ());
   printf_filtered (_("%s preprocessor macro info.\n"),
 		   COMPUNIT_MACRO_TABLE (cust) != NULL
 		   ? "Includes" : "Does not include");
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8ec214fb8e65..b20284cad988 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2831,7 +2831,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
   saved_name = lbasename (name);
   cu->name = obstack_strdup (&objfile->objfile_obstack, saved_name);
 
-  COMPUNIT_DEBUGFORMAT (cu) = "unknown";
+  cu->set_debugformat ("unknown");
 
   if (symtab_create_debug)
     {
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 61e3eff562e5..4220fd7f9395 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -777,7 +777,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 			printf_filtered ("  { ((struct compunit_symtab *) %s)\n",
 					 host_address_to_string (cust));
 			printf_filtered ("    debugformat %s\n",
-					 COMPUNIT_DEBUGFORMAT (cust));
+					 cust->debugformat ());
 			printf_filtered ("    producer %s\n",
 					 COMPUNIT_PRODUCER (cust) != NULL
 					 ? COMPUNIT_PRODUCER (cust)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 45d4bc4dc299..2500c8e4166d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1482,6 +1482,16 @@ struct compunit_symtab
       }
   }
 
+  const char *debugformat () const
+  {
+    return m_debugformat;
+  }
+
+  void set_debugformat (const char *debugformat)
+  {
+    m_debugformat = debugformat;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1525,7 +1535,7 @@ struct compunit_symtab
      such as "stabs", "dwarf 1", "dwarf 2", "coff", etc.  This is mostly useful
      for automated testing of gdb but may also be information that is
      useful to the user.  */
-  const char *debugformat;
+  const char *m_debugformat;
 
   /* String of producer version information, or NULL if we don't know.  */
   const char *producer;
@@ -1577,7 +1587,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
 #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index 46fc64bd69b3..4a58fe5138ea 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -496,7 +496,7 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
     {
       struct symtab_and_line prologue_sal = find_pc_line (func_addr, 0);
       struct compunit_symtab *compunit = SYMTAB_COMPUNIT (prologue_sal.symtab);
-      const char *debug_format = COMPUNIT_DEBUGFORMAT (compunit);
+      const char *debug_format = compunit->debugformat ();
 
       if (debug_format != NULL &&
 	  !strncasecmp ("dwarf", debug_format, strlen("dwarf")))
-- 
2.34.1


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

* [PATCH 09/33] gdb: remove COMPUNIT_PRODUCER macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (7 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 10/33] gdb: remove COMPUNIT_DIRNAME " Simon Marchi via Gdb-patches
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's producer.  Remove the
corresponding macro and adjust all callers.

Change-Id: Ia1d6d8a0e247a08a21af23819d71e49b37d8931b
---
 gdb/amd64-tdep.c       | 10 +++++-----
 gdb/arm-tdep.c         |  6 +++---
 gdb/buildsym.c         |  2 +-
 gdb/compile/compile.c  |  6 +++---
 gdb/dwarf2/frame.c     |  2 +-
 gdb/i386-tdep.c        |  6 +++---
 gdb/python/py-symtab.c |  4 ++--
 gdb/source.c           |  4 ++--
 gdb/symmisc.c          |  5 ++---
 gdb/symtab.h           | 13 +++++++++++--
 10 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index e67aea8e66d6..539ebe9e1c36 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2474,8 +2474,8 @@ amd64_skip_xmm_prologue (CORE_ADDR pc, CORE_ADDR start_pc)
 
   start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
   if (start_pc_sal.symtab == NULL
-      || producer_is_gcc_ge_4 (COMPUNIT_PRODUCER
-	   (SYMTAB_COMPUNIT (start_pc_sal.symtab))) < 6
+      || producer_is_gcc_ge_4 (SYMTAB_COMPUNIT
+				 (start_pc_sal.symtab)->producer ()) < 6
       || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
     return pc;
 
@@ -2545,9 +2545,9 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 	 compilers to emit usable line notes.  */
       if (post_prologue_pc
 	  && (cust != NULL
-	      && COMPUNIT_PRODUCER (cust) != NULL
-	      && (producer_is_llvm (COMPUNIT_PRODUCER (cust))
-	      || producer_is_icc_ge_19 (COMPUNIT_PRODUCER (cust)))))
+	      && cust->producer () != nullptr
+	      && (producer_is_llvm (cust->producer ())
+	      || producer_is_icc_ge_19 (cust->producer ()))))
         return std::max (start_pc, post_prologue_pc);
     }
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index f46913e8eaa2..d36856e1f3b5 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1394,9 +1394,9 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	 missing (e.g. for -gstabs), assuming the GNU tools.  */
       if (post_prologue_pc
 	  && (cust == NULL
-	      || COMPUNIT_PRODUCER (cust) == NULL
-	      || startswith (COMPUNIT_PRODUCER (cust), "GNU ")
-	      || producer_is_llvm (COMPUNIT_PRODUCER (cust))))
+	      || cust->producer () == NULL
+	      || startswith (cust->producer (), "GNU ")
+	      || producer_is_llvm (cust->producer ())))
 	return post_prologue_pc;
 
       if (post_prologue_pc != 0)
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 267b9462abd4..227272776131 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1013,7 +1013,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
   cu->set_debugformat (m_debugformat);
 
   /* Similarly for the producer.  */
-  COMPUNIT_PRODUCER (cu) = m_producer;
+  cu->set_producer (m_producer);
 
   COMPUNIT_BLOCKVECTOR (cu) = blockvector;
   {
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 6794c93d60e7..7bd6ac817b8f 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -561,11 +561,11 @@ get_selected_pc_producer_options (void)
   struct compunit_symtab *symtab = find_pc_compunit_symtab (pc);
   const char *cs;
 
-  if (symtab == NULL || symtab->producer == NULL
-      || !startswith (symtab->producer, "GNU "))
+  if (symtab == NULL || symtab->producer () == NULL
+      || !startswith (symtab->producer (), "GNU "))
     return NULL;
 
-  cs = symtab->producer;
+  cs = symtab->producer ();
   while (*cs != 0 && *cs != '-')
     cs = skip_spaces (skip_to_space (cs));
   if (*cs != '-')
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index b4e699c37e17..0b7ed2c63fdc 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -745,7 +745,7 @@ dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs,
   if (cust == NULL)
     return;
 
-  if (producer_is_realview (COMPUNIT_PRODUCER (cust)))
+  if (producer_is_realview (cust->producer ()))
     {
       if (fde->cie->version == 1)
 	fs->armcc_cfa_offsets_sf = 1;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index aaa5592f40a9..e598a4d197b8 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1853,9 +1853,9 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 	 compilers to emit usable line notes.  */
       if (post_prologue_pc
 	  && (cust != NULL
-	      && COMPUNIT_PRODUCER (cust) != NULL
-	      && (producer_is_llvm (COMPUNIT_PRODUCER (cust))
-	      || producer_is_icc_ge_19 (COMPUNIT_PRODUCER (cust)))))
+	      && cust->producer () != NULL
+	      && (producer_is_llvm (cust->producer ())
+	      || producer_is_icc_ge_19 (cust->producer ()))))
         return std::max (start_pc, post_prologue_pc);
     }
  
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index db19e4b1213e..b973b25f1587 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -132,9 +132,9 @@ stpy_get_producer (PyObject *self, void *closure)
 
   STPY_REQUIRE_VALID (self, symtab);
   cust = SYMTAB_COMPUNIT (symtab);
-  if (COMPUNIT_PRODUCER (cust) != NULL)
+  if (cust->producer () != nullptr)
     {
-      const char *producer = COMPUNIT_PRODUCER (cust);
+      const char *producer = cust->producer ();
 
       return host_string_to_python_string (producer).release ();
     }
diff --git a/gdb/source.c b/gdb/source.c
index 3f047467b2eb..07ea2af9fd85 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -724,8 +724,8 @@ info_source_command (const char *ignore, int from_tty)
 
   printf_filtered (_("Source language is %s.\n"), language_str (s->language));
   printf_filtered (_("Producer is %s.\n"),
-		   COMPUNIT_PRODUCER (cust) != NULL
-		   ? COMPUNIT_PRODUCER (cust) : _("unknown"));
+		   (cust->producer ()) != nullptr
+		    ? cust->producer () : _("unknown"));
   printf_filtered (_("Compiled with %s debugging format.\n"),
 		   cust->debugformat ());
   printf_filtered (_("%s preprocessor macro info.\n"),
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 4220fd7f9395..b946fc8bde04 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -779,9 +779,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 			printf_filtered ("    debugformat %s\n",
 					 cust->debugformat ());
 			printf_filtered ("    producer %s\n",
-					 COMPUNIT_PRODUCER (cust) != NULL
-					 ? COMPUNIT_PRODUCER (cust)
-					 : "(null)");
+					 (cust->producer () != nullptr
+					  ? cust->producer () : "(null)"));
 			printf_filtered ("    dirname %s\n",
 					 COMPUNIT_DIRNAME (cust) != NULL
 					 ? COMPUNIT_DIRNAME (cust)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 2500c8e4166d..1e3f95dc92fa 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1492,6 +1492,16 @@ struct compunit_symtab
     m_debugformat = debugformat;
   }
 
+  const char *producer () const
+  {
+    return m_producer;
+  }
+
+  void set_producer (const char *producer)
+  {
+    m_producer = producer;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1538,7 +1548,7 @@ struct compunit_symtab
   const char *m_debugformat;
 
   /* String of producer version information, or NULL if we don't know.  */
-  const char *producer;
+  const char *m_producer;
 
   /* Directory in which it was compiled, or NULL if we don't know.  */
   const char *dirname;
@@ -1587,7 +1597,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_PRODUCER(cust) ((cust)->producer)
 #define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
 #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
 #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
-- 
2.34.1


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

* [PATCH 10/33] gdb: remove COMPUNIT_DIRNAME macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (8 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 09/33] gdb: remove COMPUNIT_PRODUCER " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 11/33] gdb: remove COMPUNIT_BLOCKVECTOR " Simon Marchi via Gdb-patches
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's dirname.  Remove the
corresponding macro and adjust all callers.

Change-Id: If2f39b295fd26822586485e04a8b8b5aa5cc9b2e
---
 gdb/buildsym-legacy.c |  2 +-
 gdb/buildsym.c        |  4 ++--
 gdb/dwarf2/read.c     |  4 ++--
 gdb/jit.c             |  2 +-
 gdb/macrotab.c        |  2 +-
 gdb/symmisc.c         |  5 ++---
 gdb/symtab.h          | 16 ++++++++++++----
 7 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c
index aa7b8b56b89a..7659f53cbe09 100644
--- a/gdb/buildsym-legacy.c
+++ b/gdb/buildsym-legacy.c
@@ -303,7 +303,7 @@ restart_symtab (struct compunit_symtab *cust,
   buildsym_compunit
     = new struct buildsym_compunit (cust->objfile (),
 				    name,
-				    COMPUNIT_DIRNAME (cust),
+				    cust->dirname (),
 				    compunit_language (cust),
 				    start_addr,
 				    cust);
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 227272776131..b96d154331a3 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1005,8 +1005,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     {
       /* Reallocate the dirname on the symbol obstack.  */
       const char *comp_dir = m_comp_dir.get ();
-      COMPUNIT_DIRNAME (cu) = obstack_strdup (&m_objfile->objfile_obstack,
-					      comp_dir);
+      cu->set_dirname (obstack_strdup (&m_objfile->objfile_obstack,
+				       comp_dir));
     }
 
   /* Save the debug format string (if any) in the symtab.  */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7e62d11aa2cc..cd3e6afbe87f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10723,7 +10723,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
 	  struct compunit_symtab *cust = tug_unshare->compunit_symtab;
 	  m_builder.reset (new struct buildsym_compunit
 			   (cust->objfile (), "",
-			    COMPUNIT_DIRNAME (cust),
+			    cust->dirname (),
 			    compunit_language (cust),
 			    0, cust));
 	  list_in_scope = get_builder ()->get_file_symbols ();
@@ -10775,7 +10775,7 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die)
       struct compunit_symtab *cust = tug_unshare->compunit_symtab;
       m_builder.reset (new struct buildsym_compunit
 		       (cust->objfile (), "",
-			COMPUNIT_DIRNAME (cust),
+			cust->dirname (),
 			compunit_language (cust),
 			0, cust));
       list_in_scope = get_builder ()->get_file_symbols ();
diff --git a/gdb/jit.c b/gdb/jit.c
index 007313d3b800..2c33eb3c9332 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -504,7 +504,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
   add_compunit_symtab_to_objfile (cust);
 
   /* JIT compilers compile in memory.  */
-  COMPUNIT_DIRNAME (cust) = NULL;
+  cust->set_dirname (nullptr);
 
   /* Copy over the linetable entry if one was provided.  */
   if (stab->linetable)
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 92d68e78e71d..7ca3f312d330 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -1066,7 +1066,7 @@ macro_source_fullname (struct macro_source_file *file)
   const char *comp_dir = NULL;
 
   if (file->table->compunit_symtab != NULL)
-    comp_dir = COMPUNIT_DIRNAME (file->table->compunit_symtab);
+    comp_dir = file->table->compunit_symtab->dirname ();
 
   if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
     return file->filename;
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index b946fc8bde04..9c882a468b27 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -782,9 +782,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 					 (cust->producer () != nullptr
 					  ? cust->producer () : "(null)"));
 			printf_filtered ("    dirname %s\n",
-					 COMPUNIT_DIRNAME (cust) != NULL
-					 ? COMPUNIT_DIRNAME (cust)
-					 : "(null)");
+					 (cust->dirname () != NULL
+					  ? cust->dirname () : "(null)"));
 			printf_filtered ("    blockvector"
 					 " ((struct blockvector *) %s)\n",
 					 host_address_to_string
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 1e3f95dc92fa..b72abab2ab5a 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1413,8 +1413,7 @@ using symtab_range = next_range<symtab>;
 #define SYMTAB_OBJFILE(symtab) \
   (SYMTAB_COMPUNIT (symtab)->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
-#define SYMTAB_DIRNAME(symtab) \
-  COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab))
+#define SYMTAB_DIRNAME(symtab) (SYMTAB_COMPUNIT (symtab)->dirname ())
 
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
    as the list of all source files (what gdb has historically associated with
@@ -1502,6 +1501,16 @@ struct compunit_symtab
     m_producer = producer;
   }
 
+  const char *dirname () const
+  {
+    return m_dirname;
+  }
+
+  void set_dirname (const char *dirname)
+  {
+    m_dirname = dirname;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1551,7 +1560,7 @@ struct compunit_symtab
   const char *m_producer;
 
   /* Directory in which it was compiled, or NULL if we don't know.  */
-  const char *dirname;
+  const char *m_dirname;
 
   /* List of all symbol scope blocks for this symtab.  It is shared among
      all symtabs in a given compilation unit.  */
@@ -1597,7 +1606,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
 #define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
 #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
-- 
2.34.1


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

* [PATCH 11/33] gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (9 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 10/33] gdb: remove COMPUNIT_DIRNAME " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 12/33] gdb: remove COMPUNIT_BLOCK_LINE_SECTION " Simon Marchi via Gdb-patches
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's blockvector.  Remove
the corresponding macro and adjust all callers.

Change-Id: I99484c6619dcbbea7c5d89c72aa660316ca62f64
---
 gdb/ada-lang.c         | 10 +++++-----
 gdb/block.c            |  6 +++---
 gdb/buildsym.c         |  4 ++--
 gdb/cp-support.c       |  4 ++--
 gdb/dwarf2/read.c      |  4 ++--
 gdb/jit.c              |  2 +-
 gdb/maint.c            |  2 +-
 gdb/mdebugread.c       |  8 ++++----
 gdb/objfiles.c         |  2 +-
 gdb/psymtab.c          |  2 +-
 gdb/python/py-symbol.c |  2 +-
 gdb/symfile-debug.c    |  2 +-
 gdb/symmisc.c          |  6 +++---
 gdb/symtab.c           | 18 +++++++++---------
 gdb/symtab.h           | 15 ++++++++++++---
 15 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 5a67853455da..2bb64ae03bde 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5237,7 +5237,7 @@ map_matching_symbols (struct objfile *objfile,
   for (compunit_symtab *symtab : objfile->compunits ())
     {
       const struct block *block
-	= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
+	= BLOCKVECTOR_BLOCK (symtab->blockvector (), block_kind);
       if (!iterate_over_symbols_terminated (block, lookup_name,
 					    domain, data))
 	break;
@@ -5266,7 +5266,7 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
       for (compunit_symtab *cu : objfile->compunits ())
 	{
 	  const struct block *global_block
-	    = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);
+	    = BLOCKVECTOR_BLOCK (cu->blockvector (), GLOBAL_BLOCK);
 
 	  if (ada_add_block_renamings (result, global_block, lookup_name,
 				       domain))
@@ -12617,7 +12617,7 @@ ada_add_global_exceptions (compiled_regex *preg,
     {
       for (compunit_symtab *s : objfile->compunits ())
 	{
-	  const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
+	  const struct blockvector *bv = s->blockvector ();
 	  int i;
 
 	  for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
@@ -13204,7 +13204,7 @@ class ada_language : public language_defn
 	for (compunit_symtab *s : objfile->compunits ())
 	  {
 	    QUIT;
-	    b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
+	    b = BLOCKVECTOR_BLOCK (s->blockvector (), GLOBAL_BLOCK);
 	    ALL_BLOCK_SYMBOLS (b, iter, sym)
 	      {
 		if (completion_skip_symbol (mode, sym))
@@ -13223,7 +13223,7 @@ class ada_language : public language_defn
 	for (compunit_symtab *s : objfile->compunits ())
 	  {
 	    QUIT;
-	    b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
+	    b = BLOCKVECTOR_BLOCK (s->blockvector (), STATIC_BLOCK);
 	    /* Don't do this block twice.  */
 	    if (b == surrounding_static_block)
 	      continue;
diff --git a/gdb/block.c b/gdb/block.c
index 617164584578..c0e3e465a115 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -197,7 +197,7 @@ blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
 	return 0;
     }
 
-  bl = COMPUNIT_BLOCKVECTOR (cust);
+  bl = cust->blockvector ();
 
   /* Then search that symtab for the smallest block that wins.  */
   b = find_block_in_blockvector (bl, pc);
@@ -543,7 +543,7 @@ block_iterator_step (struct block_iterator *iterator, int first)
 	  if (cust == NULL)
 	    return  NULL;
 
-	  block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
+	  block = BLOCKVECTOR_BLOCK (cust->blockvector (),
 				     iterator->which);
 	  sym = mdict_iterator_first (BLOCK_MULTIDICT (block),
 				      &iterator->mdict_iter);
@@ -612,7 +612,7 @@ block_iter_match_step (struct block_iterator *iterator,
 	  if (cust == NULL)
 	    return  NULL;
 
-	  block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
+	  block = BLOCKVECTOR_BLOCK (cust->blockvector (),
 				     iterator->which);
 	  sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name,
 					&iterator->mdict_iter);
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b96d154331a3..847414968af4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1015,7 +1015,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
   /* Similarly for the producer.  */
   cu->set_producer (m_producer);
 
-  COMPUNIT_BLOCKVECTOR (cu) = blockvector;
+  cu->set_blockvector (blockvector);
   {
     struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
 
@@ -1163,7 +1163,7 @@ void
 buildsym_compunit::augment_type_symtab ()
 {
   struct compunit_symtab *cust = m_compunit_symtab;
-  const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
+  const struct blockvector *blockvector = cust->blockvector ();
 
   if (!m_context_stack.empty ())
     complaint (_("Context stack not empty in augment_type_symtab"));
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index de83eb5d9570..028ff0f47546 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1464,7 +1464,7 @@ add_symbol_overload_list_qualified (const char *func_name,
       for (compunit_symtab *cust : objfile->compunits ())
 	{
 	  QUIT;
-	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
+	  b = BLOCKVECTOR_BLOCK (cust->blockvector (), GLOBAL_BLOCK);
 	  add_symbol_overload_list_block (func_name, b, overload_list);
 	}
     }
@@ -1474,7 +1474,7 @@ add_symbol_overload_list_qualified (const char *func_name,
       for (compunit_symtab *cust : objfile->compunits ())
 	{
 	  QUIT;
-	  b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
+	  b = BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
 	  /* Don't do this block twice.  */
 	  if (b == surrounding_static_block)
 	    continue;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index cd3e6afbe87f..0d78c242768a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4451,8 +4451,8 @@ recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
 {
   int i;
 
-  if (COMPUNIT_BLOCKVECTOR (cust) != NULL
-      && blockvector_contains_pc (COMPUNIT_BLOCKVECTOR (cust), pc))
+  if (cust->blockvector () != nullptr
+      && blockvector_contains_pc (cust->blockvector (), pc))
     return cust;
 
   if (cust->includes == NULL)
diff --git a/gdb/jit.c b/gdb/jit.c
index 2c33eb3c9332..6f397fc91fc7 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -522,7 +522,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
 		      + (actual_nblocks - 1) * sizeof (struct block *));
   bv = (struct blockvector *) obstack_alloc (&objfile->objfile_obstack,
 					     blockvector_size);
-  COMPUNIT_BLOCKVECTOR (cust) = bv;
+  cust->set_blockvector (bv);
 
   /* At the end of this function, (begin, end) will contain the PC range this
      entire blockvector spans.  */
diff --git a/gdb/maint.c b/gdb/maint.c
index f7e1828e2810..11dc2e466d6b 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -946,7 +946,7 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
 	  for (compunit_symtab *cu : o->compunits ())
 	    {
 	      ++nr_compunit_symtabs;
-	      nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
+	      nr_blocks += BLOCKVECTOR_NBLOCKS (cu->blockvector ());
 	      nr_symtabs += std::distance (cu->filetabs ().begin (),
 					   cu->filetabs ().end ());
 	    }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 44c7bc306d07..59b70389531a 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1965,7 +1965,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
 #else
       s = mylookup_symbol
 	(sh_name,
-	 BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (search_symtab),
+	 BLOCKVECTOR_BLOCK (search_symtab->blockvector (),
 			    STATIC_BLOCK),
 	 VAR_DOMAIN,
 	 LOC_BLOCK);
@@ -4096,7 +4096,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       push_parse_stack ();
       top_stack->cur_st = cust->primary_filetab ();
       top_stack->cur_block
-	= BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
+	= BLOCKVECTOR_BLOCK (cust->blockvector (), STATIC_BLOCK);
       BLOCK_START (top_stack->cur_block) = pst->text_low (objfile);
       BLOCK_END (top_stack->cur_block) = 0;
       top_stack->blocktype = stFile;
@@ -4502,7 +4502,7 @@ add_block (struct block *b, struct symtab *s)
 					 + BLOCKVECTOR_NBLOCKS (bv)
 					 * sizeof (bv->block)));
   if (bv != SYMTAB_BLOCKVECTOR (s))
-    SYMTAB_BLOCKVECTOR (s) = bv;
+    SYMTAB_COMPUNIT (s)->set_blockvector (bv);
 
   BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
 }
@@ -4632,7 +4632,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
   BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK, lang);
   BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
     BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-  COMPUNIT_BLOCKVECTOR (cust) = bv;
+  cust->set_blockvector (bv);
 
   cust->set_debugformat ("ECOFF");
   return cust;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d0c7ac83d379..f363cb453f3a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -667,7 +667,7 @@ objfile_relocate1 (struct objfile *objfile,
 
     for (compunit_symtab *cust : objfile->compunits ())
       {
-	const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+	const struct blockvector *bv = cust->blockvector ();
 	int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
 
 	if (BLOCKVECTOR_MAP (bv))
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index fcbf54ab2bdd..ac5009aec37f 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1801,7 +1801,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 	      /* Now do checks requiring the associated symtab.  */
 	      if (cust == NULL)
 		continue;
-	      bv = COMPUNIT_BLOCKVECTOR (cust);
+	      bv = cust->blockvector ();
 	      b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
 	      for (partial_symbol *psym : ps->static_psymbols)
 		{
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 508f445e1001..f636f5119a13 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -571,7 +571,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
 	      const struct blockvector *bv;
 	      const struct block *block;
 
-	      bv = COMPUNIT_BLOCKVECTOR (cust);
+	      bv = cust->blockvector ();
 	      block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
 
 	      if (block != nullptr)
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index cd25789ba9b0..59dbaf16e62b 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -245,7 +245,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
   auto search_one_symtab = [&] (compunit_symtab *stab)
   {
     struct symbol *sym, *with_opaque = NULL;
-    const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
+    const struct blockvector *bv = stab->blockvector ();
     const struct block *block = BLOCKVECTOR_BLOCK (bv, kind);
 
     sym = block_find_symbol (block, name, domain,
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 9c882a468b27..6e1a4c2e8341 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -787,7 +787,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 			printf_filtered ("    blockvector"
 					 " ((struct blockvector *) %s)\n",
 					 host_address_to_string
-					 (COMPUNIT_BLOCKVECTOR (cust)));
+					   (cust->blockvector ()));
 			printf_filtered ("    user"
 					 " ((struct compunit_symtab *) %s)\n",
 					 cust->user != nullptr
@@ -863,7 +863,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
 
 	    QUIT;
 
-	    if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
+	    if (cust->blockvector () == NULL)
 	      found_something = 1;
 	    /* Add more checks here.  */
 
@@ -879,7 +879,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
 		  }
 		printf_filtered ("  { symtab %s\n",
 				 symtab_to_filename_for_display (symtab));
-		if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
+		if (cust->blockvector () == NULL)
 		  printf_filtered ("    NULL blockvector\n");
 		printf_filtered ("  }\n");
 	      }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6626ee8d36ca..a0bc1dfea52e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2309,7 +2309,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
       const struct block *block;
       struct block_symbol result;
 
-      bv = COMPUNIT_BLOCKVECTOR (cust);
+      bv = cust->blockvector ();
       block = BLOCKVECTOR_BLOCK (bv, block_index);
       result.symbol = block_lookup_symbol_primary (block, name, domain);
       result.block = block;
@@ -2442,7 +2442,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
       return {};
     }
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
   block = BLOCKVECTOR_BLOCK (bv, block_index);
   result.symbol = block_lookup_symbol (block, name,
 				       symbol_name_match_type::FULL, domain);
@@ -2792,7 +2792,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   if (cust == NULL)
     return NULL;
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
   block = BLOCKVECTOR_BLOCK (bv, block_index);
   sym = block_find_symbol (block, name, STRUCT_DOMAIN,
 			   block_find_non_opaque_type, NULL);
@@ -2817,7 +2817,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
 
   for (compunit_symtab *cust : objfile->compunits ())
     {
-      bv = COMPUNIT_BLOCKVECTOR (cust);
+      bv = cust->blockvector ();
       block = BLOCKVECTOR_BLOCK (bv, block_index);
       sym = block_find_symbol (block, name, STRUCT_DOMAIN,
 			       block_find_non_opaque_type, NULL);
@@ -2962,7 +2962,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
     {
       for (compunit_symtab *cust : obj_file->compunits ())
 	{
-	  const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+	  const struct blockvector *bv = cust->blockvector ();
 	  const struct block *global_block
 	    = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
 	  CORE_ADDR start = BLOCK_START (global_block);
@@ -3068,7 +3068,7 @@ find_symbol_at_address (CORE_ADDR address)
      ADDR.  */
   auto search_symtab = [] (compunit_symtab *symtab, CORE_ADDR addr) -> symbol *
     {
-      const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab);
+      const struct blockvector *bv = symtab->blockvector ();
 
       for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i)
 	{
@@ -3276,7 +3276,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
       return val;
     }
 
-  bv = COMPUNIT_BLOCKVECTOR (cust);
+  bv = cust->blockvector ();
 
   /* Look at all the symtabs that share this blockvector.
      They all have the same apriori range, that we found was right;
@@ -4793,7 +4793,7 @@ global_symbol_searcher::add_matching_symbols
   /* Add matching symbols (if not already present).  */
   for (compunit_symtab *cust : objfile->compunits ())
     {
-      const struct blockvector *bv  = COMPUNIT_BLOCKVECTOR (cust);
+      const struct blockvector *bv  = cust->blockvector ();
 
       for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK })
 	{
@@ -5773,7 +5773,7 @@ add_symtab_completions (struct compunit_symtab *cust,
   for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
     {
       QUIT;
-      b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), i);
+      b = BLOCKVECTOR_BLOCK (cust->blockvector (), i);
       ALL_BLOCK_SYMBOLS (b, iter, sym)
 	{
 	  if (completion_skip_symbol (mode, sym))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index b72abab2ab5a..f9318ffdcb46 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1409,7 +1409,7 @@ using symtab_range = next_range<symtab>;
 #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
 #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
 #define SYMTAB_BLOCKVECTOR(symtab) \
-  COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
+  (SYMTAB_COMPUNIT (symtab)->blockvector ())
 #define SYMTAB_OBJFILE(symtab) \
   (SYMTAB_COMPUNIT (symtab)->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
@@ -1511,6 +1511,16 @@ struct compunit_symtab
     m_dirname = dirname;
   }
 
+  const struct blockvector *blockvector () const
+  {
+    return m_blockvector;
+  }
+
+  void set_blockvector (const struct blockvector *blockvector)
+  {
+    m_blockvector = blockvector;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1564,7 +1574,7 @@ struct compunit_symtab
 
   /* List of all symbol scope blocks for this symtab.  It is shared among
      all symtabs in a given compilation unit.  */
-  const struct blockvector *blockvector;
+  const struct blockvector *m_blockvector;
 
   /* Section in objfile->section_offsets for the blockvector and
      the linetable.  Probably always SECT_OFF_TEXT.  */
@@ -1606,7 +1616,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
 #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
-- 
2.34.1


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

* [PATCH 12/33] gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (10 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 11/33] gdb: remove COMPUNIT_BLOCKVECTOR " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 13/33] gdb: remove COMPUNIT_LOCATIONS_VALID " Simon Marchi via Gdb-patches
                   ` (21 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's block line section.  Remove
the corresponding macro and adjust all callers.

Change-Id: I3eb1a323388ad55eae8bfa45f5bc4a08dc3df455
---
 gdb/buildsym.c   |  2 +-
 gdb/dwarf2/loc.c |  2 +-
 gdb/gdbtypes.c   |  2 +-
 gdb/objfiles.c   |  4 ++--
 gdb/symtab.c     |  2 +-
 gdb/symtab.h     | 13 +++++++++++--
 6 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 847414968af4..1b162dac9e07 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1022,7 +1022,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
     set_block_compunit_symtab (b, cu);
   }
 
-  COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
+  cu->set_block_line_section (section);
 
   COMPUNIT_MACRO_TABLE (cu) = release_macros ();
 
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 69b480e6e869..bf3cadba87ee 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -717,7 +717,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
       {
 	dwarf2_per_objfile *per_objfile = call_site->per_objfile;
 	compunit_symtab *cust = per_objfile->get_symtab (call_site->per_cu);
-	int sect_idx = COMPUNIT_BLOCK_LINE_SECTION (cust);
+	int sect_idx = cust->block_line_section ();
 	CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
 
 	return call_site->target.loc_physaddr () + delta;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 8af96c79e6ca..795844733105 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -6285,7 +6285,7 @@ call_site::pc () const
 {
   compunit_symtab *cust = this->per_objfile->get_symtab (this->per_cu);
   CORE_ADDR delta
-	= this->per_objfile->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+	= this->per_objfile->objfile->section_offsets[cust->block_line_section ()];
   return m_unrelocated_pc + delta;
 }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index f363cb453f3a..7e1ec6ca92dd 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -660,7 +660,7 @@ objfile_relocate1 (struct objfile *objfile,
 	    if (l)
 	      {
 		for (int i = 0; i < l->nitems; ++i)
-		  l->item[i].pc += delta[COMPUNIT_BLOCK_LINE_SECTION (cust)];
+		  l->item[i].pc += delta[cust->block_line_section ()];
 	      }
 	  }
       }
@@ -668,7 +668,7 @@ objfile_relocate1 (struct objfile *objfile,
     for (compunit_symtab *cust : objfile->compunits ())
       {
 	const struct blockvector *bv = cust->blockvector ();
-	int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+	int block_line_section = cust->block_line_section ();
 
 	if (BLOCKVECTOR_MAP (bv))
 	  addrmap_relocate (BLOCKVECTOR_MAP (bv), delta[block_line_section]);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a0bc1dfea52e..70a9f10ea4b6 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -338,7 +338,7 @@ compunit_symtab::find_call_site (CORE_ADDR pc) const
     return nullptr;
 
   CORE_ADDR delta
-    = this->objfile ()->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
+    = this->objfile ()->section_offsets[this->block_line_section ()];
   CORE_ADDR unrelocated_pc = pc - delta;
 
   struct call_site call_site_local (unrelocated_pc, nullptr, nullptr);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f9318ffdcb46..c59e3c3457c7 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1521,6 +1521,16 @@ struct compunit_symtab
     m_blockvector = blockvector;
   }
 
+  int block_line_section () const
+  {
+    return m_block_line_section;
+  }
+
+  void set_block_line_section (int block_line_section)
+  {
+    m_block_line_section = block_line_section;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1578,7 +1588,7 @@ struct compunit_symtab
 
   /* Section in objfile->section_offsets for the blockvector and
      the linetable.  Probably always SECT_OFF_TEXT.  */
-  int block_line_section;
+  int m_block_line_section;
 
   /* Symtab has been compiled with both optimizations and debug info so that
      GDB may stop skipping prologues as variables locations are valid already
@@ -1616,7 +1626,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
-- 
2.34.1


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

* [PATCH 13/33] gdb: remove COMPUNIT_LOCATIONS_VALID macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (11 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 12/33] gdb: remove COMPUNIT_BLOCK_LINE_SECTION " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 14/33] gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID " Simon Marchi via Gdb-patches
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's locations valid flag.
Remove the corresponding macro and adjust all callers.

Change-Id: I3e3cfba926ce62993d5b61814331bb3244afad01
---
 gdb/dwarf2/read.c |  2 +-
 gdb/symtab.c      |  4 ++--
 gdb/symtab.h      | 13 +++++++++++--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0d78c242768a..a14ac22f2882 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9493,7 +9493,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
 	 options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
 	 */
       if (cu->has_loclist && gcc_4_minor >= 5)
-	cust->locations_valid = 1;
+	cust->set_locations_valid (true);
 
       if (gcc_4_minor >= 5)
 	cust->epilogue_unwind_valid = 1;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 70a9f10ea4b6..5ad5cdbe3a3a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3709,7 +3709,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section,
   symtab_and_line sal = find_pc_sect_line (func_addr, section, 0);
 
   if (funfirstline && sal.symtab != NULL
-      && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
+      && (SYMTAB_COMPUNIT (sal.symtab)->locations_valid ()
 	  || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
     {
       struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
@@ -3885,7 +3885,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
      have proven the CU (Compilation Unit) supports it.  sal->SYMTAB does not
      have to be set by the caller so we use SYM instead.  */
   if (sym != NULL
-      && COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (symbol_symtab (sym))))
+      && SYMTAB_COMPUNIT (symbol_symtab (sym))->locations_valid ())
     force_skip = 0;
 
   saved_pc = pc;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c59e3c3457c7..a612e1a9b483 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1531,6 +1531,16 @@ struct compunit_symtab
     m_block_line_section = block_line_section;
   }
 
+  bool locations_valid () const
+  {
+    return m_locations_valid;
+  }
+
+  void set_locations_valid (bool locations_valid)
+  {
+    m_locations_valid = locations_valid;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1593,7 +1603,7 @@ struct compunit_symtab
   /* Symtab has been compiled with both optimizations and debug info so that
      GDB may stop skipping prologues as variables locations are valid already
      at function entry points.  */
-  unsigned int locations_valid : 1;
+  unsigned int m_locations_valid : 1;
 
   /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
      instruction).  This is supported by GCC since 4.5.0.  */
@@ -1626,7 +1636,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
 
-- 
2.34.1


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

* [PATCH 14/33] gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (12 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 13/33] gdb: remove COMPUNIT_LOCATIONS_VALID " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 15/33] gdb: remove COMPUNIT_MACRO_TABLE " Simon Marchi via Gdb-patches
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's epilogue unwind valid flag.
Remove the corresponding macro and adjust all callers.

Change-Id: If3b68629d987767da9be7041a95d96dc34367a9a
---
 gdb/amd64-tdep.c  |  2 +-
 gdb/dwarf2/read.c |  2 +-
 gdb/i386-tdep.c   |  2 +-
 gdb/symtab.h      | 13 +++++++++++--
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 539ebe9e1c36..4444187515fb 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2901,7 +2901,7 @@ amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   struct compunit_symtab *cust;
 
   cust = find_pc_compunit_symtab (pc);
-  if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
+  if (cust != NULL && cust->epilogue_unwind_valid ())
     return 0;
 
   if (target_read_memory (pc, &insn, 1))
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a14ac22f2882..fb138de86adc 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9496,7 +9496,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
 	cust->set_locations_valid (true);
 
       if (gcc_4_minor >= 5)
-	cust->epilogue_unwind_valid = 1;
+	cust->set_epilogue_unwind_valid (true);
 
       cust->set_call_site_htab (cu->call_site_htab);
     }
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index e598a4d197b8..b98f47574998 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2222,7 +2222,7 @@ i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   struct compunit_symtab *cust;
 
   cust = find_pc_compunit_symtab (pc);
-  if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
+  if (cust != NULL && cust->epilogue_unwind_valid ())
     return 0;
 
   if (target_read_memory (pc, &insn, 1))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a612e1a9b483..5419e70ced6a 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1541,6 +1541,16 @@ struct compunit_symtab
     m_locations_valid = locations_valid;
   }
 
+  bool epilogue_unwind_valid () const
+  {
+    return m_epilogue_unwind_valid;
+  }
+
+  void set_epilogue_unwind_valid (bool epilogue_unwind_valid)
+  {
+    m_epilogue_unwind_valid = epilogue_unwind_valid;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1607,7 +1617,7 @@ struct compunit_symtab
 
   /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
      instruction).  This is supported by GCC since 4.5.0.  */
-  unsigned int epilogue_unwind_valid : 1;
+  unsigned int m_epilogue_unwind_valid : 1;
 
   /* struct call_site entries for this compilation unit or NULL.  */
   htab_t m_call_site_htab;
@@ -1636,7 +1646,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
 
 /* Return the language of CUST.  */
-- 
2.34.1


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

* [PATCH 15/33] gdb: remove COMPUNIT_MACRO_TABLE macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (13 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 14/33] gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT " Simon Marchi via Gdb-patches
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a compunit_symtab's macro table.  Remove the
corresponding macro and adjust all callers.

Change-Id: I00615ea72d5ac43d9a865e941cb2de0a979c173a
---
 gdb/buildsym.c       |  2 +-
 gdb/macroscope.c     |  4 ++--
 gdb/mi/mi-cmd-file.c |  2 +-
 gdb/source.c         |  4 ++--
 gdb/symtab.h         | 14 +++++++++++---
 5 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 1b162dac9e07..b42c40830c90 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1024,7 +1024,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 
   cu->set_block_line_section (section);
 
-  COMPUNIT_MACRO_TABLE (cu) = release_macros ();
+  cu->set_macro_table (release_macros ());
 
   /* Default any symbols without a specified symtab to the primary symtab.  */
   {
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index 02070967579f..c581c426eda0 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -44,12 +44,12 @@ sal_macro_scope (struct symtab_and_line sal)
   if (sal.symtab == NULL)
     return NULL;
   cust = SYMTAB_COMPUNIT (sal.symtab);
-  if (COMPUNIT_MACRO_TABLE (cust) == NULL)
+  if (cust->macro_table () == NULL)
     return NULL;
 
   gdb::unique_xmalloc_ptr<struct macro_scope> ms (XNEW (struct macro_scope));
 
-  main_file = macro_main (COMPUNIT_MACRO_TABLE (cust));
+  main_file = macro_main (cust->macro_table ());
   inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename);
 
   if (inclusion)
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 23c6d7021e2e..f4ee791f17b5 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -59,7 +59,7 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc)
   uiout->field_string ("fullname", symtab_to_fullname (st.symtab));
 
   uiout->field_signed ("macro-info",
-		       COMPUNIT_MACRO_TABLE (SYMTAB_COMPUNIT (st.symtab)) != NULL);
+		       SYMTAB_COMPUNIT (st.symtab)->macro_table () != NULL);
 }
 
 /* Implement -file-list-exec-source-files command.  */
diff --git a/gdb/source.c b/gdb/source.c
index 07ea2af9fd85..e6ba44819413 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -729,8 +729,8 @@ info_source_command (const char *ignore, int from_tty)
   printf_filtered (_("Compiled with %s debugging format.\n"),
 		   cust->debugformat ());
   printf_filtered (_("%s preprocessor macro info.\n"),
-		   COMPUNIT_MACRO_TABLE (cust) != NULL
-		   ? "Includes" : "Does not include");
+		   (cust->macro_table () != nullptr
+		    ? "Includes" : "Does not include"));
 }
 \f
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5419e70ced6a..c319d51a2714 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1551,6 +1551,16 @@ struct compunit_symtab
     m_epilogue_unwind_valid = epilogue_unwind_valid;
   }
 
+  struct macro_table *macro_table () const
+  {
+    return m_macro_table;
+  }
+
+  void set_macro_table (struct macro_table *macro_table)
+  {
+    m_macro_table = macro_table;
+  }
+
   /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab.
 
      PRIMARY_FILETAB must already be a filetab of this compunit symtab.  */
@@ -1626,7 +1636,7 @@ struct compunit_symtab
      is shared between different symtabs in a given compilation unit.
      It's debatable whether it *should* be shared among all the symtabs in
      the given compilation unit, but it currently is.  */
-  struct macro_table *macro_table;
+  struct macro_table *m_macro_table;
 
   /* If non-NULL, then this points to a NULL-terminated vector of
      included compunits.  When searching the static or global
@@ -1646,8 +1656,6 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
-
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
-- 
2.34.1


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

* [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (14 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 15/33] gdb: remove COMPUNIT_MACRO_TABLE " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 17/33] gdb: remove SYMTAB_LINETABLE " Simon Marchi via Gdb-patches
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symtab's compunit_symtab.  Remove the
corresponding macro and adjust all callers.

For brevity, I chose the name "compunit" instead of "compunit_symtab"
the the field, getter and setter names.  Since we are already in symtab
context, the _symtab suffix seems redundant.

Change-Id: I4b9b731c96e3594f7733e75af1e3d01bc0e4fe92
---
 gdb/amd64-tdep.c       |  4 ++--
 gdb/breakpoint.c       |  2 +-
 gdb/macroscope.c       |  3 ++-
 gdb/mdebugread.c       |  2 +-
 gdb/mi/mi-cmd-file.c   |  2 +-
 gdb/or1k-tdep.c        |  2 +-
 gdb/python/py-symtab.c |  2 +-
 gdb/source.c           |  6 +++---
 gdb/symfile.c          |  2 +-
 gdb/symmisc.c          | 10 +++++-----
 gdb/symtab.c           |  6 +++---
 gdb/symtab.h           | 21 +++++++++++++++------
 gdb/z80-tdep.c         |  2 +-
 13 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 4444187515fb..b95ab1e87b81 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2474,8 +2474,8 @@ amd64_skip_xmm_prologue (CORE_ADDR pc, CORE_ADDR start_pc)
 
   start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
   if (start_pc_sal.symtab == NULL
-      || producer_is_gcc_ge_4 (SYMTAB_COMPUNIT
-				 (start_pc_sal.symtab)->producer ()) < 6
+      || producer_is_gcc_ge_4 (start_pc_sal.symtab->compunit ()
+			       ->producer ()) < 6
       || start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
     return pc;
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9567c737cabf..96a2b46dfc25 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9230,7 +9230,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
       struct symbol *sym;
 
       bv = blockvector_for_pc_sect (sal->pc, 0, &b,
-				    SYMTAB_COMPUNIT (sal->symtab));
+				    sal->symtab->compunit ());
       if (bv != NULL)
 	{
 	  sym = block_linkage_function (b);
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index c581c426eda0..93f561acccd8 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -43,7 +43,8 @@ sal_macro_scope (struct symtab_and_line sal)
 
   if (sal.symtab == NULL)
     return NULL;
-  cust = SYMTAB_COMPUNIT (sal.symtab);
+
+  cust = sal.symtab->compunit ();
   if (cust->macro_table () == NULL)
     return NULL;
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 59b70389531a..a6a70ccfea93 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4502,7 +4502,7 @@ add_block (struct block *b, struct symtab *s)
 					 + BLOCKVECTOR_NBLOCKS (bv)
 					 * sizeof (bv->block)));
   if (bv != SYMTAB_BLOCKVECTOR (s))
-    SYMTAB_COMPUNIT (s)->set_blockvector (bv);
+    s->compunit ()->set_blockvector (bv);
 
   BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
 }
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index f4ee791f17b5..0ed7bed82e23 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -59,7 +59,7 @@ mi_cmd_file_list_exec_source_file (const char *command, char **argv, int argc)
   uiout->field_string ("fullname", symtab_to_fullname (st.symtab));
 
   uiout->field_signed ("macro-info",
-		       SYMTAB_COMPUNIT (st.symtab)->macro_table () != NULL);
+		       st.symtab->compunit ()->macro_table () != NULL);
 }
 
 /* Implement -file-list-exec-source-files command.  */
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 5670a623024f..2787609d4f80 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -471,7 +471,7 @@ or1k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	{
 	  struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0);
 	  struct compunit_symtab *compunit
-	    = SYMTAB_COMPUNIT (prologue_sal.symtab);
+	    = prologue_sal.symtab->compunit ();
 	  const char *debug_format = compunit->debugformat ();
 
 	  if ((NULL != debug_format)
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index b973b25f1587..b5d102c1b7f1 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -131,7 +131,7 @@ stpy_get_producer (PyObject *self, void *closure)
   struct compunit_symtab *cust;
 
   STPY_REQUIRE_VALID (self, symtab);
-  cust = SYMTAB_COMPUNIT (symtab);
+  cust = symtab->compunit ();
   if (cust->producer () != nullptr)
     {
       const char *producer = cust->producer ();
diff --git a/gdb/source.c b/gdb/source.c
index e6ba44819413..ee896264277f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -711,7 +711,7 @@ info_source_command (const char *ignore, int from_tty)
       return;
     }
 
-  cust = SYMTAB_COMPUNIT (s);
+  cust = s->compunit ();
   printf_filtered (_("Current source file is %s\n"), s->filename);
   if (SYMTAB_DIRNAME (s) != NULL)
     printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s));
@@ -1184,9 +1184,9 @@ open_source_file (struct symtab *s)
 
   if (fd.get () < 0)
     {
-      if (SYMTAB_COMPUNIT (s) != nullptr)
+      if (s->compunit () != nullptr)
 	{
-	  const objfile *ofp = SYMTAB_COMPUNIT (s)->objfile ();
+	  const objfile *ofp = s->compunit ()->objfile ();
 
 	  std::string srcpath;
 	  if (IS_ABSOLUTE_PATH (s->filename))
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b20284cad988..46c42014a9f6 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2807,7 +2807,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
   cust->add_filetab (symtab);
 
   /* Backlink to the containing compunit symtab.  */
-  symtab->compunit_symtab = cust;
+  symtab->set_compunit (cust);
 
   return symtab;
 }
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 6e1a4c2e8341..d079ac460ee8 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -329,7 +329,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
     }
   else
     {
-      compunit_symtab *compunit = SYMTAB_COMPUNIT (symtab);
+      compunit_symtab *compunit = symtab->compunit ();
       const char *compunit_filename
 	= symtab_to_filename_for_display (compunit->primary_filetab ());
 
@@ -342,7 +342,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
      compunit_symtabs included by this one. */
   if (is_main_symtab_of_compunit_symtab (symtab))
     {
-      struct compunit_symtab *cust = SYMTAB_COMPUNIT (symtab);
+      struct compunit_symtab *cust = symtab->compunit ();
 
       if (cust->user != nullptr)
 	{
@@ -956,14 +956,14 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
   struct linetable *linetable;
   struct objfile *objfile;
 
-  objfile = symtab->compunit_symtab->objfile ();
+  objfile = symtab->compunit ()->objfile ();
   printf_filtered (_("objfile: %ps ((struct objfile *) %s)\n"),
 		   styled_string (file_name_style.style (),
 				  objfile_name (objfile)),
 		   host_address_to_string (objfile));
   printf_filtered (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"),
-		   symtab->compunit_symtab->name,
-		   host_address_to_string (symtab->compunit_symtab));
+		   symtab->compunit ()->name,
+		   host_address_to_string (symtab->compunit ()));
   printf_filtered (_("symtab: %ps ((struct symtab *) %s)\n"),
 		   styled_string (file_name_style.style (),
 				  symtab_to_fullname (symtab)),
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5ad5cdbe3a3a..459c0c3c7487 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3709,7 +3709,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section,
   symtab_and_line sal = find_pc_sect_line (func_addr, section, 0);
 
   if (funfirstline && sal.symtab != NULL
-      && (SYMTAB_COMPUNIT (sal.symtab)->locations_valid ()
+      && (sal.symtab->compunit ()->locations_valid ()
 	  || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
     {
       struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
@@ -3885,7 +3885,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
      have proven the CU (Compilation Unit) supports it.  sal->SYMTAB does not
      have to be set by the caller so we use SYM instead.  */
   if (sym != NULL
-      && SYMTAB_COMPUNIT (symbol_symtab (sym))->locations_valid ())
+      && symbol_symtab (sym)->compunit ()->locations_valid ())
     force_skip = 0;
 
   saved_pc = pc;
@@ -6095,7 +6095,7 @@ collect_file_symbol_completion_matches (completion_tracker &tracker,
      for symbols which match.  */
   iterate_over_symtabs (srcfile, [&] (symtab *s)
     {
-      add_symtab_completions (SYMTAB_COMPUNIT (s),
+      add_symtab_completions (s->compunit (),
 			      tracker, mode, lookup_name,
 			      sym_text, word, TYPE_CODE_UNDEF);
       return false;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c319d51a2714..c313d54de18e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1373,6 +1373,16 @@ typedef std::vector<CORE_ADDR> section_offsets;
 
 struct symtab
 {
+  struct compunit_symtab *compunit () const
+  {
+    return m_compunit;
+  }
+
+  void set_compunit (struct compunit_symtab *compunit)
+  {
+    m_compunit = compunit;
+  }
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1380,7 +1390,7 @@ struct symtab
 
   /* Backlink to containing compunit symtab.  */
 
-  struct compunit_symtab *compunit_symtab;
+  struct compunit_symtab *m_compunit;
 
   /* Table mapping core addresses to line numbers for this file.
      Can be NULL if none.  Never shared between different symtabs.  */
@@ -1405,15 +1415,14 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab)
 #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
 #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
 #define SYMTAB_BLOCKVECTOR(symtab) \
-  (SYMTAB_COMPUNIT (symtab)->blockvector ())
+  (symtab->compunit ()->blockvector ())
 #define SYMTAB_OBJFILE(symtab) \
-  (SYMTAB_COMPUNIT (symtab)->objfile ())
+  (symtab->compunit ()->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
-#define SYMTAB_DIRNAME(symtab) (SYMTAB_COMPUNIT (symtab)->dirname ())
+#define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ())
 
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
    as the list of all source files (what gdb has historically associated with
@@ -1665,7 +1674,7 @@ extern enum language compunit_language (const struct compunit_symtab *cust);
 static inline bool
 is_main_symtab_of_compunit_symtab (struct symtab *symtab)
 {
-  return symtab == SYMTAB_COMPUNIT (symtab)->primary_filetab ();
+  return symtab == symtab->compunit ()->primary_filetab ();
 }
 \f
 
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index 4a58fe5138ea..a252574c94e2 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -495,7 +495,7 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (prologue_end != 0)
     {
       struct symtab_and_line prologue_sal = find_pc_line (func_addr, 0);
-      struct compunit_symtab *compunit = SYMTAB_COMPUNIT (prologue_sal.symtab);
+      struct compunit_symtab *compunit = prologue_sal.symtab->compunit ();
       const char *debug_format = compunit->debugformat ();
 
       if (debug_format != NULL &&
-- 
2.34.1


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

* [PATCH 17/33] gdb: remove SYMTAB_LINETABLE macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (15 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE " Simon Marchi via Gdb-patches
                   ` (16 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symtab's linetable.  Remove the
corresponding macro and adjust all callers.

Change-Id: I159183fc0ccd8e18ab937b3c2f09ef2244ec6e9c
---
 gdb/buildsym.c            | 12 +++++-------
 gdb/disasm.c              | 16 ++++++++--------
 gdb/jit.c                 |  7 +++----
 gdb/mdebugread.c          | 14 +++++++-------
 gdb/mi/mi-symbol-cmds.c   |  8 ++++----
 gdb/objfiles.c            |  2 +-
 gdb/python/py-linetable.c | 20 ++++++++++----------
 gdb/record-btrace.c       |  2 +-
 gdb/symmisc.c             |  9 +++++----
 gdb/symtab.c              | 18 +++++++++---------
 gdb/symtab.h              | 13 +++++++++++--
 11 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b42c40830c90..2a99a96e2e60 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -977,15 +977,13 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
       if (subfile->line_vector)
 	{
 	  /* Reallocate the line table on the symbol obstack.  */
-	  SYMTAB_LINETABLE (symtab) = (struct linetable *)
-	    obstack_alloc (&m_objfile->objfile_obstack, linetablesize);
-	  memcpy (SYMTAB_LINETABLE (symtab), subfile->line_vector,
-		  linetablesize);
+	  symtab->set_linetable
+	    ((struct linetable *)
+	     obstack_alloc (&m_objfile->objfile_obstack, linetablesize));
+	  memcpy (symtab->linetable (), subfile->line_vector, linetablesize);
 	}
       else
-	{
-	  SYMTAB_LINETABLE (symtab) = NULL;
-	}
+	symtab->set_linetable (nullptr);
 
       /* Use whatever language we have been using for this
 	 subfile, not the one that was deduced in allocate_symtab
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 3000e5dddad9..d739e22293e0 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -393,10 +393,10 @@ do_mixed_source_and_assembly_deprecated
   int num_displayed = 0;
   print_source_lines_flags psl_flags = 0;
 
-  gdb_assert (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL);
+  gdb_assert (symtab != nullptr && symtab->linetable () != nullptr);
 
-  nlines = SYMTAB_LINETABLE (symtab)->nitems;
-  le = SYMTAB_LINETABLE (symtab)->item;
+  nlines = symtab->linetable ()->nitems;
+  le = symtab->linetable ()->item;
 
   if (flags & DISASSEMBLY_FILENAME)
     psl_flags |= PRINT_SOURCE_LINES_FILENAME;
@@ -535,7 +535,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
   struct symtab *last_symtab;
   int last_line;
 
-  gdb_assert (main_symtab != NULL && SYMTAB_LINETABLE (main_symtab) != NULL);
+  gdb_assert (main_symtab != NULL && main_symtab->linetable () != NULL);
 
   /* First pass: collect the list of all source files and lines.
      We do this so that we can only print lines containing code once.
@@ -553,8 +553,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
      line after the opening brace.  We still want to print this opening brace.
      first_le is used to implement this.  */
 
-  nlines = SYMTAB_LINETABLE (main_symtab)->nitems;
-  le = SYMTAB_LINETABLE (main_symtab)->item;
+  nlines = main_symtab->linetable ()->nitems;
+  le = main_symtab->linetable ()->item;
   first_le = NULL;
 
   /* Skip all the preceding functions.  */
@@ -850,8 +850,8 @@ gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
   /* Assume symtab is valid for whole PC range.  */
   symtab = find_pc_line_symtab (low);
 
-  if (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL)
-    nlines = SYMTAB_LINETABLE (symtab)->nitems;
+  if (symtab != NULL && symtab->linetable () != NULL)
+    nlines = symtab->linetable ()->nitems;
 
   if (!(flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE))
       || nlines <= 0)
diff --git a/gdb/jit.c b/gdb/jit.c
index 6f397fc91fc7..c8415781672a 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -512,10 +512,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       size_t size = ((stab->linetable->nitems - 1)
 		     * sizeof (struct linetable_entry)
 		     + sizeof (struct linetable));
-      SYMTAB_LINETABLE (filetab)
-	= (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size);
-      memcpy (SYMTAB_LINETABLE (filetab),
-	      stab->linetable.get (), size);
+      filetab->set_linetable ((struct linetable *)
+			      obstack_alloc (&objfile->objfile_obstack, size));
+      memcpy (filetab->linetable (), stab->linetable.get (), size);
     }
 
   blockvector_size = (sizeof (struct blockvector)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index a6a70ccfea93..3dc6a8b72971 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4089,7 +4089,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 
       psymtab_language = cust->primary_filetab ()->language;
 
-      lines = SYMTAB_LINETABLE (cust->primary_filetab ());
+      lines = cust->primary_filetab ()->linetable ();
 
       /* Get a new lexical context.  */
 
@@ -4173,11 +4173,11 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
       size = lines->nitems;
       if (size > 1)
 	--size;
-      SYMTAB_LINETABLE (cust->primary_filetab ())
-	= ((struct linetable *)
-	   obstack_copy (&mdebugread_objfile->objfile_obstack,
-			 lines, (sizeof (struct linetable)
-				 + size * sizeof (lines->item))));
+      cust->primary_filetab ()->set_linetable
+	((struct linetable *)
+	 obstack_copy (&mdebugread_objfile->objfile_obstack,
+		       lines, (sizeof (struct linetable)
+			       + size * sizeof (lines->item))));
       xfree (lines);
 
       /* .. and our share of externals.
@@ -4623,7 +4623,7 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
   add_compunit_symtab_to_objfile (cust);
   symtab = allocate_symtab (cust, name);
 
-  SYMTAB_LINETABLE (symtab) = new_linetable (maxlines);
+  symtab->set_linetable (new_linetable (maxlines));
   lang = compunit_language (cust);
 
   /* All symtabs must have at least two blocks.  */
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 2177354ae19c..2078ab8e5243 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -53,12 +53,12 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
   gdbarch = SYMTAB_OBJFILE (s)->arch ();
 
   ui_out_emit_list list_emitter (uiout, "lines");
-  if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0)
-    for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++)
+  if (s->linetable () != NULL && s->linetable ()->nitems > 0)
+    for (i = 0; i < s->linetable ()->nitems; i++)
       {
 	ui_out_emit_tuple tuple_emitter (uiout, NULL);
-	uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc);
-	uiout->field_signed ("line", SYMTAB_LINETABLE (s)->item[i].line);
+	uiout->field_core_addr ("pc", gdbarch, s->linetable ()->item[i].pc);
+	uiout->field_signed ("line", s->linetable ()->item[i].line);
       }
 }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 7e1ec6ca92dd..d41dc73b02b8 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -656,7 +656,7 @@ objfile_relocate1 (struct objfile *objfile,
 	    struct linetable *l;
 
 	    /* First the line table.  */
-	    l = SYMTAB_LINETABLE (s);
+	    l = s->linetable ();
 	    if (l)
 	      {
 		for (int i = 0; i < l->nitems; ++i)
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index dfd4cbebdae8..8e545febb171 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -192,16 +192,16 @@ ltpy_has_line (PyObject *self, PyObject *args)
   if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
     return NULL;
 
-  if (SYMTAB_LINETABLE (symtab) == NULL)
+  if (symtab->linetable () == NULL)
     {
       PyErr_SetString (PyExc_RuntimeError,
 		       _("Linetable information not found in symbol table"));
       return NULL;
     }
 
-  for (index = 0; index < SYMTAB_LINETABLE (symtab)->nitems; index++)
+  for (index = 0; index < symtab->linetable ()->nitems; index++)
     {
-      struct linetable_entry *item = &(SYMTAB_LINETABLE (symtab)->item[index]);
+      struct linetable_entry *item = &(symtab->linetable ()->item[index]);
       if (item->line == py_line)
 	  Py_RETURN_TRUE;
     }
@@ -223,7 +223,7 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
 
   LTPY_REQUIRE_VALID (self, symtab);
 
-  if (SYMTAB_LINETABLE (symtab) == NULL)
+  if (symtab->linetable () == NULL)
     {
       PyErr_SetString (PyExc_RuntimeError,
 		       _("Linetable information not found in symbol table"));
@@ -234,9 +234,9 @@ ltpy_get_all_source_lines (PyObject *self, PyObject *args)
   if (source_dict == NULL)
     return NULL;
 
-  for (index = 0; index < SYMTAB_LINETABLE (symtab)->nitems; index++)
+  for (index = 0; index < symtab->linetable ()->nitems; index++)
     {
-      item = &(SYMTAB_LINETABLE (symtab)->item[index]);
+      item = &(symtab->linetable ()->item[index]);
 
       /* 0 is used to signify end of line table information.  Do not
 	 include in the source set. */
@@ -399,13 +399,13 @@ ltpy_iternext (PyObject *self)
 
   LTPY_REQUIRE_VALID (iter_obj->source, symtab);
 
-  if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems)
+  if (iter_obj->current_index >= symtab->linetable ()->nitems)
     {
       PyErr_SetNone (PyExc_StopIteration);
       return NULL;
     }
 
-  item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]);
+  item = &(symtab->linetable ()->item[iter_obj->current_index]);
 
   /* Skip over internal entries such as 0.  0 signifies the end of
      line table data and is not useful to the API user.  */
@@ -414,12 +414,12 @@ ltpy_iternext (PyObject *self)
       iter_obj->current_index++;
 
       /* Exit if the internal value is the last item in the line table.  */
-      if (iter_obj->current_index >= SYMTAB_LINETABLE (symtab)->nitems)
+      if (iter_obj->current_index >= symtab->linetable ()->nitems)
 	{
 	  PyErr_SetNone (PyExc_StopIteration);
 	  return NULL;
 	}
-      item = &(SYMTAB_LINETABLE (symtab)->item[iter_obj->current_index]);
+      item = &(symtab->linetable ()->item[iter_obj->current_index]);
     }
 
   obj = build_linetable_entry (item->line, item->pc);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index e6542bd317a9..3dfdf592dd51 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -713,7 +713,7 @@ btrace_find_line_range (CORE_ADDR pc)
   if (symtab == NULL)
     return btrace_mk_line_range (NULL, 0, 0);
 
-  ltable = SYMTAB_LINETABLE (symtab);
+  ltable = symtab->linetable ();
   if (ltable == NULL)
     return btrace_mk_line_range (symtab, 0, 0);
 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index d079ac460ee8..2fdd0f626274 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -77,7 +77,7 @@ print_objfile_statistics (void)
 	    for (symtab *s : cu->filetabs ())
 	      {
 		i++;
-		if (SYMTAB_LINETABLE (s) != NULL)
+		if (s->linetable () != NULL)
 		  linetables++;
 	      }
 	  }
@@ -259,7 +259,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 		    language_str (symtab->language));
 
   /* First print the line table.  */
-  l = SYMTAB_LINETABLE (symtab);
+  l = symtab->linetable ();
   if (l)
     {
       fprintf_filtered (outfile, "\nLine table:\n\n");
@@ -824,7 +824,8 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
 				     : "(null)");
 		    printf_filtered ("\t  "
 				     "linetable ((struct linetable *) %s)\n",
-				     host_address_to_string (symtab->linetable));
+				     host_address_to_string
+				       (symtab->linetable ()));
 		    printf_filtered ("\t}\n");
 		  }
 	      }
@@ -968,7 +969,7 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
 		   styled_string (file_name_style.style (),
 				  symtab_to_fullname (symtab)),
 		   host_address_to_string (symtab));
-  linetable = SYMTAB_LINETABLE (symtab);
+  linetable = symtab->linetable ();
   printf_filtered (_("linetable: ((struct linetable *) %s):\n"),
 		   host_address_to_string (linetable));
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 459c0c3c7487..f796ee4bd362 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3285,7 +3285,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
   for (symtab *iter_s : cust->filetabs ())
     {
       /* Find the best line in this symtab.  */
-      l = SYMTAB_LINETABLE (iter_s);
+      l = iter_s->linetable ();
       if (!l)
 	continue;
       len = l->nitems;
@@ -3454,7 +3454,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
   struct symtab *best_symtab;
 
   /* First try looking it up in the given symtab.  */
-  best_linetable = SYMTAB_LINETABLE (sym_tab);
+  best_linetable = sym_tab->linetable ();
   best_symtab = sym_tab;
   best_index = find_line_common (best_linetable, line, &exact, 0);
   if (best_index < 0 || !exact)
@@ -3493,7 +3493,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
 		  if (FILENAME_CMP (symtab_to_fullname (sym_tab),
 				    symtab_to_fullname (s)) != 0)
 		    continue;	
-		  l = SYMTAB_LINETABLE (s);
+		  l = s->linetable ();
 		  ind = find_line_common (l, line, &exact, 0);
 		  if (ind >= 0)
 		    {
@@ -3545,14 +3545,14 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line,
       int was_exact;
       int idx;
 
-      idx = find_line_common (SYMTAB_LINETABLE (symtab), line, &was_exact,
+      idx = find_line_common (symtab->linetable (), line, &was_exact,
 			      start);
       if (idx < 0)
 	break;
 
       if (!was_exact)
 	{
-	  struct linetable_entry *item = &SYMTAB_LINETABLE (symtab)->item[idx];
+	  struct linetable_entry *item = &symtab->linetable ()->item[idx];
 
 	  if (*best_item == NULL
 	      || (item->line < (*best_item)->line && item->is_stmt))
@@ -3561,7 +3561,7 @@ find_pcs_for_symtab_line (struct symtab *symtab, int line,
 	  break;
 	}
 
-      result.push_back (SYMTAB_LINETABLE (symtab)->item[idx].pc);
+      result.push_back (symtab->linetable ()->item[idx].pc);
       start = idx + 1;
     }
 
@@ -3586,7 +3586,7 @@ find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc)
   symtab = find_line_symtab (symtab, line, &ind, NULL);
   if (symtab != NULL)
     {
-      l = SYMTAB_LINETABLE (symtab);
+      l = symtab->linetable ();
       *pc = l->item[ind].pc;
       return true;
     }
@@ -3783,7 +3783,7 @@ skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
   int i;
 
   /* Give up if this symbol has no lineinfo table.  */
-  l = SYMTAB_LINETABLE (symtab);
+  l = symtab->linetable ();
   if (l == NULL)
     return func_addr;
 
@@ -4025,7 +4025,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
 	 do this.  */
       if (prologue_sal.symtab->language != language_asm)
 	{
-	  struct linetable *linetable = SYMTAB_LINETABLE (prologue_sal.symtab);
+	  struct linetable *linetable = prologue_sal.symtab->linetable ();
 	  int idx = 0;
 
 	  /* Skip any earlier lines, and any end-of-sequence marker
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c313d54de18e..8881f4e5c02b 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1383,6 +1383,16 @@ struct symtab
     m_compunit = compunit;
   }
 
+  struct linetable *linetable () const
+  {
+    return m_linetable;
+  }
+
+  void set_linetable (struct linetable *linetable)
+  {
+    m_linetable = linetable;
+  }
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1395,7 +1405,7 @@ struct symtab
   /* Table mapping core addresses to line numbers for this file.
      Can be NULL if none.  Never shared between different symtabs.  */
 
-  struct linetable *linetable;
+  struct linetable *m_linetable;
 
   /* Name of this source file.  This pointer is never NULL.  */
 
@@ -1415,7 +1425,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
 #define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
 #define SYMTAB_BLOCKVECTOR(symtab) \
   (symtab->compunit ()->blockvector ())
-- 
2.34.1


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

* [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (16 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 17/33] gdb: remove SYMTAB_LINETABLE " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 19/33] gdb: remove SYMTAB_BLOCKVECTOR macro Simon Marchi via Gdb-patches
                   ` (15 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symtab's language.  Remove the
corresponding macro and adjust all callers.

Change-Id: I9f4d840b11c19f80f39bac1bce020fdd1739e11f
---
 gdb/buildsym.c    |  2 +-
 gdb/dwarf2/read.c |  8 ++++----
 gdb/linespec.c    |  2 +-
 gdb/mdebugread.c  |  5 +++--
 gdb/source.c      |  3 ++-
 gdb/stack.c       |  2 +-
 gdb/symfile.c     |  2 +-
 gdb/symmisc.c     |  8 ++++----
 gdb/symtab.c      |  8 ++++----
 gdb/symtab.h      | 13 +++++++++++--
 10 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 2a99a96e2e60..27206f97b2b0 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -991,7 +991,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block,
 	 we created the subfile, and we may have altered our
 	 opinion of what language it is from things we found in
 	 the symbols.  */
-      symtab->language = subfile->language;
+      symtab->set_language (subfile->language);
     }
 
   /* Make sure the filetab of main_subfile is the primary filetab of the CU.  */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index fb138de86adc..3bbd253d8413 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9477,8 +9477,8 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
 	 compilation is from a C file generated by language preprocessors, do
 	 not set the language if it was already deduced by start_subfile.  */
       if (!(cu->per_cu->lang == language_c
-	    && cust->primary_filetab ()->language != language_unknown))
-	cust->primary_filetab ()->language = cu->per_cu->lang;
+	    && cust->primary_filetab ()->language () != language_unknown))
+	cust->primary_filetab ()->set_language (cu->per_cu->lang);
 
       /* GCC-4.0 has started to support -fvar-tracking.  GCC-3.x still can
 	 produce DW_AT_location with location lists but it can be possibly
@@ -9562,8 +9562,8 @@ process_full_type_unit (dwarf2_cu *cu,
 	     do not set the language if it was already deduced by
 	     start_subfile.  */
 	  if (!(cu->per_cu->lang == language_c
-		&& cust->primary_filetab ()->language != language_c))
-	    cust->primary_filetab ()->language = cu->per_cu->lang;
+		&& cust->primary_filetab ()->language () != language_c))
+	    cust->primary_filetab ()->set_language (cu->per_cu->lang);
 	}
     }
   else
diff --git a/gdb/linespec.c b/gdb/linespec.c
index f8b4b86a1e8e..c16e81753c0d 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4424,7 +4424,7 @@ add_matching_symbols_to_info (const char *name,
 	     which we don't have debug info.  Check for a minimal symbol in
 	     this case.  */
 	  if (prev_len == info->result.symbols->size ()
-	      && elt->language == language_asm)
+	      && elt->language () == language_asm)
 	    search_minsyms_for_name (info, lookup_name, pspace, elt);
 	}
     }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 3dc6a8b72971..192fafa5d02a 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4084,10 +4084,11 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 
 	  /* The proper language was already determined when building
 	     the psymtab, use it.  */
-	  cust->primary_filetab ()->language = PST_PRIVATE (pst)->pst_language;
+	  cust->primary_filetab ()->set_language
+	    (PST_PRIVATE (pst)->pst_language);
 	}
 
-      psymtab_language = cust->primary_filetab ()->language;
+      psymtab_language = cust->primary_filetab ()->language ();
 
       lines = cust->primary_filetab ()->linetable ();
 
diff --git a/gdb/source.c b/gdb/source.c
index ee896264277f..e99fff885254 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -722,7 +722,8 @@ info_source_command (const char *ignore, int from_tty)
     printf_filtered (_("Contains %d line%s.\n"), (int) offsets->size (),
 		     offsets->size () == 1 ? "" : "s");
 
-  printf_filtered (_("Source language is %s.\n"), language_str (s->language));
+  printf_filtered (_("Source language is %s.\n"),
+		   language_str (s->language ()));
   printf_filtered (_("Producer is %s.\n"),
 		   (cust->producer ()) != nullptr
 		    ? cust->producer () : _("unknown"));
diff --git a/gdb/stack.c b/gdb/stack.c
index c7269e2ac326..8d5983e64391 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1638,7 +1638,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
 
   if (s)
     printf_filtered (" source language %s.\n",
-		     language_str (s->language));
+		     language_str (s->language ()));
 
   {
     /* Address of the argument list for this frame, or 0.  */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 46c42014a9f6..1a64fc797423 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2780,7 +2780,7 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
 
   symtab->filename = objfile->intern (filename);
   symtab->fullname = NULL;
-  symtab->language = deduce_language_from_filename (filename);
+  symtab->set_language (deduce_language_from_filename (filename));
 
   /* This can be very verbose with lots of headers.
      Only print at higher debug levels.  */
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 2fdd0f626274..24b2915a3acc 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -256,7 +256,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 		    objfile_name (objfile),
 		    host_address_to_string (objfile));
   fprintf_filtered (outfile, "Language: %s\n",
-		    language_str (symtab->language));
+		    language_str (symtab->language ()));
 
   /* First print the line table.  */
   l = symtab->linetable ();
@@ -370,11 +370,11 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile)
      because certain routines used during dump_symtab() use the current
      language to print an image of the symbol.  We'll restore it later.
      But use only real languages, not placeholders.  */
-  if (symtab->language != language_unknown
-      && symtab->language != language_auto)
+  if (symtab->language () != language_unknown
+      && symtab->language () != language_auto)
     {
       scoped_restore_current_language save_lang;
-      set_language (symtab->language);
+      set_language (symtab->language ());
       dump_symtab_1 (symtab, outfile);
     }
   else
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f796ee4bd362..65359374fef6 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -407,7 +407,7 @@ compunit_language (const struct compunit_symtab *cust)
 
 /* The language of the compunit symtab is the language of its primary
    source file.  */
-  return SYMTAB_LANGUAGE (symtab);
+  return symtab->language ();
 }
 
 /* See symtab.h.  */
@@ -3710,7 +3710,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section,
 
   if (funfirstline && sal.symtab != NULL
       && (sal.symtab->compunit ()->locations_valid ()
-	  || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
+	  || sal.symtab->language () == language_asm))
     {
       struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
 
@@ -3840,7 +3840,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
      is likely to be the wrong choice.  */
   if (sal->symtab != nullptr
       && sal->explicit_line
-      && SYMTAB_LANGUAGE (sal->symtab) == language_asm)
+      && sal->symtab->language () == language_asm)
     return;
 
   scoped_restore_current_pspace_and_thread restore_pspace_thread;
@@ -4023,7 +4023,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
 	 The GNU assembler emits separate line notes for each instruction
 	 in a multi-instruction macro, but compilers generally will not
 	 do this.  */
-      if (prologue_sal.symtab->language != language_asm)
+      if (prologue_sal.symtab->language () != language_asm)
 	{
 	  struct linetable *linetable = prologue_sal.symtab->linetable ();
 	  int idx = 0;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 8881f4e5c02b..28309695bca3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1393,6 +1393,16 @@ struct symtab
     m_linetable = linetable;
   }
 
+  enum language language () const
+  {
+    return m_language;
+  }
+
+  void set_language (enum language language)
+  {
+    m_language = language;
+  }
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1413,7 +1423,7 @@ struct symtab
 
   /* Language of this source file.  */
 
-  enum language language;
+  enum language m_language;
 
   /* Full name of file as found by searching the source path.
      NULL if not yet known.  */
@@ -1425,7 +1435,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
 #define SYMTAB_BLOCKVECTOR(symtab) \
   (symtab->compunit ()->blockvector ())
 #define SYMTAB_OBJFILE(symtab) \
-- 
2.34.1


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

* [PATCH 19/33] gdb: remove SYMTAB_BLOCKVECTOR macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (17 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE " Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 20/33] gdb: remove SYMTAB_OBJFILE macro Simon Marchi via Gdb-patches
                   ` (14 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Remove the macro, replace with an equivalent method.

Change-Id: Id6fe2a79c04bcd6c69ccaefb7a69bc06a476288c
---
 gdb/ada-exp.y                     |  2 +-
 gdb/ada-lang.c                    |  4 ++--
 gdb/c-exp.y                       |  2 +-
 gdb/coffread.c                    |  2 +-
 gdb/compile/compile-object-load.c |  2 +-
 gdb/compile/compile.c             |  2 +-
 gdb/guile/scm-symtab.c            |  4 ++--
 gdb/linespec.c                    |  6 +++---
 gdb/mdebugread.c                  | 14 +++++++-------
 gdb/p-exp.y                       |  2 +-
 gdb/parse.c                       |  2 +-
 gdb/python/py-symtab.c            |  4 ++--
 gdb/symmisc.c                     |  2 +-
 gdb/symtab.h                      | 10 ++++++++--
 14 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 16ba336df4aa..0d5083f513bf 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1302,7 +1302,7 @@ block_lookup (const struct block *context, const char *raw_name)
     symtab = NULL;
 
   if (symtab != NULL)
-    result = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
+    result = BLOCKVECTOR_BLOCK (symtab->blockvector (), STATIC_BLOCK);
   else if (syms.empty () || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
     {
       if (context == NULL)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2bb64ae03bde..f3b8442b5508 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4384,9 +4384,9 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
      the symbol is local or not, we check the block where we found it
      against the global and static blocks of its associated symtab.  */
   if (sym
-      && BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symbol_symtab (sym)),
+      && BLOCKVECTOR_BLOCK (symbol_symtab (sym)->blockvector (),
 			    GLOBAL_BLOCK) != block
-      && BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symbol_symtab (sym)),
+      && BLOCKVECTOR_BLOCK (symbol_symtab (sym)->blockvector (),
 			    STATIC_BLOCK) != block)
     return;
 
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 464ed44a2297..4b58ce041002 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -3109,7 +3109,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 	  symtab = lookup_symtab (copy.c_str ());
 	  if (symtab)
 	    {
-	      yylval.bval = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
+	      yylval.bval = BLOCKVECTOR_BLOCK (symtab->blockvector (),
 					       STATIC_BLOCK);
 	      return FILENAME;
 	    }
diff --git a/gdb/coffread.c b/gdb/coffread.c
index f6bf973e9f75..af0699bed2d5 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1483,7 +1483,7 @@ patch_opaque_types (struct symtab *s)
   struct symbol *real_sym;
 
   /* Go through the per-file symbols only.  */
-  b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), STATIC_BLOCK);
+  b = BLOCKVECTOR_BLOCK (s->blockvector (), STATIC_BLOCK);
   ALL_BLOCK_SYMBOLS (b, iter, real_sym)
     {
       /* Find completed typedefs to use to fix opaque ones.
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 336e8d3d4351..692e9906fd7d 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -421,7 +421,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
   lookup_name_info func_matcher (GCC_FE_WRAPPER_FUNCTION,
 				 symbol_name_match_type::SEARCH_NAME);
 
-  bv = SYMTAB_BLOCKVECTOR (func_sym->owner.symtab);
+  bv = func_sym->owner.symtab->blockvector ();
   nblocks = BLOCKVECTOR_NBLOCKS (bv);
 
   gdb_ptr_type_sym = NULL;
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 7bd6ac817b8f..5ab4e48f3061 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -484,7 +484,7 @@ get_expr_block_and_pc (CORE_ADDR *pc)
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       if (cursal.symtab)
-	block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
+	block = BLOCKVECTOR_BLOCK (cursal.symtab->blockvector (),
 				   STATIC_BLOCK);
       if (block != NULL)
 	*pc = BLOCK_ENTRY_PC (block);
diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
index 40410f7b9fbd..e2a90e580166 100644
--- a/gdb/guile/scm-symtab.c
+++ b/gdb/guile/scm-symtab.c
@@ -363,7 +363,7 @@ gdbscm_symtab_global_block (SCM self)
   const struct blockvector *blockvector;
   const struct block *block;
 
-  blockvector = SYMTAB_BLOCKVECTOR (symtab);
+  blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
 
   return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab));
@@ -381,7 +381,7 @@ gdbscm_symtab_static_block (SCM self)
   const struct blockvector *blockvector;
   const struct block *block;
 
-  blockvector = SYMTAB_BLOCKVECTOR (symtab);
+  blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
 
   return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab));
diff --git a/gdb/linespec.c b/gdb/linespec.c
index c16e81753c0d..03be93728c2d 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1190,10 +1190,10 @@ iterate_over_all_matching_symtabs
 		  int i;
 
 		  for (i = FIRST_LOCAL_BLOCK;
-		       i < BLOCKVECTOR_NBLOCKS (SYMTAB_BLOCKVECTOR (symtab));
+		       i < BLOCKVECTOR_NBLOCKS (symtab->blockvector ());
 		       i++)
 		    {
-		      block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), i);
+		      block = BLOCKVECTOR_BLOCK (symtab->blockvector (), i);
 		      state->language->iterate_over_symbols
 			(block, lookup_name, name_domain,
 			 [&] (block_symbol *bsym)
@@ -1232,7 +1232,7 @@ iterate_over_file_blocks
 {
   const struct block *block;
 
-  for (block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
+  for (block = BLOCKVECTOR_BLOCK (symtab->blockvector (), STATIC_BLOCK);
        block != NULL;
        block = BLOCK_SUPERBLOCK (block))
     current_language->iterate_over_symbols (block, name, domain, callback);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 192fafa5d02a..b98ac8fe7996 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -628,7 +628,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       break;
 
     case stGlobal:		/* External symbol, goes into global block.  */
-      b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st),
+      b = BLOCKVECTOR_BLOCK (top_stack->cur_st->blockvector (),
 			     GLOBAL_BLOCK);
       s = new_symbol (name);
       SET_SYMBOL_VALUE_ADDRESS (s, (CORE_ADDR) sh->value);
@@ -771,7 +771,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       if (sh->st == stProc)
 	{
 	  const struct blockvector *bv
-	    = SYMTAB_BLOCKVECTOR (top_stack->cur_st);
+	    = top_stack->cur_st->blockvector ();
 
 	  /* The next test should normally be true, but provides a
 	     hook for nested functions (which we don't want to make
@@ -1144,7 +1144,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	{
 	  /* Finished with procedure */
 	  const struct blockvector *bv
-	    = SYMTAB_BLOCKVECTOR (top_stack->cur_st);
+	    = top_stack->cur_st->blockvector ();
 	  struct mdebug_extra_func_info *e;
 	  struct block *cblock = top_stack->cur_block;
 	  struct type *ftype = top_stack->cur_type;
@@ -4186,7 +4186,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 	 FIXME, Maybe quit once we have found the right number of ext's?  */
       top_stack->cur_st = cust->primary_filetab ();
       top_stack->cur_block
-	= BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st),
+	= BLOCKVECTOR_BLOCK (top_stack->cur_st->blockvector (),
 			     GLOBAL_BLOCK);
       top_stack->blocktype = stFile;
 
@@ -4496,13 +4496,13 @@ add_block (struct block *b, struct symtab *s)
 {
   /* Cast away "const", but that's ok because we're building the
      symtab and blockvector here.  */
-  struct blockvector *bv = (struct blockvector *) SYMTAB_BLOCKVECTOR (s);
+  struct blockvector *bv = (struct blockvector *) s->blockvector ();
 
   bv = (struct blockvector *) xrealloc ((void *) bv,
 					(sizeof (struct blockvector)
 					 + BLOCKVECTOR_NBLOCKS (bv)
 					 * sizeof (bv->block)));
-  if (bv != SYMTAB_BLOCKVECTOR (s))
+  if (bv != s->blockvector ())
     s->compunit ()->set_blockvector (bv);
 
   BLOCKVECTOR_BLOCK (bv, BLOCKVECTOR_NBLOCKS (bv)++) = b;
@@ -4566,7 +4566,7 @@ sort_blocks (struct symtab *s)
 {
   /* We have to cast away const here, but this is ok because we're
      constructing the blockvector in this code.  */
-  struct blockvector *bv = (struct blockvector *) SYMTAB_BLOCKVECTOR (s);
+  struct blockvector *bv = (struct blockvector *) s->blockvector ();
 
   if (BLOCKVECTOR_NBLOCKS (bv) <= FIRST_LOCAL_BLOCK)
     {
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 62b0a3be5a9a..10738d073f6e 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -619,7 +619,7 @@ block	:	BLOCKNAME
 			      struct symtab *tem =
 				  lookup_symtab (copy.c_str ());
 			      if (tem)
-				$$ = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (tem),
+				$$ = BLOCKVECTOR_BLOCK (tem->blockvector (),
 							STATIC_BLOCK);
 			      else
 				error (_("No file or function \"%s\"."),
diff --git a/gdb/parse.c b/gdb/parse.c
index a6595e3da069..23f0e66bf275 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -462,7 +462,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
       if (cursal.symtab)
 	expression_context_block
-	  = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
+	  = BLOCKVECTOR_BLOCK (cursal.symtab->blockvector (),
 			       STATIC_BLOCK);
       if (expression_context_block)
 	expression_context_pc = BLOCK_ENTRY_PC (expression_context_block);
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index b5d102c1b7f1..33657f1e6e43 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -181,7 +181,7 @@ stpy_global_block (PyObject *self, PyObject *args)
 
   STPY_REQUIRE_VALID (self, symtab);
 
-  blockvector = SYMTAB_BLOCKVECTOR (symtab);
+  blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
   return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
 }
@@ -197,7 +197,7 @@ stpy_static_block (PyObject *self, PyObject *args)
 
   STPY_REQUIRE_VALID (self, symtab);
 
-  blockvector = SYMTAB_BLOCKVECTOR (symtab);
+  blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
   return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
 }
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 24b2915a3acc..3f5f840fbe7f 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -278,7 +278,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
   if (is_main_symtab_of_compunit_symtab (symtab))
     {
       fprintf_filtered (outfile, "\nBlockvector:\n\n");
-      bv = SYMTAB_BLOCKVECTOR (symtab);
+      bv = symtab->blockvector ();
       len = BLOCKVECTOR_NBLOCKS (bv);
       for (i = 0; i < len; i++)
 	{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 28309695bca3..1935113336a8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1403,6 +1403,8 @@ struct symtab
     m_language = language;
   }
 
+  const struct blockvector *blockvector () const;
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1435,8 +1437,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_BLOCKVECTOR(symtab) \
-  (symtab->compunit ()->blockvector ())
 #define SYMTAB_OBJFILE(symtab) \
   (symtab->compunit ()->objfile ())
 #define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
@@ -1683,6 +1683,12 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
+inline const struct blockvector *
+symtab::blockvector () const
+{
+  return this->compunit ()->blockvector ();
+}
+
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
-- 
2.34.1


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

* [PATCH 20/33] gdb: remove SYMTAB_OBJFILE macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (18 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 19/33] gdb: remove SYMTAB_BLOCKVECTOR macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 21/33] gdb: remove SYMTAB_PSPACE macro Simon Marchi via Gdb-patches
                   ` (13 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Remove the macro, replace with an equivalent method.

Change-Id: I8f9ecd290ad28502e53c1ceca5006ba78bf042eb
---
 gdb/ada-lang.c          |  4 ++--
 gdb/annotate.c          |  2 +-
 gdb/breakpoint.c        |  8 ++++----
 gdb/cli/cli-cmds.c      |  4 ++--
 gdb/guile/scm-symtab.c  |  8 ++++----
 gdb/linespec.c          |  4 ++--
 gdb/mi/mi-symbol-cmds.c |  2 +-
 gdb/objfiles.c          |  2 +-
 gdb/python/py-symtab.c  | 18 +++++++++---------
 gdb/source-cache.c      |  4 ++--
 gdb/source.c            |  2 +-
 gdb/symmisc.c           |  4 ++--
 gdb/symtab.c            |  6 +++---
 gdb/symtab.h            | 12 +++++++++---
 gdb/tui/tui-source.c    |  2 +-
 gdb/tui/tui-winsource.c |  2 +-
 16 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f3b8442b5508..e6bfb8e1467f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11388,8 +11388,8 @@ is_known_support_routine (struct frame_info *frame)
       re_comp (known_runtime_file_name_patterns[i]);
       if (re_exec (lbasename (sal.symtab->filename)))
 	return 1;
-      if (SYMTAB_OBJFILE (sal.symtab) != NULL
-	  && re_exec (objfile_name (SYMTAB_OBJFILE (sal.symtab))))
+      if (sal.symtab->objfile () != NULL
+	  && re_exec (objfile_name (sal.symtab->objfile ())))
 	return 1;
     }
 
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 4ac1b63b66bf..b84d8f0bf6a8 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -448,7 +448,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement,
 	return false;
 
       annotate_source (s->fullname, line, (int) (*offsets)[line - 1],
-		       mid_statement, SYMTAB_OBJFILE (s)->arch (),
+		       mid_statement, s->objfile ()->arch (),
 		       pc);
 
       /* Update the current symtab and line.  */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 96a2b46dfc25..b1130acbab21 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -7194,7 +7194,7 @@ get_sal_arch (struct symtab_and_line sal)
   if (sal.section)
     return sal.section->objfile->arch ();
   if (sal.symtab)
-    return SYMTAB_OBJFILE (sal.symtab)->arch ();
+    return sal.symtab->objfile ()->arch ();
 
   return NULL;
 }
@@ -9236,8 +9236,8 @@ resolve_sal_pc (struct symtab_and_line *sal)
 	  sym = block_linkage_function (b);
 	  if (sym != NULL)
 	    {
-	      fixup_symbol_section (sym, SYMTAB_OBJFILE (sal->symtab));
-	      sal->section = sym->obj_section (SYMTAB_OBJFILE (sal->symtab));
+	      fixup_symbol_section (sym, sal->symtab->objfile ());
+	      sal->section = sym->obj_section (sal->symtab->objfile ());
 	    }
 	  else
 	    {
@@ -14736,7 +14736,7 @@ void
 breakpoint_free_objfile (struct objfile *objfile)
 {
   for (bp_location *loc : all_bp_locations ())
-    if (loc->symtab != NULL && SYMTAB_OBJFILE (loc->symtab) == objfile)
+    if (loc->symtab != NULL && loc->symtab->objfile () == objfile)
       loc->symtab = NULL;
 }
 
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2f5ce3e5fff2..67155daf5b02 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1002,7 +1002,7 @@ edit_command (const char *arg, int from_tty)
 	    error (_("No source file for address %s."),
 		   paddress (get_current_arch (), sal.pc));
 
-	  gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+	  gdbarch = sal.symtab->objfile ()->arch ();
 	  sym = find_pc_function (sal.pc);
 	  if (sym)
 	    printf_filtered ("%s is in %s (%s:%d).\n",
@@ -1329,7 +1329,7 @@ list_command (const char *arg, int from_tty)
 	error (_("No source file for address %s."),
 	       paddress (get_current_arch (), sal.pc));
 
-      gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+      gdbarch = sal.symtab->objfile ()->arch ();
       sym = find_pc_function (sal.pc);
       if (sym)
 	printf_filtered ("%s is in %s (%s:%d).\n",
diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
index e2a90e580166..d1a5056aac86 100644
--- a/gdb/guile/scm-symtab.c
+++ b/gdb/guile/scm-symtab.c
@@ -109,7 +109,7 @@ stscm_eq_symtab_smob (const void *ap, const void *bp)
 static htab_t
 stscm_objfile_symtab_map (struct symtab *symtab)
 {
-  struct objfile *objfile = SYMTAB_OBJFILE (symtab);
+  struct objfile *objfile = symtab->objfile ();
   htab_t htab = (htab_t) objfile_data (objfile, stscm_objfile_data_key);
 
   if (htab == NULL)
@@ -348,7 +348,7 @@ gdbscm_symtab_objfile (SCM self)
     = stscm_get_valid_symtab_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symtab *symtab = st_smob->symtab;
 
-  return ofscm_scm_from_objfile (SYMTAB_OBJFILE (symtab));
+  return ofscm_scm_from_objfile (symtab->objfile ());
 }
 
 /* (symtab-global-block <gdb:symtab>) -> <gdb:block>
@@ -366,7 +366,7 @@ gdbscm_symtab_global_block (SCM self)
   blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
 
-  return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab));
+  return bkscm_scm_from_block (block, symtab->objfile ());
 }
 
 /* (symtab-static-block <gdb:symtab>) -> <gdb:block>
@@ -384,7 +384,7 @@ gdbscm_symtab_static_block (SCM self)
   blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
 
-  return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab));
+  return bkscm_scm_from_block (block, symtab->objfile ());
 }
 \f
 /* Administrivia for sal (symtab-and-line) smobs.  */
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 03be93728c2d..1606af889cd0 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4323,10 +4323,10 @@ search_minsyms_for_name (struct collect_info *info,
 	{
 	  set_current_program_space (SYMTAB_PSPACE (symtab));
 	  iterate_over_minimal_symbols
-	    (SYMTAB_OBJFILE (symtab), name,
+	    (symtab->objfile (), name,
 	     [&] (struct minimal_symbol *msym)
 	       {
-		 add_minsym (msym, SYMTAB_OBJFILE (symtab), symtab,
+		 add_minsym (msym, symtab->objfile (), symtab,
 			     info->state->list_mode, &minsyms);
 		 return false;
 	       });
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 2078ab8e5243..a8edce386d23 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -50,7 +50,7 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc)
      already sorted by increasing values in the symbol table, so no
      need to perform any other sorting.  */
 
-  gdbarch = SYMTAB_OBJFILE (s)->arch ();
+  gdbarch = s->objfile ()->arch ();
 
   ui_out_emit_list list_emitter (uiout, "lines");
   if (s->linetable () != NULL && s->linetable ()->nitems > 0)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d41dc73b02b8..90163ca59b89 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -591,7 +591,7 @@ objfile::~objfile ()
   {
     struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
-    if (cursal.symtab && SYMTAB_OBJFILE (cursal.symtab) == this)
+    if (cursal.symtab && cursal.symtab->objfile () == this)
       clear_current_source_symtab_and_line ();
   }
 
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 33657f1e6e43..cb28264a03f2 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -119,7 +119,7 @@ stpy_get_objfile (PyObject *self, void *closure)
 
   STPY_REQUIRE_VALID (self, symtab);
 
-  return objfile_to_objfile_object (SYMTAB_OBJFILE (symtab)).release ();
+  return objfile_to_objfile_object (symtab->objfile ()).release ();
 }
 
 /* Getter function for symtab.producer.  */
@@ -183,7 +183,7 @@ stpy_global_block (PyObject *self, PyObject *args)
 
   blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
-  return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
+  return block_to_block_object (block, symtab->objfile ());
 }
 
 /* Return the STATIC_BLOCK of the underlying symtab.  */
@@ -199,7 +199,7 @@ stpy_static_block (PyObject *self, PyObject *args)
 
   blockvector = symtab->blockvector ();
   block = BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK);
-  return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
+  return block_to_block_object (block, symtab->objfile ());
 }
 
 /* Implementation of gdb.Symtab.linetable (self) -> gdb.LineTable.
@@ -247,7 +247,7 @@ stpy_dealloc (PyObject *obj)
     symtab->prev->next = symtab->next;
   else if (symtab->symtab)
     {
-      set_objfile_data (SYMTAB_OBJFILE (symtab->symtab),
+      set_objfile_data (symtab->symtab->objfile (),
 			stpy_objfile_data_key, symtab->next);
     }
   if (symtab->next)
@@ -330,7 +330,7 @@ salpy_dealloc (PyObject *self)
     self_sal->prev->next = self_sal->next;
   else if (self_sal->symtab != Py_None)
     set_objfile_data
-      (SYMTAB_OBJFILE (symtab_object_to_symtab (self_sal->symtab)),
+      (symtab_object_to_symtab (self_sal->symtab)->objfile (),
        salpy_objfile_data_key, self_sal->next);
 
   if (self_sal->next)
@@ -378,12 +378,12 @@ set_sal (sal_object *sal_obj, struct symtab_and_line sal)
       symtab *symtab = symtab_object_to_symtab (sal_obj->symtab);
 
       sal_obj->next
-	= ((sal_object *) objfile_data (SYMTAB_OBJFILE (symtab),
+	= ((sal_object *) objfile_data (symtab->objfile (),
 					salpy_objfile_data_key));
       if (sal_obj->next)
 	sal_obj->next->prev = sal_obj;
 
-      set_objfile_data (SYMTAB_OBJFILE (symtab),
+      set_objfile_data (symtab->objfile (),
 			salpy_objfile_data_key, sal_obj);
     }
   else
@@ -406,10 +406,10 @@ set_symtab (symtab_object *obj, struct symtab *symtab)
     {
       obj->next
 	= ((symtab_object *)
-	   objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key));
+	   objfile_data (symtab->objfile (), stpy_objfile_data_key));
       if (obj->next)
 	obj->next->prev = obj;
-      set_objfile_data (SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj);
+      set_objfile_data (symtab->objfile (), stpy_objfile_data_key, obj);
     }
   else
     obj->next = NULL;
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 373607fc9cb4..27cea006a431 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -107,8 +107,8 @@ source_cache::get_plain_source_lines (struct symtab *s,
     perror_with_name (symtab_to_filename_for_display (s));
 
   time_t mtime = 0;
-  if (SYMTAB_OBJFILE (s) != NULL && SYMTAB_OBJFILE (s)->obfd != NULL)
-    mtime = SYMTAB_OBJFILE (s)->mtime;
+  if (s->objfile () != NULL && s->objfile ()->obfd != NULL)
+    mtime = s->objfile ()->mtime;
   else if (current_program_space->exec_bfd ())
     mtime = current_program_space->ebfd_mtime;
 
diff --git a/gdb/source.c b/gdb/source.c
index e99fff885254..d184990a6c0a 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1559,7 +1559,7 @@ info_line_command (const char *arg, int from_tty)
       else if (sal.line > 0
 	       && find_line_pc_range (sal, &start_pc, &end_pc))
 	{
-	  struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+	  struct gdbarch *gdbarch = sal.symtab->objfile ()->arch ();
 
 	  if (start_pc == end_pc)
 	    {
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 3f5f840fbe7f..62b584041def 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -131,7 +131,7 @@ dump_objfile (struct objfile *objfile)
 	      printf_filtered ("%s at %s",
 			       symtab_to_filename_for_display (symtab),
 			       host_address_to_string (symtab));
-	      if (SYMTAB_OBJFILE (symtab) != objfile)
+	      if (symtab->objfile () != objfile)
 		printf_filtered (", NOT ON CHAIN!");
 	      printf_filtered ("\n");
 	    }
@@ -234,7 +234,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
 static void
 dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 {
-  struct objfile *objfile = SYMTAB_OBJFILE (symtab);
+  struct objfile *objfile = symtab->objfile ();
   struct gdbarch *gdbarch = objfile->arch ();
   int i;
   struct mdict_iterator miter;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 65359374fef6..671e22c57235 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3712,7 +3712,7 @@ find_function_start_sal_1 (CORE_ADDR func_addr, obj_section *section,
       && (sal.symtab->compunit ()->locations_valid ()
 	  || sal.symtab->language () == language_asm))
     {
-      struct gdbarch *gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+      struct gdbarch *gdbarch = sal.symtab->objfile ()->arch ();
 
       sal.pc = func_addr;
       if (gdbarch_skip_entrypoint_p (gdbarch))
@@ -6527,7 +6527,7 @@ struct objfile *
 symbol_objfile (const struct symbol *symbol)
 {
   gdb_assert (SYMBOL_OBJFILE_OWNED (symbol));
-  return SYMTAB_OBJFILE (symbol->owner.symtab);
+  return symbol->owner.symtab->objfile ();
 }
 
 /* See symtab.h.  */
@@ -6537,7 +6537,7 @@ symbol_arch (const struct symbol *symbol)
 {
   if (!SYMBOL_OBJFILE_OWNED (symbol))
     return symbol->owner.arch;
-  return SYMTAB_OBJFILE (symbol->owner.symtab)->arch ();
+  return symbol->owner.symtab->objfile ()->arch ();
 }
 
 /* See symtab.h.  */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 1935113336a8..9cfbd71937a3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1405,6 +1405,8 @@ struct symtab
 
   const struct blockvector *blockvector () const;
 
+  struct objfile *objfile () const;
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1437,9 +1439,7 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_OBJFILE(symtab) \
-  (symtab->compunit ()->objfile ())
-#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
+#define SYMTAB_PSPACE(symtab) ((symtab)->objfile ()->pspace)
 #define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ())
 
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
@@ -1689,6 +1689,12 @@ symtab::blockvector () const
   return this->compunit ()->blockvector ();
 }
 
+inline struct objfile *
+symtab::objfile () const
+{
+  return this->compunit ()->objfile ();
+}
+
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index bbdefbafb615..294ea1c7f136 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -70,7 +70,7 @@ tui_source_window::set_contents (struct gdbarch *arch,
   m_fullname = make_unique_xstrdup (symtab_to_fullname (s));
 
   cur_line = 0;
-  m_gdbarch = SYMTAB_OBJFILE (s)->arch ();
+  m_gdbarch = s->objfile ()->arch ();
   m_start_line_or_addr.loa = LOA_LINE;
   cur_line_no = m_start_line_or_addr.u.line_no = line_no;
 
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 23c7ddae4290..c8a1c1aa64bc 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -199,7 +199,7 @@ tui_update_source_windows_with_line (struct symtab_and_line sal)
   if (sal.symtab != nullptr)
     {
       find_line_pc (sal.symtab, sal.line, &sal.pc);
-      gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+      gdbarch = sal.symtab->objfile ()->arch ();
     }
 
   for (struct tui_source_window_base *win_info : tui_source_windows ())
-- 
2.34.1


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

* [PATCH 21/33] gdb: remove SYMTAB_PSPACE macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (19 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 20/33] gdb: remove SYMTAB_OBJFILE macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 22/33] gdb: remove SYMTAB_DIRNAME macro Simon Marchi via Gdb-patches
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Remove the macro, replace with an equivalent method.

Change-Id: Icccc20e7e8ae03ac4dac1c7514c25a12a9a0ac69
---
 gdb/annotate.c |  2 +-
 gdb/linespec.c | 40 ++++++++++++++++++++--------------------
 gdb/source.c   |  2 +-
 gdb/symtab.c   |  8 ++++++++
 gdb/symtab.h   |  3 ++-
 5 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/gdb/annotate.c b/gdb/annotate.c
index b84d8f0bf6a8..7201d9a06dcb 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -453,7 +453,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement,
 
       /* Update the current symtab and line.  */
       symtab_and_line sal;
-      sal.pspace = SYMTAB_PSPACE (s);
+      sal.pspace = s->pspace ();
       sal.symtab = s;
       sal.line = line;
       set_current_source_symtab_and_line (sal);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1606af889cd0..9531295e6a3d 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2265,7 +2265,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
       for (const auto &sym : ls->labels.label_symbols)
 	{
 	  struct program_space *pspace
-	    = SYMTAB_PSPACE (symbol_symtab (sym.symbol));
+	    = symbol_symtab (sym.symbol)->pspace ();
 
 	  if (symbol_to_sal (&sal, state->funfirstline, sym.symbol)
 	      && maybe_add_address (state->addr_set, pspace, sal.pc))
@@ -2287,7 +2287,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
 	  for (const auto &sym : ls->function_symbols)
 	    {
 	      program_space *pspace
-		= SYMTAB_PSPACE (symbol_symtab (sym.symbol));
+		= symbol_symtab (sym.symbol)->pspace ();
 	      set_current_program_space (pspace);
 
 	      /* Don't skip to the first line of the function if we
@@ -3539,8 +3539,8 @@ lookup_prefix_sym (struct linespec_state *state,
 	{
 	  /* Program spaces that are executing startup should have
 	     been filtered out earlier.  */
-	  gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
-	  set_current_program_space (SYMTAB_PSPACE (elt));
+	  gdb_assert (!elt->pspace ()->executing_startup);
+	  set_current_program_space (elt->pspace ());
 	  iterate_over_file_blocks (elt, lookup_name, STRUCT_DOMAIN, collector);
 	  iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, collector);
 	}
@@ -3558,8 +3558,8 @@ compare_symbols (const block_symbol &a, const block_symbol &b)
 {
   uintptr_t uia, uib;
 
-  uia = (uintptr_t) SYMTAB_PSPACE (symbol_symtab (a.symbol));
-  uib = (uintptr_t) SYMTAB_PSPACE (symbol_symtab (b.symbol));
+  uia = (uintptr_t) symbol_symtab (a.symbol)->pspace ();
+  uib = (uintptr_t) symbol_symtab (b.symbol)->pspace ();
 
   if (uia < uib)
     return true;
@@ -3683,7 +3683,7 @@ find_method (struct linespec_state *self,
 
       /* Program spaces that are executing startup should have
 	 been filtered out earlier.  */
-      pspace = SYMTAB_PSPACE (symbol_symtab (sym));
+      pspace = symbol_symtab (sym)->pspace ();
       gdb_assert (!pspace->executing_startup);
       set_current_program_space (pspace);
       t = check_typedef (SYMBOL_TYPE (sym));
@@ -3694,7 +3694,7 @@ find_method (struct linespec_state *self,
 	 sure not to miss the last batch.  */
       if (ix == sym_classes->size () - 1
 	  || (pspace
-	      != SYMTAB_PSPACE (symbol_symtab (sym_classes->at (ix + 1).symbol))))
+	      != symbol_symtab (sym_classes->at (ix + 1).symbol)->pspace ()))
 	{
 	  /* If we did not find a direct implementation anywhere in
 	     this program space, consider superclasses.  */
@@ -4058,7 +4058,7 @@ find_label_symbols (struct linespec_state *self,
       for (const auto &elt : function_symbols)
 	{
 	  fn_sym = elt.symbol;
-	  set_current_program_space (SYMTAB_PSPACE (symbol_symtab (fn_sym)));
+	  set_current_program_space (symbol_symtab (fn_sym)->pspace ());
 	  block = SYMBOL_BLOCK_VALUE (fn_sym);
 
 	  find_label_symbols_in_block (block, name, fn_sym, completion_mode,
@@ -4087,13 +4087,13 @@ decode_digits_list_mode (struct linespec_state *self,
       /* The logic above should ensure this.  */
       gdb_assert (elt != NULL);
 
-      set_current_program_space (SYMTAB_PSPACE (elt));
+      set_current_program_space (elt->pspace ());
 
       /* Simplistic search just for the list command.  */
       val.symtab = find_line_symtab (elt, val.line, NULL, NULL);
       if (val.symtab == NULL)
 	val.symtab = elt;
-      val.pspace = SYMTAB_PSPACE (elt);
+      val.pspace = elt->pspace ();
       val.pc = 0;
       val.explicit_line = true;
 
@@ -4121,13 +4121,13 @@ decode_digits_ordinary (struct linespec_state *self,
       /* The logic above should ensure this.  */
       gdb_assert (elt != NULL);
 
-      set_current_program_space (SYMTAB_PSPACE (elt));
+      set_current_program_space (elt->pspace ());
 
       pcs = find_pcs_for_symtab_line (elt, line, best_entry);
       for (CORE_ADDR pc : pcs)
 	{
 	  symtab_and_line sal;
-	  sal.pspace = SYMTAB_PSPACE (elt);
+	  sal.pspace = elt->pspace ();
 	  sal.symtab = elt;
 	  sal.line = line;
 	  sal.explicit_line = true;
@@ -4319,9 +4319,9 @@ search_minsyms_for_name (struct collect_info *info,
     }
   else
     {
-      if (search_pspace == NULL || SYMTAB_PSPACE (symtab) == search_pspace)
+      if (search_pspace == NULL || symtab->pspace () == search_pspace)
 	{
-	  set_current_program_space (SYMTAB_PSPACE (symtab));
+	  set_current_program_space (symtab->pspace ());
 	  iterate_over_minimal_symbols
 	    (symtab->objfile (), name,
 	     [&] (struct minimal_symbol *msym)
@@ -4407,14 +4407,14 @@ add_matching_symbols_to_info (const char *name,
 	    { return info->add_symbol (bsym); });
 	  search_minsyms_for_name (info, lookup_name, pspace, NULL);
 	}
-      else if (pspace == NULL || pspace == SYMTAB_PSPACE (elt))
+      else if (pspace == NULL || pspace == elt->pspace ())
 	{
 	  int prev_len = info->result.symbols->size ();
 
 	  /* Program spaces that are executing startup should have
 	     been filtered out earlier.  */
-	  gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
-	  set_current_program_space (SYMTAB_PSPACE (elt));
+	  gdb_assert (!elt->pspace ()->executing_startup);
+	  set_current_program_space (elt->pspace ());
 	  iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN,
 				    [&] (block_symbol *bsym)
 	    { return info->add_symbol (bsym); });
@@ -4453,7 +4453,7 @@ symbol_to_sal (struct symtab_and_line *result,
 	  result->symbol = sym;
 	  result->line = SYMBOL_LINE (sym);
 	  result->pc = SYMBOL_VALUE_ADDRESS (sym);
-	  result->pspace = SYMTAB_PSPACE (result->symtab);
+	  result->pspace = result->symtab->pspace ();
 	  result->explicit_pc = 1;
 	  return 1;
 	}
@@ -4469,7 +4469,7 @@ symbol_to_sal (struct symtab_and_line *result,
 	  result->symbol = sym;
 	  result->line = SYMBOL_LINE (sym);
 	  result->pc = SYMBOL_VALUE_ADDRESS (sym);
-	  result->pspace = SYMTAB_PSPACE (result->symtab);
+	  result->pspace = result->symtab->pspace ();
 	  return 1;
 	}
     }
diff --git a/gdb/source.c b/gdb/source.c
index d184990a6c0a..1339c4a727f3 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -311,7 +311,7 @@ select_source_symtab (struct symtab *s)
   if (s)
     {
       current_source_location *loc
-	= get_source_location (SYMTAB_PSPACE (s));
+	= get_source_location (s->pspace ());
       loc->set (s, 1);
       return;
     }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 671e22c57235..b12c3af7f2ba 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -331,6 +331,14 @@ search_domain_name (enum search_domain e)
 
 /* See symtab.h.  */
 
+program_space *
+symtab::pspace () const
+{
+  return this->objfile ()->pspace;
+}
+
+/* See symtab.h.  */
+
 call_site *
 compunit_symtab::find_call_site (CORE_ADDR pc) const
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 9cfbd71937a3..5ef4bdaa1109 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1407,6 +1407,8 @@ struct symtab
 
   struct objfile *objfile () const;
 
+  program_space *pspace () const;
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1439,7 +1441,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_PSPACE(symtab) ((symtab)->objfile ()->pspace)
 #define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ())
 
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
-- 
2.34.1


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

* [PATCH 22/33] gdb: remove SYMTAB_DIRNAME macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (20 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 21/33] gdb: remove SYMTAB_PSPACE macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 23/33] gdb: remove SYMBOL_MATCHES_SEARCH_NAME Simon Marchi via Gdb-patches
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Remove the macro, replace with an equivalent method.

Change-Id: I46ec36b91bb734331138eb9cd086b2db01635aed
---
 gdb/cli/cli-cmds.c |  4 ++--
 gdb/source.c       | 14 +++++++-------
 gdb/symmisc.c      |  4 ++--
 gdb/symtab.h       | 10 ++++++++--
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 67155daf5b02..eb14ee131a47 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -2033,8 +2033,8 @@ ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
 static int
 cmp_symtabs (const symtab_and_line &sala, const symtab_and_line &salb)
 {
-  const char *dira = SYMTAB_DIRNAME (sala.symtab);
-  const char *dirb = SYMTAB_DIRNAME (salb.symtab);
+  const char *dira = sala.symtab->dirname ();
+  const char *dirb = salb.symtab->dirname ();
   int r;
 
   if (dira == NULL)
diff --git a/gdb/source.c b/gdb/source.c
index 1339c4a727f3..53854c02eac1 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -713,8 +713,8 @@ info_source_command (const char *ignore, int from_tty)
 
   cust = s->compunit ();
   printf_filtered (_("Current source file is %s\n"), s->filename);
-  if (SYMTAB_DIRNAME (s) != NULL)
-    printf_filtered (_("Compilation directory is %s\n"), SYMTAB_DIRNAME (s));
+  if (s->dirname () != NULL)
+    printf_filtered (_("Compilation directory is %s\n"), s->dirname ());
   if (s->fullname)
     printf_filtered (_("Located in %s\n"), s->fullname);
   const std::vector<off_t> *offsets;
@@ -1180,7 +1180,7 @@ open_source_file (struct symtab *s)
 
   gdb::unique_xmalloc_ptr<char> fullname (s->fullname);
   s->fullname = NULL;
-  scoped_fd fd = find_and_open_source (s->filename, SYMTAB_DIRNAME (s),
+  scoped_fd fd = find_and_open_source (s->filename, s->dirname (),
 				       &fullname);
 
   if (fd.get () < 0)
@@ -1192,9 +1192,9 @@ open_source_file (struct symtab *s)
 	  std::string srcpath;
 	  if (IS_ABSOLUTE_PATH (s->filename))
 	    srcpath = s->filename;
-	  else if (SYMTAB_DIRNAME (s) != nullptr)
+	  else if (s->dirname () != nullptr)
 	    {
-	      srcpath = SYMTAB_DIRNAME (s);
+	      srcpath = s->dirname ();
 	      srcpath += SLASH_STRING;
 	      srcpath += s->filename;
 	    }
@@ -1268,10 +1268,10 @@ symtab_to_fullname (struct symtab *s)
 	  /* rewrite_source_path would be applied by find_and_open_source, we
 	     should report the pathname where GDB tried to find the file.  */
 
-	  if (SYMTAB_DIRNAME (s) == NULL || IS_ABSOLUTE_PATH (s->filename))
+	  if (s->dirname () == NULL || IS_ABSOLUTE_PATH (s->filename))
 	    fullname.reset (xstrdup (s->filename));
 	  else
-	    fullname.reset (concat (SYMTAB_DIRNAME (s), SLASH_STRING,
+	    fullname.reset (concat (s->dirname (), SLASH_STRING,
 				    s->filename, (char *) NULL));
 
 	  s->fullname = rewrite_source_path (fullname.get ()).release ();
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 62b584041def..179b83e416fe 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -249,9 +249,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 		    symtab_to_filename_for_display (symtab),
 		    host_address_to_string (symtab));
 
-  if (SYMTAB_DIRNAME (symtab) != NULL)
+  if (symtab->dirname () != NULL)
     fprintf_filtered (outfile, "Compilation directory is %s\n",
-		      SYMTAB_DIRNAME (symtab));
+		      symtab->dirname ());
   fprintf_filtered (outfile, "Read from object file %s (%s)\n",
 		    objfile_name (objfile),
 		    host_address_to_string (objfile));
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5ef4bdaa1109..88dab003c5c3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1409,6 +1409,8 @@ struct symtab
 
   program_space *pspace () const;
 
+  const char *dirname () const;
+
   /* Unordered chain of all filetabs in the compunit,  with the exception
      that the "main" source file is the first entry in the list.  */
 
@@ -1441,8 +1443,6 @@ struct symtab
 
 using symtab_range = next_range<symtab>;
 
-#define SYMTAB_DIRNAME(symtab) ((symtab)->compunit ()->dirname ())
-
 /* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
    as the list of all source files (what gdb has historically associated with
    the term "symtab").
@@ -1696,6 +1696,12 @@ symtab::objfile () const
   return this->compunit ()->objfile ();
 }
 
+inline const char *
+symtab::dirname () const
+{
+  return this->compunit ()->dirname ();
+}
+
 /* Return the language of CUST.  */
 
 extern enum language compunit_language (const struct compunit_symtab *cust);
-- 
2.34.1


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

* [PATCH 23/33] gdb: remove SYMBOL_MATCHES_SEARCH_NAME
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (21 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 22/33] gdb: remove SYMTAB_DIRNAME macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 24/33] gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter Simon Marchi via Gdb-patches
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

It seems like this macro is not needed at all anymore, it just wraps the
function of the same name with the same arguments.

Change-Id: I3c342ac8d89c27af5aee1a819dc32cc6396fd41b
---
 gdb/symfile-debug.c | 4 ++--
 gdb/symtab.c        | 2 +-
 gdb/symtab.h        | 7 +------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 59dbaf16e62b..f1a8f5ef9d4e 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -257,14 +257,14 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
        information (but NAME might contain it).  */
 
     if (sym != NULL
-	&& SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name))
+	&& symbol_matches_search_name (sym, lookup_name))
       {
 	retval = stab;
 	/* Found it.  */
 	return false;
       }
     if (with_opaque != NULL
-	&& SYMBOL_MATCHES_SEARCH_NAME (with_opaque, lookup_name))
+	&& symbol_matches_search_name (with_opaque, lookup_name))
       retval = stab;
 
     /* Keep looking through other psymtabs.  */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index b12c3af7f2ba..30335ee55f8c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1264,7 +1264,7 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
 	  struct symbol *sym = slot->value.found.symbol;
 	  lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
 
-	  if (!SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name))
+	  if (!symbol_matches_search_name (sym, lookup_name))
 	    return 0;
 
 	  if (!symbol_matches_domain (sym->language (), slot_domain, domain))
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 88dab003c5c3..a765d1a76180 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -595,13 +595,8 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
 extern gdb::unique_xmalloc_ptr<char> symbol_find_demangled_name
      (struct general_symbol_info *gsymbol, const char *mangled);
 
-/* Return true if NAME matches the "search" name of SYMBOL, according
+/* Return true if NAME matches the "search" name of GSYMBOL, according
    to the symbol's language.  */
-#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)                       \
-  symbol_matches_search_name ((symbol), (name))
-
-/* Helper for SYMBOL_MATCHES_SEARCH_NAME that works with both symbols
-   and psymbols.  */
 extern bool symbol_matches_search_name
   (const struct general_symbol_info *gsymbol,
    const lookup_name_info &name);
-- 
2.34.1


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

* [PATCH 24/33] gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (22 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 23/33] gdb: remove SYMBOL_MATCHES_SEARCH_NAME Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 25/33] gdb: remove SYMBOL_IMPL macro, add method Simon Marchi via Gdb-patches
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symbol's aclass index.  Remove the
corresponding macro and adjust all callers.

Change-Id: Ie8c8d732624cfadb714aba5ddafa3d29409b3d39
---
 gdb/coffread.c    | 20 +++++++-------
 gdb/ctfread.c     | 16 +++++------
 gdb/dwarf2/read.c | 50 +++++++++++++++++-----------------
 gdb/jit.c         |  2 +-
 gdb/language.c    |  2 +-
 gdb/mdebugread.c  | 24 ++++++++---------
 gdb/stabsread.c   | 68 +++++++++++++++++++++++------------------------
 gdb/symtab.h      | 17 +++++++++---
 gdb/xcoffread.c   |  2 +-
 9 files changed, 105 insertions(+), 96 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index af0699bed2d5..d4c4226a8d2d 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1575,7 +1575,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	lookup_function_type (decode_function_type (cs, cs->c_type,
 						    aux, objfile));
 
-      SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+      sym->set_aclass_index (LOC_BLOCK);
       if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
 	  || cs->c_sclass == C_THUMBSTATFUNC)
 	add_symbol_to_list (sym, get_file_symbols ());
@@ -1592,14 +1592,14 @@ process_coff_symbol (struct coff_symbol *cs,
 	  break;
 
 	case C_AUTO:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
+	  sym->set_aclass_index (LOC_LOCAL);
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_THUMBEXT:
 	case C_THUMBEXTFUNC:
 	case C_EXT:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+	  sym->set_aclass_index (LOC_STATIC);
 	  SET_SYMBOL_VALUE_ADDRESS (sym,
 				    (CORE_ADDR) cs->c_value
 				    + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
@@ -1609,7 +1609,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_THUMBSTAT:
 	case C_THUMBSTATFUNC:
 	case C_STAT:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+	  sym->set_aclass_index (LOC_STATIC);
 	  SET_SYMBOL_VALUE_ADDRESS (sym,
 				    (CORE_ADDR) cs->c_value
 				    + objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
@@ -1629,7 +1629,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_GLBLREG:
 #endif
 	case C_REG:
-	  SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
+	  sym->set_aclass_index (coff_register_index);
 	  SYMBOL_VALUE (sym) = cs->c_value;
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
@@ -1639,20 +1639,20 @@ process_coff_symbol (struct coff_symbol *cs,
 	  break;
 
 	case C_ARG:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
+	  sym->set_aclass_index (LOC_ARG);
 	  SYMBOL_IS_ARGUMENT (sym) = 1;
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_REGPARM:
-	  SYMBOL_ACLASS_INDEX (sym) = coff_register_index;
+	  sym->set_aclass_index (coff_register_index);
 	  SYMBOL_IS_ARGUMENT (sym) = 1;
 	  SYMBOL_VALUE (sym) = cs->c_value;
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_TPDEF:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 
 	  /* If type has no name, give it one.  */
@@ -1707,7 +1707,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_STRTAG:
 	case C_UNTAG:
 	case C_ENTAG:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
 
 	  /* Some compilers try to be helpful by inventing "fake"
@@ -2098,7 +2098,7 @@ coff_read_enum_type (int index, int length, int lastsym,
 
 	  name = obstack_strdup (&objfile->objfile_obstack, name);
 	  sym->set_linkage_name (name);
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	  sym->set_aclass_index (LOC_CONST);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	  SYMBOL_VALUE (sym) = ms->c_value;
 	  add_symbol_to_list (sym, symlist);
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 0a96520411f6..dbafe75b8312 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -330,7 +330,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
   if (msym.minsym != NULL)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym, BMSYMBOL_VALUE_ADDRESS (msym));
-      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+      sym->set_aclass_index (LOC_STATIC);
       sym->set_section_index (msym.minsym->section_index ());
     }
 }
@@ -450,7 +450,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
 
       sym->set_language (language_c, &ccp->of->objfile_obstack);
       sym->compute_and_set_names (name, false, ccp->of->per_bfd);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+      sym->set_aclass_index (LOC_CONST);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_TYPE (sym) = fip->ptype;
       add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
@@ -480,7 +480,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
       sym->set_language (language_c, &objfile->objfile_obstack);
       sym->compute_and_set_names (name, false, objfile->per_bfd);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+      sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 
       if (type != nullptr)
 	SYMBOL_TYPE (sym) = type;
@@ -491,11 +491,11 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	  case CTF_K_STRUCT:
 	  case CTF_K_UNION:
 	  case CTF_K_ENUM:
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	    sym->set_aclass_index (LOC_TYPEDEF);
 	    SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
 	    break;
 	  case CTF_K_FUNCTION:
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+	    sym->set_aclass_index (LOC_STATIC);
 	    set_symbol_address (objfile, sym, sym->linkage_name ());
 	    break;
 	  case CTF_K_CONST:
@@ -505,7 +505,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	  case CTF_K_TYPEDEF:
 	  case CTF_K_INTEGER:
 	  case CTF_K_FLOAT:
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	    sym->set_aclass_index (LOC_TYPEDEF);
 	    SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	    break;
 	  case CTF_K_POINTER:
@@ -1171,7 +1171,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
 	OBJSTAT (ccp->of, n_syms++);
 	SYMBOL_TYPE (sym) = type;
 	SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+	sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	sym->compute_and_set_names (name, false, ccp->of->per_bfd);
 	add_symbol_to_list (sym, ccp->builder->get_file_symbols ());
 	break;
@@ -1207,7 +1207,7 @@ add_stt_entries (struct ctf_context *ccp, int functions)
       OBJSTAT (ccp->of, n_syms++);
       SYMBOL_TYPE (sym) = type;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+      sym->set_aclass_index (LOC_STATIC);
       sym->compute_and_set_names (tname, false, ccp->of->per_bfd);
       add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
       set_symbol_address (ccp->of, sym, tname);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3bbd253d8413..1155efb6df74 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8917,7 +8917,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       /* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
 	 e.g., "main" finds the "main" module and not C's main().  */
       SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+      sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_TYPE (sym) = type;
 
       add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
@@ -16865,7 +16865,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
   gdb_assert (ptr - baton->data == baton->size);
 
   SYMBOL_LOCATION_BATON (sym) = baton;
-  SYMBOL_ACLASS_INDEX (sym) = dwarf2_locexpr_index;
+  sym->set_aclass_index (dwarf2_locexpr_index);
 }
 
 /* Create appropriate locally-scoped variables for all the
@@ -21601,7 +21601,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
      variable has been optimized away.  */
   if (attr->form_is_block () && attr->as_block ()->size == 0)
     {
-      SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+      sym->set_aclass_index (LOC_OPTIMIZED_OUT);
       return;
     }
 
@@ -21632,7 +21632,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
 	    SET_SYMBOL_VALUE_ADDRESS
 	      (sym, read_addr_index_from_leb128 (cu, block->data + 1,
 						 &dummy));
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+	  sym->set_aclass_index (LOC_STATIC);
 	  fixup_symbol_section (sym, objfile);
 	  SET_SYMBOL_VALUE_ADDRESS
 	    (sym,
@@ -21718,7 +21718,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       /* Default assumptions.
 	 Use the passed type or decode it from the die.  */
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+      sym->set_aclass_index (LOC_OPTIMIZED_OUT);
       if (type != NULL)
 	SYMBOL_TYPE (sym) = type;
       else
@@ -21760,10 +21760,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	      addr = attr->as_address ();
 	      addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
 	      SET_SYMBOL_VALUE_ADDRESS (sym, addr);
-	      SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
+	      sym->set_aclass_index (LOC_LABEL);
 	    }
 	  else
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+	    sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	  SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
 	  SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
 	  add_symbol_to_list (sym, cu->list_in_scope);
@@ -21771,7 +21771,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_subprogram:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+	  sym->set_aclass_index (LOC_BLOCK);
 	  attr2 = dwarf2_attr (die, DW_AT_external, cu);
 	  if ((attr2 != nullptr && attr2->as_boolean ())
 	      || cu->per_cu->lang == language_ada
@@ -21793,7 +21793,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_inlined_subroutine:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+	  sym->set_aclass_index (LOC_BLOCK);
 	  SYMBOL_INLINED (sym) = 1;
 	  list_to_add = cu->list_in_scope;
 	  break;
@@ -21913,7 +21913,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		       ? cu->get_builder ()->get_global_symbols ()
 		       : cu->list_in_scope);
 
-		  SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED;
+		  sym->set_aclass_index (LOC_UNRESOLVED);
 		}
 	      else if (!die_is_declaration (die, cu))
 		{
@@ -21963,7 +21963,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_union_type:
 	case DW_TAG_set_type:
 	case DW_TAG_enumeration_type:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
 
 	  {
@@ -22001,14 +22001,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  }
 	  break;
 	case DW_TAG_typedef:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_array_type:
 	case DW_TAG_base_type:
 	case DW_TAG_subrange_type:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	  list_to_add = cu->list_in_scope;
 	  break;
@@ -22031,16 +22031,16 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  break;
 	case DW_TAG_imported_declaration:
 	case DW_TAG_namespace:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  list_to_add = cu->get_builder ()->get_global_symbols ();
 	  break;
 	case DW_TAG_module:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+	  sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_DOMAIN (sym) = MODULE_DOMAIN;
 	  list_to_add = cu->get_builder ()->get_global_symbols ();
 	  break;
 	case DW_TAG_common_block:
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
+	  sym->set_aclass_index (LOC_COMMON_BLOCK);
 	  SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
 	  add_symbol_to_list (sym, cu->list_in_scope);
 	  break;
@@ -22238,17 +22238,17 @@ dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
   if (baton != NULL)
     {
       SYMBOL_LOCATION_BATON (sym) = baton;
-      SYMBOL_ACLASS_INDEX (sym) = dwarf2_locexpr_index;
+      sym->set_aclass_index (dwarf2_locexpr_index);
     }
   else if (bytes != NULL)
      {
       SYMBOL_VALUE_BYTES (sym) = bytes;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_CONST_BYTES;
+      sym->set_aclass_index (LOC_CONST_BYTES);
     }
   else
     {
       SYMBOL_VALUE (sym) = value;
-      SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+      sym->set_aclass_index (LOC_CONST);
     }
 }
 
@@ -24341,9 +24341,9 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
 	complaint (_("Location list used without "
 		     "specifying the CU base address."));
 
-      SYMBOL_ACLASS_INDEX (sym) = (is_block
-				   ? dwarf2_loclist_block_index
-				   : dwarf2_loclist_index);
+      sym->set_aclass_index ((is_block
+			      ? dwarf2_loclist_block_index
+			      : dwarf2_loclist_index));
       SYMBOL_LOCATION_BATON (sym) = baton;
     }
   else
@@ -24373,9 +24373,9 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
 	  baton->size = 0;
 	}
 
-      SYMBOL_ACLASS_INDEX (sym) = (is_block
-				   ? dwarf2_locexpr_block_index
-				   : dwarf2_locexpr_index);
+      sym->set_aclass_index ((is_block
+			      ? dwarf2_locexpr_block_index
+			      : dwarf2_locexpr_index));
       SYMBOL_LOCATION_BATON (sym) = baton;
     }
 }
diff --git a/gdb/jit.c b/gdb/jit.c
index c8415781672a..a2c7345fc495 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -551,7 +551,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
 
       /* The name.  */
       SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK;
+      block_name->set_aclass_index (LOC_BLOCK);
       symbol_set_symtab (block_name, filetab);
       SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
       SYMBOL_BLOCK_VALUE (block_name) = new_block;
diff --git a/gdb/language.c b/gdb/language.c
index f000142fc2da..aff6c21e2b62 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1002,7 +1002,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->set_section_index (0);
   SYMBOL_TYPE (symbol) = type;
   SYMBOL_DOMAIN (symbol) = VAR_DOMAIN;
-  SYMBOL_ACLASS_INDEX (symbol) = LOC_TYPEDEF;
+  symbol->set_aclass_index (LOC_TYPEDEF);
   return symbol;
 }
 
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index b98ac8fe7996..e0d108935e11 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -563,7 +563,7 @@ add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend,
 		 struct objfile *objfile, const char *name)
 {
   SYMBOL_DOMAIN (s) = VAR_DOMAIN;
-  SYMBOL_ACLASS_INDEX (s) = aclass_index;
+  s->set_aclass_index (aclass_index);
   add_symbol (s, top_stack->cur_st, b);
 
   /* Type could be missing if file is compiled without debugging info.  */
@@ -681,19 +681,19 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	{
 	case scRegister:
 	  /* Pass by value in register.  */
-	  SYMBOL_ACLASS_INDEX (s) = mdebug_register_index;
+	  s->set_aclass_index (mdebug_register_index);
 	  break;
 	case scVar:
 	  /* Pass by reference on stack.  */
-	  SYMBOL_ACLASS_INDEX (s) = LOC_REF_ARG;
+	  s->set_aclass_index (LOC_REF_ARG);
 	  break;
 	case scVarRegister:
 	  /* Pass by reference in register.  */
-	  SYMBOL_ACLASS_INDEX (s) = mdebug_regparm_index;
+	  s->set_aclass_index (mdebug_regparm_index);
 	  break;
 	default:
 	  /* Pass by value on stack.  */
-	  SYMBOL_ACLASS_INDEX (s) = LOC_ARG;
+	  s->set_aclass_index (LOC_ARG);
 	  break;
 	}
       SYMBOL_VALUE (s) = svalue;
@@ -704,7 +704,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
     case stLabel:		/* label, goes into current block.  */
       s = new_symbol (name);
       SYMBOL_DOMAIN (s) = VAR_DOMAIN;	/* So that it can be used */
-      SYMBOL_ACLASS_INDEX (s) = LOC_LABEL;	/* but not misused.  */
+      s->set_aclass_index (LOC_LABEL);	/* but not misused.  */
       SET_SYMBOL_VALUE_ADDRESS (s, (CORE_ADDR) sh->value);
       SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_int;
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
@@ -745,7 +745,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	}
       s = new_symbol (name);
       SYMBOL_DOMAIN (s) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (s) = LOC_BLOCK;
+      s->set_aclass_index (LOC_BLOCK);
       /* Type of the return value.  */
       if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
 	t = objfile_type (objfile)->builtin_int;
@@ -1065,7 +1065,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		enum_sym->set_linkage_name
 		  (obstack_strdup (&mdebugread_objfile->objfile_obstack,
 				   f->name ()));
-		SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST;
+		enum_sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (enum_sym) = t;
 		SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
 		SYMBOL_VALUE (enum_sym) = tsym.value;
@@ -1098,7 +1098,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 	s = new_symbol (name);
 	SYMBOL_DOMAIN (s) = STRUCT_DOMAIN;
-	SYMBOL_ACLASS_INDEX (s) = LOC_TYPEDEF;
+	s->set_aclass_index (LOC_TYPEDEF);
 	SYMBOL_VALUE (s) = 0;
 	SYMBOL_TYPE (s) = t;
 	add_symbol (s, top_stack->cur_st, top_stack->cur_block);
@@ -1155,7 +1155,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  /* Make up special symbol to contain procedure specific info.  */
 	  s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
 	  SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
-	  SYMBOL_ACLASS_INDEX (s) = LOC_CONST;
+	  s->set_aclass_index (LOC_CONST);
 	  SYMBOL_TYPE (s) = objfile_type (mdebugread_objfile)->builtin_void;
 	  e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
 			      mdebug_extra_func_info);
@@ -1296,7 +1296,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	break;
       s = new_symbol (name);
       SYMBOL_DOMAIN (s) = VAR_DOMAIN;
-      SYMBOL_ACLASS_INDEX (s) = LOC_TYPEDEF;
+      s->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block;
       SYMBOL_TYPE (s) = t;
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
@@ -3988,7 +3988,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 		  struct symbol *s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
 
 		  SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
-		  SYMBOL_ACLASS_INDEX (s) = LOC_CONST;
+		  s->set_aclass_index (LOC_CONST);
 		  SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void;
 		  SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
 		  e->pdr.framereg = -1;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 20cba381cc55..21f824f6e73c 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -425,7 +425,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
 		 a N_GSYM stab for it, but no regular (C_EXT) symbol.  */
 	      sym = new (&objfile->objfile_obstack) symbol;
 	      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	      SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
+	      sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	      sym->set_linkage_name
 		(obstack_strndup (&objfile->objfile_obstack, name, pp - name));
 	      pp += 2;
@@ -783,7 +783,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;").  */
       if (*p != '=')
 	{
-	  SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	  sym->set_aclass_index (LOC_CONST);
 	  SYMBOL_TYPE (sym) = error_type (&p, objfile);
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 	  add_symbol_to_list (sym, get_file_symbols ());
@@ -806,7 +806,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	    SYMBOL_TYPE (sym) = dbl_type;
 	    SYMBOL_VALUE_BYTES (sym) = dbl_valu;
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST_BYTES;
+	    sym->set_aclass_index (LOC_CONST_BYTES);
 	  }
 	  break;
 	case 'i':
@@ -820,7 +820,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	    SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_long;
 	    SYMBOL_VALUE (sym) = atoi (p);
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	    sym->set_aclass_index (LOC_CONST);
 	  }
 	  break;
 
@@ -828,7 +828,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  {
 	    SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_char;
 	    SYMBOL_VALUE (sym) = atoi (p);
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	    sym->set_aclass_index (LOC_CONST);
 	  }
 	  break;
 
@@ -842,7 +842,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	    if (quote != '\'' && quote != '"')
 	      {
-		SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+		sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
 		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 		add_symbol_to_list (sym, get_file_symbols ());
@@ -867,7 +867,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      }
 	    if (*p != quote)
 	      {
-		SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+		sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
 		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
 		add_symbol_to_list (sym, get_file_symbols ());
@@ -889,7 +889,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    p++;
 
 	    SYMBOL_VALUE_BYTES (sym) = string_value;
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST_BYTES;
+	    sym->set_aclass_index (LOC_CONST_BYTES);
 	  }
 	  break;
 
@@ -899,7 +899,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	     e.g. "b:c=e6,0" for "const b = blob1"
 	     (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;").  */
 	  {
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	    sym->set_aclass_index (LOC_CONST);
 	    SYMBOL_TYPE (sym) = read_type (&p, objfile);
 
 	    if (*p != ',')
@@ -920,7 +920,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  break;
 	default:
 	  {
-	    SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+	    sym->set_aclass_index (LOC_CONST);
 	    SYMBOL_TYPE (sym) = error_type (&p, objfile);
 	  }
 	}
@@ -931,7 +931,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'C':
       /* The name of a caught exception.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
+      sym->set_aclass_index (LOC_LABEL);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       add_symbol_to_list (sym, get_local_symbols ());
@@ -940,7 +940,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'f':
       /* A static function definition.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+      sym->set_aclass_index (LOC_BLOCK);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_file_symbols ());
       /* fall into process_function_types.  */
@@ -1012,7 +1012,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'F':
       /* A global function definition.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+      sym->set_aclass_index (LOC_BLOCK);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_global_symbols ());
       goto process_function_types;
@@ -1023,7 +1023,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 corresponding linker definition to find the value.
 	 These definitions appear at the end of the namelist.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+      sym->set_aclass_index (LOC_STATIC);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       /* Don't add symbol references to global_sym_chain.
 	 Symbol references don't have valid names and wont't match up with
@@ -1044,7 +1044,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 's':
     case 'l':
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
+      sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1064,7 +1064,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       else
 	SYMBOL_TYPE (sym) = read_type (&p, objfile);
 
-      SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
+      sym->set_aclass_index (LOC_ARG);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_IS_ARGUMENT (sym) = 1;
@@ -1113,7 +1113,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'R':
       /* Parameter which is in a register.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = stab_register_index;
+      sym->set_aclass_index (stab_register_index);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -1123,7 +1123,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'r':
       /* Register variable (either global or local).  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = stab_register_index;
+      sym->set_aclass_index (stab_register_index);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       if (within_function)
@@ -1160,7 +1160,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		  && strcmp (prev_sym->linkage_name (),
 			     sym->linkage_name ()) == 0)
 		{
-		  SYMBOL_ACLASS_INDEX (prev_sym) = stab_register_index;
+		  prev_sym->set_aclass_index (stab_register_index);
 		  /* Use the type from the LOC_REGISTER; that is the type
 		     that is actually in that register.  */
 		  SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
@@ -1178,7 +1178,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'S':
       /* Static symbol at top level of file.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+      sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_file_symbols ());
@@ -1209,7 +1209,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (nameless)
 	return NULL;
 
-      SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+      sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       /* C++ vagaries: we may have a type which is derived from
@@ -1286,7 +1286,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  struct symbol *struct_sym = new (&objfile->objfile_obstack) symbol;
 
 	  *struct_sym = *sym;
-	  SYMBOL_ACLASS_INDEX (struct_sym) = LOC_TYPEDEF;
+	  struct_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (struct_sym) = valu;
 	  SYMBOL_DOMAIN (struct_sym) = STRUCT_DOMAIN;
 	  if (SYMBOL_TYPE (sym)->name () == 0)
@@ -1313,7 +1313,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (nameless)
 	return NULL;
 
-      SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
+      sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
       if (SYMBOL_TYPE (sym)->name () == 0)
@@ -1328,7 +1328,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  struct symbol *typedef_sym = new (&objfile->objfile_obstack) symbol;
 
 	  *typedef_sym = *sym;
-	  SYMBOL_ACLASS_INDEX (typedef_sym) = LOC_TYPEDEF;
+	  typedef_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (typedef_sym) = valu;
 	  SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
 	  if (SYMBOL_TYPE (sym)->name () == 0)
@@ -1342,7 +1342,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'V':
       /* Static symbol of local scope.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
+      sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1351,7 +1351,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'v':
       /* Reference parameter */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_REF_ARG;
+      sym->set_aclass_index (LOC_REF_ARG);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -1361,7 +1361,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     case 'a':
       /* Reference parameter which is in a register.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = stab_regparm_index;
+      sym->set_aclass_index (stab_regparm_index);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -1374,7 +1374,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 that Pascal uses it too, but when I tried it Pascal used
 	 "x:3" (local symbol) instead.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
+      sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1382,7 +1382,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     default:
       SYMBOL_TYPE (sym) = error_type (&p, objfile);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+      sym->set_aclass_index (LOC_CONST);
       SYMBOL_VALUE (sym) = 0;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       add_symbol_to_list (sym, get_file_symbols ());
@@ -1399,11 +1399,11 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
 	 variables passed in a register).  */
       if (SYMBOL_CLASS (sym) == LOC_REGISTER)
-	SYMBOL_ACLASS_INDEX (sym) = LOC_REGPARM_ADDR;
+	sym->set_aclass_index (LOC_REGPARM_ADDR);
       /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
 	 and subsequent arguments on SPARC, for example).  */
       else if (SYMBOL_CLASS (sym) == LOC_ARG)
-	SYMBOL_ACLASS_INDEX (sym) = LOC_REF_ARG;
+	sym->set_aclass_index (LOC_REF_ARG);
     }
 
   return sym;
@@ -3592,7 +3592,7 @@ read_enum_type (const char **pp, struct type *type,
       sym->set_linkage_name (name);
       sym->set_language (get_current_subfile ()->language,
 			 &objfile->objfile_obstack);
-      SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
+      sym->set_aclass_index (LOC_CONST);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_VALUE (sym) = n;
       if (n < 0)
@@ -4260,7 +4260,7 @@ common_block_end (struct objfile *objfile)
   sym = new (&objfile->objfile_obstack) symbol;
   /* Note: common_block_name already saved on objfile_obstack.  */
   sym->set_linkage_name (common_block_name);
-  SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+  sym->set_aclass_index (LOC_BLOCK);
 
   /* Now we copy all the symbols which have been defined since the BCOMM.  */
 
@@ -4628,7 +4628,7 @@ scan_file_globals (struct objfile *objfile)
 
 	  /* Complain about unresolved common block symbols.  */
 	  if (SYMBOL_CLASS (prev) == LOC_STATIC)
-	    SYMBOL_ACLASS_INDEX (prev) = LOC_UNRESOLVED;
+	    prev->set_aclass_index (LOC_UNRESOLVED);
 	  else
 	    complaint (_("%s: common block `%s' from "
 			 "global_sym_chain unresolved"),
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a765d1a76180..aa380aa7be2e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1112,7 +1112,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
   symbol ()
     /* Class-initialization of bitfields is only allowed in C++20.  */
     : domain (UNDEF_DOMAIN),
-      aclass_index (0),
+      m_aclass_index (0),
       is_objfile_owned (1),
       is_argument (0),
       is_inlined (0),
@@ -1136,6 +1136,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
   symbol (const symbol &) = default;
   symbol &operator= (const symbol &) = default;
 
+  unsigned int aclass_index () const
+  {
+    return m_aclass_index;
+  }
+
+  void set_aclass_index (unsigned int aclass_index)
+  {
+    m_aclass_index = aclass_index;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1162,7 +1172,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
      table.  The actual enum address_class value is stored there,
      alongside any per-class ops vectors.  */
 
-  unsigned int aclass_index : SYMBOL_ACLASS_BITS;
+  unsigned int m_aclass_index : SYMBOL_ACLASS_BITS;
 
   /* If non-zero then symbol is objfile-owned, use owner.symtab.
        Otherwise symbol is arch-owned, use owner.arch.  */
@@ -1241,8 +1251,7 @@ extern const struct symbol_impl *symbol_impls;
    "private".  */
 
 #define SYMBOL_DOMAIN(symbol)	(symbol)->domain
-#define SYMBOL_IMPL(symbol)		(symbol_impls[(symbol)->aclass_index])
-#define SYMBOL_ACLASS_INDEX(symbol)	(symbol)->aclass_index
+#define SYMBOL_IMPL(symbol)		(symbol_impls[(symbol)->aclass_index ()])
 #define SYMBOL_CLASS(symbol)		(SYMBOL_IMPL (symbol).aclass)
 #define SYMBOL_OBJFILE_OWNED(symbol)	((symbol)->is_objfile_owned)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 33e9148f6724..6458e9f52d0f 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1574,7 +1574,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
       sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced));
       SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol;
 
-      SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
+      sym->set_aclass_index (LOC_BLOCK);
       sym2 = new (&objfile->objfile_obstack) symbol (*sym);
 
       if (cs->c_sclass == C_EXT || C_WEAKEXT)
-- 
2.34.1


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

* [PATCH 25/33] gdb: remove SYMBOL_IMPL macro, add method
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (23 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 24/33] gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 26/33] gdb: remove SYMBOL_CLASS macro, add getter Simon Marchi via Gdb-patches
                   ` (8 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter for a symbol's "impl".  Remove the corresponding macro and
adjust all callers.

Change-Id: Ibe26ed442f0f99a0f5cddafca30bd96ec7fb9fa8
---
 gdb/symtab.h | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/gdb/symtab.h b/gdb/symtab.h
index aa380aa7be2e..3a22d3e19eee 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1105,6 +1105,8 @@ enum symbol_subclass_kind
   SYMBOL_RUST_VTABLE
 };
 
+extern const struct symbol_impl *symbol_impls;
+
 /* This structure is space critical.  See space comments at the top.  */
 
 struct symbol : public general_symbol_info, public allocate_on_obstack
@@ -1146,6 +1148,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_aclass_index = aclass_index;
   }
 
+  const symbol_impl &impl () const
+  {
+    return symbol_impls[this->aclass_index ()];
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1245,14 +1252,11 @@ struct block_symbol
   const struct block *block;
 };
 
-extern const struct symbol_impl *symbol_impls;
-
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
 #define SYMBOL_DOMAIN(symbol)	(symbol)->domain
-#define SYMBOL_IMPL(symbol)		(symbol_impls[(symbol)->aclass_index ()])
-#define SYMBOL_CLASS(symbol)		(SYMBOL_IMPL (symbol).aclass)
+#define SYMBOL_CLASS(symbol)		((symbol)->impl ().aclass)
 #define SYMBOL_OBJFILE_OWNED(symbol)	((symbol)->is_objfile_owned)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
@@ -1260,9 +1264,9 @@ extern const struct symbol_impl *symbol_impls;
   (((symbol)->subclass) == SYMBOL_TEMPLATE)
 #define SYMBOL_TYPE(symbol)		(symbol)->type
 #define SYMBOL_LINE(symbol)		(symbol)->line
-#define SYMBOL_COMPUTED_OPS(symbol)	(SYMBOL_IMPL (symbol).ops_computed)
-#define SYMBOL_BLOCK_OPS(symbol)	(SYMBOL_IMPL (symbol).ops_block)
-#define SYMBOL_REGISTER_OPS(symbol)	(SYMBOL_IMPL (symbol).ops_register)
+#define SYMBOL_COMPUTED_OPS(symbol)	((symbol)->impl ().ops_computed)
+#define SYMBOL_BLOCK_OPS(symbol)	((symbol)->impl ().ops_block)
+#define SYMBOL_REGISTER_OPS(symbol)	((symbol)->impl ().ops_register)
 #define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value
 
 extern int register_symbol_computed_impl (enum address_class,
-- 
2.34.1


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

* [PATCH 26/33] gdb: remove SYMBOL_CLASS macro, add getter
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (24 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 25/33] gdb: remove SYMBOL_IMPL macro, add method Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 27/33] gdb: remove SYMBOL_DOMAIN macro Simon Marchi via Gdb-patches
                   ` (7 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Change-Id: I83211d5a47efc0564386e5b5ea4a29c00b1fd46a
---
 gdb/ada-exp.y                       | 14 ++++----
 gdb/ada-lang.c                      | 56 ++++++++++++++---------------
 gdb/ax-gdb.c                        |  2 +-
 gdb/block.c                         |  9 +++--
 gdb/c-exp.y                         |  8 ++---
 gdb/c-typeprint.c                   |  2 +-
 gdb/coffread.c                      |  2 +-
 gdb/compile/compile-c-symbols.c     |  8 ++---
 gdb/compile/compile-cplus-symbols.c |  6 ++--
 gdb/cp-support.c                    |  2 +-
 gdb/d-exp.y                         |  6 ++--
 gdb/dwarf2/read.c                   |  8 ++---
 gdb/eval.c                          |  2 +-
 gdb/expop.h                         |  2 +-
 gdb/f-exp.y                         |  2 +-
 gdb/f-valprint.c                    |  2 +-
 gdb/findvar.c                       |  6 ++--
 gdb/gdbtypes.c                      |  2 +-
 gdb/go-exp.y                        |  2 +-
 gdb/guile/scm-symbol.c              | 10 +++---
 gdb/infcmd.c                        |  2 +-
 gdb/linespec.c                      | 10 +++---
 gdb/m2-exp.y                        |  6 ++--
 gdb/mdebugread.c                    |  2 +-
 gdb/mi/mi-cmd-stack.c               |  2 +-
 gdb/mips-tdep.c                     |  2 +-
 gdb/objfiles.c                      |  4 +--
 gdb/p-exp.y                         |  8 ++---
 gdb/printcmd.c                      |  2 +-
 gdb/python/py-framefilter.c         |  2 +-
 gdb/python/py-symbol.c              | 10 +++---
 gdb/python/py-type.c                |  4 +--
 gdb/rust-parse.c                    |  4 +--
 gdb/source.c                        |  2 +-
 gdb/stabsread.c                     | 16 ++++-----
 gdb/stack.c                         |  6 ++--
 gdb/symmisc.c                       |  6 ++--
 gdb/symtab.c                        | 28 +++++++--------
 gdb/symtab.h                        |  6 +++-
 gdb/tracepoint.c                    | 12 +++----
 gdb/typeprint.c                     |  2 +-
 gdb/valops.c                        |  4 +--
 42 files changed, 147 insertions(+), 144 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 0d5083f513bf..c9fce7d40b0e 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1157,7 +1157,7 @@ write_object_renaming (struct parser_state *par_state,
   ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
   if (sym_info.symbol == NULL)
     error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
-  else if (SYMBOL_CLASS (sym_info.symbol) == LOC_TYPEDEF)
+  else if (sym_info.symbol->aclass () == LOC_TYPEDEF)
     /* We have a renaming of an old-style renaming symbol.  Don't
        trust the block information.  */
     sym_info.block = orig_left_context;
@@ -1226,7 +1226,7 @@ write_object_renaming (struct parser_state *par_state,
 				       VAR_DOMAIN, &index_sym_info);
 	    if (index_sym_info.symbol == NULL)
 	      error (_("Could not find %s"), index_name);
-	    else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
+	    else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF)
 	      /* Index is an old-style renaming symbol.  */
 	      index_sym_info.block = orig_left_context;
 	    write_var_from_sym (par_state, index_sym_info);
@@ -1296,14 +1296,14 @@ block_lookup (const struct block *context, const char *raw_name)
     = ada_lookup_symbol_list (name, context, VAR_DOMAIN);
 
   if (context == NULL
-      && (syms.empty () || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
+      && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
     symtab = lookup_symtab (name);
   else
     symtab = NULL;
 
   if (symtab != NULL)
     result = BLOCKVECTOR_BLOCK (symtab->blockvector (), STATIC_BLOCK);
-  else if (syms.empty () || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
+  else if (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)
     {
       if (context == NULL)
 	error (_("No file or function \"%s\"."), raw_name);
@@ -1329,7 +1329,7 @@ select_possible_type_sym (const std::vector<struct block_symbol> &syms)
 	  
   preferred_index = -1; preferred_type = NULL;
   for (i = 0; i < syms.size (); i += 1)
-    switch (SYMBOL_CLASS (syms[i].symbol))
+    switch (syms[i].symbol->aclass ())
       {
       case LOC_TYPEDEF:
 	if (ada_prefer_type (SYMBOL_TYPE (syms[i].symbol), preferred_type))
@@ -1373,7 +1373,7 @@ find_primitive_type (struct parser_state *par_state, const char *name)
       strcpy (expanded_name, "standard__");
       strcat (expanded_name, name);
       sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol;
-      if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+      if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
 	type = SYMBOL_TYPE (sym);
     }
 
@@ -1690,7 +1690,7 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
 				  par_state->expression_context_block,
 				  VAR_DOMAIN);
 
-      if (syms.size () != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
+      if (syms.size () != 1 || syms[0].symbol->aclass () == LOC_TYPEDEF)
 	pstate->push_new<ada_string_operation> (copy_name (name));
       else
 	write_var_from_sym (par_state, syms[0]);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e6bfb8e1467f..c689548aab6c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3325,7 +3325,7 @@ See set/show multiple-symbol."));
       if (syms[i].symbol == NULL)
 	continue;
 
-      if (SYMBOL_CLASS (syms[i].symbol) == LOC_BLOCK)
+      if (syms[i].symbol->aclass () == LOC_BLOCK)
 	{
 	  struct symtab_and_line sal =
 	    find_function_start_sal (syms[i].symbol, 1);
@@ -3347,7 +3347,7 @@ See set/show multiple-symbol."));
       else
 	{
 	  int is_enumeral =
-	    (SYMBOL_CLASS (syms[i].symbol) == LOC_CONST
+	    (syms[i].symbol->aclass () == LOC_CONST
 	     && SYMBOL_TYPE (syms[i].symbol) != NULL
 	     && SYMBOL_TYPE (syms[i].symbol)->code () == TYPE_CODE_ENUM);
 	  struct symtab *symtab = NULL;
@@ -3491,7 +3491,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
 		   candidates.end (),
 		   [] (block_symbol &bsym)
 		   {
-		     switch (SYMBOL_CLASS (bsym.symbol))
+		     switch (bsym.symbol->aclass ())
 		       {
 		       case LOC_REGISTER:
 		       case LOC_ARG:
@@ -3514,7 +3514,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
 	  candidates.end (),
 	  [] (block_symbol &bsym)
 	  {
-	    return SYMBOL_CLASS (bsym.symbol) == LOC_TYPEDEF;
+	    return bsym.symbol->aclass () == LOC_TYPEDEF;
 	  }),
 	 candidates.end ());
     }
@@ -3628,7 +3628,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
   int i;
   struct type *func_type = SYMBOL_TYPE (func);
 
-  if (SYMBOL_CLASS (func) == LOC_CONST
+  if (func->aclass () == LOC_CONST
       && func_type->code () == TYPE_CODE_ENUM)
     return (n_actuals == 0);
   else if (func_type == NULL || func_type->code () != TYPE_CODE_FUNC)
@@ -3934,7 +3934,7 @@ ada_parse_renaming (struct symbol *sym,
 
   if (sym == NULL)
     return ADA_NOT_RENAMING;
-  switch (SYMBOL_CLASS (sym)) 
+  switch (sym->aclass ()) 
     {
     default:
       return ADA_NOT_RENAMING;
@@ -4443,7 +4443,7 @@ is_nonfunction (const std::vector<struct block_symbol> &syms)
   for (const block_symbol &sym : syms)
     if (SYMBOL_TYPE (sym.symbol)->code () != TYPE_CODE_FUNC
 	&& (SYMBOL_TYPE (sym.symbol)->code () != TYPE_CODE_ENUM
-	    || SYMBOL_CLASS (sym.symbol) != LOC_CONST))
+	    || sym.symbol->aclass () != LOC_CONST))
       return 1;
 
   return 0;
@@ -4478,10 +4478,10 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
   if (sym0 == sym1)
     return 1;
   if (SYMBOL_DOMAIN (sym0) != SYMBOL_DOMAIN (sym1)
-      || SYMBOL_CLASS (sym0) != SYMBOL_CLASS (sym1))
+      || sym0->aclass () != sym1->aclass ())
     return 0;
 
-  switch (SYMBOL_CLASS (sym0))
+  switch (sym0->aclass ())
     {
     case LOC_UNDEF:
       return 1;
@@ -4743,7 +4743,7 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
 	 should be identical.  */
 
       else if ((*syms)[i].symbol->linkage_name () != NULL
-	  && SYMBOL_CLASS ((*syms)[i].symbol) == LOC_STATIC
+	  && (*syms)[i].symbol->aclass () == LOC_STATIC
 	  && is_nondebugging_type (SYMBOL_TYPE ((*syms)[i].symbol)))
 	{
 	  for (j = 0; j < syms->size (); j += 1)
@@ -4752,8 +4752,8 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
 		  && (*syms)[j].symbol->linkage_name () != NULL
 		  && strcmp ((*syms)[i].symbol->linkage_name (),
 			     (*syms)[j].symbol->linkage_name ()) == 0
-		  && SYMBOL_CLASS ((*syms)[i].symbol)
-		       == SYMBOL_CLASS ((*syms)[j].symbol)
+		  && ((*syms)[i].symbol->aclass ()
+		      == (*syms)[j].symbol->aclass ())
 		  && SYMBOL_VALUE_ADDRESS ((*syms)[i].symbol)
 		  == SYMBOL_VALUE_ADDRESS ((*syms)[j].symbol))
 		remove_p = 1;
@@ -4845,7 +4845,7 @@ is_package_name (const char *name)
 static int
 old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
 {
-  if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
+  if (sym->aclass () != LOC_TYPEDEF)
     return 0;
 
   std::string scope = xget_renaming_scope (SYMBOL_TYPE (sym));
@@ -4924,7 +4924,7 @@ remove_irrelevant_renamings (std::vector<struct block_symbol> *syms,
       const char *name;
       const char *suffix;
 
-      if (sym == NULL || SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+      if (sym == NULL || sym->aclass () == LOC_TYPEDEF)
 	continue;
       name = sym->linkage_name ();
       suffix = strstr (name, "___XR");
@@ -5051,7 +5051,7 @@ match_data::operator() (struct block_symbol *bsym)
     }
   else 
     {
-      if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
+      if (sym->aclass () == LOC_UNRESOLVED)
 	return true;
       else if (SYMBOL_IS_ARGUMENT (sym))
 	arg_sym = sym;
@@ -5742,7 +5742,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
     {
       if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
 	{
-	  if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED)
+	  if (sym->aclass () != LOC_UNRESOLVED)
 	    {
 	      if (SYMBOL_IS_ARGUMENT (sym))
 		arg_sym = sym;
@@ -5796,7 +5796,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
 	    if (cmp == 0
 		&& is_name_suffix (sym->linkage_name () + name_len + 5))
 	      {
-		if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED)
+		if (sym->aclass () != LOC_UNRESOLVED)
 		  {
 		    if (SYMBOL_IS_ARGUMENT (sym))
 		      arg_sym = sym;
@@ -7214,7 +7214,7 @@ ada_find_any_type_symbol (const char *name)
   struct symbol *sym;
 
   sym = standard_lookup (name, get_selected_block (NULL), VAR_DOMAIN);
-  if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
     return sym;
 
   sym = standard_lookup (name, NULL, STRUCT_DOMAIN);
@@ -11253,10 +11253,10 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
 
   /* Make sure that the symbol we found corresponds to a function.  */
 
-  if (SYMBOL_CLASS (sym) != LOC_BLOCK)
+  if (sym->aclass () != LOC_BLOCK)
     {
       error (_("Symbol \"%s\" is not a function (class = %d)"),
-	     sym->linkage_name (), SYMBOL_CLASS (sym));
+	     sym->linkage_name (), sym->aclass ());
       return 0;
     }
 
@@ -11276,10 +11276,10 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
 
   /* Make sure that the symbol we found corresponds to a function.  */
 
-  if (SYMBOL_CLASS (sym) != LOC_BLOCK)
+  if (sym->aclass () != LOC_BLOCK)
     {
       error (_("Symbol \"%s\" is not a function (class = %d)"),
-	     sym->linkage_name (), SYMBOL_CLASS (sym));
+	     sym->linkage_name (), sym->aclass ());
       return 0;
     }
 
@@ -12246,7 +12246,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex,
   if (sym == NULL)
     error (_("Catchpoint symbol not found: %s"), sym_name);
 
-  if (SYMBOL_CLASS (sym) != LOC_BLOCK)
+  if (sym->aclass () != LOC_BLOCK)
     error (_("Unable to insert catchpoint. %s is not a function."), sym_name);
 
   /* Set ADDR_STRING.  */
@@ -12420,10 +12420,10 @@ ada_is_exception_sym (struct symbol *sym)
 {
   const char *type_name = SYMBOL_TYPE (sym)->name ();
 
-  return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
-	  && SYMBOL_CLASS (sym) != LOC_BLOCK
-	  && SYMBOL_CLASS (sym) != LOC_CONST
-	  && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
+  return (sym->aclass () != LOC_TYPEDEF
+	  && sym->aclass () != LOC_BLOCK
+	  && sym->aclass () != LOC_CONST
+	  && sym->aclass () != LOC_UNRESOLVED
 	  && type_name != NULL && strcmp (type_name, "exception") == 0);
 }
 
@@ -12545,7 +12545,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
 
       ALL_BLOCK_SYMBOLS (block, iter, sym)
 	{
-	  switch (SYMBOL_CLASS (sym))
+	  switch (sym->aclass ())
 	    {
 	    case LOC_TYPEDEF:
 	    case LOC_BLOCK:
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 0383ec6c1a77..7ba44c4c8c09 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -520,7 +520,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
     }
 
   /* I'm imitating the code in read_var_value.  */
-  switch (SYMBOL_CLASS (var))
+  switch (var->aclass ())
     {
     case LOC_CONST:		/* A constant, like an enum value.  */
       ax_const_l (ax, (LONGEST) SYMBOL_VALUE (var));
diff --git a/gdb/block.c b/gdb/block.c
index c0e3e465a115..38773afe6a66 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -665,7 +665,7 @@ bool
 best_symbol (struct symbol *a, const domain_enum domain)
 {
   return (SYMBOL_DOMAIN (a) == domain
-	  && SYMBOL_CLASS (a) != LOC_UNRESOLVED);
+	  && a->aclass () != LOC_UNRESOLVED);
 }
 
 /* See block.h.  */
@@ -685,11 +685,10 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
       && SYMBOL_DOMAIN (a) != domain)
     return b;
 
-  if (SYMBOL_CLASS (a) != LOC_UNRESOLVED
-      && SYMBOL_CLASS (b) == LOC_UNRESOLVED)
+  if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
     return a;
-  if (SYMBOL_CLASS (b) != LOC_UNRESOLVED
-      && SYMBOL_CLASS (a) == LOC_UNRESOLVED)
+
+  if (b->aclass () != LOC_UNRESOLVED && a->aclass () == LOC_UNRESOLVED)
     return b;
 
   return a;
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 4b58ce041002..73347243f550 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1093,7 +1093,7 @@ block	:	block COLONCOLON name
 			    = lookup_symbol (copy.c_str (), $1,
 					     VAR_DOMAIN, NULL).symbol;
 
-			  if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
+			  if (!tem || tem->aclass () != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy.c_str ());
 			  $$ = SYMBOL_BLOCK_VALUE (tem); }
@@ -3067,7 +3067,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 			par_state->language ()->name_of_this ()
 			? &is_a_field_of_this : NULL);
 
-  if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
+  if (bsym.symbol && bsym.symbol->aclass () == LOC_BLOCK)
     {
       yylval.ssym.sym = bsym;
       yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
@@ -3116,7 +3116,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 	}
     }
 
-  if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_TYPEDEF)
+  if (bsym.symbol && bsym.symbol->aclass () == LOC_TYPEDEF)
     {
       yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
       return TYPENAME;
@@ -3211,7 +3211,7 @@ classify_inner_name (struct parser_state *par_state,
       return ERROR;
     }
 
-  switch (SYMBOL_CLASS (yylval.ssym.sym.symbol))
+  switch (yylval.ssym.sym.symbol->aclass ())
     {
     case LOC_BLOCK:
     case LOC_LABEL:
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a24ada66434a..14d671e29897 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -883,7 +883,7 @@ c_type_print_template_args (const struct type_print_options *flags,
     {
       struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
 
-      if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
+      if (sym->aclass () != LOC_TYPEDEF)
 	continue;
 
       if (first)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index d4c4226a8d2d..9fef28019760 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1490,7 +1490,7 @@ patch_opaque_types (struct symtab *s)
 	 Remove syms from the chain when their types are stored,
 	 but search the whole chain, as there may be several syms
 	 from different files with the same name.  */
-      if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF
+      if (real_sym->aclass () == LOC_TYPEDEF
 	  && SYMBOL_DOMAIN (real_sym) == VAR_DOMAIN
 	  && SYMBOL_TYPE (real_sym)->code () == TYPE_CODE_PTR
 	  && TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 96a7b786b397..8602480d01ab 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -62,7 +62,7 @@ convert_one_symbol (compile_c_instance *context,
 
   context->error_symbol_once (sym.symbol);
 
-  if (SYMBOL_CLASS (sym.symbol) == LOC_LABEL)
+  if (sym.symbol->aclass () == LOC_LABEL)
     sym_type = 0;
   else
     sym_type = context->convert_type (SYMBOL_TYPE (sym.symbol));
@@ -80,7 +80,7 @@ convert_one_symbol (compile_c_instance *context,
       CORE_ADDR addr = 0;
       gdb::unique_xmalloc_ptr<char> symbol_name;
 
-      switch (SYMBOL_CLASS (sym.symbol))
+      switch (sym.symbol->aclass ())
 	{
 	case LOC_TYPEDEF:
 	  kind = GCC_C_SYMBOL_TYPEDEF;
@@ -398,7 +398,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
 
       /* We only need global functions here.  */
       sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol;
-      if (sym != NULL && SYMBOL_CLASS (sym) == LOC_BLOCK)
+      if (sym != NULL && sym->aclass () == LOC_BLOCK)
 	{
 	  if (compile_debug)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -577,7 +577,7 @@ generate_c_for_for_one_variable (compile_instance *compiler,
 	}
       else
 	{
-	  switch (SYMBOL_CLASS (sym))
+	  switch (sym->aclass ())
 	    {
 	    case LOC_REGISTER:
 	    case LOC_ARG:
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 7d265357a2e4..de7afcaebcf6 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -53,7 +53,7 @@ convert_one_symbol (compile_cplus_instance *instance,
 
   instance->error_symbol_once (sym.symbol);
 
-  if (SYMBOL_CLASS (sym.symbol) == LOC_LABEL)
+  if (sym.symbol->aclass () == LOC_LABEL)
     sym_type = 0;
   else
     sym_type = instance->convert_type (SYMBOL_TYPE (sym.symbol));
@@ -70,7 +70,7 @@ convert_one_symbol (compile_cplus_instance *instance,
       std::string name;
       gdb::unique_xmalloc_ptr<char> symbol_name;
 
-      switch (SYMBOL_CLASS (sym.symbol))
+      switch (sym.symbol->aclass ())
 	{
 	case LOC_TYPEDEF:
 	  if (SYMBOL_TYPE (sym.symbol)->code () == TYPE_CODE_TYPEDEF)
@@ -435,7 +435,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
       struct symbol *sym
 	= lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol;
 
-      if (sym != nullptr && SYMBOL_CLASS (sym) == LOC_BLOCK)
+      if (sym != nullptr && sym->aclass () == LOC_BLOCK)
 	{
 	  if (compile_debug)
 	    fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 028ff0f47546..f146183f3775 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1501,7 +1501,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
       return NULL;
     }
 
-  if (SYMBOL_CLASS (rtti_sym) != LOC_TYPEDEF)
+  if (rtti_sym->aclass () != LOC_TYPEDEF)
     {
       warning (_("RTTI symbol for class '%s' is not a type"), name);
       return NULL;
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index ef858ecbd4b7..601659d080d3 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -448,7 +448,7 @@ PrimaryExpression:
 		  sym = lookup_symbol (copy.c_str (),
 				       pstate->expression_context_block,
 				       VAR_DOMAIN, &is_a_field_of_this);
-		  if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
+		  if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF)
 		    {
 		      if (symbol_read_needs_frame (sym.symbol))
 			pstate->block_tracker->update (sym);
@@ -1341,7 +1341,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
   std::string copy = copy_name (yylval.sval);
 
   sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
-  if (sym.symbol && SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF)
+  if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF)
     {
       yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
       return TYPENAME;
@@ -1388,7 +1388,7 @@ classify_inner_name (struct parser_state *par_state,
   if (yylval.ssym.sym.symbol == NULL)
     return ERROR;
 
-  if (SYMBOL_CLASS (yylval.ssym.sym.symbol) == LOC_TYPEDEF)
+  if (yylval.ssym.sym.symbol->aclass () == LOC_TYPEDEF)
     {
       yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol);
       return TYPENAME;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1155efb6df74..d07c9d26abd0 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8879,7 +8879,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
 	  struct symbol *sym = list->symbol[i];
 
 	  if (sym->language () == language_go
-	      && SYMBOL_CLASS (sym) == LOC_BLOCK)
+	      && sym->aclass () == LOC_BLOCK)
 	    {
 	      gdb::unique_xmalloc_ptr<char> this_package_name
 		(go_symbol_package_name (sym));
@@ -21844,7 +21844,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		  && die->parent->tag == DW_TAG_common_block)
 		attr2 = NULL;
 
-	      if (SYMBOL_CLASS (sym) == LOC_STATIC
+	      if (sym->aclass () == LOC_STATIC
 		  && SYMBOL_VALUE_ADDRESS (sym) == 0
 		  && !per_objfile->per_bfd->has_section_at_zero)
 		{
@@ -21855,7 +21855,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		}
 	      else if (attr2 != nullptr && attr2->as_boolean ())
 		{
-		  if (SYMBOL_CLASS (sym) == LOC_STATIC
+		  if (sym->aclass () == LOC_STATIC
 		      && (objfile->flags & OBJF_MAINLINE) == 0
 		      && per_objfile->per_bfd->can_copy)
 		    {
@@ -21918,7 +21918,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	      else if (!die_is_declaration (die, cu))
 		{
 		  /* Use the default LOC_OPTIMIZED_OUT class.  */
-		  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
+		  gdb_assert (sym->aclass () == LOC_OPTIMIZED_OUT);
 		  if (!suppress_add)
 		    list_to_add = cu->list_in_scope;
 		}
diff --git a/gdb/eval.c b/gdb/eval.c
index 713f977bc77d..91ff41cfe25a 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2588,7 +2588,7 @@ var_value_operation::evaluate_for_address (struct expression *exp,
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
       struct type *type = lookup_pointer_type (SYMBOL_TYPE (var));
-      enum address_class sym_class = SYMBOL_CLASS (var);
+      enum address_class sym_class = var->aclass ();
 
       if (sym_class == LOC_CONST
 	  || sym_class == LOC_CONST_BYTES
diff --git a/gdb/expop.h b/gdb/expop.h
index 279774ca3aff..58863b8f3ab9 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -482,7 +482,7 @@ check_constant (ULONGEST cst)
 static inline bool
 check_constant (struct symbol *sym)
 {
-  enum address_class sc = SYMBOL_CLASS (sym);
+  enum address_class sc = sym->aclass ();
   return (sc == LOC_BLOCK
 	  || sc == LOC_CONST
 	  || sc == LOC_CONST_BYTES
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 42d3130bf8a7..13f8c10897fc 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1487,7 +1487,7 @@ yylex (void)
       {
 	result = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
 				domain, NULL);
-	if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF)
+	if (result.symbol && result.symbol->aclass () == LOC_TYPEDEF)
 	  {
 	    yylval.tsym.type = SYMBOL_TYPE (result.symbol);
 	    return TYPENAME;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 3d13eb11fb0f..592593715c94 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -600,7 +600,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
 	const struct common_block *common = SYMBOL_VALUE_COMMON_BLOCK (sym);
 	size_t index;
 
-	gdb_assert (SYMBOL_CLASS (sym) == LOC_COMMON_BLOCK);
+	gdb_assert (sym->aclass () == LOC_COMMON_BLOCK);
 
 	if (comname && (!sym->linkage_name ()
 			|| strcmp (comname, sym->linkage_name ()) != 0))
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 8fcdcbb92b28..fdfad599f32e 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -358,7 +358,7 @@ symbol_read_needs (struct symbol *sym)
   if (SYMBOL_COMPUTED_OPS (sym) != NULL)
     return SYMBOL_COMPUTED_OPS (sym)->get_symbol_read_needs (sym);
 
-  switch (SYMBOL_CLASS (sym))
+  switch (sym->aclass ())
     {
       /* All cases listed explicitly so that gcc -Wall will detect it if
 	 we failed to consider one.  */
@@ -616,7 +616,7 @@ language_defn::read_var_value (struct symbol *var,
   if (SYMBOL_COMPUTED_OPS (var) != NULL)
     return SYMBOL_COMPUTED_OPS (var)->read_variable (var, frame);
 
-  switch (SYMBOL_CLASS (var))
+  switch (var->aclass ())
     {
     case LOC_CONST:
       if (is_dynamic_type (type))
@@ -718,7 +718,7 @@ language_defn::read_var_value (struct symbol *var,
 		      ->register_number (var, get_frame_arch (frame));
 	struct value *regval;
 
-	if (SYMBOL_CLASS (var) == LOC_REGPARM_ADDR)
+	if (var->aclass () == LOC_REGPARM_ADDR)
 	  {
 	    regval = value_from_register (lookup_pointer_type (type),
 					  regno,
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 795844733105..2e7f6540f94f 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1690,7 +1690,7 @@ lookup_typename (const struct language_defn *language,
 
   sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
 				   language->la_language, NULL).symbol;
-  if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
     return SYMBOL_TYPE (sym);
 
   if (noerr)
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 359af2260568..5436072d66e3 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1338,7 +1338,7 @@ package_name_p (const char *name, const struct block *block)
   sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol;
 
   if (sym
-      && SYMBOL_CLASS (sym) == LOC_TYPEDEF
+      && sym->aclass () == LOC_TYPEDEF
       && SYMBOL_TYPE (sym)->code () == TYPE_CODE_MODULE)
     return 1;
 
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 05e6b88fc84c..9816a90a8dd8 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -412,7 +412,7 @@ gdbscm_symbol_addr_class (SCM self)
     = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symbol *symbol = s_smob->symbol;
 
-  return scm_from_int (SYMBOL_CLASS (symbol));
+  return scm_from_int (symbol->aclass ());
 }
 
 /* (symbol-argument? <gdb:symbol>) -> boolean */
@@ -437,7 +437,7 @@ gdbscm_symbol_constant_p (SCM self)
   const struct symbol *symbol = s_smob->symbol;
   enum address_class theclass;
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return scm_from_bool (theclass == LOC_CONST || theclass == LOC_CONST_BYTES);
 }
@@ -452,7 +452,7 @@ gdbscm_symbol_function_p (SCM self)
   const struct symbol *symbol = s_smob->symbol;
   enum address_class theclass;
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return scm_from_bool (theclass == LOC_BLOCK);
 }
@@ -467,7 +467,7 @@ gdbscm_symbol_variable_p (SCM self)
   const struct symbol *symbol = s_smob->symbol;
   enum address_class theclass;
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return scm_from_bool (!SYMBOL_IS_ARGUMENT (symbol)
 			&& (theclass == LOC_LOCAL || theclass == LOC_REGISTER
@@ -534,7 +534,7 @@ gdbscm_symbol_value (SCM self, SCM rest)
   if (!gdbscm_is_false (frame_scm))
     f_smob = frscm_get_frame_smob_arg_unsafe (frame_scm, frame_pos, FUNC_NAME);
 
-  if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
+  if (symbol->aclass () == LOC_TYPEDEF)
     {
       gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
 				 _("cannot get the value of a typedef"));
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 994dd5b32a3e..b02040f68d3b 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -976,7 +976,7 @@ prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
 	  if (inline_skipped_frames (tp) > 0)
 	    {
 	      symbol *sym = inline_skipped_symbol (tp);
-	      if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+	      if (sym->aclass () == LOC_BLOCK)
 		{
 		  const block *block = SYMBOL_BLOCK_VALUE (sym);
 		  if (BLOCK_END (block) < tp->control.step_range_end)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 9531295e6a3d..ba135fa07203 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -204,7 +204,7 @@ collect_info::add_symbol (block_symbol *bsym)
 {
   /* In list mode, add all matching symbols, regardless of class.
      This allows the user to type "list a_global_variable".  */
-  if (SYMBOL_CLASS (bsym->symbol) == LOC_BLOCK || this->state->list_mode)
+  if (bsym->symbol->aclass () == LOC_BLOCK || this->state->list_mode)
     this->result.symbols->push_back (*bsym);
 
   /* Continue iterating.  */
@@ -2298,7 +2298,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
 
 	      if (state->funfirstline
 		   && !ls->minimal_symbols.empty ()
-		   && SYMBOL_CLASS (sym.symbol) == LOC_BLOCK)
+		   && sym.symbol->aclass () == LOC_BLOCK)
 		{
 		  const CORE_ADDR addr
 		    = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym.symbol));
@@ -3491,7 +3491,7 @@ decode_compound_collector::operator () (block_symbol *bsym)
   struct type *t;
   struct symbol *sym = bsym->symbol;
 
-  if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
+  if (sym->aclass () != LOC_TYPEDEF)
     return true; /* Continue iterating.  */
 
   t = SYMBOL_TYPE (sym);
@@ -4439,14 +4439,14 @@ static int
 symbol_to_sal (struct symtab_and_line *result,
 	       int funfirstline, struct symbol *sym)
 {
-  if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+  if (sym->aclass () == LOC_BLOCK)
     {
       *result = find_function_start_sal (sym, funfirstline);
       return 1;
     }
   else
     {
-      if (SYMBOL_CLASS (sym) == LOC_LABEL && SYMBOL_VALUE_ADDRESS (sym) != 0)
+      if (sym->aclass () == LOC_LABEL && SYMBOL_VALUE_ADDRESS (sym) != 0)
 	{
 	  *result = {};
 	  result->symtab = symbol_symtab (sym);
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 86409cf78b12..02e3cf1b4e7b 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -507,7 +507,7 @@ fblock	:	block COLONCOLON BLOCKNAME
 			{ struct symbol *tem
 			    = lookup_symbol (copy_name ($3).c_str (), $1,
 					     VAR_DOMAIN, 0).symbol;
-			  if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
+			  if (!tem || tem->aclass () != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy_name ($3).c_str ());
 			  $$ = tem;
@@ -932,7 +932,7 @@ yylex (void)
       return BLOCKNAME;
     sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
 			 VAR_DOMAIN, 0).symbol;
-    if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
+    if (sym && sym->aclass () == LOC_BLOCK)
       return BLOCKNAME;
     if (lookup_typename (pstate->language (),
 			 tmp.c_str (), pstate->expression_context_block, 1))
@@ -940,7 +940,7 @@ yylex (void)
 
     if(sym)
     {
-      switch(SYMBOL_CLASS (sym))
+      switch(sym->aclass ())
        {
        case LOC_STATIC:
        case LOC_REGISTER:
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index e0d108935e11..131b033777cd 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4468,7 +4468,7 @@ mylookup_symbol (const char *name, const struct block *block,
     {
       if (sym->linkage_name ()[0] == inc
 	  && SYMBOL_DOMAIN (sym) == domain
-	  && SYMBOL_CLASS (sym) == theclass
+	  && sym->aclass () == theclass
 	  && strcmp (sym->linkage_name (), name) == 0)
 	return sym;
     }
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 87ed547e5fb9..0c2172f0c639 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -599,7 +599,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	{
 	  int print_me = 0;
 
-	  switch (SYMBOL_CLASS (sym))
+	  switch (sym->aclass ())
 	    {
 	    default:
 	    case LOC_UNDEF:	/* catches errors        */
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index e5f8c6b20533..6ef521016ca2 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -483,7 +483,7 @@ msymbol_is_micromips (struct minimal_symbol *msym)
 static void
 mips_make_symbol_special (struct symbol *sym, struct objfile *objfile)
 {
-  if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+  if (sym->aclass () == LOC_BLOCK)
     {
       /* We are in symbol reading so it is OK to cast away constness.  */
       struct block *block = (struct block *) SYMBOL_BLOCK_VALUE (sym);
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 90163ca59b89..35b275ad3012 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -616,8 +616,8 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
      any symbols in STRUCT_DOMAIN or UNDEF_DOMAIN.
      But I'm leaving out that test, on the theory that
      they can't possibly pass the tests below.  */
-  if ((SYMBOL_CLASS (sym) == LOC_LABEL
-       || SYMBOL_CLASS (sym) == LOC_STATIC)
+  if ((sym->aclass () == LOC_LABEL
+       || sym->aclass () == LOC_STATIC)
       && sym->section_index () >= 0)
     {
       SET_SYMBOL_VALUE_ADDRESS (sym,
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 10738d073f6e..c7fa0dc882dc 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -635,7 +635,7 @@ block	:	block COLONCOLON name
 			    = lookup_symbol (copy.c_str (), $1,
 					     VAR_DOMAIN, NULL).symbol;
 
-			  if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
+			  if (!tem || tem->aclass () != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy.c_str ());
 			  $$ = SYMBOL_BLOCK_VALUE (tem); }
@@ -1544,7 +1544,7 @@ yylex (void)
     /* Call lookup_symtab, not lookup_partial_symtab, in case there are
        no psymtabs (coff, xcoff, or some future change to blow away the
        psymtabs once once symbols are read).  */
-    if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
+    if ((sym && sym->aclass () == LOC_BLOCK)
 	|| lookup_symtab (tmp.c_str ()))
       {
 	yylval.ssym.sym.symbol = sym;
@@ -1553,7 +1553,7 @@ yylex (void)
 	free (uptokstart);
 	return BLOCKNAME;
       }
-    if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+    if (sym && sym->aclass () == LOC_TYPEDEF)
 	{
 #if 1
 	  /* Despite the following flaw, we need to keep this code enabled.
@@ -1622,7 +1622,7 @@ yylex (void)
 					 VAR_DOMAIN, NULL).symbol;
 		      if (cur_sym)
 			{
-			  if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
+			  if (cur_sym->aclass () == LOC_TYPEDEF)
 			    {
 			      best_sym = cur_sym;
 			      pstate->lexptr = p;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index ab87310965df..0b0a1d63a81e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1700,7 +1700,7 @@ info_address_command (const char *exp, int from_tty)
       return;
     }
 
-  switch (SYMBOL_CLASS (sym))
+  switch (sym->aclass ())
     {
     case LOC_CONST:
     case LOC_CONST_BYTES:
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 708fcc535e20..70fec4aad5da 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -169,7 +169,7 @@ mi_should_print (struct symbol *sym, enum mi_print_types type)
 {
   int print_me = 0;
 
-  switch (SYMBOL_CLASS (sym))
+  switch (sym->aclass ())
     {
     default:
     case LOC_UNDEF:	/* catches errors        */
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index f636f5119a13..fe62809c19b2 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -131,7 +131,7 @@ sympy_get_addr_class (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  return gdb_py_object_from_longest (SYMBOL_CLASS (symbol)).release ();
+  return gdb_py_object_from_longest (symbol->aclass ()).release ();
 }
 
 static PyObject *
@@ -152,7 +152,7 @@ sympy_is_constant (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return PyBool_FromLong (theclass == LOC_CONST || theclass == LOC_CONST_BYTES);
 }
@@ -165,7 +165,7 @@ sympy_is_function (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return PyBool_FromLong (theclass == LOC_BLOCK);
 }
@@ -178,7 +178,7 @@ sympy_is_variable (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  theclass = SYMBOL_CLASS (symbol);
+  theclass = symbol->aclass ();
 
   return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (symbol)
 			  && (theclass == LOC_LOCAL || theclass == LOC_REGISTER
@@ -260,7 +260,7 @@ sympy_value (PyObject *self, PyObject *args)
     }
 
   SYMPY_REQUIRE_VALID (self, symbol);
-  if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
+  if (symbol->aclass () == LOC_TYPEDEF)
     {
       PyErr_SetString (PyExc_TypeError, "cannot get the value of a typedef");
       return NULL;
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index e71e635ecdfd..6ab551a85200 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -997,9 +997,9 @@ typy_template_argument (PyObject *self, PyObject *args)
     }
 
   sym = TYPE_TEMPLATE_ARGUMENT (type, argno);
-  if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  if (sym->aclass () == LOC_TYPEDEF)
     return type_to_type_object (SYMBOL_TYPE (sym));
-  else if (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT)
+  else if (sym->aclass () == LOC_OPTIMIZED_OUT)
     {
       PyErr_Format (PyExc_RuntimeError,
 		    _("Template argument is optimized out"));
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 31a1ee3b38f1..b4e0090bc6cf 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -1176,14 +1176,14 @@ rust_parser::name_to_operation (const std::string &name)
   struct block_symbol sym = lookup_symbol (name.c_str (),
 					   pstate->expression_context_block,
 					   VAR_DOMAIN);
-  if (sym.symbol != nullptr && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
+  if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF)
     return make_operation<var_value_operation> (sym);
 
   struct type *type = nullptr;
 
   if (sym.symbol != nullptr)
     {
-      gdb_assert (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF);
+      gdb_assert (sym.symbol->aclass () == LOC_TYPEDEF);
       type = SYMBOL_TYPE (sym.symbol);
     }
   if (type == nullptr)
diff --git a/gdb/source.c b/gdb/source.c
index 53854c02eac1..249a88318e0f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -323,7 +323,7 @@ select_source_symtab (struct symtab *s)
   /* Make the default place to list be the function `main'
      if one exists.  */
   block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0);
-  if (bsym.symbol != nullptr && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
+  if (bsym.symbol != nullptr && bsym.symbol->aclass () == LOC_BLOCK)
     {
       symtab_and_line sal = find_function_start_sal (bsym.symbol, true);
       if (sal.symtab == NULL)
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 21f824f6e73c..467f622a3677 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1155,8 +1155,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      struct symbol *prev_sym;
 
 	      prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
-	      if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
-		   || SYMBOL_CLASS (prev_sym) == LOC_ARG)
+	      if ((prev_sym->aclass () == LOC_REF_ARG
+		   || prev_sym->aclass () == LOC_ARG)
 		  && strcmp (prev_sym->linkage_name (),
 			     sym->linkage_name ()) == 0)
 		{
@@ -1398,11 +1398,11 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     {
       /* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
 	 variables passed in a register).  */
-      if (SYMBOL_CLASS (sym) == LOC_REGISTER)
+      if (sym->aclass () == LOC_REGISTER)
 	sym->set_aclass_index (LOC_REGPARM_ADDR);
       /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
 	 and subsequent arguments on SPARC, for example).  */
-      else if (SYMBOL_CLASS (sym) == LOC_ARG)
+      else if (sym->aclass () == LOC_ARG)
 	sym->set_aclass_index (LOC_REF_ARG);
     }
 
@@ -1628,7 +1628,7 @@ read_type (const char **pp, struct objfile *objfile)
 	    {
 	      struct symbol *sym = ppt->symbol[i];
 
-	      if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
+	      if (sym->aclass () == LOC_TYPEDEF
 		  && SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
 		  && (SYMBOL_TYPE (sym)->code () == code)
 		  && strcmp (sym->linkage_name (), type_name) == 0)
@@ -4466,7 +4466,7 @@ cleanup_undefined_types_1 (void)
 		      {
 			struct symbol *sym = ppt->symbol[i];
 
-			if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
+			if (sym->aclass () == LOC_TYPEDEF
 			    && SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
 			    && (SYMBOL_TYPE (sym)->code () == (*type)->code ())
 			    && ((*type)->instance_flags ()
@@ -4576,7 +4576,7 @@ scan_file_globals (struct objfile *objfile)
 		     the same symbol if there are multiple references.  */
 		  if (sym)
 		    {
-		      if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+		      if (sym->aclass () == LOC_BLOCK)
 			{
 			  fix_common_block (sym,
 					    MSYMBOL_VALUE_ADDRESS (resolve_objfile,
@@ -4627,7 +4627,7 @@ scan_file_globals (struct objfile *objfile)
 	  SET_SYMBOL_VALUE_ADDRESS (prev, 0);
 
 	  /* Complain about unresolved common block symbols.  */
-	  if (SYMBOL_CLASS (prev) == LOC_STATIC)
+	  if (prev->aclass () == LOC_STATIC)
 	    prev->set_aclass_index (LOC_UNRESOLVED);
 	  else
 	    complaint (_("%s: common block `%s' from "
diff --git a/gdb/stack.c b/gdb/stack.c
index 8d5983e64391..1df3f6b8de3b 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -773,7 +773,7 @@ print_frame_args (const frame_print_options &fp_opts,
 	      break;
 	    }
 
-	  switch (SYMBOL_CLASS (sym))
+	  switch (sym->aclass ())
 	    {
 	    case LOC_ARG:
 	    case LOC_REF_ARG:
@@ -828,7 +828,7 @@ print_frame_args (const frame_print_options &fp_opts,
 	      nsym = lookup_symbol_search_name (sym->search_name (),
 						b, VAR_DOMAIN).symbol;
 	      gdb_assert (nsym != NULL);
-	      if (SYMBOL_CLASS (nsym) == LOC_REGISTER
+	      if (nsym->aclass () == LOC_REGISTER
 		  && !SYMBOL_IS_ARGUMENT (nsym))
 		{
 		  /* There is a LOC_ARG/LOC_REGISTER pair.  This means
@@ -2248,7 +2248,7 @@ iterate_over_block_locals (const struct block *b,
 
   ALL_BLOCK_SYMBOLS (b, iter, sym)
     {
-      switch (SYMBOL_CLASS (sym))
+      switch (sym->aclass ())
 	{
 	case LOC_CONST:
 	case LOC_LOCAL:
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 179b83e416fe..5c96bf9886d2 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -543,7 +543,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
     }
   else
     {
-      if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF)
+      if (symbol->aclass () == LOC_TYPEDEF)
 	fprintf_filtered (outfile, "typedef ");
       if (SYMBOL_TYPE (symbol))
 	{
@@ -558,7 +558,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
       else
 	fprintf_filtered (outfile, "%s ", symbol->print_name ());
 
-      switch (SYMBOL_CLASS (symbol))
+      switch (symbol->aclass ())
 	{
 	case LOC_CONST:
 	  fprintf_filtered (outfile, "const %s (%s)",
@@ -654,7 +654,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 
 	default:
 	  fprintf_filtered (outfile, "botched symbol class %x",
-			    SYMBOL_CLASS (symbol));
+			    symbol->aclass ());
 	  break;
 	}
     }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 30335ee55f8c..9357b5b11ed1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1805,7 +1805,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
   /* We should have an objfile by now.  */
   gdb_assert (objfile);
 
-  switch (SYMBOL_CLASS (sym))
+  switch (sym->aclass ())
     {
     case LOC_STATIC:
     case LOC_LABEL:
@@ -3086,7 +3086,7 @@ find_symbol_at_address (CORE_ADDR address)
 
 	  ALL_BLOCK_SYMBOLS (b, iter, sym)
 	    {
-	      if (SYMBOL_CLASS (sym) == LOC_STATIC
+	      if (sym->aclass () == LOC_STATIC
 		  && SYMBOL_VALUE_ADDRESS (sym) == addr)
 		return sym;
 	    }
@@ -4119,7 +4119,7 @@ find_function_alias_target (bound_minimal_symbol msymbol)
 
   symbol *sym = find_pc_function (func_addr);
   if (sym != NULL
-      && SYMBOL_CLASS (sym) == LOC_BLOCK
+      && sym->aclass () == LOC_BLOCK
       && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == func_addr)
     return sym;
 
@@ -4828,25 +4828,25 @@ global_symbol_searcher::add_matching_symbols
 		       || preg->exec (sym->natural_name (), 0,
 				      NULL, 0) == 0)
 		      && ((kind == VARIABLES_DOMAIN
-			   && SYMBOL_CLASS (sym) != LOC_TYPEDEF
-			   && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
-			   && SYMBOL_CLASS (sym) != LOC_BLOCK
+			   && sym->aclass () != LOC_TYPEDEF
+			   && sym->aclass () != LOC_UNRESOLVED
+			   && sym->aclass () != LOC_BLOCK
 			   /* LOC_CONST can be used for more than
 			      just enums, e.g., c++ static const
 			      members.  We only want to skip enums
 			      here.  */
-			   && !(SYMBOL_CLASS (sym) == LOC_CONST
+			   && !(sym->aclass () == LOC_CONST
 				&& (SYMBOL_TYPE (sym)->code ()
 				    == TYPE_CODE_ENUM))
 			   && (!treg.has_value ()
 			       || treg_matches_sym_type_name (*treg, sym)))
 			  || (kind == FUNCTIONS_DOMAIN
-			      && SYMBOL_CLASS (sym) == LOC_BLOCK
+			      && sym->aclass () == LOC_BLOCK
 			      && (!treg.has_value ()
 				  || treg_matches_sym_type_name (*treg,
 								 sym)))
 			  || (kind == TYPES_DOMAIN
-			      && SYMBOL_CLASS (sym) == LOC_TYPEDEF
+			      && sym->aclass () == LOC_TYPEDEF
 			      && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN)
 			  || (kind == MODULES_DOMAIN
 			      && SYMBOL_DOMAIN (sym) == MODULE_DOMAIN
@@ -5056,7 +5056,7 @@ symbol_to_info_string (struct symbol *sym, int block,
       string_file tmp_stream;
 
       type_print (SYMBOL_TYPE (sym),
-		  (SYMBOL_CLASS (sym) == LOC_TYPEDEF
+		  (sym->aclass () == LOC_TYPEDEF
 		   ? "" : sym->print_name ()),
 		  &tmp_stream, 0);
 
@@ -5526,7 +5526,7 @@ completion_list_add_symbol (completion_tracker &tracker,
      tracker.  */
   if (sym->language () == language_cplus
       && SYMBOL_DOMAIN (sym) == VAR_DOMAIN
-      && SYMBOL_CLASS (sym) == LOC_BLOCK)
+      && sym->aclass () == LOC_BLOCK)
     {
       /* The call to canonicalize returns the empty string if the input
 	 string is already in canonical form, thanks to this we don't
@@ -5671,7 +5671,7 @@ completion_list_add_fields (completion_tracker &tracker,
 			    const lookup_name_info &lookup_name,
 			    const char *text, const char *word)
 {
-  if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+  if (sym->aclass () == LOC_TYPEDEF)
     {
       struct type *t = SYMBOL_TYPE (sym);
       enum type_code c = t->code ();
@@ -5723,7 +5723,7 @@ symbol_is_function_or_method (minimal_symbol *msymbol)
 bound_minimal_symbol
 find_gnu_ifunc (const symbol *sym)
 {
-  if (SYMBOL_CLASS (sym) != LOC_BLOCK)
+  if (sym->aclass () != LOC_BLOCK)
     return {};
 
   lookup_name_info lookup_name (sym->search_name (),
@@ -6572,7 +6572,7 @@ CORE_ADDR
 get_symbol_address (const struct symbol *sym)
 {
   gdb_assert (sym->maybe_copied);
-  gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC);
+  gdb_assert (sym->aclass () == LOC_STATIC);
 
   const char *linkage_name = sym->linkage_name ();
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3a22d3e19eee..a00b48f868e9 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1153,6 +1153,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     return symbol_impls[this->aclass_index ()];
   }
 
+  address_class aclass () const
+  {
+    return this->impl ().aclass;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1256,7 +1261,6 @@ struct block_symbol
    "private".  */
 
 #define SYMBOL_DOMAIN(symbol)	(symbol)->domain
-#define SYMBOL_CLASS(symbol)		((symbol)->impl ().aclass)
 #define SYMBOL_OBJFILE_OWNED(symbol)	((symbol)->is_objfile_owned)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 95fc58fb8f06..7063b08fc6f9 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -696,14 +696,14 @@ validate_actionline (const char *line, struct breakpoint *b)
 		       (exp->op.get ()));
 		  sym = vvop->get_symbol ();
 
-		  if (SYMBOL_CLASS (sym) == LOC_CONST)
+		  if (sym->aclass () == LOC_CONST)
 		    {
 		      error (_("constant `%s' (value %s) "
 			       "will not be collected."),
 			     sym->print_name (),
 			     plongest (SYMBOL_VALUE (sym)));
 		    }
-		  else if (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT)
+		  else if (sym->aclass () == LOC_OPTIMIZED_OUT)
 		    {
 		      error (_("`%s' is optimized away "
 			       "and cannot be collected."),
@@ -928,11 +928,11 @@ collection_list::collect_symbol (struct symbol *sym,
   int treat_as_expr = 0;
 
   len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
-  switch (SYMBOL_CLASS (sym))
+  switch (sym->aclass ())
     {
     default:
       printf_filtered ("%s: don't know symbol class %d\n",
-		       sym->print_name (), SYMBOL_CLASS (sym));
+		       sym->print_name (), sym->aclass ());
       break;
     case LOC_CONST:
       printf_filtered ("constant %s (value %s) will not be collected.\n",
@@ -2550,12 +2550,12 @@ info_scope_command (const char *args_in, int from_tty)
 							  gdb_stdout);
 	  else
 	    {
-	      switch (SYMBOL_CLASS (sym))
+	      switch (sym->aclass ())
 		{
 		default:
 		case LOC_UNDEF:	/* Messed up symbol?  */
 		  printf_filtered ("a bogus symbol, class %d.\n",
-				   SYMBOL_CLASS (sym));
+				   sym->aclass ());
 		  count--;		/* Don't count this one.  */
 		  continue;
 		case LOC_CONST:
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index d68970b9d672..1de223ac5a10 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -255,7 +255,7 @@ typedef_hash_table::add_template_parameters (struct type *t)
       void **slot;
 
       /* We only want type-valued template parameters in the hash.  */
-      if (SYMBOL_CLASS (TYPE_TEMPLATE_ARGUMENT (t, i)) != LOC_TYPEDEF)
+      if (TYPE_TEMPLATE_ARGUMENT (t, i)->aclass () != LOC_TYPEDEF)
 	continue;
 
       tf = XOBNEW (&m_storage, struct decl_field);
diff --git a/gdb/valops.c b/gdb/valops.c
index e091c445e794..9767b2c30e69 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -120,7 +120,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
   sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
   if (sym.symbol != NULL)
     {
-      if (SYMBOL_CLASS (sym.symbol) != LOC_BLOCK)
+      if (sym.symbol->aclass () != LOC_BLOCK)
 	{
 	  error (_("\"%s\" exists in this program but is not a function."),
 		 name);
@@ -3779,7 +3779,7 @@ value_maybe_namespace_elt (const struct type *curtype,
   if (sym.symbol == NULL)
     return NULL;
   else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
-	   && (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF))
+	   && (sym.symbol->aclass () == LOC_TYPEDEF))
     result = allocate_value (SYMBOL_TYPE (sym.symbol));
   else
     result = value_of_variable (sym.symbol, sym.block);
-- 
2.34.1


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

* [PATCH 27/33] gdb: remove SYMBOL_DOMAIN macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (25 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 26/33] gdb: remove SYMBOL_CLASS macro, add getter Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro Simon Marchi via Gdb-patches
                   ` (6 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symbol's domain.  Remove the
corresponding macro and adjust all callers.

Change-Id: I54465b50ac89739c663859a726aef8cdc6e4b8f3
---
 gdb/ada-exp.y                       |  4 +--
 gdb/ada-lang.c                      | 14 ++++----
 gdb/block.c                         | 17 +++++-----
 gdb/coffread.c                      | 10 +++---
 gdb/compile/compile-c-symbols.c     |  2 +-
 gdb/compile/compile-cplus-symbols.c |  4 +--
 gdb/ctfread.c                       | 12 +++----
 gdb/dwarf2/read.c                   | 16 ++++-----
 gdb/f-valprint.c                    |  2 +-
 gdb/jit.c                           |  2 +-
 gdb/language.c                      |  2 +-
 gdb/linespec.c                      |  2 +-
 gdb/mdebugread.c                    | 22 ++++++------
 gdb/stabsread.c                     | 52 ++++++++++++++---------------
 gdb/stack.c                         |  2 +-
 gdb/symmisc.c                       |  4 +--
 gdb/symtab.c                        | 22 ++++++------
 gdb/symtab.h                        | 15 +++++++--
 gdb/xcoffread.c                     |  2 +-
 19 files changed, 107 insertions(+), 99 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index c9fce7d40b0e..0cb4aac10e33 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -290,7 +290,7 @@ ada_funcall (int nargs)
   int array_arity = 0;
   struct type *callee_t = nullptr;
   if (vvo == nullptr
-      || SYMBOL_DOMAIN (vvo->get_symbol ()) != UNDEF_DOMAIN)
+      || vvo->get_symbol ()->domain () != UNDEF_DOMAIN)
     {
       struct value *callee_v = callee->evaluate (nullptr,
 						 pstate->expout.get (),
@@ -1435,7 +1435,7 @@ write_ambiguous_var (struct parser_state *par_state,
 {
   struct symbol *sym = new (&temp_parse_space) symbol ();
 
-  SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
+  sym->set_domain (UNDEF_DOMAIN);
   sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
   sym->set_language (language_ada, nullptr);
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c689548aab6c..dd1be6045639 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4477,7 +4477,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
 {
   if (sym0 == sym1)
     return 1;
-  if (SYMBOL_DOMAIN (sym0) != SYMBOL_DOMAIN (sym1)
+  if (sym0->domain () != sym1->domain ()
       || sym0->aclass () != sym1->aclass ())
     return 0;
 
@@ -5740,7 +5740,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
        sym != NULL;
        sym = block_iter_match_next (lookup_name, &iter))
     {
-      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), sym->domain (), domain))
 	{
 	  if (sym->aclass () != LOC_UNRESOLVED)
 	    {
@@ -5780,7 +5780,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
       ALL_BLOCK_SYMBOLS (block, iter, sym)
       {
 	if (symbol_matches_domain (sym->language (),
-				   SYMBOL_DOMAIN (sym), domain))
+				   sym->domain (), domain))
 	  {
 	    int cmp;
 
@@ -10411,7 +10411,7 @@ ada_var_value_operation::evaluate (struct type *expect_type,
 {
   symbol *sym = std::get<0> (m_storage).symbol;
 
-  if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
+  if (sym->domain () == UNDEF_DOMAIN)
     /* Only encountered when an unresolved symbol occurs in a
        context other than a function call, in which case, it is
        invalid.  */
@@ -10501,7 +10501,7 @@ ada_var_value_operation::resolve (struct expression *exp,
 				  struct type *context_type)
 {
   symbol *sym = std::get<0> (m_storage).symbol;
-  if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
+  if (sym->domain () == UNDEF_DOMAIN)
     {
       block_symbol resolved
 	= ada_resolve_variable (sym, std::get<0> (m_storage).block,
@@ -10666,7 +10666,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
   ada_var_value_operation *avv
     = dynamic_cast<ada_var_value_operation *> (callee_op.get ());
   if (avv != nullptr
-      && SYMBOL_DOMAIN (avv->get_symbol ()) == UNDEF_DOMAIN)
+      && avv->get_symbol ()->domain () == UNDEF_DOMAIN)
     error (_("Unexpected unresolved symbol, %s, during evaluation"),
 	   avv->get_symbol ()->print_name ());
 
@@ -10810,7 +10810,7 @@ ada_funcall_operation::resolve (struct expression *exp,
     return false;
 
   symbol *sym = avv->get_symbol ();
-  if (SYMBOL_DOMAIN (sym) != UNDEF_DOMAIN)
+  if (sym->domain () != UNDEF_DOMAIN)
     return false;
 
   const std::vector<operation_up> &args_up = std::get<1> (m_storage);
diff --git a/gdb/block.c b/gdb/block.c
index 38773afe6a66..7ec56c745aff 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -664,7 +664,7 @@ block_iter_match_next (const lookup_name_info &name,
 bool
 best_symbol (struct symbol *a, const domain_enum domain)
 {
-  return (SYMBOL_DOMAIN (a) == domain
+  return (a->domain () == domain
 	  && a->aclass () != LOC_UNRESOLVED);
 }
 
@@ -678,11 +678,10 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
   if (b == NULL)
     return a;
 
-  if (SYMBOL_DOMAIN (a) == domain
-      && SYMBOL_DOMAIN (b) != domain)
+  if (a->domain () == domain && b->domain () != domain)
     return a;
-  if (SYMBOL_DOMAIN (b) == domain
-      && SYMBOL_DOMAIN (a) != domain)
+
+  if (b->domain () == domain && a->domain () != domain)
     return b;
 
   if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
@@ -730,7 +729,7 @@ block_lookup_symbol (const struct block *block, const char *name,
 	     make sure there is no "better" matching symbol, i.e., one with
 	     exactly the same domain.  PR 16253.  */
 	  if (symbol_matches_domain (sym->language (),
-				     SYMBOL_DOMAIN (sym), domain))
+				     sym->domain (), domain))
 	    other = better_symbol (other, sym, domain);
 	}
       return other;
@@ -751,7 +750,7 @@ block_lookup_symbol (const struct block *block, const char *name,
       ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
 	{
 	  if (symbol_matches_domain (sym->language (),
-				     SYMBOL_DOMAIN (sym), domain))
+				     sym->domain (), domain))
 	    {
 	      sym_found = sym;
 	      if (!SYMBOL_IS_ARGUMENT (sym))
@@ -819,7 +818,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
 	 STRUCT vs VAR domain symbols.  So if a matching symbol is found,
 	 make sure there is no "better" matching symbol, i.e., one with
 	 exactly the same domain.  PR 16253.  */
-      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), sym->domain (), domain))
 	other = better_symbol (other, sym, domain);
     }
 
@@ -846,7 +845,7 @@ block_find_symbol (const struct block *block, const char *name,
     {
       /* MATCHER is deliberately called second here so that it never sees
 	 a non-domain-matching symbol.  */
-      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain)
+      if (symbol_matches_domain (sym->language (), sym->domain (), domain)
 	  && matcher (sym, data))
 	return sym;
     }
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 9fef28019760..8bf742161e7e 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1491,7 +1491,7 @@ patch_opaque_types (struct symtab *s)
 	 but search the whole chain, as there may be several syms
 	 from different files with the same name.  */
       if (real_sym->aclass () == LOC_TYPEDEF
-	  && SYMBOL_DOMAIN (real_sym) == VAR_DOMAIN
+	  && real_sym->domain () == VAR_DOMAIN
 	  && SYMBOL_TYPE (real_sym)->code () == TYPE_CODE_PTR
 	  && TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
 	{
@@ -1565,7 +1565,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
   /* default assumptions */
   SYMBOL_VALUE (sym) = cs->c_value;
-  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+  sym->set_domain (VAR_DOMAIN);
   sym->set_section_index (cs_to_section (cs, objfile));
 
   if (ISFCN (cs->c_type))
@@ -1653,7 +1653,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
 	case C_TPDEF:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	  sym->set_domain (VAR_DOMAIN);
 
 	  /* If type has no name, give it one.  */
 	  if (SYMBOL_TYPE (sym)->name () == 0)
@@ -1708,7 +1708,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	case C_UNTAG:
 	case C_ENTAG:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
+	  sym->set_domain (STRUCT_DOMAIN);
 
 	  /* Some compilers try to be helpful by inventing "fake"
 	     names for anonymous enums, structures, and unions, like
@@ -2099,7 +2099,7 @@ coff_read_enum_type (int index, int length, int lastsym,
 	  name = obstack_strdup (&objfile->objfile_obstack, name);
 	  sym->set_linkage_name (name);
 	  sym->set_aclass_index (LOC_CONST);
-	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	  sym->set_domain (VAR_DOMAIN);
 	  SYMBOL_VALUE (sym) = ms->c_value;
 	  add_symbol_to_list (sym, symlist);
 	  nsyms++;
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 8602480d01ab..41746c20e057 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -67,7 +67,7 @@ convert_one_symbol (compile_c_instance *context,
   else
     sym_type = context->convert_type (SYMBOL_TYPE (sym.symbol));
 
-  if (SYMBOL_DOMAIN (sym.symbol) == STRUCT_DOMAIN)
+  if (sym.symbol->domain () == STRUCT_DOMAIN)
     {
       /* Binding a tag, so we don't need to build a decl.  */
       context->plugin ().tagbind (sym.symbol->natural_name (),
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index de7afcaebcf6..3a24aa7dc8b0 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -58,7 +58,7 @@ convert_one_symbol (compile_cplus_instance *instance,
   else
     sym_type = instance->convert_type (SYMBOL_TYPE (sym.symbol));
 
-  if (SYMBOL_DOMAIN (sym.symbol) == STRUCT_DOMAIN)
+  if (sym.symbol->domain () == STRUCT_DOMAIN)
     {
       /* Nothing to do.  */
     }
@@ -374,7 +374,7 @@ gcc_cplus_convert_symbol (void *datum,
 	    {
 	      found = true;
 	      convert_symbol_sym (instance, identifier, it,
-				  SYMBOL_DOMAIN (it.symbol));
+				  it.symbol->domain ());
 	    }
 	}
 
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index dbafe75b8312..2f8c03916594 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -451,7 +451,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
       sym->set_language (language_c, &ccp->of->objfile_obstack);
       sym->compute_and_set_names (name, false, ccp->of->per_bfd);
       sym->set_aclass_index (LOC_CONST);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       SYMBOL_TYPE (sym) = fip->ptype;
       add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
     }
@@ -479,7 +479,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 
       sym->set_language (language_c, &objfile->objfile_obstack);
       sym->compute_and_set_names (name, false, objfile->per_bfd);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 
       if (type != nullptr)
@@ -492,7 +492,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	  case CTF_K_UNION:
 	  case CTF_K_ENUM:
 	    sym->set_aclass_index (LOC_TYPEDEF);
-	    SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
+	    sym->set_domain (STRUCT_DOMAIN);
 	    break;
 	  case CTF_K_FUNCTION:
 	    sym->set_aclass_index (LOC_STATIC);
@@ -506,7 +506,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	  case CTF_K_INTEGER:
 	  case CTF_K_FLOAT:
 	    sym->set_aclass_index (LOC_TYPEDEF);
-	    SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	    sym->set_domain (VAR_DOMAIN);
 	    break;
 	  case CTF_K_POINTER:
 	    break;
@@ -1170,7 +1170,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
 	sym = new (&ccp->of->objfile_obstack) symbol;
 	OBJSTAT (ccp->of, n_syms++);
 	SYMBOL_TYPE (sym) = type;
-	SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	sym->set_domain (VAR_DOMAIN);
 	sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	sym->compute_and_set_names (name, false, ccp->of->per_bfd);
 	add_symbol_to_list (sym, ccp->builder->get_file_symbols ());
@@ -1206,7 +1206,7 @@ add_stt_entries (struct ctf_context *ccp, int functions)
       sym = new (&ccp->of->objfile_obstack) symbol;
       OBJSTAT (ccp->of, n_syms++);
       SYMBOL_TYPE (sym) = type;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       sym->set_aclass_index (LOC_STATIC);
       sym->compute_and_set_names (tname, false, ccp->of->per_bfd);
       add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d07c9d26abd0..b62252eb4cfe 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8916,7 +8916,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
       /* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
 	 e.g., "main" finds the "main" module and not C's main().  */
-      SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
+      sym->set_domain (STRUCT_DOMAIN);
       sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_TYPE (sym) = type;
 
@@ -21717,7 +21717,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
       /* Default assumptions.
 	 Use the passed type or decode it from the die.  */
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       sym->set_aclass_index (LOC_OPTIMIZED_OUT);
       if (type != NULL)
 	SYMBOL_TYPE (sym) = type;
@@ -21765,7 +21765,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  else
 	    sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	  SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
-	  SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
+	  sym->set_domain (LABEL_DOMAIN);
 	  add_symbol_to_list (sym, cu->list_in_scope);
 	  break;
 	case DW_TAG_subprogram:
@@ -21964,7 +21964,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_set_type:
 	case DW_TAG_enumeration_type:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
+	  sym->set_domain (STRUCT_DOMAIN);
 
 	  {
 	    /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
@@ -22002,14 +22002,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  break;
 	case DW_TAG_typedef:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	  sym->set_domain (VAR_DOMAIN);
 	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_array_type:
 	case DW_TAG_base_type:
 	case DW_TAG_subrange_type:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	  sym->set_domain (VAR_DOMAIN);
 	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_enumerator:
@@ -22036,12 +22036,12 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  break;
 	case DW_TAG_module:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  SYMBOL_DOMAIN (sym) = MODULE_DOMAIN;
+	  sym->set_domain (MODULE_DOMAIN);
 	  list_to_add = cu->get_builder ()->get_global_symbols ();
 	  break;
 	case DW_TAG_common_block:
 	  sym->set_aclass_index (LOC_COMMON_BLOCK);
-	  SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
+	  sym->set_domain (COMMON_BLOCK_DOMAIN);
 	  add_symbol_to_list (sym, cu->list_in_scope);
 	  break;
 	default:
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 592593715c94..e8d8627bfca4 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -595,7 +595,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
   get_user_print_options (&opts);
 
   ALL_BLOCK_SYMBOLS (block, iter, sym)
-    if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
+    if (sym->domain () == COMMON_BLOCK_DOMAIN)
       {
 	const struct common_block *common = SYMBOL_VALUE_COMMON_BLOCK (sym);
 	size_t index;
diff --git a/gdb/jit.c b/gdb/jit.c
index a2c7345fc495..833cb8ed78c7 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -550,7 +550,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter.end;
 
       /* The name.  */
-      SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
+      block_name->set_domain (VAR_DOMAIN);
       block_name->set_aclass_index (LOC_BLOCK);
       symbol_set_symtab (block_name, filetab);
       SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
diff --git a/gdb/language.c b/gdb/language.c
index aff6c21e2b62..b33ff7ff0da3 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1001,7 +1001,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   SYMBOL_OBJFILE_OWNED (symbol) = 0;
   symbol->set_section_index (0);
   SYMBOL_TYPE (symbol) = type;
-  SYMBOL_DOMAIN (symbol) = VAR_DOMAIN;
+  symbol->set_domain (VAR_DOMAIN);
   symbol->set_aclass_index (LOC_TYPEDEF);
   return symbol;
 }
diff --git a/gdb/linespec.c b/gdb/linespec.c
index ba135fa07203..7c904473657f 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3995,7 +3995,7 @@ find_label_symbols_in_block (const struct block *block,
       ALL_BLOCK_SYMBOLS (block, iter, sym)
 	{
 	  if (symbol_matches_domain (sym->language (),
-				     SYMBOL_DOMAIN (sym), LABEL_DOMAIN)
+				     sym->domain (), LABEL_DOMAIN)
 	      && cmp (sym->search_name (), name, name_len) == 0)
 	    {
 	      result->push_back ({sym, block});
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 131b033777cd..0a2a4c327d16 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -562,7 +562,7 @@ add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend,
 		 struct symbol *s, int aclass_index, struct block *b,
 		 struct objfile *objfile, const char *name)
 {
-  SYMBOL_DOMAIN (s) = VAR_DOMAIN;
+  s->set_domain (VAR_DOMAIN);
   s->set_aclass_index (aclass_index);
   add_symbol (s, top_stack->cur_st, b);
 
@@ -675,7 +675,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	name = "this";		/* FIXME, not alloc'd in obstack.  */
       s = new_symbol (name);
 
-      SYMBOL_DOMAIN (s) = VAR_DOMAIN;
+      s->set_domain (VAR_DOMAIN);
       SYMBOL_IS_ARGUMENT (s) = 1;
       switch (sh->sc)
 	{
@@ -703,7 +703,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
     case stLabel:		/* label, goes into current block.  */
       s = new_symbol (name);
-      SYMBOL_DOMAIN (s) = VAR_DOMAIN;	/* So that it can be used */
+      s->set_domain (VAR_DOMAIN);	/* So that it can be used */
       s->set_aclass_index (LOC_LABEL);	/* but not misused.  */
       SET_SYMBOL_VALUE_ADDRESS (s, (CORE_ADDR) sh->value);
       SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_int;
@@ -744,7 +744,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  break;
 	}
       s = new_symbol (name);
-      SYMBOL_DOMAIN (s) = VAR_DOMAIN;
+      s->set_domain (VAR_DOMAIN);
       s->set_aclass_index (LOC_BLOCK);
       /* Type of the return value.  */
       if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
@@ -1067,7 +1067,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 				   f->name ()));
 		enum_sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (enum_sym) = t;
-		SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
+		enum_sym->set_domain (VAR_DOMAIN);
 		SYMBOL_VALUE (enum_sym) = tsym.value;
 		if (SYMBOL_VALUE (enum_sym) < 0)
 		  unsigned_enum = 0;
@@ -1097,7 +1097,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  }
 
 	s = new_symbol (name);
-	SYMBOL_DOMAIN (s) = STRUCT_DOMAIN;
+	s->set_domain (STRUCT_DOMAIN);
 	s->set_aclass_index (LOC_TYPEDEF);
 	SYMBOL_VALUE (s) = 0;
 	SYMBOL_TYPE (s) = t;
@@ -1154,7 +1154,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 	  /* Make up special symbol to contain procedure specific info.  */
 	  s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
-	  SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
+	  s->set_domain (LABEL_DOMAIN);
 	  s->set_aclass_index (LOC_CONST);
 	  SYMBOL_TYPE (s) = objfile_type (mdebugread_objfile)->builtin_void;
 	  e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
@@ -1295,7 +1295,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       if (has_opaque_xref (cur_fdr, sh))
 	break;
       s = new_symbol (name);
-      SYMBOL_DOMAIN (s) = VAR_DOMAIN;
+      s->set_domain (VAR_DOMAIN);
       s->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block;
       SYMBOL_TYPE (s) = t;
@@ -1987,7 +1987,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
 #else
 /* FIXME -- delete.  We can't do symbol allocation now; it's all done.  */
       s = new_symbol (sh_name);
-      SYMBOL_DOMAIN (s) = VAR_DOMAIN;
+      s->set_domain (VAR_DOMAIN);
       SYMBOL_CLASS (s) = LOC_BLOCK;
       /* Don't know its type, hope int is ok.  */
       SYMBOL_TYPE (s)
@@ -3987,7 +3987,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 				      mdebug_extra_func_info);
 		  struct symbol *s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
 
-		  SYMBOL_DOMAIN (s) = LABEL_DOMAIN;
+		  s->set_domain (LABEL_DOMAIN);
 		  s->set_aclass_index (LOC_CONST);
 		  SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void;
 		  SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
@@ -4467,7 +4467,7 @@ mylookup_symbol (const char *name, const struct block *block,
   ALL_BLOCK_SYMBOLS (block, iter, sym)
     {
       if (sym->linkage_name ()[0] == inc
-	  && SYMBOL_DOMAIN (sym) == domain
+	  && sym->domain () == domain
 	  && sym->aclass () == theclass
 	  && strcmp (sym->linkage_name (), name) == 0)
 	return sym;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 467f622a3677..38e94818fc54 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -424,7 +424,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
 		 ld will remove it from the executable.  There is then
 		 a N_GSYM stab for it, but no regular (C_EXT) symbol.  */
 	      sym = new (&objfile->objfile_obstack) symbol;
-	      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	      sym->set_domain (VAR_DOMAIN);
 	      sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	      sym->set_linkage_name
 		(obstack_strndup (&objfile->objfile_obstack, name, pp - name));
@@ -785,7 +785,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	{
 	  sym->set_aclass_index (LOC_CONST);
 	  SYMBOL_TYPE (sym) = error_type (&p, objfile);
-	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+	  sym->set_domain (VAR_DOMAIN);
 	  add_symbol_to_list (sym, get_file_symbols ());
 	  return sym;
 	}
@@ -844,7 +844,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      {
 		sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
-		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+		sym->set_domain (VAR_DOMAIN);
 		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
 	      }
@@ -869,7 +869,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      {
 		sym->set_aclass_index (LOC_CONST);
 		SYMBOL_TYPE (sym) = error_type (&p, objfile);
-		SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+		sym->set_domain (VAR_DOMAIN);
 		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
 	      }
@@ -924,7 +924,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    SYMBOL_TYPE (sym) = error_type (&p, objfile);
 	  }
 	}
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
       return sym;
 
@@ -932,7 +932,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* The name of a caught exception.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_LABEL);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
@@ -941,7 +941,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* A static function definition.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_BLOCK);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
       /* fall into process_function_types.  */
 
@@ -1013,7 +1013,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* A global function definition.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_BLOCK);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_global_symbols ());
       goto process_function_types;
 
@@ -1024,7 +1024,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 These definitions appear at the end of the namelist.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_STATIC);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       /* Don't add symbol references to global_sym_chain.
 	 Symbol references don't have valid names and wont't match up with
 	 minimal symbols when the global_sym_chain is relocated.
@@ -1046,7 +1046,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1066,7 +1066,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
       sym->set_aclass_index (LOC_ARG);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       add_symbol_to_list (sym, get_local_symbols ());
 
@@ -1116,7 +1116,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       sym->set_aclass_index (stab_register_index);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1125,7 +1125,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (stab_register_index);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       if (within_function)
 	{
 	  /* Sun cc uses a pair of symbols, one 'p' and one 'r', with
@@ -1180,7 +1180,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
       break;
 
@@ -1211,7 +1211,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
       sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       /* C++ vagaries: we may have a type which is derived from
 	 a base type which did not have its name defined when the
 	 derived class was output.  We fill in the derived class's
@@ -1288,7 +1288,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  *struct_sym = *sym;
 	  struct_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (struct_sym) = valu;
-	  SYMBOL_DOMAIN (struct_sym) = STRUCT_DOMAIN;
+	  struct_sym->set_domain (STRUCT_DOMAIN);
 	  if (SYMBOL_TYPE (sym)->name () == 0)
 	    SYMBOL_TYPE (sym)->set_name
 	      (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
@@ -1315,7 +1315,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
       sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
+      sym->set_domain (STRUCT_DOMAIN);
       if (SYMBOL_TYPE (sym)->name () == 0)
 	SYMBOL_TYPE (sym)->set_name
 	  (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
@@ -1330,7 +1330,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  *typedef_sym = *sym;
 	  typedef_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (typedef_sym) = valu;
-	  SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
+	  typedef_sym->set_domain (VAR_DOMAIN);
 	  if (SYMBOL_TYPE (sym)->name () == 0)
 	    SYMBOL_TYPE (sym)->set_name
 	      (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
@@ -1344,7 +1344,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1354,7 +1354,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       sym->set_aclass_index (LOC_REF_ARG);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1364,7 +1364,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       sym->set_aclass_index (stab_regparm_index);
       SYMBOL_IS_ARGUMENT (sym) = 1;
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1376,7 +1376,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
       break;
 
@@ -1384,7 +1384,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_TYPE (sym) = error_type (&p, objfile);
       sym->set_aclass_index (LOC_CONST);
       SYMBOL_VALUE (sym) = 0;
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
       break;
     }
@@ -1629,7 +1629,7 @@ read_type (const char **pp, struct objfile *objfile)
 	      struct symbol *sym = ppt->symbol[i];
 
 	      if (sym->aclass () == LOC_TYPEDEF
-		  && SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
+		  && sym->domain () == STRUCT_DOMAIN
 		  && (SYMBOL_TYPE (sym)->code () == code)
 		  && strcmp (sym->linkage_name (), type_name) == 0)
 		{
@@ -3593,7 +3593,7 @@ read_enum_type (const char **pp, struct type *type,
       sym->set_language (get_current_subfile ()->language,
 			 &objfile->objfile_obstack);
       sym->set_aclass_index (LOC_CONST);
-      SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
+      sym->set_domain (VAR_DOMAIN);
       SYMBOL_VALUE (sym) = n;
       if (n < 0)
 	unsigned_enum = 0;
@@ -4467,7 +4467,7 @@ cleanup_undefined_types_1 (void)
 			struct symbol *sym = ppt->symbol[i];
 
 			if (sym->aclass () == LOC_TYPEDEF
-			    && SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
+			    && sym->domain () == STRUCT_DOMAIN
 			    && (SYMBOL_TYPE (sym)->code () == (*type)->code ())
 			    && ((*type)->instance_flags ()
 				== SYMBOL_TYPE (sym)->instance_flags ())
diff --git a/gdb/stack.c b/gdb/stack.c
index 1df3f6b8de3b..fcdcd35f8b39 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2258,7 +2258,7 @@ iterate_over_block_locals (const struct block *b,
 	case LOC_OPTIMIZED_OUT:
 	  if (SYMBOL_IS_ARGUMENT (sym))
 	    break;
-	  if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
+	  if (sym->domain () == COMMON_BLOCK_DOMAIN)
 	    break;
 	  (*cb) (sym->print_name (), sym, cb_data);
 	  break;
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 5c96bf9886d2..9bba067a07f8 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -508,7 +508,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
     section = NULL;
 
   print_spaces_filtered (depth, outfile);
-  if (SYMBOL_DOMAIN (symbol) == LABEL_DOMAIN)
+  if (symbol->domain () == LABEL_DOMAIN)
     {
       fprintf_filtered (outfile, "label %s at ", symbol->print_name ());
       fputs_filtered (paddress (gdbarch, SYMBOL_VALUE_ADDRESS (symbol)),
@@ -521,7 +521,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
       return;
     }
 
-  if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
+  if (symbol->domain () == STRUCT_DOMAIN)
     {
       if (SYMBOL_TYPE (symbol)->name ())
 	{
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9357b5b11ed1..5e4a461deb92 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1229,7 +1229,7 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
   else
     {
       slot_name = slot->value.found.symbol->search_name ();
-      slot_domain = SYMBOL_DOMAIN (slot->value.found.symbol);
+      slot_domain = slot->value.found.symbol->domain ();
     }
 
   /* NULL names match.  */
@@ -1582,7 +1582,7 @@ symbol_cache_dump (const struct symbol_cache *cache)
 		printf_filtered ("  [%4u] = %s, %s %s\n", i,
 				 host_address_to_string (context),
 				 found->print_name (),
-				 domain_name (SYMBOL_DOMAIN (found)));
+				 domain_name (found->domain ()));
 		break;
 	      }
 	    }
@@ -2329,7 +2329,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
 	  break;
 	}
       if (symbol_matches_domain (result.symbol->language (),
-				 SYMBOL_DOMAIN (result.symbol), domain))
+				 result.symbol->domain (), domain))
 	{
 	  struct symbol *better
 	    = better_symbol (other.symbol, result.symbol, domain);
@@ -2906,7 +2906,7 @@ iterate_over_symbols (const struct block *block,
 
   ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     {
-      if (symbol_matches_domain (sym->language (), SYMBOL_DOMAIN (sym), domain))
+      if (symbol_matches_domain (sym->language (), sym->domain (), domain))
 	{
 	  struct block_symbol block_sym = {sym, block};
 
@@ -4847,9 +4847,9 @@ global_symbol_searcher::add_matching_symbols
 								 sym)))
 			  || (kind == TYPES_DOMAIN
 			      && sym->aclass () == LOC_TYPEDEF
-			      && SYMBOL_DOMAIN (sym) != MODULE_DOMAIN)
+			      && sym->domain () != MODULE_DOMAIN)
 			  || (kind == MODULES_DOMAIN
-			      && SYMBOL_DOMAIN (sym) == MODULE_DOMAIN
+			      && sym->domain () == MODULE_DOMAIN
 			      && SYMBOL_LINE (sym) != 0))))
 		{
 		  if (result_set->size () < m_max_search_results)
@@ -5030,7 +5030,7 @@ symbol_to_info_string (struct symbol *sym, int block,
 
   /* Typedef that is not a C++ class.  */
   if (kind == TYPES_DOMAIN
-      && SYMBOL_DOMAIN (sym) != STRUCT_DOMAIN)
+      && sym->domain () != STRUCT_DOMAIN)
     {
       string_file tmp_stream;
 
@@ -5051,7 +5051,7 @@ symbol_to_info_string (struct symbol *sym, int block,
   /* variable, func, or typedef-that-is-c++-class.  */
   else if (kind < TYPES_DOMAIN
 	   || (kind == TYPES_DOMAIN
-	       && SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN))
+	       && sym->domain () == STRUCT_DOMAIN))
     {
       string_file tmp_stream;
 
@@ -5525,7 +5525,7 @@ completion_list_add_symbol (completion_tracker &tracker,
      the msymbol name and removes the msymbol name from the completion
      tracker.  */
   if (sym->language () == language_cplus
-      && SYMBOL_DOMAIN (sym) == VAR_DOMAIN
+      && sym->domain () == VAR_DOMAIN
       && sym->aclass () == LOC_BLOCK)
     {
       /* The call to canonicalize returns the empty string if the input
@@ -5788,7 +5788,7 @@ add_symtab_completions (struct compunit_symtab *cust,
 	    continue;
 
 	  if (code == TYPE_CODE_UNDEF
-	      || (SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
+	      || (sym->domain () == STRUCT_DOMAIN
 		  && SYMBOL_TYPE (sym)->code () == code))
 	    completion_list_add_symbol (tracker, sym,
 					lookup_name,
@@ -5941,7 +5941,7 @@ default_collect_symbol_completion_matches_break_on
 		completion_list_add_fields (tracker, sym, lookup_name,
 					    sym_text, word);
 	      }
-	    else if (SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN
+	    else if (sym->domain () == STRUCT_DOMAIN
 		     && SYMBOL_TYPE (sym)->code () == code)
 	      completion_list_add_symbol (tracker, sym, lookup_name,
 					  sym_text, word);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a00b48f868e9..2825697fc192 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1113,7 +1113,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
 {
   symbol ()
     /* Class-initialization of bitfields is only allowed in C++20.  */
-    : domain (UNDEF_DOMAIN),
+    : m_domain (UNDEF_DOMAIN),
       m_aclass_index (0),
       is_objfile_owned (1),
       is_argument (0),
@@ -1158,6 +1158,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     return this->impl ().aclass;
   }
 
+  domain_enum domain () const
+  {
+    return m_domain;
+  }
+
+  void set_domain (domain_enum domain)
+  {
+    m_domain = domain;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1178,7 +1188,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
 
   /* Domain code.  */
 
-  ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;
+  ENUM_BITFIELD(domain_enum_tag) m_domain : SYMBOL_DOMAIN_BITS;
 
   /* Address class.  This holds an index into the 'symbol_impls'
      table.  The actual enum address_class value is stored there,
@@ -1260,7 +1270,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_DOMAIN(symbol)	(symbol)->domain
 #define SYMBOL_OBJFILE_OWNED(symbol)	((symbol)->is_objfile_owned)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 6458e9f52d0f..bdfbdbff96ff 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1562,7 +1562,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;
+  sym->set_domain (VAR_DOMAIN);
   sym->set_section_index (secnum_to_section (cs->c_secnum, objfile));
 
   if (ISFCN (cs->c_type))
-- 
2.34.1


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

* [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (26 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 27/33] gdb: remove SYMBOL_DOMAIN macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 29/33] gdb: remove SYMBOL_IS_ARGUMENT macro Simon Marchi via Gdb-patches
                   ` (5 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for whether a symbol is objfile owned.  Remove
the corresponding macro and adjust all callers.

Change-Id: Ib7ef3718d65553ae924ca04c3fd478b0f4f3147c
---
 gdb/ada-lang.c         |  4 ++--
 gdb/guile/scm-symbol.c |  4 ++--
 gdb/language.c         |  2 +-
 gdb/printcmd.c         |  2 +-
 gdb/python/py-symbol.c |  6 +++---
 gdb/symmisc.c          |  2 +-
 gdb/symtab.c           | 10 +++++-----
 gdb/symtab.h           | 15 ++++++++++++---
 8 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index dd1be6045639..77d6c07c6a9e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3352,7 +3352,7 @@ See set/show multiple-symbol."));
 	     && SYMBOL_TYPE (syms[i].symbol)->code () == TYPE_CODE_ENUM);
 	  struct symtab *symtab = NULL;
 
-	  if (SYMBOL_OBJFILE_OWNED (syms[i].symbol))
+	  if (syms[i].symbol->is_objfile_owned ())
 	    symtab = symbol_symtab (syms[i].symbol);
 
 	  if (SYMBOL_LINE (syms[i].symbol) != 0 && symtab != NULL)
@@ -4376,7 +4376,7 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
 
   /* Symbols for builtin types don't have a block.
      For now don't cache such symbols.  */
-  if (sym != NULL && !SYMBOL_OBJFILE_OWNED (sym))
+  if (sym != NULL && !sym->is_objfile_owned ())
     return;
 
   /* If the symbol is a local symbol, then do not cache it, as a search
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 9816a90a8dd8..caad90f46785 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -101,7 +101,7 @@ syscm_get_symbol_map (struct symbol *symbol)
 {
   htab_t htab;
 
-  if (SYMBOL_OBJFILE_OWNED (symbol))
+  if (symbol->is_objfile_owned ())
     {
       struct objfile *objfile = symbol_objfile (symbol);
 
@@ -362,7 +362,7 @@ gdbscm_symbol_symtab (SCM self)
     = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symbol *symbol = s_smob->symbol;
 
-  if (!SYMBOL_OBJFILE_OWNED (symbol))
+  if (!symbol->is_objfile_owned ())
     return SCM_BOOL_F;
   return stscm_scm_from_symtab (symbol_symtab (symbol));
 }
diff --git a/gdb/language.c b/gdb/language.c
index b33ff7ff0da3..1d4b1b312525 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -998,7 +998,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->m_name = type->name ();
   symbol->set_language (lang, nullptr);
   symbol->owner.arch = gdbarch;
-  SYMBOL_OBJFILE_OWNED (symbol) = 0;
+  symbol->set_is_objfile_owned (0);
   symbol->set_section_index (0);
   SYMBOL_TYPE (symbol) = type;
   symbol->set_domain (VAR_DOMAIN);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 0b0a1d63a81e..787d8d771284 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1686,7 +1686,7 @@ info_address_command (const char *exp, int from_tty)
   puts_filtered (sym->print_name ());
   printf_filtered ("\" is ");
   val = SYMBOL_VALUE (sym);
-  if (SYMBOL_OBJFILE_OWNED (sym))
+  if (sym->is_objfile_owned ())
     section = sym->obj_section (symbol_objfile (sym));
   else
     section = NULL;
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index fe62809c19b2..708474331d72 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -88,7 +88,7 @@ sympy_get_symtab (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  if (!SYMBOL_OBJFILE_OWNED (symbol))
+  if (!symbol->is_objfile_owned ())
     Py_RETURN_NONE;
 
   return symtab_to_symtab_object (symbol_symtab (symbol));
@@ -302,7 +302,7 @@ set_symbol (symbol_object *obj, struct symbol *symbol)
 {
   obj->symbol = symbol;
   obj->prev = NULL;
-  if (SYMBOL_OBJFILE_OWNED (symbol)
+  if (symbol->is_objfile_owned ()
       && symbol_symtab (symbol) != NULL)
     {
       struct objfile *objfile = symbol_objfile (symbol);
@@ -348,7 +348,7 @@ sympy_dealloc (PyObject *obj)
   if (sym_obj->prev)
     sym_obj->prev->next = sym_obj->next;
   else if (sym_obj->symbol != NULL
-	   && SYMBOL_OBJFILE_OWNED (sym_obj->symbol)
+	   && sym_obj->symbol->is_objfile_owned ()
 	   && symbol_symtab (sym_obj->symbol) != NULL)
     {
       set_objfile_data (symbol_objfile (sym_obj->symbol),
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 9bba067a07f8..cb16b5c202b5 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -502,7 +502,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 {
   struct obj_section *section;
 
-  if (SYMBOL_OBJFILE_OWNED (symbol))
+  if (symbol->is_objfile_owned ())
     section = symbol->obj_section (symbol_objfile (symbol));
   else
     section = NULL;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5e4a461deb92..8bdc6cab9608 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1789,7 +1789,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
   if (!sym)
     return NULL;
 
-  if (!SYMBOL_OBJFILE_OWNED (sym))
+  if (!sym->is_objfile_owned ())
     return sym;
 
   /* We either have an OBJFILE, or we can get at it from the sym's
@@ -6534,7 +6534,7 @@ initialize_ordinary_address_classes (void)
 struct objfile *
 symbol_objfile (const struct symbol *symbol)
 {
-  gdb_assert (SYMBOL_OBJFILE_OWNED (symbol));
+  gdb_assert (symbol->is_objfile_owned ());
   return symbol->owner.symtab->objfile ();
 }
 
@@ -6543,7 +6543,7 @@ symbol_objfile (const struct symbol *symbol)
 struct gdbarch *
 symbol_arch (const struct symbol *symbol)
 {
-  if (!SYMBOL_OBJFILE_OWNED (symbol))
+  if (!symbol->is_objfile_owned ())
     return symbol->owner.arch;
   return symbol->owner.symtab->objfile ()->arch ();
 }
@@ -6553,7 +6553,7 @@ symbol_arch (const struct symbol *symbol)
 struct symtab *
 symbol_symtab (const struct symbol *symbol)
 {
-  gdb_assert (SYMBOL_OBJFILE_OWNED (symbol));
+  gdb_assert (symbol->is_objfile_owned ());
   return symbol->owner.symtab;
 }
 
@@ -6562,7 +6562,7 @@ symbol_symtab (const struct symbol *symbol)
 void
 symbol_set_symtab (struct symbol *symbol, struct symtab *symtab)
 {
-  gdb_assert (SYMBOL_OBJFILE_OWNED (symbol));
+  gdb_assert (symbol->is_objfile_owned ());
   symbol->owner.symtab = symtab;
 }
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 2825697fc192..ef9e653dfad2 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1115,7 +1115,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     /* Class-initialization of bitfields is only allowed in C++20.  */
     : m_domain (UNDEF_DOMAIN),
       m_aclass_index (0),
-      is_objfile_owned (1),
+      m_is_objfile_owned (1),
       is_argument (0),
       is_inlined (0),
       maybe_copied (0),
@@ -1168,6 +1168,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_domain = domain;
   }
 
+  bool is_objfile_owned () const
+  {
+    return m_is_objfile_owned;
+  }
+
+  void set_is_objfile_owned (bool is_objfile_owned)
+  {
+    m_is_objfile_owned = is_objfile_owned;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1199,7 +1209,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
   /* If non-zero then symbol is objfile-owned, use owner.symtab.
        Otherwise symbol is arch-owned, use owner.arch.  */
 
-  unsigned int is_objfile_owned : 1;
+  unsigned int m_is_objfile_owned : 1;
 
   /* Whether this is an argument.  */
 
@@ -1270,7 +1280,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_OBJFILE_OWNED(symbol)	((symbol)->is_objfile_owned)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
 #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
-- 
2.34.1


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

* [PATCH 29/33] gdb: remove SYMBOL_IS_ARGUMENT macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (27 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 30/33] gdb: remove SYMBOL_INLINED macro Simon Marchi via Gdb-patches
                   ` (4 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for whether a symbol is an argument.  Remove
the corresponding macro and adjust all callers.

Change-Id: I71b4f0465f3dfd2ed8b9e140bd3f7d5eb8d9ee81
---
 gdb/ada-lang.c              |  6 +++---
 gdb/block.c                 |  2 +-
 gdb/buildsym.c              |  4 ++--
 gdb/c-exp.y                 |  2 +-
 gdb/coffread.c              |  4 ++--
 gdb/dwarf2/read.c           |  2 +-
 gdb/go-exp.y                |  2 +-
 gdb/guile/scm-symbol.c      |  4 ++--
 gdb/infrun.c                |  2 +-
 gdb/mdebugread.c            |  4 ++--
 gdb/mi/mi-cmd-stack.c       | 10 +++++-----
 gdb/printcmd.c              |  2 +-
 gdb/python/py-framefilter.c |  4 ++--
 gdb/python/py-symbol.c      |  4 ++--
 gdb/stabsread.c             | 10 +++++-----
 gdb/stack.c                 |  8 ++++----
 gdb/symmisc.c               |  2 +-
 gdb/symtab.h                | 15 ++++++++++++---
 gdb/tracepoint.c            |  2 +-
 19 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 77d6c07c6a9e..636ae906250b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5053,7 +5053,7 @@ match_data::operator() (struct block_symbol *bsym)
     {
       if (sym->aclass () == LOC_UNRESOLVED)
 	return true;
-      else if (SYMBOL_IS_ARGUMENT (sym))
+      else if (sym->is_argument ())
 	arg_sym = sym;
       else
 	{
@@ -5744,7 +5744,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
 	{
 	  if (sym->aclass () != LOC_UNRESOLVED)
 	    {
-	      if (SYMBOL_IS_ARGUMENT (sym))
+	      if (sym->is_argument ())
 		arg_sym = sym;
 	      else
 		{
@@ -5798,7 +5798,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
 	      {
 		if (sym->aclass () != LOC_UNRESOLVED)
 		  {
-		    if (SYMBOL_IS_ARGUMENT (sym))
+		    if (sym->is_argument ())
 		      arg_sym = sym;
 		    else
 		      {
diff --git a/gdb/block.c b/gdb/block.c
index 7ec56c745aff..f7532120286b 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -753,7 +753,7 @@ block_lookup_symbol (const struct block *block, const char *name,
 				     sym->domain (), domain))
 	    {
 	      sym_found = sym;
-	      if (!SYMBOL_IS_ARGUMENT (sym))
+	      if (!sym->is_argument ())
 		{
 		  break;
 		}
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 27206f97b2b0..51764a67040c 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -266,7 +266,7 @@ buildsym_compunit::finish_block_internal
 	     we haven't fully initialized the block yet.  */
 	  ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
 	    {
-	      if (SYMBOL_IS_ARGUMENT (sym))
+	      if (sym->is_argument ())
 		nparams++;
 	    }
 	  if (nparams > 0)
@@ -284,7 +284,7 @@ buildsym_compunit::finish_block_internal
 		  if (iparams == nparams)
 		    break;
 
-		  if (SYMBOL_IS_ARGUMENT (sym))
+		  if (sym->is_argument ())
 		    {
 		      ftype->field (iparams).set_type (SYMBOL_TYPE (sym));
 		      TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 73347243f550..6d4cb475bd19 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1102,7 +1102,7 @@ block	:	block COLONCOLON name
 variable:	name_not_typename ENTRY
 			{ struct symbol *sym = $1.sym.symbol;
 
-			  if (sym == NULL || !SYMBOL_IS_ARGUMENT (sym)
+			  if (sym == NULL || !sym->is_argument ()
 			      || !symbol_read_needs_frame (sym))
 			    error (_("@entry can be used only for function "
 				     "parameters, not for \"%s\""),
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 8bf742161e7e..e4db4fdb02f6 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1640,13 +1640,13 @@ process_coff_symbol (struct coff_symbol *cs,
 
 	case C_ARG:
 	  sym->set_aclass_index (LOC_ARG);
-	  SYMBOL_IS_ARGUMENT (sym) = 1;
+	  sym->set_is_argument (1);
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
 
 	case C_REGPARM:
 	  sym->set_aclass_index (coff_register_index);
-	  SYMBOL_IS_ARGUMENT (sym) = 1;
+	  sym->set_is_argument (1);
 	  SYMBOL_VALUE (sym) = cs->c_value;
 	  add_symbol_to_list (sym, get_local_symbols ());
 	  break;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b62252eb4cfe..259401fbbb70 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21934,7 +21934,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    struct context_stack *curr
 	      = cu->get_builder ()->get_current_context_stack ();
 	    if (curr != nullptr && curr->name != nullptr)
-	      SYMBOL_IS_ARGUMENT (sym) = 1;
+	      sym->set_is_argument (1);
 	    attr = dwarf2_attr (die, DW_AT_location, cu);
 	    if (attr != nullptr)
 	      {
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 5436072d66e3..fed7fe531f98 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -545,7 +545,7 @@ variable:	name_not_typename ENTRY
 			{ struct symbol *sym = $1.sym.symbol;
 
 			  if (sym == NULL
-			      || !SYMBOL_IS_ARGUMENT (sym)
+			      || !sym->is_argument ()
 			      || !symbol_read_needs_frame (sym))
 			    error (_("@entry can be used only for function "
 				     "parameters, not for \"%s\""),
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index caad90f46785..32ef3361941a 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -424,7 +424,7 @@ gdbscm_symbol_argument_p (SCM self)
     = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symbol *symbol = s_smob->symbol;
 
-  return scm_from_bool (SYMBOL_IS_ARGUMENT (symbol));
+  return scm_from_bool (symbol->is_argument ());
 }
 
 /* (symbol-constant? <gdb:symbol>) -> boolean */
@@ -469,7 +469,7 @@ gdbscm_symbol_variable_p (SCM self)
 
   theclass = symbol->aclass ();
 
-  return scm_from_bool (!SYMBOL_IS_ARGUMENT (symbol)
+  return scm_from_bool (!symbol->is_argument ()
 			&& (theclass == LOC_LOCAL || theclass == LOC_REGISTER
 			    || theclass == LOC_STATIC || theclass == LOC_COMPUTED
 			    || theclass == LOC_OPTIMIZED_OUT));
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2e7ed15723fd..f9420d549907 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -7935,7 +7935,7 @@ check_exception_resume (struct execution_control_state *ecs,
       b = SYMBOL_BLOCK_VALUE (func);
       ALL_BLOCK_SYMBOLS (b, iter, sym)
 	{
-	  if (!SYMBOL_IS_ARGUMENT (sym))
+	  if (!sym->is_argument ())
 	    continue;
 
 	  if (argno == 0)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 0a2a4c327d16..a295878b625a 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -676,7 +676,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       s = new_symbol (name);
 
       s->set_domain (VAR_DOMAIN);
-      SYMBOL_IS_ARGUMENT (s) = 1;
+      s->set_is_argument (1);
       switch (sh->sc)
 	{
 	case scRegister:
@@ -1202,7 +1202,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		      if (iparams == nparams)
 			break;
 
-		      if (SYMBOL_IS_ARGUMENT (sym))
+		      if (sym->is_argument ())
 			{
 			  ftype->field (iparams).set_type (SYMBOL_TYPE (sym));
 			  TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 0c2172f0c639..ed22f3435e0f 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -520,7 +520,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
     stb.puts ("@entry");
   uiout->field_stream ("name", stb);
 
-  if (what == all && SYMBOL_IS_ARGUMENT (arg->sym))
+  if (what == all && arg->sym->is_argument ())
     uiout->field_signed ("arg", 1);
 
   if (values == PRINT_SIMPLE_VALUES)
@@ -623,9 +623,9 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	      if (what == all)
 		print_me = 1;
 	      else if (what == locals)
-		print_me = !SYMBOL_IS_ARGUMENT (sym);
+		print_me = !sym->is_argument ();
 	      else
-		print_me = SYMBOL_IS_ARGUMENT (sym);
+		print_me = sym->is_argument ();
 	      break;
 	    }
 	  if (print_me)
@@ -633,7 +633,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	      struct symbol *sym2;
 	      struct frame_arg arg, entryarg;
 
-	      if (SYMBOL_IS_ARGUMENT (sym))
+	      if (sym->is_argument ())
 		sym2 = lookup_symbol_search_name (sym->search_name (),
 						  block, VAR_DOMAIN).symbol;
 	      else
@@ -654,7 +654,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
 		      && type->code () != TYPE_CODE_UNION)
 		    {
 		case PRINT_ALL_VALUES:
-		  if (SYMBOL_IS_ARGUMENT (sym))
+		  if (sym->is_argument ())
 		    read_frame_arg (fp_opts, sym2, fi, &arg, &entryarg);
 		  else
 		    read_frame_local (sym2, fi, &arg);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 787d8d771284..6f9be820b0cf 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1735,7 +1735,7 @@ info_address_command (const char *exp, int from_tty)
 	 in that objfile.  */
       regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
 
-      if (SYMBOL_IS_ARGUMENT (sym))
+      if (sym->is_argument ())
 	printf_filtered (_("an argument in register %s"),
 			 gdbarch_register_name (gdbarch, regno));
       else
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 70fec4aad5da..e6eb1ec8cdf1 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -191,9 +191,9 @@ mi_should_print (struct symbol *sym, enum mi_print_types type)
     case LOC_REGISTER:	/* register              */
     case LOC_COMPUTED:	/* computed location     */
       if (type == MI_PRINT_LOCALS)
-	print_me = ! SYMBOL_IS_ARGUMENT (sym);
+	print_me = ! sym->is_argument ();
       else
-	print_me = SYMBOL_IS_ARGUMENT (sym);
+	print_me = sym->is_argument ();
     }
   return print_me;
 }
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 708474331d72..c756870adb6c 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -141,7 +141,7 @@ sympy_is_argument (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  return PyBool_FromLong (SYMBOL_IS_ARGUMENT (symbol));
+  return PyBool_FromLong (symbol->is_argument ());
 }
 
 static PyObject *
@@ -180,7 +180,7 @@ sympy_is_variable (PyObject *self, void *closure)
 
   theclass = symbol->aclass ();
 
-  return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (symbol)
+  return PyBool_FromLong (!symbol->is_argument ()
 			  && (theclass == LOC_LOCAL || theclass == LOC_REGISTER
 			      || theclass == LOC_STATIC || theclass == LOC_COMPUTED
 			      || theclass == LOC_OPTIMIZED_OUT));
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 38e94818fc54..33fcc9263f7e 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1067,7 +1067,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       sym->set_aclass_index (LOC_ARG);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
-      SYMBOL_IS_ARGUMENT (sym) = 1;
+      sym->set_is_argument (1);
       add_symbol_to_list (sym, get_local_symbols ());
 
       if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG)
@@ -1114,7 +1114,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* Parameter which is in a register.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (stab_register_index);
-      SYMBOL_IS_ARGUMENT (sym) = 1;
+      sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1352,7 +1352,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* Reference parameter */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (LOC_REF_ARG);
-      SYMBOL_IS_ARGUMENT (sym) = 1;
+      sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1362,7 +1362,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* Reference parameter which is in a register.  */
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
       sym->set_aclass_index (stab_regparm_index);
-      SYMBOL_IS_ARGUMENT (sym) = 1;
+      sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_local_symbols ());
@@ -1394,7 +1394,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
      register or on the stack) instead of the structure itself.  */
 
   if (gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym))
-      && SYMBOL_IS_ARGUMENT (sym))
+      && sym->is_argument ())
     {
       /* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
 	 variables passed in a register).  */
diff --git a/gdb/stack.c b/gdb/stack.c
index fcdcd35f8b39..834e016ef937 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -763,7 +763,7 @@ print_frame_args (const frame_print_options &fp_opts,
 	  /* Keep track of the highest stack argument offset seen, and
 	     skip over any kinds of symbols we don't care about.  */
 
-	  if (!SYMBOL_IS_ARGUMENT (sym))
+	  if (!sym->is_argument ())
 	    continue;
 
 	  if (!print_names)
@@ -829,7 +829,7 @@ print_frame_args (const frame_print_options &fp_opts,
 						b, VAR_DOMAIN).symbol;
 	      gdb_assert (nsym != NULL);
 	      if (nsym->aclass () == LOC_REGISTER
-		  && !SYMBOL_IS_ARGUMENT (nsym))
+		  && !nsym->is_argument ())
 		{
 		  /* There is a LOC_ARG/LOC_REGISTER pair.  This means
 		     that it was passed on the stack and loaded into a
@@ -2256,7 +2256,7 @@ iterate_over_block_locals (const struct block *b,
 	case LOC_STATIC:
 	case LOC_COMPUTED:
 	case LOC_OPTIMIZED_OUT:
-	  if (SYMBOL_IS_ARGUMENT (sym))
+	  if (sym->is_argument ())
 	    break;
 	  if (sym->domain () == COMMON_BLOCK_DOMAIN)
 	    break;
@@ -2503,7 +2503,7 @@ iterate_over_block_arg_vars (const struct block *b,
   ALL_BLOCK_SYMBOLS (b, iter, sym)
     {
       /* Don't worry about things which aren't arguments.  */
-      if (SYMBOL_IS_ARGUMENT (sym))
+      if (sym->is_argument ())
 	{
 	  /* We have to look up the symbol because arguments can have
 	     two entries (one a parameter, one a local) and the one we
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index cb16b5c202b5..328230afe3ad 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -589,7 +589,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 	  break;
 
 	case LOC_REGISTER:
-	  if (SYMBOL_IS_ARGUMENT (symbol))
+	  if (symbol->is_argument ())
 	    fprintf_filtered (outfile, "parameter register %s",
 			      plongest (SYMBOL_VALUE (symbol)));
 	  else
diff --git a/gdb/symtab.h b/gdb/symtab.h
index ef9e653dfad2..f565f1258248 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1116,7 +1116,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     : m_domain (UNDEF_DOMAIN),
       m_aclass_index (0),
       m_is_objfile_owned (1),
-      is_argument (0),
+      m_is_argument (0),
       is_inlined (0),
       maybe_copied (0),
       subclass (SYMBOL_NONE),
@@ -1178,6 +1178,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_is_objfile_owned = is_objfile_owned;
   }
 
+  bool is_argument () const
+  {
+    return m_is_argument;
+  }
+
+  void set_is_argument (bool is_argument)
+  {
+    m_is_argument = is_argument;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1213,7 +1223,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
 
   /* Whether this is an argument.  */
 
-  unsigned is_argument : 1;
+  unsigned m_is_argument : 1;
 
   /* Whether this is an inlined function (class LOC_BLOCK only).  */
   unsigned is_inlined : 1;
@@ -1280,7 +1290,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
 #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
   (((symbol)->subclass) == SYMBOL_TEMPLATE)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 7063b08fc6f9..7aaf912a495f 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2586,7 +2586,7 @@ info_scope_command (const char *args_in, int from_tty)
 		  regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym,
 								      gdbarch);
 
-		  if (SYMBOL_IS_ARGUMENT (sym))
+		  if (sym->is_argument ())
 		    printf_filtered ("an argument in register $%s",
 				     gdbarch_register_name (gdbarch, regno));
 		  else
-- 
2.34.1


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

* [PATCH 30/33] gdb: remove SYMBOL_INLINED macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (28 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 29/33] gdb: remove SYMBOL_IS_ARGUMENT macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 31/33] gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro Simon Marchi via Gdb-patches
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for whether a symbol is inlined.  Remove the
corresponding macro and adjust all callers.

Change-Id: I934468da3b5a32dd6b161a6f252a6b1b94737279
---
 gdb/block.c       |  2 +-
 gdb/dwarf2/read.c |  2 +-
 gdb/linespec.c    |  2 +-
 gdb/symtab.h      | 15 ++++++++++++---
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index f7532120286b..3d11ea607682 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -124,7 +124,7 @@ block_containing_function (const struct block *bl)
 int
 block_inlined_p (const struct block *bl)
 {
-  return BLOCK_FUNCTION (bl) != NULL && SYMBOL_INLINED (BLOCK_FUNCTION (bl));
+  return BLOCK_FUNCTION (bl) != NULL && BLOCK_FUNCTION (bl)->is_inlined ();
 }
 
 /* A helper function that checks whether PC is in the blockvector BL.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 259401fbbb70..95d4d6fc5532 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21794,7 +21794,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
 	  sym->set_aclass_index (LOC_BLOCK);
-	  SYMBOL_INLINED (sym) = 1;
+	  sym->set_is_inlined (1);
 	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_template_value_param:
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 7c904473657f..4a83b78d4fd6 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1200,7 +1200,7 @@ iterate_over_all_matching_symtabs
 			 {
 			   /* Restrict calls to CALLBACK to symbols
 			      representing inline symbols only.  */
-			   if (SYMBOL_INLINED (bsym->symbol))
+			   if (bsym->symbol->is_inlined ())
 			     return callback (bsym);
 			   return true;
 			 });
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f565f1258248..9b7d7e35c972 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1117,7 +1117,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       m_aclass_index (0),
       m_is_objfile_owned (1),
       m_is_argument (0),
-      is_inlined (0),
+      m_is_inlined (0),
       maybe_copied (0),
       subclass (SYMBOL_NONE),
       artificial (false)
@@ -1188,6 +1188,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_is_argument = is_argument;
   }
 
+  bool is_inlined () const
+  {
+    return m_is_inlined;
+  }
+
+  void set_is_inlined (bool is_inlined)
+  {
+    m_is_inlined = is_inlined;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1226,7 +1236,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
   unsigned m_is_argument : 1;
 
   /* Whether this is an inlined function (class LOC_BLOCK only).  */
-  unsigned is_inlined : 1;
+  unsigned m_is_inlined : 1;
 
   /* For LOC_STATIC only, if this is set, then the symbol might be
      subject to copy relocation.  In this case, a minimal symbol
@@ -1290,7 +1300,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
 #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
   (((symbol)->subclass) == SYMBOL_TEMPLATE)
 #define SYMBOL_TYPE(symbol)		(symbol)->type
-- 
2.34.1


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

* [PATCH 31/33] gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (29 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 30/33] gdb: remove SYMBOL_INLINED macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 32/33] gdb: remove SYMBOL_TYPE macro Simon Marchi via Gdb-patches
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter for a whether a symbol is a C++ template function.  Remove
the corresponding macro and adjust all callers.

Change-Id: I89abc2802a952b77b0e0eb73a25c2306cb8e8bcc
---
 gdb/cp-namespace.c | 2 +-
 gdb/symtab.h       | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 6130381fdd66..8fb2f71b46cc 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -519,7 +519,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
   if (function != NULL && function->language () == language_cplus)
     {
       /* Search the function's template parameters.  */
-      if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function))
+      if (function->is_cplus_template_function ())
 	{
 	  struct template_symbol *templ
 	    = (struct template_symbol *) function;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 9b7d7e35c972..a86145198fdc 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1198,6 +1198,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_is_inlined = is_inlined;
   }
 
+  bool is_cplus_template_function () const
+  {
+    return this->subclass == SYMBOL_TEMPLATE;
+  }
+
   /* Data type of value */
 
   struct type *type = nullptr;
@@ -1300,8 +1305,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
-  (((symbol)->subclass) == SYMBOL_TEMPLATE)
 #define SYMBOL_TYPE(symbol)		(symbol)->type
 #define SYMBOL_LINE(symbol)		(symbol)->line
 #define SYMBOL_COMPUTED_OPS(symbol)	((symbol)->impl ().ops_computed)
@@ -1342,7 +1345,7 @@ extern void symbol_set_symtab (struct symbol *symbol, struct symtab *symtab);
 
 /* An instance of this type is used to represent a C++ template
    function.  A symbol is really of this type iff
-   SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION is true.  */
+   symbol::is_cplus_template_function is true.  */
 
 struct template_symbol : public symbol
 {
-- 
2.34.1


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

* [PATCH 32/33] gdb: remove SYMBOL_TYPE macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (30 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 31/33] gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-01-28 12:45 ` [PATCH 33/33] gdb: remove SYMBOL_LINE macro Simon Marchi via Gdb-patches
  2022-02-06 15:22 ` [PATCH 00/33] Remove some more accessor macros Joel Brobecker via Gdb-patches
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symbol's type.  Remove the corresponding
macro and adjust all callers.

Change-Id: Ie1a137744c5bfe1df4d4f9ae5541c5299577c8de
---
 gdb/ada-exp.y                       |  10 +-
 gdb/ada-lang.c                      |  52 +++++-----
 gdb/ada-tasks.c                     |  24 ++---
 gdb/ax-gdb.c                        |   2 +-
 gdb/block.c                         |   4 +-
 gdb/blockframe.c                    |   2 +-
 gdb/buildsym.c                      |   4 +-
 gdb/c-exp.y                         |   8 +-
 gdb/c-typeprint.c                   |   8 +-
 gdb/c-valprint.c                    |   2 +-
 gdb/coffread.c                      |  34 +++----
 gdb/compile/compile-c-symbols.c     |  12 +--
 gdb/compile/compile-cplus-symbols.c |  14 +--
 gdb/compile/compile-cplus-types.c   |  10 +-
 gdb/compile/compile-object-load.c   |   8 +-
 gdb/compile/compile-object-run.c    |   2 +-
 gdb/cp-namespace.c                  |   4 +-
 gdb/cp-support.c                    |   8 +-
 gdb/ctfread.c                       |  12 +--
 gdb/d-exp.y                         |   6 +-
 gdb/d-namespace.c                   |   4 +-
 gdb/dwarf2/loc.c                    |  18 ++--
 gdb/dwarf2/read.c                   |  18 ++--
 gdb/eval.c                          |  18 ++--
 gdb/f-exp.y                         |   2 +-
 gdb/fbsd-tdep.c                     |   4 +-
 gdb/findvar.c                       |   2 +-
 gdb/gdbtypes.c                      |  24 ++---
 gdb/gnu-v3-abi.c                    |   2 +-
 gdb/go-exp.y                        |   2 +-
 gdb/guile/scm-symbol.c              |   4 +-
 gdb/infcmd.c                        |   4 +-
 gdb/jit.c                           |   2 +-
 gdb/language.c                      |   4 +-
 gdb/linespec.c                      |   4 +-
 gdb/m2-typeprint.c                  |   4 +-
 gdb/mdebugread.c                    |  46 ++++-----
 gdb/mi/mi-cmd-stack.c               |   6 +-
 gdb/mi/mi-symbol-cmds.c             |   2 +-
 gdb/objc-lang.c                     |   4 +-
 gdb/p-exp.y                         |   6 +-
 gdb/p-valprint.c                    |   2 +-
 gdb/python/py-finishbreakpoint.c    |   2 +-
 gdb/python/py-symbol.c              |   4 +-
 gdb/python/py-type.c                |   2 +-
 gdb/rust-lang.c                     |   2 +-
 gdb/rust-parse.c                    |   4 +-
 gdb/sparc-tdep.c                    |   2 +-
 gdb/stabsread.c                     | 152 ++++++++++++++--------------
 gdb/stack.c                         |   8 +-
 gdb/symmisc.c                       |  18 ++--
 gdb/symtab.c                        |  30 +++---
 gdb/symtab.h                        |  13 ++-
 gdb/tracepoint.c                    |  14 +--
 gdb/typeprint.c                     |   2 +-
 gdb/valops.c                        |  10 +-
 gdb/xcoffread.c                     |   4 +-
 57 files changed, 342 insertions(+), 333 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 0cb4aac10e33..916b8ef94fef 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1332,10 +1332,10 @@ select_possible_type_sym (const std::vector<struct block_symbol> &syms)
     switch (syms[i].symbol->aclass ())
       {
       case LOC_TYPEDEF:
-	if (ada_prefer_type (SYMBOL_TYPE (syms[i].symbol), preferred_type))
+	if (ada_prefer_type (syms[i].symbol->type (), preferred_type))
 	  {
 	    preferred_index = i;
-	    preferred_type = SYMBOL_TYPE (syms[i].symbol);
+	    preferred_type = syms[i].symbol->type ();
 	  }
 	break;
       case LOC_REGISTER:
@@ -1374,7 +1374,7 @@ find_primitive_type (struct parser_state *par_state, const char *name)
       strcat (expanded_name, name);
       sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol;
       if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
-	type = SYMBOL_TYPE (sym);
+	type = sym->type ();
     }
 
   return type;
@@ -1474,7 +1474,7 @@ get_symbol_field_type (struct symbol *sym, const char *encoded_field_name)
 {
   const char *field_name = encoded_field_name;
   const char *subfield_name;
-  struct type *type = SYMBOL_TYPE (sym);
+  struct type *type = sym->type ();
   int fieldno;
 
   if (type == NULL || field_name == NULL)
@@ -1595,7 +1595,7 @@ write_var_or_type (struct parser_state *par_state,
 	      struct type *field_type;
 	      
 	      if (tail_index == name_len)
-		return SYMBOL_TYPE (type_sym);
+		return type_sym->type ();
 
 	      /* We have some extraneous characters after the type name.
 		 If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN",
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 636ae906250b..fbeb176d5668 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3163,7 +3163,7 @@ static void
 ada_print_symbol_signature (struct ui_file *stream, struct symbol *sym,
 			    const struct type_print_options *flags)
 {
-  struct type *type = SYMBOL_TYPE (sym);
+  struct type *type = sym->type ();
 
   fprintf_filtered (stream, "%s", sym->print_name ());
   if (!print_signatures
@@ -3348,8 +3348,8 @@ See set/show multiple-symbol."));
 	{
 	  int is_enumeral =
 	    (syms[i].symbol->aclass () == LOC_CONST
-	     && SYMBOL_TYPE (syms[i].symbol) != NULL
-	     && SYMBOL_TYPE (syms[i].symbol)->code () == TYPE_CODE_ENUM);
+	     && syms[i].symbol->type () != NULL
+	     && syms[i].symbol->type ()->code () == TYPE_CODE_ENUM);
 	  struct symtab *symtab = NULL;
 
 	  if (syms[i].symbol->is_objfile_owned ())
@@ -3365,10 +3365,10 @@ See set/show multiple-symbol."));
 			       SYMBOL_LINE (syms[i].symbol));
 	    }
 	  else if (is_enumeral
-		   && SYMBOL_TYPE (syms[i].symbol)->name () != NULL)
+		   && syms[i].symbol->type ()->name () != NULL)
 	    {
 	      printf_filtered (("[%d] "), i + first_choice);
-	      ada_print_type (SYMBOL_TYPE (syms[i].symbol), NULL,
+	      ada_print_type (syms[i].symbol->type (), NULL,
 			      gdb_stdout, -1, 0, &type_print_raw_options);
 	      printf_filtered (_("'(%s) (enumeral)\n"),
 			       syms[i].symbol->print_name ());
@@ -3467,7 +3467,7 @@ ada_resolve_enum (std::vector<struct block_symbol> &syms,
     {
       /* We already know the name matches, so we're just looking for
 	 an element of the correct enum type.  */
-      if (ada_check_typedef (SYMBOL_TYPE (syms[i].symbol)) == context_type)
+      if (ada_check_typedef (syms[i].symbol->type ()) == context_type)
 	return i;
     }
 
@@ -3626,7 +3626,7 @@ static int
 ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
 {
   int i;
-  struct type *func_type = SYMBOL_TYPE (func);
+  struct type *func_type = func->type ();
 
   if (func->aclass () == LOC_CONST
       && func_type->code () == TYPE_CODE_ENUM)
@@ -3714,7 +3714,7 @@ ada_resolve_function (std::vector<struct block_symbol> &syms,
     {
       for (k = 0; k < syms.size (); k += 1)
 	{
-	  struct type *type = ada_check_typedef (SYMBOL_TYPE (syms[k].symbol));
+	  struct type *type = ada_check_typedef (syms[k].symbol->type ());
 
 	  if (ada_args_match (syms[k].symbol, args, nargs)
 	      && (fallback || return_match (type, context_type)))
@@ -4441,8 +4441,8 @@ static int
 is_nonfunction (const std::vector<struct block_symbol> &syms)
 {
   for (const block_symbol &sym : syms)
-    if (SYMBOL_TYPE (sym.symbol)->code () != TYPE_CODE_FUNC
-	&& (SYMBOL_TYPE (sym.symbol)->code () != TYPE_CODE_ENUM
+    if (sym.symbol->type ()->code () != TYPE_CODE_FUNC
+	&& (sym.symbol->type ()->code () != TYPE_CODE_ENUM
 	    || sym.symbol->aclass () != LOC_CONST))
       return 1;
 
@@ -4487,8 +4487,8 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
       return 1;
     case LOC_TYPEDEF:
       {
-	struct type *type0 = SYMBOL_TYPE (sym0);
-	struct type *type1 = SYMBOL_TYPE (sym1);
+	struct type *type0 = sym0->type ();
+	struct type *type1 = sym1->type ();
 	const char *name0 = sym0->linkage_name ();
 	const char *name1 = sym1->linkage_name ();
 	int len0 = strlen (name0);
@@ -4501,7 +4501,7 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
       }
     case LOC_CONST:
       return SYMBOL_VALUE (sym0) == SYMBOL_VALUE (sym1)
-	&& equiv_types (SYMBOL_TYPE (sym0), SYMBOL_TYPE (sym1));
+	&& equiv_types (sym0->type (), sym1->type ());
 
     case LOC_STATIC:
       {
@@ -4675,7 +4675,7 @@ symbols_are_identical_enums (const std::vector<struct block_symbol> &syms)
 
   /* Quick check: All symbols should have an enum type.  */
   for (i = 0; i < syms.size (); i++)
-    if (SYMBOL_TYPE (syms[i].symbol)->code () != TYPE_CODE_ENUM)
+    if (syms[i].symbol->type ()->code () != TYPE_CODE_ENUM)
       return 0;
 
   /* Quick check: They should all have the same value.  */
@@ -4685,16 +4685,16 @@ symbols_are_identical_enums (const std::vector<struct block_symbol> &syms)
 
   /* Quick check: They should all have the same number of enumerals.  */
   for (i = 1; i < syms.size (); i++)
-    if (SYMBOL_TYPE (syms[i].symbol)->num_fields ()
-	!= SYMBOL_TYPE (syms[0].symbol)->num_fields ())
+    if (syms[i].symbol->type ()->num_fields ()
+	!= syms[0].symbol->type ()->num_fields ())
       return 0;
 
   /* All the sanity checks passed, so we might have a set of
      identical enumeration types.  Perform a more complete
      comparison of the type of each symbol.  */
   for (i = 1; i < syms.size (); i++)
-    if (!ada_identical_enum_types_p (SYMBOL_TYPE (syms[i].symbol),
-				     SYMBOL_TYPE (syms[0].symbol)))
+    if (!ada_identical_enum_types_p (syms[i].symbol->type (),
+				     syms[0].symbol->type ()))
       return 0;
 
   return 1;
@@ -4725,13 +4725,13 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
       /* If two symbols have the same name and one of them is a stub type,
 	 the get rid of the stub.  */
 
-      if (SYMBOL_TYPE ((*syms)[i].symbol)->is_stub ()
+      if ((*syms)[i].symbol->type ()->is_stub ()
 	  && (*syms)[i].symbol->linkage_name () != NULL)
 	{
 	  for (j = 0; j < syms->size (); j++)
 	    {
 	      if (j != i
-		  && !SYMBOL_TYPE ((*syms)[j].symbol)->is_stub ()
+		  && !(*syms)[j].symbol->type ()->is_stub ()
 		  && (*syms)[j].symbol->linkage_name () != NULL
 		  && strcmp ((*syms)[i].symbol->linkage_name (),
 			     (*syms)[j].symbol->linkage_name ()) == 0)
@@ -4744,7 +4744,7 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
 
       else if ((*syms)[i].symbol->linkage_name () != NULL
 	  && (*syms)[i].symbol->aclass () == LOC_STATIC
-	  && is_nondebugging_type (SYMBOL_TYPE ((*syms)[i].symbol)))
+	  && is_nondebugging_type ((*syms)[i].symbol->type ()))
 	{
 	  for (j = 0; j < syms->size (); j += 1)
 	    {
@@ -4848,7 +4848,7 @@ old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
   if (sym->aclass () != LOC_TYPEDEF)
     return 0;
 
-  std::string scope = xget_renaming_scope (SYMBOL_TYPE (sym));
+  std::string scope = xget_renaming_scope (sym->type ());
 
   /* If the rename has been defined in a package, then it is visible.  */
   if (is_package_name (scope.c_str ()))
@@ -7231,7 +7231,7 @@ ada_find_any_type (const char *name)
   struct symbol *sym = ada_find_any_type_symbol (name);
 
   if (sym != NULL)
-    return SYMBOL_TYPE (sym);
+    return sym->type ();
 
   return NULL;
 }
@@ -10420,7 +10420,7 @@ ada_var_value_operation::evaluate (struct type *expect_type,
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
-      struct type *type = static_unwrap_type (SYMBOL_TYPE (sym));
+      struct type *type = static_unwrap_type (sym->type ());
       /* Check to see if this is a tagged type.  We also need to handle
 	 the case where the type is a reference to a tagged type, but
 	 we have to be careful to exclude pointers to tagged types.
@@ -10511,7 +10511,7 @@ ada_var_value_operation::resolve (struct expression *exp,
     }
 
   if (deprocedure_p
-      && (SYMBOL_TYPE (std::get<0> (m_storage).symbol)->code ()
+      && (std::get<0> (m_storage).symbol->type ()->code ()
 	  == TYPE_CODE_FUNC))
     return true;
 
@@ -12418,7 +12418,7 @@ catch_assert_command (const char *arg_entry, int from_tty,
 static int
 ada_is_exception_sym (struct symbol *sym)
 {
-  const char *type_name = SYMBOL_TYPE (sym)->name ();
+  const char *type_name = sym->type ()->name ();
 
   return (sym->aclass () != LOC_TYPEDEF
 	  && sym->aclass () != LOC_BLOCK
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 5b602c4d36fb..6a41d5f4b2b5 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -503,7 +503,7 @@ ada_get_tcb_types_info (void)
     lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN,
 			       language_c, NULL).symbol;
 
-  if (atcb_sym == NULL || atcb_sym->type == NULL)
+  if (atcb_sym == NULL || atcb_sym->type () == NULL)
     {
       /* In Ravenscar run-time libs, the  ATCB does not have a dynamic
 	 size, so the symbol name differs.  */
@@ -511,34 +511,34 @@ ada_get_tcb_types_info (void)
 					    STRUCT_DOMAIN, language_c,
 					    NULL).symbol;
 
-      if (atcb_sym == NULL || atcb_sym->type == NULL)
+      if (atcb_sym == NULL || atcb_sym->type () == NULL)
 	return _("Cannot find Ada_Task_Control_Block type");
 
-      type = atcb_sym->type;
+      type = atcb_sym->type ();
     }
   else
     {
       /* Get a static representation of the type record
 	 Ada_Task_Control_Block.  */
-      type = atcb_sym->type;
+      type = atcb_sym->type ();
       type = ada_template_to_fixed_record_type_1 (type, NULL, 0, NULL, 0);
     }
 
-  if (common_atcb_sym == NULL || common_atcb_sym->type == NULL)
+  if (common_atcb_sym == NULL || common_atcb_sym->type () == NULL)
     return _("Cannot find Common_ATCB type");
-  if (private_data_sym == NULL || private_data_sym->type == NULL)
+  if (private_data_sym == NULL || private_data_sym->type ()== NULL)
     return _("Cannot find Private_Data type");
-  if (entry_call_record_sym == NULL || entry_call_record_sym->type == NULL)
+  if (entry_call_record_sym == NULL || entry_call_record_sym->type () == NULL)
     return _("Cannot find Entry_Call_Record type");
 
   /* Get the type for Ada_Task_Control_Block.Common.  */
-  common_type = common_atcb_sym->type;
+  common_type = common_atcb_sym->type ();
 
   /* Get the type for Ada_Task_Control_Bloc.Common.Call.LL.  */
-  ll_type = private_data_sym->type;
+  ll_type = private_data_sym->type ();
 
   /* Get the type for Common_ATCB.Call.all.  */
-  call_type = entry_call_record_sym->type;
+  call_type = entry_call_record_sym->type ();
 
   /* Get the field indices.  */
   fieldnos.common = ada_get_field_index (type, "common", 0);
@@ -904,7 +904,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
       if (sym != NULL)
 	{
 	  /* Validate.  */
-	  struct type *type = check_typedef (SYMBOL_TYPE (sym));
+	  struct type *type = check_typedef (sym->type ());
 	  struct type *eltype = NULL;
 	  struct type *idxtype = NULL;
 
@@ -950,7 +950,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
       if (sym != NULL && SYMBOL_VALUE_ADDRESS (sym) != 0)
 	{
 	  /* Validate.  */
-	  struct type *type = check_typedef (SYMBOL_TYPE (sym));
+	  struct type *type = check_typedef (sym->type ());
 
 	  if (type->code () == TYPE_CODE_PTR)
 	    {
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 7ba44c4c8c09..0b12dc3a42f1 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -510,7 +510,7 @@ static void
 gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
 {
   /* Dereference any typedefs.  */
-  value->type = check_typedef (SYMBOL_TYPE (var));
+  value->type = check_typedef (var->type ());
   value->optimized_out = 0;
 
   if (SYMBOL_COMPUTED_OPS (var) != NULL)
diff --git a/gdb/block.c b/gdb/block.c
index 3d11ea607682..3fe096db5838 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -857,7 +857,7 @@ block_find_symbol (const struct block *block, const char *name,
 int
 block_find_non_opaque_type (struct symbol *sym, void *data)
 {
-  return !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym));
+  return !TYPE_IS_OPAQUE (sym->type ());
 }
 
 /* See block.h.  */
@@ -867,7 +867,7 @@ block_find_non_opaque_type_preferred (struct symbol *sym, void *data)
 {
   struct symbol **best = (struct symbol **) data;
 
-  if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+  if (!TYPE_IS_OPAQUE (sym->type ()))
     return 1;
   *best = sym;
   return 0;
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 88595d4fcb0b..50c464f44a24 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -426,7 +426,7 @@ find_function_type (CORE_ADDR pc)
   struct symbol *sym = find_pc_function (pc);
 
   if (sym != NULL && BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)) == pc)
-    return SYMBOL_TYPE (sym);
+    return sym->type ();
 
   return NULL;
 }
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 51764a67040c..999f632f4013 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -249,7 +249,7 @@ buildsym_compunit::finish_block_internal
 
   if (symbol)
     {
-      struct type *ftype = SYMBOL_TYPE (symbol);
+      struct type *ftype = symbol->type ();
       struct mdict_iterator miter;
       SYMBOL_BLOCK_VALUE (symbol) = block;
       BLOCK_FUNCTION (block) = symbol;
@@ -286,7 +286,7 @@ buildsym_compunit::finish_block_internal
 
 		  if (sym->is_argument ())
 		    {
-		      ftype->field (iparams).set_type (SYMBOL_TYPE (sym));
+		      ftype->field (iparams).set_type (sym->type ());
 		      TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
 		      iparams++;
 		    }
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 6d4cb475bd19..de29d2f70e23 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -3090,7 +3090,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 				&inner_is_a_field_of_this);
 	  if (bsym.symbol != NULL)
 	    {
-	      yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
+	      yylval.tsym.type = bsym.symbol->type ();
 	      return TYPENAME;
 	    }
 	}
@@ -3118,7 +3118,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 
   if (bsym.symbol && bsym.symbol->aclass () == LOC_TYPEDEF)
     {
-      yylval.tsym.type = SYMBOL_TYPE (bsym.symbol);
+      yylval.tsym.type = bsym.symbol->type ();
       return TYPENAME;
     }
 
@@ -3135,7 +3135,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 	  sym = lookup_struct_typedef (copy.c_str (),
 				       par_state->expression_context_block, 1);
 	  if (sym)
-	    yylval.theclass.type = SYMBOL_TYPE (sym);
+	    yylval.theclass.type = sym->type ();
 	  return CLASSNAME;
 	}
     }
@@ -3231,7 +3231,7 @@ classify_inner_name (struct parser_state *par_state,
       return ERROR;
 
     case LOC_TYPEDEF:
-      yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol);
+      yylval.tsym.type = yylval.ssym.sym.symbol->type ();
       return TYPENAME;
 
     default:
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 14d671e29897..405ede8b9c88 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -207,10 +207,10 @@ c_print_typedef (struct type *type,
   type = check_typedef (type);
   fprintf_filtered (stream, "typedef ");
   type_print (type, "", stream, -1);
-  if ((SYMBOL_TYPE (new_symbol))->name () == 0
-      || strcmp ((SYMBOL_TYPE (new_symbol))->name (),
+  if ((new_symbol->type ())->name () == 0
+      || strcmp ((new_symbol->type ())->name (),
 		 new_symbol->linkage_name ()) != 0
-      || SYMBOL_TYPE (new_symbol)->code () == TYPE_CODE_TYPEDEF)
+      || new_symbol->type ()->code () == TYPE_CODE_TYPEDEF)
     fprintf_filtered (stream, " %s", new_symbol->print_name ());
   fprintf_filtered (stream, ";");
 }
@@ -899,7 +899,7 @@ c_type_print_template_args (const struct type_print_options *flags,
 	  fprintf_filtered (stream, "%s = ", sym->linkage_name ());
 	}
 
-      c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags);
+      c_print_type (sym->type (), "", stream, -1, 0, flags);
     }
 
   if (!first)
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 461763075e87..fadbc5b7022c 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -210,7 +210,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 
 	  if (wsym)
 	    {
-	      wtype = SYMBOL_TYPE (wsym);
+	      wtype = wsym->type ();
 	    }
 	  else
 	    {
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e4db4fdb02f6..3ff62bc96c02 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1492,8 +1492,8 @@ patch_opaque_types (struct symtab *s)
 	 from different files with the same name.  */
       if (real_sym->aclass () == LOC_TYPEDEF
 	  && real_sym->domain () == VAR_DOMAIN
-	  && SYMBOL_TYPE (real_sym)->code () == TYPE_CODE_PTR
-	  && TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
+	  && real_sym->type ()->code () == TYPE_CODE_PTR
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (real_sym->type ())) != 0)
 	{
 	  const char *name = real_sym->linkage_name ();
 	  int hash = hashname (name);
@@ -1514,7 +1514,7 @@ patch_opaque_types (struct symtab *s)
 		      opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
 		    }
 
-		  patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym));
+		  patch_type (sym->type (), real_sym->type ());
 
 		  if (prev)
 		    {
@@ -1571,9 +1571,9 @@ process_coff_symbol (struct coff_symbol *cs,
   if (ISFCN (cs->c_type))
     {
       SYMBOL_VALUE (sym) += objfile->text_section_offset ();
-      SYMBOL_TYPE (sym) =
-	lookup_function_type (decode_function_type (cs, cs->c_type,
-						    aux, objfile));
+      sym->set_type
+	(lookup_function_type (decode_function_type (cs, cs->c_type,
+						     aux, objfile)));
 
       sym->set_aclass_index (LOC_BLOCK);
       if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
@@ -1585,7 +1585,7 @@ process_coff_symbol (struct coff_symbol *cs,
     }
   else
     {
-      SYMBOL_TYPE (sym) = decode_type (cs, cs->c_type, aux, objfile);
+      sym->set_type (decode_type (cs, cs->c_type, aux, objfile));
       switch (cs->c_sclass)
 	{
 	case C_NULL:
@@ -1656,10 +1656,10 @@ process_coff_symbol (struct coff_symbol *cs,
 	  sym->set_domain (VAR_DOMAIN);
 
 	  /* If type has no name, give it one.  */
-	  if (SYMBOL_TYPE (sym)->name () == 0)
+	  if (sym->type ()->name () == 0)
 	    {
-	      if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_PTR
-		  || SYMBOL_TYPE (sym)->code () == TYPE_CODE_FUNC)
+	      if (sym->type ()->code () == TYPE_CODE_PTR
+		  || sym->type ()->code () == TYPE_CODE_FUNC)
 		{
 		  /* If we are giving a name to a type such as
 		     "pointer to foo" or "function returning foo", we
@@ -1682,7 +1682,7 @@ process_coff_symbol (struct coff_symbol *cs,
 		  ;
 		}
 	      else
-		SYMBOL_TYPE (sym)->set_name (xstrdup (sym->linkage_name ()));
+		sym->type ()->set_name (xstrdup (sym->linkage_name ()));
 	    }
 
 	  /* Keep track of any type which points to empty structured
@@ -1691,9 +1691,9 @@ process_coff_symbol (struct coff_symbol *cs,
 	     not an empty structured type, though; the forward
 	     references work themselves out via the magic of
 	     coff_lookup_type.  */
-	  if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_PTR
-	      && TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))) == 0
-	      && TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))->code ()
+	  if (sym->type ()->code () == TYPE_CODE_PTR
+	      && TYPE_LENGTH (TYPE_TARGET_TYPE (sym->type ())) == 0
+	      && TYPE_TARGET_TYPE (sym->type ())->code ()
 	      != TYPE_CODE_UNDEF)
 	    {
 	      int i = hashname (sym->linkage_name ());
@@ -1713,11 +1713,11 @@ process_coff_symbol (struct coff_symbol *cs,
 	  /* Some compilers try to be helpful by inventing "fake"
 	     names for anonymous enums, structures, and unions, like
 	     "~0fake" or ".0fake".  Thanks, but no thanks...  */
-	  if (SYMBOL_TYPE (sym)->name () == 0)
+	  if (sym->type ()->name () == 0)
 	    if (sym->linkage_name () != NULL
 		&& *sym->linkage_name () != '~'
 		&& *sym->linkage_name () != '.')
-	      SYMBOL_TYPE (sym)->set_name (xstrdup (sym->linkage_name ()));
+	      sym->type ()->set_name (xstrdup (sym->linkage_name ()));
 
 	  add_symbol_to_list (sym, get_file_symbols ());
 	  break;
@@ -2143,7 +2143,7 @@ coff_read_enum_type (int index, int length, int lastsym,
 	{
 	  struct symbol *xsym = syms->symbol[j];
 
-	  SYMBOL_TYPE (xsym) = type;
+	  xsym->set_type (type);
 	  type->field (n).set_name (xsym->linkage_name ());
 	  type->field (n).set_loc_enumval (SYMBOL_VALUE (xsym));
 	  if (SYMBOL_VALUE (xsym) < 0)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 41746c20e057..4f7a5b22da51 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -65,7 +65,7 @@ convert_one_symbol (compile_c_instance *context,
   if (sym.symbol->aclass () == LOC_LABEL)
     sym_type = 0;
   else
-    sym_type = context->convert_type (SYMBOL_TYPE (sym.symbol));
+    sym_type = context->convert_type (sym.symbol->type ());
 
   if (sym.symbol->domain () == STRUCT_DOMAIN)
     {
@@ -94,12 +94,12 @@ convert_one_symbol (compile_c_instance *context,
 	case LOC_BLOCK:
 	  kind = GCC_C_SYMBOL_FUNCTION;
 	  addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym.symbol));
-	  if (is_global && SYMBOL_TYPE (sym.symbol)->is_gnu_ifunc ())
+	  if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
 	    addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
 	  break;
 
 	case LOC_CONST:
-	  if (SYMBOL_TYPE (sym.symbol)->code () == TYPE_CODE_ENUM)
+	  if (sym.symbol->type ()->code () == TYPE_CODE_ENUM)
 	    {
 	      /* Already handled by convert_enum.  */
 	      return;
@@ -405,7 +405,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
 				"gcc_symbol_address \"%s\": full symbol\n",
 				identifier);
 	  result = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
-	  if (SYMBOL_TYPE (sym)->is_gnu_ifunc ())
+	  if (sym->type ()->is_gnu_ifunc ())
 	    result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
 	  found = 1;
 	}
@@ -548,14 +548,14 @@ generate_c_for_for_one_variable (compile_instance *compiler,
 
   try
     {
-      if (is_dynamic_type (SYMBOL_TYPE (sym)))
+      if (is_dynamic_type (sym->type ()))
 	{
 	  /* We need to emit to a temporary buffer in case an error
 	     occurs in the middle.  */
 	  string_file local_file;
 
 	  generate_vla_size (compiler, &local_file, gdbarch, registers_used, pc,
-			     SYMBOL_TYPE (sym), sym);
+			     sym->type (), sym);
 
 	  stream->write (local_file.c_str (), local_file.size ());
 	}
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 3a24aa7dc8b0..7cf5703dc71d 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -56,7 +56,7 @@ convert_one_symbol (compile_cplus_instance *instance,
   if (sym.symbol->aclass () == LOC_LABEL)
     sym_type = 0;
   else
-    sym_type = instance->convert_type (SYMBOL_TYPE (sym.symbol));
+    sym_type = instance->convert_type (sym.symbol->type ());
 
   if (sym.symbol->domain () == STRUCT_DOMAIN)
     {
@@ -73,9 +73,9 @@ convert_one_symbol (compile_cplus_instance *instance,
       switch (sym.symbol->aclass ())
 	{
 	case LOC_TYPEDEF:
-	  if (SYMBOL_TYPE (sym.symbol)->code () == TYPE_CODE_TYPEDEF)
+	  if (sym.symbol->type ()->code () == TYPE_CODE_TYPEDEF)
 	    kind = GCC_CP_SYMBOL_TYPEDEF;
-	  else  if (SYMBOL_TYPE (sym.symbol)->code () == TYPE_CODE_NAMESPACE)
+	  else  if (sym.symbol->type ()->code () == TYPE_CODE_NAMESPACE)
 	    return;
 	  break;
 
@@ -88,13 +88,13 @@ convert_one_symbol (compile_cplus_instance *instance,
 	  {
 	    kind = GCC_CP_SYMBOL_FUNCTION;
 	    addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
-	    if (is_global && SYMBOL_TYPE (sym.symbol)->is_gnu_ifunc ())
+	    if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
 	      addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
 	  }
 	  break;
 
 	case LOC_CONST:
-	  if (SYMBOL_TYPE (sym.symbol)->code () == TYPE_CODE_ENUM)
+	  if (sym.symbol->type ()->code () == TYPE_CODE_ENUM)
 	    {
 	      /* Already handled by convert_enum.  */
 	      return;
@@ -190,7 +190,7 @@ convert_one_symbol (compile_cplus_instance *instance,
 	    {
 	      compile_scope scope
 		= instance->new_scope (sym.symbol->natural_name (),
-				       SYMBOL_TYPE (sym.symbol));
+				       sym.symbol->type ());
 	      if (scope.nested_type () != GCC_TYPE_NONE)
 		{
 		  /* We found a symbol for this type that was defined inside
@@ -442,7 +442,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
 				"gcc_symbol_address \"%s\": full symbol\n",
 				identifier);
 	  result = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
-	  if (SYMBOL_TYPE (sym)->is_gnu_ifunc ())
+	  if (sym->type ()->is_gnu_ifunc ())
 	    result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
 	  found = 1;
 	}
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index ce8b94526859..198799669865 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -161,7 +161,7 @@ type_name_to_scope (const char *type_name, const struct block *block)
 
 	  scope.push_back (comp);
 
-	  if (SYMBOL_TYPE (bsymbol.symbol)->code () != TYPE_CODE_NAMESPACE)
+	  if (bsymbol.symbol->type ()->code () != TYPE_CODE_NAMESPACE)
 	    {
 	      /* We're done.  */
 	      break;
@@ -271,7 +271,7 @@ compile_cplus_instance::enter_scope (compile_scope &&new_scope)
 	(m_scopes.back ().begin (), m_scopes.back ().end () - 1,
 	 [this] (const scope_component &comp)
 	 {
-	  gdb_assert (SYMBOL_TYPE (comp.bsymbol.symbol)->code ()
+	  gdb_assert (comp.bsymbol.symbol->type ()->code ()
 		      == TYPE_CODE_NAMESPACE);
 
 	  const char *ns = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr
@@ -313,7 +313,7 @@ compile_cplus_instance::leave_scope ()
       std::for_each
 	(current.begin (),current.end () - 1,
 	 [this] (const scope_component &comp) {
-	  gdb_assert (SYMBOL_TYPE (comp.bsymbol.symbol)->code ()
+	  gdb_assert (comp.bsymbol.symbol->type ()->code ()
 		      == TYPE_CODE_NAMESPACE);
 	  this->plugin ().pop_binding_level (comp.name.c_str ());
 	});
@@ -345,14 +345,14 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type)
 	 unqualified name of the type to process.  */
       scope_component &comp = scope.back ();
 
-      if (!types_equal (type, SYMBOL_TYPE (comp.bsymbol.symbol))
+      if (!types_equal (type, comp.bsymbol.symbol->type ())
 	  && (m_scopes.empty ()
 	      || (m_scopes.back ().back ().bsymbol.symbol
 		  != comp.bsymbol.symbol)))
 	{
 	  /* The type is defined inside another class(es).  Convert that
 	     type instead of defining this type.  */
-	  convert_type (SYMBOL_TYPE (comp.bsymbol.symbol));
+	  convert_type (comp.bsymbol.symbol->type ());
 
 	  /* If the original type (passed in to us) is defined in a nested
 	     class, the previous call will give us that type's gcc_type.
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 692e9906fd7d..073f2fe2fd32 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -458,7 +458,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
   if (block_loop == nblocks)
     error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_VAL);
 
-  gdb_type = SYMBOL_TYPE (gdb_val_sym);
+  gdb_type = gdb_val_sym->type ();
   gdb_type = check_typedef (gdb_type);
 
   gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE,
@@ -466,7 +466,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
 					  VAR_DOMAIN);
   if (gdb_ptr_type_sym == NULL)
     error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE);
-  gdb_ptr_type = SYMBOL_TYPE (gdb_ptr_type_sym);
+  gdb_ptr_type = gdb_ptr_type_sym->type ();
   gdb_ptr_type = check_typedef (gdb_ptr_type);
   if (gdb_ptr_type->code () != TYPE_CODE_PTR)
     error (_("Type of \"%s\" is not a pointer"), COMPILE_I_EXPR_PTR_TYPE);
@@ -517,7 +517,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
 static struct type *
 get_regs_type (struct symbol *func_sym, struct objfile *objfile)
 {
-  struct type *func_type = SYMBOL_TYPE (func_sym);
+  struct type *func_type = func_sym->type ();
   struct type *regsp_type, *regs_type;
 
   /* No register parameter present.  */
@@ -656,7 +656,7 @@ compile_object_load (const compile_file_names &file_names,
   if (func_sym == NULL)
     error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
 	   GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));
-  func_type = SYMBOL_TYPE (func_sym);
+  func_type = func_sym->type ();
   if (func_type->code () != TYPE_CODE_FUNC)
     error (_("Invalid type code %d of function \"%s\" in compiled "
 	     "module \"%s\"."),
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index b2e09cab0715..bce0f82a1ee2 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -134,7 +134,7 @@ compile_object_run (compile_module_up &&module)
 
   try
     {
-      struct type *func_type = SYMBOL_TYPE (func_sym);
+      struct type *func_type = func_sym->type ();
       int current_arg = 0;
       struct value **vargs;
 
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 8fb2f71b46cc..18238db2c872 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -220,7 +220,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
 	return {};
 
 
-      type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
+      type = check_typedef (TYPE_TARGET_TYPE (lang_this.symbol->type ()));
       /* If TYPE_NAME is NULL, abandon trying to find this symbol.
 	 This can happen for lambda functions compiled with clang++,
 	 which outputs no name for the container class.  */
@@ -274,7 +274,7 @@ cp_search_static_and_baseclasses (const char *name,
   if (scope_sym.symbol == NULL)
     return {};
 
-  struct type *scope_type = SYMBOL_TYPE (scope_sym.symbol);
+  struct type *scope_type = scope_sym.symbol->type ();
 
   /* If the scope is a function/method, then look up NESTED as a local
      static variable.  E.g., "print 'function()::static_var'".  */
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index f146183f3775..0be1a04852f9 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -166,7 +166,7 @@ inspect_type (struct demangle_parse_info *info,
 
   if (sym != NULL)
     {
-      struct type *otype = SYMBOL_TYPE (sym);
+      struct type *otype = sym->type ();
 
       if (finder != NULL)
 	{
@@ -512,7 +512,7 @@ replace_typedefs (struct demangle_parse_info *info,
 
 	      if (sym != NULL)
 		{
-		  struct type *otype = SYMBOL_TYPE (sym);
+		  struct type *otype = sym->type ();
 		  const char *new_name = (*finder) (otype, data);
 
 		  if (new_name != NULL)
@@ -1215,7 +1215,7 @@ overload_list_add_symbol (struct symbol *sym,
 {
   /* If there is no type information, we can't do anything, so
      skip.  */
-  if (SYMBOL_TYPE (sym) == NULL)
+  if (sym->type () == NULL)
     return;
 
   /* skip any symbols that we've already considered.  */
@@ -1507,7 +1507,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
       return NULL;
     }
 
-  rtti_type = check_typedef (SYMBOL_TYPE (rtti_sym));
+  rtti_type = check_typedef (rtti_sym->type ());
 
   switch (rtti_type->code ())
     {
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 2f8c03916594..5d965bb0e08c 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -452,7 +452,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
       sym->compute_and_set_names (name, false, ccp->of->per_bfd);
       sym->set_aclass_index (LOC_CONST);
       sym->set_domain (VAR_DOMAIN);
-      SYMBOL_TYPE (sym) = fip->ptype;
+      sym->set_type (fip->ptype);
       add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
     }
 
@@ -483,7 +483,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
       sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 
       if (type != nullptr)
-	SYMBOL_TYPE (sym) = type;
+	sym->set_type (type);
 
       uint32_t kind = ctf_type_kind (fp, tid);
       switch (kind)
@@ -499,8 +499,8 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	    set_symbol_address (objfile, sym, sym->linkage_name ());
 	    break;
 	  case CTF_K_CONST:
-	    if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_VOID)
-	      SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_int;
+	    if (sym->type ()->code () == TYPE_CODE_VOID)
+	      sym->set_type (objfile_type (objfile)->builtin_int);
 	    break;
 	  case CTF_K_TYPEDEF:
 	  case CTF_K_INTEGER:
@@ -1169,7 +1169,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
 	  }
 	sym = new (&ccp->of->objfile_obstack) symbol;
 	OBJSTAT (ccp->of, n_syms++);
-	SYMBOL_TYPE (sym) = type;
+	sym->set_type (type);
 	sym->set_domain (VAR_DOMAIN);
 	sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	sym->compute_and_set_names (name, false, ccp->of->per_bfd);
@@ -1205,7 +1205,7 @@ add_stt_entries (struct ctf_context *ccp, int functions)
 	continue;
       sym = new (&ccp->of->objfile_obstack) symbol;
       OBJSTAT (ccp->of, n_syms++);
-      SYMBOL_TYPE (sym) = type;
+      sym->set_type (type);
       sym->set_domain (VAR_DOMAIN);
       sym->set_aclass_index (LOC_STATIC);
       sym->compute_and_set_names (tname, false, ccp->of->per_bfd);
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 601659d080d3..027a8fa206da 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -1343,7 +1343,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
   sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
   if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF)
     {
-      yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
+      yylval.tsym.type = sym.symbol->type ();
       return TYPENAME;
     }
   else if (sym.symbol == NULL)
@@ -1355,7 +1355,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
 
       if (sym.symbol != NULL)
 	{
-	  yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
+	  yylval.tsym.type = sym.symbol->type ();
 	  return TYPENAME;
 	}
 
@@ -1390,7 +1390,7 @@ classify_inner_name (struct parser_state *par_state,
 
   if (yylval.ssym.sym.symbol->aclass () == LOC_TYPEDEF)
     {
-      yylval.tsym.type = SYMBOL_TYPE (yylval.ssym.sym.symbol);
+      yylval.tsym.type = yylval.ssym.sym.symbol->type ();
       return TYPENAME;
     }
 
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index eab99cec6720..07c22e0eae54 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -130,7 +130,7 @@ d_lookup_symbol (const struct language_defn *langdef,
 	  if (lang_this.symbol == NULL)
 	    return {};
 
-	  type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
+	  type = check_typedef (TYPE_TARGET_TYPE (lang_this.symbol->type ()));
 	  classname = type->name ();
 	  nested = name;
 	}
@@ -151,7 +151,7 @@ d_lookup_symbol (const struct language_defn *langdef,
 	return {};
 
       /* Look for a symbol named NESTED in this class.  */
-      sym = d_lookup_nested_symbol (SYMBOL_TYPE (class_sym.symbol),
+      sym = d_lookup_nested_symbol (class_sym.symbol->type (),
 				    nested.c_str (), block);
     }
 
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index bf3cadba87ee..badc7f890789 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -744,7 +744,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr)
 		   "name for address %s"),
 		 paddress (gdbarch, addr));
 
-  type = SYMBOL_TYPE (sym);
+  type = sym->type ();
   gdb_assert (type->code () == TYPE_CODE_FUNC);
   gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC);
 
@@ -783,7 +783,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr)
 
       func_sym = func_addr_to_tail_call_list (gdbarch, addr);
 
-      for (call_site = TYPE_TAIL_CALL_LIST (SYMBOL_TYPE (func_sym));
+      for (call_site = TYPE_TAIL_CALL_LIST (func_sym->type ());
 	   call_site; call_site = call_site->tail_call_next)
 	{
 	  CORE_ADDR target_addr;
@@ -985,7 +985,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
 	  struct symbol *target_func;
 
 	  target_func = func_addr_to_tail_call_list (gdbarch, target_func_addr);
-	  target_call_site = TYPE_TAIL_CALL_LIST (SYMBOL_TYPE (target_func));
+	  target_call_site = TYPE_TAIL_CALL_LIST (target_func->type ());
 	}
 
       do
@@ -3019,7 +3019,7 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
     = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
   struct value *val;
 
-  val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data,
+  val = dwarf2_evaluate_loc_desc (symbol->type (), frame, dlbaton->data,
 				  dlbaton->size, dlbaton->per_cu,
 				  dlbaton->per_objfile);
 
@@ -3036,7 +3036,7 @@ locexpr_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
   struct dwarf2_locexpr_baton *dlbaton
     = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
 
-  return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol), frame, dlbaton->data,
+  return value_of_dwarf_block_entry (symbol->type (), frame, dlbaton->data,
 				     dlbaton->size);
 }
 
@@ -3856,7 +3856,7 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
   CORE_ADDR pc = frame ? get_frame_address_in_block (frame) : 0;
 
   data = dwarf2_find_location_expression (dlbaton, &size, pc);
-  val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, data, size,
+  val = dwarf2_evaluate_loc_desc (symbol->type (), frame, data, size,
 				  dlbaton->per_cu, dlbaton->per_objfile);
 
   return val;
@@ -3880,13 +3880,13 @@ loclist_read_variable_at_entry (struct symbol *symbol, struct frame_info *frame)
   CORE_ADDR pc;
 
   if (frame == NULL || !get_frame_func_if_available (frame, &pc))
-    return allocate_optimized_out_value (SYMBOL_TYPE (symbol));
+    return allocate_optimized_out_value (symbol->type ());
 
   data = dwarf2_find_location_expression (dlbaton, &size, pc);
   if (data == NULL)
-    return allocate_optimized_out_value (SYMBOL_TYPE (symbol));
+    return allocate_optimized_out_value (symbol->type ());
 
-  return value_of_dwarf_block_entry (SYMBOL_TYPE (symbol), frame, data, size);
+  return value_of_dwarf_block_entry (symbol->type (), frame, data, size);
 }
 
 /* Implementation of get_symbol_read_needs from
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 95d4d6fc5532..3a22bcdd43d8 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -8918,7 +8918,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
 	 e.g., "main" finds the "main" module and not C's main().  */
       sym->set_domain (STRUCT_DOMAIN);
       sym->set_aclass_index (LOC_TYPEDEF);
-      SYMBOL_TYPE (sym) = type;
+      sym->set_type (type);
 
       add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
     }
@@ -21720,9 +21720,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       sym->set_domain (VAR_DOMAIN);
       sym->set_aclass_index (LOC_OPTIMIZED_OUT);
       if (type != NULL)
-	SYMBOL_TYPE (sym) = type;
+	sym->set_type (type);
       else
-	SYMBOL_TYPE (sym) = die_type (die, cu);
+	sym->set_type (die_type (die, cu));
       attr = dwarf2_attr (die,
 			  inlined_func ? DW_AT_call_line : DW_AT_decl_line,
 			  cu);
@@ -21764,7 +21764,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    }
 	  else
 	    sym->set_aclass_index (LOC_OPTIMIZED_OUT);
-	  SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
+	  sym->set_type (objfile_type (objfile)->builtin_core_addr);
 	  sym->set_domain (LABEL_DOMAIN);
 	  add_symbol_to_list (sym, cu->list_in_scope);
 	  break;
@@ -21806,8 +21806,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  /* Compilation with minimal debug info may result in
 	     variables with missing type entries.  Change the
 	     misleading `void' type to something sensible.  */
-	  if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_VOID)
-	    SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_int;
+	  if (sym->type ()->code () == TYPE_CODE_VOID)
+	    sym->set_type (objfile_type (objfile)->builtin_int);
 
 	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
 	  /* In the case of DW_TAG_member, we should only be called for
@@ -21994,8 +21994,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 		    /* The symbol's name is already allocated along
 		       with this objfile, so we don't need to
 		       duplicate it for the type.  */
-		    if (SYMBOL_TYPE (sym)->name () == 0)
-		      SYMBOL_TYPE (sym)->set_name (sym->search_name ());
+		    if (sym->type ()->name () == 0)
+		      sym->type ()->set_name (sym->search_name ());
 		  }
 	      }
 	  }
@@ -22230,7 +22230,7 @@ dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
   const gdb_byte *bytes;
   struct dwarf2_locexpr_baton *baton;
 
-  dwarf2_const_value_attr (attr, SYMBOL_TYPE (sym),
+  dwarf2_const_value_attr (attr, sym->type (),
 			   sym->print_name (),
 			   &objfile->objfile_obstack, cu,
 			   &value, &bytes, &baton);
diff --git a/gdb/eval.c b/gdb/eval.c
index 91ff41cfe25a..6ced0b261e78 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -564,7 +564,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var)
       if (noside != EVAL_AVOID_SIDE_EFFECTS)
 	throw;
 
-      ret = value_zero (SYMBOL_TYPE (var), not_lval);
+      ret = value_zero (var->type (), not_lval);
     }
 
   return ret;
@@ -580,7 +580,7 @@ var_value_operation::evaluate (struct type *expect_type,
 			       enum noside noside)
 {
   symbol *var = std::get<0> (m_storage).symbol;
-  if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR)
+  if (var->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (var->print_name ());
   return evaluate_var_value (noside, std::get<0> (m_storage).block, var);
 }
@@ -722,7 +722,7 @@ var_value_operation::evaluate_funcall (struct type *expect_type,
 		       NULL, std::get<0> (m_storage).symbol,
 		       NULL, &symp, NULL, 0, noside);
 
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
   value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block,
 				      symp);
@@ -1005,7 +1005,7 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
 			 enum noside noside, symbol *sym)
 {
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    return value_zero (SYMBOL_TYPE (sym), not_lval);
+    return value_zero (sym->type (), not_lval);
 
   if (SYMBOL_COMPUTED_OPS (sym) == NULL
       || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
@@ -2261,7 +2261,7 @@ adl_func_operation::evaluate (struct type *expect_type,
 		       NON_METHOD,
 		       nullptr, nullptr,
 		       nullptr, &symp, nullptr, 0, noside);
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
   value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
   return evaluate_subexp_do_call (exp, noside, callee, args,
@@ -2582,12 +2582,12 @@ var_value_operation::evaluate_for_address (struct expression *exp,
 
   /* C++: The "address" of a reference should yield the address
    * of the object pointed to.  Let value_addr() deal with it.  */
-  if (TYPE_IS_REFERENCE (SYMBOL_TYPE (var)))
+  if (TYPE_IS_REFERENCE (var->type ()))
     return operation::evaluate_for_address (exp, noside);
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
-      struct type *type = lookup_pointer_type (SYMBOL_TYPE (var));
+      struct type *type = lookup_pointer_type (var->type ());
       enum address_class sym_class = var->aclass ();
 
       if (sym_class == LOC_CONST
@@ -2606,7 +2606,7 @@ var_value_operation::evaluate_with_coercion (struct expression *exp,
 					     enum noside noside)
 {
   struct symbol *var = std::get<0> (m_storage).symbol;
-  struct type *type = check_typedef (SYMBOL_TYPE (var));
+  struct type *type = check_typedef (var->type ());
   if (type->code () == TYPE_CODE_ARRAY
       && !type->is_vector ()
       && CAST_IS_CONVERSION (exp->language_defn))
@@ -2735,7 +2735,7 @@ value *
 var_value_operation::evaluate_for_sizeof (struct expression *exp,
 					  enum noside noside)
 {
-  struct type *type = SYMBOL_TYPE (std::get<0> (m_storage).symbol);
+  struct type *type = std::get<0> (m_storage).symbol->type ();
   if (is_dynamic_type (type))
     {
       value *val = evaluate (nullptr, exp, EVAL_NORMAL);
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 13f8c10897fc..9cba30f68379 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1489,7 +1489,7 @@ yylex (void)
 				domain, NULL);
 	if (result.symbol && result.symbol->aclass () == LOC_TYPEDEF)
 	  {
-	    yylval.tsym.type = SYMBOL_TYPE (result.symbol);
+	    yylval.tsym.type = result.symbol->type ();
 	    return TYPENAME;
 	  }
 
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index f5c880d65963..47c98ab97930 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -1952,9 +1952,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
 				     language_c, NULL).symbol;
       if (obj_entry_sym == NULL)
 	error (_("Unable to find Struct_Obj_Entry symbol"));
-      data->off_linkmap = lookup_struct_elt (SYMBOL_TYPE (obj_entry_sym),
+      data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (),
 					     "linkmap", 0).offset / 8;
-      data->off_tlsindex = lookup_struct_elt (SYMBOL_TYPE (obj_entry_sym),
+      data->off_tlsindex = lookup_struct_elt (obj_entry_sym->type (),
 					      "tlsindex", 0).offset / 8;
       data->rtld_offsets_valid = true;
       return;
diff --git a/gdb/findvar.c b/gdb/findvar.c
index fdfad599f32e..1d22e645305e 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -593,7 +593,7 @@ language_defn::read_var_value (struct symbol *var,
 			       struct frame_info *frame) const
 {
   struct value *v;
-  struct type *type = SYMBOL_TYPE (var);
+  struct type *type = var->type ();
   CORE_ADDR addr;
   enum symbol_needs_kind sym_need;
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2e7f6540f94f..ff07086b46f8 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1691,7 +1691,7 @@ lookup_typename (const struct language_defn *language,
   sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
 				   language->la_language, NULL).symbol;
   if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
-    return SYMBOL_TYPE (sym);
+    return sym->type ();
 
   if (noerr)
     return NULL;
@@ -1738,12 +1738,12 @@ lookup_struct (const char *name, const struct block *block)
     {
       error (_("No struct type named %s."), name);
     }
-  if (SYMBOL_TYPE (sym)->code () != TYPE_CODE_STRUCT)
+  if (sym->type ()->code () != TYPE_CODE_STRUCT)
     {
       error (_("This context has class, union or enum %s, not a struct."),
 	     name);
     }
-  return (SYMBOL_TYPE (sym));
+  return (sym->type ());
 }
 
 /* Lookup a union type named "union NAME",
@@ -1760,7 +1760,7 @@ lookup_union (const char *name, const struct block *block)
   if (sym == NULL)
     error (_("No union type named %s."), name);
 
-  t = SYMBOL_TYPE (sym);
+  t = sym->type ();
 
   if (t->code () == TYPE_CODE_UNION)
     return t;
@@ -1783,12 +1783,12 @@ lookup_enum (const char *name, const struct block *block)
     {
       error (_("No enum type named %s."), name);
     }
-  if (SYMBOL_TYPE (sym)->code () != TYPE_CODE_ENUM)
+  if (sym->type ()->code () != TYPE_CODE_ENUM)
     {
       error (_("This context has class, struct or union %s, not an enum."), 
 	     name);
     }
-  return (SYMBOL_TYPE (sym));
+  return (sym->type ());
 }
 
 /* Lookup a template type named "template NAME<TYPE>",
@@ -1813,12 +1813,12 @@ lookup_template_type (const char *name, struct type *type,
     {
       error (_("No template type named %s."), name);
     }
-  if (SYMBOL_TYPE (sym)->code () != TYPE_CODE_STRUCT)
+  if (sym->type ()->code () != TYPE_CODE_STRUCT)
     {
       error (_("This context has class, union or enum %s, not a struct."),
 	     name);
     }
-  return (SYMBOL_TYPE (sym));
+  return (sym->type ());
 }
 
 /* See gdbtypes.h.  */
@@ -2906,7 +2906,7 @@ check_typedef (struct type *type)
 	    }
 	  sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
 	  if (sym)
-	    TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
+	    TYPE_TARGET_TYPE (type) = sym->type ();
 	  else					/* TYPE_CODE_UNDEF */
 	    TYPE_TARGET_TYPE (type) = alloc_type_arch (type->arch ());
 	}
@@ -3000,11 +3000,11 @@ check_typedef (struct type *type)
 	  /* Same as above for opaque types, we can replace the stub
 	     with the complete type only if they are in the same
 	     objfile.  */
-	  if (SYMBOL_TYPE (sym)->objfile_owner () == type->objfile_owner ())
-	    type = make_qualified_type (SYMBOL_TYPE (sym),
+	  if (sym->type ()->objfile_owner () == type->objfile_owner ())
+	    type = make_qualified_type (sym->type (),
 					type->instance_flags (), type);
 	  else
-	    type = SYMBOL_TYPE (sym);
+	    type = sym->type ();
 	}
     }
 
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 270a8b4b46f9..0cbb8d0d3a63 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1071,7 +1071,7 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch)
     typeinfo_type
       = (struct type *) gdbarch_data (gdbarch, std_type_info_gdbarch_data);
   else
-    typeinfo_type = SYMBOL_TYPE (typeinfo);
+    typeinfo_type = typeinfo->type ();
 
   return typeinfo_type;
 }
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index fed7fe531f98..456920456cde 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1339,7 +1339,7 @@ package_name_p (const char *name, const struct block *block)
 
   if (sym
       && sym->aclass () == LOC_TYPEDEF
-      && SYMBOL_TYPE (sym)->code () == TYPE_CODE_MODULE)
+      && sym->type ()->code () == TYPE_CODE_MODULE)
     return 1;
 
   return 0;
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 32ef3361941a..4c28603fa636 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -345,10 +345,10 @@ gdbscm_symbol_type (SCM self)
     = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symbol *symbol = s_smob->symbol;
 
-  if (SYMBOL_TYPE (symbol) == NULL)
+  if (symbol->type () == NULL)
     return SCM_BOOL_F;
 
-  return tyscm_scm_from_type (SYMBOL_TYPE (symbol));
+  return tyscm_scm_from_type (symbol->type ());
 }
 
 /* (symbol-symtab <gdb:symbol>) -> <gdb:symtab> | #f
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index b02040f68d3b..b9fb121dbbe6 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1567,7 +1567,7 @@ finish_command_fsm::should_stop (struct thread_info *tp)
       /* We're done.  */
       set_finished ();
 
-      rv->type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
+      rv->type = TYPE_TARGET_TYPE (function->type ());
       if (rv->type == NULL)
 	internal_error (__FILE__, __LINE__,
 			_("finish_command: function has no target type"));
@@ -1803,7 +1803,7 @@ finish_command (const char *arg, int from_tty)
 	printf_filtered (_("Run back to call of "));
       else
 	{
-	  if (sm->function != NULL && TYPE_NO_RETURN (sm->function->type)
+	  if (sm->function != NULL && TYPE_NO_RETURN (sm->function->type ())
 	      && !query (_("warning: Function %s does not return normally.\n"
 			   "Try to finish anyway? "),
 			 sm->function->print_name ()))
diff --git a/gdb/jit.c b/gdb/jit.c
index 833cb8ed78c7..0e224d9551d4 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -553,7 +553,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       block_name->set_domain (VAR_DOMAIN);
       block_name->set_aclass_index (LOC_BLOCK);
       symbol_set_symtab (block_name, filetab);
-      SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
+      block_name->set_type (lookup_function_type (block_type));
       SYMBOL_BLOCK_VALUE (block_name) = new_block;
 
       block_name->m_name = obstack_strdup (&objfile->objfile_obstack,
diff --git a/gdb/language.c b/gdb/language.c
index 1d4b1b312525..69c73b0318e1 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -975,7 +975,7 @@ language_arch_info::bool_type () const
       sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol;
       if (sym != nullptr)
 	{
-	  struct type *type = SYMBOL_TYPE (sym);
+	  struct type *type = sym->type ();
 	  if (type != nullptr && type->code () == TYPE_CODE_BOOL)
 	    return type;
 	}
@@ -1000,7 +1000,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->owner.arch = gdbarch;
   symbol->set_is_objfile_owned (0);
   symbol->set_section_index (0);
-  SYMBOL_TYPE (symbol) = type;
+  symbol->set_type (type);
   symbol->set_domain (VAR_DOMAIN);
   symbol->set_aclass_index (LOC_TYPEDEF);
   return symbol;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 4a83b78d4fd6..1775c7c48f3e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3494,7 +3494,7 @@ decode_compound_collector::operator () (block_symbol *bsym)
   if (sym->aclass () != LOC_TYPEDEF)
     return true; /* Continue iterating.  */
 
-  t = SYMBOL_TYPE (sym);
+  t = sym->type ();
   t = check_typedef (t);
   if (t->code () != TYPE_CODE_STRUCT
       && t->code () != TYPE_CODE_UNION
@@ -3686,7 +3686,7 @@ find_method (struct linespec_state *self,
       pspace = symbol_symtab (sym)->pspace ();
       gdb_assert (!pspace->executing_startup);
       set_current_program_space (pspace);
-      t = check_typedef (SYMBOL_TYPE (sym));
+      t = check_typedef (sym->type ());
       find_methods (t, sym->language (),
 		    method_name, &result_names, &superclass_vec);
 
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index f3685f75b723..7607fd753c5a 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -163,8 +163,8 @@ m2_language::print_typedef (struct type *type, struct symbol *new_symbol,
 {
   type = check_typedef (type);
   fprintf_filtered (stream, "TYPE ");
-  if (!SYMBOL_TYPE (new_symbol)->name ()
-      || strcmp ((SYMBOL_TYPE (new_symbol))->name (),
+  if (!new_symbol->type ()->name ()
+      || strcmp ((new_symbol->type ())->name (),
 		 new_symbol->linkage_name ()) != 0)
     fprintf_filtered (stream, "%s = ", new_symbol->print_name ());
   else
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index a295878b625a..8ede3d6aa269 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -569,9 +569,9 @@ add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend,
   /* Type could be missing if file is compiled without debugging info.  */
   if (SC_IS_UNDEF (sh->sc)
       || sh->sc == scNil || sh->index == indexNil)
-    SYMBOL_TYPE (s) = objfile_type (objfile)->nodebug_data_symbol;
+    s->set_type (objfile_type (objfile)->nodebug_data_symbol);
   else
-    SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
+    s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name));
   /* Value of a data symbol is its memory address.  */
 }
 
@@ -697,7 +697,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  break;
 	}
       SYMBOL_VALUE (s) = svalue;
-      SYMBOL_TYPE (s) = parse_type (cur_fd, ax, sh->index, 0, bigend, name);
+      s->set_type (parse_type (cur_fd, ax, sh->index, 0, bigend, name));
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
       break;
 
@@ -706,7 +706,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       s->set_domain (VAR_DOMAIN);	/* So that it can be used */
       s->set_aclass_index (LOC_LABEL);	/* but not misused.  */
       SET_SYMBOL_VALUE_ADDRESS (s, (CORE_ADDR) sh->value);
-      SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_int;
+      s->set_type (objfile_type (objfile)->builtin_int);
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
       break;
 
@@ -787,12 +787,12 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       add_symbol (s, top_stack->cur_st, b);
 
       /* Make a type for the procedure itself.  */
-      SYMBOL_TYPE (s) = lookup_function_type (t);
+      s->set_type (lookup_function_type (t));
 
       /* All functions in C++ have prototypes.  For C we don't have enough
 	 information in the debug info.  */
       if (s->language () == language_cplus)
-	SYMBOL_TYPE (s)->set_is_prototyped (true);
+	s->type ()->set_is_prototyped (true);
 
       /* Create and enter a new lexical context.  */
       b = new_block (FUNCTION_BLOCK, s->language ());
@@ -809,7 +809,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       push_parse_stack ();
       top_stack->cur_block = b;
       top_stack->blocktype = sh->st;
-      top_stack->cur_type = SYMBOL_TYPE (s);
+      top_stack->cur_type = s->type ();
       top_stack->cur_field = -1;
       top_stack->procadr = sh->value;
       top_stack->numargs = 0;
@@ -1066,7 +1066,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		  (obstack_strdup (&mdebugread_objfile->objfile_obstack,
 				   f->name ()));
 		enum_sym->set_aclass_index (LOC_CONST);
-		SYMBOL_TYPE (enum_sym) = t;
+		enum_sym->set_type (t);
 		enum_sym->set_domain (VAR_DOMAIN);
 		SYMBOL_VALUE (enum_sym) = tsym.value;
 		if (SYMBOL_VALUE (enum_sym) < 0)
@@ -1100,7 +1100,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	s->set_domain (STRUCT_DOMAIN);
 	s->set_aclass_index (LOC_TYPEDEF);
 	SYMBOL_VALUE (s) = 0;
-	SYMBOL_TYPE (s) = t;
+	s->set_type (t);
 	add_symbol (s, top_stack->cur_st, top_stack->cur_block);
 	break;
 
@@ -1156,7 +1156,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
 	  s->set_domain (LABEL_DOMAIN);
 	  s->set_aclass_index (LOC_CONST);
-	  SYMBOL_TYPE (s) = objfile_type (mdebugread_objfile)->builtin_void;
+	  s->set_type (objfile_type (mdebugread_objfile)->builtin_void);
 	  e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
 			      mdebug_extra_func_info);
 	  SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
@@ -1204,7 +1204,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 		      if (sym->is_argument ())
 			{
-			  ftype->field (iparams).set_type (SYMBOL_TYPE (sym));
+			  ftype->field (iparams).set_type (sym->type ());
 			  TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
 			  iparams++;
 			}
@@ -1298,17 +1298,17 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       s->set_domain (VAR_DOMAIN);
       s->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block;
-      SYMBOL_TYPE (s) = t;
+      s->set_type (t);
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
 
       /* Incomplete definitions of structs should not get a name.  */
-      if (SYMBOL_TYPE (s)->name () == NULL
-	  && (SYMBOL_TYPE (s)->num_fields () != 0
-	      || (SYMBOL_TYPE (s)->code () != TYPE_CODE_STRUCT
-		  && SYMBOL_TYPE (s)->code () != TYPE_CODE_UNION)))
+      if (s->type ()->name () == NULL
+	  && (s->type ()->num_fields () != 0
+	      || (s->type ()->code () != TYPE_CODE_STRUCT
+		  && s->type ()->code () != TYPE_CODE_UNION)))
 	{
-	  if (SYMBOL_TYPE (s)->code () == TYPE_CODE_PTR
-	      || SYMBOL_TYPE (s)->code () == TYPE_CODE_FUNC)
+	  if (s->type ()->code () == TYPE_CODE_PTR
+	      || s->type ()->code () == TYPE_CODE_FUNC)
 	    {
 	      /* If we are giving a name to a type such as "pointer to
 		 foo" or "function returning foo", we better not set
@@ -1330,7 +1330,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 		 for anything except pointers or functions.  */
 	    }
 	  else
-	    SYMBOL_TYPE (s)->set_name (s->linkage_name ());
+	    s->type ()->set_name (s->linkage_name ());
 	}
       break;
 
@@ -1990,7 +1990,7 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
       s->set_domain (VAR_DOMAIN);
       SYMBOL_CLASS (s) = LOC_BLOCK;
       /* Don't know its type, hope int is ok.  */
-      SYMBOL_TYPE (s)
+      s->type ()
 	= lookup_function_type (objfile_type (pst->objfile)->builtin_int);
       add_symbol (s, top_stack->cur_st, top_stack->cur_block);
       /* Won't have symbols for this one.  */
@@ -2044,8 +2044,8 @@ parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
 
   if (processing_gcc_compilation == 0
       && found_ecoff_debugging_info == 0
-      && TYPE_TARGET_TYPE (SYMBOL_TYPE (s))->code () == TYPE_CODE_VOID)
-    SYMBOL_TYPE (s) = objfile_type (mdebugread_objfile)->nodebug_text_symbol;
+      && TYPE_TARGET_TYPE (s->type ())->code () == TYPE_CODE_VOID)
+    s->set_type (objfile_type (mdebugread_objfile)->nodebug_text_symbol);
 }
 
 /* Parse the external symbol ES.  Just call parse_symbol() after
@@ -3989,7 +3989,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
 
 		  s->set_domain (LABEL_DOMAIN);
 		  s->set_aclass_index (LOC_CONST);
-		  SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void;
+		  s->set_type (objfile_type (objfile)->builtin_void);
 		  SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e;
 		  e->pdr.framereg = -1;
 		  add_symbol_to_list (s, get_local_symbols ());
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index ed22f3435e0f..e63f17061497 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -525,8 +525,8 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 
   if (values == PRINT_SIMPLE_VALUES)
     {
-      check_typedef (arg->sym->type);
-      type_print (arg->sym->type, "", &stb, -1);
+      check_typedef (arg->sym->type ());
+      type_print (arg->sym->type (), "", &stb, -1);
       uiout->field_stream ("type", stb);
     }
 
@@ -648,7 +648,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	      switch (values)
 		{
 		case PRINT_SIMPLE_VALUES:
-		  type = check_typedef (sym2->type);
+		  type = check_typedef (sym2->type ());
 		  if (type->code () != TYPE_CODE_ARRAY
 		      && type->code () != TYPE_CODE_STRUCT
 		      && type->code () != TYPE_CODE_UNION)
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index a8edce386d23..6ed26d69269d 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -81,7 +81,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
   if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN)
     {
       string_file tmp_stream;
-      type_print (SYMBOL_TYPE (sym), "", &tmp_stream, -1);
+      type_print (sym->type (), "", &tmp_stream, -1);
       uiout->field_string ("type", tmp_stream.string ());
 
       std::string str = symbol_to_info_string (sym, block, kind);
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 72470144abf2..3bb9588ad480 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -96,7 +96,7 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr)
       else 
 	error (_("No struct type named %s."), name);
     }
-  if (SYMBOL_TYPE (sym)->code () != TYPE_CODE_STRUCT)
+  if (sym->type ()->code () != TYPE_CODE_STRUCT)
     {
       if (noerr)
 	return 0;
@@ -210,7 +210,7 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
   if (sym == NULL)
     type = builtin_type (gdbarch)->builtin_data_ptr;
   else
-    type = lookup_pointer_type(SYMBOL_TYPE (sym));
+    type = lookup_pointer_type(sym->type ());
 
   deprecated_set_value_type (nsstringValue, type);
   return nsstringValue;
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index c7fa0dc882dc..024a335453a1 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -690,7 +690,7 @@ variable:	name_not_typename
 				pstate->block_tracker->update (sym);
 
 			      pstate->push_new<var_value_operation> (sym);
-			      current_type = sym.symbol->type; }
+			      current_type = sym.symbol->type (); }
 			  else if ($1.is_a_field_of_this)
 			    {
 			      struct value * this_val;
@@ -1640,9 +1640,9 @@ yylex (void)
 		break;
 	    }
 
-	  yylval.tsym.type = SYMBOL_TYPE (best_sym);
+	  yylval.tsym.type = best_sym->type ();
 #else /* not 0 */
-	  yylval.tsym.type = SYMBOL_TYPE (sym);
+	  yylval.tsym.type = sym->type ();
 #endif /* not 0 */
 	  free (uptokstart);
 	  return TYPENAME;
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 635d7ed5e4de..b0541c94a15c 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -255,7 +255,7 @@ pascal_language::value_print_inner (struct value *val,
 
 	      if (wsym)
 		{
-		  wtype = SYMBOL_TYPE (wsym);
+		  wtype = wsym->type ();
 		}
 	      else
 		{
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 03bd49345060..77e19f6deee2 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -250,7 +250,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
 	  if (function != NULL)
 	    {
 	      struct type *ret_type =
-		check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (function)));
+		check_typedef (TYPE_TARGET_TYPE (function->type ()));
 
 	      /* Remember only non-void return types.  */
 	      if (ret_type->code () != TYPE_CODE_VOID)
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index c756870adb6c..747da481a1bf 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -72,13 +72,13 @@ sympy_get_type (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  if (SYMBOL_TYPE (symbol) == NULL)
+  if (symbol->type () == NULL)
     {
       Py_INCREF (Py_None);
       return Py_None;
     }
 
-  return type_to_type_object (SYMBOL_TYPE (symbol));
+  return type_to_type_object (symbol->type ());
 }
 
 static PyObject *
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 6ab551a85200..9df667d2811d 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -998,7 +998,7 @@ typy_template_argument (PyObject *self, PyObject *args)
 
   sym = TYPE_TEMPLATE_ARGUMENT (type, argno);
   if (sym->aclass () == LOC_TYPEDEF)
-    return type_to_type_object (SYMBOL_TYPE (sym));
+    return type_to_type_object (sym->type ());
   else if (sym->aclass () == LOC_OPTIMIZED_OUT)
     {
       PyErr_Format (PyExc_RuntimeError,
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index ec8cdef052fd..7584d2572fae 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1511,7 +1511,7 @@ rust_structop::evaluate_funcall (struct type *expect_type,
   if (sym.symbol == NULL)
     error (_("Could not find function named '%s'"), name.c_str ());
 
-  struct type *fn_type = SYMBOL_TYPE (sym.symbol);
+  struct type *fn_type = sym.symbol->type ();
   if (fn_type->num_fields () == 0)
     error (_("Function '%s' takes no arguments"), name.c_str ());
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index b4e0090bc6cf..af154a2e0389 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -452,7 +452,7 @@ rust_parser::rust_lookup_type (const char *name)
   if (result.symbol != NULL)
     {
       update_innermost_block (result);
-      return SYMBOL_TYPE (result.symbol);
+      return result.symbol->type ();
     }
 
   type = lookup_typename (language (), name, NULL, 1);
@@ -1184,7 +1184,7 @@ rust_parser::name_to_operation (const std::string &name)
   if (sym.symbol != nullptr)
     {
       gdb_assert (sym.symbol->aclass () == LOC_TYPEDEF);
-      type = SYMBOL_TYPE (sym.symbol);
+      type = sym.symbol->type ();
     }
   if (type == nullptr)
     type = rust_lookup_type (name.c_str ());
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 90092e8f309d..03242ed9866f 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1234,7 +1234,7 @@ sparc_frame_cache (struct frame_info *this_frame, void **this_cache)
 static int
 sparc32_struct_return_from_sym (struct symbol *sym)
 {
-  struct type *type = check_typedef (SYMBOL_TYPE (sym));
+  struct type *type = check_typedef (sym->type ());
   enum type_code code = type->code ();
 
   if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 33fcc9263f7e..d3a1ae990691 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -434,12 +434,12 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
 		  /* I don't think the linker does this with functions,
 		     so as far as I know this is never executed.
 		     But it doesn't hurt to check.  */
-		  SYMBOL_TYPE (sym) =
-		    lookup_function_type (read_type (&pp, objfile));
+		  sym->set_type
+		    (lookup_function_type (read_type (&pp, objfile)));
 		}
 	      else
 		{
-		  SYMBOL_TYPE (sym) = read_type (&pp, objfile);
+		  sym->set_type (read_type (&pp, objfile));
 		}
 	      add_symbol_to_list (sym, get_global_symbols ());
 	    }
@@ -448,12 +448,12 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
 	      pp += 2;
 	      if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
 		{
-		  SYMBOL_TYPE (sym) =
-		    lookup_function_type (read_type (&pp, objfile));
+		  sym->set_type
+		    (lookup_function_type (read_type (&pp, objfile)));
 		}
 	      else
 		{
-		  SYMBOL_TYPE (sym) = read_type (&pp, objfile);
+		  sym->set_type (read_type (&pp, objfile));
 		}
 	    }
 	}
@@ -784,7 +784,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (*p != '=')
 	{
 	  sym->set_aclass_index (LOC_CONST);
-	  SYMBOL_TYPE (sym) = error_type (&p, objfile);
+	  sym->set_type (error_type (&p, objfile));
 	  sym->set_domain (VAR_DOMAIN);
 	  add_symbol_to_list (sym, get_file_symbols ());
 	  return sym;
@@ -804,7 +804,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	    target_float_from_string (dbl_valu, dbl_type, std::string (p));
 
-	    SYMBOL_TYPE (sym) = dbl_type;
+	    sym->set_type (dbl_type);
 	    SYMBOL_VALUE_BYTES (sym) = dbl_valu;
 	    sym->set_aclass_index (LOC_CONST_BYTES);
 	  }
@@ -818,7 +818,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	       types; other languages probably should have at least
 	       unsigned as well as signed constants.  */
 
-	    SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_long;
+	    sym->set_type (objfile_type (objfile)->builtin_long);
 	    SYMBOL_VALUE (sym) = atoi (p);
 	    sym->set_aclass_index (LOC_CONST);
 	  }
@@ -826,7 +826,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	case 'c':
 	  {
-	    SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_char;
+	    sym->set_type (objfile_type (objfile)->builtin_char);
 	    SYMBOL_VALUE (sym) = atoi (p);
 	    sym->set_aclass_index (LOC_CONST);
 	  }
@@ -843,7 +843,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    if (quote != '\'' && quote != '"')
 	      {
 		sym->set_aclass_index (LOC_CONST);
-		SYMBOL_TYPE (sym) = error_type (&p, objfile);
+		sym->set_type (error_type (&p, objfile));
 		sym->set_domain (VAR_DOMAIN);
 		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
@@ -868,7 +868,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	    if (*p != quote)
 	      {
 		sym->set_aclass_index (LOC_CONST);
-		SYMBOL_TYPE (sym) = error_type (&p, objfile);
+		sym->set_type (error_type (&p, objfile));
 		sym->set_domain (VAR_DOMAIN);
 		add_symbol_to_list (sym, get_file_symbols ());
 		return sym;
@@ -880,9 +880,9 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	      = create_static_range_type (NULL,
 					  objfile_type (objfile)->builtin_int,
 					  0, ind);
-	    SYMBOL_TYPE (sym) = create_array_type (NULL,
-				  objfile_type (objfile)->builtin_char,
-				  range_type);
+	    sym->set_type
+	      (create_array_type (NULL, objfile_type (objfile)->builtin_char,
+				  range_type));
 	    string_value
 	      = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, ind + 1);
 	    memcpy (string_value, string_local, ind + 1);
@@ -900,11 +900,11 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	     (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;").  */
 	  {
 	    sym->set_aclass_index (LOC_CONST);
-	    SYMBOL_TYPE (sym) = read_type (&p, objfile);
+	    sym->set_type (read_type (&p, objfile));
 
 	    if (*p != ',')
 	      {
-		SYMBOL_TYPE (sym) = error_type (&p, objfile);
+		sym->set_type (error_type (&p, objfile));
 		break;
 	      }
 	    ++p;
@@ -921,7 +921,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	default:
 	  {
 	    sym->set_aclass_index (LOC_CONST);
-	    SYMBOL_TYPE (sym) = error_type (&p, objfile);
+	    sym->set_type (error_type (&p, objfile));
 	  }
 	}
       sym->set_domain (VAR_DOMAIN);
@@ -930,7 +930,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'C':
       /* The name of a caught exception.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_LABEL);
       sym->set_domain (VAR_DOMAIN);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
@@ -939,7 +939,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'f':
       /* A static function definition.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_BLOCK);
       sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
@@ -949,8 +949,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* Function result types are described as the result type in stabs.
 	 We need to convert this to the function-returning-type-X type
 	 in GDB.  E.g. "int" is converted to "function returning int".  */
-      if (SYMBOL_TYPE (sym)->code () != TYPE_CODE_FUNC)
-	SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
+      if (sym->type ()->code () != TYPE_CODE_FUNC)
+	sym->set_type (lookup_function_type (sym->type ()));
 
       /* All functions in C++ have prototypes.  Stabs does not offer an
 	 explicit way to identify prototyped or unprototyped functions,
@@ -958,7 +958,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 than the "declared-as" type for unprototyped functions, so
 	 we treat all functions as if they were prototyped.  This is used
 	 primarily for promotion when calling the function from GDB.  */
-      SYMBOL_TYPE (sym)->set_is_prototyped (true);
+      sym->type ()->set_is_prototyped (true);
 
       /* fall into process_prototype_types.  */
 
@@ -966,7 +966,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* Sun acc puts declared types of arguments here.  */
       if (*p == ';')
 	{
-	  struct type *ftype = SYMBOL_TYPE (sym);
+	  struct type *ftype = sym->type ();
 	  int nsemi = 0;
 	  int nparams = 0;
 	  const char *p1 = p;
@@ -1011,7 +1011,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'F':
       /* A global function definition.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_BLOCK);
       sym->set_domain (VAR_DOMAIN);
       add_symbol_to_list (sym, get_global_symbols ());
@@ -1022,7 +1022,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 value is not correct.  It is necessary to search for the
 	 corresponding linker definition to find the value.
 	 These definitions appear at the end of the namelist.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_STATIC);
       sym->set_domain (VAR_DOMAIN);
       /* Don't add symbol references to global_sym_chain.
@@ -1043,7 +1043,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 Dbx data never actually contains 'l'.  */
     case 's':
     case 'l':
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
@@ -1057,12 +1057,12 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	   Translate it into a pointer-to-function type.  */
 	{
 	  p++;
-	  SYMBOL_TYPE (sym)
-	    = lookup_pointer_type
-	    (lookup_function_type (read_type (&p, objfile)));
+	  sym->set_type
+	    (lookup_pointer_type
+	       (lookup_function_type (read_type (&p, objfile))));
 	}
       else
-	SYMBOL_TYPE (sym) = read_type (&p, objfile);
+	sym->set_type (read_type (&p, objfile));
 
       sym->set_aclass_index (LOC_ARG);
       SYMBOL_VALUE (sym) = valu;
@@ -1086,12 +1086,12 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	{
 	  /* If PCC says a parameter is a short or a char, it is
 	     really an int.  */
-	  if (TYPE_LENGTH (SYMBOL_TYPE (sym))
+	  if (TYPE_LENGTH (sym->type ())
 	      < gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT
-	      && SYMBOL_TYPE (sym)->code () == TYPE_CODE_INT)
+	      && sym->type ()->code () == TYPE_CODE_INT)
 	    {
-	      SYMBOL_TYPE (sym) =
-		(SYMBOL_TYPE (sym)->is_unsigned ()
+	      sym->set_type
+		(sym->type ()->is_unsigned ()
 		 ? objfile_type (objfile)->builtin_unsigned_int
 		 : objfile_type (objfile)->builtin_int);
 	    }
@@ -1105,14 +1105,14 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 with this extra information.  FIXME, it ought to.  */
       if (type == N_FUN)
 	{
-	  SYMBOL_TYPE (sym) = read_type (&p, objfile);
+	  sym->set_type (read_type (&p, objfile));
 	  goto process_prototype_types;
 	}
       /*FALLTHROUGH */
 
     case 'R':
       /* Parameter which is in a register.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (stab_register_index);
       sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
@@ -1122,7 +1122,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'r':
       /* Register variable (either global or local).  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (stab_register_index);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
@@ -1150,7 +1150,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  struct pending *local_symbols = *get_local_symbols ();
 	  if (local_symbols
 	      && local_symbols->nsyms > 0
-	      && gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym)))
+	      && gdbarch_stabs_argument_has_addr (gdbarch, sym->type ()))
 	    {
 	      struct symbol *prev_sym;
 
@@ -1163,7 +1163,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 		  prev_sym->set_aclass_index (stab_register_index);
 		  /* Use the type from the LOC_REGISTER; that is the type
 		     that is actually in that register.  */
-		  SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
+		  prev_sym->set_type (sym->type ());
 		  SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
 		  sym = prev_sym;
 		  break;
@@ -1177,7 +1177,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'S':
       /* Static symbol at top level of file.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       sym->set_domain (VAR_DOMAIN);
@@ -1202,7 +1202,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       synonym = (sym->language () == language_ada && p[-2] != 'T');
 
       /* Typedef */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
 
       /* For a nameless type, we don't want a create a symbol, thus we
 	 did not use `sym'.  Return without further processing.  */
@@ -1216,24 +1216,24 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 a base type which did not have its name defined when the
 	 derived class was output.  We fill in the derived class's
 	 base part member's name here in that case.  */
-      if (SYMBOL_TYPE (sym)->name () != NULL)
-	if ((SYMBOL_TYPE (sym)->code () == TYPE_CODE_STRUCT
-	     || SYMBOL_TYPE (sym)->code () == TYPE_CODE_UNION)
-	    && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
+      if (sym->type ()->name () != NULL)
+	if ((sym->type ()->code () == TYPE_CODE_STRUCT
+	     || sym->type ()->code () == TYPE_CODE_UNION)
+	    && TYPE_N_BASECLASSES (sym->type ()))
 	  {
 	    int j;
 
-	    for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
-	      if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
-		SYMBOL_TYPE (sym)->field (j).set_name
-		  (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)->name ());
+	    for (j = TYPE_N_BASECLASSES (sym->type ()) - 1; j >= 0; j--)
+	      if (TYPE_BASECLASS_NAME (sym->type (), j) == 0)
+		sym->type ()->field (j).set_name
+		  (TYPE_BASECLASS (sym->type (), j)->name ());
 	  }
 
-      if (SYMBOL_TYPE (sym)->name () == NULL)
+      if (sym->type ()->name () == NULL)
 	{
-	  if ((SYMBOL_TYPE (sym)->code () == TYPE_CODE_PTR
+	  if ((sym->type ()->code () == TYPE_CODE_PTR
 	       && strcmp (sym->linkage_name (), vtbl_ptr_name))
-	      || SYMBOL_TYPE (sym)->code () == TYPE_CODE_FUNC)
+	      || sym->type ()->code () == TYPE_CODE_FUNC)
 	    {
 	      /* If we are giving a name to a type such as "pointer to
 		 foo" or "function returning foo", we better not set
@@ -1272,10 +1272,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
 	      /* Pascal accepts names for pointer types.  */
 	      if (get_current_subfile ()->language == language_pascal)
-		SYMBOL_TYPE (sym)->set_name (sym->linkage_name ());
+		sym->type ()->set_name (sym->linkage_name ());
 	    }
 	  else
-	    SYMBOL_TYPE (sym)->set_name (sym->linkage_name ());
+	    sym->type ()->set_name (sym->linkage_name ());
 	}
 
       add_symbol_to_list (sym, get_file_symbols ());
@@ -1289,8 +1289,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  struct_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (struct_sym) = valu;
 	  struct_sym->set_domain (STRUCT_DOMAIN);
-	  if (SYMBOL_TYPE (sym)->name () == 0)
-	    SYMBOL_TYPE (sym)->set_name
+	  if (sym->type ()->name () == 0)
+	    sym->type ()->set_name
 	      (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
 			 (char *) NULL));
 	  add_symbol_to_list (struct_sym, get_file_symbols ());
@@ -1306,7 +1306,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (synonym)
 	p++;
 
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
  
       /* For a nameless type, we don't want a create a symbol, thus we
 	 did not use `sym'.  Return without further processing.  */
@@ -1316,8 +1316,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       sym->set_aclass_index (LOC_TYPEDEF);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (STRUCT_DOMAIN);
-      if (SYMBOL_TYPE (sym)->name () == 0)
-	SYMBOL_TYPE (sym)->set_name
+      if (sym->type ()->name () == 0)
+	sym->type ()->set_name
 	  (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
 		     (char *) NULL));
       add_symbol_to_list (sym, get_file_symbols ());
@@ -1331,8 +1331,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  typedef_sym->set_aclass_index (LOC_TYPEDEF);
 	  SYMBOL_VALUE (typedef_sym) = valu;
 	  typedef_sym->set_domain (VAR_DOMAIN);
-	  if (SYMBOL_TYPE (sym)->name () == 0)
-	    SYMBOL_TYPE (sym)->set_name
+	  if (sym->type ()->name () == 0)
+	    sym->type ()->set_name
 	      (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
 			 (char *) NULL));
 	  add_symbol_to_list (typedef_sym, get_file_symbols ());
@@ -1341,7 +1341,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'V':
       /* Static symbol of local scope.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_STATIC);
       SET_SYMBOL_VALUE_ADDRESS (sym, valu);
       sym->set_domain (VAR_DOMAIN);
@@ -1350,7 +1350,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'v':
       /* Reference parameter */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_REF_ARG);
       sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
@@ -1360,7 +1360,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
     case 'a':
       /* Reference parameter which is in a register.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (stab_regparm_index);
       sym->set_is_argument (1);
       SYMBOL_VALUE (sym) = valu;
@@ -1373,7 +1373,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
 	 that Pascal uses it too, but when I tried it Pascal used
 	 "x:3" (local symbol) instead.  */
-      SYMBOL_TYPE (sym) = read_type (&p, objfile);
+      sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_LOCAL);
       SYMBOL_VALUE (sym) = valu;
       sym->set_domain (VAR_DOMAIN);
@@ -1381,7 +1381,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       break;
 
     default:
-      SYMBOL_TYPE (sym) = error_type (&p, objfile);
+      sym->set_type (error_type (&p, objfile));
       sym->set_aclass_index (LOC_CONST);
       SYMBOL_VALUE (sym) = 0;
       sym->set_domain (VAR_DOMAIN);
@@ -1393,7 +1393,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
      of by value, i.e. they will pass the address of a structure (in a
      register or on the stack) instead of the structure itself.  */
 
-  if (gdbarch_stabs_argument_has_addr (gdbarch, SYMBOL_TYPE (sym))
+  if (gdbarch_stabs_argument_has_addr (gdbarch, sym->type ())
       && sym->is_argument ())
     {
       /* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
@@ -1630,11 +1630,11 @@ read_type (const char **pp, struct objfile *objfile)
 
 	      if (sym->aclass () == LOC_TYPEDEF
 		  && sym->domain () == STRUCT_DOMAIN
-		  && (SYMBOL_TYPE (sym)->code () == code)
+		  && (sym->type ()->code () == code)
 		  && strcmp (sym->linkage_name (), type_name) == 0)
 		{
 		  obstack_free (&objfile->objfile_obstack, type_name);
-		  type = SYMBOL_TYPE (sym);
+		  type = sym->type ();
 		  if (typenums[0] != -1)
 		    *dbx_lookup_type (typenums, objfile) = type;
 		  return type;
@@ -3635,7 +3635,7 @@ read_enum_type (const char **pp, struct type *type,
 	{
 	  struct symbol *xsym = syms->symbol[j];
 
-	  SYMBOL_TYPE (xsym) = type;
+	  xsym->set_type (type);
 	  type->field (n).set_name (xsym->linkage_name ());
 	  type->field (n).set_loc_enumval (SYMBOL_VALUE (xsym));
 	  TYPE_FIELD_BITSIZE (type, n) = 0;
@@ -4281,7 +4281,7 @@ common_block_end (struct objfile *objfile)
     for (j = common_block_i; j < common_block->nsyms; j++)
       add_symbol_to_list (common_block->symbol[j], &newobj);
 
-  SYMBOL_TYPE (sym) = (struct type *) newobj;
+  sym->set_type ((struct type *) newobj);
 
   /* Should we be putting local_symbols back to what it was?
      Does it matter?  */
@@ -4299,7 +4299,7 @@ common_block_end (struct objfile *objfile)
 static void
 fix_common_block (struct symbol *sym, CORE_ADDR valu)
 {
-  struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
+  struct pending *next = (struct pending *) sym->type ();
 
   for (; next; next = next->next)
     {
@@ -4468,11 +4468,11 @@ cleanup_undefined_types_1 (void)
 
 			if (sym->aclass () == LOC_TYPEDEF
 			    && sym->domain () == STRUCT_DOMAIN
-			    && (SYMBOL_TYPE (sym)->code () == (*type)->code ())
+			    && (sym->type ()->code () == (*type)->code ())
 			    && ((*type)->instance_flags ()
-				== SYMBOL_TYPE (sym)->instance_flags ())
+				== sym->type ()->instance_flags ())
 			    && strcmp (sym->linkage_name (), type_name) == 0)
-			  replace_type (*type, SYMBOL_TYPE (sym));
+			  replace_type (*type, sym->type ());
 		      }
 		  }
 	      }
diff --git a/gdb/stack.c b/gdb/stack.c
index 834e016ef937..b1bbf7d0f449 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -674,7 +674,7 @@ read_frame_arg (const frame_print_options &fp_opts,
 	  || (fp_opts.print_entry_values == print_entry_values_preferred
 	      && (!val || value_optimized_out (val))))
 	{
-	  entryval = allocate_optimized_out_value (SYMBOL_TYPE (sym));
+	  entryval = allocate_optimized_out_value (sym->type ());
 	  entryval_error = NULL;
 	}
     }
@@ -779,7 +779,7 @@ print_frame_args (const frame_print_options &fp_opts,
 	    case LOC_REF_ARG:
 	      {
 		long current_offset = SYMBOL_VALUE (sym);
-		int arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym));
+		int arg_size = TYPE_LENGTH (sym->type ());
 
 		/* Compute address of next argument by adding the size of
 		   this argument and rounding to an int boundary.  */
@@ -2762,7 +2762,7 @@ return_command (const char *retval_exp, int from_tty)
       /* Cast return value to the return type of the function.  Should
 	 the cast fail, this call throws an error.  */
       if (thisfun != NULL)
-	return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
+	return_type = TYPE_TARGET_TYPE (thisfun->type ());
       if (return_type == NULL)
 	{
 	  if (retval_expr->first_opcode () != UNOP_CAST
@@ -2818,7 +2818,7 @@ return_command (const char *retval_exp, int from_tty)
 			   query_prefix);
       else
 	{
-	  if (TYPE_NO_RETURN (thisfun->type))
+	  if (TYPE_NO_RETURN (thisfun->type ()))
 	    warning (_("Function does not return normally to caller."));
 	  confirmed = query (_("%sMake %s return now? "), query_prefix,
 			     thisfun->print_name ());
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 328230afe3ad..160278b50a97 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -523,20 +523,20 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 
   if (symbol->domain () == STRUCT_DOMAIN)
     {
-      if (SYMBOL_TYPE (symbol)->name ())
+      if (symbol->type ()->name ())
 	{
-	  LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth,
+	  LA_PRINT_TYPE (symbol->type (), "", outfile, 1, depth,
 			 &type_print_raw_options);
 	}
       else
 	{
 	  fprintf_filtered (outfile, "%s %s = ",
-			 (SYMBOL_TYPE (symbol)->code () == TYPE_CODE_ENUM
+			 (symbol->type ()->code () == TYPE_CODE_ENUM
 			  ? "enum"
-		     : (SYMBOL_TYPE (symbol)->code () == TYPE_CODE_STRUCT
+		     : (symbol->type ()->code () == TYPE_CODE_STRUCT
 			? "struct" : "union")),
 			    symbol->linkage_name ());
-	  LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth,
+	  LA_PRINT_TYPE (symbol->type (), "", outfile, 1, depth,
 			 &type_print_raw_options);
 	}
       fprintf_filtered (outfile, ";\n");
@@ -545,12 +545,12 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
     {
       if (symbol->aclass () == LOC_TYPEDEF)
 	fprintf_filtered (outfile, "typedef ");
-      if (SYMBOL_TYPE (symbol))
+      if (symbol->type ())
 	{
 	  /* Print details of types, except for enums where it's clutter.  */
-	  LA_PRINT_TYPE (SYMBOL_TYPE (symbol), symbol->print_name (),
+	  LA_PRINT_TYPE (symbol->type (), symbol->print_name (),
 			 outfile,
-			 SYMBOL_TYPE (symbol)->code () != TYPE_CODE_ENUM,
+			 symbol->type ()->code () != TYPE_CODE_ENUM,
 			 depth,
 			 &type_print_raw_options);
 	  fprintf_filtered (outfile, "; ");
@@ -569,7 +569,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
 	case LOC_CONST_BYTES:
 	  {
 	    unsigned i;
-	    struct type *type = check_typedef (SYMBOL_TYPE (symbol));
+	    struct type *type = check_typedef (symbol->type ());
 
 	    fprintf_filtered (outfile, "const %s hex bytes:",
 			      pulongest (TYPE_LENGTH (type)));
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8bdc6cab9608..8da86b613595 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2130,7 +2130,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
 
       if (result.symbol)
 	{
-	  struct type *t = result.symbol->type;
+	  struct type *t = result.symbol->type ();
 
 	  /* I'm not really sure that type of this can ever
 	     be typedefed; just be safe.  */
@@ -2806,8 +2806,8 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
 			   block_find_non_opaque_type, NULL);
   if (sym == NULL)
     error_in_psymtab_expansion (block_index, name, cust);
-  gdb_assert (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)));
-  return SYMBOL_TYPE (sym);
+  gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
+  return sym->type ();
 }
 
 /* Subroutine of basic_lookup_transparent_type to simplify it.
@@ -2831,8 +2831,8 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
 			       block_find_non_opaque_type, NULL);
       if (sym != NULL)
 	{
-	  gdb_assert (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)));
-	  return SYMBOL_TYPE (sym);
+	  gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
+	  return sym->type ();
 	}
     }
 
@@ -4657,7 +4657,7 @@ treg_matches_sym_type_name (const compiled_regex &treg,
 			  sym->natural_name ());
     }
 
-  sym_type = SYMBOL_TYPE (sym);
+  sym_type = sym->type ();
   if (sym_type == NULL)
     return false;
 
@@ -4836,7 +4836,7 @@ global_symbol_searcher::add_matching_symbols
 			      members.  We only want to skip enums
 			      here.  */
 			   && !(sym->aclass () == LOC_CONST
-				&& (SYMBOL_TYPE (sym)->code ()
+				&& (sym->type ()->code ()
 				    == TYPE_CODE_ENUM))
 			   && (!treg.has_value ()
 			       || treg_matches_sym_type_name (*treg, sym)))
@@ -5042,10 +5042,10 @@ symbol_to_info_string (struct symbol *sym, int block,
 	 For the struct printing case below, things are worse, we force
 	 printing of the ";" in this function, which is going to be wrong
 	 for languages that don't require a ";" between statements.  */
-      if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_TYPEDEF)
-	typedef_print (SYMBOL_TYPE (sym), sym, &tmp_stream);
+      if (sym->type ()->code () == TYPE_CODE_TYPEDEF)
+	typedef_print (sym->type (), sym, &tmp_stream);
       else
-	type_print (SYMBOL_TYPE (sym), "", &tmp_stream, -1);
+	type_print (sym->type (), "", &tmp_stream, -1);
       str += tmp_stream.string ();
     }
   /* variable, func, or typedef-that-is-c++-class.  */
@@ -5055,7 +5055,7 @@ symbol_to_info_string (struct symbol *sym, int block,
     {
       string_file tmp_stream;
 
-      type_print (SYMBOL_TYPE (sym),
+      type_print (sym->type (),
 		  (sym->aclass () == LOC_TYPEDEF
 		   ? "" : sym->print_name ()),
 		  &tmp_stream, 0);
@@ -5673,7 +5673,7 @@ completion_list_add_fields (completion_tracker &tracker,
 {
   if (sym->aclass () == LOC_TYPEDEF)
     {
-      struct type *t = SYMBOL_TYPE (sym);
+      struct type *t = sym->type ();
       enum type_code c = t->code ();
       int j;
 
@@ -5691,7 +5691,7 @@ completion_list_add_fields (completion_tracker &tracker,
 bool
 symbol_is_function_or_method (symbol *sym)
 {
-  switch (SYMBOL_TYPE (sym)->code ())
+  switch (sym->type ()->code ())
     {
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
@@ -5789,7 +5789,7 @@ add_symtab_completions (struct compunit_symtab *cust,
 
 	  if (code == TYPE_CODE_UNDEF
 	      || (sym->domain () == STRUCT_DOMAIN
-		  && SYMBOL_TYPE (sym)->code () == code))
+		  && sym->type ()->code () == code))
 	    completion_list_add_symbol (tracker, sym,
 					lookup_name,
 					text, word);
@@ -5942,7 +5942,7 @@ default_collect_symbol_completion_matches_break_on
 					    sym_text, word);
 	      }
 	    else if (sym->domain () == STRUCT_DOMAIN
-		     && SYMBOL_TYPE (sym)->code () == code)
+		     && sym->type ()->code () == code)
 	      completion_list_add_symbol (tracker, sym, lookup_name,
 					  sym_text, word);
 	  }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a86145198fdc..3486803cca8e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1203,9 +1203,19 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     return this->subclass == SYMBOL_TEMPLATE;
   }
 
+  struct type *type () const
+  {
+    return m_type;
+  }
+
+  void set_type (struct type *type)
+  {
+    m_type = type;
+  }
+
   /* Data type of value */
 
-  struct type *type = nullptr;
+  struct type *m_type = nullptr;
 
   /* The owner of this symbol.
      Which one to use is defined by symbol.is_objfile_owned.  */
@@ -1305,7 +1315,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_TYPE(symbol)		(symbol)->type
 #define SYMBOL_LINE(symbol)		(symbol)->line
 #define SYMBOL_COMPUTED_OPS(symbol)	((symbol)->impl ().ops_computed)
 #define SYMBOL_BLOCK_OPS(symbol)	((symbol)->impl ().ops_block)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 7aaf912a495f..cf10eca22ef2 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -927,7 +927,7 @@ collection_list::collect_symbol (struct symbol *sym,
   bfd_signed_vma offset;
   int treat_as_expr = 0;
 
-  len = TYPE_LENGTH (check_typedef (SYMBOL_TYPE (sym)));
+  len = TYPE_LENGTH (check_typedef (sym->type ()));
   switch (sym->aclass ())
     {
     default:
@@ -948,7 +948,7 @@ collection_list::collect_symbol (struct symbol *sym,
 	}
       /* A struct may be a C++ class with static fields, go to general
 	 expression handling.  */
-      if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_STRUCT)
+      if (sym->type ()->code () == TYPE_CODE_STRUCT)
 	treat_as_expr = 1;
       else
 	add_memrange (gdbarch, memrange_absolute, offset, len, scope);
@@ -960,7 +960,7 @@ collection_list::collect_symbol (struct symbol *sym,
       add_local_register (gdbarch, reg, scope);
       /* Check for doubles stored in two registers.  */
       /* FIXME: how about larger types stored in 3 or more regs?  */
-      if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_FLT &&
+      if (sym->type ()->code () == TYPE_CODE_FLT &&
 	  len > register_size (gdbarch, reg))
 	add_local_register (gdbarch, reg + 1, scope);
       break;
@@ -2565,8 +2565,8 @@ info_scope_command (const char *args_in, int from_tty)
 		  break;
 		case LOC_CONST_BYTES:
 		  printf_filtered ("constant bytes: ");
-		  if (SYMBOL_TYPE (sym))
-		    for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++)
+		  if (sym->type ())
+		    for (j = 0; j < TYPE_LENGTH (sym->type ()); j++)
 		      printf_filtered (" %02x",
 				       (unsigned) SYMBOL_VALUE_BYTES (sym)[j]);
 		  break;
@@ -2645,9 +2645,9 @@ info_scope_command (const char *args_in, int from_tty)
 		  gdb_assert_not_reached ("LOC_COMPUTED variable missing a method");
 		}
 	    }
-	  if (SYMBOL_TYPE (sym))
+	  if (sym->type ())
 	    {
-	      struct type *t = check_typedef (SYMBOL_TYPE (sym));
+	      struct type *t = check_typedef (sym->type ());
 
 	      printf_filtered (", length %s.\n", pulongest (TYPE_LENGTH (t)));
 	    }
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 1de223ac5a10..f7a2ebac398f 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -260,7 +260,7 @@ typedef_hash_table::add_template_parameters (struct type *t)
 
       tf = XOBNEW (&m_storage, struct decl_field);
       tf->name = TYPE_TEMPLATE_ARGUMENT (t, i)->linkage_name ();
-      tf->type = SYMBOL_TYPE (TYPE_TEMPLATE_ARGUMENT (t, i));
+      tf->type = TYPE_TEMPLATE_ARGUMENT (t, i)->type ();
 
       slot = htab_find_slot (m_table.get (), tf, INSERT);
       if (*slot == NULL)
diff --git a/gdb/valops.c b/gdb/valops.c
index 9767b2c30e69..3a595125752f 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1387,7 +1387,7 @@ value_of_variable (struct symbol *var, const struct block *b)
 struct value *
 address_of_variable (struct symbol *var, const struct block *b)
 {
-  struct type *type = SYMBOL_TYPE (var);
+  struct type *type = var->type ();
   struct value *val;
 
   /* Evaluate it first; if the result is a memory address, we're fine.
@@ -2833,7 +2833,7 @@ find_overload_match (gdb::array_view<value *> args,
 	     the function part.  Do not try this for non-functions (e.g.
 	     function pointers).  */
 	  if (qualified_name
-	      && (check_typedef (SYMBOL_TYPE (fsym))->code ()
+	      && (check_typedef (fsym->type ())->code ()
 		  == TYPE_CODE_FUNC))
 	    {
 	      temp_func = cp_func_name (qualified_name);
@@ -3187,14 +3187,14 @@ find_oload_champ (gdb::array_view<value *> args,
 	      static_offset = oload_method_static_p (methods, ix);
 	    }
 	  else
-	    nparms = SYMBOL_TYPE (functions[ix])->num_fields ();
+	    nparms = functions[ix]->type ()->num_fields ();
 
 	  parm_types.reserve (nparms);
 	  for (jj = 0; jj < nparms; jj++)
 	    {
 	      type *t = (methods != NULL
 			 ? (TYPE_FN_FIELD_ARGS (methods, ix)[jj].type ())
-			 : SYMBOL_TYPE (functions[ix])->field (jj).type ());
+			 : functions[ix]->type ()->field (jj).type ());
 	      parm_types.push_back (t);
 	    }
 	}
@@ -3780,7 +3780,7 @@ value_maybe_namespace_elt (const struct type *curtype,
     return NULL;
   else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
 	   && (sym.symbol->aclass () == LOC_TYPEDEF))
-    result = allocate_value (SYMBOL_TYPE (sym.symbol));
+    result = allocate_value (sym.symbol->type ());
   else
     result = value_of_variable (sym.symbol, sym.block);
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index bdfbdbff96ff..d3e9ade72cb5 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1572,7 +1572,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
 	 patch_block_stabs (), unless the file was compiled without -g.  */
 
       sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced));
-      SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol;
+      sym->set_type (objfile_type (objfile)->nodebug_text_symbol);
 
       sym->set_aclass_index (LOC_BLOCK);
       sym2 = new (&objfile->objfile_obstack) symbol (*sym);
@@ -1585,7 +1585,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
   else
     {
       /* In case we can't figure out the type, provide default.  */
-      SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_data_symbol;
+      sym->set_type (objfile_type (objfile)->nodebug_data_symbol);
 
       switch (cs->c_sclass)
 	{
-- 
2.34.1


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

* [PATCH 33/33] gdb: remove SYMBOL_LINE macro
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (31 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 32/33] gdb: remove SYMBOL_TYPE macro Simon Marchi via Gdb-patches
@ 2022-01-28 12:45 ` Simon Marchi via Gdb-patches
  2022-02-06 15:22 ` [PATCH 00/33] Remove some more accessor macros Joel Brobecker via Gdb-patches
  33 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-01-28 12:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Add a getter and a setter for a symbol's line.  Remove the corresponding macro
and adjust all callers.

Change-Id: I229f2b8fcf938c07975f641361313a8761fad9a5
---
 gdb/ada-lang.c                      |  4 ++--
 gdb/compile/compile-c-symbols.c     |  2 +-
 gdb/compile/compile-cplus-symbols.c |  2 +-
 gdb/compile/compile-cplus-types.c   |  4 ++--
 gdb/dwarf2/read.c                   |  2 +-
 gdb/frame.c                         |  4 ++--
 gdb/guile/scm-symbol.c              |  2 +-
 gdb/linespec.c                      |  6 +++---
 gdb/mi/mi-symbol-cmds.c             |  4 ++--
 gdb/python/py-symbol.c              |  2 +-
 gdb/stabsread.c                     |  4 ++--
 gdb/symtab.c                        | 10 +++++-----
 gdb/symtab.h                        | 13 +++++++++++--
 13 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index fbeb176d5668..0dd83cda8e5a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3355,14 +3355,14 @@ See set/show multiple-symbol."));
 	  if (syms[i].symbol->is_objfile_owned ())
 	    symtab = symbol_symtab (syms[i].symbol);
 
-	  if (SYMBOL_LINE (syms[i].symbol) != 0 && symtab != NULL)
+	  if (syms[i].symbol->line () != 0 && symtab != NULL)
 	    {
 	      printf_filtered ("[%d] ", i + first_choice);
 	      ada_print_symbol_signature (gdb_stdout, syms[i].symbol,
 					  &type_print_raw_options);
 	      printf_filtered (_(" at %s:%d\n"),
 			       symtab_to_filename_for_display (symtab),
-			       SYMBOL_LINE (syms[i].symbol));
+			       syms[i].symbol->line ());
 	    }
 	  else if (is_enumeral
 		   && syms[i].symbol->type ()->name () != NULL)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 4f7a5b22da51..bb156024ffa1 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -58,7 +58,7 @@ convert_one_symbol (compile_c_instance *context,
 {
   gcc_type sym_type;
   const char *filename = symbol_symtab (sym.symbol)->filename;
-  unsigned short line = SYMBOL_LINE (sym.symbol);
+  unsigned short line = sym.symbol->line ();
 
   context->error_symbol_once (sym.symbol);
 
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 7cf5703dc71d..33febaccdfd8 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -49,7 +49,7 @@ convert_one_symbol (compile_cplus_instance *instance,
   /* Squash compiler warning.  */
   gcc_type sym_type = 0;
   const char *filename = symbol_symtab (sym.symbol)->filename;
-  unsigned short line = SYMBOL_LINE (sym.symbol);
+  unsigned short line = sym.symbol->line ();
 
   instance->error_symbol_once (sym.symbol);
 
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 198799669865..f0ac05f4f2aa 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -626,7 +626,7 @@ compile_cplus_convert_struct_or_union_members
 		    continue;
 		  }
 		const char *filename = symbol_symtab (sym.symbol)->filename;
-		unsigned int line = SYMBOL_LINE (sym.symbol);
+		unsigned int line = sym.symbol->line ();
 
 		physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol);
 		instance->plugin ().build_decl
@@ -765,7 +765,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
 	    }
 
 	  const char *filename = symbol_symtab (sym.symbol)->filename;
-	  unsigned int line = SYMBOL_LINE (sym.symbol);
+	  unsigned int line = sym.symbol->line ();
 	  CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
 	  const char *kind;
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3a22bcdd43d8..c063e7baa2b5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21727,7 +21727,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 			  inlined_func ? DW_AT_call_line : DW_AT_decl_line,
 			  cu);
       if (attr != nullptr)
-	SYMBOL_LINE (sym) = attr->constant_value (0);
+	sym->set_line (attr->constant_value (0));
 
       attr = dwarf2_attr (die,
 			  inlined_func ? DW_AT_call_file : DW_AT_decl_file,
diff --git a/gdb/frame.c b/gdb/frame.c
index 6e2f6b245a25..ce95cf8343bc 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2699,10 +2699,10 @@ find_frame_sal (frame_info *frame)
       gdb_assert (sym);
 
       symtab_and_line sal;
-      if (SYMBOL_LINE (sym) != 0)
+      if (sym->line () != 0)
 	{
 	  sal.symtab = symbol_symtab (sym);
-	  sal.line = SYMBOL_LINE (sym);
+	  sal.line = sym->line ();
 	}
       else
 	/* If the symbol does not have a location, we don't know where
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 4c28603fa636..dbe19865d4e2 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -510,7 +510,7 @@ gdbscm_symbol_line (SCM self)
     = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   const struct symbol *symbol = s_smob->symbol;
 
-  return scm_from_int (SYMBOL_LINE (symbol));
+  return scm_from_int (symbol->line ());
 }
 
 /* (symbol-value <gdb:symbol> [#:frame <gdb:frame>]) -> <gdb:value>
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1775c7c48f3e..b7b24f7d97a3 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4451,7 +4451,7 @@ symbol_to_sal (struct symtab_and_line *result,
 	  *result = {};
 	  result->symtab = symbol_symtab (sym);
 	  result->symbol = sym;
-	  result->line = SYMBOL_LINE (sym);
+	  result->line = sym->line ();
 	  result->pc = SYMBOL_VALUE_ADDRESS (sym);
 	  result->pspace = result->symtab->pspace ();
 	  result->explicit_pc = 1;
@@ -4461,13 +4461,13 @@ symbol_to_sal (struct symtab_and_line *result,
 	{
 	  /* Nothing.  */
 	}
-      else if (SYMBOL_LINE (sym) != 0)
+      else if (sym->line () != 0)
 	{
 	  /* We know its line number.  */
 	  *result = {};
 	  result->symtab = symbol_symtab (sym);
 	  result->symbol = sym;
-	  result->line = SYMBOL_LINE (sym);
+	  result->line = sym->line ();
 	  result->pc = SYMBOL_VALUE_ADDRESS (sym);
 	  result->pspace = result->symtab->pspace ();
 	  return 1;
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 6ed26d69269d..1b08854296c0 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -74,8 +74,8 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
 {
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
 
-  if (SYMBOL_LINE (sym) != 0)
-    uiout->field_unsigned ("line", SYMBOL_LINE (sym));
+  if (sym->line () != 0)
+    uiout->field_unsigned ("line", sym->line ());
   uiout->field_string ("name", sym->print_name ());
 
   if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN)
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 747da481a1bf..819a51f7e414 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -221,7 +221,7 @@ sympy_line (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  return gdb_py_object_from_longest (SYMBOL_LINE (symbol)).release ();
+  return gdb_py_object_from_longest (symbol->line ()).release ();
 }
 
 /* Implementation of gdb.Symbol.is_valid (self) -> Boolean.
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index d3a1ae990691..c6821f893cbd 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -693,11 +693,11 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
     {
       /* GCC 2.x puts the line number in desc.  SunOS apparently puts in the
 	 number of bytes occupied by a type or object, which we ignore.  */
-      SYMBOL_LINE (sym) = desc;
+      sym->set_line (desc);
     }
   else
     {
-      SYMBOL_LINE (sym) = 0;	/* unknown */
+      sym->set_line (0);	/* unknown */
     }
 
   sym->set_language (get_current_subfile ()->language,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8da86b613595..1a39372aad02 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3987,9 +3987,9 @@ skip_prologue_sal (struct symtab_and_line *sal)
       b = BLOCK_SUPERBLOCK (b);
     }
   if (function_block != NULL
-      && SYMBOL_LINE (BLOCK_FUNCTION (function_block)) != 0)
+      && BLOCK_FUNCTION (function_block)->line () != 0)
     {
-      sal->line = SYMBOL_LINE (BLOCK_FUNCTION (function_block));
+      sal->line = BLOCK_FUNCTION (function_block)->line ();
       sal->symtab = symbol_symtab (BLOCK_FUNCTION (function_block));
     }
 }
@@ -4850,7 +4850,7 @@ global_symbol_searcher::add_matching_symbols
 			      && sym->domain () != MODULE_DOMAIN)
 			  || (kind == MODULES_DOMAIN
 			      && sym->domain () == MODULE_DOMAIN
-			      && SYMBOL_LINE (sym) != 0))))
+			      && sym->line () != 0))))
 		{
 		  if (result_set->size () < m_max_search_results)
 		    {
@@ -5098,8 +5098,8 @@ print_symbol_info (enum search_domain kind,
 					  s_filename));
 	}
 
-      if (SYMBOL_LINE (sym) != 0)
-	printf_filtered ("%d:\t", SYMBOL_LINE (sym));
+      if (sym->line () != 0)
+	printf_filtered ("%d:\t", sym->line ());
       else
 	puts_filtered ("\t");
     }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3486803cca8e..d12eee6e9d8c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1213,6 +1213,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_type = type;
   }
 
+  unsigned short line () const
+  {
+    return m_line;
+  }
+
+  void set_line (unsigned short line)
+  {
+    m_line = line;
+  }
+
   /* Data type of value */
 
   struct type *m_type = nullptr;
@@ -1280,7 +1290,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
      to debug files longer than 64K lines?  What about machine
      generated programs?  */
 
-  unsigned short line = 0;
+  unsigned short m_line = 0;
 
   /* An arbitrary data pointer, allowing symbol readers to record
      additional information on a per-symbol basis.  Note that this data
@@ -1315,7 +1325,6 @@ struct block_symbol
 /* Note: There is no accessor macro for symbol.owner because it is
    "private".  */
 
-#define SYMBOL_LINE(symbol)		(symbol)->line
 #define SYMBOL_COMPUTED_OPS(symbol)	((symbol)->impl ().ops_computed)
 #define SYMBOL_BLOCK_OPS(symbol)	((symbol)->impl ().ops_block)
 #define SYMBOL_REGISTER_OPS(symbol)	((symbol)->impl ().ops_register)
-- 
2.34.1


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

* Re: [PATCH 00/33] Remove some more accessor macros
  2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
                   ` (32 preceding siblings ...)
  2022-01-28 12:45 ` [PATCH 33/33] gdb: remove SYMBOL_LINE macro Simon Marchi via Gdb-patches
@ 2022-02-06 15:22 ` Joel Brobecker via Gdb-patches
  2022-02-06 21:07   ` Simon Marchi via Gdb-patches
  33 siblings, 1 reply; 36+ messages in thread
From: Joel Brobecker via Gdb-patches @ 2022-02-06 15:22 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Joel Brobecker

Hi Simon,

On Fri, Jan 28, 2022 at 07:44:58AM -0500, Simon Marchi via Gdb-patches wrote:
> Most of this is mechanical, so probably doesn't need too much review.
> But there are some changes near the beginning that move compunit
> functions and methods, that's probably worth looking at.
> 
> Simon Marchi (33):
>   gdb: add getter/setter for compunit_symtab::objfile
>   gdb: remove COMPUNIT_OBJFILE macro
>   gdb: rename compunit_primary_filetab to
>     compunit_symtab::primary_filetab
>   gdb: add compunit_symtab::add_filetab method
>   gdb: add compunit_symtab::set_primary_filetab method
>   gdb: move compunit_filetabs to compunit_symtab::filetabs
>   gdb: remove COMPUNIT_FILETABS macro
>   gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter
>   gdb: remove COMPUNIT_PRODUCER macro, add getter/setter
>   gdb: remove COMPUNIT_DIRNAME macro, add getter/setter
>   gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter
>   gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
>   gdb: remove COMPUNIT_LOCATIONS_VALID macro, add getter/setter
>   gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID macro, add getter/setter
>   gdb: remove COMPUNIT_MACRO_TABLE macro, add getter/setter
>   gdb: remove SYMTAB_COMPUNIT macro, add getter/setter
>   gdb: remove SYMTAB_LINETABLE macro, add getter/setter
>   gdb: remove SYMTAB_LANGUAGE macro, add getter/setter
>   gdb: remove SYMTAB_BLOCKVECTOR macro
>   gdb: remove SYMTAB_OBJFILE macro
>   gdb: remove SYMTAB_PSPACE macro
>   gdb: remove SYMTAB_DIRNAME macro
>   gdb: remove SYMBOL_MATCHES_SEARCH_NAME
>   gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter
>   gdb: remove SYMBOL_IMPL macro, add method
>   gdb: remove SYMBOL_CLASS macro, add getter
>   gdb: remove SYMBOL_DOMAIN macro
>   gdb: remove SYMBOL_OBJFILE_OWNED macro
>   gdb: remove SYMBOL_IS_ARGUMENT macro
>   gdb: remove SYMBOL_INLINED macro
>   gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro
>   gdb: remove SYMBOL_TYPE macro
>   gdb: remove SYMBOL_LINE macro

Thanks for this patch series. I reviewed the compunit series untit
you started adding the getter/setter or eliminating the macros.
After that, I only scanned the patches (burp, 'scuse me!).

FWIW, those patches looked good to me.

-- 
Joel

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

* Re: [PATCH 00/33] Remove some more accessor macros
  2022-02-06 15:22 ` [PATCH 00/33] Remove some more accessor macros Joel Brobecker via Gdb-patches
@ 2022-02-06 21:07   ` Simon Marchi via Gdb-patches
  0 siblings, 0 replies; 36+ messages in thread
From: Simon Marchi via Gdb-patches @ 2022-02-06 21:07 UTC (permalink / raw)
  To: Joel Brobecker, Simon Marchi via Gdb-patches



On 2022-02-06 10:22, Joel Brobecker via Gdb-patches wrote:
> Hi Simon,
> 
> On Fri, Jan 28, 2022 at 07:44:58AM -0500, Simon Marchi via Gdb-patches wrote:
>> Most of this is mechanical, so probably doesn't need too much review.
>> But there are some changes near the beginning that move compunit
>> functions and methods, that's probably worth looking at.
>>
>> Simon Marchi (33):
>>   gdb: add getter/setter for compunit_symtab::objfile
>>   gdb: remove COMPUNIT_OBJFILE macro
>>   gdb: rename compunit_primary_filetab to
>>     compunit_symtab::primary_filetab
>>   gdb: add compunit_symtab::add_filetab method
>>   gdb: add compunit_symtab::set_primary_filetab method
>>   gdb: move compunit_filetabs to compunit_symtab::filetabs
>>   gdb: remove COMPUNIT_FILETABS macro
>>   gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter
>>   gdb: remove COMPUNIT_PRODUCER macro, add getter/setter
>>   gdb: remove COMPUNIT_DIRNAME macro, add getter/setter
>>   gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter
>>   gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
>>   gdb: remove COMPUNIT_LOCATIONS_VALID macro, add getter/setter
>>   gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID macro, add getter/setter
>>   gdb: remove COMPUNIT_MACRO_TABLE macro, add getter/setter
>>   gdb: remove SYMTAB_COMPUNIT macro, add getter/setter
>>   gdb: remove SYMTAB_LINETABLE macro, add getter/setter
>>   gdb: remove SYMTAB_LANGUAGE macro, add getter/setter
>>   gdb: remove SYMTAB_BLOCKVECTOR macro
>>   gdb: remove SYMTAB_OBJFILE macro
>>   gdb: remove SYMTAB_PSPACE macro
>>   gdb: remove SYMTAB_DIRNAME macro
>>   gdb: remove SYMBOL_MATCHES_SEARCH_NAME
>>   gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter
>>   gdb: remove SYMBOL_IMPL macro, add method
>>   gdb: remove SYMBOL_CLASS macro, add getter
>>   gdb: remove SYMBOL_DOMAIN macro
>>   gdb: remove SYMBOL_OBJFILE_OWNED macro
>>   gdb: remove SYMBOL_IS_ARGUMENT macro
>>   gdb: remove SYMBOL_INLINED macro
>>   gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro
>>   gdb: remove SYMBOL_TYPE macro
>>   gdb: remove SYMBOL_LINE macro
> 
> Thanks for this patch series. I reviewed the compunit series untit
> you started adding the getter/setter or eliminating the macros.
> After that, I only scanned the patches (burp, 'scuse me!).
> 
> FWIW, those patches looked good to me.
> 

Thanks for checking, I will push the series shortly.

Simon

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

end of thread, other threads:[~2022-02-06 21:08 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 12:44 [PATCH 00/33] Remove some more accessor macros Simon Marchi via Gdb-patches
2022-01-28 12:44 ` [PATCH 01/33] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 02/33] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 03/33] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 04/33] gdb: add compunit_symtab::add_filetab method Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 06/33] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 08/33] gdb: remove COMPUNIT_DEBUGFORMAT macro, add getter/setter Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 09/33] gdb: remove COMPUNIT_PRODUCER " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 10/33] gdb: remove COMPUNIT_DIRNAME " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 11/33] gdb: remove COMPUNIT_BLOCKVECTOR " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 12/33] gdb: remove COMPUNIT_BLOCK_LINE_SECTION " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 13/33] gdb: remove COMPUNIT_LOCATIONS_VALID " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 14/33] gdb: remove COMPUNIT_EPILOGUE_UNWIND_VALID " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 15/33] gdb: remove COMPUNIT_MACRO_TABLE " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 16/33] gdb: remove SYMTAB_COMPUNIT " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 17/33] gdb: remove SYMTAB_LINETABLE " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 18/33] gdb: remove SYMTAB_LANGUAGE " Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 19/33] gdb: remove SYMTAB_BLOCKVECTOR macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 20/33] gdb: remove SYMTAB_OBJFILE macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 21/33] gdb: remove SYMTAB_PSPACE macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 22/33] gdb: remove SYMTAB_DIRNAME macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 23/33] gdb: remove SYMBOL_MATCHES_SEARCH_NAME Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 24/33] gdb: remove SYMBOL_ACLASS_INDEX macro, add getter/setter Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 25/33] gdb: remove SYMBOL_IMPL macro, add method Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 26/33] gdb: remove SYMBOL_CLASS macro, add getter Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 27/33] gdb: remove SYMBOL_DOMAIN macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 29/33] gdb: remove SYMBOL_IS_ARGUMENT macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 30/33] gdb: remove SYMBOL_INLINED macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 31/33] gdb: remote SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 32/33] gdb: remove SYMBOL_TYPE macro Simon Marchi via Gdb-patches
2022-01-28 12:45 ` [PATCH 33/33] gdb: remove SYMBOL_LINE macro Simon Marchi via Gdb-patches
2022-02-06 15:22 ` [PATCH 00/33] Remove some more accessor macros Joel Brobecker via Gdb-patches
2022-02-06 21:07   ` Simon Marchi via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox