xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.dlang/circular.exp (revision b2c35e17b976cf7ccd7250c86c6f5e95090ed636)
1# Copyright (C) 2016-2020 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
18load_lib "d-support.exp"
19load_lib "dwarf.exp"
20
21if { [skip_d_tests] } { continue }
22
23# This test can only be run on targets which support DWARF-2 and use gas.
24if {![dwarf2_support]} {
25    return 0
26}
27
28standard_testfile circular.c circular-dw.S
29
30# Make some DWARF for the test.
31set asm_file [standard_output_file $srcfile2]
32Dwarf::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	    circular1_label: module {
41		{name circular1}
42	    } {
43		imported_module {
44		    {import :$circular2_label}
45		}
46		imported_module {
47		    {import :$circular3_label}
48		}
49		imported_module {
50		    {import :$circular4_label}
51		}
52		imported_module {
53		    {import :$circular5_label}
54		}
55
56		subprogram {
57		    {external 1 flag_present}
58		    {MACRO_AT_func {found}}
59		}
60	    }
61
62	    circular2_label: module {
63		{name circular2}
64	    } {
65		imported_module {
66		    {import :$circular1_label}
67		}
68		imported_module {
69		    {import :$circular3_label}
70		}
71		imported_module {
72		    {import :$circular4_label}
73		}
74		imported_module {
75		    {import :$circular5_label}
76		}
77	    }
78
79	    circular3_label: module {
80		{name circular3}
81	    } {
82		imported_module {
83		    {import :$circular1_label}
84		}
85		imported_module {
86		    {import :$circular2_label}
87		}
88		imported_module {
89		    {import :$circular4_label}
90		}
91		imported_module {
92		    {import :$circular5_label}
93		}
94	    }
95
96	    circular4_label: module {
97		{name circular4}
98	    } {
99		imported_module {
100		    {import :$circular1_label}
101		}
102		imported_module {
103		    {import :$circular2_label}
104		}
105		imported_module {
106		    {import :$circular3_label}
107		}
108		imported_module {
109		    {import :$circular5_label}
110		}
111	    }
112
113	    circular5_label: module {
114		{name circular5}
115	    } {
116		imported_module {
117		    {import :$circular1_label}
118		}
119		imported_module {
120		    {import :$circular2_label}
121		}
122		imported_module {
123		    {import :$circular3_label}
124		}
125		imported_module {
126		    {import :$circular4_label}
127		}
128	    }
129	}
130    }
131}
132
133if { [prepare_for_testing "failed to prepare" ${testfile} \
134          [list $srcfile $asm_file] {nodebug}] } {
135    return -1
136}
137
138gdb_test_no_output "set language d"
139
140if {![runto "circular1.found"]} {
141    return -1
142}
143
144# This last test shouldn't timeout.
145gdb_test "print notfound" "No symbol \"notfound\" in current context."
146