]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Require minimum width in gdb.base/style.exp
authorTom de Vries <tdevries@suse.de>
Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 17 Jul 2025 20:06:38 +0000 (22:06 +0200)
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

gdb/testsuite/gdb.base/style.exp
gdb/testsuite/lib/gdb.exp

index 8c1bb739f5016360816cd4505de19d981f32e075..47efb646f8539dc459ccd670183d4fc10996c17d 100644 (file)
@@ -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"
index 777d64d14d1cb806b6d9fe4b3045b34510862131..f9039dc7bc8c7d0e938c616d471efbf1d522b702 100644 (file)
@@ -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]*/}