Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, |
0fb0cc75 | 2 | # 2007, 2008, 2009 Free Software Foundation, Inc. |
c906108c SS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Fred Fish. (fnf@cygnus.com) |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | set prms_id 0 | |
24 | set bug_id 0 | |
25 | ||
26 | set testfile "scope" | |
27 | set binfile ${objdir}/${subdir}/${testfile} | |
28 | ||
29 | ||
30 | if { [gdb_compile "${srcdir}/${subdir}/scope0.c" "${binfile}0.o" object {debug}] != "" } { | |
b60f0898 JB |
31 | untested scope.exp |
32 | return -1 | |
c906108c SS |
33 | } |
34 | ||
35 | if { [gdb_compile "${srcdir}/${subdir}/scope1.c" "${binfile}1.o" object {debug}] != "" } { | |
b60f0898 JB |
36 | untested scope.exp |
37 | return -1 | |
c906108c SS |
38 | } |
39 | ||
40 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
b60f0898 JB |
41 | untested scope.exp |
42 | return -1 | |
c906108c SS |
43 | } |
44 | ||
45 | # Create and source the file that provides information about the compiler | |
46 | # used to compile the test case. | |
47 | if [get_compiler_info ${binfile}] { | |
48 | return -1; | |
49 | } | |
50 | ||
51 | # Test locating various things when stopped just inside main, after | |
52 | # running init0(). To prevent cascading of errors, we report the | |
53 | # first one and quit. If all pass, then we print the pass results. | |
54 | ||
55 | proc test_at_main {} { | |
56 | global gdb_prompt | |
57 | global decimal | |
58 | global det_file | |
59 | global srcdir | |
60 | global subdir | |
085dd6e6 | 61 | global hp_cc_compiler |
c906108c | 62 | |
34e41e63 JB |
63 | # skip past init0. |
64 | # This used to do an extra "next" if the first one didn't get us | |
65 | # over the call to init0, to handle calls to __main in the | |
66 | # prologue, etc. But if a breakpoint at main doesn't leave us on | |
67 | # the first line of real code in the function, that's a GDB bug. | |
68 | gdb_test "next" "$decimal.*foo \\(\\);" "next over init0() in main" | |
c906108c SS |
69 | |
70 | # Print scope0.c::filelocal, which is 1 | |
71 | ||
72 | if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] { | |
73 | gdb_suppress_tests ; | |
74 | } | |
75 | ||
76 | ||
77 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
78 | gdb_suppress_tests ; | |
79 | } | |
80 | ||
81 | ||
82 | # Print scope0.c::filelocal_bss, which is 101 | |
83 | ||
84 | if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] { | |
85 | gdb_suppress_tests ; | |
86 | } | |
87 | ||
88 | ||
89 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_main" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
90 | gdb_suppress_tests ; | |
91 | } | |
92 | ||
93 | ||
94 | # Print scope0.c::filelocal_ro, which is 201 | |
95 | ||
15656118 | 96 | # No clue why the rs6000 fails this test. |
ba9b20a7 | 97 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
98 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] { |
99 | gdb_suppress_tests ; | |
100 | } | |
101 | ||
102 | ||
ba9b20a7 | 103 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
104 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
105 | gdb_suppress_tests ; | |
106 | } | |
107 | ||
108 | ||
109 | # Print scope1.c::filelocal, which is 2 | |
110 | ||
ba9b20a7 | 111 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
112 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
113 | gdb_suppress_tests ; | |
114 | } | |
115 | ||
116 | ||
117 | # Print scope1.c::filelocal_bss, which is 102 | |
118 | ||
ba9b20a7 | 119 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
120 | if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { |
121 | gdb_suppress_tests ; | |
122 | } | |
123 | ||
124 | ||
125 | # Print scope1.c::filelocal_ro, which is 202 | |
126 | ||
ba9b20a7 | 127 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
a0b3c4fd | 128 | if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs} |
c906108c SS |
129 | if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { |
130 | gdb_suppress_tests ; | |
131 | } | |
132 | ||
133 | ||
134 | # Print scope1.c::foo::funclocal, which is 3 | |
135 | ||
c906108c SS |
136 | if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] { |
137 | gdb_suppress_tests ; | |
138 | } | |
139 | ||
140 | ||
ba9b20a7 | 141 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
142 | if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { |
143 | gdb_suppress_tests ; | |
144 | } | |
145 | ||
146 | ||
147 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
148 | ||
149 | if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] { | |
150 | gdb_suppress_tests ; | |
151 | } | |
152 | ||
153 | ||
ba9b20a7 | 154 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
155 | if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { |
156 | gdb_suppress_tests ; | |
157 | } | |
158 | ||
159 | ||
160 | # Print scope1.c::bar::funclocal, which is 4 | |
161 | ||
162 | if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] { | |
163 | gdb_suppress_tests ; | |
164 | } | |
165 | ||
166 | ||
ba9b20a7 | 167 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
168 | if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { |
169 | gdb_suppress_tests ; | |
170 | } | |
171 | gdb_stop_suppressing_tests; | |
172 | ||
173 | } | |
174 | ||
175 | proc test_at_foo {} { | |
176 | global gdb_prompt | |
177 | global decimal | |
178 | global det_file | |
179 | global srcdir | |
180 | global subdir | |
c906108c SS |
181 | |
182 | if [gdb_test "next" ".*bar \\(\\);" "" ] { | |
183 | gdb_suppress_tests ; | |
184 | } | |
185 | ||
186 | ||
187 | # Print scope0.c::filelocal, which is 1 | |
188 | ||
189 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
190 | gdb_suppress_tests ; | |
191 | } | |
192 | ||
193 | ||
194 | # Print scope0.c::filelocal_bss, which is 101 | |
195 | ||
196 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_foo" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
197 | gdb_suppress_tests ; | |
198 | } | |
199 | ||
200 | ||
201 | # Print scope0.c::filelocal_ro, which is 201 | |
202 | ||
ba9b20a7 | 203 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
204 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
205 | gdb_suppress_tests ; | |
206 | } | |
207 | ||
208 | ||
209 | gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo" | |
210 | ||
211 | # Print scope1.c::filelocal, which is 2 | |
212 | ||
ba9b20a7 | 213 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
214 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
215 | gdb_suppress_tests ; | |
216 | } | |
217 | ||
218 | ||
219 | gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ | |
220 | "print filelocal_bss at foo" | |
221 | ||
ba9b20a7 | 222 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
223 | gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss" |
224 | ||
225 | ||
226 | gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ | |
227 | "print filelocal_ro at foo" | |
228 | ||
ba9b20a7 | 229 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
230 | gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro" |
231 | ||
232 | ||
233 | # Print scope1.c::foo::funclocal, which is 3 | |
234 | ||
235 | gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo" | |
236 | ||
c906108c SS |
237 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" \ |
238 | "print foo::funclocal at foo" | |
239 | ||
ba9b20a7 | 240 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
241 | gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal" |
242 | ||
243 | ||
244 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
245 | ||
246 | gdb_test "print funclocal_bss" "\\\$$decimal = 103" \ | |
247 | "print funclocal_bss at foo" | |
248 | ||
c906108c SS |
249 | gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \ |
250 | "print foo::funclocal_bss at foo" | |
251 | ||
ba9b20a7 | 252 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
253 | gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss" |
254 | ||
255 | ||
256 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
257 | ||
258 | gdb_test "print funclocal_ro" "\\\$$decimal = 203" \ | |
259 | "print funclocal_ro at foo" | |
260 | ||
c906108c SS |
261 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \ |
262 | "print foo::funclocal_ro at foo" | |
263 | ||
ba9b20a7 | 264 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
265 | gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro" |
266 | ||
267 | ||
268 | # Print scope1.c::bar::funclocal, which is 4 | |
269 | ||
c906108c SS |
270 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" \ |
271 | "print bar::funclocal at foo" | |
272 | ||
ba9b20a7 | 273 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
274 | gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal" |
275 | gdb_stop_suppressing_tests; | |
276 | ||
277 | } | |
278 | ||
279 | proc test_at_bar {} { | |
280 | global gdb_prompt | |
281 | global decimal | |
282 | global det_file | |
283 | global srcdir | |
284 | global subdir | |
c906108c SS |
285 | |
286 | if [gdb_test "next" ".*" "" ] { | |
287 | gdb_suppress_tests ; | |
288 | } | |
289 | ||
290 | ||
291 | # Print scope0.c::filelocal, which is 1 | |
292 | ||
293 | if [gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal"] { | |
294 | gdb_suppress_tests ; | |
295 | } | |
296 | ||
297 | ||
298 | # Print scope0.c::filelocal_bss, which is 101 | |
299 | ||
300 | if [gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_bss"] { | |
301 | gdb_suppress_tests ; | |
302 | } | |
303 | ||
304 | ||
305 | # Print scope0.c::filelocal_ro, which is 201 | |
306 | ||
ba9b20a7 | 307 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
308 | if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { |
309 | gdb_suppress_tests ; | |
310 | } | |
311 | ||
312 | ||
313 | # Print scope1.c::filelocal, which is 2 | |
314 | ||
315 | if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] { | |
316 | gdb_suppress_tests ; | |
317 | } | |
318 | ||
319 | ||
ba9b20a7 | 320 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
321 | if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { |
322 | gdb_suppress_tests ; | |
323 | } | |
324 | ||
325 | ||
326 | # Print scope1.c::filelocal_bss, which is 102 | |
327 | ||
328 | if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] { | |
329 | gdb_suppress_tests ; | |
330 | } | |
331 | ||
332 | ||
ba9b20a7 | 333 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
334 | if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { |
335 | gdb_suppress_tests ; | |
336 | } | |
337 | ||
338 | ||
339 | # Print scope1.c::filelocal_ro, which is 202 | |
340 | ||
341 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] { | |
342 | gdb_suppress_tests ; | |
343 | } | |
344 | ||
345 | ||
ba9b20a7 | 346 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
347 | if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { |
348 | gdb_suppress_tests ; | |
349 | } | |
350 | ||
351 | ||
352 | # Print scope1.c::foo::funclocal, which is 3 | |
353 | ||
c906108c SS |
354 | if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] { |
355 | gdb_suppress_tests ; | |
356 | } | |
357 | ||
358 | ||
ba9b20a7 | 359 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
360 | if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { |
361 | gdb_suppress_tests ; | |
362 | } | |
363 | ||
364 | ||
365 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
366 | ||
367 | if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] { | |
368 | gdb_suppress_tests ; | |
369 | } | |
370 | ||
371 | ||
ba9b20a7 | 372 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
373 | if [gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss"] { |
374 | gdb_suppress_tests ; | |
375 | } | |
376 | ||
377 | ||
378 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
379 | ||
380 | if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] { | |
381 | gdb_suppress_tests ; | |
382 | } | |
383 | ||
384 | ||
ba9b20a7 | 385 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
386 | if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { |
387 | gdb_suppress_tests ; | |
388 | } | |
389 | ||
390 | ||
391 | # Print scope1.c::bar::funclocal, which is 4 | |
392 | ||
393 | if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] { | |
394 | gdb_suppress_tests ; | |
395 | } | |
396 | ||
397 | ||
398 | if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] { | |
399 | gdb_suppress_tests ; | |
400 | } | |
401 | ||
402 | ||
ba9b20a7 | 403 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
404 | if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { |
405 | gdb_suppress_tests ; | |
406 | } | |
407 | ||
408 | ||
409 | # Print scope1.c::bar::funclocal_bss, which is 104 | |
410 | ||
411 | if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] { | |
412 | gdb_suppress_tests ; | |
413 | } | |
414 | ||
415 | ||
416 | if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] { | |
417 | gdb_suppress_tests ; | |
418 | } | |
419 | ||
420 | ||
ba9b20a7 | 421 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
422 | if [gdb_test "print 'scope1.c'::bar::funclocal_bss" "\\\$$decimal = 104" "print 'scope1.c'::bar::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss"] { |
423 | gdb_suppress_tests ; | |
424 | } | |
425 | gdb_stop_suppressing_tests; | |
426 | ||
427 | } | |
428 | ||
429 | # This test has little to do with local scopes, but it is in scope.exp anyway. | |
430 | # That's life. | |
431 | ||
432 | proc test_at_autovars {} { | |
433 | global gdb_prompt | |
434 | global decimal | |
435 | global hex | |
436 | global srcfile | |
437 | ||
438 | # Test symbol table lookup with 100 local (auto) variables. | |
439 | ||
440 | gdb_breakpoint marker1 | |
441 | ||
442 | if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] { | |
443 | gdb_suppress_tests; | |
444 | } | |
445 | ||
660fd469 | 446 | if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] { |
c906108c SS |
447 | gdb_suppress_tests ; |
448 | } | |
449 | ||
450 | set count 0 | |
451 | while {$count < 100} { | |
452 | if [gdb_test "print i$count" ".* = $count" "" ] { | |
453 | gdb_suppress_tests ; | |
454 | } | |
455 | ||
456 | set count [expr $count+1] | |
457 | } | |
458 | clear_xfail "*-*-*" | |
459 | pass "$count auto variables correctly initialized" | |
460 | ||
461 | # Test that block variable sorting is not screwing us. | |
462 | gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order" | |
463 | } | |
464 | ||
465 | proc test_at_localscopes {} { | |
466 | global gdb_prompt | |
467 | global decimal | |
468 | global hex | |
469 | global srcfile | |
470 | ||
471 | gdb_breakpoint marker2 | |
472 | gdb_breakpoint marker3 | |
473 | gdb_breakpoint marker4 | |
474 | ||
475 | if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] { | |
476 | gdb_suppress_tests; | |
477 | } | |
660fd469 | 478 | if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] { |
c906108c SS |
479 | gdb_suppress_tests ; |
480 | } | |
481 | ||
482 | # Should be at first (outermost) scope. Check values. | |
483 | ||
484 | gdb_test "print localval" " = 10" "print localval, outer scope" | |
485 | gdb_test "print localval1" " = 11" "print localval1, outer scope" | |
486 | gdb_test "print localval2" "No symbol \"localval2\" in current context." \ | |
487 | "print localval2, outer scope" | |
488 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
489 | "print localval3, outer scope" | |
490 | ||
491 | if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \ | |
492 | "continue to marker3 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
493 | if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] { |
494 | gdb_suppress_tests | |
495 | } | |
c906108c SS |
496 | |
497 | # Should be at next (first nested) scope. Check values. | |
498 | ||
499 | gdb_test "print localval" " = 20" \ | |
500 | "print localval, first nested scope" | |
501 | gdb_test "print localval1" " = 11" "print localval1, first nested scope" | |
502 | gdb_test "print localval2" " = 12" "print localval2, first nested scope" | |
503 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
504 | "print localval3, first nested scope" | |
505 | ||
506 | # This test will only fail if the file was compiled by gcc, but | |
507 | # there's no way to check that. | |
c906108c SS |
508 | if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \ |
509 | "continue to marker4 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
510 | if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] { |
511 | gdb_suppress_tests | |
512 | } | |
c906108c SS |
513 | |
514 | gdb_test "print localval" " = 30" "print localval, innermost scope" | |
515 | gdb_test "print localval1" " = 11" "print localval1, innermost scope" | |
516 | gdb_test "print localval2" " = 12" "print localval2, innermost scope" | |
517 | gdb_test "print localval3" " = 13" "print localval3, innermost scope" | |
518 | gdb_stop_suppressing_tests; | |
519 | } | |
520 | ||
521 | # Start with a fresh gdb. | |
522 | ||
523 | gdb_exit | |
524 | gdb_start | |
525 | gdb_reinitialize_dir $srcdir/$subdir | |
526 | gdb_load ${binfile} | |
527 | ||
528 | if [istarget "*-*-vxworks*"] { | |
529 | set timeout 120 | |
530 | verbose "Timeout is now $timeout seconds" 2 | |
531 | } | |
532 | ||
533 | # Test that variables in various segments print out correctly before | |
534 | # the program is run. | |
535 | ||
536 | # AIX--sections get mapped to the same address so we can't get the right one. | |
537 | setup_xfail "rs6000-*-*" | |
c906108c SS |
538 | |
539 | gdb_test "print 'scope0.c'::filelocal_ro" "= 201" | |
540 | ||
541 | # gdb currently cannot access bss memory on some targets if the inferior | |
542 | # is not running. | |
543 | # | |
544 | # For PA boards using monitor/remote-pa.c, the bss test is going to | |
545 | # randomly fail. We've already put remote-pa on the target stack, | |
546 | # so we actually read memory from the board. Problem is crt0.o | |
547 | # is responsible for clearing bss and that hasnt' happened yet. | |
548 | # | |
549 | # This is a problem for all non-native targets. -- manson | |
676a0442 | 550 | if [is_remote target] { |
c906108c SS |
551 | unsupported "print 'scope0.c'::filelocal_bss before run" |
552 | } else { | |
553 | gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ | |
554 | "print 'scope0.c'::filelocal_bss before run" | |
555 | } | |
556 | ||
557 | gdb_test "print 'scope0.c'::filelocal" "= 1" \ | |
558 | "print 'scope0.c'::filelocal before run" | |
559 | ||
560 | if [runto_main] then { test_at_main } | |
561 | if [istarget "mips-idt-*"] then { | |
562 | # Restart because IDT/SIM runs out of file descriptors. | |
563 | gdb_exit | |
564 | gdb_start | |
565 | gdb_reinitialize_dir $srcdir/$subdir | |
566 | gdb_load ${binfile} | |
567 | } | |
568 | if [runto foo] then { test_at_foo } | |
569 | if [istarget "mips-idt-*"] then { | |
570 | # Restart because IDT/SIM runs out of file descriptors. | |
571 | gdb_exit | |
572 | gdb_start | |
573 | gdb_reinitialize_dir $srcdir/$subdir | |
574 | gdb_load ${binfile} | |
575 | } | |
576 | if [runto bar] then { test_at_bar } | |
577 | if [istarget "mips-idt-*"] then { | |
578 | # Restart because IDT/SIM runs out of file descriptors. | |
579 | gdb_exit | |
580 | gdb_start | |
581 | gdb_reinitialize_dir $srcdir/$subdir | |
582 | gdb_load ${binfile} | |
583 | } | |
584 | if [runto localscopes] then { test_at_localscopes } | |
585 | if [istarget "mips-idt-*"] then { | |
586 | # Restart because IDT/SIM runs out of file descriptors. | |
587 | gdb_exit | |
588 | gdb_start | |
589 | gdb_reinitialize_dir $srcdir/$subdir | |
590 | gdb_load ${binfile} | |
591 | } | |
592 | if [runto autovars] then { test_at_autovars } | |
593 | ||
594 | if [istarget "*-*-vxworks*"] { | |
595 | set timeout 120 | |
596 | verbose "Timeout is now $timeout seconds" 2 | |
597 | } |