From: Simon Marchi Date: Thu, 28 Jan 2021 15:09:02 +0000 (-0500) Subject: gdb: rename type::{arch,objfile} -> type::{arch_owner,objfile_owner} X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6ac373717c28cc2befebd1e926dc5fcf39dda39f;p=binutils-gdb.git 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) : Rename to... : ... this, update all users. : Rename to... : ... this, update all users. Change-Id: Ie7c28684c7b565adec05a7619c418c69429bd8c0 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 46ba66d7c40..88dfba7c5f0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-01-28 Simon Marchi + + * gdbtypes.h (struct type) : Rename to... + : ... this, update all users. + : Rename to... + : ... this, update all users. + 2021-01-28 Andrew Burgess * gdbcmd.h (execute_command_to_string): Update comment. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8d912402462..d0baf5a183f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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. */ - if (type != nullptr && type->objfile () != nullptr - && objfile_func (type->objfile (), data)) + if (type != nullptr && type->objfile_owner () != nullptr + && objfile_func (type->objfile_owner (), data)) return 1; return 0; diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 104e619f16d..eaeb83284d4 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -165,9 +165,9 @@ convert_func (compile_c_instance *context, struct type *type) if (target_type == NULL) { if (type->is_objfile_owned ()) - target_type = objfile_type (type->objfile ())->builtin_int; + target_type = objfile_type (type->objfile_owner ())->builtin_int; 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")); } @@ -324,9 +324,9 @@ convert_type_basic (compile_c_instance *context, struct type *type) built-in parser used to do, but at least warn. */ struct type *fallback; if (type->is_objfile_owned ()) - fallback = objfile_type (type->objfile ())->builtin_int; + fallback = objfile_type (type->objfile_owner ())->builtin_int; else - fallback = builtin_type (type->arch ())->builtin_int; + fallback = builtin_type (type->arch_owner ())->builtin_int; warning (_("variable has unknown type; assuming int")); return convert_int (context, fallback); } diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 0f32b0e1ade..d666ac3a83e 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -971,9 +971,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance, if (target_type == nullptr) { if (type->is_objfile_owned ()) - target_type = objfile_type (type->objfile ())->builtin_int; + target_type = objfile_type (type->objfile_owner ())->builtin_int; 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")); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b66b89c7e56..638c8a66af9 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -227,9 +227,9 @@ struct type * alloc_type_copy (const struct type *type) { if (type->is_objfile_owned ()) - return alloc_type (type->objfile ()); + return alloc_type (type->objfile_owner ()); else - return alloc_type_arch (type->arch ()); + return alloc_type_arch (type->arch_owner ()); } /* If TYPE is gdbarch-associated, return that architecture. @@ -241,9 +241,9 @@ get_type_arch (const struct type *type) struct gdbarch *arch; if (type->is_objfile_owned ()) - arch = type->objfile ()->arch (); + arch = type->objfile_owner ()->arch (); else - arch = type->arch (); + arch = type->arch_owner (); /* 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 @@ -293,7 +293,7 @@ alloc_type_instance (struct type *oldtype) if (!oldtype->is_objfile_owned ()) type = GDBARCH_OBSTACK_ZALLOC (get_type_arch (oldtype), struct type); else - type = OBSTACK_ZALLOC (&oldtype->objfile ()->objfile_obstack, + type = OBSTACK_ZALLOC (&oldtype->objfile_owner ()->objfile_obstack, struct type); TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype); @@ -310,8 +310,8 @@ static void smash_type (struct type *type) { bool objfile_owned = type->is_objfile_owned (); - objfile *objfile = type->objfile (); - gdbarch *arch = type->arch (); + objfile *objfile = type->objfile_owner (); + gdbarch *arch = type->arch_owner (); 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: if one objfile is freed and the other kept, we'd have dangling pointers. */ - gdb_assert (type->objfile () == storage->objfile ()); + gdb_assert (type->objfile_owner () == storage->objfile_owner ()); ntype = storage; 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 to leave stub types as stub types, and look them up afresh by 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, @@ -804,7 +804,7 @@ replace_type (struct type *ntype, struct type *type) the assignment of one type's main type structure to the other will produce a type with references to objects (names; field 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); @@ -1430,9 +1430,9 @@ lookup_array_range_type (struct type *element_type, struct type *range_type; 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 - 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, low_bound, high_bound); @@ -1681,7 +1681,7 @@ type_name_or_error (struct type *type) return 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?"), name ? name : "", objfile ? objfile_name (objfile) : ""); @@ -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 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_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 ()); - temp = XOBNEW (&this->objfile ()->objfile_obstack, + temp = XOBNEW (&this->objfile_owner ()->objfile_obstack, struct dynamic_prop_list); temp->prop_kind = prop_kind; temp->prop = prop; @@ -2969,7 +2969,7 @@ check_typedef (struct type *type) TYPE's objfile is pointless, too, since you'll have to move over any other types NEWTYPE refers to, which could 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); else type = newtype; @@ -2995,7 +2995,7 @@ 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 () == type->objfile ()) + if (SYMBOL_TYPE (sym)->objfile_owner () == type->objfile_owner ()) type = make_qualified_type (SYMBOL_TYPE (sym), type->instance_flags (), type); else @@ -5192,12 +5192,12 @@ recursive_dump_type (struct type *type, int spaces) if (type->is_objfile_owned ()) { printf_filtered ("%*sobjfile ", spaces, ""); - gdb_print_host_address (type->objfile (), gdb_stdout); + gdb_print_host_address (type->objfile_owner (), gdb_stdout); } else { 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 ("%*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; 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); @@ -5667,7 +5667,7 @@ copy_type (const struct type *type) sizeof (struct main_type)); if (type->main_type->dyn_prop_list != NULL) 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); return new_type; @@ -5963,9 +5963,9 @@ allocate_fixed_point_type_info (struct type *type) if (type->is_objfile_owned ()) { fixed_point_type_storage *storage - = fixed_point_objfile_key.get (type->objfile ()); + = fixed_point_objfile_key.get (type->objfile_owner ()); if (storage == nullptr) - storage = fixed_point_objfile_key.emplace (type->objfile ()); + storage = fixed_point_objfile_key.emplace (type->objfile_owner ()); info = up.get (); storage->push_back (std::move (up)); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2e0b01a37df..df3b84ba838 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1263,7 +1263,7 @@ struct type /* Return the objfile owner of this type. Return nullptr if this type is not objfile-owned. */ - struct objfile *objfile () const + struct objfile *objfile_owner () const { if (!this->is_objfile_owned ()) return nullptr; @@ -1274,7 +1274,7 @@ struct type /* Return the gdbarch owner of this type. Return nullptr if this type is not gdbarch-owned. */ - gdbarch *arch () const + gdbarch *arch_owner () const { if (this->is_objfile_owned ()) return nullptr; @@ -2240,8 +2240,8 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN]; #define TYPE_ALLOC(t,size) \ (obstack_alloc (((t)->is_objfile_owned () \ - ? &((t)->objfile ()->objfile_obstack) \ - : gdbarch_obstack ((t)->arch ())), \ + ? &((t)->objfile_owner ()->objfile_obstack) \ + : gdbarch_obstack ((t)->arch_owner ())), \ size)) diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 936639c8a47..dd45d8e8b35 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -151,7 +151,7 @@ tyscm_eq_type_smob (const void *ap, const void *bp) static htab_t tyscm_type_map (struct type *type) { - struct objfile *objfile = type->objfile (); + struct objfile *objfile = type->objfile_owner (); htab_t htab; if (objfile == NULL) @@ -351,7 +351,7 @@ tyscm_copy_type_recursive (void **slot, void *info) { type_smob *t_smob = (type_smob *) *slot; 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; eqable_gdb_smob **new_slot; type_smob t_smob_for_lookup; diff --git a/gdb/language.c b/gdb/language.c index 6b4be71c3f2..8dde5046264 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1037,7 +1037,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol struct symbol *symbol; struct gdbarch *gdbarch; gdb_assert (!type->is_objfile_owned ()); - gdbarch = type->arch (); + gdbarch = type->arch_owner (); symbol = new (gdbarch_obstack (gdbarch)) struct symbol (); symbol->m_name = type->name (); symbol->set_language (lang, nullptr); diff --git a/gdb/parse.c b/gdb/parse.c index 7fd520493ac..933960fa30c 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1320,7 +1320,7 @@ operator_check_standard (struct expression *exp, int pos, for (arg = 0; arg < nargs; arg++) { 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)) 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. */ - if (type != nullptr && type->objfile () != nullptr - && objfile_func (type->objfile (), data)) + if (type != nullptr && type->objfile_owner () != nullptr + && objfile_func (type->objfile_owner (), data)) return 1; if (objfile && (*objfile_func) (objfile, data)) diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 878304f716c..bf707078841 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -418,7 +418,7 @@ static PyObject * typy_get_objfile (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; - struct objfile *objfile = type->objfile (); + struct objfile *objfile = type->objfile_owner (); if (objfile == nullptr) Py_RETURN_NONE; @@ -1098,9 +1098,9 @@ set_type (type_object *obj, struct type *type) { obj->type = type; 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 *) objfile_data (objfile, typy_objfile_data_key)); @@ -1119,10 +1119,10 @@ typy_dealloc (PyObject *obj) if (type->prev) 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. */ - struct objfile *objfile = type->type->objfile (); + struct objfile *objfile = type->type->objfile_owner (); if (objfile) set_objfile_data (objfile, typy_objfile_data_key, type->next); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index fc572ce96ef..ca9a74903e8 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1825,7 +1825,7 @@ rust_operator_check (struct expression *exp, int pos, case OP_AGGREGATE: { 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)) return 1; diff --git a/gdb/value.c b/gdb/value.c index 6f4ee545311..3551b80ef9e 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2514,10 +2514,10 @@ void preserve_one_value (struct value *value, struct objfile *objfile, 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); - if (value->enclosing_type->objfile () == objfile) + if (value->enclosing_type->objfile_owner () == objfile) value->enclosing_type = copy_type_recursive (objfile, value->enclosing_type, copied_types); @@ -2532,7 +2532,8 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile, switch (var->kind) { 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 = copy_type_recursive (objfile, var->u.integer.type, copied_types); break;