binutils-gdb/gdb/selftest-arch.c

107 lines
2.6 KiB
C
Raw Permalink Normal View History

/* GDB self-test for each gdbarch.
Copyright (C) 2017-2020 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#if GDB_SELF_TEST
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/selftest.h"
#include "selftest-arch.h"
#include "arch-utils.h"
namespace selftests {
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
/* A kind of selftest that calls the test function once for each gdbarch known
to GDB. */
struct gdbarch_selftest : public selftest
{
gdbarch_selftest (self_test_foreach_arch_function *function_)
: function (function_)
{}
void operator() () const override
{
const char **arches = gdbarch_printable_names ();
bool pass = true;
for (int i = 0; arches[i] != NULL; i++)
{
if (strcmp ("fr300", arches[i]) == 0)
{
/* PR 20946 */
continue;
}
else if (strcmp ("powerpc:EC603e", arches[i]) == 0
|| strcmp ("powerpc:e500mc", arches[i]) == 0
|| strcmp ("powerpc:e500mc64", arches[i]) == 0
|| strcmp ("powerpc:titan", arches[i]) == 0
|| strcmp ("powerpc:vle", arches[i]) == 0
|| strcmp ("powerpc:e5500", arches[i]) == 0
|| strcmp ("powerpc:e6500", arches[i]) == 0)
{
/* PR 19797 */
continue;
}
QUIT;
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
{
struct gdbarch_info info;
gdbarch_info_init (&info);
info.bfd_arch_info = bfd_scan_arch (arches[i]);
struct gdbarch *gdbarch = gdbarch_find_by_info (info);
SELF_CHECK (gdbarch != NULL);
function (gdbarch);
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &ex)
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
{
pass = false;
exception_fprintf (gdb_stderr, ex,
_("Self test failed: arch %s: "), arches[i]);
}
reset ();
}
SELF_CHECK (pass);
}
self_test_foreach_arch_function *function;
};
void
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
register_test_foreach_arch (const std::string &name,
self_test_foreach_arch_function *function)
{
Add selftests run filtering With the growing number of selftests, I think it would be useful to be able to run only a subset of the tests. This patch associates a name to each registered selftest. It then allows doing something like: (gdb) maintenance selftest aarch64 Running self-tests. Running selftest aarch64-analyze-prologue. Running selftest aarch64-process-record. Ran 2 unit tests, 0 failed or with gdbserver: ./gdbserver --selftest=aarch64 In both cases, only the tests that contain "aarch64" in their name are ran. To help validate that the tests you want to run were actually ran, it also prints a message with the test name before running each test. Right now, all the arch-dependent tests are registered as a single test of the selftests. To be able to filter those too, I made them "first-class citizen" selftests. The selftest type is an interface, with different implementations for "simple selftests" and "arch selftests". The run_tests function simply iterates on that an invokes operator() on each test. I changed the tests data structure from a vector to a map, because - it allows iterating in a stable (alphabetical) order - it allows to easily verify if a test with a given name has been registered, to avoid duplicates There's also a new command "maintenance info selftests" that lists the registered selftests. gdb/ChangeLog: * common/selftest.h (selftest): New struct/interface. (register_test): Add name parameter, add new overload. (run_tests): Add filter parameter. (for_each_selftest_ftype): New typedef. (for_each_selftest): New declaration. * common/selftest.c (tests): Change type to map<string, unique_ptr<selftest>>. (simple_selftest): New struct. (register_test): New function. (register_test): Add name parameter and use it. (run_tests): Add filter parameter and use it. Add prints. Adjust to vector -> map change. * aarch64-tdep.c (_initialize_aarch64_tdep): Add names when registering selftests. * arm-tdep.c (_initialize_arm_tdep): Likewise. * disasm-selftests.c (_initialize_disasm_selftests): Likewise. * dwarf2-frame.c (_initialize_dwarf2_frame): Likewise. * dwarf2loc.c (_initialize_dwarf2loc): Likewise. * findvar.c (_initialize_findvar): Likewise. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Likewise. * maint.c (maintenance_selftest): Update call to run_tests. (maintenance_info_selftests): New function. (_initialize_maint_cmds): Register "maintenance info selftests" command. Update "maintenance selftest" doc. * regcache.c (_initialize_regcache): Add names when registering selftests. * rust-exp.y (_initialize_rust_exp): Likewise. * selftest-arch.c (gdbarch_selftest): New struct. (gdbarch_tests): Remove. (register_test_foreach_arch): Add name parameter. Call register_test. (tests_with_arch): Remove, move most content to gdbarch_selftest::operator(). (_initialize_selftests_foreach_arch): Remove. * selftest-arch.h (register_test_foreach_arch): Add name parameter. (run_tests_with_arch): New declaration. * utils-selftests.c (_initialize_utils_selftests): Add names when registering selftests. * utils.c (_initialize_utils): Likewise. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Likewise. * unittests/environ-selftests.c (_initialize_environ_selftests): Likewise. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Likewise. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Likewise. * unittests/optional-selftests.c (_initialize_optional_selftests): Likewise. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Likewise. * NEWS: Document "maintenance selftest" and "maint info selftests". gdb/gdbserver/ChangeLog: * server.c (captured_main): Accept argument for --selftest. Update run_tests call. * linux-x86-tdesc-selftest.c (initialize_low_tdesc): Add names when registering selftests. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document filter parameter of "maint selftest". Document "maint info selftests" command.
2017-09-16 14:06:03 +02:00
register_test (name, new gdbarch_selftest (function));
}
void
reset ()
{
/* Clear GDB internal state. */
registers_changed ();
reinit_frame_cache ();
}
} // namespace selftests
#endif /* GDB_SELF_TEST */