From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 1B1D7386F0CB for ; Thu, 30 Jun 2022 14:24:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B1D7386F0CB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x332.google.com with SMTP id c130-20020a1c3588000000b0039c6fd897b4so1813765wma.4 for ; Thu, 30 Jun 2022 07:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=z2ien3m84b9tOi+Ez9KGlpZod8Soj/Qk/UOcsYnbXSw=; b=HVedSg3Nit3946/6sAUbWnqGAfTIKY/Jy4x0VZQRkljxpMNEyaTHfr1r6xgECWNfBj ioP/P07SsTf+FOS4sVg1SOr5LTZXupKk8YROmoAJI2ThFt0FhGwAoSAeIMzAErGBaS6q BX9TZTC9p8ILkE356m5M+bqEil4ewIBhvbD7oLSttukNQ/iRBVjywc2S9F5JfXdjF0OB yM3V0FdElHhc+zOG5sPf0QjJs1uOQtLdhmtZ+6Eif3AfnF3dueQDMqofyVUER54A2wfF Ju4pRpfUfqsHnK0OyQLXPVZzbmRksvut8jsUUphSChcnijXliTLL1X/kooGJyo/y7lBK 841w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=z2ien3m84b9tOi+Ez9KGlpZod8Soj/Qk/UOcsYnbXSw=; b=GLQ3+iqaJK80dlmLQhVAcMLxklELqmnEuADvTmz3XymATNp0tyzqoMGOid7z6cYQUO f5LP5RmoYZs7xYWdEY7qcWxH8CW4VJO2k2HjRtcApBba8lMF1AFfqzTkqr6AVnsiaB+x KZx8h9Ov+0nUPZ9xnh6yLcwhpVW9lFt3bwGxbqZ1SSoFKJGhZq3mhCntWWKXSnlaMdbT fZMRcOMzCIArF63Ec2rfoeTjJLV6HO76vOY7Gg+TlVvQRchg757lGwv36tkhbMe8pIxt UCZ36xQwjmJPNYLOiCLD+VBNGTjKXojOn/KWQ+Hwdx5znyuzwrjMG8tvWRn5kbiK0GyM 8lLQ== X-Gm-Message-State: AJIora/ceJdM+JZP3kgdD1eZbNv7MXaW77yDdU0jbU/X1t/xIGc5XqxP g/mpHVERDiVOWCFiF98m/Go1nw== X-Google-Smtp-Source: AGRyM1szAWb/63NufQUZ7grAPJ7zMQd9MVOaHhR9P6B2nqIENX97BovSounuPvdoq/KEO4iulnpUvQ== X-Received: by 2002:a05:600c:3ca2:b0:3a0:1825:2e6b with SMTP id bg34-20020a05600c3ca200b003a018252e6bmr12184048wmb.132.1656599043818; Thu, 30 Jun 2022 07:24:03 -0700 (PDT) Received: from tpp.orcam.me.uk (tpp.orcam.me.uk. [2001:8b0:154:0:ea6a:64ff:fe24:f2fc]) by smtp.gmail.com with ESMTPSA id q11-20020adfea0b000000b0020fff0ea0a3sm19169099wrm.116.2022.06.30.07.24.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2022 07:24:03 -0700 (PDT) Date: Thu, 30 Jun 2022 15:24:01 +0100 (BST) From: "Maciej W. Rozycki" To: Andrew Burgess cc: gdb-patches@sourceware.org, Simon Sobisch , Tom Tromey Subject: [PATCH v6 3/8] GDB: Add `NUMBER' completion to `set' integer commands In-Reply-To: <874k0aaylb.fsf@redhat.com> Message-ID: References: <874k0aaylb.fsf@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Thu, 30 Jun 2022 14:24:07 -0000 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. Also document the feature in the Completion section of the manual in addition to the Command Options section already there. --- On Fri, 24 Jun 2022, Andrew Burgess wrote: > > 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. > > I like this change, but I think we should add some documentation in > `@node Completion` that describes this new behaviour. We should probably > add a NEWS entry too. Thank you for your review. This is already documented in the Command Options section, but that's not necessarily the place one will look for it, so maybe it's worth repeating here as well indeed. I have changed the wording slightly compared to the original. How about this version then? Maciej Changes from v5: - document the `NUMBER' completion in the Completion section of the manual for commands accepting keywords as well as numbers, - document the addition of `NUMBER' completion for `set' commands in NEWS. No change from v4. New change in v4. --- gdb/NEWS | 12 ++++++++++++ gdb/cli/cli-decode.c | 2 ++ gdb/doc/gdb.texinfo | 15 +++++++++++++++ gdb/testsuite/gdb.base/settings.exp | 8 +++++++- 4 files changed, 36 insertions(+), 1 deletion(-) gdb-integer-complete-number.diff Index: src/gdb/NEWS =================================================================== --- src.orig/gdb/NEWS +++ src/gdb/NEWS @@ -27,6 +27,18 @@ emit to indicate where a breakpoint should be placed to break in a function past its prologue. +* Completion now also offers "NUMBER" for "set" commands that accept + a numeric argument and the "unlimited" keyword. For example: + + (gdb) set width + NUMBER unlimited + + and consequently: + + (gdb) complete set width + set width NUMBER + set width unlimited + * New commands maintenance set ignore-prologue-end-flag on|off 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); } Index: src/gdb/doc/gdb.texinfo =================================================================== --- src.orig/gdb/doc/gdb.texinfo +++ src/gdb/doc/gdb.texinfo @@ -1960,6 +1960,21 @@ After displaying the available possibili partial input (@samp{b make_} in the example) so you can finish the command. +If the command you are trying to complete expects either a keyword or a +number to follow, then @samp{NUMBER} will be shown among the available +completions, for example: + +@smallexample +(@value{GDBP}) print -elements @key{TAB}@key{TAB} +NUMBER unlimited +(@value{GDBP}) print -elements@tie{} +@end smallexample + +@noindent +Here, the option expects a number (e.g., @code{100}), not literal +@code{NUMBER}. Such metasyntactical arguments are always presented in +uppercase. + If you just want to see the list of alternatives in the first place, you can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?} means @kbd{@key{META} ?}. You can type this either by holding down a 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" }