diff options
-rw-r--r-- | gdb/gdbserver/configure.srv | 6 | ||||
-rw-r--r-- | gdb/gdbserver/linux-i386-ipa.c | 36 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 44 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-tdesc.c | 111 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-tdesc.h | 31 |
5 files changed, 135 insertions, 93 deletions
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 43f90c9..1a5801a 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -122,13 +122,14 @@ case "${target}" in srv_tgtobj="amd64-linux-siginfo.o" fi srv_tgtobj="${srv_tgtobj} $srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o" + srv_tgtobj="${srv_tgtobj} linux-x86-tdesc.o" srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o" srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes srv_linux_btrace=yes - ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o" + ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o linux-x86-tdesc-ipa.o" ;; i[34567]86-*-lynxos*) srv_regobj="i386.o" srv_tgtobj="lynx-low.o lynx-i386-low.o fork-child.o fork-inferior.o" @@ -356,6 +357,7 @@ case "${target}" in ;; x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj" srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o" + srv_tgtobj="${srv_tgtobj} linux-x86-tdesc.o" srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o" srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o" srv_tgtobj="${srv_tgtobj} amd64-linux-siginfo.o" @@ -369,7 +371,7 @@ case "${target}" in else ipa_obj="${ipa_amd64_linux_regobj}" fi - ipa_obj="${ipa_obj} linux-amd64-ipa.o" + ipa_obj="${ipa_obj} linux-amd64-ipa.o linux-x86-tdesc-ipa.o" ;; x86_64-*-mingw*) srv_regobj="$srv_amd64_regobj" srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o" diff --git a/gdb/gdbserver/linux-i386-ipa.c b/gdb/gdbserver/linux-i386-ipa.c index e9ac78b..bca3fdb 100644 --- a/gdb/gdbserver/linux-i386-ipa.c +++ b/gdb/gdbserver/linux-i386-ipa.c @@ -244,35 +244,6 @@ initialize_fast_tracepoint_trampoline_buffer (void) } } -/* Return target_desc to use for IPA, given the tdesc index passed by - gdbserver. */ - -const struct target_desc * -get_ipa_tdesc (int idx) -{ - switch (idx) - { - case X86_TDESC_MMX: - return tdesc_i386_mmx_linux; - case X86_TDESC_SSE: - return tdesc_i386_linux; - case X86_TDESC_AVX: - return tdesc_i386_avx_linux; - case X86_TDESC_MPX: - return tdesc_i386_mpx_linux; - case X86_TDESC_AVX_MPX: - return tdesc_i386_avx_mpx_linux; - case X86_TDESC_AVX_AVX512: - return tdesc_i386_avx_avx512_linux; - case X86_TDESC_AVX_MPX_AVX512_PKU: - return tdesc_i386_avx_mpx_avx512_pku_linux; - default: - internal_error (__FILE__, __LINE__, - "unknown ipa tdesc index: %d", idx); - return tdesc_i386_linux; - } -} - /* Allocate buffer for the jump pads. On i386, we can reach an arbitrary address with a jump instruction, so just allocate normally. */ @@ -291,12 +262,7 @@ alloc_jump_pad_buffer (size_t size) void initialize_low_tracepoint (void) { - init_registers_i386_mmx_linux (); - init_registers_i386_linux (); - init_registers_i386_avx_linux (); - init_registers_i386_mpx_linux (); - init_registers_i386_avx_avx512_linux (); - init_registers_i386_avx_mpx_avx512_pku_linux (); + initialize_low_tdesc (); initialize_fast_tracepoint_trampoline_buffer (); } diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index b39026c..f5d4aa1 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -757,7 +757,7 @@ x86_linux_read_description (void) { have_ptrace_getfpxregs = 0; have_ptrace_getregset = 0; - return tdesc_i386_mmx_linux; + return i386_get_ipa_tdesc (X86_TDESC_MMX); } else have_ptrace_getfpxregs = 1; @@ -878,26 +878,26 @@ x86_linux_read_description (void) switch (xcr0 & X86_XSTATE_ALL_MASK) { case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK: - return tdesc_i386_avx_mpx_avx512_pku_linux; + return i386_get_ipa_tdesc (X86_TDESC_AVX_MPX_AVX512_PKU); case (X86_XSTATE_AVX_AVX512_MASK): - return tdesc_i386_avx_avx512_linux; + return i386_get_ipa_tdesc (X86_TDESC_AVX_AVX512); case (X86_XSTATE_MPX_MASK): - return tdesc_i386_mpx_linux; + return i386_get_ipa_tdesc (X86_TDESC_MPX); case (X86_XSTATE_AVX_MPX_MASK): - return tdesc_i386_avx_mpx_linux; + return i386_get_ipa_tdesc (X86_TDESC_AVX_MPX); case (X86_XSTATE_AVX_MASK): - return tdesc_i386_avx_linux; + return i386_get_ipa_tdesc (X86_TDESC_AVX); default: - return tdesc_i386_linux; + return i386_get_ipa_tdesc (X86_TDESC_SSE); } } else - return tdesc_i386_linux; + return i386_get_ipa_tdesc (X86_TDESC_SSE); } gdb_assert_not_reached ("failed to return tdesc"); @@ -2912,22 +2912,10 @@ x86_get_ipa_tdesc_idx (void) return X86_TDESC_AVX_AVX512; #endif - if (tdesc == tdesc_i386_mmx_linux) - return X86_TDESC_MMX; - if (tdesc == tdesc_i386_linux || tdesc == tdesc_i386_linux_no_xml) + if (tdesc == tdesc_i386_linux_no_xml) return X86_TDESC_SSE; - if (tdesc == tdesc_i386_avx_linux) - return X86_TDESC_AVX; - if (tdesc == tdesc_i386_mpx_linux) - return X86_TDESC_MPX; - if (tdesc == tdesc_i386_avx_mpx_linux) - return X86_TDESC_AVX_MPX; - if (tdesc == tdesc_i386_avx_mpx_avx512_pku_linux) - return X86_TDESC_AVX_MPX_AVX512_PKU; - if (tdesc == tdesc_i386_avx_avx512_linux) - return X86_TDESC_AVX_AVX512; - return 0; + return i386_get_ipa_tdesc_idx (tdesc); } /* This is initialized assuming an amd64 target. @@ -2996,16 +2984,12 @@ initialize_low_arch (void) copy_target_description (tdesc_amd64_linux_no_xml, tdesc_amd64_linux); tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml; #endif - init_registers_i386_linux (); - init_registers_i386_mmx_linux (); - init_registers_i386_avx_linux (); - init_registers_i386_mpx_linux (); - init_registers_i386_avx_mpx_linux (); - init_registers_i386_avx_avx512_linux (); - init_registers_i386_avx_mpx_avx512_pku_linux (); + + initialize_low_tdesc (); tdesc_i386_linux_no_xml = XNEW (struct target_desc); - copy_target_description (tdesc_i386_linux_no_xml, tdesc_i386_linux); + copy_target_description (tdesc_i386_linux_no_xml, + i386_get_ipa_tdesc (X86_TDESC_SSE)); tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml; initialize_regsets_info (&x86_regsets_info); diff --git a/gdb/gdbserver/linux-x86-tdesc.c b/gdb/gdbserver/linux-x86-tdesc.c new file mode 100644 index 0000000..e294a98 --- /dev/null +++ b/gdb/gdbserver/linux-x86-tdesc.c @@ -0,0 +1,111 @@ +/* GNU/Linux/x86-64 specific target description, for the remote server + for GDB. + Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "server.h" +#include "linux-x86-tdesc.h" + +#if defined __i386__ || !defined IN_PROCESS_AGENT +/* Defined in auto-generated file i386-linux.c. */ +void init_registers_i386_linux (void); +extern const struct target_desc *tdesc_i386_linux; + +/* Defined in auto-generated file i386-mmx-linux.c. */ +void init_registers_i386_mmx_linux (void); +extern const struct target_desc *tdesc_i386_mmx_linux; + +/* Defined in auto-generated file i386-avx-linux.c. */ +void init_registers_i386_avx_linux (void); +extern const struct target_desc *tdesc_i386_avx_linux; + +/* Defined in auto-generated file i386-avx-mpx-linux.c. */ +void init_registers_i386_avx_mpx_linux (void); +extern const struct target_desc *tdesc_i386_avx_mpx_linux; + +/* Defined in auto-generated file i386-avx-avx512-linux.c. */ +void init_registers_i386_avx_avx512_linux (void); +extern const struct target_desc *tdesc_i386_avx_avx512_linux; + +/* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */ +void init_registers_i386_avx_mpx_avx512_pku_linux (void); +extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux; + +/* Defined in auto-generated file i386-mpx-linux.c. */ +void init_registers_i386_mpx_linux (void); +extern const struct target_desc *tdesc_i386_mpx_linux; +#endif + +static const struct target_desc *i386_tdescs[X86_TDESC_LAST] = { }; + +void +initialize_low_tdesc () +{ +#if defined __i386__ || !defined IN_PROCESS_AGENT + init_registers_i386_linux (); + init_registers_i386_mmx_linux (); + init_registers_i386_avx_linux (); + init_registers_i386_mpx_linux (); + init_registers_i386_avx_mpx_linux (); + init_registers_i386_avx_avx512_linux (); + init_registers_i386_avx_mpx_avx512_pku_linux (); + + i386_tdescs[X86_TDESC_MMX] = tdesc_i386_mmx_linux; + i386_tdescs[X86_TDESC_SSE] = tdesc_i386_linux; + i386_tdescs[X86_TDESC_AVX] = tdesc_i386_avx_linux; + i386_tdescs[X86_TDESC_MPX] = tdesc_i386_mpx_linux; + i386_tdescs[X86_TDESC_AVX_MPX] = tdesc_i386_avx_mpx_linux; + i386_tdescs[X86_TDESC_AVX_AVX512] = tdesc_i386_avx_avx512_linux; + i386_tdescs[X86_TDESC_AVX_MPX_AVX512_PKU] + = tdesc_i386_avx_mpx_avx512_pku_linux; +#endif +} + +const struct target_desc * +i386_get_ipa_tdesc (int idx) +{ + if (idx >= X86_TDESC_LAST) + internal_error (__FILE__, __LINE__, + "unknown ipa tdesc index: %d", idx); + + return i386_tdescs[idx]; +} + +#ifdef IN_PROCESS_AGENT + +#if defined __i386__ +const struct target_desc * +get_ipa_tdesc (int idx) +{ +return i386_get_ipa_tdesc (idx); +} +#endif + +#else +int +i386_get_ipa_tdesc_idx (const struct target_desc *tdesc) +{ + for (int i = 0; i < X86_TDESC_LAST; i++) + { + if (tdesc == i386_tdescs[i]) + return i; + } + + return 0; +} + +#endif diff --git a/gdb/gdbserver/linux-x86-tdesc.h b/gdb/gdbserver/linux-x86-tdesc.h index bbe4078..894cf4e 100644 --- a/gdb/gdbserver/linux-x86-tdesc.h +++ b/gdb/gdbserver/linux-x86-tdesc.h @@ -30,6 +30,7 @@ enum x86_linux_tdesc { X86_TDESC_AVX_MPX = 4, X86_TDESC_AVX_AVX512 = 5, X86_TDESC_AVX_MPX_AVX512_PKU = 6, + X86_TDESC_LAST = 7, }; #ifdef __x86_64__ @@ -77,31 +78,9 @@ extern const struct target_desc *tdesc_x32_avx_avx512_linux; #endif #if defined __i386__ || !defined IN_PROCESS_AGENT -/* Defined in auto-generated file i386-linux.c. */ -void init_registers_i386_linux (void); -extern const struct target_desc *tdesc_i386_linux; - -/* Defined in auto-generated file i386-mmx-linux.c. */ -void init_registers_i386_mmx_linux (void); -extern const struct target_desc *tdesc_i386_mmx_linux; - -/* Defined in auto-generated file i386-avx-linux.c. */ -void init_registers_i386_avx_linux (void); -extern const struct target_desc *tdesc_i386_avx_linux; - -/* Defined in auto-generated file i386-avx-mpx-linux.c. */ -void init_registers_i386_avx_mpx_linux (void); -extern const struct target_desc *tdesc_i386_avx_mpx_linux; - -/* Defined in auto-generated file i386-avx-avx512-linux.c. */ -void init_registers_i386_avx_avx512_linux (void); -extern const struct target_desc *tdesc_i386_avx_avx512_linux; +int i386_get_ipa_tdesc_idx (const struct target_desc *tdesc); +#endif -/* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */ -void init_registers_i386_avx_mpx_avx512_pku_linux (void); -extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux; +const struct target_desc *i386_get_ipa_tdesc (int idx); -/* Defined in auto-generated file i386-mpx-linux.c. */ -void init_registers_i386_mpx_linux (void); -extern const struct target_desc *tdesc_i386_mpx_linux; -#endif +void initialize_low_tdesc (); |