aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
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/ada-lang.c
parent1f704f761b34e145f5eabdc222301ce6e9ec9102 (diff)
downloadbinutils-3cabb6b0694b65c7b5ed800822ca08bd899fc1d1.zip
binutils-3cabb6b0694b65c7b5ed800822ca08bd899fc1d1.tar.gz
binutils-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/ada-lang.c')
-rw-r--r--gdb/ada-lang.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a4804e6..d4377a1 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8021,7 +8021,6 @@ empty_record (struct type *templ)
struct type *type = alloc_type_copy (templ);
type->set_code (TYPE_CODE_STRUCT);
- TYPE_FIELDS (type) = NULL;
INIT_NONE_SPECIFIC (type);
type->set_name ("<empty>");
TYPE_LENGTH (type) = 0;
@@ -8078,9 +8077,8 @@ ada_template_to_fixed_record_type_1 (struct type *type,
rtype->set_code (TYPE_CODE_STRUCT);
INIT_NONE_SPECIFIC (rtype);
rtype->set_num_fields (nfields);
- TYPE_FIELDS (rtype) = (struct field *)
- TYPE_ALLOC (rtype, nfields * sizeof (struct field));
- memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields);
+ rtype->set_fields
+ ((struct field *) TYPE_ZALLOC (rtype, nfields * sizeof (struct field)));
rtype->set_name (ada_type_name (type));
TYPE_FIXED_INSTANCE (rtype) = 1;
@@ -8353,10 +8351,14 @@ template_to_static_fixed_type (struct type *type0)
type->set_code (type0->code ());
INIT_NONE_SPECIFIC (type);
type->set_num_fields (nfields);
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ALLOC (type, nfields * sizeof (struct field));
- memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0),
+
+ field *fields =
+ ((struct field *)
+ TYPE_ALLOC (type, nfields * sizeof (struct field)));
+ memcpy (fields, TYPE_FIELDS (type0),
sizeof (struct field) * nfields);
+ type->set_fields (fields);
+
type->set_name (ada_type_name (type0));
TYPE_FIXED_INSTANCE (type) = 1;
TYPE_LENGTH (type) = 0;
@@ -8402,10 +8404,12 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
rtype->set_code (TYPE_CODE_STRUCT);
INIT_NONE_SPECIFIC (rtype);
rtype->set_num_fields (nfields);
- TYPE_FIELDS (rtype) =
+
+ field *fields =
(struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field));
- memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type),
- sizeof (struct field) * nfields);
+ memcpy (fields, TYPE_FIELDS (type), sizeof (struct field) * nfields);
+ rtype->set_fields (fields);
+
rtype->set_name (ada_type_name (type));
TYPE_FIXED_INSTANCE (rtype) = 1;
TYPE_LENGTH (rtype) = TYPE_LENGTH (type);