[binutils-gdb] gdb/testsuite: fix tuiterm linefeed scrolling new line content

Andrew Burgess via Gdb-cvs <[email protected]> Mon, 27 Jul 2026 13:48:53 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D85939a920ef8=
fa459072cdd7bd36c5544e6425b8

commit 85939a920ef8fa459072cdd7bd36c5544e6425b8
Author: Andrew Burgess <[email protected]>
Date:   Tue Apr 28 13:59:22 2026 +0100

    gdb/testsuite: fix tuiterm linefeed scrolling new line content
   =20
    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:
   =20
        Screen Dump (size 8 columns x 4 rows, cursor at column 0, row 3):
            0 abcdefgh
            1 ijklmnop
            2 qrstuvwx
            3 yz01234
   =20
    and after sending the line feed we have:
   =20
        Screen Dump (size 8 columns x 4 rows, cursor at column 0, row 3):
            0 ijklmnop
            1 qrstuvwx
            2 yz01234
            3 yz01234
   =20
    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.
   =20
    I don't believe this is correct.  My understanding is that new lines
    should be created empty -- or really full of space characters.
   =20
    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:
   =20
      commit e20baea1298d2227db953862d131d9bbf91cf522
      Date:   Mon May 29 22:11:05 2023 +0200
   =20
          [gdb/testsuite] Fix linefeed scrolling in tuiterm
   =20
    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.
   =20
    In this commit I think we should fix the new line content, and update
    the existing unit test to match the new behaviour.

Diff:
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 2 +-
 gdb/testsuite/lib/tuiterm.exp     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuit=
erm.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 e889e3b931b..d23e29d1a6d 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -165,6 +165,7 @@ proc Term::_ctl_0x0a {} {
 	    }
=20
 	    incr _cur_row -1
+	    _clear_lines $_cur_row $_rows
 	}
     }
 }