From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107721 invoked by alias); 23 Aug 2015 04:07:34 -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 107624 invoked by uid 89); 23 Aug 2015 04:07:28 -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-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 23 Aug 2015 04:07:27 +0000 Received: by pacdd16 with SMTP id dd16so71522893pac.2 for ; Sat, 22 Aug 2015 21:07:25 -0700 (PDT) X-Received: by 10.66.148.136 with SMTP id ts8mr33532915pab.15.1440302845599; Sat, 22 Aug 2015 21:07:25 -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 an10sm12719458pad.5.2015.08.22.21.07.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2015 21:07:25 -0700 (PDT) From: Doug Evans To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 10/19] Implement completion limiting for cmdpy_completer. References: <20150806191404.32159.50755.stgit@valrhona.uglyboxes.com> <20150806191815.32159.84277.stgit@valrhona.uglyboxes.com> Date: Sun, 23 Aug 2015 04:07:00 -0000 In-Reply-To: <20150806191815.32159.84277.stgit@valrhona.uglyboxes.com> (Keith Seitz's message of "Thu, 06 Aug 2015 12:18:36 -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/msg00649.txt.bz2 Keith Seitz writes: > Differences in this revision: > > 1. Free string memory after passing to add_completion. > > --- > > This patch converts cmdpy_completer, used by commands written in > python. It also adds tests for some untested python functionality > related to completion. > > gdb/ChangeLog > > * python/py-cmd.c (cmdpy_completer) Use add_completion. > Free memory associated with `item'. > > gdb/testsuite/ChangeLog > > * gdb.python/py-completion.exp: Test completion functions, > with and without completion limiting. LGTM, but see comment below. > --- > gdb/python/py-cmd.c | 9 +++++- > gdb/testsuite/gdb.python/py-completion.exp | 45 ++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+), 1 deletion(-) > > diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c > index 21d842e..36e352e 100644 > --- a/gdb/python/py-cmd.c > +++ b/gdb/python/py-cmd.c > @@ -392,7 +392,14 @@ cmdpy_completer (struct completer_data *cdata, > PyErr_Clear (); > continue; > } > - VEC_safe_push (char_ptr, result, item); > + > + if (add_completion (cdata, &result, item, NULL, NULL) > + == ADD_COMPLETION_MAX_REACHED) > + { > + xfree (item); > + break; > + } > + xfree (item); > } > > Py_DECREF (iter); > diff --git a/gdb/testsuite/gdb.python/py-completion.exp b/gdb/testsuite/gdb.python/py-completion.exp > index 5e45087..f7f23a3 100644 > --- a/gdb/testsuite/gdb.python/py-completion.exp > +++ b/gdb/testsuite/gdb.python/py-completion.exp > @@ -128,3 +128,48 @@ if {[readline_is_used]} { > "completelimit2 cl29" > } > } > + > +# The terminal at the end of the complete command > +set end "\\\*\\\*\\\* List may be truncated, " > +append end "max-completions reached\\\. \\\*\\\*\\\*" ==== Another case where it'd be nice to just call a function (test_completion_limit?) and have this regexp live there? It may be that each case is sufficiently different that such a function would be too complex to handle all its potential callers, I didn't study each case too thoroughly. Just wanted to bring the issue up. > + > +set max_completions 3 > +gdb_test_no_output "set max-completions $max_completions" > +set seen 0 > + > +set testname "limit completions of 'complete completel'" > +gdb_test_multiple "complete completel" $testname { > + "complete completel" { exp_continue } > + > + -re "completelimit\[1-9\]+\r\n" { > + incr seen > + exp_continue > + } > + > + -re "completel $end\r\n$gdb_prompt $" { > + if {$seen == $max_completions} { > + pass $testname > + } else { > + fail "$testname ($seen/$max_completions)" > + } > + } > +} > + > +set testname "limit completions of 'complete completelimit1 c'" > +set seen 0 > +gdb_test_multiple "complete completelimit1 c" $testname { > + "complete completelimit1 c" { exp_continue } > + > + -re "completelimit1 cl1\[1-9\]+\r\n" { > + incr seen > + exp_continue > + } > + > + -re "completelimit1 c $end\r\n$gdb_prompt $" { > + if {$seen == $max_completions} { > + pass $testname > + } else { > + fail "$testname ($seen/$max_completions)" > + } > + } > +}