aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-28 11:49:22 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-06-28 11:49:22 -0400
commitb447dd03c16d51c7b41c9af0756fc9db4ad95f0d (patch)
tree4cff1537b99c800351a42d293650b7c51459e710 /gdb/gdbarch.h
parentc87c999c511f0484de53fa616b0bf6b00c753434 (diff)
downloadfsf-binutils-gdb-b447dd03c16d51c7b41c9af0756fc9db4ad95f0d.zip
fsf-binutils-gdb-b447dd03c16d51c7b41c9af0756fc9db4ad95f0d.tar.gz
fsf-binutils-gdb-b447dd03c16d51c7b41c9af0756fc9db4ad95f0d.tar.bz2
gdb: remove gdbarch_info_init
While reviewing another patch, I realized that gdbarch_info_init could easily be removed in favor of initializing gdbarch_info fields directly in the struct declaration. The only odd part is the union. I don't know if it's actually important for it to be zero-initialized, but I presume it is. I added a constructor to gdbarch_info to take care of that. A proper solution would be to use std::variant. Or, these could also be separate fields, the little extra space required wouldn't matter. gdb/ChangeLog: * gdbarch.sh (struct gdbarch_info): Initialize fields, add constructor. * gdbarch.h: Re-generate. * arch-utils.h (gdbarch_info_init): Remove, delete all usages. * arch-utils.c (gdbarch_info_init): Remove. Change-Id: I7502e08fe0f278d84eef1667a072e8a97bda5ab5
Diffstat (limited to 'gdb/gdbarch.h')
-rw-r--r--gdb/gdbarch.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 36ea4de..ece765b 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1781,18 +1781,20 @@ struct gdbarch_list
struct gdbarch_info
{
- /* Use default: NULL (ZERO). */
- const struct bfd_arch_info *bfd_arch_info;
+ gdbarch_info ()
+ /* Ensure the union is zero-initialized. Relies on the fact that there's
+ no member larger than TDESC_DATA. */
+ : tdesc_data ()
+ {}
- /* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO). */
- enum bfd_endian byte_order;
+ const struct bfd_arch_info *bfd_arch_info = nullptr;
- enum bfd_endian byte_order_for_code;
+ enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN;
- /* Use default: NULL (ZERO). */
- bfd *abfd;
+ enum bfd_endian byte_order_for_code = BFD_ENDIAN_UNKNOWN;
+
+ bfd *abfd = nullptr;
- /* Use default: NULL (ZERO). */
union
{
/* Architecture-specific target description data. Numerous targets
@@ -1805,11 +1807,9 @@ struct gdbarch_info
int *id;
};
- /* Use default: GDB_OSABI_UNINITIALIZED (-1). */
- enum gdb_osabi osabi;
+ enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
- /* Use default: NULL (ZERO). */
- const struct target_desc *target_desc;
+ const struct target_desc *target_desc = nullptr;
};
typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches);
@@ -1883,8 +1883,8 @@ extern int gdbarch_update_p (struct gdbarch_info info);
/* Helper function. Find an architecture matching info.
- INFO should be initialized using gdbarch_info_init, relevant fields
- set, and then finished using gdbarch_info_fill.
+ INFO should have relevant fields set, and then finished using
+ gdbarch_info_fill.
Returns the corresponding architecture, or NULL if no matching
architecture was found. */