This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: PATCH: PR tui/2173: Arrow keys no longer works in breakpoint command list
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Chet Ramey <chet dot ramey at case dot edu>
- Cc: "H. J. Lu" <hjl at lucon dot org>, GDB <gdb-patches at sources dot redhat dot com>, bug-readline at gnu dot org
- Date: Mon, 18 Dec 2006 00:45:31 +0100
- Subject: Re: PATCH: PR tui/2173: Arrow keys no longer works in breakpoint command list
- References: <20061121213205.GA13310@lucon.org> <20061128164658.GB20882@nevyn.them.org> <20061128165844.GA13667@lucon.org> <20061202184344.GA2197@lucon.org> <4571CF2A.3040608@case.edu> <20061202221541.GA9776@lucon.org> <45725FC9.9070304@case.edu>
On Sun, 03 Dec 2006 06:25:29 +0100, Chet Ramey wrote:
...
> More appropriate in the sense that the application controls the state
> and switches between the callback and synchronous readline modes.
> Since it's the app that's supposed to be calling into readline when in
> callback mode anyway, I think this patch will work better.
Chet, is it right it is more a design than implementation problem of readline?
readline cannot determine how many nested readline calls have been abandoned by
signal handler's longjmp (). Therefore it cannot determine if the current mode
(the last unabandoned call) is a callback or synchronous one.
The sample code should be readline documentation compliant, still the called
function `_rl_next_macro_key' has undeterministic value of
`RL_ISSTATE (RL_STATE_CALLBACK)'.
Also any longjmp () from inside a signal handler is too dangerous as the data
structures are not locked against signals. The signal handler should only set
some flag. And the synchronous readline () function should be never used if
one needs to quit the input mode by SIGINT (as one cannot abort readline () if
not using the dangerous longjmp ()).
IMO the right way is to stop using longjmp from GDB's signal handlers.
Therefore to always use callbacked readline and stop the loop if detected
a flag set by the installed signal handler.
Thanks for info,
Jan
------------------------------------------------------------------------------
main ()
{
if (setjmp (buf_A))
{
rl_read_key (); /* -> _rl_next_macro_key () */
}
signal (SIGINT, handle_SIGINT_at_A);
readline("mode-A");
...
}
handle_SIGINT_at_A ()
{
if (setjmp (buf_B))
{
rl_read_key (); /* -> _rl_next_macro_key () */
}
signal (SIGINT, handle_SIGINT_at_B);
rl_callback_handler_install ("mode-B", mode_B_command);
for (;;)
rl_callback_read_char ();
}
handle_SIGINT_at_B ()
{
if (rand () & 1)
longjmp (buf_A);
else
longjmp (buf_B);
}