From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128842 invoked by alias); 23 Aug 2015 04:24:54 -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 128828 invoked by uid 89); 23 Aug 2015 04:24:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 23 Aug 2015 04:24:51 +0000 Received: by padfo6 with SMTP id fo6so35192447pad.1 for ; Sat, 22 Aug 2015 21:24:49 -0700 (PDT) X-Received: by 10.66.175.7 with SMTP id bw7mr33487031pac.155.1440303889430; Sat, 22 Aug 2015 21:24:49 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id ld8sm12692638pbc.61.2015.08.22.21.24.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2015 21:24:48 -0700 (PDT) From: Doug Evans To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 15/19] Implement completion limiting for scmcmd_add_completion. References: <20150806191404.32159.50755.stgit@valrhona.uglyboxes.com> <20150806191959.32159.97237.stgit@valrhona.uglyboxes.com> Date: Sun, 23 Aug 2015 04:24:00 -0000 In-Reply-To: <20150806191959.32159.97237.stgit@valrhona.uglyboxes.com> (Keith Seitz's message of "Thu, 06 Aug 2015 12:20:20 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00654.txt.bz2 Keith Seitz writes: > Differences in this revision: > > 1. Free string memory after passing to add_completion. > > --- > > This patch converts scmcmd_add_completion to use add_completion and > adds some tests for this new behavior. > > gdb/ChangeLog > > * guile/scm-cmd.c (cmdscm_add_completion): Add completer_data > argument. All callers updated. > Use add_completion. > Free memory associated with `item'. > > gdb/testsuite/ChangeLog > > * gdb.guile/scm-cmd.exp: Add completion limiting tests. LGTM. Another case for using common test_completion_limit? > --- > gdb/guile/scm-cmd.c | 11 ++++++----- > gdb/testsuite/gdb.guile/scm-cmd.exp | 24 ++++++++++++++++++++++++ > 2 files changed, 30 insertions(+), 5 deletions(-) > > diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c > index 58c79c8..1544c2b 100644 > --- a/gdb/guile/scm-cmd.c > +++ b/gdb/guile/scm-cmd.c > @@ -348,7 +348,8 @@ cmdscm_bad_completion_result (const char *msg, SCM completion) > The result is a boolean indicating success. */ > > static int > -cmdscm_add_completion (SCM completion, VEC (char_ptr) **result) > +cmdscm_add_completion (SCM completion, struct completer_data *cdata, > + VEC (char_ptr) **result) > { > char *item; > SCM except_scm; > @@ -370,8 +371,8 @@ cmdscm_add_completion (SCM completion, VEC (char_ptr) **result) > return 0; > } > > - VEC_safe_push (char_ptr, *result, item); > - > + (void) add_completion (cdata, result, item, NULL, NULL); > + xfree (item); > return 1; > } > > @@ -418,7 +419,7 @@ cmdscm_completer (struct completer_data *cdata, > { > SCM next = scm_car (list); > > - if (!cmdscm_add_completion (next, &result)) > + if (!cmdscm_add_completion (next, cdata, &result)) > { > VEC_free (char_ptr, result); > goto done; > @@ -442,7 +443,7 @@ cmdscm_completer (struct completer_data *cdata, > goto done; > } > > - if (!cmdscm_add_completion (next, &result)) > + if (!cmdscm_add_completion (next, cdata, &result)) > { > VEC_free (char_ptr, result); > goto done; > diff --git a/gdb/testsuite/gdb.guile/scm-cmd.exp b/gdb/testsuite/gdb.guile/scm-cmd.exp > index 53c0fdf..ac721c3 100644 > --- a/gdb/testsuite/gdb.guile/scm-cmd.exp > +++ b/gdb/testsuite/gdb.guile/scm-cmd.exp > @@ -196,6 +196,30 @@ gdb_test "test-scheme-error-cmd ugh" \ > "Error occurred in Scheme-implemented GDB command." \ > "call scheme-error command" > > +# Test completion limiting. > +set max_completions 2 > +gdb_test_no_output "set max-completions $max_completions" > +set end "\\\*\\\*\\\* List may be truncated, " > +append end "max-completions reached\\\. \\\*\\\*\\\*" > +set test "limit complete completer-as-function 42\." > +gdb_test_multiple "complete completer-as-function 42\." $test { > + "complete completer-as-function 42\\\." { exp_continue } > + -re "completer-as-function 42\\\.\[1-3\]\r\n" { > + incr seen > + exp_continue > + } > + -re ".*$end\r\n$gdb_prompt $" { > + if {$seen == $max_completions} { > + pass $test > + } else { > + fail "$test ($seen/$max_completions)" > + } > + } > + -re ".*$gdb_prompt $" { > + fail "$test (unlimited)" > + } > +} > + > # If there is a problem with object management, this can often trigger it. > # It is useful to do this last, after we've created a bunch of command objects. >