From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121630 invoked by alias); 13 Apr 2015 19:23:33 -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 121613 invoked by uid 89); 13 Apr 2015 19:23:33 -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:32 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJNV6Q030722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 13 Apr 2015 15:23:31 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJNVDr011268 for ; Mon, 13 Apr 2015 15:23:31 -0400 Subject: [PATCH 12/18] Implement completion limiting for sim_command_completer. From: Keith Seitz To: gdb-patches@sourceware.org Date: Mon, 13 Apr 2015 19:23:00 -0000 Message-ID: <20150413192331.29172.23243.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/msg00488.txt.bz2 This patch converts sim_command_completer to use maybe_add_completion. It does not add any tests, since the `sim' command is highly target-dependent and unimplemented for the majority of simulators. gdb/ChangeLog * remote-sim.c: Include completer.h. (sim_command_completer): Use maybe_add_completion. --- gdb/remote-sim.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 2bcb19e..5056a13 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -39,6 +39,7 @@ #include "arch-utils.h" #include "readline/readline.h" #include "gdbthread.h" +#include "completer.h" /* Prototypes */ @@ -1223,7 +1224,7 @@ sim_command_completer (struct completer_data *cdata, { struct sim_inferior_data *sim_data; char **tmp; - int i; + int i, stop; VEC (char_ptr) *result = NULL; sim_data = inferior_data (current_inferior (), sim_inferior_data_key); @@ -1235,8 +1236,29 @@ sim_command_completer (struct completer_data *cdata, return NULL; /* Transform the array into a VEC, and then free the array. */ - for (i = 0; tmp[i] != NULL; i++) - VEC_safe_push (char_ptr, result, tmp[i]); + for (i = 0, stop = 0; !stop && tmp[i] != NULL; i++) + { + enum maybe_add_completion_enum add_status; + + add_status = maybe_add_completion (cdata, tmp[i]); + switch (add_status) + { + case MAYBE_ADD_COMPLETION_OK: + VEC_safe_push (char_ptr, result, tmp[i]); + break; + case MAYBE_ADD_COMPLETION_OK_MAX_REACHED: + VEC_safe_push (char_ptr, result, tmp[i]); + stop = 1; + break; + case MAYBE_ADD_COMPLETION_MAX_REACHED: + xfree (tmp[i]); + stop = 1; + break; + case MAYBE_ADD_COMPLETION_DUPLICATE: + xfree (tmp[i]); + break; + } + } xfree (tmp); return result;