aboutsummaryrefslogtreecommitdiff
path: root/gdb/coffread.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/coffread.c
parent9392ebb3bbe4a43726ee8939c5447d88c7d3c1e4 (diff)
downloadgdb-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.zip
gdb-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.tar.gz
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/coffread.c')
-rw-r--r--gdb/coffread.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 0f7a6e3..2732421 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1455,7 +1455,7 @@ patch_type (struct type *type, struct type *real_type)
int field_size = TYPE_NFIELDS (real_target) * sizeof (struct field);
TYPE_LENGTH (target) = TYPE_LENGTH (real_target);
- TYPE_NFIELDS (target) = TYPE_NFIELDS (real_target);
+ target->set_num_fields (TYPE_NFIELDS (real_target));
TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target,
field_size);
@@ -1883,7 +1883,7 @@ decode_base_type (struct coff_symbol *cs,
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
- TYPE_NFIELDS (type) = 0;
+ type->set_num_fields (0);
}
else
{
@@ -1903,7 +1903,7 @@ decode_base_type (struct coff_symbol *cs,
INIT_CPLUS_SPECIFIC (type);
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
- TYPE_NFIELDS (type) = 0;
+ type->set_num_fields (0);
}
else
{
@@ -1924,7 +1924,7 @@ decode_base_type (struct coff_symbol *cs,
type->set_name (NULL);
TYPE_LENGTH (type) = 0;
TYPE_FIELDS (type) = 0;
- TYPE_NFIELDS (type) = 0;
+ type->set_num_fields (0);
}
else
{
@@ -2040,7 +2040,7 @@ coff_read_struct_type (int index, int length, int lastsym,
}
/* Now create the vector of fields, and record how big it is. */
- TYPE_NFIELDS (type) = nfields;
+ type->set_num_fields (nfields);
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nfields);
@@ -2120,7 +2120,7 @@ coff_read_enum_type (int index, int length, int lastsym,
else /* Assume ints. */
TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT;
type->set_code (TYPE_CODE_ENUM);
- TYPE_NFIELDS (type) = nsyms;
+ type->set_num_fields (nsyms);
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nsyms);