mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
[gdb/testsuite] Register test for each arch separately in register_test_foreach_arch
In gdb/disasm-selftests.c we have: ... selftests::register_test_foreach_arch ("print_one_insn", selftests::print_one_insn_test); ... and we get: ... $ gdb -q -batch -ex "maint selftest print_one_insn" 2>&1 \ | grep ^Running Running selftest print_one_insn. $ ... Change the semantics register_test_foreach_arch such that a version of print_one_insn is registered for each architecture, such that we have: ... $ gdb -q -batch -ex "maint selftest print_one_insn" 2>&1 \ | grep ^Running Running selftest print_one_insn::A6. Running selftest print_one_insn::A7. Running selftest print_one_insn::ARC600. ... $ ... This makes it f.i. possible to do: ... $ gdb -q -batch a.out -ex "maint selftest print_one_insn::armv8.1-m.main" Running selftest print_one_insn::armv8.1-m.main. Self test failed: self-test failed at src/gdb/disasm-selftests.c:165 Ran 1 unit tests, 1 failed ... Tested on x86_64-linux with an --enable-targets=all build.
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#if GDB_SELF_TEST
|
#if GDB_SELF_TEST
|
||||||
#include "gdbsupport/selftest.h"
|
#include "gdbsupport/selftest.h"
|
||||||
@ -25,73 +26,57 @@
|
|||||||
|
|
||||||
namespace selftests {
|
namespace selftests {
|
||||||
|
|
||||||
/* A kind of selftest that calls the test function once for each gdbarch known
|
static bool skip_arch (const char *arch)
|
||||||
to GDB. */
|
|
||||||
|
|
||||||
struct gdbarch_selftest : public selftest
|
|
||||||
{
|
{
|
||||||
gdbarch_selftest (self_test_foreach_arch_function *function_)
|
if (strcmp ("fr300", arch) == 0)
|
||||||
: function (function_)
|
{
|
||||||
{}
|
/* PR 20946 */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void operator() () const override
|
if (strcmp ("powerpc:EC603e", arch) == 0
|
||||||
{
|
|| strcmp ("powerpc:e500mc", arch) == 0
|
||||||
std::vector<const char *> arches = gdbarch_printable_names ();
|
|| strcmp ("powerpc:e500mc64", arch) == 0
|
||||||
bool pass = true;
|
|| strcmp ("powerpc:titan", arch) == 0
|
||||||
|
|| strcmp ("powerpc:vle", arch) == 0
|
||||||
|
|| strcmp ("powerpc:e5500", arch) == 0
|
||||||
|
|| strcmp ("powerpc:e6500", arch) == 0)
|
||||||
|
{
|
||||||
|
/* PR 19797 */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for (const char *arch : arches)
|
return false;
|
||||||
{
|
}
|
||||||
if (strcmp ("fr300", arch) == 0)
|
|
||||||
{
|
|
||||||
/* PR 20946 */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (strcmp ("powerpc:EC603e", arch) == 0
|
|
||||||
|| strcmp ("powerpc:e500mc", arch) == 0
|
|
||||||
|| strcmp ("powerpc:e500mc64", arch) == 0
|
|
||||||
|| strcmp ("powerpc:titan", arch) == 0
|
|
||||||
|| strcmp ("powerpc:vle", arch) == 0
|
|
||||||
|| strcmp ("powerpc:e5500", arch) == 0
|
|
||||||
|| strcmp ("powerpc:e6500", arch) == 0)
|
|
||||||
{
|
|
||||||
/* PR 19797 */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUIT;
|
/* Register a kind of selftest that calls the test function once for each
|
||||||
|
gdbarch known to GDB. */
|
||||||
try
|
|
||||||
{
|
|
||||||
struct gdbarch_info info;
|
|
||||||
|
|
||||||
info.bfd_arch_info = bfd_scan_arch (arch);
|
|
||||||
|
|
||||||
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
|
|
||||||
SELF_CHECK (gdbarch != NULL);
|
|
||||||
|
|
||||||
function (gdbarch);
|
|
||||||
}
|
|
||||||
catch (const gdb_exception_error &ex)
|
|
||||||
{
|
|
||||||
pass = false;
|
|
||||||
exception_fprintf (gdb_stderr, ex,
|
|
||||||
_("Self test failed: arch %s: "), arch);
|
|
||||||
}
|
|
||||||
|
|
||||||
reset ();
|
|
||||||
}
|
|
||||||
|
|
||||||
SELF_CHECK (pass);
|
|
||||||
}
|
|
||||||
|
|
||||||
self_test_foreach_arch_function *function;
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
register_test_foreach_arch (const std::string &name,
|
register_test_foreach_arch (const std::string &name,
|
||||||
self_test_foreach_arch_function *function)
|
self_test_foreach_arch_function *function)
|
||||||
{
|
{
|
||||||
register_test (name, new gdbarch_selftest (function));
|
std::vector<const char *> arches = gdbarch_printable_names ();
|
||||||
|
for (const char *arch : arches)
|
||||||
|
{
|
||||||
|
if (skip_arch (arch))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto test_fn
|
||||||
|
= ([=] ()
|
||||||
|
{
|
||||||
|
struct gdbarch_info info;
|
||||||
|
info.bfd_arch_info = bfd_scan_arch (arch);
|
||||||
|
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
|
||||||
|
SELF_CHECK (gdbarch != NULL);
|
||||||
|
function (gdbarch);
|
||||||
|
reset ();
|
||||||
|
});
|
||||||
|
|
||||||
|
std::string test_name
|
||||||
|
= name + std::string ("::") + std::string (arch);
|
||||||
|
register_test (test_name, test_fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user