From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109017 invoked by alias); 21 May 2015 00:25:19 -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 109008 invoked by uid 89); 21 May 2015 00:25:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no 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; Thu, 21 May 2015 00:25:18 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4L0PFFe029762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 May 2015 20:25:16 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4L0PEtG023196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 May 2015 20:25:15 -0400 Message-ID: <555D25EA.5000007@redhat.com> Date: Thu, 21 May 2015 00:25:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Andrew Burgess , gdb-patches@sourceware.org Subject: Re: [PATCH 2/4] gdb: Add completer for layout command. References: <624c38b3a3d842f5f41f1f2203bdfce78e0c2390.1432163460.git.andrew.burgess@embecosm.com> In-Reply-To: <624c38b3a3d842f5f41f1f2203bdfce78e0c2390.1432163460.git.andrew.burgess@embecosm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00527.txt.bz2 On 05/20/2015 04:17 PM, Andrew Burgess wrote: > Add layout name completion for the layout command. > > gdb/ChangeLog: > > * tui/tui-layout.c (layout_completer): New function. > (_initialize_tui_layout): Set completer on layout command. > > gdb/testsuite/ChangeLog: > > * gdb.base/completion.exp: Add test for completion of layout > names. > --- > gdb/ChangeLog | 5 +++++ > gdb/testsuite/ChangeLog | 5 +++++ > gdb/testsuite/gdb.base/completion.exp | 19 +++++++++++++++++++ > gdb/tui/tui-layout.c | 35 ++++++++++++++++++++++++++++++++++- > 4 files changed, 63 insertions(+), 1 deletion(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 40c70e7..51d2bfc 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,5 +1,10 @@ > 2015-05-20 Andrew Burgess > > + * tui/tui-layout.c (layout_completer): New function. > + (_initialize_tui_layout): Set completer on layout command. > + > +2015-05-20 Andrew Burgess > + > * tui/tui-layout.c (tui_set_layout): Remove > tui_register_display_type parameter. Remove all checking of this > parameter, and reindent function. Update header comment. > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index 3a947eb..15dae61 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,5 +1,10 @@ > 2015-05-20 Andrew Burgess > > + * gdb.base/completion.exp: Add test for completion of layout > + names. > + > +2015-05-20 Andrew Burgess > + > * lib/gdb.exp (skip_tui_tests): New proc. > * gdb.base/tui-layout.exp: Check skip_tui_tests. > > diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp > index f77bfe2..4c31bfc 100644 > --- a/gdb/testsuite/gdb.base/completion.exp > +++ b/gdb/testsuite/gdb.base/completion.exp > @@ -859,3 +859,22 @@ gdb_test_multiple "" "$test" { > pass "$test" > } > } > + > +gdb_test_no_output "set max-completions unlimited" > + > +if {![skip_tui_tests]} { > + set test "test completion of layout names" > + send_gdb "layout\t\t\t" > + gdb_test_multiple "" "$test" { > + -re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" { > + pass "$test" > + } > + } > + send_gdb "\003" > + set test "quit command input after testing layout completion" > + gdb_test_multiple "" "$test" { > + -re "$gdb_prompt $" { > + pass "$test" > + } > + } > +} > diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c > index 44aca5d..45fa575 100644 > --- a/gdb/tui/tui-layout.c > +++ b/gdb/tui/tui-layout.c > @@ -350,6 +350,36 @@ tui_default_win_viewport_height (enum tui_win_type type, > return h; > } > > +/* Complete possible layout names. TEXT is the complete text entered so > + far, WORD is the word currently being completed. */ > + > +static VEC (char_ptr) * > +layout_completer (struct cmd_list_element *ignore, > + const char *text, const char *word) > +{ > + VEC (char_ptr) *return_val = NULL; > + const char **tmp, *p; > + size_t len; > + > + static const char *layout_names [] = > + { "src", "asm", "split", "regs", "next", "prev", NULL }; > + > + gdb_assert (text != NULL); > + p = strchr (text, ' '); > + len = (p == NULL) ? strlen (text) : p - text; > + > + for (tmp = layout_names; *tmp != NULL; ++tmp) > + { > + if (strncmp (text, *tmp, len) == 0) > + { > + char *str = xstrdup (*tmp); > + VEC_safe_push (char_ptr, return_val, str); > + } > + } > + One quick observation (having seen my fair share of completion functions recently)... Most completer functions are using complete_on_enum to do this sort of thing. Will that work here? Keith