]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2021-2024 Free Software Foundation, Inc. |
702cf3f5 AB |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
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. | |
19 | ||
20 | load_lib dwarf.exp | |
21 | ||
22 | # This test can only be run on targets which support DWARF-2 and use | |
23 | # gas. | |
ce8d533e | 24 | require dwarf2_support |
702cf3f5 AB |
25 | |
26 | standard_testfile .c -dw.S | |
27 | ||
28 | set asm_file [standard_output_file $srcfile2] | |
29 | Dwarf::assemble $asm_file { | |
30 | cu {} { | |
31 | # We should have either one of DW_TAG_compile_unit, | |
32 | # DW_TAG_partial_unit, or DW_TAG_type_unit here. | |
33 | subprogram { | |
34 | {external 1 flag} | |
35 | {MACRO_AT_func {main}} | |
36 | } | |
37 | } | |
38 | } | |
39 | ||
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}]} { | |
44 | return -1 | |
45 | } | |
46 | ||
8eef5130 TV |
47 | set host_binfile [gdb_remote_download host $binfile] |
48 | ||
702cf3f5 AB |
49 | # Restart with no executable. |
50 | clean_restart | |
51 | ||
33c6eaae TT |
52 | gdb_test_no_output "maint set dwarf synchronous on" |
53 | ||
702cf3f5 AB |
54 | # This pattern is hit when GDB does not use -readnow (i.e. the default |
55 | # behaviour). | |
56 | set pattern1 \ | |
57 | [multi_line \ | |
58 | "Reading symbols from \[^\r\n\]+" \ | |
52c0a455 | 59 | "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"] |
702cf3f5 AB |
60 | |
61 | # This pattern is hit when GDB does use -readnow (e.g. running with | |
62 | # --target_board=readnow). | |
63 | set pattern2 \ | |
64 | [multi_line \ | |
65 | "Reading symbols from \[^\r\n\]+" \ | |
66 | "Expanding full symbols from \[^\r\n\]+" \ | |
52c0a455 | 67 | "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex"] |
702cf3f5 AB |
68 | |
69 | # Load the executable, we expect an error from the DWARF parser. | |
8eef5130 | 70 | gdb_test_multiple "file $host_binfile" "file $testfile" { |
702cf3f5 AB |
71 | -wrap -re $pattern1 { |
72 | pass $gdb_test_name | |
73 | } | |
74 | -re -wrap "$pattern2" { | |
75 | pass $gdb_test_name | |
76 | } | |
77 | } |