Bug 30440 - [gdb/tui] repeated stepi ends up with garbled screen
Summary: [gdb/tui] repeated stepi ends up with garbled screen
Status: RESOLVED DUPLICATE of bug 14332
Alias: None
Product: gdb
Classification: Unclassified
Component: tui (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-11 09:43 UTC by Tom de Vries
Modified: 2023-05-22 16:24 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
screenshot after garbling (383.12 KB, image/png)
2023-05-11 09:45 UTC, Tom de Vries
Details
screenshot after garbling is repaired using ^L (361.99 KB, image/png)
2023-05-11 09:45 UTC, Tom de Vries
Details
Attempt at test-case (1.60 KB, patch)
2023-05-11 10:19 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2023-05-11 09:43:26 UTC
I've been playing around with TUI, and tried to find an easy way to do a stress test.

I came up with starting a hello world, and doing si and then keeping my finger on the enter key and see what happens.

I eventually ran into screen garbling, which could be repaired using ^L.

I realized this garbling could be the result of printing the "hello", so I moved to compiling "int main (void) { return 0; }", doing a starti, and stepi-ing from there.  I played around with this for a while, and found that I could reproduce the problem within minutes when starting to stepi from __GI___tunables_init.

I tried to write a test-case that mimics this in the testsuite, but sofar I didn't manage to reproduce this.

So, here are the steps I followed (this may be way over-specific):
- openSUSE Leap 15.4 x86_64-linux
- gdb build using -O0
- gdb build from commit 38b95a52938 ("Automatic date update in version.in")
- gnome-terminal (on KDE desktop)
- TERM=xterm (native TERM=xterm-256colors)
- tab with COLUMNS 145, LINES 37
- stay in the tab, to avoid ncurses refresh when switching back to the tab.
  This also prevents resetting the regs window layout to one reg on one line.
- gdb started using "gdb ~/a.out"
- starti
- layout asm (enter tui, use asm window)
- layout regs (add regs window)
- stepi (populate regs window, should show two regs on one line)
- b __GI___tunables_init, continue
- stepi (command to repeat)
- press-and-hold enter
- observe garbling and release enter (for me, after about 3/4 minutes)

I've now also reproduce by starting gdb like so:
...
$ gdb -q ~/a.out \
    -ex "starti" \
    -ex "layout asm" \
    -ex "layout regs" \
    -ex "stepi" 
    -ex "b __GI___tunables_init" 
... 
and then continue, stepi, and press-and-hold enter.
Comment 1 Tom de Vries 2023-05-11 09:45:10 UTC
Created attachment 14873 [details]
screenshot after garbling
Comment 2 Tom de Vries 2023-05-11 09:45:45 UTC
Created attachment 14874 [details]
screenshot after garbling is repaired using ^L
Comment 3 Tom de Vries 2023-05-11 10:19:35 UTC
Created attachment 14875 [details]
Attempt at test-case
Comment 4 Tom de Vries 2023-05-11 10:45:10 UTC
reproduced with gdb-13-branch.
Comment 5 Tom de Vries 2023-05-11 10:52:06 UTC
reproduced with gdb-12-branch.
Comment 6 Tom de Vries 2023-05-11 12:18:44 UTC
Didn't reproduce with -O2 build, gave up after 7 minutes.
Comment 7 Tom de Vries 2023-05-11 13:25:55 UTC
Reproduced with build without system readline.
Comment 8 Tom de Vries 2023-05-11 13:34:09 UTC
Reproduced with changing tabs forth and back after the continue, changing the regs window to one reg per line.
Comment 9 Tom de Vries 2023-05-11 13:42:43 UTC
Didn't reproduce without layout regs, so without register window.
Comment 10 Tom de Vries 2023-05-11 13:46:57 UTC
Reproduced without layout asm, so src (showing no source available throughout) instead of asm window.
Comment 11 Tom de Vries 2023-05-11 13:51:41 UTC
Reproduced with combination of comment 8 and 10.
Comment 12 Tom de Vries 2023-05-11 14:07:25 UTC
OK, new way to reproduce:
...
$ gdb -q ~/a.out \
    -ex "starti" \
    -ex "layout src" \
    -ex "b __GI___tunables_init" \
    -ex continue
...
and do "stepi 1000", followed by press-and-hold enter.

Reproduces within seconds.

Now also reproduces with system gdb based on 12.1 and build with -O2.
Comment 13 Tom de Vries 2023-05-11 16:12:37 UTC
I'm starting to think this is the input variant of PR14332.

By doing stepi, we temporarily hand the terminal to the inferior.

Some of the enters will land in that window where the inferior has the terminal, and will be handled according to those terminal settings, not the terminal settings as setup for/by ncurses, and they're probably just translated into a newline and echoed.
Comment 14 Tom de Vries 2023-05-22 16:24:34 UTC
Duplicate.

*** This bug has been marked as a duplicate of bug 14332 ***