* [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd
@ 2025-07-18 13:01 Tom de Vries
2025-07-18 13:01 ` [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping Tom de Vries
` (6 more replies)
0 siblings, 7 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
I've been working on fixing the TUI tests on x86_64-freebsd.
I've submitted an earlier attempt here [1][2].
But after realizing that using TERM=ansiw would solve all problems, I started
over.
This series consists of the following patches:
1 [gdb/testsuite] Fix Cursor Horizontal Absolute clipping
2 [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm
3 [gdb/testsuite] Log on return in Term::_log_cur
4 [gdb/testsuite] Handle auto_left_margin in tuiterm
5 [gdb/testsuite] Fix Term::_csi_m with no args
6 [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
7 [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
I've already submitted patch 1 and 2 separately [3].
Patches 2, 4, 5 and 6 contain necessary fixes.
Patch 1 is a tuiterm fix for a problem that I spotted while working on patch
2.
Patch 3 makes logging more robust, such that patch 4 doesn't break it.
Patch 7 adds a new tuiterm proc that I wrote while investigating the failures
fixed by patch 5, and applies it in the test-case I wrote it for.
The result is:
...
# of unexpected core files 1
# of expected passes 952
# of known failures 1
# of unresolved testcases 1
# of untested testcases 1
...
The core file and unresolved are due to PR33176, a tdep assertion failure.
The untested is due to failing to compile gdb.tui/tui-layout-asm-short-prog.S.
[1] https://sourceware.org/pipermail/gdb-patches/2025-June/218943.html
[2] https://sourceware.org/pipermail/gdb-patches/2025-June/219006.html
[3] https://sourceware.org/pipermail/gdb-patches/2025-July/219274.html
Tom de Vries (7):
[gdb/testsuite] Fix Cursor Horizontal Absolute clipping
[gdb/testsuite] Handle Horizontal Position Absolute in tuiterm
[gdb/testsuite] Log on return in Term::_log_cur
[gdb/testsuite] Handle auto_left_margin in tuiterm
[gdb/testsuite] Fix Term::_csi_m with no args
[gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
[gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
gdb/testsuite/gdb.tui/main-2.exp | 2 +-
gdb/testsuite/gdb.tui/tuiterm.exp | 46 ++++++++++++++-
gdb/testsuite/lib/tuiterm.exp | 94 +++++++++++++++++++++++++++----
3 files changed, 127 insertions(+), 15 deletions(-)
base-commit: f10173a01ffccbad7759ca24336355a87b0948aa
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-18 13:01 ` [PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm Tom de Vries
` (5 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
I looked at the tuiterm implementation of Cursor Horizontal Absolute:
...
proc _csi_G {args} {
set arg [_default [lindex $args 0] 1]
_log_cur "Cursor Horizontal Absolute ($arg)" {
variable _cur_col
variable _cols
set _cur_col [expr {min ($arg - 1, $_cols)}]
}
}
...
and noticed a problem with the clipping behavior.
If we have say $_cols == 80, and we do _csi_G 81 we get $_cur_col == 80, while
$_cur_col is zero-based and should be in the 0..79 range.
Fix this by using:
...
set _cur_col [expr {min ($arg, $_cols)} - 1]
...
which gets us $_cur_col == 79.
Add two boundary tests to gdb.tui/tuiterm.exp.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.tui/tuiterm.exp | 16 ++++++++++++++++
gdb/testsuite/lib/tuiterm.exp | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 9dc2402562f..fff7c37a56e 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -435,6 +435,22 @@ proc test_horizontal_absolute { } {
"qrstuvwx"
"yz01234 "
} 3 2
+
+ Term::_csi_G 8
+ check "cursor horizontal absolute 3" {
+ "abcdefgh"
+ "ijklmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 7 2
+
+ Term::_csi_G 9
+ check "cursor horizontal absolute 4" {
+ "abcdefgh"
+ "ijklmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 7 2
}
proc test_cursor_position { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index a0cd199aed3..71ef6a4eacd 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -251,7 +251,7 @@ namespace eval Term {
variable _cur_col
variable _cols
- set _cur_col [expr {min ($arg - 1, $_cols)}]
+ set _cur_col [expr {min ($arg, $_cols)} - 1]
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
2025-07-18 13:01 ` [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-18 13:01 ` [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur Tom de Vries
` (4 subsequent siblings)
6 siblings, 0 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
2025-07-18 13:01 ` [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping Tom de Vries
2025-07-18 13:01 ` [PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-23 18:28 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm Tom de Vries
` (3 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
Proc Term::_log_cur logs the cursor update of code in its body argument:
...
proc _ctl_0x08 {} {
_log_cur "Backspace" {
variable _cur_col
if {$_cur_col > 0} {
incr _cur_col -1
}
}
}
...
giving us for instance:
...
+++ Backspace, cursor: (2, 0) -> (2, 0)
...
But if we rewrite the code to use a return:
...
if { $_cur_col == 0 } {
return
}
incr _cur_col -1
...
and the return is triggered, the log message disappears.
Fix this by wrapping the "uplevel $body" in a catch:
...
- uplevel $body
+ set code [catch {uplevel $body} result]
...
Tested on aarch64-linux.
---
gdb/testsuite/lib/tuiterm.exp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 2268b1e28e0..4364ff8d05c 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -45,9 +45,16 @@ namespace eval Term {
set orig_cur_row $_cur_row
set orig_cur_col $_cur_col
- uplevel $body
+ set code [catch {uplevel $body} result]
_log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)"
+
+ if { $code == 1 } {
+ global errorInfo errorCode
+ return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+ } else {
+ return -code $code $result
+ }
}
# If ARG is empty, return DEF: otherwise ARG. This is useful for
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
` (2 preceding siblings ...)
2025-07-18 13:01 ` [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-23 18:36 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args Tom de Vries
` (2 subsequent siblings)
6 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
The terminal capability bw (aka as auto_left_margin) controls whether a
backspace at the start of a line wraps to the last column of the previous
line.
For tuiterm, we use TERM=ansi, and on linux at least that capability is off.
Consequently the current implementation of Term::_ctl_0x08 doesn't wrap.
Add this capability in Term::_ctl_0x08, and add a unit test.
Tested on aarch64-linux.
---
gdb/testsuite/gdb.tui/tuiterm.exp | 13 +++++++++++--
gdb/testsuite/lib/tuiterm.exp | 32 ++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 0e03bfaa8ea..e58de688ef2 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -102,7 +102,7 @@ proc test_backspace {} {
Term::_move_cursor 1 2
- Term::_ctl_0x08
+ Term::_ctl_0x08 0
check "backspace one" {
"abcdefgh"
"ijklmnop"
@@ -111,13 +111,22 @@ proc test_backspace {} {
} 0 2
# Cursor should not move if it is already at column 0.
- Term::_ctl_0x08
+ Term::_ctl_0x08 0
check "backspace 2" {
"abcdefgh"
"ijklmnop"
"qrstuvwx"
"yz01234 "
} 0 2
+
+ # Cursor should wrap to previous line.
+ Term::_ctl_0x08 1
+ check "backspace 3" {
+ "abcdefgh"
+ "ijklmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 7 1
}
proc test_linefeed { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 4364ff8d05c..451fccc6693 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -90,14 +90,40 @@ namespace eval Term {
proc _ctl_0x07 {} {
}
+ # Return 1 if tuiterm has the bw/auto_left_margin enabled.
+ proc _have_bw {} {
+ return 0
+ }
+
# Backspace.
- proc _ctl_0x08 {} {
- _log_cur "Backspace" {
+ proc _ctl_0x08 { {bw -1} } {
+ if { $bw == -1 } {
+ set bw [_have_bw]
+ }
+ _log_cur "Backspace, bw == $bw" {
variable _cur_col
+ variable _cur_row
+ variable _cols
- if {$_cur_col > 0} {
+ if { $_cur_col > 0 } {
+ # No wrapping needed.
incr _cur_col -1
+ return
}
+
+ if { ! $bw } {
+ # Wrapping not enabled.
+ return
+ }
+
+ if { $_cur_row == 0 } {
+ # Can't wrap.
+ return
+ }
+
+ # Wrap to previous line.
+ set _cur_col [expr $_cols - 1]
+ incr _cur_row -1
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
` (3 preceding siblings ...)
2025-07-18 13:01 ` [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-23 18:30 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd Tom de Vries
2025-07-18 13:01 ` [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm Tom de Vries
6 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
When calling Term::_csi_m with no args, default behaviour needs to be applied,
which is equivalent to "Term::_csi_m 0" [1].
However, while "Term::_csi_m 0" works, as well as 'Term::_csi_m ""', calling
Term::_csi_m with no args has no effect.
Fix this by implementing the default behaviour in Term::_csi_m.
Tested on aarch64-linux.
[1] https://vt100.net/docs/vt510-rm/SGR.html
---
gdb/testsuite/gdb.tui/tuiterm.exp | 9 +++++++++
gdb/testsuite/lib/tuiterm.exp | 5 +++++
2 files changed, 14 insertions(+)
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index e58de688ef2..6cd65f3ede7 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -783,6 +783,15 @@ proc test_attrs {} {
set line [Term::get_line_with_attrs 0]
gdb_assert { [regexp $re $line] } "attribute: $attr"
}
+
+ # Regression test: Check that _csi_m works without arguments.
+ setup_terminal 4 1
+ Term::_csi_m 7
+ Term::_insert "a"
+ Term::_csi_m
+ Term::_insert "a"
+ set line [Term::get_line_with_attrs 0]
+ gdb_assert { [string equal $line "<reverse:1>a<reverse:0>a "] }
}
# Run proc TEST_PROC_NAME with a "small" terminal.
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 451fccc6693..10c5a3d0dce 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -638,6 +638,11 @@ namespace eval Term {
#
# https://vt100.net/docs/vt510-rm/SGR.html
proc _csi_m {args} {
+ if { [llength $args] == 0 } {
+ # Apply default.
+ set args { 0 }
+ }
+
_log_cur "Select Graphic Rendition ([join $args {, }])" {
variable _attrs
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
` (4 preceding siblings ...)
2025-07-18 13:01 ` [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-23 18:34 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm Tom de Vries
6 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
TERM=ansi is different on freebsd and linux. Consequently, many TUI
test-cases (gdb.tui/*.exp and gdb.python/tui*.exp) fail on freebsd.
One of the problems is that send_gdb "<cmd>\r\n" is needed instead of
send_gdb "<cmd>\n".
This is because gdb_send "layout regs\n" translates to
"layout regs<KEY_DOWN>", which evidently missing the carriage return part.
While we can work around this, there are other problems. There is no color
support, and the cursor keys fail to scroll the source window.
So I went looking for an alternative to TERM=ansi on freebsd, and came across
TERM=ansiw. Using this didn't work out of the box, but with the fixes in
this series it now does.
I also briefly looked at TERM=ansis, which is interesting because it's
available on both linux and freebsd, but ansiw is a better choice for now.
I've filed PR33179 to document what I learned, with the aim to eventually
follow up and address two test-case failures with TERM=ansis on linux.
Tested on x86_64-freebsd.
---
gdb/testsuite/lib/tuiterm.exp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 10c5a3d0dce..76351841988 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -92,6 +92,9 @@ namespace eval Term {
# Return 1 if tuiterm has the bw/auto_left_margin enabled.
proc _have_bw {} {
+ if { [string equal $Term::_TERM "ansiw"] } {
+ return 1
+ }
return 0
}
@@ -890,8 +893,16 @@ namespace eval Term {
# BODY.
proc with_tuiterm {rows cols body} {
global env stty_init
+ variable _TERM
save_vars {env(TERM) env(NO_COLOR) stty_init} {
- setenv TERM ansi
+ if { [ishost *-*-*bsd*] } {
+ setenv TERM ansiw
+ } else {
+ setenv TERM ansi
+ }
+ # Save active TERM variable.
+ set Term::_TERM $env(TERM)
+
setenv NO_COLOR ""
_setup $rows $cols
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
` (5 preceding siblings ...)
2025-07-18 13:01 ` [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd Tom de Vries
@ 2025-07-18 13:01 ` Tom de Vries
2025-07-23 18:36 ` Tom Tromey
6 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-18 13:01 UTC (permalink / raw)
To: gdb-patches
While reading a gdb.log for test-case gdb.tui/main-2.exp, I noticed that this
line was somewhat hard to read:
...
screen line 6: '<fg:cyan><intensity:bold>|<fg:default><intensity:normal>B+> 21 <reverse:1> return 0;<reverse:0> <fg:cyan><intensity:bold>|<fg:default><intensity:normal>'
...
because of the border attributes.
Then I realized that the test-case is only interested in the text between the
borders, so I added a proc Term::get_string_with_attrs that allows me to drop
the borders, getting us instead:
...
screen line 6: 'B+> 21 <reverse:1> return 0;<reverse:0> '
...
Tested on aarch64-linux.
---
gdb/testsuite/gdb.tui/main-2.exp | 2 +-
gdb/testsuite/lib/tuiterm.exp | 23 ++++++++++++++++++-----
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp
index 2b0fb6bd003..71ad03b73fc 100644
--- a/gdb/testsuite/gdb.tui/main-2.exp
+++ b/gdb/testsuite/gdb.tui/main-2.exp
@@ -41,7 +41,7 @@ if {![Term::enter_tui]} {
set line " return 0;"
set nr [gdb_get_line_number $line]
-set screen_line [Term::get_line_with_attrs 6]
+set screen_line [Term::get_string_with_attrs 6 1 79]
verbose -log "screen line 6: '$screen_line'"
gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \
"highlighted line in middle of source window"
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 76351841988..d62cc0751a5 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -1012,10 +1012,10 @@ namespace eval Term {
return $res
}
- # Return the text of screen line N. Lines are 0-based. If C is given,
- # stop before column C. Columns are also zero-based. If ATTRS, annotate
- # with attributes.
- proc get_line_1 {n c attrs} {
+ # Return the text of screen line N. Lines are 0-based. Start at column
+ # X. If C is given, stop before column C. Columns are also zero-based.
+ # If ATTRS, annotate with attributes.
+ proc get_string {n x c {attrs 0}} {
variable _rows
# This can happen during resizing, if the cursor seems to
# temporarily be off-screen.
@@ -1027,7 +1027,6 @@ namespace eval Term {
variable _cols
variable _chars
set c [_default $c $_cols]
- set x 0
if { $attrs } {
_reset_attrs line_attrs
}
@@ -1047,6 +1046,20 @@ namespace eval Term {
return $result
}
+ # Return the text of screen line N. Lines are 0-based. Start at column
+ # X. If C is given, stop before column C. Columns are also zero-based.
+ # Annotate with attributes.
+ proc get_string_with_attrs { n x c } {
+ return [get_string $n $x $c 1]
+ }
+
+ # Return the text of screen line N. Lines are 0-based. If C is given,
+ # stop before column C. Columns are also zero-based. If ATTRS, annotate
+ # with attributes.
+ proc get_line_1 {n c attrs} {
+ return [get_string $n 0 $c $attrs]
+ }
+
# Return the text of screen line N, without attributes. Lines are
# 0-based. If C is given, stop before column C. Columns are also
# zero-based.
--
2.43.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur
2025-07-18 13:01 ` [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur Tom de Vries
@ 2025-07-23 18:28 ` Tom Tromey
2025-07-24 7:18 ` Tom de Vries
0 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2025-07-23 18:28 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> + set code [catch {uplevel $body} result]
Tom> + if { $code == 1 } {
Tom> + global errorInfo errorCode
Tom> + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
Tom> + } else {
Tom> + return -code $code $result
Tom> + }
I suspect this could be:
catch {uplevel $body} result options
and then just
return -options $options $result
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args
2025-07-18 13:01 ` [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args Tom de Vries
@ 2025-07-23 18:30 ` Tom Tromey
2025-07-23 20:34 ` Tom de Vries
0 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2025-07-23 18:30 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> When calling Term::_csi_m with no args, default behaviour needs to be applied,
Tom> which is equivalent to "Term::_csi_m 0" [1].
Tom> However, while "Term::_csi_m 0" works, as well as 'Term::_csi_m ""', calling
Tom> Term::_csi_m with no args has no effect.
Tom> Fix this by implementing the default behaviour in Term::_csi_m.
Ok.
Approved-By: Tom Tromey <tom@tromey.com>
Tom> + set args { 0 }
The spaces seem mildly unusual since I don't think they'd be in a "real"
argument of just "0".
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
2025-07-18 13:01 ` [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd Tom de Vries
@ 2025-07-23 18:34 ` Tom Tromey
2025-07-24 9:47 ` Tom de Vries
0 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2025-07-23 18:34 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> So I went looking for an alternative to TERM=ansi on freebsd, and came across
Tom> TERM=ansiw. Using this didn't work out of the box, but with the fixes in
Tom> this series it now does.
Tom> I also briefly looked at TERM=ansis, which is interesting because it's
Tom> available on both linux and freebsd, but ansiw is a better choice for now.
I wonder if we should just give in and switch to xterm.
Tom> proc _have_bw {} {
Tom> + if { [string equal $Term::_TERM "ansiw"] } {
Tom> + return 1
Tom> + }
Tom> return 0
This can be just return [string ... ]
It seems like it could just as easily check $env(TERM) and avoid another
variable as well.
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
2025-07-18 13:01 ` [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm Tom de Vries
@ 2025-07-23 18:36 ` Tom Tromey
2025-07-24 10:07 ` Tom de Vries
0 siblings, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2025-07-23 18:36 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> + # Return the text of screen line N. Lines are 0-based. Start at column
Tom> + # X. If C is given, stop before column C. Columns are also zero-based.
Tom> + # If ATTRS, annotate with attributes.
Tom> + proc get_string {n x c {attrs 0}} {
The comment here (and the other ones later in the patch) make it sound
like C is optional, but it isn't.
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm
2025-07-18 13:01 ` [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm Tom de Vries
@ 2025-07-23 18:36 ` Tom Tromey
0 siblings, 0 replies; 18+ messages in thread
From: Tom Tromey @ 2025-07-23 18:36 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> The terminal capability bw (aka as auto_left_margin) controls whether a
Tom> backspace at the start of a line wraps to the last column of the previous
Tom> line.
Tom> For tuiterm, we use TERM=ansi, and on linux at least that capability is off.
Tom> Consequently the current implementation of Term::_ctl_0x08 doesn't wrap.
Tom> Add this capability in Term::_ctl_0x08, and add a unit test.
Ok. Thanks.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args
2025-07-23 18:30 ` Tom Tromey
@ 2025-07-23 20:34 ` Tom de Vries
2025-07-24 1:17 ` Tom Tromey
0 siblings, 1 reply; 18+ messages in thread
From: Tom de Vries @ 2025-07-23 20:34 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 7/23/25 20:30, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> When calling Term::_csi_m with no args, default behaviour needs to be applied,
> Tom> which is equivalent to "Term::_csi_m 0" [1].
>
> Tom> However, while "Term::_csi_m 0" works, as well as 'Term::_csi_m ""', calling
> Tom> Term::_csi_m with no args has no effect.
>
> Tom> Fix this by implementing the default behaviour in Term::_csi_m.
>
> Ok.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom> + set args { 0 }
>
> The spaces seem mildly unusual since I don't think they'd be in a "real"
> argument of just "0".
Hi Tom,
thanks for the review(s).
Yes, sorry about that. I keep getting tripped up about the tcl string
vs list confusion.
I added the spaces for readability, which doesn't matter when regarding
args as a list, but it does when treating it as a string.
Fixed by used [list 0] instead.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args
2025-07-23 20:34 ` Tom de Vries
@ 2025-07-24 1:17 ` Tom Tromey
0 siblings, 0 replies; 18+ messages in thread
From: Tom Tromey @ 2025-07-24 1:17 UTC (permalink / raw)
To: Tom de Vries; +Cc: Tom Tromey, gdb-patches
Tom> Fixed by used [list 0] instead.
FWIW, more idiomatic is to either write {0} or just 0, since in Tcl
these are the same, since {...} doesn't really denote a list, it's just
a certain way of quoting a string.
Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur
2025-07-23 18:28 ` Tom Tromey
@ 2025-07-24 7:18 ` Tom de Vries
0 siblings, 0 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-24 7:18 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 7/23/25 20:28, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> + set code [catch {uplevel $body} result]
>
> Tom> + if { $code == 1 } {
> Tom> + global errorInfo errorCode
> Tom> + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
> Tom> + } else {
> Tom> + return -code $code $result
> Tom> + }
>
> I suspect this could be:
>
> catch {uplevel $body} result options
>
> and then just
>
> return -options $options $result
Hi Tom,
thanks for the review.
You're right, if we can assume tcl 8.5 or later.
It's not clear what the currently supported minimal version is, so I
filed a PR about this (
https://sourceware.org/bugzilla/show_bug.cgi?id=33205 ), but probably
it's 8.4 (with the exception of ada testing, which needs 8.5 since 2015,
gdb 7.11).
I've committed this as is.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd
2025-07-23 18:34 ` Tom Tromey
@ 2025-07-24 9:47 ` Tom de Vries
0 siblings, 0 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-24 9:47 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 7/23/25 20:34, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> So I went looking for an alternative to TERM=ansi on freebsd, and came across
> Tom> TERM=ansiw. Using this didn't work out of the box, but with the fixes in
> Tom> this series it now does.
>
> Tom> I also briefly looked at TERM=ansis, which is interesting because it's
> Tom> available on both linux and freebsd, but ansiw is a better choice for now.
>
> I wonder if we should just give in and switch to xterm.
>
I've filed a PR ( https://sourceware.org/bugzilla/show_bug.cgi?id=33206 ).
> Tom> proc _have_bw {} {
> Tom> + if { [string equal $Term::_TERM "ansiw"] } {
> Tom> + return 1
> Tom> + }
> Tom> return 0
>
> This can be just return [string ... ]
>
Thanks for the review, fixed and pushed.
> It seems like it could just as easily check $env(TERM) and avoid another
> variable as well.
Say we add this to gdb.tui.basic.exp:
...
+puts "$env(TERM)"
Term::clean_restart 24 80 $testfile
+puts "$env(TERM)"
...
and run the test-case, we get:
...
dumb
dumb
...
So that wouldn't work. The env(TERM) var is only set for the duration of
starting gdb.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
2025-07-23 18:36 ` Tom Tromey
@ 2025-07-24 10:07 ` Tom de Vries
0 siblings, 0 replies; 18+ messages in thread
From: Tom de Vries @ 2025-07-24 10:07 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 7/23/25 20:36, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> + # Return the text of screen line N. Lines are 0-based. Start at column
> Tom> + # X. If C is given, stop before column C. Columns are also zero-based.
> Tom> + # If ATTRS, annotate with attributes.
> Tom> + proc get_string {n x c {attrs 0}} {
>
> The comment here (and the other ones later in the patch) make it sound
> like C is optional, but it isn't.
Thanks for the review.
Fixed by using "non-empty" instead of "passed", and pushed.
- Tom
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-07-24 10:08 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
2025-07-18 13:01 ` [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping Tom de Vries
2025-07-18 13:01 ` [PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm Tom de Vries
2025-07-18 13:01 ` [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur Tom de Vries
2025-07-23 18:28 ` Tom Tromey
2025-07-24 7:18 ` Tom de Vries
2025-07-18 13:01 ` [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm Tom de Vries
2025-07-23 18:36 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args Tom de Vries
2025-07-23 18:30 ` Tom Tromey
2025-07-23 20:34 ` Tom de Vries
2025-07-24 1:17 ` Tom Tromey
2025-07-18 13:01 ` [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd Tom de Vries
2025-07-23 18:34 ` Tom Tromey
2025-07-24 9:47 ` Tom de Vries
2025-07-18 13:01 ` [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm Tom de Vries
2025-07-23 18:36 ` Tom Tromey
2025-07-24 10:07 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox