From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121941 invoked by alias); 13 Apr 2015 19:23:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 121919 invoked by uid 89); 13 Apr 2015 19:23:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 13 Apr 2015 19:23:35 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJNYqa003208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 13 Apr 2015 15:23:34 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJNXZT031010 for ; Mon, 13 Apr 2015 15:23:33 -0400 Subject: [PATCH 13/18] Implement completion limiting for complete_on_enum. From: Keith Seitz To: gdb-patches@sourceware.org Date: Mon, 13 Apr 2015 19:23:00 -0000 Message-ID: <20150413192333.29172.68440.stgit@valrhona.uglyboxes.com> In-Reply-To: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com> References: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00495.txt.bz2 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 +}