diff options
Diffstat (limited to 'gdb/tui/tui.c')
-rw-r--r-- | gdb/tui/tui.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 781ec85..5883d6c 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -1,6 +1,6 @@ /* General functions for the WDB TUI. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -40,6 +40,7 @@ #include "terminal.h" #include "top.h" #include "ui.h" +#include "observable.h" #include <fcntl.h> @@ -60,13 +61,18 @@ show_tui_debug (struct ui_file *file, int from_tty, } /* This redefines CTRL if it is not already defined, so it must come - after terminal state releated include files like <term.h> and + after terminal state related include files like <term.h> and "gdb_curses.h". */ #include "readline/readline.h" /* Tells whether the TUI is active or not. */ bool tui_active = false; -static bool tui_finish_init = true; + +/* Tells whether the TUI should do deferred curses initialization. + If TRIBOOL_TRUE, then yes. If TRIBOOL_FALSE. then no (because + initialization is already done). If TRIBOOL_UNKNOWN, then no (because + initialization failed). */ +static tribool tui_finish_init = TRIBOOL_TRUE; enum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE; @@ -386,10 +392,18 @@ tui_enable (void) if (tui_active) return; + tui_batch_rendering defer; + /* To avoid to initialize curses when gdb starts, there is a deferred curses initialization. This initialization is made only once and the first time the curses mode is entered. */ - if (tui_finish_init) + if (tui_finish_init == TRIBOOL_UNKNOWN) + { + /* Initialization failed before, just throw a generic error, don't try + again. */ + error (_("Cannot enable the TUI")); + } + else if (tui_finish_init == TRIBOOL_TRUE) { WINDOW *w; SCREEN *s; @@ -409,6 +423,9 @@ tui_enable (void) if (!gdb_stderr->isatty ()) error (_("Cannot enable the TUI when output is not a terminal")); + /* Don't try initialization again. */ + tui_finish_init = TRIBOOL_UNKNOWN; + s = newterm (NULL, stdout, stdin); #ifdef __MINGW32__ /* The MinGW port of ncurses requires $TERM to be unset in order @@ -467,7 +484,7 @@ tui_enable (void) tui_set_win_focus_to (tui_src_win ()); keypad (tui_cmd_win ()->handle.get (), TRUE); wrefresh (tui_cmd_win ()->handle.get ()); - tui_finish_init = false; + tui_finish_init = TRIBOOL_FALSE; } else { @@ -509,6 +526,8 @@ tui_enable (void) /* Update gdb's knowledge of its terminal. */ gdb_save_tty_state (); tui_update_gdb_sizes (); + + gdb::observers::tui_enabled.notify (true); } /* Leave the tui mode. @@ -547,6 +566,8 @@ tui_disable (void) tui_active = false; tui_update_gdb_sizes (); + + gdb::observers::tui_enabled.notify (false); } /* Command wrapper for enabling tui mode. */ @@ -568,7 +589,7 @@ tui_disable_command (const char *args, int from_tty) void tui_show_assembly (struct gdbarch *gdbarch, CORE_ADDR addr) { - tui_suppress_output suppress; + tui_batch_rendering suppress; tui_add_win_to_layout (DISASSEM_WIN); tui_update_source_windows_with_addr (gdbarch, addr); } @@ -597,9 +618,7 @@ tui_get_command_dimension (unsigned int *width, return true; } -void _initialize_tui (); -void -_initialize_tui () +INIT_GDB_FILE (tui) { struct cmd_list_element **tuicmd; |