/* All possible aarch64 target descriptors. */
struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* capability */];
+/* The list of available aarch64 set/show commands. */
+static struct cmd_list_element *set_aarch64_cmdlist = NULL;
+static struct cmd_list_element *show_aarch64_cmdlist = NULL;
+
+/* The ABI to use. Keep this in sync with aarch64_abi_kind. */
+static const char *const aarch64_abi_strings[] =
+{
+ "auto",
+ "AAPCS64",
+ "AAPCS64-cap",
+ nullptr
+};
+
+/* Variables for the ABI user setting. */
+static enum aarch64_abi_kind aarch64_current_abi_global = AARCH64_ABI_AUTO;
+static const char *aarch64_current_abi_string = "auto";
+
+static void
+aarch64_update_current_architecture (void)
+{
+ struct gdbarch_info info;
+
+ /* If the current architecture is not AArch64, we have nothing to do. */
+ if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_aarch64)
+ return;
+
+ /* Update the architecture. */
+ gdbarch_info_init (&info);
+
+ if (!gdbarch_update_p (info))
+ internal_error (__FILE__, __LINE__, _("could not update architecture"));
+}
+
+/* Sets the current ABI for AArch64. */
+
+static void
+aarch64_set_abi (const char *args, int from_tty,
+ struct cmd_list_element *c)
+{
+ int abi;
+
+ for (abi = AARCH64_ABI_AUTO; abi != AARCH64_ABI_LAST; abi++)
+ if (strcmp (aarch64_current_abi_string, aarch64_abi_strings[abi]) == 0)
+ {
+ aarch64_current_abi_global = (enum aarch64_abi_kind) abi;
+ break;
+ }
+
+ if (abi == AARCH64_ABI_LAST)
+ internal_error (__FILE__, __LINE__, _("Invalid ABI accepted: %s."),
+ aarch64_current_abi_string);
+
+ aarch64_update_current_architecture ();
+}
+
+/* Shows the current ABI for AArch64. */
+
+static void
+aarch64_show_abi (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch ());
+
+ if (aarch64_current_abi_global == AARCH64_ABI_AUTO
+ && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_aarch64)
+ fprintf_filtered (file, _("\
+The current AArch64 ABI is \"auto\" (currently \"%s\").\n"),
+ aarch64_abi_strings[tdep->abi]);
+ else
+ fprintf_filtered (file, _("The current AArch64 ABI is \"%s\".\n"),
+ aarch64_current_abi_string);
+}
+
/* The standard register names, and all the valid aliases for them. */
static const struct
{
bool valid_p = true;
int i, num_regs = 0, num_pseudo_regs = 0;
int first_pauth_regnum = -1, pauth_ra_state_offset = -1;
+ aarch64_abi_kind abi = (aarch64_current_abi_global == AARCH64_ABI_AUTO)?
+ AARCH64_ABI_AAPCS64 : aarch64_current_abi_global;
/* Use the vector length passed via the target info. Here -1 is used for no
SVE, and 0 is unset. If unset then use the vector length from the existing
struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+ tdep->abi = abi;
/* This should be low enough for everything. */
tdep->lowest_pc = 0x20;
tdep->jb_pc = -1; /* Longjump support not enabled by default. */
if (tdep == NULL)
return;
- fprintf_unfiltered (file, _("aarch64_dump_tdep: Lowest pc = 0x%s"),
- paddress (gdbarch, tdep->lowest_pc));
+ fprintf_unfiltered (file, _("%s: Lowest pc = 0x%s"),
+ __func__, paddress (gdbarch, tdep->lowest_pc));
+
+ fprintf_unfiltered (file, _("%s: ABI is %s"),
+ __func__, aarch64_abi_strings[tdep->abi]);
}
#if GDB_SELF_TEST
gdbarch_register (bfd_arch_aarch64, aarch64_gdbarch_init,
aarch64_dump_tdep);
+ /* Add root prefix command for all set/show aarch64 commands. */
+ add_basic_prefix_cmd ("aarch64", no_class,
+ _("Various AArch64-specific commands."),
+ &set_aarch64_cmdlist, "set aarch64 ", 0, &setlist);
+
+ add_show_prefix_cmd ("aarch64", no_class,
+ _("Various AArch64-specific commands."),
+ &show_aarch64_cmdlist, "show aarch64 ", 0, &showlist);
+
+ /* Add a command to allow the user to force the ABI. */
+ add_setshow_enum_cmd ("abi", class_support, aarch64_abi_strings,
+ &aarch64_current_abi_string,
+ _("Set the ABI."),
+ _("Show the ABI."),
+ NULL, aarch64_set_abi, aarch64_show_abi,
+ &set_aarch64_cmdlist, &show_aarch64_cmdlist);
+
/* Debug this file's internals. */
add_setshow_boolean_cmd ("aarch64", class_maintenance, &aarch64_debug, _("\
Set AArch64 debugging."), _("\