From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 83E4E384B106 for ; Thu, 26 Nov 2020 19:12:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 83E4E384B106 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 314A91E552; Thu, 26 Nov 2020 14:12:35 -0500 (EST) Subject: Re: [PATCH] gdb: improve command completion for 'print', 'x', and 'display' To: Andrew Burgess , gdb-patches@sourceware.org References: <20201116154221.240877-1-andrew.burgess@embecosm.com> From: Simon Marchi Message-ID: <05be3103-96e3-6e2d-902a-a1e35a166389@simark.ca> Date: Thu, 26 Nov 2020 14:12:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201116154221.240877-1-andrew.burgess@embecosm.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 26 Nov 2020 19:12:36 -0000 On 2020-11-16 10:42 a.m., Andrew Burgess wrote: > The /FMT specification on the print command currently breaks command > completion, so: > > (gdb) p var. > .... list of fields in var ..... > > But, > > (gdb) p/d var. > ..... list of all symbols ..... > > After this commit this issue is now resolved. > > There are some other details around tab-completion and /FMT which > hopefully this commit improves. So, before: > > (gdb) p/ > .... lists all symbols ..... > > After: > > (gdb) p/ # Nothing changes... > > The thinking here is that after a / the user must type a FMT, but we > don't offer tab completion on FMT characters. Placing a symbol > directly after a / will not do what the user expects, so offering that > seems wrong. > > Similarly, before we had: > > (gdb) p/d > ... lists all symbols starting with 'd' .... > > But afterwards: > > (gdb) p/d # Adds a single space, so we get: > (gdb) p/d > > As before, typing a symbol where FMT is expected will not do what the > user expects. If the user has added a FMT string then upon tab > completion GDB assumes the FMT string is complete and prepares the > user to type an expression. > > In this commit I have also added completion functions for the 'x' and > 'display' commands. These commands also support /FMT specifiers and > so share some code with 'print'. > > gdb/ChangeLog: > > * printcmd.c: Include 'safe-ctype.c'. > (skip_over_slash_fmt): New function. > (print_command_completer): Call skip_over_slash_fmt. > (display_and_x_command_completer): New function. > (_initialize_printcmd): Add command completion for 'x' and > 'display'. > > gdb/testsuite/ChangeLog: > > * gdb.base/completion.exp: Add new tests. > --- > gdb/ChangeLog | 9 +++ > gdb/printcmd.c | 81 ++++++++++++++++++++++++++- > gdb/testsuite/ChangeLog | 4 ++ > gdb/testsuite/gdb.base/completion.exp | 26 +++++++++ > 4 files changed, 118 insertions(+), 2 deletions(-) I noticed this warning in the code added by this patch, I think it's not a false positive: /home/simark/src/binutils-gdb/gdb/printcmd.c: In function ‘bool skip_over_slash_fmt(completion_tracker&, const char**)’: /home/simark/src/binutils-gdb/gdb/printcmd.c:1285:14: warning: ‘in_fmt’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1285 | return in_fmt; | ^~~~~~ Simon