diff options
author | Tom Tromey <tromey@redhat.com> | 2014-06-13 09:28:24 -0600 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2014-12-12 22:26:11 +0100 |
commit | ac04f72bb4396a311ffc445710d4068c13fb0448 (patch) | |
tree | 4f83982f12355cab79a0f5cfbcb9011dcb8ecfc6 /gdb/gdbarch.c | |
parent | f208eee0f3a4f42a0bf20ab900eb36fbba8e4b9e (diff) | |
download | gdb-ac04f72bb4396a311ffc445710d4068c13fb0448.zip gdb-ac04f72bb4396a311ffc445710d4068c13fb0448.tar.gz gdb-ac04f72bb4396a311ffc445710d4068c13fb0448.tar.bz2 |
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 <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.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r-- | gdb/gdbarch.c | 23 |
1 files changed, 23 insertions, 0 deletions
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. */ |