gdb: add field::name / field::set_name

Add the `name` and `set_name` methods on `struct field`, in order to
remove `FIELD_NAME` and `TYPE_FIELD_NAME` macros.  In this patch, the
macros are changed to use `field::name`, so all the call sites that are
used to set the field's name are changed to use `field::set_name`.
The next patch will remove the macros completely.

Note that because of the name clash between the existing field named
`name` and the new method, I renamed the field `m_name`.  It is not
private per-se, because we can't make `struct field` a non-POD yet, but
it should be considered private anyway (not accessed outside `struct
field`).

Change-Id: If16ddbca4e0c39d0ff9da420bb5cdebe5b9b0896
This commit is contained in:
Simon Marchi 2021-08-30 11:49:48 -04:00
parent cdfbeec413
commit d3fd12dfc5
11 changed files with 71 additions and 59 deletions

View file

@ -7601,7 +7601,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
ada_ensure_varsize_limit (field_type); ada_ensure_varsize_limit (field_type);
rtype->field (f).set_type (field_type); rtype->field (f).set_type (field_type);
TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f); rtype->field (f).set_name (TYPE_FIELD_NAME (type, f));
/* The multiplication can potentially overflow. But because /* The multiplication can potentially overflow. But because
the field length has been size-checked just above, and the field length has been size-checked just above, and
assuming that the maximum size is a reasonable value, assuming that the maximum size is a reasonable value,
@ -7624,7 +7624,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
to distinguish between the two options. Stripping it to distinguish between the two options. Stripping it
would prevent us from printing this field appropriately. */ would prevent us from printing this field appropriately. */
rtype->field (f).set_type (type->field (f).type ()); rtype->field (f).set_type (type->field (f).type ());
TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f); rtype->field (f).set_name (TYPE_FIELD_NAME (type, f));
if (TYPE_FIELD_BITSIZE (type, f) > 0) if (TYPE_FIELD_BITSIZE (type, f) > 0)
fld_bit_len = fld_bit_len =
TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f); TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f);
@ -7686,7 +7686,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
else else
{ {
rtype->field (variant_field).set_type (branch_type); rtype->field (variant_field).set_type (branch_type);
TYPE_FIELD_NAME (rtype, variant_field) = "S"; rtype->field (variant_field).set_name ("S");
fld_bit_len = fld_bit_len =
TYPE_LENGTH (rtype->field (variant_field).type ()) * TYPE_LENGTH (rtype->field (variant_field).type ()) *
TARGET_CHAR_BIT; TARGET_CHAR_BIT;
@ -7802,7 +7802,7 @@ template_to_static_fixed_type (struct type *type0)
TYPE_LENGTH (type) = 0; TYPE_LENGTH (type) = 0;
} }
type->field (f).set_type (new_type); type->field (f).set_type (new_type);
TYPE_FIELD_NAME (type, f) = TYPE_FIELD_NAME (type0, f); type->field (f).set_name (TYPE_FIELD_NAME (type0, f));
} }
} }
@ -7871,7 +7871,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
else else
{ {
rtype->field (variant_field).set_type (branch_type); rtype->field (variant_field).set_type (branch_type);
TYPE_FIELD_NAME (rtype, variant_field) = "S"; rtype->field (variant_field).set_name ("S");
TYPE_FIELD_BITSIZE (rtype, variant_field) = 0; TYPE_FIELD_BITSIZE (rtype, variant_field) = 0;
TYPE_LENGTH (rtype) += TYPE_LENGTH (branch_type); TYPE_LENGTH (rtype) += TYPE_LENGTH (branch_type);
} }

View file

@ -2008,7 +2008,8 @@ coff_read_struct_type (int index, int length, int lastsym,
list = newobj; list = newobj;
/* Save the data. */ /* Save the data. */
list->field.name = obstack_strdup (&objfile->objfile_obstack, name); list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
name));
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux, list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile)); objfile));
SET_FIELD_BITPOS (list->field, 8 * ms->c_value); SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
@ -2024,7 +2025,8 @@ coff_read_struct_type (int index, int length, int lastsym,
list = newobj; list = newobj;
/* Save the data. */ /* Save the data. */
list->field.name = obstack_strdup (&objfile->objfile_obstack, name); list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
name));
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux, list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile)); objfile));
SET_FIELD_BITPOS (list->field, ms->c_value); SET_FIELD_BITPOS (list->field, ms->c_value);
@ -2142,7 +2144,7 @@ coff_read_enum_type (int index, int length, int lastsym,
struct symbol *xsym = syms->symbol[j]; struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type; SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name (); type->field (n).set_name (xsym->linkage_name ());
SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym)); SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0) if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0; unsigned_enum = 0;

View file

@ -399,7 +399,7 @@ ctf_add_member_cb (const char *name,
uint32_t kind; uint32_t kind;
fp = &new_field.field; fp = &new_field.field;
FIELD_NAME (*fp) = name; fp->set_name (name);
kind = ctf_type_kind (ccp->fp, tid); kind = ctf_type_kind (ccp->fp, tid);
t = fetch_tid_type (ccp, tid); t = fetch_tid_type (ccp, tid);
@ -438,7 +438,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
struct ctf_context *ccp = fip->cur_context; struct ctf_context *ccp = fip->cur_context;
fp = &new_field.field; fp = &new_field.field;
FIELD_NAME (*fp) = name; fp->set_name (name);
fp->set_type (nullptr); fp->set_type (nullptr);
SET_FIELD_ENUMVAL (*fp, enum_value); SET_FIELD_ENUMVAL (*fp, enum_value);
FIELD_BITSIZE (*fp) = 0; FIELD_BITSIZE (*fp) = 0;

View file

@ -9092,14 +9092,14 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Put the discriminant at index 0. */ /* Put the discriminant at index 0. */
type->field (0).set_type (field_type); type->field (0).set_type (field_type);
TYPE_FIELD_ARTIFICIAL (type, 0) = 1; TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>"; type->field (0).set_name ("<<discriminant>>");
SET_FIELD_BITPOS (type->field (0), bit_offset); SET_FIELD_BITPOS (type->field (0), bit_offset);
/* The order of fields doesn't really matter, so put the real /* The order of fields doesn't really matter, so put the real
field at index 1 and the data-less field at index 2. */ field at index 1 and the data-less field at index 2. */
type->field (1) = saved_field; type->field (1) = saved_field;
TYPE_FIELD_NAME (type, 1) type->field (1).set_name
= rust_last_path_segment (type->field (1).type ()->name ()); (rust_last_path_segment (type->field (1).type ()->name ()));
type->field (1).type ()->set_name type->field (1).type ()->set_name
(rust_fully_qualify (&objfile->objfile_obstack, type->name (), (rust_fully_qualify (&objfile->objfile_obstack, type->name (),
TYPE_FIELD_NAME (type, 1))); TYPE_FIELD_NAME (type, 1)));
@ -9112,7 +9112,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
type->field (2).set_type (dataless_type); type->field (2).set_type (dataless_type);
/* NAME points into the original discriminant name, which /* NAME points into the original discriminant name, which
already has the correct lifetime. */ already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name; type->field (2).set_name (name);
SET_FIELD_BITPOS (type->field (2), 0); SET_FIELD_BITPOS (type->field (2), 0);
/* Indicate that this is a variant type. */ /* Indicate that this is a variant type. */
@ -9130,7 +9130,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
struct type *field_type = type->field (0).type (); struct type *field_type = type->field (0).type ();
const char *variant_name const char *variant_name
= rust_last_path_segment (field_type->name ()); = rust_last_path_segment (field_type->name ());
TYPE_FIELD_NAME (type, 0) = variant_name; type->field (0).set_name (variant_name);
field_type->set_name field_type->set_name
(rust_fully_qualify (&objfile->objfile_obstack, (rust_fully_qualify (&objfile->objfile_obstack,
type->name (), variant_name)); type->name (), variant_name));
@ -9189,7 +9189,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Install the discriminant at index 0 in the union. */ /* Install the discriminant at index 0 in the union. */
type->field (0) = *disr_field; type->field (0) = *disr_field;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1; TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>"; type->field (0).set_name ("<<discriminant>>");
/* We need a way to find the correct discriminant given a /* We need a way to find the correct discriminant given a
variant name. For convenience we build a map here. */ variant name. For convenience we build a map here. */
@ -9239,7 +9239,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
sub_type->set_num_fields (sub_type->num_fields () - 1); sub_type->set_num_fields (sub_type->num_fields () - 1);
sub_type->set_fields (sub_type->fields () + 1); sub_type->set_fields (sub_type->fields () + 1);
} }
TYPE_FIELD_NAME (type, i) = variant_name; type->field (i).set_name (variant_name);
sub_type->set_name sub_type->set_name
(rust_fully_qualify (&objfile->objfile_obstack, (rust_fully_qualify (&objfile->objfile_obstack,
type->name (), variant_name)); type->name (), variant_name));
@ -14637,7 +14637,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 /* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */ need to duplicate it for the type. */
fp->name = fieldname; fp->set_name (fieldname);
/* Change accessibility for artificial fields (e.g. virtual table /* Change accessibility for artificial fields (e.g. virtual table
pointer or virtual base class pointer) to private. */ pointer or virtual base class pointer) to private. */
@ -14684,7 +14684,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
need to duplicate it for the type. */ need to duplicate it for the type. */
SET_FIELD_PHYSNAME (*fp, physname ? physname : ""); SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
fp->set_type (die_type (die, cu)); fp->set_type (die_type (die, cu));
FIELD_NAME (*fp) = fieldname; fp->set_name (fieldname);
} }
else if (die->tag == DW_TAG_inheritance) else if (die->tag == DW_TAG_inheritance)
{ {
@ -14692,7 +14692,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
handle_member_location (die, cu, fp); handle_member_location (die, cu, fp);
FIELD_BITSIZE (*fp) = 0; FIELD_BITSIZE (*fp) = 0;
fp->set_type (die_type (die, cu)); fp->set_type (die_type (die, cu));
FIELD_NAME (*fp) = fp->type ()->name (); fp->set_name (fp->type ()->name ());
} }
else else
gdb_assert_not_reached ("missing case in dwarf2_add_field"); gdb_assert_not_reached ("missing case in dwarf2_add_field");
@ -16141,7 +16141,7 @@ update_enumeration_type_from_children (struct die_info *die,
fields.emplace_back (); fields.emplace_back ();
struct field &field = fields.back (); struct field &field = fields.back ();
FIELD_NAME (field) = dwarf2_physname (name, child_die, cu); field.set_name (dwarf2_physname (name, child_die, cu));
SET_FIELD_ENUMVAL (field, value); SET_FIELD_ENUMVAL (field, value);
} }
@ -16515,9 +16515,9 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
/* Set the name of each field in the bounds. */ /* Set the name of each field in the bounds. */
xsnprintf (name, sizeof (name), "LB%d", i / 2); xsnprintf (name, sizeof (name), "LB%d", i / 2);
FIELD_NAME (range_fields[i]) = objfile->intern (name); range_fields[i].set_name (objfile->intern (name));
xsnprintf (name, sizeof (name), "UB%d", i / 2); xsnprintf (name, sizeof (name), "UB%d", i / 2);
FIELD_NAME (range_fields[i + 1]) = objfile->intern (name); range_fields[i + 1].set_name (objfile->intern (name));
} }
struct type *bounds = alloc_type (objfile); struct type *bounds = alloc_type (objfile);
@ -16559,10 +16559,10 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
/* The names are chosen to coincide with what the compiler does with /* The names are chosen to coincide with what the compiler does with
-fgnat-encodings=all, which the Ada code in gdb already -fgnat-encodings=all, which the Ada code in gdb already
understands. */ understands. */
TYPE_FIELD_NAME (result, 0) = "P_ARRAY"; result->field (0).set_name ("P_ARRAY");
result->field (0).set_type (lookup_pointer_type (type)); result->field (0).set_type (lookup_pointer_type (type));
TYPE_FIELD_NAME (result, 1) = "P_BOUNDS"; result->field (1).set_name ("P_BOUNDS");
result->field (1).set_type (lookup_pointer_type (bounds)); result->field (1).set_type (lookup_pointer_type (bounds));
SET_FIELD_BITPOS (result->field (1), 8 * bounds_offset); SET_FIELD_BITPOS (result->field (1), 8 * bounds_offset);

View file

@ -4876,8 +4876,9 @@ print_args (struct field *args, int nargs, int spaces)
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
printf_filtered ("%*s[%d] name '%s'\n", spaces, "", i, printf_filtered
args[i].name != NULL ? args[i].name : "<NULL>"); ("%*s[%d] name '%s'\n", spaces, "", i,
args[i].name () != NULL ? args[i].name () : "<NULL>");
recursive_dump_type (args[i].type (), spaces + 2); recursive_dump_type (args[i].type (), spaces + 2);
} }
} }
@ -5558,8 +5559,7 @@ copy_type_recursive (struct objfile *objfile,
(copy_type_recursive (objfile, type->field (i).type (), (copy_type_recursive (objfile, type->field (i).type (),
copied_types)); copied_types));
if (TYPE_FIELD_NAME (type, i)) if (TYPE_FIELD_NAME (type, i))
TYPE_FIELD_NAME (new_type, i) = new_type->field (i).set_name (xstrdup (TYPE_FIELD_NAME (type, i)));
xstrdup (TYPE_FIELD_NAME (type, i));
switch (TYPE_FIELD_LOC_KIND (type, i)) switch (TYPE_FIELD_LOC_KIND (type, i))
{ {
case FIELD_LOC_KIND_BITPOS: case FIELD_LOC_KIND_BITPOS:
@ -5846,7 +5846,7 @@ append_flags_type_field (struct type *type, int start_bitpos, int nr_bits,
gdb_assert (nr_bits >= 1 && (start_bitpos + nr_bits) <= type_bitsize); gdb_assert (nr_bits >= 1 && (start_bitpos + nr_bits) <= type_bitsize);
gdb_assert (name != NULL); gdb_assert (name != NULL);
TYPE_FIELD_NAME (type, field_nr) = xstrdup (name); type->field (field_nr).set_name (xstrdup (name));
type->field (field_nr).set_type (field_type); type->field (field_nr).set_type (field_type);
SET_FIELD_BITPOS (type->field (field_nr), start_bitpos); SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits; TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
@ -5897,7 +5897,7 @@ append_composite_type_field_raw (struct type *t, const char *name,
f = &t->field (t->num_fields () - 1); f = &t->field (t->num_fields () - 1);
memset (f, 0, sizeof f[0]); memset (f, 0, sizeof f[0]);
f[0].set_type (field); f[0].set_type (field);
FIELD_NAME (f[0]) = name; f[0].set_name (name);
return f; return f;
} }

View file

@ -654,6 +654,16 @@ struct field
this->m_type = type; this->m_type = type;
} }
const char *name () const
{
return m_name;
}
void set_name (const char *name)
{
m_name = name;
}
union field_location loc; union field_location loc;
/* * For a function or member type, this is 1 if the argument is /* * For a function or member type, this is 1 if the argument is
@ -685,7 +695,7 @@ struct field
NULL for range bounds, array domains, and member function NULL for range bounds, array domains, and member function
arguments. */ arguments. */
const char *name; const char *m_name;
}; };
struct range_bounds struct range_bounds
@ -1974,7 +1984,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \ (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))) : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
#define FIELD_NAME(thisfld) ((thisfld).name) #define FIELD_NAME(thisfld) ((thisfld).name ())
#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind) #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
#define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos) #define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos)
#define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0) #define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0)
@ -2001,7 +2011,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME((thistype)->field (n)) #define TYPE_FIELD_NAME(thistype, n) ((thistype)->field (n).name ())
#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n)) #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n)) #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n)) #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))

View file

@ -135,28 +135,28 @@ build_gdb_vtable_type (struct gdbarch *arch)
offset = 0; offset = 0;
/* ptrdiff_t vcall_and_vbase_offsets[0]; */ /* ptrdiff_t vcall_and_vbase_offsets[0]; */
FIELD_NAME (*field) = "vcall_and_vbase_offsets"; field->set_name ("vcall_and_vbase_offsets");
field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1)); field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1));
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());
field++; field++;
/* ptrdiff_t offset_to_top; */ /* ptrdiff_t offset_to_top; */
FIELD_NAME (*field) = "offset_to_top"; field->set_name ("offset_to_top");
field->set_type (ptrdiff_type); field->set_type (ptrdiff_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());
field++; field++;
/* void *type_info; */ /* void *type_info; */
FIELD_NAME (*field) = "type_info"; field->set_name ("type_info");
field->set_type (void_ptr_type); field->set_type (void_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());
field++; field++;
/* void (*virtual_functions[0]) (); */ /* void (*virtual_functions[0]) (); */
FIELD_NAME (*field) = "virtual_functions"; field->set_name ("virtual_functions");
field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1)); field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1));
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());
@ -1036,14 +1036,14 @@ build_std_type_info_type (struct gdbarch *arch)
offset = 0; offset = 0;
/* The vtable. */ /* The vtable. */
FIELD_NAME (*field) = "_vptr.type_info"; field->set_name ("_vptr.type_info");
field->set_type (void_ptr_type); field->set_type (void_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());
field++; field++;
/* The name. */ /* The name. */
FIELD_NAME (*field) = "__name"; field->set_name ("__name");
field->set_type (char_ptr_type); field->set_type (char_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ()); offset += TYPE_LENGTH (field->type ());

View file

@ -1058,13 +1058,13 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
SET_FIELD_ENUMVAL (*f, tsym.value); SET_FIELD_ENUMVAL (*f, tsym.value);
f->set_type (t); f->set_type (t);
FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss; f->set_name (debug_info->ss + cur_fdr->issBase + tsym.iss);
FIELD_BITSIZE (*f) = 0; FIELD_BITSIZE (*f) = 0;
enum_sym = new (&mdebugread_objfile->objfile_obstack) symbol; enum_sym = new (&mdebugread_objfile->objfile_obstack) symbol;
enum_sym->set_linkage_name enum_sym->set_linkage_name
(obstack_strdup (&mdebugread_objfile->objfile_obstack, (obstack_strdup (&mdebugread_objfile->objfile_obstack,
f->name)); f->name ()));
SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST; SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST;
SYMBOL_TYPE (enum_sym) = t; SYMBOL_TYPE (enum_sym) = t;
SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN; SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
@ -1241,7 +1241,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); struct field *f = &top_stack->cur_type->field (top_stack->cur_field);
top_stack->cur_field++; top_stack->cur_field++;
FIELD_NAME (*f) = name; f->set_name (name);
SET_FIELD_BITPOS (*f, sh->value); SET_FIELD_BITPOS (*f, sh->value);
bitsize = 0; bitsize = 0;
f->set_type (parse_type (cur_fd, ax, sh->index, &bitsize, bigend, f->set_type (parse_type (cur_fd, ax, sh->index, &bitsize, bigend,

View file

@ -915,7 +915,7 @@ rust_composite_type (struct type *original,
SET_FIELD_BITPOS (*field, bitpos); SET_FIELD_BITPOS (*field, bitpos);
bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT; bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT;
FIELD_NAME (*field) = field1; field->set_name (field1);
field->set_type (type1); field->set_type (type1);
++i; ++i;
} }
@ -935,7 +935,7 @@ rust_composite_type (struct type *original,
} }
SET_FIELD_BITPOS (*field, bitpos); SET_FIELD_BITPOS (*field, bitpos);
FIELD_NAME (*field) = field2; field->set_name (field2);
field->set_type (type2); field->set_type (type2);
++i; ++i;
} }

View file

@ -1225,8 +1225,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--) for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0) if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) = SYMBOL_TYPE (sym)->field (j).set_name
TYPE_BASECLASS (SYMBOL_TYPE (sym), j)->name (); (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)->name ());
} }
if (SYMBOL_TYPE (sym)->name () == NULL) if (SYMBOL_TYPE (sym)->name () == NULL)
@ -2712,8 +2712,8 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
{ {
name = ""; name = "";
} }
fip->list->field.name = obconcat (&objfile->objfile_obstack, fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
vptr_name, name, (char *) NULL); vptr_name, name, (char *) NULL));
break; break;
case 'b': /* $vb -- a virtual bsomethingorother */ case 'b': /* $vb -- a virtual bsomethingorother */
@ -2725,15 +2725,15 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
symnum); symnum);
name = "FOO"; name = "FOO";
} }
fip->list->field.name = obconcat (&objfile->objfile_obstack, vb_name, fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
name, (char *) NULL); vb_name, name, (char *) NULL));
break; break;
default: default:
invalid_cpp_abbrev_complaint (*pp); invalid_cpp_abbrev_complaint (*pp);
fip->list->field.name = obconcat (&objfile->objfile_obstack, fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
"INVALID_CPLUSPLUS_ABBREV", "INVALID_CPLUSPLUS_ABBREV",
(char *) NULL); (char *) NULL));
break; break;
} }
@ -2782,8 +2782,8 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
{ {
struct gdbarch *gdbarch = objfile->arch (); struct gdbarch *gdbarch = objfile->arch ();
fip->list->field.name fip->list->field.set_name
= obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp); (obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp));
*pp = p + 1; *pp = p + 1;
/* This means we have a visibility for a field coming. */ /* This means we have a visibility for a field coming. */
@ -3120,7 +3120,7 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
field's name. */ field's name. */
newobj->field.set_type (read_type (pp, objfile)); newobj->field.set_type (read_type (pp, objfile));
newobj->field.name = newobj->field.type ()->name (); newobj->field.set_name (newobj->field.type ()->name ());
/* Skip trailing ';' and bump count of number of fields seen. */ /* Skip trailing ';' and bump count of number of fields seen. */
if (**pp == ';') if (**pp == ';')
@ -3638,7 +3638,7 @@ read_enum_type (const char **pp, struct type *type,
struct symbol *xsym = syms->symbol[j]; struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type; SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = xsym->linkage_name (); type->field (n).set_name (xsym->linkage_name ());
SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym)); SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
TYPE_FIELD_BITSIZE (type, n) = 0; TYPE_FIELD_BITSIZE (type, n) = 0;
} }

View file

@ -761,7 +761,7 @@ create_enum (struct gdbarch *gdbarch, int bit, const char *name,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
TYPE_FIELD_NAME (type, i) = values[i].name; type->field (i).set_name (values[i].name);
SET_FIELD_ENUMVAL (type->field (i), values[i].value); SET_FIELD_ENUMVAL (type->field (i), values[i].value);
} }