PATCH: PR tui/2173: Arrow keys no longer works in breakpoint command list

H. J. Lu
2006-11-21T21:32:23Z

The problem is callback in readline 5.1 is changed. When gdb readline
callback calls readline (), readline is really confused since although
it is called from gdb callback, it isn't really in callback state. This
kludge seems to work for me.

H.J.
----
2006-11-21 H.J. Lu <hongjiu.lu@intel.com>

PR tui/2173
* top.c (gdb_readline_wrapper): Unset and reset RL_STATE_CALLBACK
around readline if needed.

--- gdb/top.c.arrow 2006-07-21 07:46:53.000000000 -0700
+++ gdb/top.c 2006-11-21 13:20:04.000000000 -0800
@@ -724,6 +724,9 @@ The filename in which to record the comm
char *
gdb_readline_wrapper (char *prompt)
{
+ char *line;
+ int in_callback;
+
/* Set the hook that works in this case. */
if (after_char_processing_hook)
{
@@ -731,7 +734,19 @@ gdb_readline_wrapper (char *prompt)
after_char_processing_hook = NULL;
}

- return readline (prompt);
+ /* When we call readline, we have to make sure that readline isn't in
+ the callback state. Otherwise, it will get really confused.
+ PR tui/2173. */
+ in_callback = RL_ISSTATE (RL_STATE_CALLBACK);
+ if (in_callback)
+ RL_UNSETSTATE (RL_STATE_CALLBACK);
+
+ line = readline (prompt);
+
+ if (in_callback)
+ RL_SETSTATE (RL_STATE_CALLBACK);
+
+ return line;
}

\f