From: Yao Qi Date: Tue, 5 Sep 2017 08:54:53 +0000 (+0100) Subject: [GDBserver] Use pre-generated tdesc as test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25a93583f34f5abfe9c1b24393738547a8de657c;p=binutils-gdb.git [GDBserver] Use pre-generated tdesc as test Now, these *-generate.c files are only used in GDBserver for unit test. If $development is false (in release), these *-generate.c files won't be used at all. gdb/gdbserver: 2017-09-05 Yao Qi * configure.srv: Set srv_i386_linux_regobj empty if $development is false. * linux-i386-ipa.c (initialize_low_tracepoint): Don't call initialize_low_tdesc. * linux-x86-low.c (initialize_low_arch): Wrap initialize_low_tdesc with #if initialize_low_tdesc. * linux-x86-tdesc-selftest.c: New file. * linux-x86-tdesc.c: Move code to linux-x86-tdesc-selftest.c. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 2a3d8d214fa..065a4184ea5 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2017-09-05 Yao Qi + + * configure.srv: Set srv_i386_linux_regobj empty if $development + is false. + * linux-i386-ipa.c (initialize_low_tracepoint): Don't call + initialize_low_tdesc. + * linux-x86-low.c (initialize_low_arch): Wrap initialize_low_tdesc + with #if initialize_low_tdesc. + * linux-x86-tdesc-selftest.c: New file. + * linux-x86-tdesc.c: Move code to linux-x86-tdesc-selftest.c. + 2017-09-05 Yao Qi * Makefile.in (arch-i386.o): New rule. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 876098b670f..dbd87b29b60 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -25,11 +25,16 @@ srv_hostio_err_objs="hostio-errno.o" srv_i386_regobj="i386.o" -srv_i386_linux_regobj="i386-linux.o i386-avx-linux.o i386-avx-avx512-linux.o i386-avx-mpx-avx512-pku-linux.o i386-mpx-linux.o i386-avx-mpx-linux.o i386-mmx-linux.o" + +if $development; then + srv_i386_linux_regobj="i386-linux.o i386-avx-linux.o i386-avx-avx512-linux.o i386-avx-mpx-avx512-pku-linux.o i386-mpx-linux.o i386-avx-mpx-linux.o i386-mmx-linux.o linux-x86-tdesc-selftest.o" +else + srv_i386_linux_regobj="" +fi + srv_amd64_regobj="amd64.o" srv_amd64_linux_regobj="amd64-linux.o amd64-avx-linux.o amd64-avx-avx512-linux.o amd64-avx-mpx-avx512-pku-linux.o amd64-mpx-linux.o amd64-avx-mpx-linux.o x32-linux.o x32-avx-linux.o x32-avx-avx512-linux.o" -ipa_i386_linux_regobj="i386-linux-ipa.o i386-avx-linux-ipa.o i386-avx-mpx-linux-ipa.o i386-avx-avx512-linux-ipa.o i386-avx-mpx-avx512-pku-linux-ipa.o i386-mpx-linux-ipa.o i386-mmx-linux-ipa.o" ipa_amd64_linux_regobj="amd64-linux-ipa.o amd64-avx-linux-ipa.o amd64-avx-mpx-linux-ipa.o amd64-avx-avx512-linux-ipa.o amd64-avx-mpx-avx512-pku-linux-ipa.o amd64-mpx-linux-ipa.o" ipa_x32_linux_regobj="x32-linux-ipa.o x32-avx-linux-ipa.o x32-avx-avx512-linux-ipa.o" ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o" @@ -131,7 +136,7 @@ case "${target}" in srv_linux_regsets=yes srv_linux_thread_db=yes srv_linux_btrace=yes - ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o linux-x86-tdesc-ipa.o" + ipa_obj="linux-i386-ipa.o linux-x86-tdesc-ipa.o" ipa_obj="${ipa_obj} i386-ipa.o" ;; i[34567]86-*-lynxos*) srv_regobj="i386.o" diff --git a/gdb/gdbserver/linux-i386-ipa.c b/gdb/gdbserver/linux-i386-ipa.c index 54608da15da..785a63ed66e 100644 --- a/gdb/gdbserver/linux-i386-ipa.c +++ b/gdb/gdbserver/linux-i386-ipa.c @@ -289,7 +289,5 @@ alloc_jump_pad_buffer (size_t size) void initialize_low_tracepoint (void) { - 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 24b76a71f49..54be82f870f 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -2969,7 +2969,9 @@ initialize_low_arch (void) tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml; #endif +#if GDB_SELF_TEST initialize_low_tdesc (); +#endif tdesc_i386_linux_no_xml = XNEW (struct target_desc); copy_target_description (tdesc_i386_linux_no_xml, diff --git a/gdb/gdbserver/linux-x86-tdesc-selftest.c b/gdb/gdbserver/linux-x86-tdesc-selftest.c new file mode 100644 index 00000000000..558a25be865 --- /dev/null +++ b/gdb/gdbserver/linux-x86-tdesc-selftest.c @@ -0,0 +1,93 @@ +/* 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 . */ + +#include "server.h" +#include "linux-x86-tdesc.h" +#include "tdesc.h" +#include "common/selftest.h" +#include "x86-xstate.h" + +/* 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; + +namespace selftests { +namespace tdesc { +static void +i386_tdesc_test () +{ + struct + { + unsigned int mask; + const target_desc *tdesc; + } tdesc_tests[] = { + { X86_XSTATE_X87, tdesc_i386_mmx_linux }, + { X86_XSTATE_SSE_MASK, tdesc_i386_linux }, + { X86_XSTATE_AVX_MASK, tdesc_i386_avx_linux }, + { X86_XSTATE_MPX_MASK, tdesc_i386_mpx_linux }, + { X86_XSTATE_AVX_MPX_MASK, tdesc_i386_avx_mpx_linux }, + { X86_XSTATE_AVX_AVX512_MASK, tdesc_i386_avx_avx512_linux }, + { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK, tdesc_i386_avx_mpx_avx512_pku_linux } + }; + + for (auto &elem : tdesc_tests) + { + const target_desc *tdesc = i386_linux_read_description (elem.mask); + + SELF_CHECK (*tdesc == *elem.tdesc); + } +} +} +} // namespace selftests + +void +initialize_low_tdesc () +{ + 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 (); + + selftests::register_test (selftests::tdesc::i386_tdesc_test); +} diff --git a/gdb/gdbserver/linux-x86-tdesc.c b/gdb/gdbserver/linux-x86-tdesc.c index 548e7805f26..d1e262c4805 100644 --- a/gdb/gdbserver/linux-x86-tdesc.c +++ b/gdb/gdbserver/linux-x86-tdesc.c @@ -23,90 +23,8 @@ #include "arch/i386.h" #include "common/x86-xstate.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 struct target_desc *i386_tdescs[X86_TDESC_LAST] = { }; -#if defined GDB_SELF_TEST && !defined IN_PROCESS_AGENT -#include "selftest.h" - -namespace selftests { -namespace tdesc { -static void -i386_tdesc_test () -{ - struct - { - unsigned int mask; - const target_desc *tdesc; - } tdesc_tests[] = { - { X86_XSTATE_X87, tdesc_i386_mmx_linux }, - { X86_XSTATE_SSE_MASK, tdesc_i386_linux }, - { X86_XSTATE_AVX_MASK, tdesc_i386_avx_linux }, - { X86_XSTATE_MPX_MASK, tdesc_i386_mpx_linux }, - { X86_XSTATE_AVX_MPX_MASK, tdesc_i386_avx_mpx_linux }, - { X86_XSTATE_AVX_AVX512_MASK, tdesc_i386_avx_avx512_linux }, - { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK, tdesc_i386_avx_mpx_avx512_pku_linux } - }; - - for (auto &elem : tdesc_tests) - { - const target_desc *tdesc = i386_linux_read_description (elem.mask); - - SELF_CHECK (*tdesc == *elem.tdesc); - } -} -} -} // namespace selftests -#endif /* GDB_SELF_TEST */ - -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 (); - -#if GDB_SELF_TEST && !defined IN_PROCESS_AGENT - selftests::register_test (selftests::tdesc::i386_tdesc_test); -#endif -#endif -} - #if defined __i386__ || !defined IN_PROCESS_AGENT /* Return the target description according to XCR0. */