public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
       [not found] <509346577.1585683.1591617067795.ref@mail.yahoo.com>
@ 2020-06-08 11:51 ` Hannes Domani
  2020-06-08 14:41   ` Andrew Burgess
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Domani @ 2020-06-08 11:51 UTC (permalink / raw)
  To: Gdb-patches

Ping.

Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:

> Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
>
> Ping.
>
> > If you press Ctrl-C during an incremental search of the readline history, the
> > prompt is reset, but readline is still in the incremental search mode.
> >
> > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > disables the incremental search mode.
> >
> > gdb/ChangeLog:
> >
> > 2020-04-25  Hannes Domani  <ssbssa@yahoo.de>
> >
> >     PR gdb/21690
> >     * main.c (start_event_loop): Call rl_callback_sigcleanup.
> > ---
> > gdb/main.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/gdb/main.c b/gdb/main.c
> > index 59cb14161b..a8c1d3ccb1 100644
> > --- a/gdb/main.c
> > +++ b/gdb/main.c
> > @@ -55,6 +55,8 @@
> > #include "gdbsupport/alt-stack.h"
> > #include "observable.h"
> >
> > +#include "readline/readline.h"
> > +
> > /* The selected interpreter.  This will be used as a set command
> >     variable, so it should always be malloc'ed - since
> >     do_setshow_command will free it.  */
> > @@ -371,6 +373,8 @@ start_event_loop ()
> >         in a messed-up state.  Reset it here.  */
> >       current_ui->prompt_state = PROMPT_NEEDED;
> >       gdb::observers::command_error.notify ();
> > +      /* Clean up internal state of the callback interface.  */
> > +      rl_callback_sigcleanup ();
> >       /* This call looks bizarre, but it is required.  If the user
> >         entered a command that caused an error,
> >         after_char_processing_hook won't be called from
> > --
> > 2.26.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
  2020-06-08 11:51 ` [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search Hannes Domani
@ 2020-06-08 14:41   ` Andrew Burgess
  2020-06-08 14:58     ` Hannes Domani
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Burgess @ 2020-06-08 14:41 UTC (permalink / raw)
  To: Hannes Domani; +Cc: Gdb-patches

* Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2020-06-08 11:51:07 +0000]:

> Ping.
> 
> Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> 
> > Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> >
> > Ping.
> >
> > > If you press Ctrl-C during an incremental search of the readline history, the
> > > prompt is reset, but readline is still in the incremental search mode.
> > >
> > > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > > disables the incremental search mode.

I didn't look into the implementation of this, but something seems a
little odd, though I don't know if this is just my machine setup....

I start a GDB session, and do this:

  (gdb) echo hello\n
  hello

At this point I start a reverse search, so I type:

  <ctrl+r>
  echo
  <ctrl+c>

Now I'm left in this situation:

  (gdb) echo hello\n
        ^
        '-- Prompt is here.

So, whatever I was in the process of finding when I hit Ctrl+C is left
on my prompt line in an editable state.

This is different from the behaviour I see in, for example, bash,
where when I Ctrl+C the reverse search is aborted and I'm dropped back
to an empty prompt.

Which behaviour do you see?

Which behaviour do you expect to see?

Thanks,
Andrew



> > >
> > > gdb/ChangeLog:
> > >
> > > 2020-04-25  Hannes Domani  <ssbssa@yahoo.de>
> > >
> > >     PR gdb/21690
> > >     * main.c (start_event_loop): Call rl_callback_sigcleanup.
> > > ---
> > > gdb/main.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/gdb/main.c b/gdb/main.c
> > > index 59cb14161b..a8c1d3ccb1 100644
> > > --- a/gdb/main.c
> > > +++ b/gdb/main.c
> > > @@ -55,6 +55,8 @@
> > > #include "gdbsupport/alt-stack.h"
> > > #include "observable.h"
> > >
> > > +#include "readline/readline.h"
> > > +
> > > /* The selected interpreter.  This will be used as a set command
> > >     variable, so it should always be malloc'ed - since
> > >     do_setshow_command will free it.  */
> > > @@ -371,6 +373,8 @@ start_event_loop ()
> > >         in a messed-up state.  Reset it here.  */
> > >       current_ui->prompt_state = PROMPT_NEEDED;
> > >       gdb::observers::command_error.notify ();
> > > +      /* Clean up internal state of the callback interface.  */
> > > +      rl_callback_sigcleanup ();
> > >       /* This call looks bizarre, but it is required.  If the user
> > >         entered a command that caused an error,
> > >         after_char_processing_hook won't be called from
> > > --
> > > 2.26.2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
  2020-06-08 14:41   ` Andrew Burgess
@ 2020-06-08 14:58     ` Hannes Domani
  2020-06-08 15:35       ` Andrew Burgess
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Domani @ 2020-06-08 14:58 UTC (permalink / raw)
  To: Gdb-patches

 Am Montag, 8. Juni 2020, 16:41:32 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:

> * Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2020-06-08 11:51:07 +0000]:
>
> > Ping.
> >
> > Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> >
> > > Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > >
> > > Ping.
> > >
> > > > If you press Ctrl-C during an incremental search of the readline history, the
> > > > prompt is reset, but readline is still in the incremental search mode.
> > > >
> > > > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > > > disables the incremental search mode.
>
> I didn't look into the implementation of this, but something seems a
> little odd, though I don't know if this is just my machine setup....
>
> I start a GDB session, and do this:
>
>   (gdb) echo hello\n
>   hello
>
> At this point I start a reverse search, so I type:
>
>   <ctrl+r>
>   echo
>   <ctrl+c>
>
> Now I'm left in this situation:
>
>   (gdb) echo hello\n
>         ^
>         '-- Prompt is here.
>
> So, whatever I was in the process of finding when I hit Ctrl+C is left
> on my prompt line in an editable state.
>
> This is different from the behaviour I see in, for example, bash,
> where when I Ctrl+C the reverse search is aborted and I'm dropped back
> to an empty prompt.
>
> Which behaviour do you see?

This is the behaviour I also see with this patch applied.


> Which behaviour do you expect to see?

I didn't compare with anything else, so my expectation was just that it
shouldn't be in this weird state where the prompt is empty, but readline
actually thinks it's still in the reverse search.


Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
  2020-06-08 14:58     ` Hannes Domani
@ 2020-06-08 15:35       ` Andrew Burgess
  2020-06-08 17:36         ` Hannes Domani
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Burgess @ 2020-06-08 15:35 UTC (permalink / raw)
  To: Hannes Domani; +Cc: Gdb-patches

* Hannes Domani <ssbssa@yahoo.de> [2020-06-08 14:58:50 +0000]:

>  Am Montag, 8. Juni 2020, 16:41:32 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:
> 
> > * Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2020-06-08 11:51:07 +0000]:
> >
> > > Ping.
> > >
> > > Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > >
> > > > Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > > >
> > > > Ping.
> > > >
> > > > > If you press Ctrl-C during an incremental search of the readline history, the
> > > > > prompt is reset, but readline is still in the incremental search mode.
> > > > >
> > > > > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > > > > disables the incremental search mode.
> >
> > I didn't look into the implementation of this, but something seems a
> > little odd, though I don't know if this is just my machine setup....
> >
> > I start a GDB session, and do this:
> >
> >   (gdb) echo hello\n
> >   hello
> >
> > At this point I start a reverse search, so I type:
> >
> >   <ctrl+r>
> >   echo
> >   <ctrl+c>
> >
> > Now I'm left in this situation:
> >
> >   (gdb) echo hello\n
> >         ^
> >         '-- Prompt is here.
> >
> > So, whatever I was in the process of finding when I hit Ctrl+C is left
> > on my prompt line in an editable state.
> >
> > This is different from the behaviour I see in, for example, bash,
> > where when I Ctrl+C the reverse search is aborted and I'm dropped back
> > to an empty prompt.
> >
> > Which behaviour do you see?
> 
> This is the behaviour I also see with this patch applied.
> 
> 
> > Which behaviour do you expect to see?
> 
> I didn't compare with anything else, so my expectation was just that it
> shouldn't be in this weird state where the prompt is empty, but readline
> actually thinks it's still in the reverse search.

I think we should end up back at the empty prompt.  That certainly
feels more natural after a Ctrl+C (to me anyway).

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
  2020-06-08 15:35       ` Andrew Burgess
@ 2020-06-08 17:36         ` Hannes Domani
  2020-06-08 19:45           ` Hannes Domani
  0 siblings, 1 reply; 6+ messages in thread
From: Hannes Domani @ 2020-06-08 17:36 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Gdb-patches

 Am Montag, 8. Juni 2020, 17:36:09 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:

> * Hannes Domani <ssbssa@yahoo.de> [2020-06-08 14:58:50 +0000]:
>
> >  Am Montag, 8. Juni 2020, 16:41:32 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:
> >
> > > * Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2020-06-08 11:51:07 +0000]:
> > >
> > > > Ping.
> > > >
> > > > Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > > >
> > > > > Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > > > >
> > > > > Ping.
> > > > >
> > > > > > If you press Ctrl-C during an incremental search of the readline history, the
> > > > > > prompt is reset, but readline is still in the incremental search mode.
> > > > > >
> > > > > > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > > > > > disables the incremental search mode.
> > >
> > > I didn't look into the implementation of this, but something seems a
> > > little odd, though I don't know if this is just my machine setup....
> > >
> > > I start a GDB session, and do this:
> > >
> > >   (gdb) echo hello\n
> > >   hello
> > >
> > > At this point I start a reverse search, so I type:
> > >
> > >   <ctrl+r>
> > >   echo
> > >   <ctrl+c>
> > >
> > > Now I'm left in this situation:
> > >
> > >   (gdb) echo hello\n
> > >         ^
> > >         '-- Prompt is here.
> > >
> > > So, whatever I was in the process of finding when I hit Ctrl+C is left
> > > on my prompt line in an editable state.
> > >
> > > This is different from the behaviour I see in, for example, bash,
> > > where when I Ctrl+C the reverse search is aborted and I'm dropped back
> > > to an empty prompt.
> > >
> > > Which behaviour do you see?
> >
> > This is the behaviour I also see with this patch applied.
> >
> >
> > > Which behaviour do you expect to see?
> >
> > I didn't compare with anything else, so my expectation was just that it
> > shouldn't be in this weird state where the prompt is empty, but readline
> > actually thinks it's still in the reverse search.
>
> I think we should end up back at the empty prompt.  That certainly
> feels more natural after a Ctrl+C (to me anyway).

I tried to implement that, and the best source I could find was this:
https://lists.gnu.org/archive/html/bug-readline/2016-04/msg00071.html

But I could not figure out a way that also works in TUI mode.

How does it work that the line is cleared when not in the reverse-search mode?


Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search
  2020-06-08 17:36         ` Hannes Domani
@ 2020-06-08 19:45           ` Hannes Domani
  0 siblings, 0 replies; 6+ messages in thread
From: Hannes Domani @ 2020-06-08 19:45 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Gdb-patches

 Am Montag, 8. Juni 2020, 19:37:05 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:

> Am Montag, 8. Juni 2020, 17:36:09 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:
>
> > * Hannes Domani <ssbssa@yahoo.de> [2020-06-08 14:58:50 +0000]:
> >
> > >  Am Montag, 8. Juni 2020, 16:41:32 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:
> > >
> > > > * Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2020-06-08 11:51:07 +0000]:
> > > >
> > > > > Ping.
> > > > >
> > > > > Am Freitag, 15. Mai 2020, 11:00:41 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > > > >
> > > > > > Am Samstag, 25. April 2020, 19:17:34 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
> > > > > >
> > > > > > Ping.
> > > > > >
> > > > > > > If you press Ctrl-C during an incremental search of the readline history, the
> > > > > > > prompt is reset, but readline is still in the incremental search mode.
> > > > > > >
> > > > > > > The call of rl_callback_sigcleanup cleans up the internal readline state, and
> > > > > > > disables the incremental search mode.
> > > >
> > > > I didn't look into the implementation of this, but something seems a
> > > > little odd, though I don't know if this is just my machine setup....
> > > >
> > > > I start a GDB session, and do this:
> > > >
> > > >   (gdb) echo hello\n
> > > >   hello
> > > >
> > > > At this point I start a reverse search, so I type:
> > > >
> > > >   <ctrl+r>
> > > >   echo
> > > >   <ctrl+c>
> > > >
> > > > Now I'm left in this situation:
> > > >
> > > >   (gdb) echo hello\n
> > > >         ^
> > > >         '-- Prompt is here.
> > > >
> > > > So, whatever I was in the process of finding when I hit Ctrl+C is left
> > > > on my prompt line in an editable state.
> > > >
> > > > This is different from the behaviour I see in, for example, bash,
> > > > where when I Ctrl+C the reverse search is aborted and I'm dropped back
> > > > to an empty prompt.
> > > >
> > > > Which behaviour do you see?
> > >
> > > This is the behaviour I also see with this patch applied.
> > >
> > >
> > > > Which behaviour do you expect to see?
> > >
> > > I didn't compare with anything else, so my expectation was just that it
> > > shouldn't be in this weird state where the prompt is empty, but readline
> > > actually thinks it's still in the reverse search.
> >
> > I think we should end up back at the empty prompt.  That certainly
> > feels more natural after a Ctrl+C (to me anyway).
>
> I tried to implement that, and the best source I could find was this:
> https://lists.gnu.org/archive/html/bug-readline/2016-04/msg00071.html
>
> But I could not figure out a way that also works in TUI mode.
>
> How does it work that the line is cleared when not in the reverse-search mode?

I figured that part out, the line is cleared by one of the observers:
gdb::observers::command_error.notify ();

So I moved rl_callback_sigcleanup in front of it, and the line is cleared
(kinda), but only after the current line is displayed, so now I get 2 prompts
on top of each other:

(reverse-i-search)`a': echo Quitn
(gdb) echo (gdb)

At this point I stopped for the day.


Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-08 19:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <509346577.1585683.1591617067795.ref@mail.yahoo.com>
2020-06-08 11:51 ` [PING^2][PATCH][PR gdb/21690] Fix interruption of command history search Hannes Domani
2020-06-08 14:41   ` Andrew Burgess
2020-06-08 14:58     ` Hannes Domani
2020-06-08 15:35       ` Andrew Burgess
2020-06-08 17:36         ` Hannes Domani
2020-06-08 19:45           ` Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).