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
This commit is contained in:
Simon Marchi
2021-06-28 11:49:22 -04:00
parent c87c999c51
commit b447dd03c1
18 changed files with 43 additions and 92 deletions

View File

@@ -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. */