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

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=ebe694f0b28a2cfbb30aaf127eb7200e68871a5a

commit ebe694f0b28a2cfbb30aaf127eb7200e68871a5a
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 2)
    
    With Tcl 9.0 and test-cases gdb.ada/non-ascii-latin-{1,3}.exp we run into
    similar problems as reported in the previous patch.
    
    Work around this by avoiding non-UTF-8 chars in:
    - gdb input by using a command file, and
    - gdb output by not printing a source line containing such chars
    
    Approved-By: Tom Tromey <[email protected]>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

Diff:
---
 gdb/testsuite/gdb.ada/non-ascii-latin-1.exp | 26 +++++++++++++++++-----
 gdb/testsuite/gdb.ada/non-ascii-latin-1.gdb | 30 +++++++++++++++++++++++++
 gdb/testsuite/gdb.ada/non-ascii-latin-3.exp | 31 +++++++++++++++++++++-----
 gdb/testsuite/gdb.ada/non-ascii-latin-3.gdb | 34 +++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp b/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
index d4545dc43d8..126813066c0 100644
--- a/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
@@ -32,9 +32,13 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
     return
 }
 
+set remote_cmd_file [gdb_remote_download host $srcdir/$subdir/non-ascii-latin-1.gdb]
+
 # Restart without an executable so that we can set the encoding early.
 clean_restart
 
+gdb_test_no_output "source $remote_cmd_file" "load cmd file"
+
 # The default is Latin-1, but set this explicitly just in case we get
 # to change the default someday.
 gdb_test_no_output "set ada source-charset ISO-8859-1"
@@ -42,10 +46,22 @@ gdb_test_no_output "set ada source-charset ISO-8859-1"
 gdb_load ${binfile}
 
 set bp_location [gdb_get_line_number "BREAK" ${testdir}/prog.adb]
-runto "prog.adb:$bp_location"
 
-gdb_test "print VAR_Þ" " = 23"
-gdb_test "print var_þ" " = 23"
+# With Tcl 9.0, something (dejagnu/expect/gdb testsuite infrastructure)
+# has problems with gdb IO containing non-UTF-8 chars.  Work around this by:
+# - avoiding to show the source line, which contains non-UTF-8 chars, using
+#   "set print frame-info location", and
+# - avoiding to use commands containing non-UTF-8 chars, using user-defined
+#   commands defined in remote_cmd_file.
+
+with_set "print frame-info" "location" {
+    runto "prog.adb:$bp_location"
+}
+
+gdb_test "print_1" " = 23" "print VAR_Þ"
+gdb_test "print_2" " = 23" "print var_þ"
 
-gdb_breakpoint "FUNC_Þ" message
-gdb_breakpoint "func_þ" message
+gdb_test break_1 "Breakpoint $decimal .*" \
+    "gdb_breakpoint: set breakpoint at FUNC_Þ"
+gdb_test break_2 "Breakpoint $decimal .*" \
+    "gdb_breakpoint: set breakpoint at func_þ"
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-1.gdb b/gdb/testsuite/gdb.ada/non-ascii-latin-1.gdb
new file mode 100644
index 00000000000..446f2983a06
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-1.gdb
@@ -0,0 +1,30 @@
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+define print_1
+print VAR_Þ
+end
+
+define print_2
+print var_þ
+end
+
+define break_1
+       break "FUNC_Þ"
+end
+
+define break_2
+       break "func_þ"
+end
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp b/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
index 1ecf389e2f8..fd4cd5f064c 100644
--- a/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
@@ -32,20 +32,39 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
     return
 }
 
+set remote_cmd_file [gdb_remote_download host $srcdir/$subdir/non-ascii-latin-3.gdb]
+
 # Restart without an executable so that we can set the encoding early.
 clean_restart
 
+gdb_test_no_output "source $remote_cmd_file" "load cmd file"
+
 gdb_test_no_output "set ada source-charset ISO-8859-3"
 
 gdb_load ${binfile}
 
 set bp_location [gdb_get_line_number "BREAK" ${testdir}/prog.adb]
-runto "prog.adb:$bp_location"
 
-gdb_test "print VAR_Ż" " = 23"
-gdb_test "print var_ż" " = 23"
+# With Tcl 9.0, something (dejagnu/expect/gdb testsuite infrastructure)
+# has problems with gdb IO containing non-UTF-8 chars.  Work around this by:
+# - avoiding to show the source line, which contains non-UTF-8 chars, using
+#   "set print frame-info location", and
+# - avoiding to use commands containing non-UTF-8 chars, using user-defined
+#   commands defined in remote_cmd_file.
+
+with_set "print frame-info" "location" {
+    runto "prog.adb:$bp_location"
+}
+
+gdb_test print_1 " = 23" \
+    "print VAR_Ż"
+gdb_test print_2 " = 23" \
+    "print var_ż"
 
-gdb_breakpoint "FUNC_Ż" message
-gdb_breakpoint "func_ż" message
+gdb_test break_1 "Breakpoint $decimal .*" \
+    "gdb_breakpoint: set breakpoint at FUNC_Ż"
+gdb_test break_2 "Breakpoint $decimal .*" \
+    "gdb_breakpoint: set breakpoint at func_ż"
 
-gdb_test "print var_𝕯" "warning: charset conversion failure.*"
+gdb_test print_3 "warning: charset conversion failure.*" \
+     "print var_𝕯"
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-3.gdb b/gdb/testsuite/gdb.ada/non-ascii-latin-3.gdb
new file mode 100644
index 00000000000..d814fb19813
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-3.gdb
@@ -0,0 +1,34 @@
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+define print_1
+print VAR_Ż
+end
+
+define print_2
+print var_ż
+end
+
+define break_1
+break "FUNC_Ż"
+end
+
+define break_2
+break "func_ż"
+end
+
+define print_3
+print var_𝕯
+end
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.