[PATCH 3/8] Disassembly unit test: disassemble one instruction

Pedro Alves palves@redhat.com
Thu Jan 12 13:06:00 GMT 2017


I'd much prefer if the core of the unit testing framework doesn't learn
about different random subsystems.  Consider what we'd do if we
wanted to reuse selftest.c in gdbserver.  I think we will at some point.

How about we move all this gdbarch stuff elsewhere, like
gdb/arch-utils.c or a new gdb/arch-selftests.c?

You'd then have,

- call the new function typedef "arch_self_test_function"

- in arch-selftests.c:

static std::vector<arch_self_test_function *> gdbarch_tests;

void
register_arch_self_test (arch_self_test_function *function)
{
  gdbarch_tests.push_back (function);
}

namespace selftests {

arch_tests ()
{
  for (const auto &f : gdbarch_tests)
    {
      const char **arches = gdbarch_printable_names ();
      int i;
   [...]
}

} /* namespace selftests */

void
_initialize_arch_selftests (void)
{
#if GDB_SELF_TEST
  register_self_test (selftests::arch_tests);
#endif
}

Thanks,
Pedro Alves



More information about the Binutils mailing list