selftest-arch.c revision 1.1.1.1.2.2 1 1.1.1.1.2.2 christos /* GDB self-test for each gdbarch.
2 1.1.1.1.2.2 christos Copyright (C) 2017 Free Software Foundation, Inc.
3 1.1.1.1.2.2 christos
4 1.1.1.1.2.2 christos This file is part of GDB.
5 1.1.1.1.2.2 christos
6 1.1.1.1.2.2 christos This program is free software; you can redistribute it and/or modify
7 1.1.1.1.2.2 christos it under the terms of the GNU General Public License as published by
8 1.1.1.1.2.2 christos the Free Software Foundation; either version 3 of the License, or
9 1.1.1.1.2.2 christos (at your option) any later version.
10 1.1.1.1.2.2 christos
11 1.1.1.1.2.2 christos This program is distributed in the hope that it will be useful,
12 1.1.1.1.2.2 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1.1.1.1.2.2 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 1.1.1.1.2.2 christos GNU General Public License for more details.
15 1.1.1.1.2.2 christos
16 1.1.1.1.2.2 christos You should have received a copy of the GNU General Public License
17 1.1.1.1.2.2 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 1.1.1.1.2.2 christos
19 1.1.1.1.2.2 christos #include "defs.h"
20 1.1.1.1.2.2 christos
21 1.1.1.1.2.2 christos #if GDB_SELF_TEST
22 1.1.1.1.2.2 christos #include "selftest.h"
23 1.1.1.1.2.2 christos #include "selftest-arch.h"
24 1.1.1.1.2.2 christos #include "arch-utils.h"
25 1.1.1.1.2.2 christos
26 1.1.1.1.2.2 christos static std::vector<self_test_foreach_arch_function *> gdbarch_tests;
27 1.1.1.1.2.2 christos
28 1.1.1.1.2.2 christos void
29 1.1.1.1.2.2 christos register_self_test_foreach_arch (self_test_foreach_arch_function *function)
30 1.1.1.1.2.2 christos {
31 1.1.1.1.2.2 christos gdbarch_tests.push_back (function);
32 1.1.1.1.2.2 christos }
33 1.1.1.1.2.2 christos
34 1.1.1.1.2.2 christos namespace selftests {
35 1.1.1.1.2.2 christos
36 1.1.1.1.2.2 christos static void
37 1.1.1.1.2.2 christos tests_with_arch ()
38 1.1.1.1.2.2 christos {
39 1.1.1.1.2.2 christos int failed = 0;
40 1.1.1.1.2.2 christos
41 1.1.1.1.2.2 christos for (const auto &f : gdbarch_tests)
42 1.1.1.1.2.2 christos {
43 1.1.1.1.2.2 christos const char **arches = gdbarch_printable_names ();
44 1.1.1.1.2.2 christos
45 1.1.1.1.2.2 christos for (int i = 0; arches[i] != NULL; i++)
46 1.1.1.1.2.2 christos {
47 1.1.1.1.2.2 christos if (strcmp ("fr300", arches[i]) == 0)
48 1.1.1.1.2.2 christos {
49 1.1.1.1.2.2 christos /* PR 20946 */
50 1.1.1.1.2.2 christos continue;
51 1.1.1.1.2.2 christos }
52 1.1.1.1.2.2 christos else if (strcmp ("powerpc:EC603e", arches[i]) == 0
53 1.1.1.1.2.2 christos || strcmp ("powerpc:e500mc", arches[i]) == 0
54 1.1.1.1.2.2 christos || strcmp ("powerpc:e500mc64", arches[i]) == 0
55 1.1.1.1.2.2 christos || strcmp ("powerpc:titan", arches[i]) == 0
56 1.1.1.1.2.2 christos || strcmp ("powerpc:vle", arches[i]) == 0
57 1.1.1.1.2.2 christos || strcmp ("powerpc:e5500", arches[i]) == 0
58 1.1.1.1.2.2 christos || strcmp ("powerpc:e6500", arches[i]) == 0)
59 1.1.1.1.2.2 christos {
60 1.1.1.1.2.2 christos /* PR 19797 */
61 1.1.1.1.2.2 christos continue;
62 1.1.1.1.2.2 christos }
63 1.1.1.1.2.2 christos
64 1.1.1.1.2.2 christos QUIT;
65 1.1.1.1.2.2 christos
66 1.1.1.1.2.2 christos TRY
67 1.1.1.1.2.2 christos {
68 1.1.1.1.2.2 christos struct gdbarch_info info;
69 1.1.1.1.2.2 christos
70 1.1.1.1.2.2 christos gdbarch_info_init (&info);
71 1.1.1.1.2.2 christos info.bfd_arch_info = bfd_scan_arch (arches[i]);
72 1.1.1.1.2.2 christos
73 1.1.1.1.2.2 christos struct gdbarch *gdbarch = gdbarch_find_by_info (info);
74 1.1.1.1.2.2 christos SELF_CHECK (gdbarch != NULL);
75 1.1.1.1.2.2 christos f (gdbarch);
76 1.1.1.1.2.2 christos }
77 1.1.1.1.2.2 christos CATCH (ex, RETURN_MASK_ERROR)
78 1.1.1.1.2.2 christos {
79 1.1.1.1.2.2 christos ++failed;
80 1.1.1.1.2.2 christos exception_fprintf (gdb_stderr, ex,
81 1.1.1.1.2.2 christos _("Self test failed: arch %s: "), arches[i]);
82 1.1.1.1.2.2 christos }
83 1.1.1.1.2.2 christos END_CATCH
84 1.1.1.1.2.2 christos }
85 1.1.1.1.2.2 christos }
86 1.1.1.1.2.2 christos
87 1.1.1.1.2.2 christos SELF_CHECK (failed == 0);
88 1.1.1.1.2.2 christos }
89 1.1.1.1.2.2 christos
90 1.1.1.1.2.2 christos } // namespace selftests
91 1.1.1.1.2.2 christos #endif /* GDB_SELF_TEST */
92 1.1.1.1.2.2 christos
93 1.1.1.1.2.2 christos /* Suppress warning from -Wmissing-prototypes. */
94 1.1.1.1.2.2 christos extern initialize_file_ftype _initialize_selftests_foreach_arch;
95 1.1.1.1.2.2 christos
96 1.1.1.1.2.2 christos void
97 1.1.1.1.2.2 christos _initialize_selftests_foreach_arch ()
98 1.1.1.1.2.2 christos {
99 1.1.1.1.2.2 christos #if GDB_SELF_TEST
100 1.1.1.1.2.2 christos register_self_test (selftests::tests_with_arch);
101 1.1.1.1.2.2 christos #endif
102 1.1.1.1.2.2 christos }
103