[PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm

Tom de Vries
2025-07-18T13:04:05Z

I ran the tui testsuite on freebsd with TERM=ansiw, and investigated the first
failure, in test-case gdb.tui/tui-init-source.exp.

The problem turned out to be the lack of handling a Horizontal Position
Absolute [1] sequence "^[[80`" in tuiterm.

Add Term::_csi_`, forwarding to Term::_csi_G which handles Cursor Horizontal
Absolute [2].

Tested on x86_64-linux.

[1] https://vt100.net/docs/vt510-rm/HPA.html
[2] https://vt100.net/docs/vt510-rm/CHA.html
---
gdb/testsuite/gdb.tui/tuiterm.exp | 8 ++++++++
gdb/testsuite/lib/tuiterm.exp | 10 +++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index fff7c37a56e..0e03bfaa8ea 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -451,6 +451,14 @@ proc test_horizontal_absolute { } {
"qrstuvwx"
"yz01234 "
} 7 2
+
+ Term::_csi_`
+ check "horizontal position absolute 1" {
+ "abcdefgh"
+ "ijklmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 0 2
}

proc test_cursor_position { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 71ef6a4eacd..2268b1e28e0 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -155,6 +155,14 @@ namespace eval Term {
}
}

+ # Horizontal Position Absolute.
+ #
+ # https://vt100.net/docs/vt510-rm/HPA.html
+ proc _csi_` {args} {
+ # Same as Cursor Horizontal Absolute.
+ return [Term::_csi_G {*}$args]
+ }
+
# Cursor Up.
#
# https://vt100.net/docs/vt510-rm/CUU.html
@@ -740,7 +748,7 @@ namespace eval Term {
_log "wait_for: unsupported escape"
error "unsupported escape"
}
- -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" {
+ -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@`\])" {
set cmd $expect_out(2,string)
set params [split $expect_out(1,string) ";"]
_log "wait_for: _csi_$cmd <<<$expect_out(1,string)>>>"
--
2.43.0