public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb] Name arch selftests more clearly
@ 2022-06-04  9:10 Tom de Vries
  2022-06-06 13:45 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2022-06-04  9:10 UTC (permalink / raw)
  To: gdb-patches

Hi,

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.

Any comments?

Thanks,
- Tom

[gdb] Name arch selftests more clearly

---
 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;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][gdb] Name arch selftests more clearly
  2022-06-04  9:10 [PATCH][gdb] Name arch selftests more clearly Tom de Vries
@ 2022-06-06 13:45 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-06-06 13:45 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> By now I know that A6 is an arc architecture, but for others that's less
Tom> clear.

Tom> Fix this by using unpack_field_as_long::arc::A6 instead.

Tom> This then introduces redundant names like arm::arm, so try to avoid those,
Tom> though I'm not entirely convinced that that's worth the trouble.

Looks reasonable to me.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-06 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04  9:10 [PATCH][gdb] Name arch selftests more clearly Tom de Vries
2022-06-06 13:45 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).