Replace all uses of it by type::field.
Note that since type::field returns a reference to the field, some spots
are used to assign the whole field structure. See ctfread.c, function
attach_fields_to_type, for example. This is the same as was happening
with the macro, so I don't think it's a problem, but if anybody sees a
really nicer way to do this, now could be a good time to implement it.
gdb/ChangeLog:
* gdbtypes.h (TYPE_FIELD): Remove. Replace all uses with
type::field.
+2020-05-23 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * gdbtypes.h (TYPE_FIELD): Remove. Replace all uses with
+ type::field.
+
2020-05-23 Joel Brobecker <brobecker@adacore.com>
GDB 9.2 released.
for (int i = 0; i < type->num_fields (); i++)
{
/* Ignore any static fields. */
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
struct type *member = check_typedef (TYPE_FIELD_TYPE (type, i));
for (int i = 0; i < arg_type->num_fields (); i++)
{
/* Don't include static fields. */
- if (field_is_static (&TYPE_FIELD (arg_type, i)))
+ if (field_is_static (&arg_type->field (i)))
continue;
struct value *field = value_primitive_field (arg, 0, i, arg_type);
{
off = align_up (off, field_alignment (type, f))
+ TYPE_FIELD_BITPOS (type, f);
- SET_FIELD_BITPOS (TYPE_FIELD (rtype, f), off);
+ SET_FIELD_BITPOS (rtype->field (f), off);
TYPE_FIELD_BITSIZE (rtype, f) = 0;
if (ada_is_variant_part (type, f))
/* Ignore static fields, empty fields (for example nested
empty structures), and bitfields (these are handled by
the caller). */
- if (field_is_static (&TYPE_FIELD (type, i))
+ if (field_is_static (&type->field (i))
|| (TYPE_FIELD_BITSIZE (type, i) == 0
&& TYPE_LENGTH (subtype) == 0)
|| TYPE_FIELD_PACKED (type, i))
/* Ignore static fields, or empty fields, for example nested
empty structures.*/
- if (field_is_static (&TYPE_FIELD (type, i)) || bitsize == 0)
+ if (field_is_static (&type->field (i)) || bitsize == 0)
return;
if (subtype->code () == TYPE_CODE_STRUCT
{
int sub_count = 0;
- if (!field_is_static (&TYPE_FIELD (t, i)))
+ if (!field_is_static (&t->field (i)))
sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
base_type);
if (sub_count == -1)
for (i = type->num_fields () - 1; i >= nbases; i--)
{
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
{
gen_static_field (ax, &value, type, i);
if (value.optimized_out)
"this") will have been generated already, which will
be unnecessary but not harmful if the static field is
being handled as a global. */
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
{
gen_static_field (ax, value, type, i);
if (value->optimized_out)
if (t_field_name && strcmp (t_field_name, fieldname) == 0)
{
- if (field_is_static (&TYPE_FIELD (t, i)))
+ if (field_is_static (&t->field (i)))
{
gen_static_field (ax, value, t, i);
if (value->optimized_out)
TYPE_FIELD_PRIVATE (type, i), flags);
}
- bool is_static = field_is_static (&TYPE_FIELD (type, i));
+ bool is_static = field_is_static (&type->field (i));
if (flags->print_offsets)
podata->update (type, i, stream);
try
{
- if (field_is_static (&TYPE_FIELD (type, type_index)))
+ if (field_is_static (&type->field (type_index)))
result = value_static_field (type, type_index);
else
result = value_primitive_field (value, 0, type_index, type);
/* Copy the saved-up fields into the field vector. */
for (n = nfields; list; list = list->next)
- TYPE_FIELD (type, --n) = list->field;
+ type->field (--n) = list->field;
return type;
}
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
- SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
+ SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
int i;
for (i = 0; i < type->num_fields (); ++i)
- if (!field_is_static (&TYPE_FIELD (type, i)))
+ if (!field_is_static (&type->field (i)))
generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
TYPE_FIELD_TYPE (type, i), sym);
}
gcc_type field_type
= instance->convert_type (TYPE_FIELD_TYPE (type, i));
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
{
CORE_ADDR physaddr;
/* If requested, skip printing of static fields. */
if (!options->static_field_print
- && field_is_static (&TYPE_FIELD (type, i)))
+ && field_is_static (&type->field (i)))
continue;
if (fields_seen)
annotate_field_begin (TYPE_FIELD_TYPE (type, i));
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
{
fputs_filtered ("static ", stream);
fprintf_symbol_filtered (stream,
}
annotate_field_value ();
- if (!field_is_static (&TYPE_FIELD (type, i))
+ if (!field_is_static (&type->field (i))
&& TYPE_FIELD_PACKED (type, i))
{
struct value *v;
fputs_styled ("<optimized out or zero length>",
metadata_style.style (), stream);
}
- else if (field_is_static (&TYPE_FIELD (type, i)))
+ else if (field_is_static (&type->field (i)))
{
try
{
for (int i = 0; i < nfields; ++i)
{
struct ctf_nextfield &field = fip->fields[i];
- TYPE_FIELD (type, i) = field.field;
+ type->field (i) = field.field;
}
}
type->set_code (TYPE_CODE_STRUCT);
type->set_num_fields (3);
/* Save the field we care about. */
- struct field saved_field = TYPE_FIELD (type, 0);
+ struct field saved_field = type->field (0);
type->set_fields
((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)));
TYPE_FIELD_TYPE (type, 0) = field_type;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
- SET_FIELD_BITPOS (TYPE_FIELD (type, 0), bit_offset);
+ SET_FIELD_BITPOS (type->field (0), bit_offset);
/* The order of fields doesn't really matter, so put the real
field at index 1 and the data-less field at index 2. */
- TYPE_FIELD (type, 1) = saved_field;
+ type->field (1) = saved_field;
TYPE_FIELD_NAME (type, 1)
= rust_last_path_segment (TYPE_FIELD_TYPE (type, 1)->name ());
TYPE_FIELD_TYPE (type, 1)->set_name
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name;
- SET_FIELD_BITPOS (TYPE_FIELD (type, 2), 0);
+ SET_FIELD_BITPOS (type->field (2), 0);
/* Indicate that this is a variant type. */
static discriminant_range ranges[1] = { { 0, 0 } };
type->set_code (TYPE_CODE_STRUCT);
/* Make space for the discriminant field. */
- struct field *disr_field = &TYPE_FIELD (disr_type, 0);
+ struct field *disr_field = &disr_type->field (0);
field *new_fields
= (struct field *) TYPE_ZALLOC (type, ((type->num_fields () + 1)
* sizeof (struct field)));
type->set_num_fields (type->num_fields () + 1);
/* Install the discriminant at index 0 in the union. */
- TYPE_FIELD (type, 0) = *disr_field;
+ type->field (0) = *disr_field;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
= ((i < fip->baseclasses.size ()) ? fip->baseclasses[i]
: fip->fields[i - fip->baseclasses.size ()]);
- TYPE_FIELD (type, i) = field.field;
+ type->field (i) = field.field;
switch (field.accessibility)
{
case DW_ACCESS_private:
fieldno++;
/* Skip static fields. */
while (fieldno < struct_type->num_fields ()
- && field_is_static (&TYPE_FIELD (struct_type,
- fieldno)))
+ && field_is_static (&struct_type->field (fieldno)))
fieldno++;
if (fieldno >= struct_type->num_fields ())
error (_("too many initializers"));
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
- return {&TYPE_FIELD (type, i), TYPE_FIELD_BITPOS (type, i)};
+ return {&type->field (i), TYPE_FIELD_BITPOS (type, i)};
}
else if (!t_field_name || *t_field_name == '\0')
{
for (i = 0; i < type->num_fields (); ++i)
{
/* Static fields can be ignored here. */
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
/* If the field has dynamic type, then so does TYPE. */
if (is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
{
struct type *t;
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
t = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
if (!flags[i])
continue;
- TYPE_FIELD (resolved_type, out) = TYPE_FIELD (type, i);
+ resolved_type->field (out) = type->field (i);
++out;
}
}
unsigned new_bit_length;
struct property_addr_info pinfo;
- if (field_is_static (&TYPE_FIELD (resolved_type, i)))
+ if (field_is_static (&resolved_type->field (i)))
continue;
if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
CORE_ADDR addr;
if (dwarf2_evaluate_property (&prop, nullptr, addr_stack, &addr,
true))
- SET_FIELD_BITPOS (TYPE_FIELD (resolved_type, i),
+ SET_FIELD_BITPOS (resolved_type->field (i),
TARGET_CHAR_BIT * (addr - addr_stack->addr));
}
int number_of_non_static_fields = 0;
for (unsigned i = 0; i < type->num_fields (); ++i)
{
- if (!field_is_static (&TYPE_FIELD (type, i)))
+ if (!field_is_static (&type->field (i)))
{
number_of_non_static_fields++;
ULONGEST f_align = type_align (TYPE_FIELD_TYPE (type, i));
for (i = 0; i < type1->num_fields (); ++i)
{
- const struct field *field1 = &TYPE_FIELD (type1, i);
- const struct field *field2 = &TYPE_FIELD (type2, i);
+ const struct field *field1 = &type1->field (i);
+ const struct field *field2 = &type2->field (i);
if (FIELD_ARTIFICIAL (*field1) != FIELD_ARTIFICIAL (*field2)
|| FIELD_BITSIZE (*field1) != FIELD_BITSIZE (*field2)
switch (TYPE_FIELD_LOC_KIND (type, i))
{
case FIELD_LOC_KIND_BITPOS:
- SET_FIELD_BITPOS (TYPE_FIELD (new_type, i),
+ SET_FIELD_BITPOS (new_type->field (i),
TYPE_FIELD_BITPOS (type, i));
break;
case FIELD_LOC_KIND_ENUMVAL:
- SET_FIELD_ENUMVAL (TYPE_FIELD (new_type, i),
+ SET_FIELD_ENUMVAL (new_type->field (i),
TYPE_FIELD_ENUMVAL (type, i));
break;
case FIELD_LOC_KIND_PHYSADDR:
- SET_FIELD_PHYSADDR (TYPE_FIELD (new_type, i),
+ SET_FIELD_PHYSADDR (new_type->field (i),
TYPE_FIELD_STATIC_PHYSADDR (type, i));
break;
case FIELD_LOC_KIND_PHYSNAME:
- SET_FIELD_PHYSNAME (TYPE_FIELD (new_type, i),
+ SET_FIELD_PHYSNAME (new_type->field (i),
xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
i)));
break;
TYPE_FIELD_NAME (type, field_nr) = xstrdup (name);
TYPE_FIELD_TYPE (type, field_nr) = field_type;
- SET_FIELD_BITPOS (TYPE_FIELD (type, field_nr), start_bitpos);
+ SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
type->set_num_fields (type->num_fields () + 1);
}
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields[n]
-#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
-#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
-#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
-#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
-#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0)
+#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE((thistype)->field (n))
+#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME((thistype)->field (n))
+#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
+#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
+#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
+#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
+#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
+#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
+#define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
+#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
+#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
#define TYPE_FIELD_PRIVATE_BITS(thistype) \
TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
about recursive loops here, since we are only looking at members
of complete class type. Also ignore any static members. */
for (fieldnum = 0; fieldnum < type->num_fields (); fieldnum++)
- if (!field_is_static (&TYPE_FIELD (type, fieldnum)))
+ if (!field_is_static (&type->field (fieldnum)))
{
struct type *field_type = TYPE_FIELD_TYPE (type, fieldnum);
/* This should be non-NULL by construction. */
gdb_assert (type->fields () != NULL);
- return &TYPE_FIELD (type, f_smob->field_num);
+ return &type->field (f_smob->field_num);
}
\f
/* Type smob accessors. */
struct type *field_type;
/* We're only looking at normal fields. */
- if (field_is_static (&TYPE_FIELD (arg_type, i))
+ if (field_is_static (&arg_type->field (i))
|| (TYPE_FIELD_BITPOS (arg_type, i) % 8) != 0)
continue;
}
print_spaces_filtered (level + 4, stream);
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
fprintf_filtered (stream, "static ");
pascal_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 4, flags);
- if (!field_is_static (&TYPE_FIELD (type, i))
+ if (!field_is_static (&type->field (i))
&& TYPE_FIELD_PACKED (type, i))
{
/* It is a bitfield. This code does not attempt
{
/* If requested, skip printing of static fields. */
if (!options->pascal_static_field_print
- && field_is_static (&TYPE_FIELD (type, i)))
+ && field_is_static (&type->field (i)))
continue;
if (fields_seen)
fprintf_filtered (stream, ", ");
annotate_field_begin (TYPE_FIELD_TYPE (type, i));
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
{
fputs_filtered ("static ", stream);
fprintf_symbol_filtered (stream,
fputs_filtered (" = ", stream);
annotate_field_value ();
- if (!field_is_static (&TYPE_FIELD (type, i))
+ if (!field_is_static (&type->field (i))
&& TYPE_FIELD_PACKED (type, i))
{
struct value *v;
fputs_styled ("<optimized out or zero length>",
metadata_style.style (), stream);
}
- else if (field_is_static (&TYPE_FIELD (type, i)))
+ else if (field_is_static (&type->field (i)))
{
/* struct value *v = value_static_field (type, i);
v4.17 specific. */
{
LONGEST sub_count;
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
sub_count = ppc64_aggregate_candidate
if (PyObject_SetAttrString (result.get (), "parent_type", arg.get ()) < 0)
return NULL;
- if (!field_is_static (&TYPE_FIELD (type, field)))
+ if (!field_is_static (&type->field (field)))
{
const char *attrstring;
return false;
for (i = 0; i < type->num_fields (); ++i)
{
- if (!field_is_static (&TYPE_FIELD (type, i)))
+ if (!field_is_static (&type->field (i)))
{
char buf[20];
first_field = 1;
for (i = 0; i < type->num_fields (); ++i)
{
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
if (!first_field)
std::vector<int> fields;
for (int i = 0; i < type->num_fields (); ++i)
{
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
continue;
if (is_enum && TYPE_FIELD_ARTIFICIAL (type, i))
continue;
{
QUIT;
- gdb_assert (!field_is_static (&TYPE_FIELD (type, i)));
+ gdb_assert (!field_is_static (&type->field (i)));
gdb_assert (! (is_enum && TYPE_FIELD_ARTIFICIAL (type, i)));
if (flags->print_offsets)
bitpos = 0;
if (field1 != NULL)
{
- struct field *field = &TYPE_FIELD (result, i);
+ struct field *field = &result->field (i);
SET_FIELD_BITPOS (*field, bitpos);
bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT;
}
if (field2 != NULL)
{
- struct field *field = &TYPE_FIELD (result, i);
+ struct field *field = &result->field (i);
unsigned align = type_align (type2);
if (align != 0)
abort the unwrapping. */
for (int i = 0; i < type->num_fields (); i++)
{
- struct field f = TYPE_FIELD (type, i);
+ struct field f = type->field (i);
if (field_is_static (&f))
continue;
while (nfields-- > 0)
{
- TYPE_FIELD (type, nfields) = fip->list->field;
+ type->field (nfields) = fip->list->field;
switch (fip->list->visibility)
{
case VISIBILITY_PRIVATE:
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
- SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
+ SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
TYPE_FIELD_BITSIZE (type, n) = 0;
}
if (syms == osyms)
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{
is_a_field_of_this->type = type;
- is_a_field_of_this->field = &TYPE_FIELD (type, i);
+ is_a_field_of_this->field = &type->field (i);
return 1;
}
}
print_offset_data::update (struct type *type, unsigned int field_idx,
struct ui_file *stream)
{
- if (field_is_static (&TYPE_FIELD (type, field_idx)))
+ if (field_is_static (&type->field (field_idx)))
{
print_spaces_filtered (indentation, stream);
return;
{
struct value *v;
- if (field_is_static (&TYPE_FIELD (type, i)))
+ if (field_is_static (&type->field (i)))
v = value_static_field (type, i);
else
v = value_primitive_field (arg1, offset, i, type);
for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++)
{
- if (!field_is_static (&TYPE_FIELD (t, i))
+ if (!field_is_static (&t->field (i))
&& bitpos == TYPE_FIELD_BITPOS (t, i)
&& types_equal (ftype, TYPE_FIELD_TYPE (t, i)))
return value_primitive_field (*argp, 0, i, t);
if (t_field_name && strcmp (t_field_name, name) == 0)
{
- if (field_is_static (&TYPE_FIELD (t, i)))
+ if (field_is_static (&t->field (i)))
{
struct value *v = value_static_field (t, i);
if (want_address)
for (i = 0; i < count; i++)
{
TYPE_FIELD_NAME (type, i) = values[i].name;
- SET_FIELD_ENUMVAL (TYPE_FIELD (type, i), values[i].value);
+ SET_FIELD_ENUMVAL (type->field (i), values[i].value);
}
return type;