diff options
author | Lancelot SIX <lancelot.six@amd.com> | 2022-03-22 10:02:54 -0400 |
---|---|---|
committer | Lancelot SIX <lancelot.six@amd.com> | 2022-04-19 09:12:42 +0100 |
commit | 531c82a1c724079f98a4b069584681bc66da4dae (patch) | |
tree | b6c5c75bac8fa56639c689ac3eeed1cf180cc994 /gdb/selftest-arch.h | |
parent | 9a0f7f634e8eb98a8b2ff48eb68f90fefed83ac1 (diff) | |
download | fsf-binutils-gdb-531c82a1c724079f98a4b069584681bc66da4dae.zip fsf-binutils-gdb-531c82a1c724079f98a4b069584681bc66da4dae.tar.gz fsf-binutils-gdb-531c82a1c724079f98a4b069584681bc66da4dae.tar.bz2 |
gdb/selftest-arch: Make register_test_foreach_arch generate arch tests lazily
The register_test_foreach_arch is used to instantiate a given selftest
for all architectures supported by GDB. It is used in many _initialize_*
functions (under initialize_all_files, called by gdb_init).
Because the call is done during GDB's initialization, and because there
is no guaranty about the order in which all the _initialize_* functions
are executed, when register_test_foreach_arch is called, GDB is not
fully initialized. Specifically, when a particular initialize function
is executed, only the architectures registered at that point are listed
by gdbarch_printable_names.
As a consequence, the list of selftest effectively executed depends on
the order the _initialize_* functions are called. This can be observed
with the following:
$ ./gdb/gdb \
-data-directory ./gdb/data-directory \
-quiet -batch -ex "maint selftest" 2>&1 \
| grep -E "Ran [0-9]+ unit tests"
Ran 145 unit tests, 0 failed
$ GDB_REVERSE_INIT_FUNCTIONS=1 ./gdb/gdb \
-data-directory ./gdb/data-directory \
-quiet -batch -ex "maint selftest" 2>&1 \
| grep -E "Ran [0-9]+ unit tests"
Ran 82 unit tests, 0 failed
To fix this, make register_test_foreach_arch register a lazy selftest
generator. This way when the test generator is eventually executed, all
architectures are registered and we do not have a dependency on the
order the initialize functions are executed in.
Tested on x86_64-linux
Change-Id: I88eefebf7d372ad672f42d3a103e89354bc8a925
Diffstat (limited to 'gdb/selftest-arch.h')
-rw-r--r-- | gdb/selftest-arch.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/selftest-arch.h b/gdb/selftest-arch.h index f359e4a..6bdef26 100644 --- a/gdb/selftest-arch.h +++ b/gdb/selftest-arch.h @@ -23,6 +23,9 @@ typedef void self_test_foreach_arch_function (struct gdbarch *); namespace selftests { + +/* Register a selftest running FUNCTION for each arch supported by GDB. */ + extern void register_test_foreach_arch (const std::string &name, self_test_foreach_arch_function *function); |