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.
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
}
}
-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