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