aboutsummaryrefslogtreecommitdiff
path: root/gdb/selftest-arch.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2017-09-22 17:00:33 -0300
committerAlexandre Oliva <aoliva@redhat.com>2017-09-22 17:00:33 -0300
commit9e0703de64a6dd4deae2ebd569955f14337f2710 (patch)
treecec45139f1febef6441deabae142c3fb3f2c61f3 /gdb/selftest-arch.c
parent13b9f79a1904081d984a64037af6457c1e3ff7b6 (diff)
parent43573013c9836f2b91b74b9b29dac35fdb41e06b (diff)
downloadgdb-9e0703de64a6dd4deae2ebd569955f14337f2710.zip
gdb-9e0703de64a6dd4deae2ebd569955f14337f2710.tar.gz
gdb-9e0703de64a6dd4deae2ebd569955f14337f2710.tar.bz2
Merge remote-tracking branch 'remotes/master' into users/aoliva/SFN
Updated local changes to binutils/testsuite/binutils-all/readelf.exp to match the unresolved (failed to assemble) messages introduced by Alan Modra.
Diffstat (limited to 'gdb/selftest-arch.c')
-rw-r--r--gdb/selftest-arch.c145
1 files changed, 73 insertions, 72 deletions
diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c
index c4fe60d..1ddc663 100644
--- a/gdb/selftest-arch.c
+++ b/gdb/selftest-arch.c
@@ -23,84 +23,85 @@
#include "selftest-arch.h"
#include "arch-utils.h"
-static std::vector<self_test_foreach_arch_function *> gdbarch_tests;
+namespace selftests {
-void
-register_self_test_foreach_arch (self_test_foreach_arch_function *function)
-{
- gdbarch_tests.push_back (function);
-}
+/* A kind of selftest that calls the test function once for each gdbarch known
+ to GDB. */
-namespace selftests {
+struct gdbarch_selftest : public selftest
+{
+ gdbarch_selftest (self_test_foreach_arch_function *function_)
+ : function (function_)
+ {}
+
+ void operator() () const override
+ {
+ const char **arches = gdbarch_printable_names ();
+ bool pass = true;
+
+ for (int i = 0; arches[i] != NULL; i++)
+ {
+ if (strcmp ("fr300", arches[i]) == 0)
+ {
+ /* PR 20946 */
+ continue;
+ }
+ else if (strcmp ("powerpc:EC603e", arches[i]) == 0
+ || strcmp ("powerpc:e500mc", arches[i]) == 0
+ || strcmp ("powerpc:e500mc64", arches[i]) == 0
+ || strcmp ("powerpc:titan", arches[i]) == 0
+ || strcmp ("powerpc:vle", arches[i]) == 0
+ || strcmp ("powerpc:e5500", arches[i]) == 0
+ || strcmp ("powerpc:e6500", arches[i]) == 0)
+ {
+ /* PR 19797 */
+ continue;
+ }
+
+ QUIT;
+
+ TRY
+ {
+ struct gdbarch_info info;
+
+ gdbarch_info_init (&info);
+ info.bfd_arch_info = bfd_scan_arch (arches[i]);
+
+ struct gdbarch *gdbarch = gdbarch_find_by_info (info);
+ SELF_CHECK (gdbarch != NULL);
+
+ function (gdbarch);
+ }
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ pass = false;
+ exception_fprintf (gdb_stderr, ex,
+ _("Self test failed: arch %s: "), arches[i]);
+ }
+ END_CATCH
+
+ reset ();
+ }
+
+ SELF_CHECK (pass);
+ }
+
+ self_test_foreach_arch_function *function;
+};
-static void
-tests_with_arch ()
+void
+register_test_foreach_arch (const std::string &name,
+ self_test_foreach_arch_function *function)
{
- int failed = 0;
-
- for (const auto &f : gdbarch_tests)
- {
- const char **arches = gdbarch_printable_names ();
-
- for (int i = 0; arches[i] != NULL; i++)
- {
- if (strcmp ("fr300", arches[i]) == 0)
- {
- /* PR 20946 */
- continue;
- }
- else if (strcmp ("powerpc:EC603e", arches[i]) == 0
- || strcmp ("powerpc:e500mc", arches[i]) == 0
- || strcmp ("powerpc:e500mc64", arches[i]) == 0
- || strcmp ("powerpc:titan", arches[i]) == 0
- || strcmp ("powerpc:vle", arches[i]) == 0
- || strcmp ("powerpc:e5500", arches[i]) == 0
- || strcmp ("powerpc:e6500", arches[i]) == 0)
- {
- /* PR 19797 */
- continue;
- }
-
- QUIT;
-
- TRY
- {
- struct gdbarch_info info;
-
- gdbarch_info_init (&info);
- info.bfd_arch_info = bfd_scan_arch (arches[i]);
-
- struct gdbarch *gdbarch = gdbarch_find_by_info (info);
- SELF_CHECK (gdbarch != NULL);
- f (gdbarch);
- }
- CATCH (ex, RETURN_MASK_ERROR)
- {
- ++failed;
- exception_fprintf (gdb_stderr, ex,
- _("Self test failed: arch %s: "), arches[i]);
- }
- END_CATCH
-
- /* Clear GDB internal state. */
- registers_changed ();
- reinit_frame_cache ();
- }
- }
-
- SELF_CHECK (failed == 0);
+ register_test (name, new gdbarch_selftest (function));
}
-} // namespace selftests
-#endif /* GDB_SELF_TEST */
-
-/* Suppress warning from -Wmissing-prototypes. */
-extern initialize_file_ftype _initialize_selftests_foreach_arch;
-
void
-_initialize_selftests_foreach_arch ()
+reset ()
{
-#if GDB_SELF_TEST
- register_self_test (selftests::tests_with_arch);
-#endif
+ /* Clear GDB internal state. */
+ registers_changed ();
+ reinit_frame_cache ();
}
+} // namespace selftests
+#endif /* GDB_SELF_TEST */