gdb: remove TYPE_FIELD_BITPOS

Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.

Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320
This commit is contained in:
Simon Marchi 2021-09-26 16:36:15 -04:00
parent 2ad53ea10c
commit b610c04548
30 changed files with 87 additions and 93 deletions

View file

@ -1537,7 +1537,7 @@ desc_bounds (struct value *arr)
static int static int
fat_pntr_bounds_bitpos (struct type *type) fat_pntr_bounds_bitpos (struct type *type)
{ {
return TYPE_FIELD_BITPOS (desc_base_type (type), 1); return desc_base_type (type)->field (1).loc_bitpos ();
} }
/* If TYPE is the type of an array-descriptor (fat pointer), the bit /* If TYPE is the type of an array-descriptor (fat pointer), the bit
@ -1603,7 +1603,7 @@ desc_data (struct value *arr)
static int static int
fat_pntr_data_bitpos (struct type *type) fat_pntr_data_bitpos (struct type *type)
{ {
return TYPE_FIELD_BITPOS (desc_base_type (type), 0); return desc_base_type (type)->field (0).loc_bitpos ();
} }
/* If TYPE is the type of an array-descriptor (fat pointer), the bit /* If TYPE is the type of an array-descriptor (fat pointer), the bit
@ -1641,7 +1641,7 @@ desc_one_bound (struct value *bounds, int i, int which)
static int static int
desc_bound_bitpos (struct type *type, int i, int which) desc_bound_bitpos (struct type *type, int i, int which)
{ {
return TYPE_FIELD_BITPOS (desc_base_type (type), 2 * i + which - 2); return desc_base_type (type)->field (2 * i + which - 2).loc_bitpos ();
} }
/* If BOUNDS is an array-bounds structure type, return the bit field size /* If BOUNDS is an array-bounds structure type, return the bit field size
@ -6555,7 +6555,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
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 || value_bitpos (arg1) != 0) if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || value_bitpos (arg1) != 0)
{ {
int bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno); int bit_pos = arg_type->field (fieldno).loc_bitpos ();
int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno); int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno);
return ada_value_primitive_packed_val (arg1, return ada_value_primitive_packed_val (arg1,
@ -6660,7 +6660,7 @@ find_struct_field (const char *name, struct type *type, int offset,
int bit_pos = 0, fld_offset = 0; int bit_pos = 0, fld_offset = 0;
if (byte_offset_p != nullptr || bit_offset_p != nullptr) if (byte_offset_p != nullptr || bit_offset_p != nullptr)
{ {
bit_pos = TYPE_FIELD_BITPOS (type, i); bit_pos = type->field (i).loc_bitpos ();
fld_offset = offset + bit_pos / 8; fld_offset = offset + bit_pos / 8;
} }
@ -6716,7 +6716,7 @@ find_struct_field (const char *name, struct type *type, int offset,
{ {
if (find_struct_field (name, field_type->field (j).type (), if (find_struct_field (name, field_type->field (j).type (),
fld_offset fld_offset
+ TYPE_FIELD_BITPOS (field_type, j) / 8, + field_type->field (j).loc_bitpos () / 8,
field_type_p, byte_offset_p, field_type_p, byte_offset_p,
bit_offset_p, bit_size_p, index_p)) bit_offset_p, bit_size_p, index_p))
return 1; return 1;
@ -6735,7 +6735,7 @@ find_struct_field (const char *name, struct type *type, int offset,
int fld_offset = offset; int fld_offset = offset;
if (byte_offset_p != nullptr || bit_offset_p != nullptr) if (byte_offset_p != nullptr || bit_offset_p != nullptr)
{ {
int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset); int bit_pos = type->field (parent_offset).loc_bitpos ();
fld_offset += bit_pos / 8; fld_offset += bit_pos / 8;
} }
@ -6805,7 +6805,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
{ {
struct value *v = /* Do not let indent join lines here. */ struct value *v = /* Do not let indent join lines here. */
ada_search_struct_field (name, arg, ada_search_struct_field (name, arg,
offset + TYPE_FIELD_BITPOS (type, i) / 8, offset + type->field (i).loc_bitpos () / 8,
type->field (i).type ()); type->field (i).type ());
if (v != NULL) if (v != NULL)
@ -6817,14 +6817,14 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
/* PNH: Do we ever get here? See find_struct_field. */ /* PNH: Do we ever get here? See find_struct_field. */
int j; int j;
struct type *field_type = ada_check_typedef (type->field (i).type ()); struct type *field_type = ada_check_typedef (type->field (i).type ());
int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8; int var_offset = offset + type->field (i).loc_bitpos () / 8;
for (j = 0; j < field_type->num_fields (); j += 1) for (j = 0; j < field_type->num_fields (); j += 1)
{ {
struct value *v = ada_search_struct_field /* Force line struct value *v = ada_search_struct_field /* Force line
break. */ break. */
(name, arg, (name, arg,
var_offset + TYPE_FIELD_BITPOS (field_type, j) / 8, var_offset + field_type->field (j).loc_bitpos () / 8,
field_type->field (j).type ()); field_type->field (j).type ());
if (v != NULL) if (v != NULL)
@ -6839,7 +6839,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
if (parent_offset != -1) if (parent_offset != -1)
{ {
struct value *v = ada_search_struct_field ( struct value *v = ada_search_struct_field (
name, arg, offset + TYPE_FIELD_BITPOS (type, parent_offset) / 8, name, arg, offset + type->field (parent_offset).loc_bitpos () / 8,
type->field (parent_offset).type ()); type->field (parent_offset).type ());
if (v != NULL) if (v != NULL)
@ -6885,7 +6885,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset,
{ {
struct value *v = /* Do not let indent join lines here. */ struct value *v = /* Do not let indent join lines here. */
ada_index_struct_field_1 (index_p, arg, ada_index_struct_field_1 (index_p, arg,
offset + TYPE_FIELD_BITPOS (type, i) / 8, offset + type->field (i).loc_bitpos () / 8,
type->field (i).type ()); type->field (i).type ());
if (v != NULL) if (v != NULL)
@ -7525,7 +7525,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
for (f = 0; f < nfields; f += 1) for (f = 0; f < nfields; f += 1)
{ {
off = align_up (off, field_alignment (type, f)) off = align_up (off, field_alignment (type, f))
+ TYPE_FIELD_BITPOS (type, f); + type->field (f).loc_bitpos ();
rtype->field (f).set_loc_bitpos (off); rtype->field (f).set_loc_bitpos (off);
TYPE_FIELD_BITSIZE (rtype, f) = 0; TYPE_FIELD_BITSIZE (rtype, f) = 0;
@ -7562,7 +7562,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
that follow this one. */ that follow this one. */
if (ada_is_aligner_type (field_type)) if (ada_is_aligner_type (field_type))
{ {
long field_offset = TYPE_FIELD_BITPOS (type, f); long field_offset = type->field (f).loc_bitpos ();
field_valaddr = cond_offset_host (field_valaddr, field_offset); field_valaddr = cond_offset_host (field_valaddr, field_offset);
field_address = cond_offset_target (field_address, field_offset); field_address = cond_offset_target (field_address, field_offset);
@ -7642,7 +7642,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
{ {
struct type *branch_type; struct type *branch_type;
off = TYPE_FIELD_BITPOS (rtype, variant_field); off = rtype->field (variant_field).loc_bitpos ();
if (dval0 == NULL) if (dval0 == NULL)
{ {
@ -7837,10 +7837,10 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
branch_type = to_fixed_variant_branch_type branch_type = to_fixed_variant_branch_type
(type->field (variant_field).type (), (type->field (variant_field).type (),
cond_offset_host (valaddr, cond_offset_host (valaddr,
TYPE_FIELD_BITPOS (type, variant_field) type->field (variant_field).loc_bitpos ()
/ TARGET_CHAR_BIT), / TARGET_CHAR_BIT),
cond_offset_target (address, cond_offset_target (address,
TYPE_FIELD_BITPOS (type, variant_field) type->field (variant_field).loc_bitpos ()
/ TARGET_CHAR_BIT), dval); / TARGET_CHAR_BIT), dval);
if (branch_type == NULL) if (branch_type == NULL)
{ {
@ -8742,10 +8742,9 @@ const gdb_byte *
ada_aligned_value_addr (struct type *type, const gdb_byte *valaddr) ada_aligned_value_addr (struct type *type, const gdb_byte *valaddr)
{ {
if (ada_is_aligner_type (type)) if (ada_is_aligner_type (type))
return ada_aligned_value_addr (type->field (0).type (), return ada_aligned_value_addr
valaddr + (type->field (0).type (),
TYPE_FIELD_BITPOS (type, valaddr + type->field (0).loc_bitpos () / TARGET_CHAR_BIT);
0) / TARGET_CHAR_BIT);
else else
return valaddr; return valaddr;
} }

View file

@ -637,7 +637,7 @@ print_field_values (struct value *value, struct value *outer_value,
else else
{ {
struct value *v; struct value *v;
int bit_pos = TYPE_FIELD_BITPOS (type, i); int bit_pos = type->field (i).loc_bitpos ();
int bit_size = TYPE_FIELD_BITSIZE (type, i); int bit_size = TYPE_FIELD_BITSIZE (type, i);
struct value_print_options opts; struct value_print_options opts;

View file

@ -563,7 +563,7 @@ amd64_has_unaligned_fields (struct type *type)
|| TYPE_FIELD_PACKED (type, i)) || TYPE_FIELD_PACKED (type, i))
continue; continue;
int bitpos = TYPE_FIELD_BITPOS (type, i); int bitpos = type->field (i).loc_bitpos ();
if (bitpos % 8 != 0) if (bitpos % 8 != 0)
return true; return true;
@ -604,7 +604,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
if (field_is_static (&type->field (i)) || bitsize == 0) if (field_is_static (&type->field (i)) || bitsize == 0)
return; return;
int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i); int bitpos = bitoffset + type->field (i).loc_bitpos ();
int pos = bitpos / 64; int pos = bitpos / 64;
int endpos = (bitpos + bitsize - 1) / 64; int endpos = (bitpos + bitsize - 1) / 64;

View file

@ -8127,7 +8127,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
} }
/* If bitpos != 0, then we have to care about it. */ /* If bitpos != 0, then we have to care about it. */
if (TYPE_FIELD_BITPOS (type, i) != 0) if (type->field (i).loc_bitpos () != 0)
{ {
/* 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

View file

@ -1310,14 +1310,14 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
if (TYPE_FIELD_PACKED (type, fieldno)) if (TYPE_FIELD_PACKED (type, fieldno))
gen_bitfield_ref (ax, value, type->field (fieldno).type (), gen_bitfield_ref (ax, value, type->field (fieldno).type (),
(offset * TARGET_CHAR_BIT (offset * TARGET_CHAR_BIT
+ TYPE_FIELD_BITPOS (type, fieldno)), + type->field (fieldno).loc_bitpos ()),
(offset * TARGET_CHAR_BIT (offset * TARGET_CHAR_BIT
+ TYPE_FIELD_BITPOS (type, fieldno) + type->field (fieldno).loc_bitpos ()
+ TYPE_FIELD_BITSIZE (type, fieldno))); + TYPE_FIELD_BITSIZE (type, fieldno)));
else else
{ {
gen_offset (ax, offset gen_offset (ax, offset
+ TYPE_FIELD_BITPOS (type, fieldno) / TARGET_CHAR_BIT); + type->field (fieldno).loc_bitpos () / TARGET_CHAR_BIT);
value->kind = axs_lvalue_memory; value->kind = axs_lvalue_memory;
value->type = type->field (fieldno).type (); value->type = type->field (fieldno).type ();
} }

View file

@ -1192,7 +1192,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
/* Make sure we carry our offset when we expand the /* Make sure we carry our offset when we expand the
struct/union. */ struct/union. */
local_podata.offset_bitpos local_podata.offset_bitpos
= podata->offset_bitpos + TYPE_FIELD_BITPOS (type, i); = podata->offset_bitpos + type->field (i).loc_bitpos ();
/* We're entering a struct/union. Right now, /* We're entering a struct/union. Right now,
PODATA->END_BITPOS points right *after* the PODATA->END_BITPOS points right *after* the
struct/union. However, when printing the first field struct/union. However, when printing the first field
@ -1646,11 +1646,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
stream, show, level + 4, stream, show, level + 4,
language, &local_flags, podata); language, &local_flags, podata);
fprintf_filtered (stream, " @%s", fprintf_filtered (stream, " @%s",
plongest (TYPE_FIELD_BITPOS (type, i))); plongest (type->field (i).loc_bitpos ()));
if (TYPE_FIELD_BITSIZE (type, i) > 1) if (TYPE_FIELD_BITSIZE (type, i) > 1)
{ {
fprintf_filtered (stream, "-%s", fprintf_filtered (stream, "-%s",
plongest (TYPE_FIELD_BITPOS (type, i) plongest (type->field (i).loc_bitpos ()
+ TYPE_FIELD_BITSIZE (type, i) + TYPE_FIELD_BITSIZE (type, i)
- 1)); - 1));
} }

View file

@ -372,7 +372,7 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
/* Print vtable entry - we only get here if NOT using /* Print vtable entry - we only get here if NOT using
-fvtable_thunks. (Otherwise, look under -fvtable_thunks. (Otherwise, look under
TYPE_CODE_PTR.) */ TYPE_CODE_PTR.) */
int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8; int offset = type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8;
struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type (); struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type ();
const gdb_byte *valaddr = value_contents_for_printing (val).data (); const gdb_byte *valaddr = value_contents_for_printing (val).data ();
CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);

View file

@ -115,7 +115,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
type->field (i).name (), type->field (i).name (),
field_type, field_type,
bitsize, bitsize,
TYPE_FIELD_BITPOS (type, i)); type->field (i).loc_bitpos ());
} }
context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type)); context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type));

View file

@ -652,7 +652,7 @@ compile_cplus_convert_struct_or_union_members
instance->plugin ().build_field instance->plugin ().build_field
(field_name, field_type, field_flags, bitsize, (field_name, field_type, field_flags, bitsize,
TYPE_FIELD_BITPOS (type, i)); type->field (i).loc_bitpos ());
} }
} }
} }

View file

@ -553,7 +553,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++) for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
{ {
const char *reg_name = regs_type->field (fieldno).name (); const char *reg_name = regs_type->field (fieldno).name ();
ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno); ULONGEST reg_bitpos = regs_type->field (fieldno).loc_bitpos ();
ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno); ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
ULONGEST reg_offset; ULONGEST reg_offset;
struct type *reg_type struct type *reg_type

View file

@ -270,11 +270,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
fputs_styled ("<optimized out or zero length>", fputs_styled ("<optimized out or zero length>",
metadata_style.style (), stream); metadata_style.style (), stream);
} }
else if (value_bits_synthetic_pointer (val, else if (value_bits_synthetic_pointer
TYPE_FIELD_BITPOS (type, (val, type->field (i).loc_bitpos (),
i), TYPE_FIELD_BITSIZE (type, i)))
TYPE_FIELD_BITSIZE (type,
i)))
{ {
fputs_styled (_("<synthetic pointer>"), fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream); metadata_style.style (), stream);
@ -316,7 +314,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
} }
else if (i == vptr_fieldno && type == vptr_basetype) else if (i == vptr_fieldno && type == vptr_basetype)
{ {
int i_offset = TYPE_FIELD_BITPOS (type, i) / 8; int i_offset = type->field (i).loc_bitpos () / 8;
struct type *i_type = type->field (i).type (); struct type *i_type = type->field (i).type ();
if (valprint_check_validity (stream, i_type, i_offset, val)) if (valprint_check_validity (stream, i_type, i_offset, val))
@ -638,7 +636,7 @@ cp_find_class_member (struct type **self_p, int *fieldno,
for (i = TYPE_N_BASECLASSES (self); i < len; i++) for (i = TYPE_N_BASECLASSES (self); i < len; i++)
{ {
LONGEST bitpos = TYPE_FIELD_BITPOS (self, i); LONGEST bitpos = self->field (i).loc_bitpos ();
QUIT; QUIT;
if (offset == bitpos) if (offset == bitpos)
@ -650,7 +648,7 @@ cp_find_class_member (struct type **self_p, int *fieldno,
for (i = 0; i < TYPE_N_BASECLASSES (self); i++) for (i = 0; i < TYPE_N_BASECLASSES (self); i++)
{ {
LONGEST bitpos = TYPE_FIELD_BITPOS (self, i); LONGEST bitpos = self->field (i).loc_bitpos ();
LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ()); LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ());
if (offset >= bitpos && offset < bitpos + bitsize) if (offset >= bitpos && offset < bitpos + bitsize)

View file

@ -55,7 +55,7 @@ dynamic_array_type (struct type *type,
ptr_type = type->field (1).type (); ptr_type = type->field (1).type ();
elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type)); elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
addr = unpack_pointer (ptr_type, addr = unpack_pointer (ptr_type,
valaddr + TYPE_FIELD_BITPOS (type, 1) / 8 valaddr + type->field (1).loc_bitpos () / 8
+ embedded_offset); + embedded_offset);
true_type = check_typedef (elttype); true_type = check_typedef (elttype);

View file

@ -9076,7 +9076,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
} }
++name; ++name;
bit_offset += TYPE_FIELD_BITPOS (field_type, index); bit_offset += field_type->field (index).loc_bitpos ();
field_type = field_type->field (index).type (); field_type = field_type->field (index).type ();
} }
@ -16530,7 +16530,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
bounds->num_fields () * sizeof (struct field)); bounds->num_fields () * sizeof (struct field));
int last_fieldno = range_fields.size () - 1; int last_fieldno = range_fields.size () - 1;
int bounds_size = (TYPE_FIELD_BITPOS (bounds, last_fieldno) / 8 int bounds_size = (bounds->field (last_fieldno).loc_bitpos () / 8
+ TYPE_LENGTH (bounds->field (last_fieldno).type ())); + TYPE_LENGTH (bounds->field (last_fieldno).type ()));
TYPE_LENGTH (bounds) = align_up (bounds_size, max_align); TYPE_LENGTH (bounds) = align_up (bounds_size, max_align);

View file

@ -2321,7 +2321,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
val = value_cast (field_type, val); val = value_cast (field_type, val);
bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno); bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
bitpos = TYPE_FIELD_BITPOS (struct_type, fieldno); bitpos = struct_type->field (fieldno).loc_bitpos ();
addr = value_contents_writeable (struct_val).data () + bitpos / 8; addr = value_contents_writeable (struct_val).data () + bitpos / 8;
if (bitsize) if (bitsize)
modify_field (struct_type, addr, modify_field (struct_type, addr,

View file

@ -1851,7 +1851,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
{ {
return {&type->field (i), TYPE_FIELD_BITPOS (type, i)}; return {&type->field (i), type->field (i).loc_bitpos ()};
} }
else if (!t_field_name || *t_field_name == '\0') else if (!t_field_name || *t_field_name == '\0')
{ {
@ -1859,7 +1859,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
= lookup_struct_elt (type->field (i).type (), name, 1); = lookup_struct_elt (type->field (i).type (), name, 1);
if (elt.field != NULL) if (elt.field != NULL)
{ {
elt.offset += TYPE_FIELD_BITPOS (type, i); elt.offset += type->field (i).loc_bitpos ();
return elt; return elt;
} }
} }
@ -2464,7 +2464,7 @@ compute_variant_fields_inner (struct type *type,
else else
{ {
CORE_ADDR addr = (addr_stack->addr CORE_ADDR addr = (addr_stack->addr
+ (TYPE_FIELD_BITPOS (type, idx) + (type->field (idx).loc_bitpos ()
/ TARGET_CHAR_BIT)); / TARGET_CHAR_BIT));
LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx); LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
@ -2475,7 +2475,7 @@ compute_variant_fields_inner (struct type *type,
gdb_byte bits[sizeof (ULONGEST)]; gdb_byte bits[sizeof (ULONGEST)];
read_memory (addr, bits, size); read_memory (addr, bits, size);
LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx) LONGEST bitpos = (type->field (idx).loc_bitpos ()
% TARGET_CHAR_BIT); % TARGET_CHAR_BIT);
discr_value = unpack_bits_as_long (type->field (idx).type (), discr_value = unpack_bits_as_long (type->field (idx).type (),
@ -2615,7 +2615,7 @@ resolve_dynamic_struct (struct type *type,
" (invalid location kind)")); " (invalid location kind)"));
pinfo.type = check_typedef (resolved_type->field (i).type ()); pinfo.type = check_typedef (resolved_type->field (i).type ());
size_t offset = TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT; size_t offset = resolved_type->field (i).loc_bitpos () / TARGET_CHAR_BIT;
pinfo.valaddr = addr_stack->valaddr; pinfo.valaddr = addr_stack->valaddr;
if (!pinfo.valaddr.empty ()) if (!pinfo.valaddr.empty ())
pinfo.valaddr = pinfo.valaddr.slice (offset); pinfo.valaddr = pinfo.valaddr.slice (offset);
@ -2628,7 +2628,7 @@ resolve_dynamic_struct (struct type *type,
gdb_assert (resolved_type->field (i).loc_kind () gdb_assert (resolved_type->field (i).loc_kind ()
== FIELD_LOC_KIND_BITPOS); == FIELD_LOC_KIND_BITPOS);
new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i); new_bit_length = resolved_type->field (i).loc_bitpos ();
if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0) if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i); new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
else else
@ -5340,7 +5340,7 @@ recursive_dump_type (struct type *type, int spaces)
idx, plongest (TYPE_FIELD_ENUMVAL (type, idx))); idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
else else
printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "", printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
idx, plongest (TYPE_FIELD_BITPOS (type, idx)), idx, plongest (type->field (idx).loc_bitpos ()),
TYPE_FIELD_BITSIZE (type, idx)); TYPE_FIELD_BITSIZE (type, idx));
gdb_print_host_address (type->field (idx).type (), gdb_stdout); gdb_print_host_address (type->field (idx).type (), gdb_stdout);
printf_filtered (" name '%s' (", printf_filtered (" name '%s' (",
@ -5562,7 +5562,7 @@ copy_type_recursive (struct objfile *objfile,
switch (type->field (i).loc_kind ()) switch (type->field (i).loc_kind ())
{ {
case FIELD_LOC_KIND_BITPOS: case FIELD_LOC_KIND_BITPOS:
new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i)); new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
break; break;
case FIELD_LOC_KIND_ENUMVAL: case FIELD_LOC_KIND_ENUMVAL:
new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i)); new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));

View file

@ -2116,7 +2116,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ()) #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ()) #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index) #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
#define BASETYPE_VIA_PUBLIC(thistype, index) \ #define BASETYPE_VIA_PUBLIC(thistype, index) \
((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index))) ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
#define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
@ -2128,7 +2128,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
#define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
#define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ()) #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ()) #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ()) #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())

View file

@ -364,7 +364,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
CORE_ADDR addr; CORE_ADDR addr;
field_type = check_typedef (type->field (i).type ()); field_type = check_typedef (type->field (i).type ());
field_offset = TYPE_FIELD_BITPOS (type, i) / 8; field_offset = type->field (i).loc_bitpos () / 8;
field_length = TYPE_LENGTH (field_type); field_length = TYPE_LENGTH (field_type);
if (!value_bytes_available (val, embedded_offset + field_offset, if (!value_bytes_available (val, embedded_offset + field_offset,

View file

@ -195,7 +195,7 @@ vtable_address_point_offset (struct gdbarch *gdbarch)
struct type *vtable_type struct type *vtable_type
= (struct type *) gdbarch_data (gdbarch, vtable_type_gdbarch_data); = (struct type *) gdbarch_data (gdbarch, vtable_type_gdbarch_data);
return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions) return (vtable_type->field (vtable_field_virtual_functions).loc_bitpos ()
/ TARGET_CHAR_BIT); / TARGET_CHAR_BIT);
} }

View file

@ -102,7 +102,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
for (i = low_bound; i <= high_bound; i++) for (i = low_bound; i <= high_bound; i++)
{ {
bitval = value_bit_index (type->field (field).type (), bitval = value_bit_index (type->field (field).type (),
(TYPE_FIELD_BITPOS (type, field) / 8) + (type->field (field).loc_bitpos () / 8) +
valaddr + embedded_offset, i); valaddr + embedded_offset, i);
if (bitval < 0) if (bitval < 0)
error (_("bit test is out of range")); error (_("bit test is out of range"));
@ -168,7 +168,7 @@ m2_print_unbounded_array (struct value *value,
const gdb_byte *valaddr = value_contents_for_printing (value).data (); const gdb_byte *valaddr = value_contents_for_printing (value).data ();
addr = unpack_pointer (type->field (0).type (), addr = unpack_pointer (type->field (0).type (),
(TYPE_FIELD_BITPOS (type, 0) / 8) + (type->field (0).loc_bitpos () / 8) +
valaddr); valaddr);
val = value_at_lazy (TYPE_TARGET_TYPE (type->field (0).type ()), val = value_at_lazy (TYPE_TARGET_TYPE (type->field (0).type ()),

View file

@ -4858,11 +4858,11 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
/* We're only looking at normal fields. */ /* We're only looking at normal fields. */
if (field_is_static (&arg_type->field (i)) if (field_is_static (&arg_type->field (i))
|| (TYPE_FIELD_BITPOS (arg_type, i) % 8) != 0) || (arg_type->field (i).loc_bitpos () % 8) != 0)
continue; continue;
/* If we have gone past the offset, there is no double to pass. */ /* If we have gone past the offset, there is no double to pass. */
pos = TYPE_FIELD_BITPOS (arg_type, i) / 8; pos = arg_type->field (i).loc_bitpos () / 8;
if (pos > offset) if (pos > offset)
return 0; return 0;

View file

@ -102,11 +102,11 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size,
&& strcmp (type->field (1).name (), "st") == 0) && strcmp (type->field (1).name (), "st") == 0)
{ {
if (length_pos) if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT; *length_pos = type->field (0).loc_bitpos () / TARGET_CHAR_BIT;
if (length_size) if (length_size)
*length_size = TYPE_LENGTH (type->field (0).type ()); *length_size = TYPE_LENGTH (type->field (0).type ());
if (string_pos) if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT; *string_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT;
if (char_type) if (char_type)
*char_type = TYPE_TARGET_TYPE (type->field (1).type ()); *char_type = TYPE_TARGET_TYPE (type->field (1).type ());
if (arrayname) if (arrayname)
@ -122,11 +122,11 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size,
&& strcmp (type->field (1).name (), "length") == 0) && strcmp (type->field (1).name (), "length") == 0)
{ {
if (length_pos) if (length_pos)
*length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT; *length_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT;
if (length_size) if (length_size)
*length_size = TYPE_LENGTH (type->field (1).type ()); *length_size = TYPE_LENGTH (type->field (1).type ());
if (string_pos) if (string_pos)
*string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT; *string_pos = type->field (2).loc_bitpos () / TARGET_CHAR_BIT;
/* FIXME: how can I detect wide chars in GPC ?? */ /* FIXME: how can I detect wide chars in GPC ?? */
if (char_type) if (char_type)
{ {

View file

@ -306,7 +306,7 @@ pascal_language::value_print_inner (struct value *val,
print_address_demangle print_address_demangle
(options, gdbarch, (options, gdbarch,
extract_unsigned_integer extract_unsigned_integer
(valaddr + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8, (valaddr + type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8,
TYPE_LENGTH (type->field (VTBL_FNADDR_OFFSET).type ()), TYPE_LENGTH (type->field (VTBL_FNADDR_OFFSET).type ()),
byte_order), byte_order),
stream, demangle); stream, demangle);
@ -606,11 +606,9 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
fputs_styled ("<optimized out or zero length>", fputs_styled ("<optimized out or zero length>",
metadata_style.style (), stream); metadata_style.style (), stream);
} }
else if (value_bits_synthetic_pointer (val, else if (value_bits_synthetic_pointer
TYPE_FIELD_BITPOS (type, (val, type->field (i).loc_bitpos (),
i), TYPE_FIELD_BITSIZE (type, i)))
TYPE_FIELD_BITSIZE (type,
i)))
{ {
fputs_styled (_("<synthetic pointer>"), fputs_styled (_("<synthetic pointer>"),
metadata_style.style (), stream); metadata_style.style (), stream);

View file

@ -192,7 +192,7 @@ convert_field (struct type *type, int field)
if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK) if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
arg = gdbpy_ref<>::new_reference (Py_None); arg = gdbpy_ref<>::new_reference (Py_None);
else else
arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field)); arg = gdb_py_object_from_longest (type->field (field).loc_bitpos ());
attrstring = "bitpos"; attrstring = "bitpos";
} }

View file

@ -2548,7 +2548,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
struct type *field_type = type->field (i).type (); struct type *field_type = type->field (i).type ();
field_type = check_typedef (field_type); field_type = check_typedef (field_type);
int field_offset int field_offset
= offset + TYPE_FIELD_BITPOS (type, i) / TARGET_CHAR_BIT; = offset + type->field (i).loc_bitpos () / TARGET_CHAR_BIT;
switch (field_type->code ()) switch (field_type->code ())
{ {

View file

@ -686,8 +686,8 @@ rust_print_struct_def (struct type *type, const char *varstring,
std::sort (fields.begin (), fields.end (), std::sort (fields.begin (), fields.end (),
[&] (int a, int b) [&] (int a, int b)
{ {
return (TYPE_FIELD_BITPOS (type, a) return (type->field (a).loc_bitpos ()
< TYPE_FIELD_BITPOS (type, b)); < type->field (b).loc_bitpos ());
}); });
for (int i : fields) for (int i : fields)
@ -943,7 +943,7 @@ rust_composite_type (struct type *original,
if (i > 0) if (i > 0)
TYPE_LENGTH (result) TYPE_LENGTH (result)
= (TYPE_FIELD_BITPOS (result, i - 1) / TARGET_CHAR_BIT + = (result->field (i - 1).loc_bitpos () / TARGET_CHAR_BIT +
TYPE_LENGTH (result->field (i - 1).type ())); TYPE_LENGTH (result->field (i - 1).type ()));
return result; return result;
} }

View file

@ -1267,7 +1267,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
for (i = 0; i < type->num_fields (); i++) for (i = 0; i < type->num_fields (); i++)
{ {
struct type *subtype = check_typedef (type->field (i).type ()); struct type *subtype = check_typedef (type->field (i).type ());
int subpos = bitpos + TYPE_FIELD_BITPOS (type, i); int subpos = bitpos + type->field (i).loc_bitpos ();
sparc64_store_floating_fields (regcache, subtype, valbuf, sparc64_store_floating_fields (regcache, subtype, valbuf,
element, subpos); element, subpos);
@ -1355,7 +1355,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
for (i = 0; i < type->num_fields (); i++) for (i = 0; i < type->num_fields (); i++)
{ {
struct type *subtype = check_typedef (type->field (i).type ()); struct type *subtype = check_typedef (type->field (i).type ());
int subpos = bitpos + TYPE_FIELD_BITPOS (type, i); int subpos = bitpos + type->field (i).loc_bitpos ();
sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos); sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
} }

View file

@ -143,7 +143,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
return; return;
} }
unsigned int bitpos = TYPE_FIELD_BITPOS (type, field_idx); unsigned int bitpos = type->field (field_idx).loc_bitpos ();
unsigned int fieldsize_byte = TYPE_LENGTH (ftype); unsigned int fieldsize_byte = TYPE_LENGTH (ftype);
unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT; unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT;

View file

@ -2030,8 +2030,8 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
have to add the offset of the union here. */ have to add the offset of the union here. */
if (field_type->code () == TYPE_CODE_STRUCT if (field_type->code () == TYPE_CODE_STRUCT
|| (field_type->num_fields () > 0 || (field_type->num_fields () > 0
&& TYPE_FIELD_BITPOS (field_type, 0) == 0)) && field_type->field (0).loc_bitpos () == 0))
new_offset += TYPE_FIELD_BITPOS (type, i) / 8; new_offset += type->field (i).loc_bitpos () / 8;
search (arg1, new_offset, field_type); search (arg1, new_offset, field_type);
} }
@ -2430,7 +2430,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++) for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++)
{ {
if (!field_is_static (&t->field (i)) if (!field_is_static (&t->field (i))
&& bitpos == TYPE_FIELD_BITPOS (t, i) && bitpos == t->field (i).loc_bitpos ()
&& types_equal (ftype, t->field (i).type ())) && types_equal (ftype, t->field (i).type ()))
return value_primitive_field (*argp, 0, i, t); return value_primitive_field (*argp, 0, i, t);
} }
@ -3518,7 +3518,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
if (want_address) if (want_address)
return value_from_longest return value_from_longest
(lookup_memberptr_type (t->field (i).type (), domain), (lookup_memberptr_type (t->field (i).type (), domain),
offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3)); offset + (LONGEST) (t->field (i).loc_bitpos () >> 3));
else if (noside != EVAL_NORMAL) else if (noside != EVAL_NORMAL)
return allocate_value (t->field (i).type ()); return allocate_value (t->field (i).type ());
else else

View file

@ -1214,7 +1214,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
int. */ int. */
&& TYPE_FIELD_BITSIZE (type, field) == 1) && TYPE_FIELD_BITSIZE (type, field) == 1)
{ {
if (val & ((ULONGEST)1 << TYPE_FIELD_BITPOS (type, field))) if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ()))
fprintf_filtered fprintf_filtered
(stream, " %ps", (stream, " %ps",
styled_string (variable_name_style.style (), styled_string (variable_name_style.style (),
@ -1223,7 +1223,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_BITSIZE (type, field);
ULONGEST field_val = val >> TYPE_FIELD_BITPOS (type, field); 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)
field_val &= ((ULONGEST) 1 << field_len) - 1; field_val &= ((ULONGEST) 1 << field_len) - 1;

View file

@ -3044,7 +3044,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
bit. Assume that the address, offset, and embedded offset bit. Assume that the address, offset, and embedded offset
are sufficiently aligned. */ are sufficiently aligned. */
LONGEST bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno); LONGEST bitpos = arg_type->field (fieldno).loc_bitpos ();
LONGEST container_bitsize = TYPE_LENGTH (type) * 8; LONGEST container_bitsize = TYPE_LENGTH (type) * 8;
v = allocate_value_lazy (type); v = allocate_value_lazy (type);
@ -3082,7 +3082,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
value_address (arg1), value_address (arg1),
arg1); arg1);
else else
boffset = TYPE_FIELD_BITPOS (arg_type, fieldno) / 8; boffset = arg_type->field (fieldno).loc_bitpos () / 8;
if (value_lazy (arg1)) if (value_lazy (arg1))
v = allocate_value_lazy (value_enclosing_type (arg1)); v = allocate_value_lazy (value_enclosing_type (arg1));
@ -3110,7 +3110,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
else else
{ {
/* Plain old data member */ /* Plain old data member */
offset += (TYPE_FIELD_BITPOS (arg_type, fieldno) offset += (arg_type->field (fieldno).loc_bitpos ()
/ (HOST_CHAR_BIT * unit_size)); / (HOST_CHAR_BIT * unit_size));
/* Lazy register values with offsets are not supported. */ /* Lazy register values with offsets are not supported. */
@ -3274,7 +3274,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
LONGEST embedded_offset, int fieldno, LONGEST embedded_offset, int fieldno,
const struct value *val, LONGEST *result) const struct value *val, LONGEST *result)
{ {
int bitpos = TYPE_FIELD_BITPOS (type, fieldno); int bitpos = type->field (fieldno).loc_bitpos ();
int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
struct type *field_type = type->field (fieldno).type (); struct type *field_type = type->field (fieldno).type ();
int bit_offset; int bit_offset;
@ -3297,7 +3297,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
LONGEST 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_BITPOS (type, fieldno); int bitpos = type->field (fieldno).loc_bitpos ();
int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
struct type *field_type = type->field (fieldno).type (); struct type *field_type = type->field (fieldno).type ();
@ -3362,7 +3362,7 @@ value_field_bitfield (struct type *type, int fieldno,
const gdb_byte *valaddr, const gdb_byte *valaddr,
LONGEST embedded_offset, const struct value *val) LONGEST embedded_offset, const struct value *val)
{ {
int bitpos = TYPE_FIELD_BITPOS (type, fieldno); int bitpos = type->field (fieldno).loc_bitpos ();
int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
struct value *res_val = allocate_value (type->field (fieldno).type ()); struct value *res_val = allocate_value (type->field (fieldno).type ());