gdb: rename type::{arch,objfile} -> type::{arch_owner,objfile_owner}

I think this makes the names of the methods clearer, especially for the
arch.  The type::arch method (which gets the arch owner, or NULL if the
type is not arch owned) is easily confused with the get_type_arch method
(which returns an arch no matter what).  The name "arch_owner" will make
it intuitive that the method returns NULL if the type is not arch-owned.

Also, this frees the type::arch name, so we will be able to morph the
get_type_arch function into the type::arch method.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <arch>: Rename to...
	<arch_owner>: ... this, update all users.
	<objfile>: Rename to...
	<objfile_owner>: ... this, update all users.

Change-Id: Ie7c28684c7b565adec05a7619c418c69429bd8c0
This commit is contained in:
Simon Marchi 2021-01-28 10:09:02 -05:00
parent cc3edc5274
commit 6ac373717c
12 changed files with 58 additions and 50 deletions

View file

@ -1,3 +1,10 @@
2021-01-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (struct type) <arch>: Rename to...
<arch_owner>: ... this, update all users.
<objfile>: Rename to...
<objfile_owner>: ... this, update all users.
2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com> 2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
* gdbcmd.h (execute_command_to_string): Update comment. * gdbcmd.h (execute_command_to_string): Update comment.

View file

@ -13269,8 +13269,8 @@ ada_operator_check (struct expression *exp, int pos,
/* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
if (type != nullptr && type->objfile () != nullptr if (type != nullptr && type->objfile_owner () != nullptr
&& objfile_func (type->objfile (), data)) && objfile_func (type->objfile_owner (), data))
return 1; return 1;
return 0; return 0;

View file

@ -165,9 +165,9 @@ convert_func (compile_c_instance *context, struct type *type)
if (target_type == NULL) if (target_type == NULL)
{ {
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
target_type = objfile_type (type->objfile ())->builtin_int; target_type = objfile_type (type->objfile_owner ())->builtin_int;
else else
target_type = builtin_type (type->arch ())->builtin_int; target_type = builtin_type (type->arch_owner ())->builtin_int;
warning (_("function has unknown return type; assuming int")); warning (_("function has unknown return type; assuming int"));
} }
@ -324,9 +324,9 @@ convert_type_basic (compile_c_instance *context, struct type *type)
built-in parser used to do, but at least warn. */ built-in parser used to do, but at least warn. */
struct type *fallback; struct type *fallback;
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
fallback = objfile_type (type->objfile ())->builtin_int; fallback = objfile_type (type->objfile_owner ())->builtin_int;
else else
fallback = builtin_type (type->arch ())->builtin_int; fallback = builtin_type (type->arch_owner ())->builtin_int;
warning (_("variable has unknown type; assuming int")); warning (_("variable has unknown type; assuming int"));
return convert_int (context, fallback); return convert_int (context, fallback);
} }

View file

@ -971,9 +971,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
if (target_type == nullptr) if (target_type == nullptr)
{ {
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
target_type = objfile_type (type->objfile ())->builtin_int; target_type = objfile_type (type->objfile_owner ())->builtin_int;
else else
target_type = builtin_type (type->arch ())->builtin_int; target_type = builtin_type (type->arch_owner ())->builtin_int;
warning (_("function has unknown return type; assuming int")); warning (_("function has unknown return type; assuming int"));
} }

View file

@ -227,9 +227,9 @@ struct type *
alloc_type_copy (const struct type *type) alloc_type_copy (const struct type *type)
{ {
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
return alloc_type (type->objfile ()); return alloc_type (type->objfile_owner ());
else else
return alloc_type_arch (type->arch ()); return alloc_type_arch (type->arch_owner ());
} }
/* If TYPE is gdbarch-associated, return that architecture. /* If TYPE is gdbarch-associated, return that architecture.
@ -241,9 +241,9 @@ get_type_arch (const struct type *type)
struct gdbarch *arch; struct gdbarch *arch;
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
arch = type->objfile ()->arch (); arch = type->objfile_owner ()->arch ();
else else
arch = type->arch (); arch = type->arch_owner ();
/* The ARCH can be NULL if TYPE is associated with neither an objfile nor /* The ARCH can be NULL if TYPE is associated with neither an objfile nor
a gdbarch, however, this is very rare, and even then, in most cases a gdbarch, however, this is very rare, and even then, in most cases
@ -293,7 +293,7 @@ alloc_type_instance (struct type *oldtype)
if (!oldtype->is_objfile_owned ()) if (!oldtype->is_objfile_owned ())
type = GDBARCH_OBSTACK_ZALLOC (get_type_arch (oldtype), struct type); type = GDBARCH_OBSTACK_ZALLOC (get_type_arch (oldtype), struct type);
else else
type = OBSTACK_ZALLOC (&oldtype->objfile ()->objfile_obstack, type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack,
struct type); struct type);
TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype); TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
@ -310,8 +310,8 @@ static void
smash_type (struct type *type) smash_type (struct type *type)
{ {
bool objfile_owned = type->is_objfile_owned (); bool objfile_owned = type->is_objfile_owned ();
objfile *objfile = type->objfile (); objfile *objfile = type->objfile_owner ();
gdbarch *arch = type->arch (); gdbarch *arch = type->arch_owner ();
memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type)); memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
@ -648,7 +648,7 @@ make_qualified_type (struct type *type, type_instance_flags new_flags,
as TYPE. Otherwise, we can't link it into TYPE's cv chain: as TYPE. Otherwise, we can't link it into TYPE's cv chain:
if one objfile is freed and the other kept, we'd have if one objfile is freed and the other kept, we'd have
dangling pointers. */ dangling pointers. */
gdb_assert (type->objfile () == storage->objfile ()); gdb_assert (type->objfile_owner () == storage->objfile_owner ());
ntype = storage; ntype = storage;
TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type); TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
@ -738,7 +738,7 @@ make_cv_type (int cnst, int voltl,
can't have inter-objfile pointers. The only thing to do is can't have inter-objfile pointers. The only thing to do is
to leave stub types as stub types, and look them up afresh by to leave stub types as stub types, and look them up afresh by
name each time you encounter them. */ name each time you encounter them. */
gdb_assert ((*typeptr)->objfile () == type->objfile ()); gdb_assert ((*typeptr)->objfile_owner () == type->objfile_owner ());
} }
ntype = make_qualified_type (type, new_flags, ntype = make_qualified_type (type, new_flags,
@ -804,7 +804,7 @@ replace_type (struct type *ntype, struct type *type)
the assignment of one type's main type structure to the other the assignment of one type's main type structure to the other
will produce a type with references to objects (names; field will produce a type with references to objects (names; field
lists; etc.) allocated on an objfile other than its own. */ lists; etc.) allocated on an objfile other than its own. */
gdb_assert (ntype->objfile () == type->objfile ()); gdb_assert (ntype->objfile_owner () == type->objfile_owner ());
*TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type); *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
@ -1430,9 +1430,9 @@ lookup_array_range_type (struct type *element_type,
struct type *range_type; struct type *range_type;
if (element_type->is_objfile_owned ()) if (element_type->is_objfile_owned ())
index_type = objfile_type (element_type->objfile ())->builtin_int; index_type = objfile_type (element_type->objfile_owner ())->builtin_int;
else else
index_type = builtin_type (element_type->arch ())->builtin_int; index_type = builtin_type (element_type->arch_owner ())->builtin_int;
range_type = create_static_range_type (NULL, index_type, range_type = create_static_range_type (NULL, index_type,
low_bound, high_bound); low_bound, high_bound);
@ -1681,7 +1681,7 @@ type_name_or_error (struct type *type)
return name; return name;
name = saved_type->name (); name = saved_type->name ();
objfile = saved_type->objfile (); objfile = saved_type->objfile_owner ();
error (_("Invalid anonymous type %s [in module %s], GCC PR debug/47510 bug?"), error (_("Invalid anonymous type %s [in module %s], GCC PR debug/47510 bug?"),
name ? name : "<anonymous>", name ? name : "<anonymous>",
objfile ? objfile_name (objfile) : "<arch>"); objfile ? objfile_name (objfile) : "<arch>");
@ -2027,7 +2027,7 @@ get_vptr_fieldno (struct type *type, struct type **basetypep)
{ {
/* If the type comes from a different objfile we can't cache /* If the type comes from a different objfile we can't cache
it, it may have a different lifetime. PR 2384 */ it, it may have a different lifetime. PR 2384 */
if (type->objfile () == basetype->objfile ()) if (type->objfile_owner () == basetype->objfile_owner ())
{ {
set_type_vptr_fieldno (type, fieldno); set_type_vptr_fieldno (type, fieldno);
set_type_vptr_basetype (type, basetype); set_type_vptr_basetype (type, basetype);
@ -2800,7 +2800,7 @@ type::add_dyn_prop (dynamic_prop_node_kind prop_kind, dynamic_prop prop)
gdb_assert (this->is_objfile_owned ()); gdb_assert (this->is_objfile_owned ());
temp = XOBNEW (&this->objfile ()->objfile_obstack, temp = XOBNEW (&this->objfile_owner ()->objfile_obstack,
struct dynamic_prop_list); struct dynamic_prop_list);
temp->prop_kind = prop_kind; temp->prop_kind = prop_kind;
temp->prop = prop; temp->prop = prop;
@ -2969,7 +2969,7 @@ check_typedef (struct type *type)
TYPE's objfile is pointless, too, since you'll have to TYPE's objfile is pointless, too, since you'll have to
move over any other types NEWTYPE refers to, which could move over any other types NEWTYPE refers to, which could
be an unbounded amount of stuff. */ be an unbounded amount of stuff. */
if (newtype->objfile () == type->objfile ()) if (newtype->objfile_owner () == type->objfile_owner ())
type = make_qualified_type (newtype, type->instance_flags (), type); type = make_qualified_type (newtype, type->instance_flags (), type);
else else
type = newtype; type = newtype;
@ -2995,7 +2995,7 @@ check_typedef (struct type *type)
/* Same as above for opaque types, we can replace the stub /* Same as above for opaque types, we can replace the stub
with the complete type only if they are in the same with the complete type only if they are in the same
objfile. */ objfile. */
if (SYMBOL_TYPE (sym)->objfile () == type->objfile ()) if (SYMBOL_TYPE (sym)->objfile_owner () == type->objfile_owner ())
type = make_qualified_type (SYMBOL_TYPE (sym), type = make_qualified_type (SYMBOL_TYPE (sym),
type->instance_flags (), type); type->instance_flags (), type);
else else
@ -5192,12 +5192,12 @@ recursive_dump_type (struct type *type, int spaces)
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
{ {
printf_filtered ("%*sobjfile ", spaces, ""); printf_filtered ("%*sobjfile ", spaces, "");
gdb_print_host_address (type->objfile (), gdb_stdout); gdb_print_host_address (type->objfile_owner (), gdb_stdout);
} }
else else
{ {
printf_filtered ("%*sgdbarch ", spaces, ""); printf_filtered ("%*sgdbarch ", spaces, "");
gdb_print_host_address (type->arch (), gdb_stdout); gdb_print_host_address (type->arch_owner (), gdb_stdout);
} }
printf_filtered ("\n"); printf_filtered ("\n");
printf_filtered ("%*starget_type ", spaces, ""); printf_filtered ("%*starget_type ", spaces, "");
@ -5497,7 +5497,7 @@ copy_type_recursive (struct objfile *objfile,
/* This type shouldn't be pointing to any types in other objfiles; /* This type shouldn't be pointing to any types in other objfiles;
if it did, the type might disappear unexpectedly. */ if it did, the type might disappear unexpectedly. */
gdb_assert (type->objfile () == objfile); gdb_assert (type->objfile_owner () == objfile);
struct type_pair pair (type, nullptr); struct type_pair pair (type, nullptr);
@ -5667,7 +5667,7 @@ copy_type (const struct type *type)
sizeof (struct main_type)); sizeof (struct main_type));
if (type->main_type->dyn_prop_list != NULL) if (type->main_type->dyn_prop_list != NULL)
new_type->main_type->dyn_prop_list new_type->main_type->dyn_prop_list
= copy_dynamic_prop_list (&type->objfile ()->objfile_obstack, = copy_dynamic_prop_list (&type->objfile_owner ()->objfile_obstack,
type->main_type->dyn_prop_list); type->main_type->dyn_prop_list);
return new_type; return new_type;
@ -5963,9 +5963,9 @@ allocate_fixed_point_type_info (struct type *type)
if (type->is_objfile_owned ()) if (type->is_objfile_owned ())
{ {
fixed_point_type_storage *storage fixed_point_type_storage *storage
= fixed_point_objfile_key.get (type->objfile ()); = fixed_point_objfile_key.get (type->objfile_owner ());
if (storage == nullptr) if (storage == nullptr)
storage = fixed_point_objfile_key.emplace (type->objfile ()); storage = fixed_point_objfile_key.emplace (type->objfile_owner ());
info = up.get (); info = up.get ();
storage->push_back (std::move (up)); storage->push_back (std::move (up));
} }

View file

@ -1263,7 +1263,7 @@ struct type
/* Return the objfile owner of this type. /* Return the objfile owner of this type.
Return nullptr if this type is not objfile-owned. */ Return nullptr if this type is not objfile-owned. */
struct objfile *objfile () const struct objfile *objfile_owner () const
{ {
if (!this->is_objfile_owned ()) if (!this->is_objfile_owned ())
return nullptr; return nullptr;
@ -1274,7 +1274,7 @@ struct type
/* Return the gdbarch owner of this type. /* Return the gdbarch owner of this type.
Return nullptr if this type is not gdbarch-owned. */ Return nullptr if this type is not gdbarch-owned. */
gdbarch *arch () const gdbarch *arch_owner () const
{ {
if (this->is_objfile_owned ()) if (this->is_objfile_owned ())
return nullptr; return nullptr;
@ -2240,8 +2240,8 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
#define TYPE_ALLOC(t,size) \ #define TYPE_ALLOC(t,size) \
(obstack_alloc (((t)->is_objfile_owned () \ (obstack_alloc (((t)->is_objfile_owned () \
? &((t)->objfile ()->objfile_obstack) \ ? &((t)->objfile_owner ()->objfile_obstack) \
: gdbarch_obstack ((t)->arch ())), \ : gdbarch_obstack ((t)->arch_owner ())), \
size)) size))

View file

@ -151,7 +151,7 @@ tyscm_eq_type_smob (const void *ap, const void *bp)
static htab_t static htab_t
tyscm_type_map (struct type *type) tyscm_type_map (struct type *type)
{ {
struct objfile *objfile = type->objfile (); struct objfile *objfile = type->objfile_owner ();
htab_t htab; htab_t htab;
if (objfile == NULL) if (objfile == NULL)
@ -351,7 +351,7 @@ tyscm_copy_type_recursive (void **slot, void *info)
{ {
type_smob *t_smob = (type_smob *) *slot; type_smob *t_smob = (type_smob *) *slot;
htab_t copied_types = (htab_t) info; htab_t copied_types = (htab_t) info;
struct objfile *objfile = t_smob->type->objfile (); struct objfile *objfile = t_smob->type->objfile_owner ();
htab_t htab; htab_t htab;
eqable_gdb_smob **new_slot; eqable_gdb_smob **new_slot;
type_smob t_smob_for_lookup; type_smob t_smob_for_lookup;

View file

@ -1037,7 +1037,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
struct symbol *symbol; struct symbol *symbol;
struct gdbarch *gdbarch; struct gdbarch *gdbarch;
gdb_assert (!type->is_objfile_owned ()); gdb_assert (!type->is_objfile_owned ());
gdbarch = type->arch (); gdbarch = type->arch_owner ();
symbol = new (gdbarch_obstack (gdbarch)) struct symbol (); symbol = new (gdbarch_obstack (gdbarch)) struct symbol ();
symbol->m_name = type->name (); symbol->m_name = type->name ();
symbol->set_language (lang, nullptr); symbol->set_language (lang, nullptr);

View file

@ -1320,7 +1320,7 @@ operator_check_standard (struct expression *exp, int pos,
for (arg = 0; arg < nargs; arg++) for (arg = 0; arg < nargs; arg++)
{ {
struct type *inst_type = elts[pos + 3 + arg].type; struct type *inst_type = elts[pos + 3 + arg].type;
struct objfile *inst_objfile = inst_type->objfile (); struct objfile *inst_objfile = inst_type->objfile_owner ();
if (inst_objfile && (*objfile_func) (inst_objfile, data)) if (inst_objfile && (*objfile_func) (inst_objfile, data))
return 1; return 1;
@ -1351,8 +1351,8 @@ operator_check_standard (struct expression *exp, int pos,
/* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */ /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
if (type != nullptr && type->objfile () != nullptr if (type != nullptr && type->objfile_owner () != nullptr
&& objfile_func (type->objfile (), data)) && objfile_func (type->objfile_owner (), data))
return 1; return 1;
if (objfile && (*objfile_func) (objfile, data)) if (objfile && (*objfile_func) (objfile, data))

View file

@ -418,7 +418,7 @@ static PyObject *
typy_get_objfile (PyObject *self, void *closure) typy_get_objfile (PyObject *self, void *closure)
{ {
struct type *type = ((type_object *) self)->type; struct type *type = ((type_object *) self)->type;
struct objfile *objfile = type->objfile (); struct objfile *objfile = type->objfile_owner ();
if (objfile == nullptr) if (objfile == nullptr)
Py_RETURN_NONE; Py_RETURN_NONE;
@ -1098,9 +1098,9 @@ set_type (type_object *obj, struct type *type)
{ {
obj->type = type; obj->type = type;
obj->prev = NULL; obj->prev = NULL;
if (type != nullptr && type->objfile () != nullptr) if (type != nullptr && type->objfile_owner () != nullptr)
{ {
struct objfile *objfile = type->objfile (); struct objfile *objfile = type->objfile_owner ();
obj->next = ((type_object *) obj->next = ((type_object *)
objfile_data (objfile, typy_objfile_data_key)); objfile_data (objfile, typy_objfile_data_key));
@ -1119,10 +1119,10 @@ typy_dealloc (PyObject *obj)
if (type->prev) if (type->prev)
type->prev->next = type->next; type->prev->next = type->next;
else if (type->type != nullptr && type->type->objfile () != nullptr) else if (type->type != nullptr && type->type->objfile_owner () != nullptr)
{ {
/* Must reset head of list. */ /* Must reset head of list. */
struct objfile *objfile = type->type->objfile (); struct objfile *objfile = type->type->objfile_owner ();
if (objfile) if (objfile)
set_objfile_data (objfile, typy_objfile_data_key, type->next); set_objfile_data (objfile, typy_objfile_data_key, type->next);

View file

@ -1825,7 +1825,7 @@ rust_operator_check (struct expression *exp, int pos,
case OP_AGGREGATE: case OP_AGGREGATE:
{ {
struct type *type = exp->elts[pos + 1].type; struct type *type = exp->elts[pos + 1].type;
struct objfile *objfile = type->objfile (); struct objfile *objfile = type->objfile_owner ();
if (objfile != NULL && (*objfile_func) (objfile, data)) if (objfile != NULL && (*objfile_func) (objfile, data))
return 1; return 1;

View file

@ -2514,10 +2514,10 @@ void
preserve_one_value (struct value *value, struct objfile *objfile, preserve_one_value (struct value *value, struct objfile *objfile,
htab_t copied_types) htab_t copied_types)
{ {
if (value->type->objfile () == objfile) if (value->type->objfile_owner () == objfile)
value->type = copy_type_recursive (objfile, value->type, copied_types); value->type = copy_type_recursive (objfile, value->type, copied_types);
if (value->enclosing_type->objfile () == objfile) if (value->enclosing_type->objfile_owner () == objfile)
value->enclosing_type = copy_type_recursive (objfile, value->enclosing_type = copy_type_recursive (objfile,
value->enclosing_type, value->enclosing_type,
copied_types); copied_types);
@ -2532,7 +2532,8 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
switch (var->kind) switch (var->kind)
{ {
case INTERNALVAR_INTEGER: case INTERNALVAR_INTEGER:
if (var->u.integer.type && var->u.integer.type->objfile () == objfile) if (var->u.integer.type
&& var->u.integer.type->objfile_owner () == objfile)
var->u.integer.type var->u.integer.type
= copy_type_recursive (objfile, var->u.integer.type, copied_types); = copy_type_recursive (objfile, var->u.integer.type, copied_types);
break; break;