aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:16 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:16 -0400
commit3cabb6b0694b65c7b5ed800822ca08bd899fc1d1 (patch)
tree58ba2ab20a5c34f30dff225f099dea06d0ef531e /gdb/dwarf2
parent1f704f761b34e145f5eabdc222301ce6e9ec9102 (diff)
downloadgdb-3cabb6b0694b65c7b5ed800822ca08bd899fc1d1.zip
gdb-3cabb6b0694b65c7b5ed800822ca08bd899fc1d1.tar.gz
gdb-3cabb6b0694b65c7b5ed800822ca08bd899fc1d1.tar.bz2
gdb: add type::fields / type::set_fields
Add the `fields` and `set_fields` methods on `struct type`, in order to remove the `TYPE_FIELDS` macro. In this patch, the `TYPE_FIELDS` macro is changed to the `type::fields`, so all the call sites that use it to set the fields array are changed to use `type::set_fields`. The next patch will remove `TYPE_FIELDS` entirely. gdb/ChangeLog: * gdbtypes.h (struct type) <fields, set_fields>: New methods. (TYPE_FIELDS): Use type::fields. Change all call sites that modify the propery to use type::set_fields instead. Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0581b8e..08d2358 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9365,8 +9365,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
type->set_num_fields (3);
/* Save the field we care about. */
struct field saved_field = TYPE_FIELD (type, 0);
- TYPE_FIELDS (type)
- = (struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field));
+ type->set_fields
+ ((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)));
/* Put the discriminant at index 0. */
TYPE_FIELD_TYPE (type, 0) = field_type;
@@ -9460,7 +9460,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
* sizeof (struct field)));
memcpy (new_fields + 1, TYPE_FIELDS (type),
type->num_fields () * sizeof (struct field));
- TYPE_FIELDS (type) = new_fields;
+ type->set_fields (new_fields);
type->set_num_fields (type->num_fields () + 1);
/* Install the discriminant at index 0 in the union. */
@@ -9510,7 +9510,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
if (sub_type->num_fields () > 0)
{
sub_type->set_num_fields (sub_type->num_fields () - 1);
- ++TYPE_FIELDS (sub_type);
+ sub_type->set_fields (sub_type->fields () + 1);
}
TYPE_FIELD_NAME (type, i) = variant_name;
sub_type->set_name
@@ -14805,8 +14805,8 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
/* Record the field count, allocate space for the array of fields,
and create blank accessibility bitfields if necessary. */
type->set_num_fields (nfields);
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ZALLOC (type, sizeof (struct field) * nfields);
+ type->set_fields
+ ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields));
if (fip->non_public_fields && cu->language != language_ada)
{
@@ -15934,8 +15934,9 @@ update_enumeration_type_from_children (struct die_info *die,
if (!fields.empty ())
{
type->set_num_fields (fields.size ());
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ALLOC (type, sizeof (struct field) * fields.size ());
+ type->set_fields
+ ((struct field *)
+ TYPE_ALLOC (type, sizeof (struct field) * fields.size ()));
memcpy (TYPE_FIELDS (type), fields.data (),
sizeof (struct field) * fields.size ());
}
@@ -17085,8 +17086,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
/* Allocate storage for parameters and fill them in. */
ftype->set_num_fields (nparams);
- TYPE_FIELDS (ftype) = (struct field *)
- TYPE_ZALLOC (ftype, nparams * sizeof (struct field));
+ ftype->set_fields
+ ((struct field *) TYPE_ZALLOC (ftype, nparams * sizeof (struct field)));
/* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it
even if we error out during the parameters reading below. */