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