]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove TYPE_FIELD_BITPOS
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 26 Sep 2021 20:36:15 +0000 (16:36 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 29 Oct 2021 20:44:44 +0000 (16:44 -0400)
Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.

Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320

30 files changed:
gdb/ada-lang.c
gdb/ada-valprint.c
gdb/amd64-tdep.c
gdb/arm-tdep.c
gdb/ax-gdb.c
gdb/c-typeprint.c
gdb/c-valprint.c
gdb/compile/compile-c-types.c
gdb/compile/compile-cplus-types.c
gdb/compile/compile-object-load.c
gdb/cp-valprint.c
gdb/d-valprint.c
gdb/dwarf2/read.c
gdb/eval.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/gnu-v2-abi.c
gdb/gnu-v3-abi.c
gdb/m2-valprint.c
gdb/mips-tdep.c
gdb/p-lang.c
gdb/p-valprint.c
gdb/python/py-type.c
gdb/riscv-tdep.c
gdb/rust-lang.c
gdb/sparc64-tdep.c
gdb/typeprint.c
gdb/valops.c
gdb/valprint.c
gdb/value.c

index d7e78729e2f8268e049708eef8bc49d86e87cfa5..c7837c75139da0d18ec3f26dfab15a93d6a8a87f 100644 (file)
@@ -1537,7 +1537,7 @@ desc_bounds (struct value *arr)
 static int
 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
@@ -1603,7 +1603,7 @@ desc_data (struct value *arr)
 static int
 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
@@ -1641,7 +1641,7 @@ desc_one_bound (struct value *bounds, int i, int which)
 static int
 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
@@ -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.  */
   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);
 
       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;
       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;
        }
 
@@ -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 (),
                                     fld_offset
-                                    + TYPE_FIELD_BITPOS (field_type, j) / 8,
+                                    + field_type->field (j).loc_bitpos () / 8,
                                     field_type_p, byte_offset_p,
                                     bit_offset_p, bit_size_p, index_p))
                return 1;
@@ -6735,7 +6735,7 @@ find_struct_field (const char *name, struct type *type, int offset,
       int fld_offset = offset;
       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;
        }
 
@@ -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.  */
            ada_search_struct_field (name, arg,
-                                    offset + TYPE_FIELD_BITPOS (type, i) / 8,
+                                    offset + type->field (i).loc_bitpos () / 8,
                                     type->field (i).type ());
 
          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.  */
          int j;
          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)
            {
              struct value *v = ada_search_struct_field /* Force line
                                                           break.  */
                (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 ());
 
              if (v != NULL)
@@ -6839,7 +6839,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
   if (parent_offset != -1)
     {
       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 ());
 
       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.  */
            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 ());
 
          if (v != NULL)
@@ -7525,7 +7525,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
   for (f = 0; f < nfields; f += 1)
     {
       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);
       TYPE_FIELD_BITSIZE (rtype, f) = 0;
 
@@ -7562,7 +7562,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
             that follow this one.  */
          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_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;
 
-      off = TYPE_FIELD_BITPOS (rtype, variant_field);
+      off = rtype->field (variant_field).loc_bitpos ();
 
       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
     (type->field (variant_field).type (),
      cond_offset_host (valaddr,
-                      TYPE_FIELD_BITPOS (type, variant_field)
+                      type->field (variant_field).loc_bitpos ()
                       / TARGET_CHAR_BIT),
      cond_offset_target (address,
-                        TYPE_FIELD_BITPOS (type, variant_field)
+                        type->field (variant_field).loc_bitpos ()
                         / TARGET_CHAR_BIT), dval);
   if (branch_type == NULL)
     {
@@ -8742,10 +8742,9 @@ const gdb_byte *
 ada_aligned_value_addr (struct type *type, const gdb_byte *valaddr)
 {
   if (ada_is_aligner_type (type))
-    return ada_aligned_value_addr (type->field (0).type (),
-                                  valaddr +
-                                  TYPE_FIELD_BITPOS (type,
-                                                     0) / TARGET_CHAR_BIT);
+    return ada_aligned_value_addr
+      (type->field (0).type (),
+       valaddr + type->field (0).loc_bitpos () / TARGET_CHAR_BIT);
   else
     return valaddr;
 }
index 6be16ee17ec2f7f869c084fdf7b7163f481f08a5..04f1c7d840831b615562fd8b44832709d5a22761 100644 (file)
@@ -637,7 +637,7 @@ print_field_values (struct value *value, struct value *outer_value,
          else
            {
              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);
              struct value_print_options opts;
 
index e563d369d8cb3eb3c2f732c2fa850ec70ba8d63b..de04bbd07c1d0a634f5774b6f50c7a99f8bca561 100644 (file)
@@ -563,7 +563,7 @@ amd64_has_unaligned_fields (struct type *type)
              || TYPE_FIELD_PACKED (type, i))
            continue;
 
-         int bitpos = TYPE_FIELD_BITPOS (type, i);
+         int bitpos = type->field (i).loc_bitpos ();
 
          if (bitpos % 8 != 0)
            return true;
@@ -604,7 +604,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
   if (field_is_static (&type->field (i)) || bitsize == 0)
     return;
 
-  int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
+  int bitpos = bitoffset + type->field (i).loc_bitpos ();
   int pos = bitpos / 64;
   int endpos = (bitpos + bitsize - 1) / 64;
 
index 10f8e00d6c30b6e6093533f654c427c83c7e6975..5b60831bbe9fd0074a0d49685a6df5f85713453d 100644 (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 (TYPE_FIELD_BITPOS (type, i) != 0)
+             if (type->field (i).loc_bitpos () != 0)
                {
                  /* Bitfields are not addressable.  If the field bitsize is 
                     zero, then the field is not packed.  Hence it cannot be
index 29d1bab81148df8d52e201227e2a471944977f50..b56652a7a2516c9efc4af010382b14457289f7bb 100644 (file)
@@ -1310,14 +1310,14 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
   if (TYPE_FIELD_PACKED (type, fieldno))
     gen_bitfield_ref (ax, value, type->field (fieldno).type (),
                      (offset * TARGET_CHAR_BIT
-                      + TYPE_FIELD_BITPOS (type, fieldno)),
+                      + type->field (fieldno).loc_bitpos ()),
                      (offset * TARGET_CHAR_BIT
-                      + TYPE_FIELD_BITPOS (type, fieldno)
+                      + type->field (fieldno).loc_bitpos ()
                       + TYPE_FIELD_BITSIZE (type, fieldno)));
   else
     {
       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->type = type->field (fieldno).type ();
     }
index 33700aa34fd886db1f06d5bdcb4d9351f377f726..a471fdc27203f3c04dce95696a8109baf891a1a5 100644 (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
                 struct/union.  */
              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,
                 PODATA->END_BITPOS points right *after* the
                 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,
                                language, &local_flags, podata);
                fprintf_filtered (stream, " @%s",
-                                 plongest (TYPE_FIELD_BITPOS (type, i)));
+                                 plongest (type->field (i).loc_bitpos ()));
                if (TYPE_FIELD_BITSIZE (type, i) > 1)
                  {
                    fprintf_filtered (stream, "-%s",
-                                     plongest (TYPE_FIELD_BITPOS (type, i)
+                                     plongest (type->field (i).loc_bitpos ()
                                                + TYPE_FIELD_BITSIZE (type, i)
                                                - 1));
                  }
index c491d37020d1766f18bb8e403644b07e7abf6f8e..daf24538f95d17e2548f5db76d15dd942180368d 100644 (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
         -fvtable_thunks.  (Otherwise, look under
         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 ();
       const gdb_byte *valaddr = value_contents_for_printing (val).data ();
       CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
index e9e5398b83a12f712187a915b7a983b163d5f34e..8fbbc0e4ef2ce467419cb4240fbbbc0193cacbbd 100644 (file)
@@ -115,7 +115,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
                                          type->field (i).name (),
                                          field_type,
                                          bitsize,
-                                         TYPE_FIELD_BITPOS (type, i));
+                                         type->field (i).loc_bitpos ());
     }
 
   context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type));
index ef73aaabf0f10268c0b2a9af47afee1cd365ae51..a54a5449242ca7c605bd5b8adc1d3575eb80d475 100644 (file)
@@ -652,7 +652,7 @@ compile_cplus_convert_struct_or_union_members
 
          instance->plugin ().build_field
            (field_name, field_type, field_flags, bitsize,
-            TYPE_FIELD_BITPOS (type, i));
+            type->field (i).loc_bitpos ());
        }
     }
 }
index 6786b422ec9f938b4f52654a982b8a49e5ed212a..bf69bf72cc948777e4a4a2b8c570c795e03ce245 100644 (file)
@@ -553,7 +553,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
   for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
     {
       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_offset;
       struct type *reg_type
index 10237289f6ca350cc15269cab1c1c63c115d77cb..27884102e10be5cb2884a163f95f786f8a44c085 100644 (file)
@@ -270,11 +270,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
                  fputs_styled ("<optimized out or zero length>",
                                metadata_style.style (), stream);
                }
-             else if (value_bits_synthetic_pointer (val,
-                                                    TYPE_FIELD_BITPOS (type,
-                                                                       i),
-                                                    TYPE_FIELD_BITSIZE (type,
-                                                                        i)))
+             else if (value_bits_synthetic_pointer
+                        (val, type->field (i).loc_bitpos (),
+                         TYPE_FIELD_BITSIZE (type, i)))
                {
                  fputs_styled (_("<synthetic pointer>"),
                                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)
                {
-                 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 ();
 
                  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++)
     {
-      LONGEST bitpos = TYPE_FIELD_BITPOS (self, i);
+      LONGEST bitpos = self->field (i).loc_bitpos ();
 
       QUIT;
       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++)
     {
-      LONGEST bitpos = TYPE_FIELD_BITPOS (self, i);
+      LONGEST bitpos = self->field (i).loc_bitpos ();
       LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ());
 
       if (offset >= bitpos && offset < bitpos + bitsize)
index 4b73c96857827ecb0022b32e110362d00820a7d5..5f8ee94fffe39d46ac7d220d6f884c8081643c32 100644 (file)
@@ -55,7 +55,7 @@ dynamic_array_type (struct type *type,
       ptr_type = type->field (1).type ();
       elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
       addr = unpack_pointer (ptr_type,
-                            valaddr + TYPE_FIELD_BITPOS (type, 1) / 8
+                            valaddr + type->field (1).loc_bitpos () / 8
                             + embedded_offset);
       true_type = check_typedef (elttype);
 
index 5e5c7ccfdb859b722e928c8cf45680cf6312e894..e3609abfa9c82d593af823ef70a1e28db510395a 100644 (file)
@@ -9076,7 +9076,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
            }
          ++name;
 
-         bit_offset += TYPE_FIELD_BITPOS (field_type, index);
+         bit_offset += field_type->field (index).loc_bitpos ();
          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));
 
   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) = align_up (bounds_size, max_align);
 
index 6416ac55b7081d34bec47484f08f39cfc4c7c2f6..bcdb78f05bcfedc8f832073b96e129a5f9a8e414 100644 (file)
@@ -2321,7 +2321,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
        val = value_cast (field_type, val);
 
       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;
       if (bitsize)
        modify_field (struct_type, addr,
index 981b9b337c2e3ec37de5427a9e2ef88d123d281b..0dd2790d33a4deafd748cbbfc858c88d03d299a0 100644 (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))
        {
-         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')
        {
@@ -1859,7 +1859,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
            = lookup_struct_elt (type->field (i).type (), name, 1);
          if (elt.field != NULL)
            {
-             elt.offset += TYPE_FIELD_BITPOS (type, i);
+             elt.offset += type->field (i).loc_bitpos ();
              return elt;
            }
        }
@@ -2464,7 +2464,7 @@ compute_variant_fields_inner (struct type *type,
       else
        {
          CORE_ADDR addr = (addr_stack->addr
-                           + (TYPE_FIELD_BITPOS (type, idx)
+                           + (type->field (idx).loc_bitpos ()
                               / TARGET_CHAR_BIT));
 
          LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
@@ -2475,7 +2475,7 @@ compute_variant_fields_inner (struct type *type,
          gdb_byte bits[sizeof (ULONGEST)];
          read_memory (addr, bits, size);
 
-         LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx)
+         LONGEST bitpos = (type->field (idx).loc_bitpos ()
                            % TARGET_CHAR_BIT);
 
          discr_value = unpack_bits_as_long (type->field (idx).type (),
@@ -2615,7 +2615,7 @@ resolve_dynamic_struct (struct type *type,
                 " (invalid location kind)"));
 
       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;
       if (!pinfo.valaddr.empty ())
        pinfo.valaddr = pinfo.valaddr.slice (offset);
@@ -2628,7 +2628,7 @@ resolve_dynamic_struct (struct type *type,
       gdb_assert (resolved_type->field (i).loc_kind ()
                  == 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)
        new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
       else
@@ -5340,7 +5340,7 @@ recursive_dump_type (struct type *type, int spaces)
                         idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
       else
        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));
       gdb_print_host_address (type->field (idx).type (), gdb_stdout);
       printf_filtered (" name '%s' (",
@@ -5562,7 +5562,7 @@ copy_type_recursive (struct objfile *objfile,
          switch (type->field (i).loc_kind ())
            {
            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;
            case FIELD_LOC_KIND_ENUMVAL:
              new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
index b9f96d945696cb908bceed253f9bf1edd2f19413..18f856fb0597bd77c892167496e34d3e17d16568 100644 (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_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
 #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) \
   ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
 #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_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_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
index cdcd3d5dd781f35e0481d0979ed8539612a686ee..019b0119798e412fb7cf8cff08f3922188d10876 100644 (file)
@@ -364,7 +364,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
              CORE_ADDR addr;
 
              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);
 
              if (!value_bytes_available (val, embedded_offset + field_offset,
index 773d3f8053cc6187e482c1657bb3f02b92fcba0e..80b7eddd87871b867440714ef7b29e3bfd089ce5 100644 (file)
@@ -195,7 +195,7 @@ vtable_address_point_offset (struct gdbarch *gdbarch)
   struct type *vtable_type
     = (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);
 }
 
index a3af19541e8970e12c24c1a30b593bf7559ab765..fab7f0ad5b79c3e3e55dae2526910f218302bada 100644 (file)
@@ -102,7 +102,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
       for (i = low_bound; i <= high_bound; i++)
        {
          bitval = value_bit_index (type->field (field).type (),
-                                   (TYPE_FIELD_BITPOS (type, field) / 8) +
+                                   (type->field (field).loc_bitpos () / 8) +
                                    valaddr + embedded_offset, i);
          if (bitval < 0)
            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 ();
 
   addr = unpack_pointer (type->field (0).type (),
-                        (TYPE_FIELD_BITPOS (type, 0) / 8) +
+                        (type->field (0).loc_bitpos () / 8) +
                         valaddr);
 
   val = value_at_lazy (TYPE_TARGET_TYPE (type->field (0).type ()),
index 65eec4797583b1e8a20bf6bde0495db689b4ca86..89f689e02cc566ef7728b47553be60c9c9ba5c51 100644 (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.  */
       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;
 
       /* 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)
        return 0;
 
index cac8fbeaeb07f6ba8fc2f7180f0ec8c3389ad6b2..b30b03bdc8103a15faca93833fef4b13df43c4e4 100644 (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)
        {
          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)
            *length_size = TYPE_LENGTH (type->field (0).type ());
          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)
            *char_type = TYPE_TARGET_TYPE (type->field (1).type ());
          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)
        {
          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)
            *length_size = TYPE_LENGTH (type->field (1).type ());
          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 ??  */
          if (char_type)
            {
index 335d4b8b471126a57e802871389865fd33cf711d..e3c524c3b59de7933eef8dcb4a45b7d39b16fa9d 100644 (file)
@@ -306,7 +306,7 @@ pascal_language::value_print_inner (struct value *val,
          print_address_demangle
            (options, gdbarch,
             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 ()),
                byte_order),
             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>",
                                metadata_style.style (), stream);
                }
-             else if (value_bits_synthetic_pointer (val,
-                                                    TYPE_FIELD_BITPOS (type,
-                                                                       i),
-                                                    TYPE_FIELD_BITSIZE (type,
-                                                                        i)))
+             else if (value_bits_synthetic_pointer
+                        (val, type->field (i).loc_bitpos (),
+                         TYPE_FIELD_BITSIZE (type, i)))
                {
                  fputs_styled (_("<synthetic pointer>"),
                                metadata_style.style (), stream);
index 7980bec1c90562a702799704cbfafe25abc94c7e..0895093e5e35bd66e249c489c6e852dd42557c58 100644 (file)
@@ -192,7 +192,7 @@ convert_field (struct type *type, int field)
          if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
            arg = gdbpy_ref<>::new_reference (Py_None);
          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";
        }
 
index 069aebf372a4e44f316b4862453b9e55c5c667f7..bfd93c65d22285765c03fc7f098abf651b6654b2 100644 (file)
@@ -2548,7 +2548,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
       struct type *field_type = type->field (i).type ();
       field_type = check_typedef (field_type);
       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 ())
        {
index 1da758f781665e4cb32b7cc8aad9e165b0b55623..e5a404187bef18d62223e719ec9272fd125e93e5 100644 (file)
@@ -686,8 +686,8 @@ rust_print_struct_def (struct type *type, const char *varstring,
     std::sort (fields.begin (), fields.end (),
               [&] (int a, int b)
               {
-                return (TYPE_FIELD_BITPOS (type, a)
-                        < TYPE_FIELD_BITPOS (type, b));
+                return (type->field (a).loc_bitpos ()
+                        < type->field (b).loc_bitpos ());
               });
 
   for (int i : fields)
@@ -943,7 +943,7 @@ rust_composite_type (struct type *original,
 
   if (i > 0)
     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 ()));
   return result;
 }
index 4a1b864621d0a2d743173ea18eb31d40d8486a0b..c0d31599570e12fd2b3763fc2812694ee4d58f3e 100644 (file)
@@ -1267,7 +1267,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
       for (i = 0; i < type->num_fields (); i++)
        {
          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,
                                         element, subpos);
@@ -1355,7 +1355,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
       for (i = 0; i < type->num_fields (); i++)
        {
          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);
        }
index 8ca3d3efe2cbaed5e038fc6cbb1711f9331494ce..097fb6860fae78b426c99e1340a94c63c5e2eae5 100644 (file)
@@ -143,7 +143,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
       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_bit = fieldsize_byte * TARGET_CHAR_BIT;
 
index a80bdf08611bec010a76bc66e1ce059b77772c44..0d025841b12c66b922c6a3a4ced0b1bfcc3486af 100644 (file)
@@ -2030,8 +2030,8 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
                   have to add the offset of the union here.  */
                if (field_type->code () == TYPE_CODE_STRUCT
                    || (field_type->num_fields () > 0
-                       && TYPE_FIELD_BITPOS (field_type, 0) == 0))
-                 new_offset += TYPE_FIELD_BITPOS (type, i) / 8;
+                       && field_type->field (0).loc_bitpos () == 0))
+                 new_offset += type->field (i).loc_bitpos () / 8;
 
                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++)
     {
       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 ()))
        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)
            return value_from_longest
              (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)
            return allocate_value (t->field (i).type ());
          else
index e5afb3d10a35e8dc4e2936ff8938509ad06dbd90..2656d0ded3fd7693243dcdeb3b2e8e4e060f2ad8 100644 (file)
@@ -1214,7 +1214,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
                 int.  */
              && 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
                  (stream, " %ps",
                   styled_string (variable_name_style.style (),
@@ -1223,7 +1223,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
          else
            {
              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)
                field_val &= ((ULONGEST) 1 << field_len) - 1;
index b6672c77073f5422d8c1522d46fe5289fff65e77..e64811fe87c8f803d7608c6a7c86be4a53e1511a 100644 (file)
@@ -3044,7 +3044,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
         bit.  Assume that the address, offset, and embedded offset
         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;
 
       v = allocate_value_lazy (type);
@@ -3082,7 +3082,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
                                    value_address (arg1),
                                    arg1);
       else
-       boffset = TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
+       boffset = arg_type->field (fieldno).loc_bitpos () / 8;
 
       if (value_lazy (arg1))
        v = allocate_value_lazy (value_enclosing_type (arg1));
@@ -3110,7 +3110,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
   else
     {
       /* Plain old data member */
-      offset += (TYPE_FIELD_BITPOS (arg_type, fieldno)
+      offset += (arg_type->field (fieldno).loc_bitpos ()
                 / (HOST_CHAR_BIT * unit_size));
 
       /* 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,
                            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);
   struct type *field_type = type->field (fieldno).type ();
   int bit_offset;
@@ -3297,7 +3297,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
 LONGEST
 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);
   struct type *field_type = type->field (fieldno).type ();
 
@@ -3362,7 +3362,7 @@ value_field_bitfield (struct type *type, int fieldno,
                      const gdb_byte *valaddr,
                      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);
   struct value *res_val = allocate_value (type->field (fieldno).type ());