[PATCH] gdb: add accessors for field (and call site) location
Simon Marchi
simon.marchi@polymtl.ca
Fri Sep 24 04:09:24 GMT 2021
Add accessors for the various location values in struct field. This
lets us assert that when we get a location value of a certain kind (say,
bitpos), the field's location indeed contains a value of that kind.
Remove the SET_FIELD_* macros, instead use the new setters directly.
Update the FIELD_* macros used to access field locations to go through
the getters. They will be removed in a subsequent patch.
There are places where the FIELD_* macros are used on call_site_target
structures, because it contains members of the same name (loc_kind and
loc). For now, I have replicated the getters/setters in
call_site_target. But we could perhaps eventually factor them in a
"location" structure that can be used at both places.
I also added a FIELD_LOC_KIND_UNSET value to the field_loc_kind enum.
Otherwise, fields, which are zero-initialized, are created with loc ==
FIELD_LOC_KIND_BITPOS, with a bitpos == 0. This could help catch cases
where debug info readers fail to set the location, which would be a bug.
Change-Id: I53d3734916c46457576ba11dd77df4049d2fc1e8
---
gdb/ada-lang.c | 2 +-
gdb/coffread.c | 6 +-
gdb/cp-valprint.c | 12 +--
gdb/ctfread.c | 4 +-
gdb/dwarf2/read.c | 42 +++++-----
gdb/gdbtypes.c | 33 ++++----
gdb/gdbtypes.h | 172 ++++++++++++++++++++++++++++++--------
gdb/gnu-v3-abi.c | 12 +--
gdb/mdebugread.c | 4 +-
gdb/rust-lang.c | 4 +-
gdb/stabsread.c | 12 ++-
gdb/target-descriptions.c | 6 +-
gdb/windows-tdep.c | 2 +-
13 files changed, 203 insertions(+), 108 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 487d92be5c92..2b1ae84fd846 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7528,7 +7528,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
{
off = align_up (off, field_alignment (type, f))
+ TYPE_FIELD_BITPOS (type, f);
- SET_FIELD_BITPOS (rtype->field (f), off);
+ rtype->field (f).set_loc_bitpos (off);
TYPE_FIELD_BITSIZE (rtype, f) = 0;
if (ada_is_variant_part (type, f))
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 0135363bc5a5..b9fe2a69852b 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2011,7 +2011,7 @@ coff_read_struct_type (int index, int length, int lastsym,
list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile));
- SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
+ list->field.set_loc_bitpos (8 * ms->c_value);
FIELD_BITSIZE (list->field) = 0;
nfields++;
break;
@@ -2027,7 +2027,7 @@ coff_read_struct_type (int index, int length, int lastsym,
list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile));
- SET_FIELD_BITPOS (list->field, ms->c_value);
+ list->field.set_loc_bitpos (ms->c_value);
FIELD_BITSIZE (list->field) = sub_aux.x_sym.x_misc.x_lnsz.x_size;
nfields++;
break;
@@ -2143,7 +2143,7 @@ coff_read_enum_type (int index, int length, int lastsym,
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
- SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
+ type->field (n).set_loc_enumval (SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
TYPE_FIELD_BITSIZE (type, n) = 0;
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 7442ec0743e1..d2b508ed6369 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -735,13 +735,13 @@ test_print_fields (gdbarch *arch)
if (gdbarch_byte_order (arch) == BFD_ENDIAN_LITTLE)
{
f = append_composite_type_field_raw (the_struct, "A", bool_type);
- SET_FIELD_BITPOS (*f, 1);
+ f->set_loc_bitpos (1);
FIELD_BITSIZE (*f) = 1;
f = append_composite_type_field_raw (the_struct, "B", uint8_type);
- SET_FIELD_BITPOS (*f, 3);
+ f->set_loc_bitpos (3);
FIELD_BITSIZE (*f) = 3;
f = append_composite_type_field_raw (the_struct, "C", bool_type);
- SET_FIELD_BITPOS (*f, 7);
+ f->set_loc_bitpos (7);
FIELD_BITSIZE (*f) = 1;
}
/* According to the logic commented in "make_gdb_type_struct ()" of
@@ -750,13 +750,13 @@ test_print_fields (gdbarch *arch)
else
{
f = append_composite_type_field_raw (the_struct, "A", bool_type);
- SET_FIELD_BITPOS (*f, 30);
+ f->set_loc_bitpos (30);
FIELD_BITSIZE (*f) = 1;
f = append_composite_type_field_raw (the_struct, "B", uint8_type);
- SET_FIELD_BITPOS (*f, 26);
+ f->set_loc_bitpos (26);
FIELD_BITSIZE (*f) = 3;
f = append_composite_type_field_raw (the_struct, "C", bool_type);
- SET_FIELD_BITPOS (*f, 24);
+ f->set_loc_bitpos (24);
FIELD_BITSIZE (*f) = 1;
}
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 01334e4d3028..22747cc59537 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -418,7 +418,7 @@ ctf_add_member_cb (const char *name,
process_struct_members (ccp, tid, t);
fp->set_type (t);
- SET_FIELD_BITPOS (*fp, offset / TARGET_CHAR_BIT);
+ fp->set_loc_bitpos (offset / TARGET_CHAR_BIT);
FIELD_BITSIZE (*fp) = get_bitsize (ccp->fp, tid, kind);
fip->fields.emplace_back (new_field);
@@ -440,7 +440,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
fp = &new_field.field;
FIELD_NAME (*fp) = name;
fp->set_type (nullptr);
- SET_FIELD_ENUMVAL (*fp, enum_value);
+ fp->set_loc_enumval (enum_value);
FIELD_BITSIZE (*fp) = 0;
if (name != nullptr)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3c81ac6b7b51..c6106c41e7b6 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9089,7 +9089,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
type->field (0).set_type (field_type);
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
- SET_FIELD_BITPOS (type->field (0), bit_offset);
+ type->field (0).set_loc_bitpos (bit_offset);
/* The order of fields doesn't really matter, so put the real
field at index 1 and the data-less field at index 2. */
@@ -9109,7 +9109,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name;
- SET_FIELD_BITPOS (type->field (2), 0);
+ type->field (2).set_loc_bitpos (0);
/* Indicate that this is a variant type. */
static discriminant_range ranges[1] = { { 0, 0 } };
@@ -13463,7 +13463,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
/* This was a pre-DWARF-5 GNU extension alias for DW_AT_call_origin. */
attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
}
- SET_FIELD_DWARF_BLOCK (call_site->target, NULL);
+
+ call_site->target.set_loc_dwarf_block (nullptr);
if (!attr || (attr->form_is_block () && attr->as_block ()->size == 0))
/* Keep NULL DWARF_BLOCK. */;
else if (attr->form_is_block ())
@@ -13477,7 +13478,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
dlbaton->per_objfile = per_objfile;
dlbaton->per_cu = cu->per_cu;
- SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton);
+ call_site->target.set_loc_dwarf_block (dlbaton);
}
else if (attr->form_is_ref ())
{
@@ -13499,7 +13500,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
"physname, for referencing DIE %s [in module %s]"),
sect_offset_str (die->sect_off), objfile_name (objfile));
else
- SET_FIELD_PHYSNAME (call_site->target, target_physname);
+ call_site->target.set_loc_physname (target_physname);
}
else
{
@@ -13514,7 +13515,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
else
{
lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
- SET_FIELD_PHYSADDR (call_site->target, lowpc);
+ call_site->target.set_loc_physaddr (lowpc);
}
}
}
@@ -14469,7 +14470,7 @@ handle_data_member_location (struct die_info *die, struct dwarf2_cu *cu,
if (attr->form_is_constant ())
{
LONGEST offset = attr->constant_value (0);
- SET_FIELD_BITPOS (*field, offset * bits_per_byte);
+ field->set_loc_bitpos (offset * bits_per_byte);
}
else if (attr->form_is_section_offset ())
dwarf2_complex_location_expr_complaint ();
@@ -14478,7 +14479,7 @@ handle_data_member_location (struct die_info *die, struct dwarf2_cu *cu,
bool handled;
CORE_ADDR offset = decode_locdesc (attr->as_block (), cu, &handled);
if (handled)
- SET_FIELD_BITPOS (*field, offset * bits_per_byte);
+ field->set_loc_bitpos (offset * bits_per_byte);
else
{
dwarf2_per_objfile *per_objfile = cu->per_objfile;
@@ -14495,7 +14496,7 @@ handle_data_member_location (struct die_info *die, struct dwarf2_cu *cu,
dlbaton->per_objfile = per_objfile;
dlbaton->per_cu = cu->per_cu;
- SET_FIELD_DWARF_BLOCK (*field, dlbaton);
+ field->set_loc_dwarf_block (dlbaton);
}
}
else
@@ -14548,7 +14549,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
/* Get type of field. */
fp->set_type (die_type (die, cu));
- SET_FIELD_BITPOS (*fp, 0);
+ fp->set_loc_bitpos (0);
/* Get bit size of field (zero if none). */
attr = dwarf2_attr (die, DW_AT_bit_size, cu);
@@ -14573,8 +14574,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
anonymous object to the MSB of the field. We don't
have to do anything special since we don't need to
know the size of the anonymous object. */
- SET_FIELD_BITPOS (*fp, (FIELD_BITPOS (*fp)
- + attr->constant_value (0)));
+ fp->set_loc_bitpos ((FIELD_BITPOS (*fp) + attr->constant_value (0)));
}
else
{
@@ -14603,16 +14603,14 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
bit field. */
anonymous_size = TYPE_LENGTH (fp->type ());
}
- SET_FIELD_BITPOS (*fp,
- (FIELD_BITPOS (*fp)
- + anonymous_size * bits_per_byte
- - bit_offset - FIELD_BITSIZE (*fp)));
+ fp->set_loc_bitpos (FIELD_BITPOS (*fp)
+ + anonymous_size * bits_per_byte
+ - bit_offset - FIELD_BITSIZE (*fp));
}
}
attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu);
if (attr != NULL)
- SET_FIELD_BITPOS (*fp, (FIELD_BITPOS (*fp)
- + attr->constant_value (0)));
+ fp->set_loc_bitpos ((FIELD_BITPOS (*fp) + attr->constant_value (0)));
/* Get name of field. */
fieldname = dwarf2_name (die, cu);
@@ -14666,7 +14664,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
/* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */
- SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
+ fp->set_loc_physname (physname ? physname : "");
fp->set_type (die_type (die, cu));
FIELD_NAME (*fp) = fieldname;
}
@@ -16126,7 +16124,7 @@ update_enumeration_type_from_children (struct die_info *die,
fields.emplace_back ();
struct field &field = fields.back ();
FIELD_NAME (field) = dwarf2_physname (name, child_die, cu);
- SET_FIELD_ENUMVAL (field, value);
+ field.set_loc_enumval (value);
}
if (!fields.empty ())
@@ -16400,7 +16398,7 @@ recognize_bound_expression (struct die_info *die, enum dwarf_attribute name,
else
return false;
- SET_FIELD_BITPOS (*field, 8 * offset);
+ field->set_loc_bitpos (8 * offset);
if (size != TYPE_LENGTH (field->type ()))
FIELD_BITSIZE (*field) = 8 * size;
@@ -16548,7 +16546,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
TYPE_FIELD_NAME (result, 1) = "P_BOUNDS";
result->field (1).set_type (lookup_pointer_type (bounds));
- SET_FIELD_BITPOS (result->field (1), 8 * bounds_offset);
+ result->field (1).set_loc_bitpos (8 * bounds_offset);
result->set_name (type->name ());
TYPE_LENGTH (result) = (TYPE_LENGTH (result->field (0).type ())
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 67593dac0559..7860503ce041 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2598,8 +2598,8 @@ resolve_dynamic_struct (struct type *type,
CORE_ADDR addr;
if (dwarf2_evaluate_property (&prop, nullptr, addr_stack, &addr,
true))
- SET_FIELD_BITPOS (resolved_type->field (i),
- TARGET_CHAR_BIT * (addr - addr_stack->addr));
+ resolved_type->field (i).set_loc_bitpos
+ (TARGET_CHAR_BIT * (addr - addr_stack->addr));
}
/* As we know this field is not a static field, the field's
@@ -5563,25 +5563,22 @@ copy_type_recursive (struct objfile *objfile,
switch (TYPE_FIELD_LOC_KIND (type, i))
{
case FIELD_LOC_KIND_BITPOS:
- SET_FIELD_BITPOS (new_type->field (i),
- TYPE_FIELD_BITPOS (type, i));
+ new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i));
break;
case FIELD_LOC_KIND_ENUMVAL:
- SET_FIELD_ENUMVAL (new_type->field (i),
- TYPE_FIELD_ENUMVAL (type, i));
+ new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
break;
case FIELD_LOC_KIND_PHYSADDR:
- SET_FIELD_PHYSADDR (new_type->field (i),
- TYPE_FIELD_STATIC_PHYSADDR (type, i));
+ new_type->field (i).set_loc_physaddr
+ (TYPE_FIELD_STATIC_PHYSADDR (type, i));
break;
case FIELD_LOC_KIND_PHYSNAME:
- SET_FIELD_PHYSNAME (new_type->field (i),
- xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
- i)));
+ new_type->field (i).set_loc_physname
+ (xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, i)));
break;
case FIELD_LOC_KIND_DWARF_BLOCK:
- SET_FIELD_DWARF_BLOCK (new_type->field (i),
- TYPE_FIELD_DWARF_BLOCK (type, i));
+ new_type->field (i).set_loc_dwarf_block
+ (TYPE_FIELD_DWARF_BLOCK (type, i));
break;
default:
internal_error (__FILE__, __LINE__,
@@ -5848,7 +5845,7 @@ append_flags_type_field (struct type *type, int start_bitpos, int nr_bits,
TYPE_FIELD_NAME (type, field_nr) = xstrdup (name);
type->field (field_nr).set_type (field_type);
- SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
+ type->field (field_nr).set_loc_bitpos (start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
type->set_num_fields (type->num_fields () + 1);
}
@@ -5920,10 +5917,8 @@ append_composite_type_field_aligned (struct type *t, const char *name,
TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
if (t->num_fields () > 1)
{
- SET_FIELD_BITPOS (f[0],
- (FIELD_BITPOS (f[-1])
- + (TYPE_LENGTH (f[-1].type ())
- * TARGET_CHAR_BIT)));
+ f->set_loc_bitpos
+ ((FIELD_BITPOS (f[-1]) + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT)));
if (alignment)
{
@@ -5934,7 +5929,7 @@ append_composite_type_field_aligned (struct type *t, const char *name,
if (left)
{
- SET_FIELD_BITPOS (f[0], FIELD_BITPOS (f[0]) + (alignment - left));
+ f->set_loc_bitpos (FIELD_BITPOS (f[0]) + (alignment - left));
TYPE_LENGTH (t) += (alignment - left) / TARGET_CHAR_BIT;
}
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2a641122aec0..a2fae53f0ccd 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -577,13 +577,14 @@ struct dynamic_prop_list
used. */
enum field_loc_kind
- {
- FIELD_LOC_KIND_BITPOS, /**< bitpos */
- FIELD_LOC_KIND_ENUMVAL, /**< enumval */
- FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
- FIELD_LOC_KIND_PHYSNAME, /**< physname */
- FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
- };
+{
+ FIELD_LOC_KIND_UNSET = 0,
+ FIELD_LOC_KIND_BITPOS,
+ FIELD_LOC_KIND_ENUMVAL,
+ FIELD_LOC_KIND_PHYSADDR,
+ FIELD_LOC_KIND_PHYSNAME,
+ FIELD_LOC_KIND_DWARF_BLOCK,
+};
/* * A discriminant to determine which field in the
main_type.type_specific union is being used, if any.
@@ -654,7 +655,74 @@ struct field
this->m_type = type;
}
- union field_location loc;
+ /* Location getters / setters. */
+
+ field_loc_kind loc_kind () const
+ {
+ return m_loc_kind;
+ }
+
+ LONGEST loc_bitpos () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
+ return m_loc.bitpos;
+ }
+
+ void set_loc_bitpos (LONGEST bitpos)
+ {
+ m_loc_kind = FIELD_LOC_KIND_BITPOS;
+ m_loc.bitpos = bitpos;
+ }
+
+ LONGEST loc_enumval () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_ENUMVAL);
+ return m_loc.enumval;
+ }
+
+ void set_loc_enumval (LONGEST enumval)
+ {
+ m_loc_kind = FIELD_LOC_KIND_ENUMVAL;
+ m_loc.enumval = enumval;
+ }
+
+ CORE_ADDR loc_physaddr () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
+ return m_loc.physaddr;
+ }
+
+ void set_loc_physaddr (CORE_ADDR physaddr)
+ {
+ m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
+ m_loc.physaddr = physaddr;
+ }
+
+ const char *loc_physname () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
+ return m_loc.physname;
+ }
+
+ void set_loc_physname (const char *physname)
+ {
+ m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
+ m_loc.physname = physname;
+ }
+
+ dwarf2_locexpr_baton *loc_dwarf_block () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
+ return m_loc.dwarf_block;
+ }
+
+ void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
+ {
+ m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
+ m_loc.dwarf_block = dwarf_block;
+ }
+
+ union field_location m_loc;
/* * For a function or member type, this is 1 if the argument is
marked artificial. Artificial arguments should not be shown
@@ -665,7 +733,7 @@ struct field
/* * Discriminant for union field_location. */
- ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
+ ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
/* * Size of this field, in bits, or zero if not packed.
If non-zero in an array type, indicates the element size in
@@ -1732,11 +1800,64 @@ enum call_site_parameter_kind
struct call_site_target
{
- union field_location loc;
+ field_loc_kind loc_kind () const
+ {
+ return m_loc_kind;
+ }
+
+ LONGEST loc_bitpos () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
+ return m_loc.bitpos;
+ }
+
+ void set_loc_bitpos (LONGEST bitpos)
+ {
+ m_loc_kind = FIELD_LOC_KIND_BITPOS;
+ m_loc.bitpos = bitpos;
+ }
+
+ CORE_ADDR loc_physaddr () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
+ return m_loc.physaddr;
+ }
+
+ void set_loc_physaddr (CORE_ADDR physaddr)
+ {
+ m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
+ m_loc.physaddr = physaddr;
+ }
+
+ const char *loc_physname () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
+ return m_loc.physname;
+ }
+
+ void set_loc_physname (const char *physname)
+ {
+ m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
+ m_loc.physname = physname;
+ }
+
+ dwarf2_locexpr_baton *loc_dwarf_block () const
+ {
+ gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
+ return m_loc.dwarf_block;
+ }
+
+ void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
+ {
+ m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
+ m_loc.dwarf_block = dwarf_block;
+ }
+
+ union field_location m_loc;
/* * Discriminant for union field_location. */
- ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
+ ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
};
union call_site_parameter_u
@@ -1975,29 +2096,12 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
#define FIELD_NAME(thisfld) ((thisfld).name)
-#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
-#define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos)
-#define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0)
-#define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval)
-#define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0)
-#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
-#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
-#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
-#define SET_FIELD_BITPOS(thisfld, bitpos) \
- (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS, \
- FIELD_BITPOS_LVAL (thisfld) = (bitpos))
-#define SET_FIELD_ENUMVAL(thisfld, enumval) \
- (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_ENUMVAL, \
- FIELD_ENUMVAL_LVAL (thisfld) = (enumval))
-#define SET_FIELD_PHYSNAME(thisfld, name) \
- (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \
- FIELD_STATIC_PHYSNAME (thisfld) = (name))
-#define SET_FIELD_PHYSADDR(thisfld, addr) \
- (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \
- FIELD_STATIC_PHYSADDR (thisfld) = (addr))
-#define SET_FIELD_DWARF_BLOCK(thisfld, addr) \
- (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_DWARF_BLOCK, \
- FIELD_DWARF_BLOCK (thisfld) = (addr))
+#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind ())
+#define FIELD_BITPOS(thisfld) ((thisfld).loc_bitpos ())
+#define FIELD_ENUMVAL(thisfld) ((thisfld).loc_enumval ())
+#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
+#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
+#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 45e57c210cbf..fdd4bfefb250 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -137,28 +137,28 @@ build_gdb_vtable_type (struct gdbarch *arch)
/* ptrdiff_t vcall_and_vbase_offsets[0]; */
FIELD_NAME (*field) = "vcall_and_vbase_offsets";
field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1));
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* ptrdiff_t offset_to_top; */
FIELD_NAME (*field) = "offset_to_top";
field->set_type (ptrdiff_type);
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* void *type_info; */
FIELD_NAME (*field) = "type_info";
field->set_type (void_ptr_type);
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions";
field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1));
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
@@ -1038,14 +1038,14 @@ build_std_type_info_type (struct gdbarch *arch)
/* The vtable. */
FIELD_NAME (*field) = "_vptr.type_info";
field->set_type (void_ptr_type);
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* The name. */
FIELD_NAME (*field) = "__name";
field->set_type (char_ptr_type);
- SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
+ field->set_loc_bitpos (offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 026f2ff20da4..708ffee9daf2 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1056,7 +1056,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
if (tsym.st != stMember)
break;
- SET_FIELD_ENUMVAL (*f, tsym.value);
+ f->set_loc_enumval (tsym.value);
f->set_type (t);
FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
FIELD_BITSIZE (*f) = 0;
@@ -1242,7 +1242,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
struct field *f = &top_stack->cur_type->field (top_stack->cur_field);
top_stack->cur_field++;
FIELD_NAME (*f) = name;
- SET_FIELD_BITPOS (*f, sh->value);
+ f->set_loc_bitpos (sh->value);
bitsize = 0;
f->set_type (parse_type (cur_fd, ax, sh->index, &bitsize, bigend,
name));
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 60ea89b13949..2a5018ce6e1c 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -912,7 +912,7 @@ rust_composite_type (struct type *original,
{
struct field *field = &result->field (i);
- SET_FIELD_BITPOS (*field, bitpos);
+ field->set_loc_bitpos (bitpos);
bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT;
FIELD_NAME (*field) = field1;
@@ -933,7 +933,7 @@ rust_composite_type (struct type *original,
if (delta != 0)
bitpos += align - delta;
}
- SET_FIELD_BITPOS (*field, bitpos);
+ field->set_loc_bitpos (bitpos);
FIELD_NAME (*field) = field2;
field->set_type (type2);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 72cb351d2f8f..7f8d1d00fe46 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2755,8 +2755,7 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
{
int nbits;
- SET_FIELD_BITPOS (fip->list->field,
- read_huge_number (pp, ';', &nbits, 0));
+ fip->list->field.set_loc_bitpos (read_huge_number (pp, ';', &nbits, 0));
if (nbits != 0)
return 0;
}
@@ -2817,7 +2816,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
p++;
}
/* Static class member. */
- SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
+ fip->list->field.set_loc_physname (savestring (*pp, p - *pp));
*pp = p + 1;
return;
}
@@ -2833,8 +2832,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
{
int nbits;
- SET_FIELD_BITPOS (fip->list->field,
- read_huge_number (pp, ',', &nbits, 0));
+ fip->list->field.set_loc_bitpos (read_huge_number (pp, ',', &nbits, 0));
if (nbits != 0)
{
stabs_general_complaint ("bad structure-type format");
@@ -3110,7 +3108,7 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
corresponding to this baseclass. Always zero in the absence of
multiple inheritance. */
- SET_FIELD_BITPOS (newobj->field, read_huge_number (pp, ',', &nbits, 0));
+ newobj->field.set_loc_bitpos (read_huge_number (pp, ',', &nbits, 0));
if (nbits != 0)
return 0;
}
@@ -3639,7 +3637,7 @@ read_enum_type (const char **pp, struct type *type,
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
- SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
+ type->field (n).set_loc_enumval (SYMBOL_VALUE (xsym));
TYPE_FIELD_BITSIZE (type, n) = 0;
}
if (syms == osyms)
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index f94ace756d4d..39a974ca58a0 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -230,9 +230,9 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
bitsize = f.end - f.start + 1;
total_size = e->size * TARGET_CHAR_BIT;
if (gdbarch_byte_order (m_gdbarch) == BFD_ENDIAN_BIG)
- SET_FIELD_BITPOS (fld[0], total_size - f.start - bitsize);
+ fld->set_loc_bitpos (total_size - f.start - bitsize);
else
- SET_FIELD_BITPOS (fld[0], f.start);
+ fld->set_loc_bitpos (f.start);
FIELD_BITSIZE (fld[0]) = bitsize;
}
else
@@ -298,7 +298,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
xstrdup (f.name.c_str ()),
NULL);
- SET_FIELD_BITPOS (fld[0], f.start);
+ fld->set_loc_bitpos (f.start);
}
}
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 8e8bc1c06d44..acba467208b2 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -762,7 +762,7 @@ create_enum (struct gdbarch *gdbarch, int bit, const char *name,
for (i = 0; i < count; i++)
{
TYPE_FIELD_NAME (type, i) = values[i].name;
- SET_FIELD_ENUMVAL (type->field (i), values[i].value);
+ type->field (i).set_loc_enumval (values[i].value);
}
return type;
--
2.33.0
More information about the Gdb-patches
mailing list