aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/arch-utils.c8
-rw-r--r--gdb/arch-utils.h1
-rw-r--r--gdb/gdbarch.c23
-rw-r--r--gdb/gdbarch.h10
-rwxr-xr-xgdb/gdbarch.sh7
-rw-r--r--gdb/i386-tdep.c17
-rw-r--r--gdb/osabi.c88
-rw-r--r--gdb/osabi.h4
9 files changed, 144 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b310769..21a292f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,21 @@
+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)
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 3cd0a21..ce6ad78 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -874,6 +874,14 @@ default_gcc_target_options (struct gdbarch *gdbarch)
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;
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index e1d2c4a..200ce54 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -201,5 +201,6 @@ extern void default_skip_permanent_breakpoint (struct regcache *regcache);
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
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index d815a1c..657708e 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -323,6 +323,7 @@ struct gdbarch
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
@@ -421,6 +422,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
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;
@@ -648,6 +650,7 @@ verify_gdbarch (struct gdbarch *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)
@@ -960,6 +963,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"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,
@@ -4565,6 +4571,23 @@ set_gdbarch_gcc_target_options (struct gdbarch *gdbarch,
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. */
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index d086553..a40863d 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1407,6 +1407,16 @@ typedef char * (gdbarch_gcc_target_options_ftype) (struct gdbarch *gdbarch);
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)
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 8f4cd69..a643d00 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -1087,6 +1087,13 @@ f:CORE_ADDR:infcall_mmap:CORE_ADDR size, unsigned prot:size, prot::default_infca
# 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
}
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 6c4ef17..0750506 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -4306,6 +4306,17 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
+/* 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)";
+}
+
+
+
/* Generic ELF. */
void
@@ -4332,6 +4343,8 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
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). */
@@ -4379,6 +4392,8 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
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);
}
@@ -8402,6 +8417,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
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))
diff --git a/gdb/osabi.c b/gdb/osabi.c
index d33ef9c..50d391a 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -41,46 +41,70 @@ static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = {
};
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
@@ -92,7 +116,7 @@ osabi_from_tdesc_string (const char *name)
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. */
@@ -645,7 +669,7 @@ extern initialize_file_ftype _initialize_gdb_osabi; /* -Wmissing-prototype */
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"));
diff --git a/gdb/osabi.h b/gdb/osabi.h
index 4c03790..8408f0a 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -49,6 +49,10 @@ void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *);
/* 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. */