aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/selftest.cc
AgeCommit message (Collapse)AuthorFilesLines
2022-04-19gdbsupport/selftest: Allow lazy registrationLancelot SIX1-0/+21
This patch adds a way to delay the registration of tests until the latest possible moment. This is intended for situations where GDB needs to be fully initialized in order to decide if a particular selftest can be executed or not. This mechanism will be used in the next patch. Change-Id: I7f6b061f4c0a6832226c7080ab4e3a2523e1b0b0
2022-04-19gdbsupport/selftest: Replace for_each_selftest with an iterator_rangeLancelot SIX1-15/+12
Remove the callback-based selftests::for_each_selftest function and use an iterator_range instead. Also use this iterator range in run_tests so all iterations over the selftests are done in a consistent way. This will become useful in a later commit. Change-Id: I0b3a5349a7987fbcb0071f11c394e353df986583
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-10-19Always use std::function for self-testsTom Tromey1-31/+6
Now that there is a register_test variant that accepts std::function, it seems to me that the 'selftest' struct and accompanying code is obsolete -- simply always using std::function is simpler. This patch implements this idea.
2021-09-22[gdb] Add maint selftest -verbose optionTom de Vries1-1/+14
The print_one_insn selftest in gdb/disasm-selftests.c contains: ... /* If you want to see the disassembled instruction printed to gdb_stdout, set verbose to true. */ static const bool verbose = false; ... Make this parameter available in the maint selftest command using a new option -verbose, such that we can do: ... (gdb) maint selftest -verbose print_one_insn ... Tested on x86_64-linux.
2021-09-21[gdb] Change register_test to use std::function argTom de Vries1-18/+21
Change register_test to use std::function arg, such that we can do: ... register_test (test_name, [=] () { SELF_CHECK (...); }); ... Tested on x86_64-linux.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-08-13gdb: allow specifying multiple filters when running selftestsSimon Marchi1-3/+14
I found myself wanting to run a few specific selftests while developing. I thought it would be nice to be able to provide multiple test names when running `maintenant selftests`. The arguments to that command is currently interpreted as a single filter (not split by spaces), it now becomes a list a filters, split by spaces. A test is executed when it matches at least one filter. Here's an example of the result in GDB: (gdb) maintenance selftest xml Running selftest xml_escape_text. Running selftest xml_escape_text_append. Ran 2 unit tests, 0 failed (gdb) maintenance selftest xml unord Running selftest unordered_remove. Running selftest xml_escape_text. Running selftest xml_escape_text_append. Ran 3 unit tests, 0 failed (gdb) maintenance selftest xml unord foobar Running selftest unordered_remove. Running selftest xml_escape_text. Running selftest xml_escape_text_append. Ran 3 unit tests, 0 failed Since the selftest machinery is also shared with gdbserver, I also adapted gdbserver. It accepts a `--selftest` switch, which accepts an optional filter argument. I made it so you can now pass `--selftest` multiple time to add filters. It's not so useful right now though: there's only a single selftest right now in GDB and it's for an architecture I can't compile. So I tested by adding dummy tests, here's an example of the result: $ ./gdbserver --selftest=foo Running selftest foo. foo Running selftest foobar. foobar Ran 2 unit tests, 0 failed $ ./gdbserver --selftest=foo --selftest=bar Running selftest bar. bar Running selftest foo. foo Running selftest foobar. foobar Ran 3 unit tests, 0 failed gdbsupport/ChangeLog: * selftest.h (run_tests): Change parameter to array_view. * selftest.c (run_tests): Change parameter to array_view and use it. gdb/ChangeLog: * maint.c (maintenance_selftest): Split args and pass array_view to run_tests. gdbserver/ChangeLog: * server.cc (captured_main): Accept multiple `--selftest=` options. Pass all `--selftest=` arguments to run_tests. Change-Id: I422bd49f08ea8095ae174c5d66a2dd502a59613a
2020-02-13gdbsupport: rename source files to .ccSimon Marchi1-0/+111
This patch renames the .c source files in gdbsupport to .cc. In the gdb directory, there is an argument against renaming the source files, which is that it makes using some git commands more difficult to do archeology. Some commands have some kind of "follow" option that makes git try to follow renames, but it doesn't work in all situations. Given that we have just moved the gdbsupport directory, that argument doesn't hold for source files in that directory. I therefore suggest renaming them to .cc, so that they are automatically recognized as C++ by various tools and editors. The original motivation behind this is that when building gdbsupport with clang, I get: CC agent.o clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated] In the gdb/ directory, we make clang happy by passing "-x c++". We could do this in gdbsupport too, but I think that renaming the files is a better long-term solution. gdbserver still does its own build of gdbsupport, so a few changes in its Makefile are necessary. gdbsupport/ChangeLog: * Makefile.am: Rename source files from .c to .cc. (CC, CFLAGS): Don't override. (AM_CFLAGS): Rename to ... (AM_CXXFLAGS): ... this. * Makefile.in: Re-generate. * %.c: Rename to %.cc. gdbserver/ChangeLog: * Makefile.in: Rename gdbsupport source files from .c to .cc.