From 6d8ace9ffd8e9e8cc7fd36d7a06c2da885705eee Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 24 Jul 2025 11:48:29 +0200 Subject: [PATCH] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd 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 "\r\n" is needed instead of send_gdb "\n". This is because gdb_send "layout regs\n" translates to "layout regs", 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index ce5df306ba4..8ea8ebecd6b 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -92,7 +92,7 @@ namespace eval Term { # Return 1 if tuiterm has the bw/auto_left_margin enabled. proc _have_bw {} { - return 0 + return [string equal $Term::_TERM "ansiw"] } # Backspace. @@ -890,8 +890,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.47.2