[gdb/testsuite] Fix gdb.dwarf2/dw2-using-debug-str.exp with cc-with-gdb-index

When running with target board cc-with-gdb-index, we run into:
...
(gdb) file dw2-using-debug-str-no-debug-str^M
Reading symbols from dw2-using-debug-str-no-debug-str...^M
Dwarf Error: DW_FORM_strp used without required section^M
(gdb) FAIL: gdb.dwarf2/dw2-using-debug-str.exp: file dw2-using-debug-str
...

The test expects the dwarf error, but has no matching pattern for the entire
output.

Fix this by updating the regexp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-08-02  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/dw2-using-debug-str.exp: Update regexp to match
	cc-with-gdb-index output.
This commit is contained in:
Tom de Vries 2021-08-02 15:31:51 +02:00
parent 1df42e9083
commit f7ded54b34

View file

@ -115,28 +115,32 @@ if {[run_on_host "objcopy" [gdb_find_objcopy] "$args"]} {
# executable we're going to get an error, which we check for below.
clean_restart
set line1 "Reading symbols from \[^\r\n\]+"
set dwarf_error "Dwarf Error: DW_FORM_strp used without required section"
# This pattern is hit when GDB does not use -readnow (i.e. the default
# behaviour).
set pattern1 \
[multi_line \
"Reading symbols from \[^\r\n\]+" \
"Dwarf Error: DW_FORM_strp used without required section" \
$line1 \
$dwarf_error \
"\\(No debugging symbols \[^\r\n\]+\\)"]
# This pattern is hit when GDB does use -readnow (e.g. running with
# --target_board=readnow).
set pattern2 \
[multi_line \
"Reading symbols from \[^\r\n\]+" \
$line1 \
"Expanding full symbols from \[^\r\n\]+" \
"Dwarf Error: DW_FORM_strp used without required section"]
$dwarf_error]
# This pattern is hit when gcc adds an index (e.g. running with
# --target_board=cc-with-gdb-index).
set pattern3 \
[multi_line \
$line1 \
$dwarf_error]
# Load the executable, we expect an error from the DWARF parser.
gdb_test_multiple "file $binfile_no_debug_str" "file $testfile" {
-wrap -re $pattern1 {
pass $gdb_test_name
}
-re -wrap "$pattern2" {
pass $gdb_test_name
}
}
gdb_test "file $binfile_no_debug_str" "($pattern1|$pattern2|$pattern3)" \
"file $testfile"