[5/6] gdb/tui: fix for debuginfod prompt while enabling the TUI
Commit Message
PR tui/31449 reports a SIGFPE when the debuginfod query happens while
enabling TUI using the "tui enable" command:
Thread 1 "gdb" received signal SIGFPE, Arithmetic exception.
0x0000000001021084 in tui_inject_newline_into_command_window () at /data/vries/gdb/src/gdb/tui/tui-io.c:1096
1096 py += px / tui_cmd_win ()->width;
due to divide-by-zero because tui_cmd_win ()->width == 0.
The corresponding backtrace is:
(gdb) bt
#0 0x0000000001021084 in tui_inject_newline_into_command_window () at gdb/tui/tui-io.c:1096
#1 0x0000000000fe65fd in gdb_readline_wrapper_line (line=...) at gdb/top.c:939
#2 0x0000000000944eef in gdb_rl_callback_handler (rl=0x2cc865a0 "n") at gdb/event-top.c:288
#3 0x0000000001175779 in rl_callback_read_char () at readline/readline/callback.c:302
#4 0x0000000000944bc3 in gdb_rl_callback_read_char_wrapper_sjlj () at gdb/event-top.c:197
#5 0x0000000000944cd4 in gdb_rl_callback_read_char_wrapper_noexcept () at gdb/event-top.c:240
#6 0x0000000000944d52 in gdb_rl_callback_read_char_wrapper (...) at gdb/event-top.c:252
#7 0x0000000001062352 in stdin_event_handler (error=0, client_data=0x2c865150) at gdb/ui.c:154
#8 0x0000000001a04edf in handle_file_event (file_ptr=0x2ccf8850, ready_mask=1) at gdbsupport/event-loop.cc:551
#9 0x0000000001a05522 in gdb_wait_for_event (block=1) at gdbsupport/event-loop.cc:672
#10 0x0000000001a043ff in gdb_do_one_event (mstimeout=-1) at gdbsupport/event-loop.cc:263
#11 0x00000000006d5480 in interp::do_one_event (this=0x2cc2af20, mstimeout=-1) at gdb/interps.h:93
#12 0x0000000000fe670d in gdb_readline_wrapper (prompt=0x2ccca4e0 "Enable debuginfod for this session? (y or [n]) ") at gdb/top.c:1033
#13 0x00000000010c6853 in defaulted_query(...) (...) at gdb/utils.c:844
#14 0x00000000010c6b8a in nquery (...) at gdb/utils.c:901
#15 0x00000000007a9324 in debuginfod_is_enabled () at gdb/debuginfod-support.c:268
#16 0x00000000007a950d in debuginfod_source_query (...) at gdb/debuginfod-support.c:311
#17 0x0000000000efc2c7 in open_source_file (s=0x2cc8f4b0) at gdb/source.c:1152
#18 0x0000000000efc619 in symtab_to_fullname (...) at gdb/source.c:1214
#19 0x0000000000f5ebb3 in find_line_symtab (...) at gdb/symtab.c:3287
#20 0x0000000000f5f0e5 in find_pc_for_line (...) at gdb/symtab.c:3391
#21 0x0000000001011f54 in tui_get_begin_asm_address (...) at gdb/tui/tui-disasm.c:404
#22 0x000000000104888d in tui_source_window_base::rerender (this=0x2cbdc570) at gdb/tui/tui-winsource.c:474
#23 0x0000000001028e81 in tui_win_info::resize (this=0x2cbdc570, height_=21, width_=127, origin_x_=0, origin_y_=0) at gdb/tui/tui-layout.c:299
#24 0x00000000010297d0 in tui_layout_window::apply (this=0x2cc50350, x_=0, y_=0, width_=127, height_=21, preserve_cmd_win_size_p=false) at gdb/tui/tui-layout.c:432
#25 0x000000000102bfea in tui_layout_split::apply (this=0x2caea920, x_=0, y_=0, width_=127, height_=33, preserve_cmd_win_size_p=false) at gdb/tui/tui-layout.c:1026
#26 0x0000000001028267 in tui_apply_current_layout (...) at gdb/tui/tui-layout.c:68
#27 0x0000000001028737 in tui_set_layout (layout=0x2c9b9e90) at gdb/tui/tui-layout.c:133
#28 0x0000000001028af5 in tui_set_initial_layout () at gdb/tui/tui-layout.c:209
#29 0x000000000104b795 in tui_enable () at gdb/tui/tui.c:496
#30 0x000000000104bab3 in tui_enable_command (args=0x0, from_tty=1) at gdb/tui/tui.c:591
#31 0x00000000006c5ffe in do_simple_func (args=0x0, from_tty=1, c=0x2c9bb2f0) at gdb/cli/cli-decode.c:94
#32 0x00000000006cc94f in cmd_func (cmd=0x2c9bb2f0, args=0x0, from_tty=1) at gdb/cli/cli-decode.c:2831
#33 0x0000000000fe53ad in execute_command (p=0x2c86699a "", from_tty=1) at gdb/top.c:563
#34 0x000000000094584d in command_handler (command=0x2c866990 "tui enable") at gdb/event-top.c:611
#35 0x0000000000945dfe in command_line_handler (rl=...) at gdb/event-top.c:844
#36 0x000000000101e916 in tui_command_line_handler (rl=...) at gdb/tui/tui-interp.c:101
#37 0x0000000000944eef in gdb_rl_callback_handler (rl=0x2cc86a30 "tui enable") at gdb/event-top.c:288
#38 0x0000000001175779 in rl_callback_read_char () at readline/readline/callback.c:302
#39 0x0000000000944bc3 in gdb_rl_callback_read_char_wrapper_sjlj () at gdb/event-top.c:197
#40 0x0000000000944cd4 in gdb_rl_callback_read_char_wrapper_noexcept () at gdb/event-top.c:240
#41 0x0000000000944d52 in gdb_rl_callback_read_char_wrapper (...) at gdb/event-top.c:252
#42 0x0000000001062352 in stdin_event_handler (error=0, client_data=0x2c865150) at gdb/ui.c:154
#43 0x0000000001a04edf in handle_file_event (file_ptr=0x2ccf8850, ready_mask=1) at gdbsupport/event-loop.cc:551
#44 0x0000000001a05522 in gdb_wait_for_event (block=1) at gdbsupport/event-loop.cc:672
#45 0x0000000001a043ff in gdb_do_one_event (mstimeout=-1) at gdbsupport/event-loop.cc:263
#46 0x00000000006d5480 in interp::do_one_event (this=0x2cc2af20, mstimeout=-1) at gdb/interps.h:93
#47 0x0000000000b77f25 in start_event_loop () at gdb/main.c:403
#48 0x0000000000b78113 in captured_command_loop () at gdb/main.c:468
#49 0x0000000000b7a07c in captured_main (context=0x7fff660b9e60) at gdb/main.c:1381
#50 0x0000000000b7a178 in gdb_main (args=0x7fff660b9e60) at gdb/main.c:1400
#51 0x0000000000419705 in main (argc=5, argv=0x7fff660b9f98) at gdb/gdb.c:38
(gdb)
The problem is that while the TUI is being enabled for the first time,
none of the TUI windows yet exist. As each window is created its
contents are rendered (i.e. filled in based on GDB's state), which for
some windows can trigger an interactive prompt, in this case a missing
source file triggers a debuginfod prompt while trying to render the
`src` window.
The interactive prompt will be written to the `cmd` window, but at
this point the `cmd` window has not yet been created.
There have been several different attempts to fix this issue:
1. https://inbox.sourceware.org/gdb-patches/20240312215334.37888-1-amerey@redhat.com
2. https://inbox.sourceware.org/gdb-patches/20260114172833.1824823-1-tdevries@suse.de
3. https://inbox.sourceware.org/gdb-patches/20260116104313.2704994-1-tdevries@suse.de
4. https://inbox.sourceware.org/gdb-patches/20260221101818.2678136-1-tdevries@suse.de
5. https://inbox.sourceware.org/gdb-patches/20260314173737.1436116-1-tdevries@suse.de
6. https://inbox.sourceware.org/gdb-patches/20260417075719.852558-1-tdevries@suse.de
The patch presented here is similar to what was presented in (3)
above, but I think the implementation is maybe a little simpler.
Additionally, all but (6) of the above patches don't address issues
related to using multi-key combinations like 'C-x C-a' to enable TUI
mode, and that patch just takes the (admittedly safe) approach of
preventing the user from activating the TUI using a multi-key
combination if debuginfod is in ASK mode (and so could trigger an
interactive prompt).
This patch doesn't address the multi-key problem, that is left for the
next patch in this series.
This patch ensures that the `cmd` window always exists before
rendering the windows (i.e. filling in their content). This is done
by introducing a tui_defer_rerender global which is set in tui_enable,
and checked in tui_win_info::resize. Then, prior to the prompt being
displayed, if the flag is set, we render the contents of all visible
windows. This can trigger a secondary prompt (e.g. the debuginfod
prompt), but by this point the `cmd` window exists, and can display
the prompt.
The debuginfod-query.exp test included here is based on the test Tom
de Vries wrote for one of his patches listed above, but extended to
cover some additional cases. The activate-with-key-combo.exp test is
new for this series.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31449
Co-Authored-By: Tom de Vries <tdevries@suse.de>
---
.../gdb.tui/activate-with-key-combo.c | 22 ++
.../gdb.tui/activate-with-key-combo.exp | 83 ++++++
gdb/testsuite/gdb.tui/debuginfod-query.c | 22 ++
gdb/testsuite/gdb.tui/debuginfod-query.exp | 245 ++++++++++++++++++
gdb/tui/tui-hooks.c | 21 +-
gdb/tui/tui-layout.c | 3 +-
gdb/tui/tui.c | 11 +
gdb/tui/tui.h | 5 +
8 files changed, 410 insertions(+), 2 deletions(-)
create mode 100644 gdb/testsuite/gdb.tui/activate-with-key-combo.c
create mode 100644 gdb/testsuite/gdb.tui/activate-with-key-combo.exp
create mode 100644 gdb/testsuite/gdb.tui/debuginfod-query.c
create mode 100644 gdb/testsuite/gdb.tui/debuginfod-query.exp
new file mode 100644
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2026 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,83 @@
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Exercise the multi-key combinations (e.g. 'C-x C-a') as a means to
+# activate TUI mode. After activating TUI mode check that GDB is
+# still responsive, and output shows up in the CMD window.
+
+tuiterm_env
+
+require allow_tui_tests
+
+standard_testfile
+
+if {[build_executable "build executable" ${testfile} ${srcfile}] == -1} {
+ return
+}
+
+# Check that readline is in use.
+clean_restart
+if { ![readline_is_used] } {
+ unsupported "readline is required"
+ return
+}
+
+# Use KEY to activate TUI mode, where KEY should be a multi-key
+# combination, e.g. 'C-x C-a' expressed as an escape sequence,
+# e.g. "\030\001". Wait for the GDB prompt to be displayed then type
+# a single character 'q'. Check that the character shows up on the
+# screen then cancel the 'q' with Ctrl-C. Finally send a basic print
+# command to GDB to ensure everything is still working and
+# responsive.
+proc run_test { key } {
+ Term::clean_restart 24 80 $::testfile
+
+ if {![Term::prepare_for_tui]} {
+ return
+ }
+
+ send_gdb $key
+
+ Term::wait_for ""
+
+ gdb_assert {[Term::check_region_contents_p 0 16 5 1 \
+ [string_to_regexp "(gdb)"]]} \
+ "check prompt is where we want it"
+
+ send_gdb "q"
+
+ gdb_assert {[Term::wait_for_region_contents 0 16 80 1 q]} \
+ "the 'q' key appears in the terminal"
+
+ # Send Ctrl-c, cancelling the 'q' we typed.
+ send_gdb "\003"
+
+ gdb_assert {[Term::wait_for_region_contents 0 16 80 1 Quit]} \
+ "cancel the partial command"
+
+ Term::command "print 1"
+
+ gdb_assert {[Term::check_region_contents_p 0 18 80 1 " = 1"]} \
+ "wait for output of the print command"
+
+ Term::dump_screen
+}
+
+# Use different multi-key combinations to trigger a switch to TUI mode.
+foreach mk { \030\001 \030a \030A \0302 \0301 \030o } {
+ with_test_prefix "using key '[unprintable_to_octal $mk]'" {
+ run_test $mk
+ }
+}
new file mode 100644
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2026 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,245 @@
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that a debuginfod query during TUI initialization doesn't cause a
+# crash.
+
+require allow_tui_tests
+
+load_lib debuginfod-support.exp
+require allow_debuginfod_tests
+
+tuiterm_env
+
+standard_testfile
+
+if { [build_executable "build executable" $testfile $srcfile] == -1 } {
+ return
+}
+
+if {[section_get $binfile ".gnu_debuglink"] ne ""} {
+ unsupported "debug information has already been split out"
+ return
+}
+
+# Assume that GDB is in TUI mode, in the SRC layout, and that a
+# debuginfod prompt is currently active in the CMD window.
+#
+# Send ANSWER, either 'y' or 'n' to the debuginfod prompt, and check
+# how the SRC window updates. Answer 'y' and debuginfod should
+# download the source code, which should be displayed in the SRC
+# window. Answer 'n' and the 'No Source Available' message should
+# appear in the SRC window.
+#
+# Finally, send a basic 'print' command to GDB to check that the CMD
+# window is still responsive.
+proc src_layout_answer_prompt_check_screen { answer } {
+ set re \
+ [string_to_regexp \
+ {(y or [n]) }]
+
+ send_gdb "${answer}\n"
+ Term::wait_for ""
+ set re "${re}${answer}"
+ gdb_assert { [Term::check_region_contents_p 0 15 80 9 $re] } \
+ "wait for answer to interactive prompt to show"
+
+ if { $answer eq "n" } {
+ gdb_assert { [Term::check_region_contents_p 0 15 80 9 \
+ "Debuginfod has been disabled\\."] } \
+ "debuginfod has been disabled"
+
+ gdb_assert { [Term::check_region_contents_p 1 1 78 13 \
+ "\\\[ No Source Available \\\]"] } \
+ "source code was not downloaded"
+ } else {
+ gdb_assert { [Term::check_region_contents_p 0 15 80 9 \
+ "Debuginfod has been enabled\\."] } \
+ "debuginfod has been enabled"
+
+ gdb_assert { [Term::check_region_contents_p 1 1 78 13 \
+ "main \\(void\\)"] } \
+ "source code was downloaded"
+ }
+
+ # Check that prompt is responsive.
+ gdb_assert { [Term::command "print 1"] } "responsive prompt"
+}
+
+# Basic setup before running a test. Disable debuginfod progress
+# bars, setup the substitute path so GDB cannot find the source code,
+# and must instead, use debuginfod to get the source code.
+proc setup_for_debuginfod_test {} {
+ # Hide progress bars when downloading from debuginfod.
+ gdb_test_no_output "set progress-bars enabled off"
+
+ # Ensure GDB cannot find the source file. If available the source
+ # can be fetched from debuginfod.
+ gdb_test_no_output "set directories"
+ gdb_test_no_output "set substitute-path $::srcdir /dev/null" \
+ "set substitute-path"
+
+ # Reset the height, and enable the pager. We don't expect to see
+ # any pagination prompts from these tests, but some bugs trigger
+ # the pager at the wrong time, and we want to expose those.
+ gdb_test_no_output "set pagination on"
+ gdb_test_no_output "set height 24"
+}
+
+
+# Trigger a switch to TUI mode based on HOW, which is either 'command'
+# or 'keys'. We expect to see an interactive prompt while TUI is
+# being enabled, to which we reply ANSWER (either 'y' or 'n').
+#
+# When FILL_SCREEN is true we emit lots of lines at the CLI prompt
+# before switching to the TUI, at one point this would cause GDB to
+# incorrectly print the pagination prompt when switching to the TUI
+# via a multi-key combination (e.g. C-x C-a).
+proc_with_prefix run_switch_with_prompt_test { how answer fill_screen } {
+ Term::clean_restart 24 80 $::testfile
+
+ setup_for_debuginfod_test
+
+ if {![Term::prepare_for_tui]} {
+ return
+ }
+
+ Term::gen_prompt
+
+ # Print lots of content to the screen, but not enough to trigger
+ # the pager. The critical thing here is that we must print more
+ # lines than will fit in the TUI's CMD window. If the pager is
+ # not reset when switching to TUI mode, the first output in the
+ # TUI CMD window will trigger the pager, which is not correct.
+ if { $fill_screen } {
+ set cmd "echo "
+ for { set i 0 } { $i < 20 } { incr i } {
+ set cmd "${cmd}${i}\\n"
+ }
+ gdb_test $cmd ".*" \
+ "echo lots of lines"
+ }
+
+ # Trigger the switch to TUI mode.
+ if { $how eq "command" } {
+ send_gdb "tui enable\n"
+ } elseif { $how eq "keys" } {
+ send_gdb "\030\001"
+ } else {
+ perror "unknown test mode: $how"
+ }
+
+ set re \
+ [string_to_regexp \
+ {(y or [n]) }]
+ gdb_assert { [Term::wait_for_region_contents 0 17 80 3 $re] } \
+ "wait for initial interactive prompt"
+
+ foreach mk { \030\001 \0302 \0301 \030o \030q \030s } {
+ set before [Term::get_region 0 0 80 24 "\r\n"]
+ send_gdb $mk
+ set after [Term::get_region 0 0 80 24 "\r\n"]
+
+ gdb_assert { $before eq $after } \
+ "no changes after sending '[unprintable_to_octal $mk]'"
+ }
+
+ src_layout_answer_prompt_check_screen $answer
+}
+
+# Switch into TUI mode, but directly into ASM layout using "layout
+# asm". As the SRC window is not visible no debuginfod prompt should
+# be displayed.
+#
+# Now switch to SRC layout. If HOW is 'command' the use 'layout next'
+# to select the SRC layout. If HOW is 'keys' then use 'C-x 2' which
+# also selects the next layout, which is the SRC layout.
+#
+# As the SRC window is now visible, we should see a debuginfod prompt.
+# Use ANSWER (either 'y' or 'n') to answer the prompt, and check how
+# the SRC window updates as a result.
+proc_with_prefix run_switch_to_asm_test { how answer } {
+ Term::clean_restart 24 80 $::testfile
+
+ setup_for_debuginfod_test
+
+ if {![Term::prepare_for_tui]} {
+ return
+ }
+
+ Term::gen_prompt
+
+ # Switching to ASM layout doesn't require the source file, so
+ # shouldn't trigger the debuginfod prompt.
+ send_gdb "layout asm\n"
+ Term::wait_for ""
+
+ # Now switching to the next layout, which should be the SRC
+ # layout. The SRC layout needs the source code, so this should
+ # trigger the debuginfod prompt.
+ if { $how eq "command" } {
+ send_gdb "layout next\n"
+ } elseif { $how eq "keys" } {
+ send_gdb "\0302"
+ } else {
+ perror "unknown test mode: $how"
+ }
+
+ set re \
+ [string_to_regexp \
+ {(y or [n]) }]
+ gdb_assert { [Term::wait_for_region_contents 0 18 80 3 $re] } \
+ "wait for debuginfod interactive prompt"
+
+ src_layout_answer_prompt_check_screen $answer
+}
+
+# Setup directory for the debuginfod server to serve from.
+set debugdir [standard_output_file "debug"]
+file copy -force $binfile $debugdir/
+
+# Create CACHE and DB directories ready for debuginfod to use.
+prepare_for_debuginfod cache db
+
+# Can add 'keys' to MODES list, but this doesn't currently
+# work due to PR gdb/33794. This will be fixed in the next
+# commit, and this comment removed.
+set modes {command}
+
+with_debuginfod_env $cache {
+ save_vars { env(DEBUGINFOD_URLS) } {
+ foreach_with_prefix how $modes {
+ foreach_with_prefix ans { n y } {
+ file delete -force $cache
+
+ set url [start_debuginfod $db $debugdir]
+ if { $url eq "" } {
+ unresolved "failed to start debuginfod server"
+ continue
+ }
+
+ # Point the client to the server.
+ setenv DEBUGINFOD_URLS $url
+
+ foreach_with_prefix fill_screen { true false } {
+ run_switch_with_prompt_test $how $ans $fill_screen
+ }
+ run_switch_to_asm_test $how $ans
+
+ stop_debuginfod
+ }
+ }
+ }
+}
@@ -167,7 +167,26 @@ tui_inferior_exit (struct inferior *inf)
static void
tui_before_prompt (const char *current_gdb_prompt)
{
- tui_refresh_frame_and_register_information ();
+ /* If TUI_DEFER_RERENDER is true then the window content will not
+ yet have been filled in, do so now. This is only expected to
+ happen during the switches into TUI mode as it means the CMD
+ window will exist by the time all the other windows have their
+ content filled in. If filling in one of the other windows
+ triggers a secondary prompt (e.g. debuginfod prompt) then the CMD
+ window will be available to display the prompt. */
+ if (tui_defer_rerender)
+ {
+ target_terminal::scoped_restore_terminal_state term_state;
+ target_terminal::ours_for_output ();
+
+ tui_defer_rerender = false;
+ for (tui_win_info *window : tui_windows)
+ if (window->is_visible ())
+ window->rerender ();
+ }
+ else
+ tui_refresh_frame_and_register_information ();
+
from_stack = false;
from_source_symtab = false;
}
@@ -296,7 +296,8 @@ tui_win_info::resize (int height_, int width_,
if (handle == nullptr)
make_window ();
- rerender ();
+ if (!tui_defer_rerender)
+ rerender ();
}
@@ -69,6 +69,9 @@ show_tui_debug (struct ui_file *file, int from_tty,
/* Tells whether the TUI is active or not. */
bool tui_active = false;
+/* See tui.h. */
+bool tui_defer_rerender = false;
+
/* 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
@@ -449,6 +452,14 @@ tui_enable (void)
tui_batch_rendering defer;
+ /* Defer filling in window contents at this time. The window
+ content will be filled in by calling rerender later. We do this
+ so that we can be sure the CMD window will exist as other windows
+ are rendered, filling in some windows might trigger a secondary
+ prompt (e.g. debuginfod prompt) and we want to be sure that the
+ CMD window exists to display the prompt in. */
+ tui_defer_rerender = true;
+
/* 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. */
@@ -96,4 +96,9 @@ extern void tui_set_key_mode (enum tui_key_mode mode);
extern bool tui_active;
+/* When true, defer rendering the window contents during the initial switch
+ to TUI mode. Each window's rerender method will be called later before
+ the prompt is displayed. */
+extern bool tui_defer_rerender;
+
#endif /* GDB_TUI_TUI_H */