[Bug testsuite/33167] New: [gdb/testsuite] FAIL: gdb.base/style.exp: check pagination prompt styling (timeout)

vries at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Thu Jul 17 04:59:15 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=33167

            Bug ID: 33167
           Summary: [gdb/testsuite] FAIL: gdb.base/style.exp: check
                    pagination prompt styling (timeout)
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: testsuite
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

The Linaro CI pointed out a regression with a patch I submitted (
https://sourceware.org/pipermail/gdb-patches/2025-July/219268.html ,
https://patchwork.sourceware.org/patch/116385 ,
https://ci.linaro.org/job/tcwg_gdb_check--master-arm-precommit/4918/artifact/artifacts/artifacts.precommit/notify/regressions.sum/*view*/
), but I managed to reproduce it on current trunk.

The patch changes the size of the pagination prompt, and that's a factor in
this.

The current 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--
...

The gdb.base/style.exp test proc test_pagination_prompt_styling first
calculates a desired_width, then uses it.

In my case, that's 88.

Now say we override the desired_width and use 65 (1 more than the size of the
pagination prompt) instead.

This exercises the case that readline wraps when printing the pagination
prompt.  

That's not obvious given that we have width 65, but we have an ansi TERM, and
consequently "maint info screen" reports:
...
(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.
...

We run into this error with make check-read1:
...
(gdb) set width 65^M
(gdb) PASS: gdb.base/style.exp: set width 65
info files^M
Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/out\
puts/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 12619.^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
...
and this timeout with make check:
...
(gdb) set width 65^M
(gdb) PASS: gdb.base/style.exp: set width 65
info files^M
Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/out\
puts/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)
...

By annotating the matching:
...
diff --git a/gdb/testsuite/gdb.base/style.exp
b/gdb/testsuite/gdb.base/style.exp
index 503671be8e6..d8c40034471 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -923,6 +923,7 @@ proc test_pagination_prompt_styling {} {
        }
     }

+    set desired_width 65
     # Now setup the screen width.
     gdb_test_no_output "set width $desired_width"

@@ -932,10 +933,12 @@ proc test_pagination_prompt_styling {} {
     set prev_line ""
     gdb_test_multiple "info files" "check pagination prompt styling" {
        -re "^info files\r\n" {
+           verbose -log "<MATCH CMD>"
            exp_continue
        }

        -re "^$::pagination_prompt$" {
+           verbose -log "<MATCH PAGINATION PROMPT>"
            if { ![previous_line_is_ok $prev_line] } {
                set saw_bad_line true
            }
@@ -944,6 +947,7 @@ proc test_pagination_prompt_styling {} {
        }

        -re "^(\[^\r\n\]+)$::pagination_prompt$" {
+           verbose -log "<MATCH PAGINATION PROMPT WITH PREFIX>"
            set prev_line $expect_out(1,string)
            if { ![previous_line_is_ok $prev_line] } {
                set saw_bad_line true
@@ -953,10 +957,12 @@ proc test_pagination_prompt_styling {} {
        }

        -re "^$::gdb_prompt $" {
+           verbose -log "<MATCH GDB PROMPT>"
            gdb_assert { !$saw_bad_line } $gdb_test_name
        }

        -re "^(\[^\r\n\]*)\r\n" {
+           verbose -log "<MATCH RANDOM LINE>"
            set prev_line $expect_out(1,string)
            exp_continue
        }
...
and running check-read1, we get more info:
...
(gdb) set width 65^M
(gdb) PASS: gdb.base/style.exp: set width 65
info files^M
<MATCH CMD>
Symbols from "^[[32;49;22;27m/data/vries/gdb/leap-15-6/build/gdb/testsuite/out\
puts/gdb.base/style/style^[[m".^M
<MATCH RANDOM LINE>
--Type <RET> for more, q to quit, c to continue without paging--<MATCH PAGINAT\
ION PROMPT>
^M
<MATCH RANDOM LINE>
^M^[[A^M
Native process:^M
        Using the running image of child process 16831.^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
...

Matching stops after encountering "^M^[[A^M".

The "^[[A" bit is Cursor up ( https://vt100.net/docs/vt510-rm/CUU.html ),
something that readline emits.

The problem is that the MATCH RANDOM LINE pattern "^(\[^\r\n\]*)\r\n" doesn't
match this line because it contains a \r.

The check-read1 is fixed by:
...
-       -re "^(\[^\r\n\]*)\r\n" {
+       -re "^(\[^\n\]*)\r\n" {
...
but the timeout with check still happens though.

It's probably best to require that $desired_width is large enough to guarantee
no readline wrapping.

Running the test-case again with desired_width 66 does get rid of the error and
the timeout with both check and check-read1, but we do run into a failure.

We run into line:
...
        0x00007ffff7dfbcf0 - 0x00007ffff7dfbd00 is .init_array in --Type <RET>\
 for more, q to quit, c to continue without paging--
...
which is considered to be bad line because the test considers that a style
reset must occur at the end of the line, but is missing.

Fixed by:
...
-    if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in " $str] } {
+    if { ![regexp "\\s+$::hex - $::hex is \[^\r\n\]+ in \033" $str] } {
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list