Don't recursively look for a symbol in all imports of imported modules.
[external/binutils.git] / gdb / testsuite / gdb.dlang / circular.exp
1 # Copyright (C) 2016 Free Software Foundation, Inc.
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 # Test symbol lookup when there are multiple circular imports.
17
18 load_lib "d-support.exp"
19 load_lib "dwarf.exp"
20
21 if { [skip_d_tests] } { continue }
22
23 # This test can only be run on targets which support DWARF-2 and use gas.
24 if {![dwarf2_support]} {
25     return 0
26 }
27
28 standard_testfile circular.c circular-dw.S
29
30 # Make some DWARF for the test.
31 set asm_file [standard_output_file $srcfile2]
32 Dwarf::assemble $asm_file {
33     cu {} {
34         compile_unit {
35             {language @DW_LANG_D}
36         } {
37             declare_labels circular1_label circular2_label circular3_label
38             declare_labels circular4_label circular5_label
39
40             extern circular1_found_start circular1_found_end
41
42             circular1_label: module {
43                 {name circular1}
44             } {
45                 imported_module {
46                     {import :$circular2_label}
47                 }
48                 imported_module {
49                     {import :$circular3_label}
50                 }
51                 imported_module {
52                     {import :$circular4_label}
53                 }
54                 imported_module {
55                     {import :$circular5_label}
56                 }
57
58                 subprogram {
59                     {name found}
60                     {external 1 flag_present}
61                     {low_pc circular1_found_start addr}
62                     {high_pc circular1_found_end addr}
63                 }
64             }
65
66             circular2_label: module {
67                 {name circular2}
68             } {
69                 imported_module {
70                     {import :$circular1_label}
71                 }
72                 imported_module {
73                     {import :$circular3_label}
74                 }
75                 imported_module {
76                     {import :$circular4_label}
77                 }
78                 imported_module {
79                     {import :$circular5_label}
80                 }
81             }
82
83             circular3_label: module {
84                 {name circular3}
85             } {
86                 imported_module {
87                     {import :$circular1_label}
88                 }
89                 imported_module {
90                     {import :$circular2_label}
91                 }
92                 imported_module {
93                     {import :$circular4_label}
94                 }
95                 imported_module {
96                     {import :$circular5_label}
97                 }
98             }
99
100             circular4_label: module {
101                 {name circular4}
102             } {
103                 imported_module {
104                     {import :$circular1_label}
105                 }
106                 imported_module {
107                     {import :$circular2_label}
108                 }
109                 imported_module {
110                     {import :$circular3_label}
111                 }
112                 imported_module {
113                     {import :$circular5_label}
114                 }
115             }
116
117             circular5_label: module {
118                 {name circular5}
119             } {
120                 imported_module {
121                     {import :$circular1_label}
122                 }
123                 imported_module {
124                     {import :$circular2_label}
125                 }
126                 imported_module {
127                     {import :$circular3_label}
128                 }
129                 imported_module {
130                     {import :$circular4_label}
131                 }
132             }
133         }
134     }
135 }
136
137 if { [prepare_for_testing ${testfile}.exp ${testfile} \
138           [list $srcfile $asm_file] {nodebug}] } {
139     return -1
140 }
141
142 gdb_test_no_output "set language d"
143
144 if {![runto "circular1.found"]} {
145     return -1
146 }
147
148 # This last test shouldn't timeout.
149 gdb_test "print notfound" "No symbol \"notfound\" in current context."