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) <is_stub, set_is_stub>: New methods.
	(TYPE_STUB): Use type::is_stub, change all write call sites to
	use type::set_is_stub.

Change-Id: Ie935e8fe72c908afd8718411e83f4ff00c386bf3
This commit is contained in:
Simon Marchi
2020-09-14 11:07:58 -04:00
parent 20ce41238d
commit b4b7375953
7 changed files with 31 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <is_stub, set_is_stub>: New methods.
(TYPE_STUB): Use type::is_stub, change all write call sites to
use type::set_is_stub.
2020-09-14 Simon Marchi <simon.marchi@efficios.com> 2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (TYPE_NOSIGN): Remove, replace all uses with * gdbtypes.h (TYPE_NOSIGN): Remove, replace all uses with

View File

@ -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 Consider the case of an array, for instance, where the size
of the array is computed from the number of elements in of the array is computed from the number of elements in
our array multiplied by the size of its element. */ 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; return fixed_record_type;

View File

@ -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 /* ICC<14 does not output the required DW_AT_declaration on
incomplete types, but gives them a size of zero. */ incomplete types, but gives them a size of zero. */
TYPE_STUB (type) = 1; type->set_is_stub (true);
} }
else else
TYPE_STUB_SUPPORTED (type) = 1; TYPE_STUB_SUPPORTED (type) = 1;
if (die_is_declaration (die, cu)) if (die_is_declaration (die, cu))
TYPE_STUB (type) = 1; type->set_is_stub (true);
else if (attr == NULL && die->child == NULL else if (attr == NULL && die->child == NULL
&& producer_is_realview (cu->producer)) && producer_is_realview (cu->producer))
/* RealView does not output the required DW_AT_declaration /* RealView does not output the required DW_AT_declaration
on incomplete types. */ 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 /* We need to add the type field to the die immediately so we don't
infinitely recurse when dealing with pointers to the structure 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 Types. When another package uses such a type, an incomplete DIE
may be generated by the compiler. */ may be generated by the compiler. */
if (die_is_declaration (die, cu)) 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 /* If this type has an underlying type that is not a stub, then we
may use its attributes. We always use the "unsigned" attribute 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, such a type, we treat it as a stub, and try to resolve it later on,
when needed. */ when needed. */
if (cu->language == language_ada) if (cu->language == language_ada)
TYPE_STUB (type) = 1; type->set_is_stub (true);
return set_die_type (die, type, cu); return set_die_type (die, type, cu);
} }

View File

@ -867,7 +867,7 @@ allocate_stub_method (struct type *type)
mtype = alloc_type_copy (type); mtype = alloc_type_copy (type);
mtype->set_code (TYPE_CODE_METHOD); mtype->set_code (TYPE_CODE_METHOD);
TYPE_LENGTH (mtype) = 1; TYPE_LENGTH (mtype) = 1;
TYPE_STUB (mtype) = 1; mtype->set_is_stub (true);
TYPE_TARGET_TYPE (mtype) = type; TYPE_TARGET_TYPE (mtype) = type;
/* TYPE_SELF_TYPE (mtype) = unknown yet */ /* TYPE_SELF_TYPE (mtype) = unknown yet */
return mtype; 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). */ We want a method (TYPE_CODE_METHOD). */
smash_to_method_type (mtype, type, TYPE_TARGET_TYPE (mtype), smash_to_method_type (mtype, type, TYPE_TARGET_TYPE (mtype),
argtypes, argcount, p[-2] == '.'); argtypes, argcount, p[-2] == '.');
TYPE_STUB (mtype) = 0; mtype->set_is_stub (false);
TYPE_FN_FIELD_STUB (f, signature_id) = 0; TYPE_FN_FIELD_STUB (f, signature_id) = 0;
xfree (demangled_name); xfree (demangled_name);

View File

@ -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 if someone referenced a type that wasn't defined in a source file
via (struct sir_not_appearing_in_this_film *)). */ 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 /* * 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 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_unsigned : 1;
unsigned int m_flag_nosign : 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_target_stub : 1;
unsigned int flag_prototyped : 1; unsigned int flag_prototyped : 1;
unsigned int flag_varargs : 1; unsigned int flag_varargs : 1;
@ -1084,6 +1084,16 @@ struct type
this->main_type->m_flag_nosign = has_no_signedness; 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 /* * Return the dynamic property of the requested KIND from this type's
list of dynamic properties. */ list of dynamic properties. */
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;

View File

@ -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. */ do not create a symbol for it either. */
if (t->num_fields () == 0) if (t->num_fields () == 0)
{ {
TYPE_STUB (t) = 1; t->set_is_stub (true);
break; break;
} }
@ -4274,7 +4274,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
{ {
*pname = "<undefined>"; *pname = "<undefined>";
*tpp = init_type (mdebugread_objfile, type_code, 0, NULL); *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
TYPE_STUB (*tpp) = 1; (*tpp)->set_is_stub (true);
return result; return result;
} }

View File

@ -1650,7 +1650,7 @@ again:
type->set_code (code); type->set_code (code);
type->set_name (type_name); type->set_name (type_name);
INIT_CPLUS_SPECIFIC (type); INIT_CPLUS_SPECIFIC (type);
TYPE_STUB (type) = 1; type->set_is_stub (true);
add_undefined_type (type, typenums); add_undefined_type (type, typenums);
return type; return type;
@ -3439,7 +3439,7 @@ read_struct_type (const char **pp, struct type *type, enum type_code type_code,
INIT_CPLUS_SPECIFIC (type); INIT_CPLUS_SPECIFIC (type);
type->set_code (type_code); type->set_code (type_code);
TYPE_STUB (type) = 0; type->set_is_stub (false);
/* First comes the total size in bytes. */ /* 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; TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
set_length_in_type_chain (type); set_length_in_type_chain (type);
type->set_code (TYPE_CODE_ENUM); type->set_code (TYPE_CODE_ENUM);
TYPE_STUB (type) = 0; type->set_is_stub (false);
if (unsigned_enum) if (unsigned_enum)
type->set_is_unsigned (true); type->set_is_unsigned (true);
type->set_num_fields (nsyms); type->set_num_fields (nsyms);