public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7
@ 2023-05-24 10:41 Tom de Vries
  2023-06-07 12:58 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-05-24 10:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

In commit faf01aee1d0 ("[gdb] Handle pending ^C after rl_callback_read_char")
we handled a problem (described in detail in that commit) for readline >= 8
using public readline functions rl_pending_signal and rl_check_signals.

For readline 7 (note that we require at least readline 7 so there's no need to
worry about readline 6), there was no fix though, because rl_check_signals was
not available.

Fix this by instead using the private readline function _rl_signal_handler.

There is precedent for using private readline variables and functions, but
it's something we want to get rid of (PR build/10723).  Nevertheless, I think
we can allow this specific instance because it's not used when building
against readline >= 8.

[ In the meanwhile, a fix was committed in the devel branch of the readline
repo, contained in commit 8d0c439 ("rollup of changes since readline-8.2"),
first proposed here (
https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00008.html ). ]

Tested on x86_64-linux, against system readline 7.0 on openSUSE Leap 15.4.

PR cli/27813
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27813
---
 gdb/event-top.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/event-top.c b/gdb/event-top.c
index 193ea5363ff..005ef4b7054 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -137,6 +137,9 @@ static struct async_signal_handler *async_sigterm_token;
    character is processed.  */
 void (*after_char_processing_hook) (void);
 \f
+#if RL_VERSION_MAJOR == 7
+EXTERN_C void _rl_signal_handler (int);
+#endif
 
 /* Wrapper function for calling into the readline library.  This takes
    care of a couple things:
@@ -203,8 +206,14 @@ gdb_rl_callback_read_char_wrapper_noexcept () noexcept
 	   pending signal.  I'm not sure if that's possible, but it seems
 	   better to handle the scenario than to assert.  */
 	rl_check_signals ();
+#elif RL_VERSION_MAJOR == 7
+      /* Unfortunately, rl_check_signals is not available.  Use private
+	 function _rl_signal_handler instead.  */
+
+      while (rl_pending_signal () != 0)
+	_rl_signal_handler (rl_pending_signal ());
 #else
-      /* Unfortunately, rl_check_signals is not available.  */
+#error "Readline major version >= 7 expected"
 #endif
       if (after_char_processing_hook)
 	(*after_char_processing_hook) ();

base-commit: 014a602b86f08de96fc80ef3f96a87db6cccad56
-- 
2.35.3


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

* Re: [PATCH] [gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7
  2023-05-24 10:41 [PATCH] [gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7 Tom de Vries
@ 2023-06-07 12:58 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2023-06-07 12:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

On 5/24/23 12:41, Tom de Vries via Gdb-patches wrote:
> In commit faf01aee1d0 ("[gdb] Handle pending ^C after rl_callback_read_char")
> we handled a problem (described in detail in that commit) for readline >= 8
> using public readline functions rl_pending_signal and rl_check_signals.
> 
> For readline 7 (note that we require at least readline 7 so there's no need to
> worry about readline 6), there was no fix though, because rl_check_signals was
> not available.
> 
> Fix this by instead using the private readline function _rl_signal_handler.
> 
> There is precedent for using private readline variables and functions, but
> it's something we want to get rid of (PR build/10723).  Nevertheless, I think
> we can allow this specific instance because it's not used when building
> against readline >= 8.
> 
> [ In the meanwhile, a fix was committed in the devel branch of the readline
> repo, contained in commit 8d0c439 ("rollup of changes since readline-8.2"),
> first proposed here (
> https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00008.html ). ]
> 

Committed.

Thanks,
- Tom


> Tested on x86_64-linux, against system readline 7.0 on openSUSE Leap 15.4.
> 
> PR cli/27813
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27813
> ---
>   gdb/event-top.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/event-top.c b/gdb/event-top.c
> index 193ea5363ff..005ef4b7054 100644
> --- a/gdb/event-top.c
> +++ b/gdb/event-top.c
> @@ -137,6 +137,9 @@ static struct async_signal_handler *async_sigterm_token;
>      character is processed.  */
>   void (*after_char_processing_hook) (void);
>   \f
> +#if RL_VERSION_MAJOR == 7
> +EXTERN_C void _rl_signal_handler (int);
> +#endif
>   
>   /* Wrapper function for calling into the readline library.  This takes
>      care of a couple things:
> @@ -203,8 +206,14 @@ gdb_rl_callback_read_char_wrapper_noexcept () noexcept
>   	   pending signal.  I'm not sure if that's possible, but it seems
>   	   better to handle the scenario than to assert.  */
>   	rl_check_signals ();
> +#elif RL_VERSION_MAJOR == 7
> +      /* Unfortunately, rl_check_signals is not available.  Use private
> +	 function _rl_signal_handler instead.  */
> +
> +      while (rl_pending_signal () != 0)
> +	_rl_signal_handler (rl_pending_signal ());
>   #else
> -      /* Unfortunately, rl_check_signals is not available.  */
> +#error "Readline major version >= 7 expected"
>   #endif
>         if (after_char_processing_hook)
>   	(*after_char_processing_hook) ();
> 
> base-commit: 014a602b86f08de96fc80ef3f96a87db6cccad56


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

end of thread, other threads:[~2023-06-07 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 10:41 [PATCH] [gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7 Tom de Vries
2023-06-07 12:58 ` Tom de Vries

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).