[2/6] gdb/testsuite: fix tuiterm linefeed scrolling new line content

Message ID bcdad1db7a8c14147fd75ad1780edeaace5a213e.1777645161.git.aburgess@redhat.com
State New
Headers
Series gdb/tui: fix debuginfod related crash |

Commit Message

Andrew Burgess May 1, 2026, 2:22 p.m. UTC
  I came across a bug in the implementation of line feed in tuiterm.
Consider the gdb.tui/tuiterm.exp test 'test_linefeed_scroll', before
sending the line feed we have:

    Screen Dump (size 8 columns x 4 rows, cursor at column 0, row 3):
        0 abcdefgh
        1 ijklmnop
        2 qrstuvwx
        3 yz01234

and after sending the line feed we have:

    Screen Dump (size 8 columns x 4 rows, cursor at column 0, row 3):
        0 ijklmnop
        1 qrstuvwx
        2 yz01234
        3 yz01234

Notice that the new line #3 retains its previous contents, all lines
have scrolled up, with the old line #0 having been moved off the
terminal, but the new line is starting with these cloned contents.

I don't believe this is correct.  My understanding is that new lines
should be created empty -- or really full of space characters.

After fixing this issue so that new lines are created empty, the only
test failure is the tuiterm.exp unit test mentioned above, this was
added in commit:

  commit e20baea1298d2227db953862d131d9bbf91cf522
  Date:   Mon May 29 22:11:05 2023 +0200

      [gdb/testsuite] Fix linefeed scrolling in tuiterm

This commit is fixing an issue with cursor placement after a scroll,
there is no mention of the content of the new line, which makes me
think that the test is just checking whatever behaviour used to be
there.

In this commit I think we should fix the new line content, and update
the existing unit test to match the new behaviour.
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 2 +-
 gdb/testsuite/lib/tuiterm.exp     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index ccf26195ddc..b6330b0d6a8 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -152,7 +152,7 @@  proc test_linefeed_scroll { } {
 	"ijklmnop"
 	"qrstuvwx"
 	"yz01234 "
-	"yz01234 "
+	"        "
     } 0 3
     Term::dump_screen
 }
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index a03c32b3f60..55b8e595604 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -165,6 +165,7 @@  proc Term::_ctl_0x0a {} {
 	    }
 
 	    incr _cur_row -1
+	    _clear_lines $_cur_row $_rows
 	}
     }
 }