From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/4] [gdb/tui] Switch to main UI before disabling TUI
Date: Wed, 21 Oct 2026 10:01:19 +0200 [thread overview]
Message-ID: <20261021080120.349861-4-tdevries@suse.de> (raw)
In-Reply-To: <20261021080120.349861-1-tdevries@suse.de>
Test-case gdb.tui/new-ui.exp has a setup where the main UI is in TUI mode,
and a new UI is in CLI mode.
When doing "maint internal-error" in the new UI, we'd expect something like:
...
❌ Command aborted.
(gdb)
...
but instead we get:
...
(gdb) maint internal-error
Cannot enable or disable the TUI when the interpreter is 'console'
(gdb)
...
Fix this by temporarily switching to the main UI before doing tui_disable in
internal_vproblem, similar to what is done in
undo_terminal_modifications_before_exit.
Likewise in handle_fatal_signal and tui_exit.
I've updated test-case gdb.tui/new-ui to handle the new behavior.
Thanks to previous commit "Add logging_file::fd", the backtrace now ends up in
the new UI instead of in the main UI.
The output for the command to check that TUI is no longer active looks odd in
the sense that a newline is missing:
...
21 info win
22 (gdb) info winThe TUI is not active.
23 (gdb)
...
so I've made a note of that in the test-case, but glitches like this are not
unexpected, given that we've only recently started testing this type of setup.
---
gdb/event-top.c | 8 +++++++-
gdb/testsuite/gdb.tui/new-ui.exp | 12 +++++++++++-
gdb/tui/tui-interp.c | 4 ++++
gdb/utils.c | 8 +++++++-
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 0fb6eafec57..eedf75331ba 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -971,7 +971,13 @@ init_str_handle_fatal_signal ()
handle_fatal_signal (int sig)
{
#ifdef TUI
- tui_disable ();
+ {
+ /* Switch to the main UI, otherwise TUI won't be disabled. */
+ scoped_restore restore_current_ui
+ = make_scoped_restore (¤t_ui, main_ui);
+
+ tui_disable ();
+ }
#endif
#ifdef GDB_PRINT_INTERNAL_BACKTRACE
diff --git a/gdb/testsuite/gdb.tui/new-ui.exp b/gdb/testsuite/gdb.tui/new-ui.exp
index 3063868334b..5c2066e785f 100644
--- a/gdb/testsuite/gdb.tui/new-ui.exp
+++ b/gdb/testsuite/gdb.tui/new-ui.exp
@@ -113,7 +113,7 @@ with_test_prefix new-ui {
send_gdb "$cmd\n"
set re \
[multi_line \
- $re_cannot_enable_disable_tui \
+ [string_to_regexp "Command aborted."] \
"$gdb_prompt $"]
gdb_expect {
-re $re {
@@ -131,3 +131,13 @@ with_test_prefix new-ui {
}
}
}
+
+with_test_prefix main-ui {
+ # Currently there's a missing newline after running this command:
+ # (gdb) info winThe TUI is not active.
+ # (gdb)
+ send_gdb "info win\n"
+ set re_no_tui [string_to_regexp "The TUI is not active."]
+ gdb_assert {[Term::wait_for $re_no_tui]} "TUI disabled"
+ Term::dump_screen
+}
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index e171ae6263e..5d1305a8fec 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -55,6 +55,10 @@ class tui_interp final : public cli_interp_base
static void
tui_exit (void)
{
+ /* Switch to the main UI, otherwise TUI won't be disabled. */
+ scoped_restore restore_current_ui
+ = make_scoped_restore (¤t_ui, main_ui);
+
/* Disable the tui. Curses mode is left leaving the screen in a
clean state (see endwin()). */
tui_disable ();
diff --git a/gdb/utils.c b/gdb/utils.c
index 5deecdbba94..1ec7454a606 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -389,7 +389,13 @@ internal_vproblem (struct internal_problem *problem,
}
#ifdef TUI
- tui_disable ();
+ {
+ /* Switch to the main UI, otherwise TUI won't be disabled. */
+ scoped_restore restore_current_ui
+ = make_scoped_restore (¤t_ui, main_ui);
+
+ tui_disable ();
+ }
#endif
/* Create a string containing the full error/warning message. Need
--
2.51.0
next prev parent reply other threads:[~2026-10-21 8:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 8:01 [PATCH 0/4] [gdb/tui] Fix hang in tui_disable in handle_fatal_signal Tom de Vries
2026-10-21 8:01 ` [PATCH 1/4] [gdb] Add logging_file::fd Tom de Vries
2026-10-21 16:54 ` Tom Tromey
2026-10-23 8:02 ` Tom de Vries
2026-10-23 17:41 ` Tom Tromey
2026-10-23 18:25 ` Tom de Vries
2026-10-21 8:01 ` [PATCH 2/4] [gdb/testsuite] Check internal-error in gdb.tui/new-ui.exp Tom de Vries
2026-10-21 8:01 ` Tom de Vries [this message]
2026-10-21 8:01 ` [PATCH 4/4] [gdb/tui] Fix hang in tui_disable in handle_fatal_signal Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021080120.349861-4-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox