aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-09-30 22:38:29 -0400
committerSimon Marchi <simon.marchi@efficios.com>2021-10-07 11:03:54 -0400
commitcd3f655cc7a55437a05aa8e7b1fcc9051b5fe404 (patch)
tree6ac5ac49884488ff6e8856d8d1ae7964a47866fe /gdb
parent8baf3d07567f886be683aa26e3fc92346b604a93 (diff)
downloadgdb-cd3f655cc7a55437a05aa8e7b1fcc9051b5fe404.zip
gdb-cd3f655cc7a55437a05aa8e7b1fcc9051b5fe404.tar.gz
gdb-cd3f655cc7a55437a05aa8e7b1fcc9051b5fe404.tar.bz2
gdb: add accessors for field (and call site) location
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. Note that the field structure, being zero-initialized, defaults to a bitpos location with value 0. While writing this patch, I tried to make it default to an "unset" location, to catch places where we would miss setting a field's location. However, I found that some places relied on the default being "bitpos 0", so I left it as-is. This change could always be done as follow-up work, making these places explicitly set the "bitpos 0" location. I found two issues to fix: - I got some failures in the gdb.base/infcall-nested-structs-c++.exp test. They were caused by two functions in amd64-tdep.c using TYPE_FIELD_BITPOS before checking if the location is of the bitpos kind, which they do indirectly through `field_is_static`. Simply move getting the bitpos below the field_is_static call. - I got a failure in gdb.xml/tdesc-regs.exp. It turns out that in make_gdb_type_enum, we set enum field values using SET_FIELD_BITPOS, and later access them through FIELD_ENUMVAL. Fix that by using set_loc_enumval to set the value. Change-Id: I53d3734916c46457576ba11dd77df4049d2fc1e8
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ada-lang.c2
-rw-r--r--gdb/amd64-tdep.c11
-rw-r--r--gdb/coffread.c6
-rw-r--r--gdb/cp-valprint.c12
-rw-r--r--gdb/ctfread.c4
-rw-r--r--gdb/dwarf2/read.c41
-rw-r--r--gdb/gdbtypes.c33
-rw-r--r--gdb/gdbtypes.h145
-rw-r--r--gdb/gnu-v3-abi.c12
-rw-r--r--gdb/mdebugread.c4
-rw-r--r--gdb/rust-lang.c4
-rw-r--r--gdb/stabsread.c12
-rw-r--r--gdb/target-descriptions.c6
-rw-r--r--gdb/windows-tdep.c2
14 files changed, 189 insertions, 105 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6a19ad9..98718bc 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7503,7 +7503,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/amd64-tdep.c b/gdb/amd64-tdep.c
index 129f07e..4776120 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -553,7 +553,6 @@ amd64_has_unaligned_fields (struct type *type)
for (int i = 0; i < type->num_fields (); i++)
{
struct type *subtype = check_typedef (type->field (i).type ());
- int bitpos = TYPE_FIELD_BITPOS (type, i);
/* Ignore static fields, empty fields (for example nested
empty structures), and bitfields (these are handled by
@@ -564,6 +563,8 @@ amd64_has_unaligned_fields (struct type *type)
|| TYPE_FIELD_PACKED (type, i))
continue;
+ int bitpos = TYPE_FIELD_BITPOS (type, i);
+
if (bitpos % 8 != 0)
return true;
@@ -592,21 +593,21 @@ amd64_classify_aggregate_field (struct type *type, int i,
unsigned int bitoffset)
{
struct type *subtype = check_typedef (type->field (i).type ());
- int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
- int pos = bitpos / 64;
enum amd64_reg_class subclass[2];
int bitsize = TYPE_FIELD_BITSIZE (type, i);
- int endpos;
if (bitsize == 0)
bitsize = TYPE_LENGTH (subtype) * 8;
- endpos = (bitpos + bitsize - 1) / 64;
/* Ignore static fields, or empty fields, for example nested
empty structures.*/
if (field_is_static (&type->field (i)) || bitsize == 0)
return;
+ int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
+ int pos = bitpos / 64;
+ int endpos = (bitpos + bitsize - 1) / 64;
+
if (subtype->code () == TYPE_CODE_STRUCT
|| subtype->code () == TYPE_CODE_UNION)
{
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 30cf819..225e0e2 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -2012,7 +2012,7 @@ coff_read_struct_type (int index, int length, int lastsym,
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;
@@ -2029,7 +2029,7 @@ coff_read_struct_type (int index, int length, int lastsym,
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;
@@ -2145,7 +2145,7 @@ coff_read_enum_type (int index, int length, int lastsym,
SYMBOL_TYPE (xsym) = type;
type->field (n).set_name (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 f6969a5..ef7276a 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 3d2cb11..712683b 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;
fp->set_name (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 5d48e4c..cbd9a30 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9093,7 +9093,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 (0).set_name ("<<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. */
@@ -9113,7 +9113,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 (2).set_name (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 } };
@@ -13469,7 +13469,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 ())
@@ -13483,7 +13484,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 ())
{
@@ -13505,7 +13506,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
{
@@ -13521,7 +13522,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
{
lowpc = (gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr)
- baseaddr);
- SET_FIELD_PHYSADDR (call_site->target, lowpc);
+ call_site->target.set_loc_physaddr (lowpc);
}
}
}
@@ -14483,7 +14484,7 @@ handle_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 ();
@@ -14492,7 +14493,7 @@ handle_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;
@@ -14509,7 +14510,7 @@ handle_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
@@ -14519,7 +14520,7 @@ handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
{
attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu);
if (attr != nullptr)
- SET_FIELD_BITPOS (*field, attr->constant_value (0));
+ field->set_loc_bitpos (attr->constant_value (0));
}
}
@@ -14568,7 +14569,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);
@@ -14593,8 +14594,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
{
@@ -14623,10 +14623,9 @@ 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));
}
}
@@ -14682,7 +14681,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));
fp->set_name (fieldname);
}
@@ -16142,7 +16141,7 @@ update_enumeration_type_from_children (struct die_info *die,
fields.emplace_back ();
struct field &field = fields.back ();
field.set_name (dwarf2_physname (name, child_die, cu));
- SET_FIELD_ENUMVAL (field, value);
+ field.set_loc_enumval (value);
}
if (!fields.empty ())
@@ -16416,7 +16415,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;
@@ -16564,7 +16563,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
result->field (1).set_name ("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 913a877..de73a2b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2599,8 +2599,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
@@ -5561,25 +5561,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__,
@@ -5846,7 +5843,7 @@ append_flags_type_field (struct type *type, int start_bitpos, int nr_bits,
type->field (field_nr).set_name (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);
}
@@ -5918,10 +5915,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)
{
@@ -5932,7 +5927,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 4e5b2f1..dc575c4 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -664,7 +664,74 @@ struct field
m_name = name;
}
- 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
@@ -675,7 +742,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
@@ -1742,11 +1809,52 @@ enum call_site_parameter_kind
struct call_site_target
{
- union field_location loc;
+ field_loc_kind loc_kind () const
+ {
+ return m_loc_kind;
+ }
+
+ 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
@@ -2016,29 +2124,12 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
-#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 748d555..b82ac59 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->set_name ("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->set_name ("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->set_name ("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->set_name ("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++;
@@ -1035,14 +1035,14 @@ build_std_type_info_type (struct gdbarch *arch)
/* The vtable. */
field->set_name ("_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->set_name ("__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 3e560ae..0faff5f 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);
f->set_name (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++;
f->set_name (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 79284be..3c6a358 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->set_name (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->set_name (field2);
field->set_type (type2);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index f63b372..64734b7 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 (n).set_name (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 f5ec617..4587eca 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_enumval (f.start);
}
}
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index c79d5e2..f6005a3 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 (i).set_name (values[i].name);
- SET_FIELD_ENUMVAL (type->field (i), values[i].value);
+ type->field (i).set_loc_enumval (values[i].value);
}
return type;