[PATCH 13/18] Implement completion limiting for complete_on_enum.
Keith Seitz
keiths@redhat.com
Mon Apr 13 19:23:00 GMT 2015
This is another patch to push along the conversion of location_completer
toward using maybe_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 maybe_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 | 19 ++++++++++++++++++-
gdb/testsuite/gdb.base/completion.exp | 12 ++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 21f4c45..04eb437 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1866,6 +1866,7 @@ complete_on_enum (struct completer_data *cdata,
if (strncmp (name, text, textlen) == 0)
{
char *match;
+ enum maybe_add_completion_enum add_status;
match = (char *) xmalloc (strlen (word) + strlen (name) + 1);
if (word == text)
@@ -1882,7 +1883,23 @@ complete_on_enum (struct completer_data *cdata,
match[text - word] = '\0';
strcat (match, name);
}
- VEC_safe_push (char_ptr, matchlist, match);
+
+ add_status = maybe_add_completion (cdata, match);
+ switch (add_status)
+ {
+ case MAYBE_ADD_COMPLETION_OK:
+ VEC_safe_push (char_ptr, matchlist, match);
+ break;
+ case MAYBE_ADD_COMPLETION_OK_MAX_REACHED:
+ VEC_safe_push (char_ptr, matchlist, match);
+ return matchlist;
+ case MAYBE_ADD_COMPLETION_MAX_REACHED:
+ xfree (match);
+ return matchlist;
+ case MAYBE_ADD_COMPLETION_DUPLICATE:
+ xfree (match);
+ 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
+}
More information about the Gdb-patches
mailing list