1 /* GDB self-test for each gdbarch.
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
23 #include "gdbsupport/selftest.h"
24 #include "selftest-arch.h"
25 #include "arch-utils.h"
29 static bool skip_arch (const char *arch
)
31 if (strcmp ("fr300", arch
) == 0)
37 if (strcmp ("powerpc:EC603e", arch
) == 0
38 || strcmp ("powerpc:e500mc", arch
) == 0
39 || strcmp ("powerpc:e500mc64", arch
) == 0
40 || strcmp ("powerpc:titan", arch
) == 0
41 || strcmp ("powerpc:vle", arch
) == 0
42 || strcmp ("powerpc:e5500", arch
) == 0
43 || strcmp ("powerpc:e6500", arch
) == 0)
52 /* Generate a selftest for each gdbarch known to GDB. */
54 static std::vector
<selftest
>
55 foreach_arch_test_generator (const std::string
&name
,
56 self_test_foreach_arch_function
*function
)
58 std::vector
<selftest
> tests
;
59 std::vector
<const char *> arches
= gdbarch_printable_names ();
60 tests
.reserve (arches
.size ());
61 for (const char *arch
: arches
)
69 /* Prevent warnings when setting architecture with current osabi
71 A handler for the OS ABI "GNU/Linux" is not built into this
72 configuration of GDB. Attempting to continue with the
73 default aarch64:ilp32 settings. */
74 enum gdb_osabi_mode mode
;
76 get_osabi (mode
, osabi
);
78 set_osabi (osabi_user
, GDB_OSABI_NONE
);
82 set_osabi (mode
, osabi
);
85 struct gdbarch_info info
;
86 info
.bfd_arch_info
= bfd_scan_arch (arch
);
87 struct gdbarch
*gdbarch
= gdbarch_find_by_info (info
);
88 SELF_CHECK (gdbarch
!= NULL
);
93 tests
.emplace_back (string_printf ("%s::%s", name
.c_str (), arch
),
99 /* See selftest-arch.h. */
102 register_test_foreach_arch (const std::string
&name
,
103 self_test_foreach_arch_function
*function
)
105 add_lazy_generator ([=] ()
107 return foreach_arch_test_generator (name
, function
);
114 /* Clear GDB internal state. */
115 registers_changed ();
116 reinit_frame_cache ();
118 } // namespace selftests
119 #endif /* GDB_SELF_TEST */