From: Tom de Vries Date: Mon, 3 Aug 2026 17:51:31 +0000 (+0200) Subject: [gdb/testsuite] Fix gdb.dwarf2/dw-form-strx-out-of-bounds.exp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a58e6081294fd3dde8fc7397f3a09f8c8a3f87aa;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix gdb.dwarf2/dw-form-strx-out-of-bounds.exp With test-case gdb.dwarf2/dw-form-strx-out-of-bounds.exp, I usually get: ... (gdb) file dw-form-strx-out-of-bounds Reading symbols from dw-form-strx-out-of-bounds... (gdb) ptype global_var DWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing \ outside of .debug_str_offsets section in CU at offset 0x2d1 [in module \ dw-form-strx-out-of-bounds] No symbol "global_var" in current context. (gdb) PASS: $exp: ptype global_var ... But I just ran into: ... (gdb) file dw-form-strx-out-of-bounds^M Reading symbols from dw-form-strx-out-of-bounds... DWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx pointing \ outside of .debug_str_offsets section in CU at offset 0x2df [in module \ dw-form-strx-out-of-bounds]^M (gdb) ptype global_var^M No symbol "global_var" in current context.^M (gdb) FAIL: $exp: ptype global_var ... Fix this by: - using "maint set dwarf synchronous on" to ensure that the error happens during the file command - updating the matching to check $gdb_file_cmd_msg Tested gdb.dwarf2/dw-form-strx-out-of-bounds.exp and gdb.dwarf2/dw-form-strx.exp using make-check-all.sh on x86_64-linux. --- diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp index be7323bce95..e1e28eb432f 100644 --- a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp @@ -34,8 +34,7 @@ set re_dwarf_error \ set re_in_module \ {in module [^\r\n]+} set re_in_module [string_to_regexp {[}]$re_in_module[string_to_regexp {]}] +gdb_assert {[regexp "$re_dwarf_error $re_in_module" $gdb_file_cmd_msg]} + set re_no_symbol [string_to_regexp {No symbol "global_var" in current context.}] -gdb_test "ptype global_var" \ - [multi_line \ - "$re_dwarf_error $re_in_module"\ - $re_no_symbol] +gdb_test "ptype global_var" $re_no_symbol diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl index 931c935ccae..b261dc654af 100644 --- a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl @@ -54,11 +54,17 @@ Dwarf::assemble $asm_file { } } -if { [prepare_for_testing "failed to prepare" ${testfile} \ +if { [build_executable "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { return } +clean_restart + +gdb_test_no_output "maint set dwarf synchronous on" + +gdb_load $binfile + # Let includers know prepare_for_testing was done, without having to check # source return status. set prepare_for_testing_done 1