This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 08/19] Implement completion limiting for signal_completer.
- From: Keith Seitz <keiths at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 06 Aug 2015 12:17:53 -0700
- Subject: [PATCH v3 08/19] Implement completion limiting for signal_completer.
- Authentication-results: sourceware.org; auth=none
- References: <20150806191404 dot 32159 dot 50755 dot stgit at valrhona dot uglyboxes dot com>
There are no revisions in this version.
---
This patch converts signal_completer to use add_completion
and adds some tests to cover this new behavior.
gdb/ChangeLog
* completer.c (signal_completer): Use add_completion.
gdb/testsuite/ChangeLog
* gdb.base/completion.exp: Add completion limiting tests
for "handle signal".
---
gdb/completer.c | 6 +++++-
gdb/testsuite/gdb.base/completion.exp | 27 +++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/gdb/completer.c b/gdb/completer.c
index 6aa8d35..bf85efe 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1046,7 +1046,11 @@ signal_completer (struct completer_data *cdata,
continue;
if (strncasecmp (signame, word, len) == 0)
- VEC_safe_push (char_ptr, return_val, xstrdup (signame));
+ {
+ if (add_completion (cdata, &return_val, signame, NULL, NULL)
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
+ }
}
return return_val;
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index f0b7f2c..884b9f6 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -995,6 +995,33 @@ test_completion_limit "file ./gdb.base/jit-s" \
test_completion_limit "file ./gdb.a" "file \\\./gdb\\\.a(da|rch|sm)" \
$max_completions
+# Test completion limiting in signal_completer.
+with_test_prefix "signal_completer" {
+ gdb_test_no_output "set max-completions unlimited"
+ set num_signals 0
+ gdb_test_multiple "complete handle signal SIG10" "" {
+ "complete handle signal SIG10" { exp_continue }
+ -re "handle signal SIG10\[0-9\]\r\n" {
+ incr num_signals
+ exp_continue
+ }
+ -re "$gdb_prompt $" {
+ pass "count available signals"
+ }
+ }
+
+ gdb_test_no_output "set max-completions $max_completions"
+}
+
+if {$num_signals > $max_completions} {
+ test_completion_limit "handle signal SIG10" \
+ "handle signal SIG10\[0-9\]" $max_completions
+} else {
+ set msg "insufficient signals to test completion "
+ append msg "limiting in signal_handler ($num_signals)"
+ untested $msg
+}
+
#
# Test TUI completions
#