Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-missing-cu-tag.exp
CommitLineData
88b9d363 1# Copyright 2021-2022 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
20load_lib dwarf.exp
21
22# This test can only be run on targets which support DWARF-2 and use
23# gas.
24if {![dwarf2_support]} {
25 return 0
26}
27
28standard_testfile .c -dw.S
29
30set asm_file [standard_output_file $srcfile2]
31Dwarf::assemble $asm_file {
32 cu {} {
33 # We should have either one of DW_TAG_compile_unit,
34 # DW_TAG_partial_unit, or DW_TAG_type_unit here.
35 subprogram {
36 {external 1 flag}
37 {MACRO_AT_func {main}}
38 }
39 }
40}
41
42# Don't use prepare_for_testing here as we want to manually run the
43# file command (so we can check its output).
44if {[build_executable "failed to build executable" $testfile \
45 [list $srcfile $asm_file] {nodebug quiet}]} {
46 return -1
47}
48
49# Restart with no executable.
50clean_restart
51
52# This pattern is hit when GDB does not use -readnow (i.e. the default
53# behaviour).
54set pattern1 \
55 [multi_line \
56 "Reading symbols from \[^\r\n\]+" \
57 "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex \\\[\[^\r\n\]+\\\]" \
58 "\\(No debugging symbols \[^\r\n\]+\\)"]
59
60# This pattern is hit when GDB does use -readnow (e.g. running with
61# --target_board=readnow).
62set pattern2 \
63 [multi_line \
64 "Reading symbols from \[^\r\n\]+" \
65 "Expanding full symbols from \[^\r\n\]+" \
66 "Dwarf Error: unexpected tag 'DW_TAG_subprogram' at offset $hex \\\[\[^\r\n\]+\\\]"]
67
68# Load the executable, we expect an error from the DWARF parser.
69gdb_test_multiple "file $binfile" "file $testfile" {
70 -wrap -re $pattern1 {
71 pass $gdb_test_name
72 }
73 -re -wrap "$pattern2" {
74 pass $gdb_test_name
75 }
76}
This page took 0.137209 seconds and 4 git commands to generate.