]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Skip selftest with warning
authorTom de Vries <tdevries@suse.de>
Sun, 30 Mar 2025 06:40:12 +0000 (08:40 +0200)
committerTom de Vries <tdevries@suse.de>
Sun, 30 Mar 2025 06:40:12 +0000 (08:40 +0200)
With the selftest register_name, we run into a few warning:
...
$ gdb -q -batch -ex "maint selftest register_name" 2>&1 \
    | grep -B1 warning:
Running selftest register_name::m68hc11.
warning: No frame soft register found in the symbol table.
--
Running selftest register_name::m68hc12.
warning: No frame soft register found in the symbol table.
--
Running selftest register_name::m68hc12:HCS12.
warning: No frame soft register found in the symbol table.
...

We already filter out these architectures in other selftests because of the
same warning.

Do the same in this selftest.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/gdbarch-selftests.c
gdb/regcache.c
gdb/selftest-arch.c
gdb/selftest-arch.h

index 27b17d172a60aa75b29041ae7a0ff770d3d4a8fe..8f42557a6c9e5c528e5c26c4fba7cfd15eb2eb62 100644 (file)
@@ -127,6 +127,9 @@ register_to_value_test (struct gdbarch *gdbarch)
 static void
 register_name_test (struct gdbarch *gdbarch)
 {
+  if (selftest_skip_warning_arch (gdbarch))
+    return;
+
   scoped_mock_context<test_target_ops> mockctx (gdbarch);
 
   /* Track the number of times each register name appears.  */
index 55087782bacf77fa515206cbae73a45d9ca6de61..ad72429ae79bc480e809a4847e8e7f7ca07aef4a 100644 (file)
@@ -1911,32 +1911,13 @@ public:
   {}
 };
 
-/* Return true if regcache::cooked_{read,write}_test should be skipped for
-   GDBARCH.  */
-
-static bool
-selftest_skiparch (struct gdbarch *gdbarch)
-{
-  const char *name = gdbarch_bfd_arch_info (gdbarch)->printable_name;
-
-  /* Avoid warning:
-       Running selftest regcache::cooked_{read,write}_test::m68hc11.
-       warning: No frame soft register found in the symbol table.
-       Stack backtrace will not work.
-     We could instead capture the output and then filter out the warning, but
-     that seems more trouble than it's worth.  */
-  return (strcmp (name, "m68hc11") == 0
-         || strcmp (name, "m68hc12") == 0
-         || strcmp (name, "m68hc12:HCS12") == 0);
-}
-
 /* Test regcache::cooked_read gets registers from raw registers and
    memory instead of target to_{fetch,store}_registers.  */
 
 static void
 cooked_read_test (struct gdbarch *gdbarch)
 {
-  if (selftest_skiparch (gdbarch))
+  if (selftest_skip_warning_arch (gdbarch))
     return;
 
   scoped_mock_context<target_ops_no_register> mockctx (gdbarch);
@@ -2074,7 +2055,7 @@ cooked_read_test (struct gdbarch *gdbarch)
 static void
 cooked_write_test (struct gdbarch *gdbarch)
 {
-  if (selftest_skiparch (gdbarch))
+  if (selftest_skip_warning_arch (gdbarch))
     return;
 
   /* Create a mock environment.  A process_stratum target pushed.  */
index 17eeba843e97e66cb392a78d487f131759c61d88..79889c050b392a41a1b10e37223ce0808e85c7d2 100644 (file)
@@ -108,5 +108,24 @@ reset ()
   registers_changed ();
   reinit_frame_cache ();
 }
+
+/* See selftest-arch.h.  */
+
+bool
+selftest_skip_warning_arch (struct gdbarch *gdbarch)
+{
+  const char *name = gdbarch_bfd_arch_info (gdbarch)->printable_name;
+
+  /* Avoid warning:
+       Running selftest <test>::m68hc11.
+       warning: No frame soft register found in the symbol table.
+       Stack backtrace will not work.
+     We could instead capture the output and then filter out the warning, but
+     that seems more trouble than it's worth.  */
+  return (strcmp (name, "m68hc11") == 0
+         || strcmp (name, "m68hc12") == 0
+         || strcmp (name, "m68hc12:HCS12") == 0);
+}
+
 } /* namespace selftests */
 #endif /* GDB_SELF_TEST */
index db11723395e726f284ff05b8310471a1acbdc776..c6a85fa837bca3f8dce3a39006ad7d274d2493b7 100644 (file)
@@ -29,6 +29,11 @@ namespace selftests
 extern void
   register_test_foreach_arch (const std::string &name,
                              self_test_foreach_arch_function *function);
+
+/* Return true if GDBARCH should be skipped in some selftests to avoid
+   warnings.  */
+
+extern bool selftest_skip_warning_arch (struct gdbarch *gdbarch);
 }
 
 #endif /* GDB_SELFTEST_ARCH_H */