Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>, Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/6] gdb: move display of completion results into completion_result class
Date: Fri, 12 Apr 2024 18:24:31 +0100	[thread overview]
Message-ID: <87v84m4hps.fsf@redhat.com> (raw)
In-Reply-To: <86v853ar3c.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sat, 30 Mar 2024 23:30:38 +0000
>> From: Lancelot SIX <lsix@lancelotsix.com>
>> Cc: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
>> 
>> On Fri, Mar 29, 2024 at 03:14:07PM +0300, Eli Zaretskii wrote:
>> > > From: Andrew Burgess <aburgess@redhat.com>
>> > > Cc: Andrew Burgess <aburgess@redhat.com>
>> > > Date: Fri, 29 Mar 2024 11:42:28 +0000
>> > > 
>> > > When using the 'complete' command to complete file names we have some
>> > > problems.  The suggested completion should include any required
>> > > escaping, so if there is a filename '/tmp/aa"bb' (without the single
>> > > quotes), then this should be displayed in the completion output like:
>> > > 
>> > >   (gdb) complete file /tmp/aa
>> > >   file /tmp/aa\"bb
>> > 
>> > Why should it be displayed with the backslash?  And would the
>> > completed name, if passed to a command, also have the backslash added?
>> > If so, it could cause some commands to fail; basically, you are adding
>> > shell file-name semantics into commands that don't work via the shell.
>> 
>> Hi,
>> 
>> The "file" command currently expects "shell file-name semantics":
>
> For starters, this fact, if it is true, is not really documented.

Agreed.  This can be improved.

>
>>     $ gdb -q
>>     (gdb) file test/aa bb/a.out
>>     test/aa: No such file or directory.
>>     (gdb) file "test/aa bb/a.out"
>>     Reading symbols from test/aa bb/a.out...
>>     (gdb) file test/aa\ bb/a.out
>>     Load new symbol table from "test/aa bb/a.out"? (y or n) y
>>     Reading symbols from test/aa bb/a.out...
>>     (gdb)
>
> Next, if 'file' indeed expects shell file-name semantics, then the
> question is: which shell?  Should the above behave differently on, for
> example, MS-Windows, since file-name quoting there works differently?
> For example, escaping whitespace with a backslash will not work on
> Windows.

I think calling this "shell file-name semantics" makes this change seem
worse than it is.  If we want to call it anything, then it should be
called gdb-shell semantics.

That is, this is how GDB quotes filenames.

This syntax isn't getting forwarded to any system shell, it remains
entirely within GDB, so I don't think we'd need to change the behaviour
for MS-Windows vs GNU/Linux.

> Also, Andrew used the 'file' command in his examples, but completion
> in GDB is used in many other commands, including those who don't
> necessarily expect/need shell file-name semantics.

These changes only impact filename completion, anything that doesn't
specifically invoke the filename completion function will not change its
behaviour.  If you see any examples of this then that is 100% a bug in
this work.

> And last, but not least: the manual says about the 'complete' command:
>
>      This is intended for use by GNU Emacs.
>
> So one other thing we should consider is how Emacs handles these cases
> and what it expects from GDB in response.

Happy to test such a thing.  Can you point me at any instruction/guides
for how to trigger completion via emacs?

My hope is that this change will fix things rather than break them.
Previously the 'complete' command would output a partial completion that
was invalid, that is, if the user passes emacs a short string and then
triggers completion, GDB would provide a longer string which was
invalid.  If emacs then feeds that longs string back to GDB the command
isn't going to work.  After this change that should no longer be the
case.

>
>> The problem Andrew is trying to solve is that the current completer for
>> this command completes to something that is not a valid input.
>
> My point is that we need to have a clear idea what is a "valid input"
> before we decide whether the current behavior is invalid, and if so,
> how to fix it.

I do disagree with the "decide whether the current behaviour is invalid"
part of this text.  Completion of files containing whitespace doesn't
work right now, so I'd suggest the current behaviour is self-evidently
invalid.  But ...

>                 IOW, we should step back and discuss the valid
> behavior first.

I'm totally happy to take suggestions on what the working behaviour
should look like.

>                  Andrew's patch series started from postulating a
> certain desired result without any such discussion, and I think we
> should discuss these aspects before we decide what is the desired
> result.

Sure.  My experience of proposing changes without patches is that folk
say, "Sure, sounds good, but how _exactly_ will it work.  What _exactly_
will it look like."  And honestly, I'm just not smart enough to answer
those questions without writing the code first.

I'm ALWAYS willing to rework changes based on feedback.  Please don't
think, just because I posted a patch that I'm saying it _has_ to be this
way.

That said, you email raises the idea concerns, but I'm still not clear
exactly _what_ your concerns are (other than emacs compatibility which
has been covered above).

I think there's something else which has been missed from this
discussion, which is super important when we talk about what the
"correct" behaviour should be:  I'm changing _completion_, I'm not
changing how GDB actually reads files names.

Right now if we want to pass a file containing whitespace to the 'file'
command then a user can either quote the filename, or escape the
whitespace.  That is _current_ behaviour, and is not something I'm
touching in this series.

This series makes the completion engine offer completions using those
schemes: if the user didn't include an opening quote then the whitespace
will be escaped.  If the filename did have an opening quote then no
escaping is necessary.  As such, it would seem that unless we want to
change how GDB currently parses filenames[*] then what completion should
do is pretty much prescribed by GDB's parsing rules...

I'll see if I can figure out the emacs thing, but if you do have some
hints that would be great.

Thanks,
Andrew




>
>> That being said, this is just my 2 cent, I am looking forward to
>> hearing other people’s thoughts on the subject.
>
> Same here.
>
> Thanks.


  reply	other threads:[~2024-04-12 17:24 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 11:42 [PATCH 0/6] Further filename completion improvements Andrew Burgess
2024-03-29 11:42 ` [PATCH 1/6] gdb: improve escaping when completing filenames Andrew Burgess
2024-03-30 23:48   ` Lancelot SIX
2024-03-29 11:42 ` [PATCH 2/6] gdb: move display of completion results into completion_result class Andrew Burgess
2024-03-29 12:14   ` Eli Zaretskii
2024-03-30 23:30     ` Lancelot SIX
2024-03-31  5:49       ` Eli Zaretskii
2024-04-12 17:24         ` Andrew Burgess [this message]
2024-04-12 18:42           ` Eli Zaretskii
2024-04-12 22:20             ` Andrew Burgess
2024-04-13  6:36               ` Eli Zaretskii
2024-04-13  9:09                 ` Andrew Burgess
2024-04-13  9:46                   ` Eli Zaretskii
2024-04-12 17:31       ` Andrew Burgess
2024-03-29 11:42 ` [PATCH 3/6] gdb: simplify completion_result::print_matches Andrew Burgess
2024-03-30 23:48   ` Lancelot SIX
2024-03-29 11:42 ` [PATCH 4/6] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-03-30 23:49   ` Lancelot SIX
2024-03-31  5:55     ` Eli Zaretskii
2024-04-12 17:42       ` Andrew Burgess
2024-04-12 18:44         ` Eli Zaretskii
2024-04-12 22:29           ` Andrew Burgess
2024-04-13  6:39             ` Eli Zaretskii
2024-03-29 11:42 ` [PATCH 5/6] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-03-29 11:42 ` [PATCH 6/6] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-04-20  9:10 ` [PATCHv2 0/8] Further filename completion improvements Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 1/8] gdb/doc: document how filename arguments are formatted Andrew Burgess
2024-04-20  9:44     ` Eli Zaretskii
2024-04-27 10:01       ` Andrew Burgess
2024-04-27 10:06         ` Eli Zaretskii
2024-04-29  9:10           ` Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 2/8] gdb: split apart two different types of filename completion Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 3/8] gdb: improve escaping when completing filenames Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 4/8] gdb: move display of completion results into completion_result class Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 5/8] gdb: simplify completion_result::print_matches Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 6/8] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 7/8] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-04-20  9:10   ` [PATCHv2 8/8] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-06-05 13:36   ` [PATCHv3 0/7] Further filename completion improvements Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 1/7] gdb: split apart two different types of filename completion Andrew Burgess
2024-06-06 16:18       ` Tom Tromey
2024-06-17 13:05         ` Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 2/7] gdb: improve escaping when completing filenames Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 3/7] gdb: move display of completion results into completion_result class Andrew Burgess
2024-06-06 16:19       ` Tom Tromey
2024-06-05 13:36     ` [PATCHv3 4/7] gdb: simplify completion_result::print_matches Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 5/7] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-06-06 16:14       ` Tom Tromey
2024-06-17 13:29         ` Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 6/7] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-06-05 13:36     ` [PATCHv3 7/7] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-06-06 16:24     ` [PATCHv3 0/7] Further filename completion improvements Tom Tromey
2024-07-04 14:20     ` [PATCHv4 00/14] " Andrew Burgess
2024-07-04 14:20       ` [PATCHv4 01/14] gdb: split apart two different types of filename completion Andrew Burgess
2024-07-04 14:20       ` [PATCHv4 02/14] gdb: deprecated filename_completer and associated functions Andrew Burgess
2024-07-04 14:20       ` [PATCHv4 03/14] gdb: improve escaping when completing filenames Andrew Burgess
2024-07-04 14:20       ` [PATCHv4 04/14] gdb: move display of completion results into completion_result class Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 05/14] gdb: simplify completion_result::print_matches Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 06/14] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 07/14] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 08/14] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 09/14] gdb: implement readline rl_directory_rewrite_hook callback Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 10/14] gdb: new extract_single_filename_arg helper function Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 11/14] gdb: extend completion of quoted filenames to work in brkchars phase Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 12/14] gdb: add remove-symbol-file command completion Andrew Burgess
2024-07-04 15:38         ` Eli Zaretskii
2024-07-04 14:21       ` [PATCHv4 13/14] gdb: allow quoted filenames for commands that have custom completion Andrew Burgess
2024-07-04 15:42         ` Eli Zaretskii
2024-08-20 17:18           ` Andrew Burgess
2024-07-04 14:21       ` [PATCHv4 14/14] gdb: 'target ...' commands now expect quoted/escaped filenames Andrew Burgess
2024-07-04 15:34         ` Eli Zaretskii
2024-08-20 17:10       ` [PATCHv5 00/14] Further filename completion improvements Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 01/14] gdb: split apart two different types of filename completion Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 02/14] gdb: deprecated filename_completer and associated functions Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 03/14] gdb: improve escaping when completing filenames Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 04/14] gdb: move display of completion results into completion_result class Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 05/14] gdb: simplify completion_result::print_matches Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 06/14] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 07/14] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 08/14] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 09/14] gdb: implement readline rl_directory_rewrite_hook callback Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 10/14] gdb: new extract_single_filename_arg helper function Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 11/14] gdb: extend completion of quoted filenames to work in brkchars phase Andrew Burgess
2024-08-20 17:10         ` [PATCHv5 12/14] gdb: add remove-symbol-file command completion Andrew Burgess
2024-08-20 18:46           ` Eli Zaretskii
2024-08-20 17:10         ` [PATCHv5 13/14] gdb: allow quoted filenames for commands that have custom completion Andrew Burgess
2024-08-20 18:47           ` Eli Zaretskii
2024-08-20 17:10         ` [PATCHv5 14/14] gdb: 'target ...' commands now expect quoted/escaped filenames Andrew Burgess
2024-08-30 11:33         ` [PATCHv6 00/14] Further filename completion improvements Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 01/14] gdb: split apart two different types of filename completion Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 02/14] gdb: deprecated filename_completer and associated functions Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 03/14] gdb: improve escaping when completing filenames Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 04/14] gdb: move display of completion results into completion_result class Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 05/14] gdb: simplify completion_result::print_matches Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 06/14] gdb: add match formatter mechanism for 'complete' command output Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 07/14] gdb: apply escaping to filenames in 'complete' results Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 08/14] gdb: improve gdb_rl_find_completion_word for quoted words Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 09/14] gdb: implement readline rl_directory_rewrite_hook callback Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 10/14] gdb: new extract_single_filename_arg helper function Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 11/14] gdb: extend completion of quoted filenames to work in brkchars phase Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 12/14] gdb: add remove-symbol-file command completion Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 13/14] gdb: allow quoted filenames for commands that have custom completion Andrew Burgess
2024-08-30 11:33           ` [PATCHv6 14/14] gdb: 'target ...' commands now expect quoted/escaped filenames Andrew Burgess
2024-09-07 19:57           ` [PATCHv6 00/14] Further filename completion improvements Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v84m4hps.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox