From 38015f6710d67d700f34cfecc6d9fe5ae6241252 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 6 Jun 2022 19:27:46 +0200 Subject: [PATCH] [gdb] Name arch selftests more clearly When running some all archs selftest I get: ... $ gdb -q -batch -ex "maint selftest unpack_field_as_long" Running selftest unpack_field_as_long::A6. ... By now I know that A6 is an arc architecture, but for others that's less clear. Fix this by using unpack_field_as_long::arc::A6 instead. This then introduces redundant names like arm::arm, so try to avoid those, though I'm not entirely convinced that that's worth the trouble. This introduces the following new names: ... +Running selftest unpack_field_as_long::am33_2::am33-2. +Running selftest unpack_field_as_long::arc::A6. +Running selftest unpack_field_as_long::arc::A7. +Running selftest unpack_field_as_long::arc::EM. +Running selftest unpack_field_as_long::arc::HS. +Running selftest unpack_field_as_long::arm::ep9312. +Running selftest unpack_field_as_long::arm::iwmmxt. +Running selftest unpack_field_as_long::arm::iwmmxt2. +Running selftest unpack_field_as_long::arm::xscale. +Running selftest unpack_field_as_long::bpf::xbpf. +Running selftest unpack_field_as_long::frv::fr400. +Running selftest unpack_field_as_long::frv::fr450. +Running selftest unpack_field_as_long::frv::fr500. +Running selftest unpack_field_as_long::frv::fr550. +Running selftest unpack_field_as_long::frv::simple. +Running selftest unpack_field_as_long::frv::tomcat. +Running selftest unpack_field_as_long::iq2000::iq10. +Running selftest unpack_field_as_long::m32c::m16c. +Running selftest unpack_field_as_long::mep::c5. +Running selftest unpack_field_as_long::mep::h1. +Running selftest unpack_field_as_long::nds32::n1. +Running selftest unpack_field_as_long::nds32::n1h. +Running selftest unpack_field_as_long::nds32::n1h_v2. +Running selftest unpack_field_as_long::nds32::n1h_v3. +Running selftest unpack_field_as_long::nds32::n1h_v3m. +Running selftest unpack_field_as_long::z80::ez80-adl. +Running selftest unpack_field_as_long::z80::ez80-z80. +Running selftest unpack_field_as_long::z80::gbz80. +Running selftest unpack_field_as_long::z80::r800. +Running selftest unpack_field_as_long::z80::z180. ... Tested on x86_64-linux. --- gdb/selftest-arch.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c index 1fe0b2d59b4..33d7875c120 100644 --- a/gdb/selftest-arch.c +++ b/gdb/selftest-arch.c @@ -63,20 +63,37 @@ foreach_arch_test_generator (const std::string &name, if (skip_arch (arch)) continue; + struct gdbarch_info info; + info.bfd_arch_info = bfd_scan_arch (arch); + info.osabi = GDB_OSABI_NONE; + auto test_fn = ([=] () { - struct gdbarch_info info; - info.bfd_arch_info = bfd_scan_arch (arch); - info.osabi = GDB_OSABI_NONE; struct gdbarch *gdbarch = gdbarch_find_by_info (info); SELF_CHECK (gdbarch != NULL); function (gdbarch); reset (); }); - tests.emplace_back (string_printf ("%s::%s", name.c_str (), arch), - test_fn); + std::string id; + + bool has_sep = strchr (arch, ':') != nullptr; + if (has_sep) + /* Avoid avr::avr:1. */ + id = arch; + else if (strncasecmp (info.bfd_arch_info->arch_name, arch, + strlen (info.bfd_arch_info->arch_name)) == 0) + /* Avoid arm::arm. */ + id = arch; + else + /* Use arc::A6 instead of A6. This still leaves us with an unfortunate + redundant id like am33_2::am33-2, but that doesn't seem worth the + effort to avoid. */ + id = string_printf ("%s::%s", info.bfd_arch_info->arch_name, arch); + + id = string_printf ("%s::%s", name.c_str (), id.c_str ()); + tests.emplace_back (id, test_fn); } return tests; } -- 2.30.2