aboutsummaryrefslogtreecommitdiff
path: root/gdb/maint.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-09-23 09:56:51 -0400
committerSimon Marchi <simon.marchi@efficios.com>2021-10-28 11:17:45 -0400
commitc0492bea7ca33fafc280f08f4ed9f505d29e7130 (patch)
tree573f368c19b8c952d10b85deb697296d0822a263 /gdb/maint.c
parent8c2999954bd3aa5853f553eb6a050dd38e6d9029 (diff)
downloadgdb-c0492bea7ca33fafc280f08f4ed9f505d29e7130.zip
gdb-c0492bea7ca33fafc280f08f4ed9f505d29e7130.tar.gz
gdb-c0492bea7ca33fafc280f08f4ed9f505d29e7130.tar.bz2
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
Diffstat (limited to 'gdb/maint.c')
-rw-r--r--gdb/maint.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gdb/maint.c b/gdb/maint.c
index 4e75e47..85fa18c 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -1176,8 +1176,15 @@ maintenance_selftest_completer (cmd_list_element *cmd,
{
auto grp = make_maintenance_selftest_option_group (nullptr);
- gdb::option::complete_options
- (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp))
+ return;
+
+ selftests::for_each_selftest ([&tracker, text] (const std::string &name)
+ {
+ if (startswith (name.c_str (), text))
+ tracker.add_completion (make_unique_xstrdup (name.c_str ()));
+ });
}
static void