* [pushed 1/3] [gdb/testsuite] Factor out Term::_scroll
2026-10-16 11:31 [pushed 0/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert Tom de Vries
@ 2026-10-16 11:31 ` Tom de Vries
2026-10-16 11:31 ` [pushed 2/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert Tom de Vries
2026-10-16 11:31 ` [pushed 3/3] [gdb/testsuite] Add gdb.tui/scroll-bottom-right.exp Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 11:31 UTC (permalink / raw)
To: gdb-patches
Factor Term::_scroll out of Term::_ctl_0x0a.
---
gdb/testsuite/lib/tuiterm.exp | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index edabadeb1a3..39fcb082b47 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -177,25 +177,27 @@ proc Term::_copy_lines { sy ey dy } {
return $cnt
}
+# Scroll display contents until the cursor is on the display.
+proc Term::_scroll {} {
+ variable _cur_row
+ variable _rows
+
+ while {$_cur_row >= $_rows} {
+ # Scroll the display contents. We scroll one line at
+ # a time here.
+ _copy_lines 1 $_rows 0
+
+ incr _cur_row -1
+ _clear_lines $_cur_row $_rows
+ }
+}
+
# Linefeed.
proc Term::_ctl_0x0a {} {
_log_cur "Line feed" {
variable _cur_row
- variable _rows
-
incr _cur_row 1
- while {$_cur_row >= $_rows} {
- # Scroll the display contents. We scroll one line at
- # a time here; as _cur_row was only increased by one,
- # a single line scroll should be enough to put the
- # cursor back on the screen. But we wrap the
- # scrolling inside a while loop just to be on the safe
- # side.
- _copy_lines 1 $_rows 0
-
- incr _cur_row -1
- _clear_lines $_cur_row $_rows
- }
+ _scroll
}
}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [pushed 2/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert
2026-10-16 11:31 [pushed 0/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert Tom de Vries
2026-10-16 11:31 ` [pushed 1/3] [gdb/testsuite] Factor out Term::_scroll Tom de Vries
@ 2026-10-16 11:31 ` Tom de Vries
2026-10-16 11:31 ` [pushed 3/3] [gdb/testsuite] Add gdb.tui/scroll-bottom-right.exp Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 11:31 UTC (permalink / raw)
To: gdb-patches
Use Term::_scroll in Term::_insert to fix the error "FIXME scroll".
At the point that tuiterm was added, it had two of those, one in
Term::_ctl_0x0a and one in Term::_insert.
The one in Term::_ctl_0x0a was fixed by commit efe1b6507b7 ("gdb/testsuite:
fix line feed scrolling in tuiterm.exp").
We're essentially reusing that code to fix Term::_insert as well.
The scrolling affected by this patch is scrolling after wrapping. This commit
implements ANSI wrapping behaviour. Wrapping in xterm requires support for
the newline glitch. There's an issue open about this [1].
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=30451
---
gdb/testsuite/gdb.tui/tuiterm.exp | 12 ++++++++++--
gdb/testsuite/lib/tuiterm.exp | 5 +----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 4966800c0bb..75bd205d51e 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -81,8 +81,7 @@ set small_initial {
# yz01234
#
# The bottom right cell is left blank: trying to write to it using _insert
-# would move the cursor past the screen, causing a scroll, but scrolling is
-# not implemented at the moment.
+# would move the cursor past the screen, causing a scroll.
proc setup_small {} {
setup_terminal 8 4
@@ -594,6 +593,15 @@ proc test_repeat { } {
"qrstuvwx"
"yz01234 "
} 5 1
+
+ Term::_move_cursor 7 3
+ Term::_csi_b 1
+ check "repeat at bottom-right corner" {
+ "xxXXXnop"
+ "qrstuvwx"
+ "yz01234X"
+ " "
+ } 0 3
}
proc test_vertical_line_position_absolute { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 39fcb082b47..9d29549fdce 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -922,7 +922,6 @@ proc Term::_insert {str} {
variable _cur_col
variable _cur_row
- variable _rows
variable _cols
variable _attrs
variable _chars
@@ -934,9 +933,7 @@ proc Term::_insert {str} {
if {$_cur_col >= $_cols} {
set _cur_col 0
incr _cur_row
- if {$_cur_row >= $_rows} {
- error "FIXME scroll"
- }
+ _scroll
}
}
}
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [pushed 3/3] [gdb/testsuite] Add gdb.tui/scroll-bottom-right.exp
2026-10-16 11:31 [pushed 0/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert Tom de Vries
2026-10-16 11:31 ` [pushed 1/3] [gdb/testsuite] Factor out Term::_scroll Tom de Vries
2026-10-16 11:31 ` [pushed 2/3] [gdb/testsuite] Fix "FIXME scroll" error in Term::_insert Tom de Vries
@ 2026-10-16 11:31 ` Tom de Vries
2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2026-10-16 11:31 UTC (permalink / raw)
To: gdb-patches
Add a test-case where gdb triggers the situation where tuiterm used to run
into a "FIXME scroll" error.
---
gdb/testsuite/gdb.tui/scroll-bottom-right.exp | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 gdb/testsuite/gdb.tui/scroll-bottom-right.exp
diff --git a/gdb/testsuite/gdb.tui/scroll-bottom-right.exp b/gdb/testsuite/gdb.tui/scroll-bottom-right.exp
new file mode 100644
index 00000000000..ff00e90bb56
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/scroll-bottom-right.exp
@@ -0,0 +1,62 @@
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Regression test for "FIXME scroll" in Term::_insert. Insert a character when
+# the current position is at the bottom-right corner.
+
+tuiterm_env
+
+require allow_tui_tests
+
+Term::clean_restart 24 80
+
+set last_line {0 23 80 1}
+
+# Get prompt on last line.
+set cmd "echo "
+for { set i 0 } { $i < 24 } { incr i } {
+ set cmd "${cmd}${i}\\n"
+}
+send_gdb "$cmd\n"
+gdb_assert \
+ {[Term::wait_for_region_contents {*}$last_line "^$gdb_prompt"]} \
+ "prompt on last line"
+
+set str10 0123456789
+set str60 $str10$str10$str10$str10$str10$str10
+send_gdb "echo $str60"
+gdb_assert \
+ {[Term::wait_for_region_contents {*}$last_line "^$gdb_prompt echo $str60"]} \
+ "setup for scroll"
+
+# Trigger scroll in Term::_insert. This used to trigger error "FIXME scroll".
+send_gdb "$str10"
+gdb_assert \
+ {[Term::wait_for_region_contents {*}$last_line "^9"]} \
+ "scroll"
+
+# Get back prompt.
+send_gdb "\n"
+gdb_assert \
+ {[Term::wait_for_region_contents {*}$last_line "$gdb_prompt"]} \
+ "got back prompt"
+
+# Send ^L to get prompt at left border. Echo doesn't add an implicit newline,
+# so the prompt is now near the right border.
+send_gdb "\014"
+gdb_assert {[Term::wait_for ""]} "prompt at left border"
+
+# Check that gdb is responsive.
+gdb_assert {[Term::command "print 1"]} "responsive prompt"
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread