558a25be865bdeddc4bf6a109a992ee96dfdba44
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-x86-tdesc-selftest.c
1 /* Copyright (C) 2017 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include "server.h"
19 #include "linux-x86-tdesc.h"
20 #include "tdesc.h"
21 #include "common/selftest.h"
22 #include "x86-xstate.h"
23
24 /* Defined in auto-generated file i386-linux.c. */
25 void init_registers_i386_linux (void);
26 extern const struct target_desc *tdesc_i386_linux;
27
28 /* Defined in auto-generated file i386-mmx-linux.c. */
29 void init_registers_i386_mmx_linux (void);
30 extern const struct target_desc *tdesc_i386_mmx_linux;
31
32 /* Defined in auto-generated file i386-avx-linux.c. */
33 void init_registers_i386_avx_linux (void);
34 extern const struct target_desc *tdesc_i386_avx_linux;
35
36 /* Defined in auto-generated file i386-avx-mpx-linux.c. */
37 void init_registers_i386_avx_mpx_linux (void);
38 extern const struct target_desc *tdesc_i386_avx_mpx_linux;
39
40 /* Defined in auto-generated file i386-avx-avx512-linux.c. */
41 void init_registers_i386_avx_avx512_linux (void);
42 extern const struct target_desc *tdesc_i386_avx_avx512_linux;
43
44 /* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */
45 void init_registers_i386_avx_mpx_avx512_pku_linux (void);
46 extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux;
47
48 /* Defined in auto-generated file i386-mpx-linux.c. */
49 void init_registers_i386_mpx_linux (void);
50 extern const struct target_desc *tdesc_i386_mpx_linux;
51
52 namespace selftests {
53 namespace tdesc {
54 static void
55 i386_tdesc_test ()
56 {
57 struct
58 {
59 unsigned int mask;
60 const target_desc *tdesc;
61 } tdesc_tests[] = {
62 { X86_XSTATE_X87, tdesc_i386_mmx_linux },
63 { X86_XSTATE_SSE_MASK, tdesc_i386_linux },
64 { X86_XSTATE_AVX_MASK, tdesc_i386_avx_linux },
65 { X86_XSTATE_MPX_MASK, tdesc_i386_mpx_linux },
66 { X86_XSTATE_AVX_MPX_MASK, tdesc_i386_avx_mpx_linux },
67 { X86_XSTATE_AVX_AVX512_MASK, tdesc_i386_avx_avx512_linux },
68 { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK, tdesc_i386_avx_mpx_avx512_pku_linux }
69 };
70
71 for (auto &elem : tdesc_tests)
72 {
73 const target_desc *tdesc = i386_linux_read_description (elem.mask);
74
75 SELF_CHECK (*tdesc == *elem.tdesc);
76 }
77 }
78 }
79 } // namespace selftests
80
81 void
82 initialize_low_tdesc ()
83 {
84 init_registers_i386_linux ();
85 init_registers_i386_mmx_linux ();
86 init_registers_i386_avx_linux ();
87 init_registers_i386_mpx_linux ();
88 init_registers_i386_avx_mpx_linux ();
89 init_registers_i386_avx_avx512_linux ();
90 init_registers_i386_avx_mpx_avx512_pku_linux ();
91
92 selftests::register_test (selftests::tdesc::i386_tdesc_test);
93 }
This page took 0.031583 seconds and 3 git commands to generate.