public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 28/33] gdb: remove SYMBOL_OBJFILE_OWNED macro
Date: Fri, 28 Jan 2022 07:45:26 -0500	[thread overview]
Message-ID: <20220128124531.2302941-29-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220128124531.2302941-1-simon.marchi@polymtl.ca>

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


  parent reply	other threads:[~2022-01-28 12:51 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220128124531.2302941-29-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).