Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 08/18] Implement completion limiting for signal_completer.
Date: Mon, 13 Apr 2015 19:23:00 -0000	[thread overview]
Message-ID: <20150413192321.29172.22932.stgit@valrhona.uglyboxes.com> (raw)
In-Reply-To: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com>

This patch converts signal_completer to use maybe_add_completion
and adds some tests to cover this new behavior.

gdb/ChangeLog

	* completer.c (signal_completer): Use maybe_add_completion.

gdb/testsuite/ChangeLog

	* gdb.base/completion.exp: Add completion limiting tests
	for "handle signal".
---
 gdb/completer.c                       |   22 +++++++++++++++++++++-
 gdb/testsuite/gdb.base/completion.exp |   27 +++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/gdb/completer.c b/gdb/completer.c
index 291ba73..3022d7e 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1009,7 +1009,27 @@ signal_completer (struct completer_data *cdata,
 	continue;
 
       if (strncasecmp (signame, word, len) == 0)
-	VEC_safe_push (char_ptr, return_val, xstrdup (signame));
+	{
+	  char *completion = xstrdup (signame);
+	  enum maybe_add_completion_enum add_status;
+
+	  add_status = maybe_add_completion (cdata, completion);
+	  switch (add_status)
+	    {
+	    case MAYBE_ADD_COMPLETION_OK:
+	      VEC_safe_push (char_ptr, return_val, completion);
+	      break;
+	    case MAYBE_ADD_COMPLETION_OK_MAX_REACHED:
+	      VEC_safe_push (char_ptr, return_val, completion);
+	      return return_val;
+	    case MAYBE_ADD_COMPLETION_MAX_REACHED:
+	      xfree (completion);
+	      return return_val;
+	    case MAYBE_ADD_COMPLETION_DUPLICATE:
+	      xfree (completion);
+	      break;
+	    }
+	}
     }
 
   return return_val;
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 78ba216..90cdb36 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -994,3 +994,30 @@ test_completion_limit "file ./gdb.base/jit-s" \
 # same as above but completing on directory names.
 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
+}


  parent reply	other threads:[~2015-04-13 19:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 19:23 [PATCH 00/18] Implement full completer limiting Keith Seitz
2015-04-13 19:23 ` [PATCH 07/18] Implement completion limiting for filename_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 14/18] Implement completion limiting in add_struct_fields Keith Seitz
2015-04-13 19:23 ` [PATCH 16/18] Make the completion API completely opaque Keith Seitz
2015-04-13 19:23 ` [PATCH 09/18] Implement completion limiting for interpreter_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 18/18] Remove the vector return result from the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 06/18] Implement completion limiting for condition_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 13/18] Implement completion limiting for complete_on_enum Keith Seitz
2015-04-13 19:23 ` [PATCH 12/18] Implement completion limiting for sim_command_completer Keith Seitz
2015-04-14 15:28   ` Mike Frysinger
2015-05-05 15:03     ` Keith Seitz
2015-05-05 15:34       ` Mike Frysinger
2015-05-05 15:53         ` Keith Seitz
2015-04-13 19:23 ` [PATCH 15/18] Implement completion limiting for scmcmd_add_completion Keith Seitz
2015-04-13 19:23 ` [PATCH 10/18] Implement completion limiting for cmdpy_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 17/18] Use the hashtable to accumulate completion results Keith Seitz
2015-04-13 19:23 ` [PATCH 02/18] Remove completion_tracker_t from the public completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 11/18] Implement completion limiting for reg_or_group_completer Keith Seitz
2015-04-13 19:23 ` Keith Seitz [this message]
2015-04-13 19:23 ` [PATCH 05/18] Implement completion limiting for ada_make_symbol_completion_list Keith Seitz
2015-04-13 19:23 ` [PATCH 04/18] Implement completion limiting for add_filename_to_list Keith Seitz
2015-04-13 19:23 ` [PATCH 01/18] Add struct completer_data to the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 03/18] Implement completion limiting for complete_on_cmdlist Keith Seitz
2015-04-20  3:21 ` [PATCH 00/18] Implement full completer limiting Doug Evans
2015-04-29 19:19   ` Keith Seitz
2015-04-30  0:26     ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150413192321.29172.22932.stgit@valrhona.uglyboxes.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox