Replace with type::field + field::bitsize.
Change-Id: I2a24755a33683e4a2775a6d2a7b7a9ae7362e43a
Approved-By: Tom Tromey <tom@tromey.com>
{
type = desc_base_type (type);
- if (TYPE_FIELD_BITSIZE (type, 1) > 0)
- return TYPE_FIELD_BITSIZE (type, 1);
+ if (type->field (1).bitsize () > 0)
+ return type->field (1).bitsize ();
else
return 8 * ada_check_typedef (type->field (1).type ())->length ();
}
{
type = desc_base_type (type);
- if (TYPE_FIELD_BITSIZE (type, 0) > 0)
- return TYPE_FIELD_BITSIZE (type, 0);
+ if (type->field (0).bitsize () > 0)
+ return type->field (0).bitsize ();
else
return TARGET_CHAR_BIT * type->field (0).type ()->length ();
}
{
type = desc_base_type (type);
- if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0)
- return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2);
+ if (type->field (2 * i + which - 2).bitsize () > 0)
+ return type->field (2 * i + which - 2).bitsize ();
else
return 8 * type->field (2 * i + which - 2).type ()->length ();
}
if (lo < hi)
{
int array_bitsize =
- (hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0);
+ (hi - lo + 1) * elt_type->field (0).bitsize ();
elt_type->set_length ((array_bitsize + 7) / 8);
}
if (type->code () == TYPE_CODE_TYPEDEF)
type = ada_typedef_target_type (type);
/* Now we can see if the array elements are packed. */
- return TYPE_FIELD_BITSIZE (type, 0) > 0;
+ return type->field (0).bitsize () > 0;
}
return 0;
{
return (ada_is_constrained_packed_array_type (type)
|| (type->code () == TYPE_CODE_ARRAY
- && TYPE_FIELD_BITSIZE (type, 0) % 8 != 0));
+ && type->field (0).bitsize () % 8 != 0));
}
/* Given that TYPE encodes a packed array type (constrained or unconstrained),
fetches the array type. */
type = type->field (0).type ()->target_type ();
/* Now we can see if the array elements are packed. */
- return TYPE_FIELD_BITSIZE (type, 0);
+ return type->field (0).bitsize ();
}
if (sscanf (tail + sizeof ("___XP") - 1, "%ld", &bits) != 1)
if (elt_type->code () == TYPE_CODE_ARRAY)
{
LONGEST elt_len = recursively_update_array_bitsize (elt_type);
- LONGEST elt_bitsize = elt_len * TYPE_FIELD_BITSIZE (elt_type, 0);
+ LONGEST elt_bitsize = elt_len * elt_type->field (0).bitsize ();
type->field (0).set_bitsize (elt_bitsize);
type->set_length (((our_len * elt_bitsize + HOST_CHAR_BIT - 1)
for (i = 0; i < arity; i += 1)
{
if (elt_type->code () != TYPE_CODE_ARRAY
- || TYPE_FIELD_BITSIZE (elt_type, 0) == 0)
+ || elt_type->field (0).bitsize () == 0)
error
(_("attempt to do packed indexing of "
"something other than a packed array"));
if (idx < lowerbound || idx > upperbound)
lim_warning (_("packed array index %ld out of bounds"),
(long) idx);
- bits = TYPE_FIELD_BITSIZE (elt_type, 0);
+ bits = elt_type->field (0).bitsize ();
elt_total_bit_offset += (idx - lowerbound) * bits;
elt_type = ada_check_typedef (elt_type->target_type ());
}
elt_type = ada_check_typedef (elt->type ());
if (elt_type->code () == TYPE_CODE_ARRAY
- && TYPE_FIELD_BITSIZE (elt_type, 0) > 0)
+ && elt_type->field (0).bitsize () > 0)
return value_subscript_packed (elt, arity, ind);
for (k = 0; k < arity; k += 1)
= check_typedef (array_ind->enclosing_type ());
if (type->code () == TYPE_CODE_ARRAY
- && TYPE_FIELD_BITSIZE (type, 0) > 0)
+ && type->field (0).bitsize () > 0)
return value_subscript_packed (array_ind, arity, ind);
for (k = 0; k < arity; k += 1)
struct type *slice_type = create_array_type_with_stride
(alloc, type0->target_type (), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
- TYPE_FIELD_BITSIZE (type0, 0));
+ type0->field (0).bitsize ());
int base_low = ada_discrete_type_low_bound (type0->index_type ());
gdb::optional<LONGEST> base_low_pos, low_pos;
CORE_ADDR base;
base_low_pos = base_low;
}
- ULONGEST stride = TYPE_FIELD_BITSIZE (slice_type, 0) / 8;
+ ULONGEST stride = slice_type->field (0).bitsize () / 8;
if (stride == 0)
stride = type0->target_type ()->length ();
struct type *slice_type = create_array_type_with_stride
(alloc, type->target_type (), index_type,
type->dyn_prop (DYN_PROP_BYTE_STRIDE),
- TYPE_FIELD_BITSIZE (type, 0));
+ type->field (0).bitsize ());
gdb::optional<LONGEST> low_pos, high_pos;
/* Handle packed fields. It might be that the field is not packed
relative to its containing structure, but the structure itself is
packed; in this case we must take the bit-field path. */
- if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || arg1->bitpos () != 0)
+ if (arg_type->field (fieldno).bitsize () != 0 || arg1->bitpos () != 0)
{
int bit_pos = arg_type->field (fieldno).loc_bitpos ();
- int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno);
+ int bit_size = arg_type->field (fieldno).bitsize ();
return ada_value_primitive_packed_val (arg1,
arg1->contents ().data (),
else if (name != NULL && field_name_match (t_field_name, name))
{
- int bit_size = TYPE_FIELD_BITSIZE (type, i);
+ int bit_size = type->field (i).bitsize ();
if (field_type_p != NULL)
*field_type_p = type->field (i).type ();
would prevent us from printing this field appropriately. */
rtype->field (f).set_type (type->field (f).type ());
rtype->field (f).set_name (type->field (f).name ());
- if (TYPE_FIELD_BITSIZE (type, f) > 0)
+ if (type->field (f).bitsize () > 0)
{
- fld_bit_len = TYPE_FIELD_BITSIZE (type, f);
+ fld_bit_len = type->field (f).bitsize ();
rtype->field (f).set_bitsize (fld_bit_len);
}
else
bitsize of the array elements needs to be set again, and the array
length needs to be recomputed based on that bitsize. */
int len = result->length () / result->target_type ()->length ();
- int elt_bitsize = TYPE_FIELD_BITSIZE (type0, 0);
+ int elt_bitsize = type0->field (0).bitsize ();
- result->field (0).set_bitsize (TYPE_FIELD_BITSIZE (type0, 0));
+ result->field (0).set_bitsize (elt_bitsize);
result->set_length (len * elt_bitsize / HOST_CHAR_BIT);
if (result->length () * HOST_CHAR_BIT < len * elt_bitsize)
result->set_length (result->length () + 1);
(desc_base_type (callee->type ())))
callee = ada_coerce_to_simple_array (callee);
else if (callee->type ()->code () == TYPE_CODE_ARRAY
- && TYPE_FIELD_BITSIZE (callee->type (), 0) != 0)
+ && callee->type ()->field (0).bitsize () != 0)
/* This is a packed array that has already been fixed, and
therefore already coerced to a simple array. Nothing further
to do. */
gdb_printf (stream, ", ");
print_range (arr_type->index_type (), stream,
0 /* bounds_preferred_p */);
- if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
- bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
+ if (arr_type->field (0).bitsize () > 0)
+ bitsize = arr_type->field (0).bitsize ();
/* A multi-dimensional array is represented using a
sequence of array types. If one of these types has a
name, then it is not another dimension of the outer
gdb_printf (stream, ", ");
print_range_type (range_desc_type->field (k).type (),
stream, 0 /* bounds_preferred_p */);
- if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
- bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
+ if (arr_type->field (0).bitsize () > 0)
+ bitsize = arr_type->field (0).bitsize ();
}
}
}
unsigned int things_printed = 0;
unsigned len;
struct type *elttype, *index_type;
- unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0);
+ unsigned long bitsize = type->field (0).bitsize ();
LONGEST low = 0;
scoped_value_mark mark;
{
struct value *v;
int bit_pos = type->field (i).loc_bitpos ();
- int bit_size = TYPE_FIELD_BITSIZE (type, i);
+ int bit_size = type->field (i).bitsize ();
struct value_print_options opts;
v = ada_value_primitive_packed_val
if (val->entirely_optimized_out ())
val_print_optimized_out (val, stream);
- else if (TYPE_FIELD_BITSIZE (type, 0) > 0)
+ else if (type->field (0).bitsize () > 0)
{
const gdb_byte *valaddr = val->contents_for_printing ().data ();
int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
empty structures), and bitfields (these are handled by
the caller). */
if (type->field (i).is_static ()
- || (TYPE_FIELD_BITSIZE (type, i) == 0
+ || (type->field (i).bitsize () == 0
&& subtype->length () == 0)
|| TYPE_FIELD_PACKED (type, i))
continue;
{
struct type *subtype = check_typedef (type->field (i).type ());
enum amd64_reg_class subclass[2];
- int bitsize = TYPE_FIELD_BITSIZE (type, i);
+ int bitsize = type->field (i).bitsize ();
if (bitsize == 0)
bitsize = subtype->length () * 8;
/* Bitfields are not addressable. If the field bitsize is
zero, then the field is not packed. Hence it cannot be
a bitfield or any other packed type. */
- if (TYPE_FIELD_BITSIZE (type, i) == 0)
+ if (type->field (i).bitsize () == 0)
{
nRc = 1;
break;
+ type->field (fieldno).loc_bitpos ()),
(offset * TARGET_CHAR_BIT
+ type->field (fieldno).loc_bitpos ()
- + TYPE_FIELD_BITSIZE (type, fieldno)));
+ + type->field (fieldno).bitsize ()));
else
{
gen_offset (ax, offset
unnamed fields. This would lead to misleading
results if the compiler does not put out fields
for such things (I don't know what it does). */
- gdb_printf (stream, " : %d",
- TYPE_FIELD_BITSIZE (type, i));
+ gdb_printf (stream, " : %d", type->field (i).bitsize ());
}
gdb_printf (stream, ";\n");
}
language, &local_flags, podata);
gdb_printf (stream, " @%s",
plongest (type->field (i).loc_bitpos ()));
- if (TYPE_FIELD_BITSIZE (type, i) > 1)
+ if (type->field (i).bitsize () > 1)
{
gdb_printf (stream, "-%s",
plongest (type->field (i).loc_bitpos ()
- + TYPE_FIELD_BITSIZE (type, i)
+ + type->field (i).bitsize ()
- 1));
}
gdb_printf (stream, ";\n");
for (i = 0; i < type->num_fields (); ++i)
{
gcc_type field_type;
- unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
+ unsigned long bitsize = type->field (i).bitsize ();
field_type = context->convert_type (type->field (i).type ());
if (bitsize == 0)
}
else
{
- unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
+ unsigned long bitsize = type->field (i).bitsize ();
enum gcc_cp_symbol_kind field_flags = GCC_CP_SYMBOL_FIELD
| get_field_access_flag (type, i);
{
const char *reg_name = regs_type->field (fieldno).name ();
ULONGEST reg_bitpos = regs_type->field (fieldno).loc_bitpos ();
- ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
+ ULONGEST reg_bitsize = regs_type->field (fieldno).bitsize ();
ULONGEST reg_offset;
struct type *reg_type
= check_typedef (regs_type->field (fieldno).type ());
}
else if (val->bits_synthetic_pointer
(type->field (i).loc_bitpos (),
- TYPE_FIELD_BITSIZE (type, i)))
+ type->field (i).bitsize ()))
{
fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream);
if (val->type () != field_type)
val = value_cast (field_type, val);
- bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
+ bitsize = struct_type->field (fieldno).bitsize ();
bitpos = struct_type->field (fieldno).loc_bitpos ();
addr = struct_val->contents_writeable ().data () + bitpos / 8;
if (bitsize)
if (element_type->code () == TYPE_CODE_ARRAY
&& (stride != 0 || element_type->is_multi_dimensional ())
&& element_type->length () != 0
- && TYPE_FIELD_BITSIZE (element_type, 0) != 0
+ && element_type->field (0).bitsize () != 0
&& get_array_bounds (element_type, &low_bound, &high_bound)
&& high_bound >= low_bound)
type->field (0).set_bitsize
((high_bound - low_bound + 1)
- * TYPE_FIELD_BITSIZE (element_type, 0));
+ * element_type->field (0).bitsize ());
return true;
}
}
}
else
- bit_stride = TYPE_FIELD_BITSIZE (type, 0);
+ bit_stride = type->field (0).bitsize ();
type_allocator alloc (type, type_allocator::SMASH);
return create_array_type_with_stride (alloc, elt_type, range_type, NULL,
+ (type->field (idx).loc_bitpos ()
/ TARGET_CHAR_BIT));
- LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
+ LONGEST bitsize = type->field (idx).bitsize ();
LONGEST size = bitsize / 8;
if (size == 0)
size = type->field (idx).type ()->length ();
== FIELD_LOC_KIND_BITPOS);
new_bit_length = resolved_type->field (i).loc_bitpos ();
- if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
- new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
+ if (resolved_type->field (i).bitsize () != 0)
+ new_bit_length += resolved_type->field (i).bitsize ();
else
{
struct type *real_type
else
gdb_printf ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
idx, plongest (type->field (idx).loc_bitpos ()),
- TYPE_FIELD_BITSIZE (type, idx));
+ type->field (idx).bitsize ());
gdb_printf ("%s name '%s' (%s)\n",
host_address_to_string (type->field (idx).type ()),
type->field (idx).name () != NULL
{
new_type->field (i).set_is_artificial
(type->field (i).is_artificial ());
- new_type->field (i).set_bitsize (TYPE_FIELD_BITSIZE (type, i));
+ new_type->field (i).set_bitsize (type->field (i).bitsize ());
if (type->field (i).type ())
new_type->field (i).set_type
(copy_type_recursive (type->field (i).type (), copied_types));
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
-#define TYPE_FIELD_BITSIZE(thistype, n) ((thistype)->field (n).bitsize ())
#define TYPE_FIELD_PACKED(thistype, n) (((thistype)->field (n).bitsize ())!=0)
#define TYPE_FIELD_PRIVATE_BITS(thistype) \
unnamed fields. This would lead to misleading
results if the compiler does not put out fields
for such things (I don't know what it does). */
- gdb_printf (stream, " : %d",
- TYPE_FIELD_BITSIZE (type, i));
+ gdb_printf (stream, " : %d", type->field (i).bitsize ());
}
gdb_printf (stream, ";\n");
}
unnamed fields. This would lead to misleading
results if the compiler does not put out fields
for such things (I don't know what it does). */
- gdb_printf (stream, " : %d",
- TYPE_FIELD_BITSIZE (type, i));
+ gdb_printf (stream, " : %d", type->field (i).bitsize ());
}
gdb_printf (stream, ";\n");
}
}
else if (val->bits_synthetic_pointer
(type->field (i).loc_bitpos (),
- TYPE_FIELD_BITSIZE (type, i)))
+ type->field (i).bitsize ()))
{
fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream);
if (PyObject_SetAttrString (result.get (), "is_base_class", arg.get ()) < 0)
return NULL;
- arg = gdb_py_object_from_longest (TYPE_FIELD_BITSIZE (type, field));
+ arg = gdb_py_object_from_longest (type->field (field).bitsize ());
if (arg == NULL)
return NULL;
if (PyObject_SetAttrString (result.get (), "bitsize", arg.get ()) < 0)
|| offset_bitpos % TARGET_CHAR_BIT != 0)
{
/* We're dealing with a bitfield. Print the bit offset. */
- fieldsize_bit = TYPE_FIELD_BITSIZE (type, field_idx);
+ fieldsize_bit = type->field (field_idx).bitsize ();
unsigned real_bitpos = bitpos + offset_bitpos;
problematic place to notify the user of an internal error
though. Instead just fall through and print the field as an
int. */
- && TYPE_FIELD_BITSIZE (type, field) == 1)
+ && type->field (field).bitsize () == 1)
{
if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ()))
gdb_printf
}
else
{
- unsigned field_len = TYPE_FIELD_BITSIZE (type, field);
+ unsigned field_len = type->field (field).bitsize ();
ULONGEST field_val = val >> type->field (field).loc_bitpos ();
if (field_len < sizeof (ULONGEST) * TARGET_CHAR_BIT)
description correctly. */
check_typedef (type);
- if (TYPE_FIELD_BITSIZE (arg_type, fieldno))
+ if (arg_type->field (fieldno).bitsize ())
{
/* Handle packed fields.
LONGEST container_bitsize = type->length () * 8;
v = value::allocate_lazy (type);
- v->set_bitsize (TYPE_FIELD_BITSIZE (arg_type, fieldno));
+ v->set_bitsize (arg_type->field (fieldno).bitsize ());
if ((bitpos % container_bitsize) + v->bitsize () <= container_bitsize
&& type->length () <= (int) sizeof (LONGEST))
v->set_bitpos (bitpos % container_bitsize);
const struct value *val, LONGEST *result)
{
int bitpos = type->field (fieldno).loc_bitpos ();
- int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
+ int bitsize = type->field (fieldno).bitsize ();
struct type *field_type = type->field (fieldno).type ();
int bit_offset;
unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
{
int bitpos = type->field (fieldno).loc_bitpos ();
- int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
+ int bitsize = type->field (fieldno).bitsize ();
struct type *field_type = type->field (fieldno).type ();
return unpack_bits_as_long (field_type, valaddr, bitpos, bitsize);
LONGEST embedded_offset, const struct value *val)
{
int bitpos = type->field (fieldno).loc_bitpos ();
- int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
+ int bitsize = type->field (fieldno).bitsize ();
struct value *res_val = value::allocate (type->field (fieldno).type ());
val->unpack_bitfield (res_val, bitpos, bitsize, valaddr, embedded_offset);