1 # Copyright 2021-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This test creates some invalid DWARF, compiles this into an
17 # executable, then tries to load the executable using the 'file'
18 # command. We expect to see an error from the DWARF parser.
22 # This test can only be run on targets which support DWARF-2 and use
24 require dwarf2_support
26 standard_testfile .c -dw.S
28 set asm_file [standard_output_file $srcfile2]
29 Dwarf::assemble $asm_file {
31 # We should have either one of DW_TAG_compile_unit,
32 # DW_TAG_partial_unit, or DW_TAG_type_unit here.
35 {MACRO_AT_func {main}}
40 # Don't use prepare_for_testing here as we want to manually run the
41 # file command (so we can check its output).
42 if {[build_executable "failed to build executable" $testfile \
43 [list $srcfile $asm_file] {nodebug quiet}]} {
47 set host_binfile [gdb_remote_download host $binfile]
49 # Restart with no executable.
52 gdb_test_no_output "maint set dwarf synchronous on"
54 # This pattern is hit when GDB does not use -readnow (i.e. the default
58 "Reading symbols from \[^\r\n\]+" \
59 "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"]
61 # This pattern is hit when GDB does use -readnow (e.g. running with
62 # --target_board=readnow).
65 "Reading symbols from \[^\r\n\]+" \
66 "Expanding full symbols from \[^\r\n\]+" \
67 "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"]
69 # Load the executable, we expect an error from the DWARF parser.
70 gdb_test_multiple "file $host_binfile" "file $testfile" {
74 -re -wrap "$pattern2" {