diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-28 11:49:22 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-28 11:49:22 -0400 |
commit | b447dd03c16d51c7b41c9af0756fc9db4ad95f0d (patch) | |
tree | 4cff1537b99c800351a42d293650b7c51459e710 /gdb/arch-utils.c | |
parent | c87c999c511f0484de53fa616b0bf6b00c753434 (diff) | |
download | binutils-gdb-b447dd03c16d51c7b41c9af0756fc9db4ad95f0d.tar.gz |
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/arch-utils.c')
-rw-r--r-- | gdb/arch-utils.c | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index c75a79757ea..4290d637ce1 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -389,8 +389,6 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c) { struct gdbarch_info info; - gdbarch_info_init (&info); - if (set_endian_string == endian_auto) { target_byte_order_user = BFD_ENDIAN_UNKNOWN; @@ -548,8 +546,6 @@ set_architecture (const char *ignore_args, { struct gdbarch_info info; - gdbarch_info_init (&info); - if (strcmp (set_architecture_string, "auto") == 0) { target_architecture_user = NULL; @@ -630,7 +626,6 @@ struct gdbarch * gdbarch_from_bfd (bfd *abfd) { struct gdbarch_info info; - gdbarch_info_init (&info); info.abfd = abfd; return gdbarch_find_by_info (info); @@ -645,7 +640,6 @@ set_gdbarch_from_file (bfd *abfd) struct gdbarch_info info; struct gdbarch *gdbarch; - gdbarch_info_init (&info); info.abfd = abfd; info.target_desc = target_current_description (); gdbarch = gdbarch_find_by_info (info); @@ -679,10 +673,6 @@ void initialize_current_architecture (void) { const char **arches = gdbarch_printable_names (); - struct gdbarch_info info; - - /* determine a default architecture and byte order. */ - gdbarch_info_init (&info); /* Find a default architecture. */ if (default_bfd_arch == NULL) @@ -705,6 +695,7 @@ initialize_current_architecture (void) _("initialize_current_architecture: Arch not found")); } + gdbarch_info info; info.bfd_arch_info = default_bfd_arch; /* Take several guesses at a byte order. */ @@ -769,21 +760,6 @@ initialize_current_architecture (void) } } - -/* Initialize a gdbarch info to values that will be automatically - overridden. Note: Originally, this ``struct info'' was initialized - using memset(0). Unfortunately, that ran into problems, namely - BFD_ENDIAN_BIG is zero. An explicit initialization function that - can explicitly set each field to a well defined value is used. */ - -void -gdbarch_info_init (struct gdbarch_info *info) -{ - memset (info, 0, sizeof (struct gdbarch_info)); - info->byte_order = BFD_ENDIAN_UNKNOWN; - info->byte_order_for_code = info->byte_order; -} - /* Similar to init, but this time fill in the blanks. Information is obtained from the global "set ..." options and explicitly initialized INFO fields. */ |