• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisiona350efd4fb368a35ada608f6bc26ccd3bed0ae6b (tree)
Zeit2020-06-17 09:02:20
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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.

Ändern Zusammenfassung

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
11 2020-06-16 Tom Tromey <tom@tromey.com>
22
3+ PR tui/25348:
4+ * tui/tui.c (tui_ensure_readline_initialized): Rename from
5+ tui_initialize_readline. Only run once. Call rl_initialize.
6+ * tui/tui.h (tui_ensure_readline_initialized): Rename from
7+ tui_initialize_readline.
8+ * tui/tui-io.c (tui_setup_io): Call
9+ tui_ensure_readline_initialized.
10+ * tui/tui-interp.c (tui_interp::init): Update.
11+
12+2020-06-16 Tom Tromey <tom@tromey.com>
13+
314 * tui/tui-layout.c (tui_layout_split::remove_windows): Fix logic.
415 Also preserve the status window.
516
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -244,7 +244,7 @@ tui_interp::init (bool top_level)
244244 tui_initialize_io ();
245245 tui_initialize_win ();
246246 if (gdb_stdout->isatty ())
247- tui_initialize_readline ();
247+ tui_ensure_readline_initialized ();
248248 }
249249
250250 void
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -746,6 +746,10 @@ tui_setup_io (int mode)
746746
747747 if (mode)
748748 {
749+ /* Ensure that readline has been initialized before saving any
750+ of its variables. */
751+ tui_ensure_readline_initialized ();
752+
749753 /* Redirect readline to TUI. */
750754 tui_old_rl_redisplay_function = rl_redisplay_function;
751755 tui_old_rl_deprep_terminal = rl_deprep_term_function;
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -268,8 +268,14 @@ tui_set_key_mode (enum tui_key_mode mode)
268268 /* Initialize readline and configure the keymap for the switching
269269 key shortcut. */
270270 void
271-tui_initialize_readline (void)
271+tui_ensure_readline_initialized ()
272272 {
273+ static bool initialized;
274+
275+ if (initialized)
276+ return;
277+ initialized = true;
278+
273279 int i;
274280 Keymap tui_ctlx_keymap;
275281
@@ -325,6 +331,9 @@ tui_initialize_readline (void)
325331 rl_bind_key_in_map ('q', tui_rl_next_keymap, tui_keymap);
326332 rl_bind_key_in_map ('s', tui_rl_next_keymap, emacs_ctlx_keymap);
327333 rl_bind_key_in_map ('s', tui_rl_next_keymap, tui_ctlx_keymap);
334+
335+ /* Initialize readline after the above. */
336+ rl_initialize ();
328337 }
329338
330339 /* Return the TERM variable from the environment, or "<unset>"
--- a/gdb/tui/tui.h
+++ b/gdb/tui/tui.h
@@ -49,9 +49,9 @@ extern bool tui_is_window_visible (enum tui_win_type type);
4949 extern bool tui_get_command_dimension (unsigned int *width,
5050 unsigned int *height);
5151
52-/* Initialize readline and configure the keymap for the switching
53- key shortcut. */
54-extern void tui_initialize_readline (void);
52+/* Initialize readline and configure the keymap for the switching key
53+ shortcut. May be called more than once without issue. */
54+extern void tui_ensure_readline_initialized ();
5555
5656 /* Enter in the tui mode (curses). */
5757 extern void tui_enable (void);