* [PATCH] gdb/readline: fix extra 'quit' message problem
@ 2022-04-26 14:25 Andrew Burgess
2022-04-30 10:08 ` Andrew Burgess
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-04-26 14:25 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
After these two commits:
commit 4fb7bc4b147fd30b781ea2dad533956d0362295a
Date: Mon Mar 7 13:49:21 2022 +0000
readline: back-port changes needed to properly detect EOF
commit 91395d97d905c31ac38513e4aaedecb3b25e818f
Date: Tue Feb 15 17:28:03 2022 +0000
gdb: handle bracketed-paste-mode and EOF correctly
It was observed that, if a previous command is selected at the
readline prompt using the up arrow key, then when the command is
accepted (by pressing return) an unexpected 'quit' message will be
printed by GDB. Here's an example session:
(gdb) p 123
$1 = 123
(gdb) p 123
quit
$2 = 123
(gdb)
In this session the section 'p 123' was entered not by typing 'p 123',
but by pressing the up arrow key to select the previous command. It
is important that the up arrow key is used, typing Ctrl-p will not
trigger the bug.
The problem here appears to be readline's EOF detection when handling
multi-character input sequences. I have raised this issue on the
readline mailing list here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00012.html
This patch includes a test for this issue as well as a proposed
readline patch (that is included in the thread linked above). I don't
know if the above patch will be accepted into readline, or if there
will be some alternative fix for upstream readline.
My proposal for now is to wait a couple of days and see if there's a
quick turn around on this issue in upstream readline. If there is
then I'll update this patch inline with upstream readline and merge
it.
If there's not a quick resolution in upstream readline, then I propose
to merge this patch which will resolve the immediate issue we see in
gdb master, then we can wait for readline to fix the issue properly,
hopefully that will be done in time for the 8.2 readline release.
If this problem isn't fixed in readline 8.2 then we may have to back
out the 91395d97d90 commit (mentioned above) as that's the one that is
responsible for printing the unexpected "quit" message.
---
gdb/testsuite/gdb.base/readline.exp | 10 ++++++++++
readline/readline/callback.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp
index 4d770336eb6..caf3b4acb62 100644
--- a/gdb/testsuite/gdb.base/readline.exp
+++ b/gdb/testsuite/gdb.base/readline.exp
@@ -183,6 +183,16 @@ save_vars { env(TERM) } {
}
}
+ # Use the up arrow to select a previous command. Check that
+ # no unexpected output is added between the previously
+ # selected command, and the output of that command.
+ gdb_test "print 123" "\\\$\[0-9\]* = 123"
+ gdb_test_multiple "\033\[A" "use up arrow" {
+ -re -wrap "print 123\r\n\\\$\[0-9\]* = 123" {
+ pass $gdb_test_name
+ }
+ }
+
# Now repeat the first test with a history file that fills the entire
# history list.
diff --git a/readline/readline/callback.c b/readline/readline/callback.c
index 58b84d2e2ad..0f51a5e4f0f 100644
--- a/readline/readline/callback.c
+++ b/readline/readline/callback.c
@@ -271,7 +271,7 @@ rl_callback_read_char (void)
}
/* Make sure application hooks can see whether we saw EOF. */
- if (rl_eof_found = eof)
+ if (rl_eof_found = (rl_done && eof))
RL_SETSTATE(RL_STATE_EOF);
if (rl_done)
--
2.25.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/readline: fix extra 'quit' message problem
2022-04-26 14:25 [PATCH] gdb/readline: fix extra 'quit' message problem Andrew Burgess
@ 2022-04-30 10:08 ` Andrew Burgess
2022-05-07 9:56 ` Andrew Burgess
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2022-04-30 10:08 UTC (permalink / raw)
To: gdb-patches
There's been some feedback on the readline list. I've updated the patch
accordingly.
My current plan is to wait until next week (hopefully the fix will be
merged to readline by then) before merging this patch.
Thanks,
Andrew
---
commit f84f51dd190c090c65af4a89123d9be87bd09aa7
Author: Andrew Burgess <aburgess@redhat.com>
Date: Tue Apr 26 15:08:02 2022 +0100
gdb/readline: fix extra 'quit' message problem
After these two commits:
commit 4fb7bc4b147fd30b781ea2dad533956d0362295a
Date: Mon Mar 7 13:49:21 2022 +0000
readline: back-port changes needed to properly detect EOF
commit 91395d97d905c31ac38513e4aaedecb3b25e818f
Date: Tue Feb 15 17:28:03 2022 +0000
gdb: handle bracketed-paste-mode and EOF correctly
It was observed that, if a previous command is selected at the
readline prompt using the up arrow key, then when the command is
accepted (by pressing return) an unexpected 'quit' message will be
printed by GDB. Here's an example session:
(gdb) p 123
$1 = 123
(gdb) p 123
quit
$2 = 123
(gdb)
In this session the second 'p 123' was entered not by typing 'p 123',
but by pressing the up arrow key to select the previous command. It
is important that the up arrow key is used, typing Ctrl-p will not
trigger the bug.
The problem here appears to be readline's EOF detection when handling
multi-character input sequences. I have raised this issue on the
readline mailing list here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00012.html
a solution has been proposed here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00016.html
This patch includes a test for this issue as well as the proposed
readline patch. Hopefully the above patch (or something equivalent)
will be make it into the readline 8.2 release.
If the above fix (or something equivalent) does make it into readline
8.2 then we can back-port the fix (or just merge 8.2 into our tree).
However, if 8.2 is released without this fix then we may need to
consider backing out commit 91395d97d90 as that is the one responsible
for the extra "quit" message.
I'm going to sit on this patch for a few more days, hopefully the
above fix will be merged into readline in that time, in which case
I'll merge this patch.
diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp
index 4d770336eb6..caf3b4acb62 100644
--- a/gdb/testsuite/gdb.base/readline.exp
+++ b/gdb/testsuite/gdb.base/readline.exp
@@ -183,6 +183,16 @@ save_vars { env(TERM) } {
}
}
+ # Use the up arrow to select a previous command. Check that
+ # no unexpected output is added between the previously
+ # selected command, and the output of that command.
+ gdb_test "print 123" "\\\$\[0-9\]* = 123"
+ gdb_test_multiple "\033\[A" "use up arrow" {
+ -re -wrap "print 123\r\n\\\$\[0-9\]* = 123" {
+ pass $gdb_test_name
+ }
+ }
+
# Now repeat the first test with a history file that fills the entire
# history list.
diff --git a/readline/readline/callback.c b/readline/readline/callback.c
index 58b84d2e2ad..93f23d97bc2 100644
--- a/readline/readline/callback.c
+++ b/readline/readline/callback.c
@@ -271,8 +271,11 @@ rl_callback_read_char (void)
}
/* Make sure application hooks can see whether we saw EOF. */
- if (rl_eof_found = eof)
- RL_SETSTATE(RL_STATE_EOF);
+ if (eof > 0)
+ {
+ rl_eof_found = eof;
+ RL_SETSTATE(RL_STATE_EOF);
+ }
if (rl_done)
{
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/readline: fix extra 'quit' message problem
2022-04-30 10:08 ` Andrew Burgess
@ 2022-05-07 9:56 ` Andrew Burgess
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2022-05-07 9:56 UTC (permalink / raw)
To: gdb-patches
The fix for the EOF detection has now been merged into upstream
readline. I've pushed the patch below that includes a test for this
issue and a back-port of the upstream fix.
Thanks,
Andrew
---
commit 8f3babfaf8ea582bed93fd6abcde7bfc96d3a8dd
Author: Andrew Burgess <aburgess@redhat.com>
Date: Tue Apr 26 15:08:02 2022 +0100
gdb/readline: fix extra 'quit' message problem
After these two commits:
commit 4fb7bc4b147fd30b781ea2dad533956d0362295a
Date: Mon Mar 7 13:49:21 2022 +0000
readline: back-port changes needed to properly detect EOF
commit 91395d97d905c31ac38513e4aaedecb3b25e818f
Date: Tue Feb 15 17:28:03 2022 +0000
gdb: handle bracketed-paste-mode and EOF correctly
It was observed that, if a previous command is selected at the
readline prompt using the up arrow key, then when the command is
accepted (by pressing return) an unexpected 'quit' message will be
printed by GDB. Here's an example session:
(gdb) p 123
$1 = 123
(gdb) p 123
quit
$2 = 123
(gdb)
In this session the second 'p 123' was entered not by typing 'p 123',
but by pressing the up arrow key to select the previous command. It
is important that the up arrow key is used, typing Ctrl-p will not
trigger the bug.
The problem here appears to be readline's EOF detection when handling
multi-character input sequences. I have raised this issue on the
readline mailing list here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00012.html
a solution has been proposed here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00016.html
This patch includes a test for this issue as well as a back-port of
(the important bits of) readline commit:
commit 2ef9cec8c48ab1ae3a16b1874a49bd1f58eaaca1
Date: Wed May 4 11:18:04 2022 -0400
fix for setting RL_STATE_EOF in callback mode
That commit also includes some updates to the readline documentation
and tests that I have not included in this commit.
With this commit in place the unexpected 'quit' messages are resolved.
diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp
index 4d770336eb6..caf3b4acb62 100644
--- a/gdb/testsuite/gdb.base/readline.exp
+++ b/gdb/testsuite/gdb.base/readline.exp
@@ -183,6 +183,16 @@ save_vars { env(TERM) } {
}
}
+ # Use the up arrow to select a previous command. Check that
+ # no unexpected output is added between the previously
+ # selected command, and the output of that command.
+ gdb_test "print 123" "\\\$\[0-9\]* = 123"
+ gdb_test_multiple "\033\[A" "use up arrow" {
+ -re -wrap "print 123\r\n\\\$\[0-9\]* = 123" {
+ pass $gdb_test_name
+ }
+ }
+
# Now repeat the first test with a history file that fills the entire
# history list.
diff --git a/readline/readline/callback.c b/readline/readline/callback.c
index 58b84d2e2ad..93f23d97bc2 100644
--- a/readline/readline/callback.c
+++ b/readline/readline/callback.c
@@ -271,8 +271,11 @@ rl_callback_read_char (void)
}
/* Make sure application hooks can see whether we saw EOF. */
- if (rl_eof_found = eof)
- RL_SETSTATE(RL_STATE_EOF);
+ if (eof > 0)
+ {
+ rl_eof_found = eof;
+ RL_SETSTATE(RL_STATE_EOF);
+ }
if (rl_done)
{
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-07 9:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 14:25 [PATCH] gdb/readline: fix extra 'quit' message problem Andrew Burgess
2022-04-30 10:08 ` Andrew Burgess
2022-05-07 9:56 ` Andrew Burgess
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).