From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9DA1A3856DC4 for ; Wed, 25 May 2022 18:36:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DA1A3856DC4 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-vyQ5ceWCMfu5H-Q4oV-yZw-1; Wed, 25 May 2022 14:36:09 -0400 X-MC-Unique: vyQ5ceWCMfu5H-Q4oV-yZw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4CEF1C16B42; Wed, 25 May 2022 18:36:08 +0000 (UTC) Received: from [10.97.116.24] (ovpn-116-24.gru2.redhat.com [10.97.116.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56F432166B26; Wed, 25 May 2022 18:36:07 +0000 (UTC) Message-ID: Date: Wed, 25 May 2022 15:36:05 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v5 3/8] GDB: Add `NUMBER' completion to `set' integer commands To: "Maciej W. Rozycki" , gdb-patches@sourceware.org Cc: Simon Sobisch , Tom Tromey , Andrew Burgess References: From: Bruno Larsen In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2022 18:36:14 -0000 On 3/30/22 07:24, Maciej W. Rozycki wrote: > Fix a completion consistency issue with `set' commands accepting integer > values and the special `unlimited' keyword: > > (gdb) complete print -elements > print -elements NUMBER > print -elements unlimited > (gdb) > > vs: > > (gdb) complete set print elements > set print elements unlimited > (gdb) > > (there is a space entered at the end of both commands, not shown here) > which also means if you strike with `set print elements ' input, > it will, annoyingly, complete to `set print elements unlimited' right > away rather than showing a choice between `NUMBER' and `unlimited'. > > Add `NUMBER' then as an available completion for such `set' commands: > > (gdb) complete set print elements > set print elements NUMBER > set print elements unlimited > (gdb) > > Adjust the testsuite accordingly. Hi Maciej, Thanks for looking at this! > --- > No change from v4. > > New change in v4. > --- > gdb/cli/cli-decode.c | 2 ++ > gdb/testsuite/gdb.base/settings.exp | 8 +++++++- > 2 files changed, 9 insertions(+), 1 deletion(-) > > gdb-integer-complete-number.diff > Index: src/gdb/cli/cli-decode.c > =================================================================== > --- src.orig/gdb/cli/cli-decode.c > +++ src/gdb/cli/cli-decode.c > @@ -989,6 +989,8 @@ integer_unlimited_completer (struct cmd_ > NULL, > }; > > + if (*text == '\0') > + tracker.add_completion (make_unique_xstrdup ("NUMBER")); > complete_on_enum (tracker, keywords, text, word); > } Seeing as the point of "complete_on_enum" is to add all keywords to the tracker, why not add "NUMBER" as a keyword? The only possible unfavorable side effect I can think of would be GDB completing N to NUMBER, and personally I feel abstracting away how the option would be added is more important than not adding this completion option. Another option would be having the function like this: void integer_unlimited_completer(...) { static const char * const keywords [] = { "NUMBER", "unlimited", NULL } if (*text != '\0') complete_on_enum (tracker, keywords + 1, text, word); else complete_on_enum (tracker, keywords, text, word); } Or some more concise way of writing it. > > Index: src/gdb/testsuite/gdb.base/settings.exp > =================================================================== > --- src.orig/gdb/testsuite/gdb.base/settings.exp > +++ src/gdb/testsuite/gdb.base/settings.exp > @@ -215,8 +215,14 @@ proc test-integer {variant} { > test_gdb_complete_none \ > "$set_cmd " > } else { > + test_gdb_complete_multiple "$set_cmd " "" "" { > + "NUMBER" > + "unlimited" > + } > + test_gdb_complete_none \ > + "$set_cmd 1" > test_gdb_complete_unique \ > - "$set_cmd " \ > + "$set_cmd u" \ > "$set_cmd unlimited" > } > > Cheers! Bruno Larsen