diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:53 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:53 +0100 |
commit | 25a93583f34f5abfe9c1b24393738547a8de657c (patch) | |
tree | afd5a99d95ae585ab568e8058c3a7bc1581da9e6 /gdb | |
parent | 188c9e6dcb2f1342f1ca51e8f68c22852522277e (diff) | |
download | gdb-25a93583f34f5abfe9c1b24393738547a8de657c.zip gdb-25a93583f34f5abfe9c1b24393738547a8de657c.tar.gz gdb-25a93583f34f5abfe9c1b24393738547a8de657c.tar.bz2 |
[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 <yao.qi@linaro.org>
* 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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/gdbserver/configure.srv | 11 | ||||
-rw-r--r-- | gdb/gdbserver/linux-i386-ipa.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-tdesc-selftest.c | 93 | ||||
-rw-r--r-- | gdb/gdbserver/linux-x86-tdesc.c | 82 |
6 files changed, 114 insertions, 87 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 2a3d8d2..065a418 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,16 @@ 2017-09-05 Yao Qi <yao.qi@linaro.org> + * 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 <yao.qi@linaro.org> + * Makefile.in (arch-i386.o): New rule. * configure.srv (i[34567]86-*-linux*): Add arch-i386.o. (x86_64-*-linux*): Likewise. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 876098b..dbd87b2 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 54608da..785a63e 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 24b76a7..54be82f 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 0000000..558a25b --- /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 <http://www.gnu.org/licenses/>. */ + +#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 548e780..d1e262c 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. */ |