+static jmp_buf gdb_readline_jmp_buf;
+
+static void
+gdb_readline_sigint_handler (int signum)
+{
+ gdb_assert (signum == SIGINT);
+ longjmp (gdb_readline_jmp_buf, 1);
+}
+
+static char *
+gdb_readline (const char *prompt)
+{
+ char *retval;
+ sighandler_t saved_handler;
+ sigset_t mask;
+ int i;
+
+ i = sigprocmask (SIG_SETMASK, NULL, &mask);
+ assert (i == 0);
+ saved_handler = signal (SIGINT, gdb_readline_sigint_handler);
+ if (setjmp (gdb_readline_jmp_buf) != 0)
+ {
+ rl_free_line_state ();
+ rl_cleanup_after_signal ();
+
+ /* GDB prints this. */
+ puts ("Quit");
+
+ i = sigprocmask (SIG_SETMASK, &mask, NULL);
+ assert (i == 0);
+ }
+ retval = readline (prompt);
+ saved_handler = signal (SIGINT, saved_handler);
+ gdb_assert (saved_handler == gdb_readline_sigint_handler);
+ return retval;
+}
+
+static int console_cb_rows, console_cb_columns, console_cb_row, console_cb_column;
+static bool console_cb_drop;
+