+2014-12-12 Tom Tromey <tromey@redhat.com>
+ Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * osabi.h (osabi_triplet_regexp): Declare.
+ * osabi.c (struct osabi_names): New.
+ (gdb_osabi_names): Change type to struct osabi_names. Update
+ values.
+ (gdbarch_osabi_name): Update.
+ (osabi_triplet_regexp): New function.
+ (osabi_from_tdesc_string, _initialize_gdb_osabi): Update.
+ * i386-tdep.c (i386_gnu_triplet_regexp): New method.
+ (i386_elf_init_abi, i386_go32_init_abi, i386_gdbarch_init): Call
+ set_gdbarch_gnu_triplet_regexp.
+ * gdbarch.sh (gnu_triplet_regexp): New method.
+ * gdbarch.c, gdbarch.h: Rebuild.
+ * arch-utils.h (default_gnu_triplet_regexp): Declare.
+ * arch-utils.c (default_gnu_triplet_regexp): New function.
+
2014-12-12 Jan Kratochvil <jan.kratochvil@redhat.com>
* arch-utils.c (default_infcall_mmap)
gdbarch_ptr_bit (gdbarch) == 64 ? " -mcmodel=large" : "");
}
+/* gdbarch gnu_triplet_regexp method. */
+
+const char *
+default_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+ return gdbarch_bfd_arch_info (gdbarch)->arch_name;
+}
+
/* -Wmissing-prototypes */
extern initialize_file_ftype _initialize_gdbarch_utils;
extern CORE_ADDR default_infcall_mmap (CORE_ADDR size, unsigned prot);
extern char *default_gcc_target_options (struct gdbarch *gdbarch);
+extern const char *default_gnu_triplet_regexp (struct gdbarch *gdbarch);
#endif
gdbarch_vsyscall_range_ftype *vsyscall_range;
gdbarch_infcall_mmap_ftype *infcall_mmap;
gdbarch_gcc_target_options_ftype *gcc_target_options;
+ gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp;
};
/* Create a new ``struct gdbarch'' based on information provided by
gdbarch->vsyscall_range = default_vsyscall_range;
gdbarch->infcall_mmap = default_infcall_mmap;
gdbarch->gcc_target_options = default_gcc_target_options;
+ gdbarch->gnu_triplet_regexp = default_gnu_triplet_regexp;
/* gdbarch_alloc() */
return gdbarch;
/* Skip verify of vsyscall_range, invalid_p == 0 */
/* Skip verify of infcall_mmap, invalid_p == 0 */
/* Skip verify of gcc_target_options, invalid_p == 0 */
+ /* Skip verify of gnu_triplet_regexp, invalid_p == 0 */
buf = ui_file_xstrdup (log, &length);
make_cleanup (xfree, buf);
if (length > 0)
"gdbarch_dump: get_syscall_number = <%s>\n",
host_address_to_string (gdbarch->get_syscall_number));
fprintf_unfiltered (file,
+ "gdbarch_dump: gnu_triplet_regexp = <%s>\n",
+ host_address_to_string (gdbarch->gnu_triplet_regexp));
+ fprintf_unfiltered (file,
"gdbarch_dump: half_bit = %s\n",
plongest (gdbarch->half_bit));
fprintf_unfiltered (file,
gdbarch->gcc_target_options = gcc_target_options;
}
+const char *
+gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->gnu_triplet_regexp != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_gnu_triplet_regexp called\n");
+ return gdbarch->gnu_triplet_regexp (gdbarch);
+}
+
+void
+set_gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch,
+ gdbarch_gnu_triplet_regexp_ftype gnu_triplet_regexp)
+{
+ gdbarch->gnu_triplet_regexp = gnu_triplet_regexp;
+}
+
/* Keep a registry of per-architecture data-pointers required by GDB
modules. */
extern char * gdbarch_gcc_target_options (struct gdbarch *gdbarch);
extern void set_gdbarch_gcc_target_options (struct gdbarch *gdbarch, gdbarch_gcc_target_options_ftype *gcc_target_options);
+/* Return a regular expression that matches names used by this
+ architecture in GNU configury triplets. The result is statically
+ allocated and must not be freed. The default implementation simply
+ returns the BFD architecture name, which is correct in nearly every
+ case. */
+
+typedef const char * (gdbarch_gnu_triplet_regexp_ftype) (struct gdbarch *gdbarch);
+extern const char * gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch);
+extern void set_gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch, gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp);
+
/* Definition for an unknown syscall, used basically in error-cases. */
#define UNKNOWN_SYSCALL (-1)
# These options are put before CU's DW_AT_producer compilation options so that
# they can override it. Method may also return NULL.
m:char *:gcc_target_options:void:::default_gcc_target_options::0
+
+# Return a regular expression that matches names used by this
+# architecture in GNU configury triplets. The result is statically
+# allocated and must not be freed. The default implementation simply
+# returns the BFD architecture name, which is correct in nearly every
+# case.
+m:const char *:gnu_triplet_regexp:void:::default_gnu_triplet_regexp::0
EOF
}
\f
+/* gdbarch gnu_triplet_regexp method. Both arches are acceptable as GDB always
+ also supplies -m64 or -m32 by gdbarch_gcc_target_options. */
+
+static const char *
+i386_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+ return "(x86_64|i.86)";
+}
+
+\f
+
/* Generic ELF. */
void
i386_stap_is_single_operand);
set_gdbarch_stap_parse_special_token (gdbarch,
i386_stap_parse_special_token);
+
+ set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
}
/* System V Release 4 (SVR4). */
set_gdbarch_sdb_reg_to_regnum (gdbarch, i386_svr4_reg_to_regnum);
set_gdbarch_has_dos_based_file_system (gdbarch, 1);
+
+ set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
}
\f
gap for the upper AVX, MPX and AVX512 registers. */
set_gdbarch_num_regs (gdbarch, I386_AVX512_NUM_REGS);
+ set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
+
/* Get the x86 target description from INFO. */
tdesc = info.target_desc;
if (! tdesc_has_registers (tdesc))
};
static const char *set_osabi_string;
+/* Names associated with each osabi. */
+
+struct osabi_names
+{
+ /* The "pretty" name. */
+
+ const char *pretty;
+
+ /* The triplet regexp, or NULL if not known. */
+
+ const char *regexp;
+};
+
/* This table matches the indices assigned to enum gdb_osabi. Keep
them in sync. */
-static const char * const gdb_osabi_names[] =
+static const struct osabi_names gdb_osabi_names[] =
{
- "none",
-
- "SVR4",
- "GNU/Hurd",
- "Solaris",
- "GNU/Linux",
- "FreeBSD a.out",
- "FreeBSD ELF",
- "NetBSD a.out",
- "NetBSD ELF",
- "OpenBSD ELF",
- "Windows CE",
- "DJGPP",
- "Irix",
- "HP/UX ELF",
- "HP/UX SOM",
- "QNX Neutrino",
- "Cygwin",
- "AIX",
- "DICOS",
- "Darwin",
- "Symbian",
- "OpenVMS",
- "LynxOS178",
- "Newlib",
-
- "<invalid>"
+ { "none", NULL },
+
+ { "SVR4", NULL },
+ { "GNU/Hurd", NULL },
+ { "Solaris", NULL },
+ { "GNU/Linux", "linux(-gnu)?" },
+ { "FreeBSD a.out", NULL },
+ { "FreeBSD ELF", NULL },
+ { "NetBSD a.out", NULL },
+ { "NetBSD ELF", NULL },
+ { "OpenBSD ELF", NULL },
+ { "Windows CE", NULL },
+ { "DJGPP", NULL },
+ { "Irix", NULL },
+ { "HP/UX ELF", NULL },
+ { "HP/UX SOM", NULL },
+ { "QNX Neutrino", NULL },
+ { "Cygwin", NULL },
+ { "AIX", NULL },
+ { "DICOS", NULL },
+ { "Darwin", NULL },
+ { "Symbian", NULL },
+ { "OpenVMS", NULL },
+ { "LynxOS178", NULL },
+ { "Newlib", NULL },
+
+ { "<invalid>", NULL }
};
const char *
gdbarch_osabi_name (enum gdb_osabi osabi)
{
if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
- return gdb_osabi_names[osabi];
+ return gdb_osabi_names[osabi].pretty;
+
+ return gdb_osabi_names[GDB_OSABI_INVALID].pretty;
+}
+
+/* See osabi.h. */
+
+const char *
+osabi_triplet_regexp (enum gdb_osabi osabi)
+{
+ if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
+ return gdb_osabi_names[osabi].regexp;
- return gdb_osabi_names[GDB_OSABI_INVALID];
+ return gdb_osabi_names[GDB_OSABI_INVALID].regexp;
}
/* Lookup the OS ABI corresponding to the specified target description
int i;
for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++)
- if (strcmp (name, gdb_osabi_names[i]) == 0)
+ if (strcmp (name, gdb_osabi_names[i].pretty) == 0)
{
/* See note above: the name table matches the indices assigned
to enum gdb_osabi. */
void
_initialize_gdb_osabi (void)
{
- if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "<invalid>") != 0)
+ if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID].pretty, "<invalid>") != 0)
internal_error
(__FILE__, __LINE__,
_("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
/* Return the name of the specified OS ABI. */
const char *gdbarch_osabi_name (enum gdb_osabi);
+/* Return a regular expression that matches the OS part of a GNU
+ configury triplet for the given OSABI. */
+const char *osabi_triplet_regexp (enum gdb_osabi osabi);
+
/* Helper routine for ELF file sniffers. This looks at ABI tag note
sections to determine the OS ABI from the note. It should be called
via bfd_map_over_sections. */