[Bug gdb/33321] [gdb] FAIL: gdb.python/py-color-pagination.exp: type=color: mode=write: color-fill write

aburgess at redhat dot com sourceware-bugzilla@sourceware.org
Tue Aug 26 08:16:33 GMT 2025


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

--- Comment #7 from Andrew Burgess <aburgess at redhat dot com> ---
(In reply to Andrew Burgess from comment #6)
> (In reply to Tom de Vries from comment #5)
> > Sounds a lot like what I ran into with commit e579b537353 ("[gdb/testsuite]
> > Fix TUI tests on freebsd").
> 
> Thanks for the reference.  That does sound like it might be the same issue. 
> Unless there's some subtlety in the expect/tcl manuals that I'm not seeing,
> I now suspect this is an expect bug.  Here's a reproducer:
> 
>   expect -c 'spawn sh -c "echo -n -e \"abc\""; set re "a"; expect -re
> "($re?)($re)(bc)"; puts "\n"; for { set i 1 } { $i < 4 } { incr i } { puts
> -nonewline "($i): \""; puts -nonewline $expect_out($i,string); puts "\"" }'
> 

Another data point, it appears the bug (if it is one) only manifests when the
optional match is at the start of the buffer.  There are two changes that can
be made which seem to avoid the bug (in the reproducer), option one, is to send
'dabc' as input.  The leading 'd' character is not matched, but now the
optional will be after the 'd', but before the 'a' character, thus:

  expect -c 'spawn sh -c "echo -n -e \"dabc\""; set re "a"; expect -re
"($re?)($re)(bc)"; puts "\n"; for { set i 1 } { $i < 4 } { incr i } { puts
-nonewline "($i): \""; puts -nonewline $expect_out($i,string); puts "\"" }'

withoutput:

  dabc

  (1): ""
  (2): "a"
  (3): "bc"

The other possible fix is to make the optional match the second item in the
regexp, as "($re)($re?)(bc)", like this (note the input is just 'abc' again):

  expect -c 'spawn sh -c "echo -n -e \"abc\""; set re "a"; expect -re
"($re)($re?)(bc)"; puts "\n"; for { set i 1 } { $i < 4 } { incr i } { puts
-nonewline "($i): \""; puts -nonewline $expect_out($i,string); puts "\"" }'

with output:

  abc

  (1): "a"
  (2): ""
  (3): "bc"

So the problem seems to be that an empty, optional, match, at the start of the
input buffer, will not work on some later versions of TCL/expect.

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


More information about the Gdb-prs mailing list