gdb: add selftest name completion

After the previous commit, it is easy to add completion for selftest
names.  Again, this is not particularly high value, but I rarely touched
completion, so it served as a simple example to get some practice.

Change the for_each_selftest_ftype parameter to gdb::function_view, so
that we can pass a lambda that captures things.

Change-Id: I87cac299ddca9ca7eb0ffab78342e850a98d954c
This commit is contained in:
Simon Marchi
2021-09-23 09:56:51 -04:00
committed by Simon Marchi
parent 8c2999954b
commit c0492bea7c
3 changed files with 27 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
#define COMMON_SELFTEST_H
#include "gdbsupport/array-view.h"
#include "gdbsupport/function-view.h"
/* A test is just a function that does some checks and throws an
exception if something has gone wrong. */
@@ -48,7 +49,8 @@ extern void run_tests (gdb::array_view<const char *const> filters,
/* Reset GDB or GDBserver's internal state. */
extern void reset ();
typedef void for_each_selftest_ftype (const std::string &name);
using for_each_selftest_ftype
= gdb::function_view<void(const std::string &name)>;
/* Call FUNC for each registered selftest. */