]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite, Tcl 9.0] Avoid non-UTF-8 GDB IO (part 2)
authorTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:28 +0000 (10:13 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:28 +0000 (10:13 +0100)
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 <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
gdb/testsuite/gdb.ada/non-ascii-latin-1.gdb [new file with mode: 0644]
gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
gdb/testsuite/gdb.ada/non-ascii-latin-3.gdb [new file with mode: 0644]

index d4545dc43d87155734eb060c8bbebe765dc4801a..126813066c00c48d5d528954e9f3afa2b18edea3 100644 (file)
@@ -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 (file)
index 0000000..446f298
--- /dev/null
@@ -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
index 1ecf389e2f8ca334cf88f3d49d63c206da24a45e..fd4cd5f064cb33f70b58f7891a71d4d75b3f234d 100644 (file)
@@ -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 (file)
index 0000000..d814fb1
--- /dev/null
@@ -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