From 450165f0845b682d1fc2046ff9ca2a48583cd69a Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 8 Aug 2025 10:51:18 +0200 Subject: [gdb/testsuite] Add gdb.base/color-prompt.exp After updating the documentation in commit cf03713dd1c ("[gdb/cli] Document \001 and \002 usage for set prompt"), I started to wonder if I could reproduce the CLI issue described in PR cli/28887 using the TUI. That turned out not to be the case, but I noticed handling of the markers in tui_puts and tui_puts_internal, and no test-case exercising this, so I decided to add this. After doing so in gdb.tui/color-prompt.exp, I realized I could use the same code to test the CLI case. Add test-case gdb.base/color-prompt.exp that shares code with gdb.tui/color-prompt.exp in gdb.tui/color-prompt.exp.tcl. For the CLI case, I was hoping to reproduce the behaviour described in the PR, but it didn't trigger. FTR, I manually reproduced the behaviour and used script to record it. I observed the following sequence after the C-a: - ^M (CR) : go to start of line - ^[[K (EL) : erase line - ^M (CR) : go to start of line - ^[[31m(gdb) ^[[0m : output prompt - some long command : output text - ^M (CR) : go to start of line - ^[[C, 15 times (CUF): cursor forward 15 times giving me: ... (gdb) some long command ^ ... Perhaps we'll trigger this on some other os, or once we start using a different TERM value. Tested on x86_64-linux. --- gdb/testsuite/lib/tuiterm.exp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gdb/testsuite/lib') diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index b83b8af..1e18a7a 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -886,6 +886,31 @@ namespace eval Term { return 1 } + # Accept some output from gdb and update the screen. Wait for the current + # screen line to match REGEXP and cursor position POS, unless POS is empty. + # Return 0 on timeout, 1 on success. + proc wait_for_line { regexp {pos ""} } { + variable _cur_row + variable _cur_col + variable _cols + + while 1 { + if { [accept_gdb_output] == 0 } { + return 0 + } + + if { ![check_region_contents_p 0 $_cur_row $_cols 1 $regexp] } { + continue + } + + if { $pos == "" || $_cur_col == $pos } { + break + } + } + + return 1 + } + # Setup the terminal with dimensions ROWSxCOLS, TERM=ansi, and execute # BODY. proc with_tuiterm {rows cols body} { -- cgit v1.1