aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:14 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-22 16:55:14 -0400
commit5e33d5f4e1a5f2c3556ee31715ddc030d039b597 (patch)
treee58db956a72805d8a2a800cf0b913fd5808933ed /gdb/stabsread.c
parent9392ebb3bbe4a43726ee8939c5447d88c7d3c1e4 (diff)
downloadfsf-binutils-gdb-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.zip
fsf-binutils-gdb-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.tar.gz
fsf-binutils-gdb-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.tar.bz2
gdb: add type::num_fields / type::set_num_fields
Add the `num_fields` and `set_num_fields` methods on `struct type`, in order to remove the `TYPE_NFIELDS` macro. In this patch, the `TYPE_NFIELDS` macro is changed to use `type::num_fields`, so all the call sites that are used to set the number of fields are changed to use `type::set_num_fields`. The next patch will remove `TYPE_NFIELDS` completely. I think that in the future, we should consider making the interface of `struct type` better. For example, right now it's possible for the number of fields property and the actual number of fields set to be out of sync. However, I want to keep the existing behavior in this patch, just translate from macros to methods. gdb/ChangeLog: * gdbtypes.h (struct type) <num_fields, set_num_fields>: New methods. (TYPE_NFIELDS): Use type::num_fields. Change all call sites that modify the number of fields to use type::set_num_fields instead. Change-Id: I5ad9de5be4097feaf942d111077434bf91d13dc5
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index a632856..c3da9a2 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1009,7 +1009,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
TYPE_FIELD_TYPE (ftype, nparams) = ptype;
TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
}
- TYPE_NFIELDS (ftype) = nparams;
+ ftype->set_num_fields (nparams);
TYPE_PROTOTYPED (ftype) = 1;
}
break;
@@ -1850,7 +1850,7 @@ again:
for (t = arg_types, i = num_args - 1; t; t = t->next, i--)
TYPE_FIELD_TYPE (func_type, i) = t->type;
}
- TYPE_NFIELDS (func_type) = num_args;
+ func_type->set_num_fields (num_args);
TYPE_PROTOTYPED (func_type) = 1;
type = func_type;
@@ -3308,7 +3308,7 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type,
non-public fields. Record the field count, allocate space for the
array of fields, and create blank visibility bitfields if necessary. */
- TYPE_NFIELDS (type) = nfields;
+ type->set_num_fields (nfields);
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nfields);
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
@@ -3654,7 +3654,7 @@ read_enum_type (const char **pp, struct type *type,
TYPE_STUB (type) = 0;
if (unsigned_enum)
TYPE_UNSIGNED (type) = 1;
- TYPE_NFIELDS (type) = nsyms;
+ type->set_num_fields (nsyms);
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nsyms);
memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);