diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-07-26 12:36:42 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-07-26 12:36:42 +0100 |
commit | 35b4818d03e8d63a926afb235a21c2cb64b14b23 (patch) | |
tree | d1a86883987c33bed2ba86552224a97e972f65ec /gdb/i386-linux-tdep.c | |
parent | 8e2141c6fba6daea1555e042da9de49ec8b1977d (diff) | |
download | binutils-gdb-35b4818d03e8d63a926afb235a21c2cb64b14b23.tar.gz |
Centralize i386 linux target descriptions
This patch moves all the tdesc_i386*_linux target descriptions to a
function i386_linux_read_description, which returns the right target
description according to xcr0. This also remove the duplication in
getting target descriptions in corefile and native target.
gdb:
2017-07-26 Yao Qi <yao.qi@linaro.org>
* i386-linux-tdep.c (i386_linux_read_description): New function.
(i386_linux_core_read_description): Call
i386_linux_read_description.
* i386-linux-tdep.h (i386_linux_read_description): Declare.
(tdesc_i386_linux, tdesc_i386_mmx_linux): Remove declarations.
(tdesc_i386_avx_linux, tdesc_i386_mpx_linux): Likewise
(tdesc_i386_avx_mpx_linux, tdesc_i386_avx_avx512_linux): Likewise.
(tdesc_i386_avx_mpx_avx512_pku_linux): Likewise.
* x86-linux-nat.c (x86_linux_read_description): Call
i386_linux_read_description.
Diffstat (limited to 'gdb/i386-linux-tdep.c')
-rw-r--r-- | gdb/i386-linux-tdep.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index d381e41c14a..e986d6feaa6 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -678,16 +678,11 @@ i386_linux_core_read_xcr0 (bfd *abfd) return xcr0; } -/* Get Linux/x86 target description from core dump. */ +/* See i386-linux-tdep.h. */ -static const struct target_desc * -i386_linux_core_read_description (struct gdbarch *gdbarch, - struct target_ops *target, - bfd *abfd) +const struct target_desc * +i386_linux_read_description (uint64_t xcr0) { - /* Linux/i386. */ - uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd); - switch ((xcr0 & X86_XSTATE_ALL_MASK)) { case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK: @@ -708,10 +703,27 @@ i386_linux_core_read_description (struct gdbarch *gdbarch, break; } + return NULL; +} + +/* Get Linux/x86 target description from core dump. */ + +static const struct target_desc * +i386_linux_core_read_description (struct gdbarch *gdbarch, + struct target_ops *target, + bfd *abfd) +{ + /* Linux/i386. */ + uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd); + const struct target_desc *tdesc = i386_linux_read_description (xcr0); + + if (tdesc != NULL) + return tdesc; + if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL) - return tdesc_i386_linux; + return i386_linux_read_description (X86_XSTATE_SSE_MASK); else - return tdesc_i386_mmx_linux; + return i386_linux_read_description (X86_XSTATE_X87_MASK); } /* Similar to i386_supply_fpregset, but use XSAVE extended state. */ @@ -835,7 +847,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS); if (! tdesc_has_registers (tdesc)) - tdesc = tdesc_i386_linux; + tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK); tdep->tdesc = tdesc; feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); |