gdb: remove gdbarch_info_init
[deliverable/binutils-gdb.git] / gdb / selftest-arch.c
CommitLineData
79843d45 1/* GDB self-test for each gdbarch.
3666a048 2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
79843d45
YQ
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include "defs.h"
20
21#if GDB_SELF_TEST
268a13a5 22#include "gdbsupport/selftest.h"
79843d45
YQ
23#include "selftest-arch.h"
24#include "arch-utils.h"
25
7649770c
YQ
26namespace selftests {
27
1526853e
SM
28/* A kind of selftest that calls the test function once for each gdbarch known
29 to GDB. */
30
31struct gdbarch_selftest : public selftest
32{
33 gdbarch_selftest (self_test_foreach_arch_function *function_)
34 : function (function_)
35 {}
36
37 void operator() () const override
38 {
39 const char **arches = gdbarch_printable_names ();
40 bool pass = true;
41
42 for (int i = 0; arches[i] != NULL; i++)
43 {
44 if (strcmp ("fr300", arches[i]) == 0)
45 {
46 /* PR 20946 */
47 continue;
48 }
49 else if (strcmp ("powerpc:EC603e", arches[i]) == 0
50 || strcmp ("powerpc:e500mc", arches[i]) == 0
51 || strcmp ("powerpc:e500mc64", arches[i]) == 0
52 || strcmp ("powerpc:titan", arches[i]) == 0
53 || strcmp ("powerpc:vle", arches[i]) == 0
54 || strcmp ("powerpc:e5500", arches[i]) == 0
55 || strcmp ("powerpc:e6500", arches[i]) == 0)
56 {
57 /* PR 19797 */
58 continue;
59 }
60
61 QUIT;
62
a70b8144 63 try
1526853e
SM
64 {
65 struct gdbarch_info info;
66
1526853e
SM
67 info.bfd_arch_info = bfd_scan_arch (arches[i]);
68
69 struct gdbarch *gdbarch = gdbarch_find_by_info (info);
70 SELF_CHECK (gdbarch != NULL);
71
72 function (gdbarch);
73 }
230d2906 74 catch (const gdb_exception_error &ex)
1526853e
SM
75 {
76 pass = false;
77 exception_fprintf (gdb_stderr, ex,
78 _("Self test failed: arch %s: "), arches[i]);
79 }
1526853e
SM
80
81 reset ();
82 }
83
84 SELF_CHECK (pass);
85 }
86
87 self_test_foreach_arch_function *function;
88};
79843d45
YQ
89
90void
1526853e
SM
91register_test_foreach_arch (const std::string &name,
92 self_test_foreach_arch_function *function)
79843d45 93{
1526853e 94 register_test (name, new gdbarch_selftest (function));
79843d45
YQ
95}
96
6d580b63
YQ
97void
98reset ()
99{
100 /* Clear GDB internal state. */
101 registers_changed ();
102 reinit_frame_cache ();
103}
79843d45
YQ
104} // namespace selftests
105#endif /* GDB_SELF_TEST */
This page took 0.574083 seconds and 4 git commands to generate.