From: Tom de Vries Date: Fri, 20 Mar 2026 09:13:28 +0000 (+0100) Subject: [gdb/testsuite, Tcl 9.0] Avoid non-UTF-8 GDB IO (part 2) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebe694f0b28a2cfbb30aaf127eb7200e68871a5a;p=thirdparty%2Fbinutils-gdb.git [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 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948 --- 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 . + +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 . + +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