From ac04f72bb4396a311ffc445710d4068c13fb0448 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 13 Jun 2014 09:28:24 -0600 Subject: add gnu_triplet_regexp gdbarch method gdb has to inform libcc1.so of the target being used, so that the correct compiler can be invoked. The compiler is invoked using the GNU configury triplet prefix, e.g., "x86_64-unknown-linux-gnu-gcc". In order for this to work we need to map the gdbarch to the GNU configury triplet arch. In most cases these are identical; however, the x86 family poses some problems, as the BFD arch names are quite different from the GNU triplet names. So, we introduce a new gdbarch method for this. A regular expression is used because there are various valid values for the arch prefix in the triplet. This patch also updates the osabi code to associate a regular expression with the OS ABI. I have only added a concrete value for Linux. Note that the "-gnu" part is optional, at least on Fedora it is omitted from the installed GCC executable's name. gdb/ChangeLog 2014-12-12 Tom Tromey Jan Kratochvil * 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. --- gdb/gdbarch.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gdb/gdbarch.h') diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index d086553bba8..a40863d7fab 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) -- cgit v1.2.3-65-gdbad