From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id CC3E73857355; Fri, 22 Apr 2022 17:51:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC3E73857355 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: improved EOF handling when using readline 7 X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 152a17495663ae9099d5efdc38322c9ad348014e X-Git-Newrev: b913bd98ce81a1600463f9a8a30db04d44b64a47 Message-Id: <20220422175133.CC3E73857355@sourceware.org> Date: Fri, 22 Apr 2022 17:51:33 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 17:51:33 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db913bd98ce81= a1600463f9a8a30db04d44b64a47 commit b913bd98ce81a1600463f9a8a30db04d44b64a47 Author: Andrew Burgess Date: Tue Mar 29 15:07:04 2022 +0100 gdb: improved EOF handling when using readline 7 =20 In this commit: =20 commit a6b413d24ccc5d76179bab866834e11fd6fec294 Date: Fri Mar 11 14:44:03 2022 +0000 =20 gdb: work around prompt corruption caused by bracketed-paste-mode =20 a change was made to GDB to work around bug PR gdb/28833. The consequence of this work around is that, when bracketed paste mode is enabled in readline, and GDB is quit by sending EOF, then the output will look like this: =20 (gdb) quit =20 The ideal output, which is what we get when bracketed paste mode is off, is this: =20 (gdb) quit =20 The reason we need to make this change is explained in the original commit referenced above. What isn't mentioned in the above commit, is that the change that motivated this work around was only added in readline 8, older versions of readline don't require the change. =20 In later commits in this series I will add a fix to GDB's in-tree copy of readline (this fix is back-ported from upstream readline), and then I will change GDB so that, when using the (patched) in-tree readline, we can have the ideal output in all cases. =20 However, GDB can be built against the system readline. When this is done, and the system readline is version 8, then we will still have to use the work around (two line) style output. =20 But, if GDB is built against the system readline, and the system readline is an older version 7 readline, then there's no reason why we can't have the ideal output, after all, readline 7 doesn't include the change that we need to work around. =20 This commit changes GDB so that, when using readline 7 we get the ideal output in all cases. This change is trivial (a simple check against the readline version number) so I think this should be fine to include. =20 For testing this commit, you need to configure GDB including the '--with-system-readline' flag, and build GDB on a system that uses readline 7, for example 'Ubuntu 18.04'. Then run the test 'gdb.base/eof-exit.exp', you should expect everything to PASS. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28833 Diff: --- gdb/event-top.c | 3 ++- gdb/testsuite/gdb.base/eof-exit.exp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index b628f0397cb..6261020b4ac 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -780,7 +780,8 @@ command_line_handler (gdb::unique_xmalloc_ptr &&r= l) we first print '\n' to move to the next line, and then print the quit. This isn't ideal, but avoids corrupting the prompt. */ const char *value =3D rl_variable_value ("enable-bracketed-paste"); - if (value !=3D nullptr && strcmp (value, "on") =3D=3D 0) + if (value !=3D nullptr && strcmp (value, "on") =3D=3D 0 + && ((rl_readline_version >> 8) & 0xff) > 0x07) printf_unfiltered ("\n"); printf_unfiltered ("quit\n"); execute_command ("quit", 1); diff --git a/gdb/testsuite/gdb.base/eof-exit.exp b/gdb/testsuite/gdb.base/e= of-exit.exp index 2d9530ccebe..ad5f33d2f10 100644 --- a/gdb/testsuite/gdb.base/eof-exit.exp +++ b/gdb/testsuite/gdb.base/eof-exit.exp @@ -49,7 +49,7 @@ proc run_test {} { # line after the 'quit', this catches that case. fail $gdb_test_name } - -re "$::gdb_prompt quit\[^\n\]*\r\n\[^\n\]*$" { + -re "$::gdb_prompt \[^\n\r\]*quit\[^\n\]*\r\n\[^\n\]*$" { pass $gdb_test_name } eof {