Fix crash when exiting TUI with gdb -tui
PR tui/25348 points out that, when "gdb -tui" is used, then exiting
the TUI will cause a crash.
This happens because tui_setup_io stashes some readline variables --
but because this happens before readline is initialized, some of these
are NULL. Then, when exiting the TUI, the NULL values are "restored",
causing a crash in readline.
This patch fixes the problem by ensuring that readline is initialized
first. Back in commit
11061048d ("Give a name to the TUI SingleKey
keymap"), a call to rl_initialize was removed from
tui_initialize_readline; this patch resurrects the call, but moves it
to the end of the function, so as not to remove the ability to modify
the SingleKey map from .inputrc.
gdb/ChangeLog
2020-06-16 Tom Tromey <tom@tromey.com>
PR tui/25348:
* tui/tui.c (tui_ensure_readline_initialized): Rename from
tui_initialize_readline. Only run once. Call rl_initialize.
* tui/tui.h (tui_ensure_readline_initialized): Rename from
tui_initialize_readline.
* tui/tui-io.c (tui_setup_io): Call
tui_ensure_readline_initialized.
* tui/tui-interp.c (tui_interp::init): Update.