[binutils-gdb] [gdb/testsuite] Require minimum width in gdb.base/style.exp

Tom de Vries vries@sourceware.org
Thu Jul 17 20:06:56 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e83ef5d62595f04f9cbae7a1dc88a4aa56a0cc6d

commit e83ef5d62595f04f9cbae7a1dc88a4aa56a0cc6d
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jul 17 22:06:38 2025 +0200

    [gdb/testsuite] Require minimum width in gdb.base/style.exp
    
    In test-case gdb.base/style.exp, we have proc test_pagination_prompt_styling,
    which:
    - determines a "desired width" by parsing the output of "info files",
    - sets width to the "desired width", and
    - runs "info files" again.
    
    The "desired width" on my system is 88, but if I override it to 65, I run
    into:
    ...
    (gdb) info files^M
    Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.base/style/style^[[m".^M
    --Type <RET> for more, q to quit, c to continue without paging--^M
    ^MFAIL: gdb.base/style.exp: check pagination prompt styling (timeout)
    ...
    with make target check, and with check-read1 into:
    ...
    (gdb) info files^M
    Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.base/style/style^[[m".^M
    --Type <RET> for more, q to quit, c to continue without paging--^M
    ^M^[[A^M
    Native process:^M
            Using the running image of child process 6179.^M
    --Type <RET> for more, q to quit, c to continue without paging--ERROR: Window too small.
    UNRESOLVED: gdb.base/style.exp: check pagination prompt styling
    ...
    
    This is caused by the following.
    
    The size of the pagination prompt is 64:
    ...
             1         2         3         4         5         6
    1234567890123456789012345678901234567890123456789012345678901234
    --Type <RET> for more, q to quit, c to continue without paging--
    ...
    and because we have TERM=ansi and width == 65, readline wraps at 64:
    ...
    (gdb) maint info screen
    Number of characters gdb thinks are in a line is 65.
    Number of characters readline reports are in a line is 64.
    ...
    
    In other words, readline wraps when printing the pagination prompt.
    
    This causes some unusual output, and the test is not prepared to handle this.
    
    Fix this by requiring that desired_width is at least
    <length of pagination prompt> + 2.
    
    Tested on x86_64-linux.
    
    Approved-By: Andrew Burgess <aburgess@redhat.com>
    
    PR testsuite/33167
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33167

Diff:
---
 gdb/testsuite/gdb.base/style.exp | 5 +++++
 gdb/testsuite/lib/gdb.exp        | 7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 8c1bb739f50..47efb646f85 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -923,6 +923,11 @@ proc test_pagination_prompt_styling {} {
 	}
     }
 
+    if { $desired_width < [string length $::pagination_prompt_str] + 2 } {
+	# Avoid readline wrapping after printing the pagination prompt.
+	return
+    }
+
     # Now setup the screen width.
     gdb_test_no_output "set width $desired_width" \
 	"set width to desired width"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 777d64d14d1..f9039dc7bc8 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -287,10 +287,13 @@ if {![info exists gdb_prompt]} {
     set gdb_prompt "\\(gdb\\)"
 }
 
-# A regexp that matches the pagination prompt.
-set pagination_prompt \
+# The pagination prompt.
+set pagination_prompt_str \
     "--Type <RET> for more, q to quit, c to continue without paging--"
 
+# A regexp that matches the pagination prompt.
+set pagination_prompt [string_to_regexp $pagination_prompt_str]
+
 # The variable fullname_syntax_POSIX is a regexp which matches a POSIX 
 # absolute path ie. /foo/ 
 set fullname_syntax_POSIX {/[^\n]*/}


More information about the Gdb-cvs mailing list