From: Simon Marchi Date: Mon, 14 Sep 2020 15:07:58 +0000 (-0400) Subject: gdb: add type::is_stub / type::set_is_stub X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4b73759537ae830d8b48834b419b095561d4d4a;p=binutils-gdb.git gdb: add type::is_stub / type::set_is_stub Add the `is_stub` and `set_is_stub` methods on `struct type`, in order to remove the `TYPE_STUB` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) : New methods. (TYPE_STUB): Use type::is_stub, change all write call sites to use type::set_is_stub. Change-Id: Ie935e8fe72c908afd8718411e83f4ff00c386bf3 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6d46d5e5425..1b58171e0f6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-09-14 Simon Marchi + + * gdbtypes.h (struct type) : New methods. + (TYPE_STUB): Use type::is_stub, change all write call sites to + use type::set_is_stub. + 2020-09-14 Simon Marchi * gdbtypes.h (TYPE_NOSIGN): Remove, replace all uses with diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c014d1c4b98..c126f98ed1d 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8604,7 +8604,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, Consider the case of an array, for instance, where the size of the array is computed from the number of elements in our array multiplied by the size of its element. */ - TYPE_STUB (fixed_record_type) = 0; + fixed_record_type->set_is_stub (false); } } return fixed_record_type; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 267cf0f18a8..f17401e922a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16081,18 +16081,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) { /* ICC<14 does not output the required DW_AT_declaration on incomplete types, but gives them a size of zero. */ - TYPE_STUB (type) = 1; + type->set_is_stub (true); } else TYPE_STUB_SUPPORTED (type) = 1; if (die_is_declaration (die, cu)) - TYPE_STUB (type) = 1; + type->set_is_stub (true); else if (attr == NULL && die->child == NULL && producer_is_realview (cu->producer)) /* RealView does not output the required DW_AT_declaration on incomplete types. */ - TYPE_STUB (type) = 1; + type->set_is_stub (true); /* We need to add the type field to the die immediately so we don't infinitely recurse when dealing with pointers to the structure @@ -16631,7 +16631,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) Types. When another package uses such a type, an incomplete DIE may be generated by the compiler. */ if (die_is_declaration (die, cu)) - TYPE_STUB (type) = 1; + type->set_is_stub (true); /* If this type has an underlying type that is not a stub, then we may use its attributes. We always use the "unsigned" attribute @@ -18444,7 +18444,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu) such a type, we treat it as a stub, and try to resolve it later on, when needed. */ if (cu->language == language_ada) - TYPE_STUB (type) = 1; + type->set_is_stub (true); return set_die_type (die, type, cu); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 997bb09c184..687cfe096b7 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -867,7 +867,7 @@ allocate_stub_method (struct type *type) mtype = alloc_type_copy (type); mtype->set_code (TYPE_CODE_METHOD); TYPE_LENGTH (mtype) = 1; - TYPE_STUB (mtype) = 1; + mtype->set_is_stub (true); TYPE_TARGET_TYPE (mtype) = type; /* TYPE_SELF_TYPE (mtype) = unknown yet */ return mtype; @@ -3033,7 +3033,7 @@ check_stub_method (struct type *type, int method_id, int signature_id) We want a method (TYPE_CODE_METHOD). */ smash_to_method_type (mtype, type, TYPE_TARGET_TYPE (mtype), argtypes, argcount, p[-2] == '.'); - TYPE_STUB (mtype) = 0; + mtype->set_is_stub (false); TYPE_FN_FIELD_STUB (f, signature_id) = 0; xfree (demangled_name); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 0be0f5c5645..7739757d442 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -220,7 +220,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); if someone referenced a type that wasn't defined in a source file via (struct sir_not_appearing_in_this_film *)). */ -#define TYPE_STUB(t) (TYPE_MAIN_TYPE (t)->flag_stub) +#define TYPE_STUB(t) ((t)->is_stub ()) /* * The target type of this type is a stub type, and this type needs to be updated if it gets un-stubbed in check_typedef. Used for @@ -846,7 +846,7 @@ struct main_type unsigned int m_flag_unsigned : 1; unsigned int m_flag_nosign : 1; - unsigned int flag_stub : 1; + unsigned int m_flag_stub : 1; unsigned int flag_target_stub : 1; unsigned int flag_prototyped : 1; unsigned int flag_varargs : 1; @@ -1084,6 +1084,16 @@ struct type this->main_type->m_flag_nosign = has_no_signedness; } + bool is_stub () const + { + return this->main_type->m_flag_stub; + } + + void set_is_stub (bool is_stub) + { + this->main_type->m_flag_stub = is_stub; + } + /* * Return the dynamic property of the requested KIND from this type's list of dynamic properties. */ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4fd3de13e07..735f00864d9 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1086,7 +1086,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, do not create a symbol for it either. */ if (t->num_fields () == 0) { - TYPE_STUB (t) = 1; + t->set_is_stub (true); break; } @@ -4274,7 +4274,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, { *pname = ""; *tpp = init_type (mdebugread_objfile, type_code, 0, NULL); - TYPE_STUB (*tpp) = 1; + (*tpp)->set_is_stub (true); return result; } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 5f654e7ed24..ce4c6f1be31 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1650,7 +1650,7 @@ again: type->set_code (code); type->set_name (type_name); INIT_CPLUS_SPECIFIC (type); - TYPE_STUB (type) = 1; + type->set_is_stub (true); add_undefined_type (type, typenums); return type; @@ -3439,7 +3439,7 @@ read_struct_type (const char **pp, struct type *type, enum type_code type_code, INIT_CPLUS_SPECIFIC (type); type->set_code (type_code); - TYPE_STUB (type) = 0; + type->set_is_stub (false); /* First comes the total size in bytes. */ @@ -3614,7 +3614,7 @@ read_enum_type (const char **pp, struct type *type, TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT; set_length_in_type_chain (type); type->set_code (TYPE_CODE_ENUM); - TYPE_STUB (type) = 0; + type->set_is_stub (false); if (unsigned_enum) type->set_is_unsigned (true); type->set_num_fields (nsyms);