[binutils-gdb] [gdb/testsuite, Tcl 9.0] Avoid non-UTF-8 GDB IO (part 1)

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bcd41a3d4808d37ff827dc055dd2b32e7be47078

commit bcd41a3d4808d37ff827dc055dd2b32e7be47078
Author: Tom de Vries <[email protected]>
Date:   Fri Mar 20 10:13:28 2026 +0100

    [gdb/testsuite, Tcl 9.0] Avoid non-UTF-8 GDB IO (part 1)
    
    When running test-case gdb.python/py-source-styling.exp with Tcl 9.0, I get:
    ...
    python gdb.execute('list 26')^M
    <SNIP>/* The following line contains a character that is non-utf-8.  This is a
    <SNIP>   critical part of the test as Python 3 can't convert this into a string
    <SNIIP>  using its default mechanism.  */
    <SNIP>FAIL: $exp: test_source_cache_style_tracking: \
      python gdb.execute('list 26') (timeout)
    ERROR: i_read(spawn_id fd=9): invalid or incomplete multibyte or wide character
        while executing
    "expect {
    -i exp9 -timeout 10
            -re ".*A problem internal to GDB has been detected" {
                fail "$message (GDB internal error)"
                gdb_internal_error..."
        ("uplevel" body line 1)
        invoked from within
    "uplevel $body" POSIX EILSEQ {invalid or incomplete multibyte or wide \
      character} i_read(spawn_id fd=9)
    : invalid or incomplete multibyte or wide character
    Couldn't send python gdb.execute('list 26', to_string=False, styling=True) to GDB.
    ...
    
    I have tried a fix similar to the previous commit in default_gdb_spawn:
    ...
    +    if {[tcl_version_at_least 9 0 0]} {
    +       set fd [exp_open -leaveopen -i $res]
    +       fconfigure $fd -encoding utf-8 -profile replace
    +    }
    +
    ...
    but that doesn't seem to work.
    
    Work around this by skipping the part that runs into this problem.
    
    Approved-By: Tom Tromey <[email protected]>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

Diff:
---
 gdb/testsuite/gdb.python/py-source-styling.exp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp
index 05fd077022b..12d43e63ea8 100644
--- a/gdb/testsuite/gdb.python/py-source-styling.exp
+++ b/gdb/testsuite/gdb.python/py-source-styling.exp
@@ -149,6 +149,12 @@ proc_with_prefix test_source_cache_style_tracking {} {
 	    false
     }
 
+    # With Tcl 9.0, something (dejagnu/expect/gdb testsuite infrastructure)
+    # has problems with gdb IO containing non-utf-8 chars.  Work around this by
+    # requiring Tcl 8.6 for the following tests.  PR testsuite/33987 is open to
+    # come up with a better solution.
+    require {expr {$::tcl_version == 8.6}}
+
     # The same again, but this time the output is sent directly to
     # stdout.
     check_source_listing_styling \
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.