Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Fix FAIL in gdb.tui/tui-mode-switch.exp
Date: Tue, 13 Oct 2026 15:06:14 +0200	[thread overview]
Message-ID: <20261013130614.1156344-1-tdevries@suse.de> (raw)

With test-case gdb.tui/tui-mode-switch.exp I ran into:
...
PASS: $exp: enter TUI
^[[?1006;1000l^[[12;1H^[[?1049l^[[23;0;0t^M^[[?1l^[>PASS: $exp: exit TUI
Box Dump (40 x 1) @ (0, 11):
   11
Box Dump (40 x 1) @ (0, 11):
   11
Box Dump (40 x 1) @ (0, 11):
   11
Box Dump (40 x 1) @ (0, 11):
   11
Box Dump (40 x 1) @ (0, 11):
   11
Box Dump (40 x 1) @ (0, 11):
   11
b(gdb) bBox Dump (40 x 1) @ (0, 11):
   11 b(gdb) b
WARNING: timeout in accept_gdb_output
Screen Dump (size 40 columns x 12 rows, cursor at column 8, row 11):
    0 (gdb)
    1 (gdb)
    2 (gdb)
    3 (gdb)
    4 (gdb)
    5 (gdb)
    6 (gdb)
    7 (gdb)
    8 (gdb)
    9 (gdb)
   10 (gdb)
   11 b(gdb) b
FAIL: $exp: type b
...

The FAIL happens in this part of the test:
...
 # Enter TUI.
 send_gdb "\030\001"
 gdb_assert { [Term::wait_for ""] } "enter TUI"

 # Exit TUI.
 send_gdb "\030\001"
 gdb_assert { [Term::wait_for ""] } "exit TUI"

 # Type b.
 send_gdb "b"
...

It's a bit easier to see what happens if we switch on logging in Term::_log
using verbose -log:
...
PASS: $exp: enter TUI
^[[?1006;1000l^[[12;1H^[[?1049l^[[23;0;0t^M^[[?1l^[>+++ wait_for: ESC
+++ wait_for: CSI
+++ wait_for: _csi_0x3f_l <<<?>>>
+++ ignored: Disable SGR Mouse Mode
+++ ignored: Don't send Mouse X & Y on button press and release
PASS: $exp: exit TUI
...

The wait_for for "exit TUI" triggers on the prompt of the TUI that's still
there, so "b" is typed too early.

From there on, there's a short window between endwin in tui_disable and
emitting the prompt where echo is enabled.  If the b arrives in that window,
we get "b(gdb) b".

We can reproduce the FAIL reliably by adding a 200ms sleep after endwin in
tui_disable.

Fix this by waiting on the CLI prompt on the line where we're expecting it.

I checked that reverting commit ee3c07a28be ("[gdb/tui] Clear readline buffer
on switching to TUI") still makes the test-case fail.

Tested on x86_64-linux, both with and without the reproducer delay.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34737
---
 gdb/testsuite/gdb.tui/tui-mode-switch.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.tui/tui-mode-switch.exp b/gdb/testsuite/gdb.tui/tui-mode-switch.exp
index 250b557125e..f4e3bb78245 100644
--- a/gdb/testsuite/gdb.tui/tui-mode-switch.exp
+++ b/gdb/testsuite/gdb.tui/tui-mode-switch.exp
@@ -39,7 +39,8 @@ gdb_assert { [Term::wait_for ""] } "enter TUI"
 
 # Exit TUI.
 send_gdb "\030\001"
-gdb_assert { [Term::wait_for ""] } "exit TUI"
+gdb_assert { [Term::wait_for_region_contents {*}$line "^$gdb_prompt "] } \
+    "exit TUI"
 
 # Type b.
 send_gdb "b"

base-commit: 559b2fef9f095796b2bc9adb8cb47eaee822fe27
-- 
2.51.0


                 reply	other threads:[~2026-10-13 13:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261013130614.1156344-1-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