gdb: add type::length / type::set_length

Add the `length` and `set_length` methods on `struct type`, in order to remove
the `TYPE_LENGTH` 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.

Change-Id: Id1090244f15c9856969b9be5006aefe8d8897ca4
This commit is contained in:
Simon Marchi
2022-07-30 12:01:12 -04:00
parent 27710edb4e
commit b6cdbc9a81
14 changed files with 119 additions and 116 deletions

View File

@@ -1472,7 +1472,7 @@ patch_type (struct type *type, struct type *real_type)
struct type *real_target = real_type->target_type ();
int field_size = real_target->num_fields () * sizeof (struct field);
TYPE_LENGTH (target) = TYPE_LENGTH (real_target);
target->set_length (real_target->length ());
target->set_num_fields (real_target->num_fields ());
field *fields = (struct field *) TYPE_ALLOC (target, field_size);
@@ -1887,7 +1887,7 @@ decode_base_type (struct coff_symbol *cs,
type->set_code (TYPE_CODE_STRUCT);
type->set_name (NULL);
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
@@ -1907,7 +1907,7 @@ decode_base_type (struct coff_symbol *cs,
type = coff_alloc_type (cs->c_symnum);
type->set_name (NULL);
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
@@ -1928,7 +1928,7 @@ decode_base_type (struct coff_symbol *cs,
type = coff_alloc_type (cs->c_symnum);
type->set_code (TYPE_CODE_ENUM);
type->set_name (NULL);
TYPE_LENGTH (type) = 0;
type->set_length (0);
type->set_fields (nullptr);
type->set_num_fields (0);
}
@@ -1996,7 +1996,7 @@ coff_read_struct_type (int index, int length, int lastsym,
type = coff_alloc_type (index);
type->set_code (TYPE_CODE_STRUCT);
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = length;
type->set_length (length);
while (!done && symnum < lastsym && symnum < nlist_nsyms_global)
{
@@ -2124,9 +2124,9 @@ coff_read_enum_type (int index, int length, int lastsym,
/* Now fill in the fields of the type-structure. */
if (length > 0)
TYPE_LENGTH (type) = length;
type->set_length (length);
else /* Assume ints. */
TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
type->set_length (gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT);
type->set_code (TYPE_CODE_ENUM);
type->set_num_fields (nsyms);
type->set_fields