+2021-06-28 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * 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.
+
2021-06-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbarch.sh (struct gdbarch_info) <tdep_info>: Remove.
new one), stashing the vector length inside id. Use -1 for when SVE
unavailable, to distinguish from an unset value of 0. */
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64);
info.id = (int *) (vq == 0 ? -1 : vq);
return gdbarch_find_by_info (info);
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.bfd_arch_info = bfd_scan_arch ("aarch64");
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
struct gdbarch_info info;
uint32_t ret;
- gdbarch_info_init (&info);
info.bfd_arch_info = bfd_scan_arch ("aarch64");
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
-
if (set_endian_string == endian_auto)
{
target_byte_order_user = BFD_ENDIAN_UNKNOWN;
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
-
if (strcmp (set_architecture_string, "auto") == 0)
{
target_architecture_user = NULL;
gdbarch_from_bfd (bfd *abfd)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.abfd = abfd;
return gdbarch_find_by_info (info);
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);
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)
_("initialize_current_architecture: Arch not found"));
}
+ gdbarch_info info;
info.bfd_arch_info = default_bfd_arch;
/* Take several guesses at a byte order. */
}
}
-
-/* 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. */
was explicitly selected. */
extern const char *selected_architecture_name (void);
-/* Initialize a ``struct info''. Can't use memset(0) since some
- default values are not zero. "fill" takes all available
- information and fills in any unspecified fields. */
-
-extern void gdbarch_info_init (struct gdbarch_info *info);
-
/* Similar to init, but this time fill in the blanks. Information is
obtained from the global "set ..." options and explicitly
initialized INFO fields. */
static void
arm_update_current_architecture (void)
{
- struct gdbarch_info info;
-
/* If the current architecture is not ARM, we have nothing to do. */
if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_arm)
return;
/* Update the architecture. */
- gdbarch_info_init (&info);
-
+ gdbarch_info info;
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__, _("could not update architecture"));
}
arm_record_test (void)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.bfd_arch_info = bfd_scan_arch ("arm");
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
for (bfd_endian endianness : {BFD_ENDIAN_LITTLE, BFD_ENDIAN_BIG})
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.byte_order = endianness;
info.byte_order_for_code = endianness;
info.bfd_arch_info = bfd_scan_arch ("arm");
if (tdesc != nullptr)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.abfd = core_bfd;
info.target_desc = tdesc;
m_core_gdbarch = gdbarch_find_by_info (info);
usr_cmd_cris_version_valid = 1;
/* Update the current architecture, if needed. */
- gdbarch_info_init (&info);
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__,
_("cris_gdbarch_update: failed to update architecture."));
struct gdbarch_info info;
/* Update the current architecture, if needed. */
- gdbarch_info_init (&info);
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__,
"cris_gdbarch_update: failed to update architecture.");
struct gdbarch_info info;
/* Update the current architecture, if needed. */
- gdbarch_info_init (&info);
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__,
_("cris_gdbarch_update: failed to update architecture."));
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
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);
/* 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. */
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 ()
+ {}
+
+ const struct bfd_arch_info *bfd_arch_info = nullptr;
- /* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO). */
- enum bfd_endian byte_order;
+ enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN;
- enum bfd_endian byte_order_for_code;
+ enum bfd_endian byte_order_for_code = BFD_ENDIAN_UNKNOWN;
- /* Use default: NULL (ZERO). */
- bfd *abfd;
+ bfd *abfd = nullptr;
- /* Use default: NULL (ZERO). */
union
{
/* Architecture-specific target description data. Numerous targets
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);
/* 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. */
{
/* Attaching to a process. Let's figure out what kind it is. */
x86_thread_state_t gp_regs;
- struct gdbarch_info info;
unsigned int gp_count = x86_THREAD_STATE_COUNT;
kern_return_t ret;
return;
}
- gdbarch_info_init (&info);
+ gdbarch_info info;
gdbarch_info_fill (&info);
info.byte_order = gdbarch_byte_order (target_gdbarch ());
info.osabi = GDB_OSABI_DARWIN;
struct address_space *aspace;
struct program_space *pspace;
struct inferior *inf;
- struct gdbarch_info info;
/* If all inferiors share an address space on this system, this
doesn't really return a new address space; otherwise, it
/* Setup the inferior's initial arch, based on information obtained
from the global "set ..." options. */
- gdbarch_info_init (&info);
+ gdbarch_info info;
inf->gdbarch = gdbarch_find_by_info (info);
/* The "set ..." options reject invalid settings, so we should
always have a valid arch by now. */
struct cmd_list_element *c)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
/* FIXME: cagney/2003-11-15: Should be setting a field in "info"
instead of relying on globals. Doing that would let generic code
handle the search for this specific architecture. */
set_mipsfpu_single_command (const char *args, int from_tty)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
mips_fpu_type = MIPS_FPU_SINGLE;
mips_fpu_type_auto = 0;
/* FIXME: cagney/2003-11-15: Should be setting a field in "info"
set_mipsfpu_double_command (const char *args, int from_tty)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
mips_fpu_type = MIPS_FPU_DOUBLE;
mips_fpu_type_auto = 0;
/* FIXME: cagney/2003-11-15: Should be setting a field in "info"
set_mipsfpu_none_command (const char *args, int from_tty)
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
mips_fpu_type = MIPS_FPU_NONE;
mips_fpu_type_auto = 0;
/* FIXME: cagney/2003-11-15: Should be setting a field in "info"
/* Force the architecture to update, and (if it's a MIPS architecture)
mips_gdbarch_init will take care of the rest. */
- gdbarch_info_init (&info);
gdbarch_update_p (info);
}
static void
set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
{
- struct gdbarch_info info;
-
if (strcmp (set_osabi_string, "auto") == 0)
user_osabi_state = osabi_auto;
else if (strcmp (set_osabi_string, "default") == 0)
/* NOTE: At some point (true multiple architectures) we'll need to be more
graceful here. */
- gdbarch_info_init (&info);
+ gdbarch_info info;
if (! gdbarch_update_p (info))
internal_error (__FILE__, __LINE__, _("Updating OS ABI failed."));
}
enum bfd_architecture arch;
unsigned long mach;
bfd abfd;
- struct gdbarch_info info;
inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty);
bfd_default_set_arch_mach (&abfd, arch, mach);
- gdbarch_info_init (&info);
+ gdbarch_info info;
info.bfd_arch_info = bfd_get_arch_info (&abfd);
info.abfd = current_program_space->exec_bfd ();
struct gdbarch_info info;
/* Update the architecture. */
- gdbarch_info_init (&info);
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__, _("could not update architecture"));
}
powerpc_set_vector_abi (const char *args, int from_tty,
struct cmd_list_element *c)
{
- struct gdbarch_info info;
int vector_abi;
for (vector_abi = POWERPC_VEC_AUTO;
powerpc_vector_abi_string);
/* Update the architecture. */
- gdbarch_info_init (&info);
+ gdbarch_info info;
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__, _("could not update architecture"));
}
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.bfd_arch_info = bfd_scan_arch (arches[i]);
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
{
struct gdbarch_info info;
- gdbarch_info_init (&info);
info.target_desc = tdesc_info->tdesc;
if (!gdbarch_update_p (info))
warning (_("Architecture rejected target-supplied description"));
tdesc_info->tdesc = nullptr;
gdbarch_info info;
- gdbarch_info_init (&info);
if (!gdbarch_update_p (info))
internal_error (__FILE__, __LINE__,
_("Could not remove target-supplied description"));