diff options
author | Tom de Vries <tdevries@suse.de> | 2025-03-30 08:40:12 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-03-30 08:40:12 +0200 |
commit | 79580fac6f582027aa3d51952728e34391c7d6be (patch) | |
tree | 13a6b1caa5781627b359014276eea96babde3156 | |
parent | 33e4d4fe62afacdd27b47cf27d3d5ce77210a817 (diff) | |
download | gdb-master.zip gdb-master.tar.gz gdb-master.tar.bz2 |
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>
-rw-r--r-- | gdb/gdbarch-selftests.c | 3 | ||||
-rw-r--r-- | gdb/regcache.c | 23 | ||||
-rw-r--r-- | gdb/selftest-arch.c | 19 | ||||
-rw-r--r-- | gdb/selftest-arch.h | 5 |
4 files changed, 29 insertions, 21 deletions
diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c index 27b17d17..8f42557 100644 --- a/gdb/gdbarch-selftests.c +++ b/gdb/gdbarch-selftests.c @@ -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. */ diff --git a/gdb/regcache.c b/gdb/regcache.c index 5508778..ad72429 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -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. */ diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c index 17eeba8..79889c0 100644 --- a/gdb/selftest-arch.c +++ b/gdb/selftest-arch.c @@ -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 */ diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h index db11723..c6a85fa 100644 --- a/gdb/selftest-arch.h +++ b/gdb/selftest-arch.h @@ -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 */ |