gdb: remove TYPE_FIELD_BITSIZE

Replace with type::field + field::bitsize.

Change-Id: I2a24755a33683e4a2775a6d2a7b7a9ae7362e43a
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Simon Marchi
2023-08-31 11:46:27 -04:00
committed by Simon Marchi
parent 3be8c91910
commit 3757d2d44f
21 changed files with 65 additions and 69 deletions

View File

@@ -1881,8 +1881,8 @@ fat_pntr_bounds_bitsize (struct type *type)
{ {
type = desc_base_type (type); type = desc_base_type (type);
if (TYPE_FIELD_BITSIZE (type, 1) > 0) if (type->field (1).bitsize () > 0)
return TYPE_FIELD_BITSIZE (type, 1); return type->field (1).bitsize ();
else else
return 8 * ada_check_typedef (type->field (1).type ())->length (); return 8 * ada_check_typedef (type->field (1).type ())->length ();
} }
@@ -1947,8 +1947,8 @@ fat_pntr_data_bitsize (struct type *type)
{ {
type = desc_base_type (type); type = desc_base_type (type);
if (TYPE_FIELD_BITSIZE (type, 0) > 0) if (type->field (0).bitsize () > 0)
return TYPE_FIELD_BITSIZE (type, 0); return type->field (0).bitsize ();
else else
return TARGET_CHAR_BIT * type->field (0).type ()->length (); return TARGET_CHAR_BIT * type->field (0).type ()->length ();
} }
@@ -1986,8 +1986,8 @@ desc_bound_bitsize (struct type *type, int i, int which)
{ {
type = desc_base_type (type); type = desc_base_type (type);
if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0) if (type->field (2 * i + which - 2).bitsize () > 0)
return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2); return type->field (2 * i + which - 2).bitsize ();
else else
return 8 * type->field (2 * i + which - 2).type ()->length (); return 8 * type->field (2 * i + which - 2).type ()->length ();
} }
@@ -2151,7 +2151,7 @@ ada_type_of_array (struct value *arr, int bounds)
if (lo < hi) if (lo < hi)
{ {
int array_bitsize = 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); elt_type->set_length ((array_bitsize + 7) / 8);
} }
@@ -2269,7 +2269,7 @@ ada_is_unconstrained_packed_array_type (struct type *type)
if (type->code () == TYPE_CODE_TYPEDEF) if (type->code () == TYPE_CODE_TYPEDEF)
type = ada_typedef_target_type (type); type = ada_typedef_target_type (type);
/* Now we can see if the array elements are packed. */ /* 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 0;
@@ -2283,7 +2283,7 @@ ada_is_any_packed_array_type (struct type *type)
{ {
return (ada_is_constrained_packed_array_type (type) return (ada_is_constrained_packed_array_type (type)
|| (type->code () == TYPE_CODE_ARRAY || (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), /* Given that TYPE encodes a packed array type (constrained or unconstrained),
@@ -2317,7 +2317,7 @@ decode_packed_array_bitsize (struct type *type)
fetches the array type. */ fetches the array type. */
type = type->field (0).type ()->target_type (); type = type->field (0).type ()->target_type ();
/* Now we can see if the array elements are packed. */ /* 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 (sscanf (tail + sizeof ("___XP") - 1, "%ld", &bits) != 1)
@@ -2458,7 +2458,7 @@ recursively_update_array_bitsize (struct type *type)
if (elt_type->code () == TYPE_CODE_ARRAY) if (elt_type->code () == TYPE_CODE_ARRAY)
{ {
LONGEST elt_len = recursively_update_array_bitsize (elt_type); 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->field (0).set_bitsize (elt_bitsize);
type->set_length (((our_len * elt_bitsize + HOST_CHAR_BIT - 1) type->set_length (((our_len * elt_bitsize + HOST_CHAR_BIT - 1)
@@ -2556,7 +2556,7 @@ value_subscript_packed (struct value *arr, int arity, struct value **ind)
for (i = 0; i < arity; i += 1) for (i = 0; i < arity; i += 1)
{ {
if (elt_type->code () != TYPE_CODE_ARRAY if (elt_type->code () != TYPE_CODE_ARRAY
|| TYPE_FIELD_BITSIZE (elt_type, 0) == 0) || elt_type->field (0).bitsize () == 0)
error error
(_("attempt to do packed indexing of " (_("attempt to do packed indexing of "
"something other than a packed array")); "something other than a packed array"));
@@ -2576,7 +2576,7 @@ value_subscript_packed (struct value *arr, int arity, struct value **ind)
if (idx < lowerbound || idx > upperbound) if (idx < lowerbound || idx > upperbound)
lim_warning (_("packed array index %ld out of bounds"), lim_warning (_("packed array index %ld out of bounds"),
(long) idx); (long) idx);
bits = TYPE_FIELD_BITSIZE (elt_type, 0); bits = elt_type->field (0).bitsize ();
elt_total_bit_offset += (idx - lowerbound) * bits; elt_total_bit_offset += (idx - lowerbound) * bits;
elt_type = ada_check_typedef (elt_type->target_type ()); elt_type = ada_check_typedef (elt_type->target_type ());
} }
@@ -2992,7 +2992,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind)
elt_type = ada_check_typedef (elt->type ()); elt_type = ada_check_typedef (elt->type ());
if (elt_type->code () == TYPE_CODE_ARRAY 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); return value_subscript_packed (elt, arity, ind);
for (k = 0; k < arity; k += 1) for (k = 0; k < arity; k += 1)
@@ -3049,7 +3049,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
= check_typedef (array_ind->enclosing_type ()); = check_typedef (array_ind->enclosing_type ());
if (type->code () == TYPE_CODE_ARRAY 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); return value_subscript_packed (array_ind, arity, ind);
for (k = 0; k < arity; k += 1) for (k = 0; k < arity; k += 1)
@@ -3084,7 +3084,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
struct type *slice_type = create_array_type_with_stride struct type *slice_type = create_array_type_with_stride
(alloc, type0->target_type (), index_type, (alloc, type0->target_type (), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE), 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 ()); int base_low = ada_discrete_type_low_bound (type0->index_type ());
gdb::optional<LONGEST> base_low_pos, low_pos; gdb::optional<LONGEST> base_low_pos, low_pos;
CORE_ADDR base; CORE_ADDR base;
@@ -3099,7 +3099,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
base_low_pos = base_low; 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) if (stride == 0)
stride = type0->target_type ()->length (); stride = type0->target_type ()->length ();
@@ -3119,7 +3119,7 @@ ada_value_slice (struct value *array, int low, int high)
struct type *slice_type = create_array_type_with_stride struct type *slice_type = create_array_type_with_stride
(alloc, type->target_type (), index_type, (alloc, type->target_type (), index_type,
type->dyn_prop (DYN_PROP_BYTE_STRIDE), type->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type, 0)); type->field (0).bitsize ());
gdb::optional<LONGEST> low_pos, high_pos; gdb::optional<LONGEST> low_pos, high_pos;
@@ -6886,10 +6886,10 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
/* Handle packed fields. It might be that the field is not packed /* Handle packed fields. It might be that the field is not packed
relative to its containing structure, but the structure itself is relative to its containing structure, but the structure itself is
packed; in this case we must take the bit-field path. */ 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_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, return ada_value_primitive_packed_val (arg1,
arg1->contents ().data (), arg1->contents ().data (),
@@ -7018,7 +7018,7 @@ find_struct_field (const char *name, struct type *type, int offset,
else if (name != NULL && field_name_match (t_field_name, name)) 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) if (field_type_p != NULL)
*field_type_p = type->field (i).type (); *field_type_p = type->field (i).type ();
@@ -7866,9 +7866,9 @@ ada_template_to_fixed_record_type_1 (struct type *type,
would prevent us from printing this field appropriately. */ would prevent us from printing this field appropriately. */
rtype->field (f).set_type (type->field (f).type ()); rtype->field (f).set_type (type->field (f).type ());
rtype->field (f).set_name (type->field (f).name ()); 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); rtype->field (f).set_bitsize (fld_bit_len);
} }
else else
@@ -8409,9 +8409,9 @@ to_fixed_array_type (struct type *type0, struct value *dval,
bitsize of the array elements needs to be set again, and the array bitsize of the array elements needs to be set again, and the array
length needs to be recomputed based on that bitsize. */ length needs to be recomputed based on that bitsize. */
int len = result->length () / result->target_type ()->length (); 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); result->set_length (len * elt_bitsize / HOST_CHAR_BIT);
if (result->length () * HOST_CHAR_BIT < len * elt_bitsize) if (result->length () * HOST_CHAR_BIT < len * elt_bitsize)
result->set_length (result->length () + 1); result->set_length (result->length () + 1);
@@ -11111,7 +11111,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
(desc_base_type (callee->type ()))) (desc_base_type (callee->type ())))
callee = ada_coerce_to_simple_array (callee); callee = ada_coerce_to_simple_array (callee);
else if (callee->type ()->code () == TYPE_CODE_ARRAY 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 /* This is a packed array that has already been fixed, and
therefore already coerced to a simple array. Nothing further therefore already coerced to a simple array. Nothing further
to do. */ to do. */

View File

@@ -383,8 +383,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
gdb_printf (stream, ", "); gdb_printf (stream, ", ");
print_range (arr_type->index_type (), stream, print_range (arr_type->index_type (), stream,
0 /* bounds_preferred_p */); 0 /* bounds_preferred_p */);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0) if (arr_type->field (0).bitsize () > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); bitsize = arr_type->field (0).bitsize ();
/* A multi-dimensional array is represented using a /* A multi-dimensional array is represented using a
sequence of array types. If one of these types has a sequence of array types. If one of these types has a
name, then it is not another dimension of the outer name, then it is not another dimension of the outer
@@ -408,8 +408,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
gdb_printf (stream, ", "); gdb_printf (stream, ", ");
print_range_type (range_desc_type->field (k).type (), print_range_type (range_desc_type->field (k).type (),
stream, 0 /* bounds_preferred_p */); stream, 0 /* bounds_preferred_p */);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0) if (arr_type->field (0).bitsize () > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); bitsize = arr_type->field (0).bitsize ();
} }
} }
} }

View File

@@ -117,7 +117,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
unsigned int things_printed = 0; unsigned int things_printed = 0;
unsigned len; unsigned len;
struct type *elttype, *index_type; struct type *elttype, *index_type;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0); unsigned long bitsize = type->field (0).bitsize ();
LONGEST low = 0; LONGEST low = 0;
scoped_value_mark mark; scoped_value_mark mark;
@@ -628,7 +628,7 @@ print_field_values (struct value *value, struct value *outer_value,
{ {
struct value *v; struct value *v;
int bit_pos = type->field (i).loc_bitpos (); 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; struct value_print_options opts;
v = ada_value_primitive_packed_val v = ada_value_primitive_packed_val
@@ -883,7 +883,7 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
if (val->entirely_optimized_out ()) if (val->entirely_optimized_out ())
val_print_optimized_out (val, stream); 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 (); const gdb_byte *valaddr = val->contents_for_printing ().data ();
int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;

View File

@@ -558,7 +558,7 @@ amd64_has_unaligned_fields (struct type *type)
empty structures), and bitfields (these are handled by empty structures), and bitfields (these are handled by
the caller). */ the caller). */
if (type->field (i).is_static () if (type->field (i).is_static ()
|| (TYPE_FIELD_BITSIZE (type, i) == 0 || (type->field (i).bitsize () == 0
&& subtype->length () == 0) && subtype->length () == 0)
|| TYPE_FIELD_PACKED (type, i)) || TYPE_FIELD_PACKED (type, i))
continue; continue;
@@ -594,7 +594,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
{ {
struct type *subtype = check_typedef (type->field (i).type ()); struct type *subtype = check_typedef (type->field (i).type ());
enum amd64_reg_class subclass[2]; enum amd64_reg_class subclass[2];
int bitsize = TYPE_FIELD_BITSIZE (type, i); int bitsize = type->field (i).bitsize ();
if (bitsize == 0) if (bitsize == 0)
bitsize = subtype->length () * 8; bitsize = subtype->length () * 8;

View File

@@ -9109,7 +9109,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
/* Bitfields are not addressable. If the field bitsize is /* Bitfields are not addressable. If the field bitsize is
zero, then the field is not packed. Hence it cannot be zero, then the field is not packed. Hence it cannot be
a bitfield or any other packed type. */ a bitfield or any other packed type. */
if (TYPE_FIELD_BITSIZE (type, i) == 0) if (type->field (i).bitsize () == 0)
{ {
nRc = 1; nRc = 1;
break; break;

View File

@@ -1323,7 +1323,7 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
+ type->field (fieldno).loc_bitpos ()), + type->field (fieldno).loc_bitpos ()),
(offset * TARGET_CHAR_BIT (offset * TARGET_CHAR_BIT
+ type->field (fieldno).loc_bitpos () + type->field (fieldno).loc_bitpos ()
+ TYPE_FIELD_BITSIZE (type, fieldno))); + type->field (fieldno).bitsize ()));
else else
{ {
gen_offset (ax, offset gen_offset (ax, offset

View File

@@ -1161,8 +1161,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
unnamed fields. This would lead to misleading unnamed fields. This would lead to misleading
results if the compiler does not put out fields results if the compiler does not put out fields
for such things (I don't know what it does). */ for such things (I don't know what it does). */
gdb_printf (stream, " : %d", gdb_printf (stream, " : %d", type->field (i).bitsize ());
TYPE_FIELD_BITSIZE (type, i));
} }
gdb_printf (stream, ";\n"); gdb_printf (stream, ";\n");
} }
@@ -1591,11 +1590,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
language, &local_flags, podata); language, &local_flags, podata);
gdb_printf (stream, " @%s", gdb_printf (stream, " @%s",
plongest (type->field (i).loc_bitpos ())); plongest (type->field (i).loc_bitpos ()));
if (TYPE_FIELD_BITSIZE (type, i) > 1) if (type->field (i).bitsize () > 1)
{ {
gdb_printf (stream, "-%s", gdb_printf (stream, "-%s",
plongest (type->field (i).loc_bitpos () plongest (type->field (i).loc_bitpos ()
+ TYPE_FIELD_BITSIZE (type, i) + type->field (i).bitsize ()
- 1)); - 1));
} }
gdb_printf (stream, ";\n"); gdb_printf (stream, ";\n");

View File

@@ -106,7 +106,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
for (i = 0; i < type->num_fields (); ++i) for (i = 0; i < type->num_fields (); ++i)
{ {
gcc_type field_type; 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 ()); field_type = context->convert_type (type->field (i).type ());
if (bitsize == 0) if (bitsize == 0)

View File

@@ -642,7 +642,7 @@ compile_cplus_convert_struct_or_union_members
} }
else 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 enum gcc_cp_symbol_kind field_flags = GCC_CP_SYMBOL_FIELD
| get_field_access_flag (type, i); | get_field_access_flag (type, i);

View File

@@ -553,7 +553,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
{ {
const char *reg_name = regs_type->field (fieldno).name (); const char *reg_name = regs_type->field (fieldno).name ();
ULONGEST reg_bitpos = regs_type->field (fieldno).loc_bitpos (); 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; ULONGEST reg_offset;
struct type *reg_type struct type *reg_type
= check_typedef (regs_type->field (fieldno).type ()); = check_typedef (regs_type->field (fieldno).type ());

View File

@@ -272,7 +272,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
} }
else if (val->bits_synthetic_pointer else if (val->bits_synthetic_pointer
(type->field (i).loc_bitpos (), (type->field (i).loc_bitpos (),
TYPE_FIELD_BITSIZE (type, i))) type->field (i).bitsize ()))
{ {
fputs_styled (_("<synthetic pointer>"), fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream); metadata_style.style (), stream);

View File

@@ -2383,7 +2383,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
if (val->type () != field_type) if (val->type () != field_type)
val = value_cast (field_type, val); 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 (); bitpos = struct_type->field (fieldno).loc_bitpos ();
addr = struct_val->contents_writeable ().data () + bitpos / 8; addr = struct_val->contents_writeable ().data () + bitpos / 8;
if (bitsize) if (bitsize)

View File

@@ -1317,12 +1317,12 @@ update_static_array_size (struct type *type)
if (element_type->code () == TYPE_CODE_ARRAY if (element_type->code () == TYPE_CODE_ARRAY
&& (stride != 0 || element_type->is_multi_dimensional ()) && (stride != 0 || element_type->is_multi_dimensional ())
&& element_type->length () != 0 && 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) && get_array_bounds (element_type, &low_bound, &high_bound)
&& high_bound >= low_bound) && high_bound >= low_bound)
type->field (0).set_bitsize type->field (0).set_bitsize
((high_bound - low_bound + 1) ((high_bound - low_bound + 1)
* TYPE_FIELD_BITSIZE (element_type, 0)); * element_type->field (0).bitsize ());
return true; return true;
} }
@@ -2330,7 +2330,7 @@ resolve_dynamic_array_or_string_1 (struct type *type,
} }
} }
else else
bit_stride = TYPE_FIELD_BITSIZE (type, 0); bit_stride = type->field (0).bitsize ();
type_allocator alloc (type, type_allocator::SMASH); type_allocator alloc (type, type_allocator::SMASH);
return create_array_type_with_stride (alloc, elt_type, range_type, NULL, return create_array_type_with_stride (alloc, elt_type, range_type, NULL,
@@ -2550,7 +2550,7 @@ compute_variant_fields_inner (struct type *type,
+ (type->field (idx).loc_bitpos () + (type->field (idx).loc_bitpos ()
/ TARGET_CHAR_BIT)); / TARGET_CHAR_BIT));
LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx); LONGEST bitsize = type->field (idx).bitsize ();
LONGEST size = bitsize / 8; LONGEST size = bitsize / 8;
if (size == 0) if (size == 0)
size = type->field (idx).type ()->length (); size = type->field (idx).type ()->length ();
@@ -2704,8 +2704,8 @@ resolve_dynamic_struct (struct type *type,
== FIELD_LOC_KIND_BITPOS); == FIELD_LOC_KIND_BITPOS);
new_bit_length = resolved_type->field (i).loc_bitpos (); new_bit_length = resolved_type->field (i).loc_bitpos ();
if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0) if (resolved_type->field (i).bitsize () != 0)
new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i); new_bit_length += resolved_type->field (i).bitsize ();
else else
{ {
struct type *real_type struct type *real_type
@@ -5349,7 +5349,7 @@ recursive_dump_type (struct type *type, int spaces)
else else
gdb_printf ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "", gdb_printf ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
idx, plongest (type->field (idx).loc_bitpos ()), idx, plongest (type->field (idx).loc_bitpos ()),
TYPE_FIELD_BITSIZE (type, idx)); type->field (idx).bitsize ());
gdb_printf ("%s name '%s' (%s)\n", gdb_printf ("%s name '%s' (%s)\n",
host_address_to_string (type->field (idx).type ()), host_address_to_string (type->field (idx).type ()),
type->field (idx).name () != NULL type->field (idx).name () != NULL
@@ -5543,7 +5543,7 @@ copy_type_recursive (struct type *type, htab_t copied_types)
{ {
new_type->field (i).set_is_artificial new_type->field (i).set_is_artificial
(type->field (i).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 ()) if (type->field (i).type ())
new_type->field (i).set_type new_type->field (i).set_type
(copy_type_recursive (type->field (i).type (), copied_types)); (copy_type_recursive (type->field (i).type (), copied_types));

View File

@@ -1933,7 +1933,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \ (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))) : 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_PACKED(thistype, n) (((thistype)->field (n).bitsize ())!=0)
#define TYPE_FIELD_PRIVATE_BITS(thistype) \ #define TYPE_FIELD_PRIVATE_BITS(thistype) \

View File

@@ -577,8 +577,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
unnamed fields. This would lead to misleading unnamed fields. This would lead to misleading
results if the compiler does not put out fields results if the compiler does not put out fields
for such things (I don't know what it does). */ for such things (I don't know what it does). */
gdb_printf (stream, " : %d", gdb_printf (stream, " : %d", type->field (i).bitsize ());
TYPE_FIELD_BITSIZE (type, i));
} }
gdb_printf (stream, ";\n"); gdb_printf (stream, ";\n");
} }

View File

@@ -529,8 +529,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
unnamed fields. This would lead to misleading unnamed fields. This would lead to misleading
results if the compiler does not put out fields results if the compiler does not put out fields
for such things (I don't know what it does). */ for such things (I don't know what it does). */
gdb_printf (stream, " : %d", gdb_printf (stream, " : %d", type->field (i).bitsize ());
TYPE_FIELD_BITSIZE (type, i));
} }
gdb_printf (stream, ";\n"); gdb_printf (stream, ";\n");
} }

View File

@@ -611,7 +611,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
} }
else if (val->bits_synthetic_pointer else if (val->bits_synthetic_pointer
(type->field (i).loc_bitpos (), (type->field (i).loc_bitpos (),
TYPE_FIELD_BITSIZE (type, i))) type->field (i).bitsize ()))
{ {
fputs_styled (_("<synthetic pointer>"), fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream); metadata_style.style (), stream);

View File

@@ -208,7 +208,7 @@ convert_field (struct type *type, int field)
if (PyObject_SetAttrString (result.get (), "is_base_class", arg.get ()) < 0) if (PyObject_SetAttrString (result.get (), "is_base_class", arg.get ()) < 0)
return NULL; 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) if (arg == NULL)
return NULL; return NULL;
if (PyObject_SetAttrString (result.get (), "bitsize", arg.get ()) < 0) if (PyObject_SetAttrString (result.get (), "bitsize", arg.get ()) < 0)

View File

@@ -153,7 +153,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
|| offset_bitpos % TARGET_CHAR_BIT != 0) || offset_bitpos % TARGET_CHAR_BIT != 0)
{ {
/* We're dealing with a bitfield. Print the bit offset. */ /* 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; unsigned real_bitpos = bitpos + offset_bitpos;

View File

@@ -1244,7 +1244,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
problematic place to notify the user of an internal error problematic place to notify the user of an internal error
though. Instead just fall through and print the field as an though. Instead just fall through and print the field as an
int. */ int. */
&& TYPE_FIELD_BITSIZE (type, field) == 1) && type->field (field).bitsize () == 1)
{ {
if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ())) if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ()))
gdb_printf gdb_printf
@@ -1254,7 +1254,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
} }
else 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 (); ULONGEST field_val = val >> type->field (field).loc_bitpos ();
if (field_len < sizeof (ULONGEST) * TARGET_CHAR_BIT) if (field_len < sizeof (ULONGEST) * TARGET_CHAR_BIT)

View File

@@ -2946,7 +2946,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
description correctly. */ description correctly. */
check_typedef (type); check_typedef (type);
if (TYPE_FIELD_BITSIZE (arg_type, fieldno)) if (arg_type->field (fieldno).bitsize ())
{ {
/* Handle packed fields. /* Handle packed fields.
@@ -2961,7 +2961,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
LONGEST container_bitsize = type->length () * 8; LONGEST container_bitsize = type->length () * 8;
v = value::allocate_lazy (type); 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 if ((bitpos % container_bitsize) + v->bitsize () <= container_bitsize
&& type->length () <= (int) sizeof (LONGEST)) && type->length () <= (int) sizeof (LONGEST))
v->set_bitpos (bitpos % container_bitsize); v->set_bitpos (bitpos % container_bitsize);
@@ -3180,7 +3180,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
const struct value *val, LONGEST *result) const struct value *val, LONGEST *result)
{ {
int bitpos = type->field (fieldno).loc_bitpos (); 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 (); struct type *field_type = type->field (fieldno).type ();
int bit_offset; int bit_offset;
@@ -3203,7 +3203,7 @@ LONGEST
unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno) unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
{ {
int bitpos = type->field (fieldno).loc_bitpos (); 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 (); struct type *field_type = type->field (fieldno).type ();
return unpack_bits_as_long (field_type, valaddr, bitpos, bitsize); return unpack_bits_as_long (field_type, valaddr, bitpos, bitsize);
@@ -3261,7 +3261,7 @@ value_field_bitfield (struct type *type, int fieldno,
LONGEST embedded_offset, const struct value *val) LONGEST embedded_offset, const struct value *val)
{ {
int bitpos = type->field (fieldno).loc_bitpos (); 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 ()); struct value *res_val = value::allocate (type->field (fieldno).type ());
val->unpack_bitfield (res_val, bitpos, bitsize, valaddr, embedded_offset); val->unpack_bitfield (res_val, bitpos, bitsize, valaddr, embedded_offset);