gdb: remove SYMBOL_OBJFILE_OWNED macro

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

Change-Id: Ib7ef3718d65553ae924ca04c3fd478b0f4f3147c
This commit is contained in:
Simon Marchi 2022-01-27 22:01:10 -05:00
parent 6c9c307c67
commit 7b3ecc7555
8 changed files with 27 additions and 18 deletions

View file

@ -3352,7 +3352,7 @@ See set/show multiple-symbol."));
&& SYMBOL_TYPE (syms[i].symbol)->code () == TYPE_CODE_ENUM); && SYMBOL_TYPE (syms[i].symbol)->code () == TYPE_CODE_ENUM);
struct symtab *symtab = NULL; struct symtab *symtab = NULL;
if (SYMBOL_OBJFILE_OWNED (syms[i].symbol)) if (syms[i].symbol->is_objfile_owned ())
symtab = symbol_symtab (syms[i].symbol); symtab = symbol_symtab (syms[i].symbol);
if (SYMBOL_LINE (syms[i].symbol) != 0 && symtab != NULL) 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. /* Symbols for builtin types don't have a block.
For now don't cache such symbols. */ For now don't cache such symbols. */
if (sym != NULL && !SYMBOL_OBJFILE_OWNED (sym)) if (sym != NULL && !sym->is_objfile_owned ())
return; return;
/* If the symbol is a local symbol, then do not cache it, as a search /* If the symbol is a local symbol, then do not cache it, as a search

View file

@ -101,7 +101,7 @@ syscm_get_symbol_map (struct symbol *symbol)
{ {
htab_t htab; htab_t htab;
if (SYMBOL_OBJFILE_OWNED (symbol)) if (symbol->is_objfile_owned ())
{ {
struct objfile *objfile = symbol_objfile (symbol); 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); = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol; const struct symbol *symbol = s_smob->symbol;
if (!SYMBOL_OBJFILE_OWNED (symbol)) if (!symbol->is_objfile_owned ())
return SCM_BOOL_F; return SCM_BOOL_F;
return stscm_scm_from_symtab (symbol_symtab (symbol)); return stscm_scm_from_symtab (symbol_symtab (symbol));
} }

View file

@ -998,7 +998,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
symbol->m_name = type->name (); symbol->m_name = type->name ();
symbol->set_language (lang, nullptr); symbol->set_language (lang, nullptr);
symbol->owner.arch = gdbarch; symbol->owner.arch = gdbarch;
SYMBOL_OBJFILE_OWNED (symbol) = 0; symbol->set_is_objfile_owned (0);
symbol->set_section_index (0); symbol->set_section_index (0);
SYMBOL_TYPE (symbol) = type; SYMBOL_TYPE (symbol) = type;
symbol->set_domain (VAR_DOMAIN); symbol->set_domain (VAR_DOMAIN);

View file

@ -1686,7 +1686,7 @@ info_address_command (const char *exp, int from_tty)
puts_filtered (sym->print_name ()); puts_filtered (sym->print_name ());
printf_filtered ("\" is "); printf_filtered ("\" is ");
val = SYMBOL_VALUE (sym); val = SYMBOL_VALUE (sym);
if (SYMBOL_OBJFILE_OWNED (sym)) if (sym->is_objfile_owned ())
section = sym->obj_section (symbol_objfile (sym)); section = sym->obj_section (symbol_objfile (sym));
else else
section = NULL; section = NULL;

View file

@ -88,7 +88,7 @@ sympy_get_symtab (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol); SYMPY_REQUIRE_VALID (self, symbol);
if (!SYMBOL_OBJFILE_OWNED (symbol)) if (!symbol->is_objfile_owned ())
Py_RETURN_NONE; Py_RETURN_NONE;
return symtab_to_symtab_object (symbol_symtab (symbol)); return symtab_to_symtab_object (symbol_symtab (symbol));
@ -302,7 +302,7 @@ set_symbol (symbol_object *obj, struct symbol *symbol)
{ {
obj->symbol = symbol; obj->symbol = symbol;
obj->prev = NULL; obj->prev = NULL;
if (SYMBOL_OBJFILE_OWNED (symbol) if (symbol->is_objfile_owned ()
&& symbol_symtab (symbol) != NULL) && symbol_symtab (symbol) != NULL)
{ {
struct objfile *objfile = symbol_objfile (symbol); struct objfile *objfile = symbol_objfile (symbol);
@ -348,7 +348,7 @@ sympy_dealloc (PyObject *obj)
if (sym_obj->prev) if (sym_obj->prev)
sym_obj->prev->next = sym_obj->next; sym_obj->prev->next = sym_obj->next;
else if (sym_obj->symbol != NULL else if (sym_obj->symbol != NULL
&& SYMBOL_OBJFILE_OWNED (sym_obj->symbol) && sym_obj->symbol->is_objfile_owned ()
&& symbol_symtab (sym_obj->symbol) != NULL) && symbol_symtab (sym_obj->symbol) != NULL)
{ {
set_objfile_data (symbol_objfile (sym_obj->symbol), set_objfile_data (symbol_objfile (sym_obj->symbol),

View file

@ -502,7 +502,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
{ {
struct obj_section *section; struct obj_section *section;
if (SYMBOL_OBJFILE_OWNED (symbol)) if (symbol->is_objfile_owned ())
section = symbol->obj_section (symbol_objfile (symbol)); section = symbol->obj_section (symbol_objfile (symbol));
else else
section = NULL; section = NULL;

View file

@ -1789,7 +1789,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
if (!sym) if (!sym)
return NULL; return NULL;
if (!SYMBOL_OBJFILE_OWNED (sym)) if (!sym->is_objfile_owned ())
return sym; return sym;
/* We either have an OBJFILE, or we can get at it from the sym's /* 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 * struct objfile *
symbol_objfile (const struct symbol *symbol) symbol_objfile (const struct symbol *symbol)
{ {
gdb_assert (SYMBOL_OBJFILE_OWNED (symbol)); gdb_assert (symbol->is_objfile_owned ());
return symbol->owner.symtab->objfile (); return symbol->owner.symtab->objfile ();
} }
@ -6543,7 +6543,7 @@ symbol_objfile (const struct symbol *symbol)
struct gdbarch * struct gdbarch *
symbol_arch (const struct symbol *symbol) symbol_arch (const struct symbol *symbol)
{ {
if (!SYMBOL_OBJFILE_OWNED (symbol)) if (!symbol->is_objfile_owned ())
return symbol->owner.arch; return symbol->owner.arch;
return symbol->owner.symtab->objfile ()->arch (); return symbol->owner.symtab->objfile ()->arch ();
} }
@ -6553,7 +6553,7 @@ symbol_arch (const struct symbol *symbol)
struct symtab * struct symtab *
symbol_symtab (const struct symbol *symbol) symbol_symtab (const struct symbol *symbol)
{ {
gdb_assert (SYMBOL_OBJFILE_OWNED (symbol)); gdb_assert (symbol->is_objfile_owned ());
return symbol->owner.symtab; return symbol->owner.symtab;
} }
@ -6562,7 +6562,7 @@ symbol_symtab (const struct symbol *symbol)
void void
symbol_set_symtab (struct symbol *symbol, struct symtab *symtab) 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; symbol->owner.symtab = symtab;
} }

View file

@ -1115,7 +1115,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
/* Class-initialization of bitfields is only allowed in C++20. */ /* Class-initialization of bitfields is only allowed in C++20. */
: m_domain (UNDEF_DOMAIN), : m_domain (UNDEF_DOMAIN),
m_aclass_index (0), m_aclass_index (0),
is_objfile_owned (1), m_is_objfile_owned (1),
is_argument (0), is_argument (0),
is_inlined (0), is_inlined (0),
maybe_copied (0), maybe_copied (0),
@ -1168,6 +1168,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_domain = domain; 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 */ /* Data type of value */
struct type *type = nullptr; 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. /* If non-zero then symbol is objfile-owned, use owner.symtab.
Otherwise symbol is arch-owned, use owner.arch. */ 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. */ /* Whether this is an argument. */
@ -1270,7 +1280,6 @@ struct block_symbol
/* Note: There is no accessor macro for symbol.owner because it is /* Note: There is no accessor macro for symbol.owner because it is
"private". */ "private". */
#define SYMBOL_OBJFILE_OWNED(symbol) ((symbol)->is_objfile_owned)
#define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument #define SYMBOL_IS_ARGUMENT(symbol) (symbol)->is_argument
#define SYMBOL_INLINED(symbol) (symbol)->is_inlined #define SYMBOL_INLINED(symbol) (symbol)->is_inlined
#define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \ #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \