This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 13/18] Implement completion limiting for complete_on_enum.
- From: Keith Seitz <keiths at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 04 May 2015 12:18:39 -0700
- Subject: [PATCH v2 13/18] Implement completion limiting for complete_on_enum.
- Authentication-results: sourceware.org; auth=none
- References: <20150504191734 dot 20434 dot 68053 dot stgit at valrhona dot uglyboxes dot com>
This is another patch to push along the conversion of location_completer
toward using add_completion. In this patch, complete_on_enum is
converted. This function is also used by several other commands, such as
integer_unlimited_completer, handle_completer, cp_abi_completer, etc.
gdb/ChangeLog
* cli/cli-decode.c (complete_on_enum): Use add_completion.
gdb/testsuite/ChangeLog
* gdb.base/completion.exp: Add tests for complete_on_enum
completion limiting using "handle signal".
---
gdb/cli/cli-decode.c | 5 ++++-
gdb/testsuite/gdb.base/completion.exp | 12 ++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 011c427..a09ad5c 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1868,7 +1868,10 @@ complete_on_enum (struct completer_data *cdata,
match[text - word] = '\0';
strcat (match, name);
}
- VEC_safe_push (char_ptr, matchlist, match);
+
+ if (add_completion (cdata, &matchlist, match)
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
}
return matchlist;
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 4a35cd1..516975c 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -1041,3 +1041,15 @@ with_test_prefix "interpreter_completer reset" {
# Test reg_or_group_completer.
test_completion_limit "info registers " \
"info registers \[a-zA-Z0-9\]+" $max_completions
+
+# Test complete_on_enum.
+set signal_to_use ""
+set signal_list [split \
+ [capture_command_output "complete handle signal " ""] \
+ \r\n]
+catch {lindex [split [lindex $signal_list 0]] 2} signal_to_use
+if {$signal_to_use != ""} {
+ test_completion_limit "handle signal $signal_to_use n" \
+ "handle signal $signal_to_use n\[a-z\]+" \
+ $max_completions
+}