Commit | Line | Data |
---|---|---|
83b8cf9d MC |
1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
2 | # 2004 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 | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
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. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | # This file was written by Fred Fish. (fnf@cygnus.com) | |
22 | ||
23 | if $tracelevel then { | |
24 | strace $tracelevel | |
25 | } | |
26 | ||
27 | set prms_id 0 | |
28 | set bug_id 0 | |
29 | ||
30 | set testfile "scope" | |
31 | set binfile ${objdir}/${subdir}/${testfile} | |
32 | ||
33 | ||
34 | if { [gdb_compile "${srcdir}/${subdir}/scope0.c" "${binfile}0.o" object {debug}] != "" } { | |
35 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
36 | } | |
37 | ||
38 | if { [gdb_compile "${srcdir}/${subdir}/scope1.c" "${binfile}1.o" object {debug}] != "" } { | |
39 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
40 | } | |
41 | ||
42 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
43 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
44 | } | |
45 | ||
46 | # Create and source the file that provides information about the compiler | |
47 | # used to compile the test case. | |
48 | if [get_compiler_info ${binfile}] { | |
49 | return -1; | |
50 | } | |
51 | ||
52 | # Test locating various things when stopped just inside main, after | |
53 | # running init0(). To prevent cascading of errors, we report the | |
54 | # first one and quit. If all pass, then we print the pass results. | |
55 | ||
56 | proc test_at_main {} { | |
57 | global gdb_prompt | |
58 | global decimal | |
59 | global det_file | |
60 | global srcdir | |
61 | global subdir | |
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-*-*" | |
ba9b20a7 | 99 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
100 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] { |
101 | gdb_suppress_tests ; | |
102 | } | |
103 | ||
104 | ||
ba9b20a7 | 105 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
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 | ||
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 | setup_xfail "powerpc-*-*" |
208 | 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"] { | |
209 | gdb_suppress_tests ; | |
210 | } | |
211 | ||
212 | ||
213 | gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo" | |
214 | ||
215 | # Print scope1.c::filelocal, which is 2 | |
216 | ||
ba9b20a7 | 217 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
218 | 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"] { |
219 | gdb_suppress_tests ; | |
220 | } | |
221 | ||
222 | ||
223 | gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ | |
224 | "print filelocal_bss at foo" | |
225 | ||
ba9b20a7 | 226 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
227 | 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" |
228 | ||
229 | ||
230 | gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ | |
231 | "print filelocal_ro at foo" | |
232 | ||
ba9b20a7 | 233 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
234 | 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" |
235 | ||
236 | ||
237 | # Print scope1.c::foo::funclocal, which is 3 | |
238 | ||
239 | gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo" | |
240 | ||
c906108c SS |
241 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" \ |
242 | "print foo::funclocal at foo" | |
243 | ||
ba9b20a7 | 244 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
245 | 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" |
246 | ||
247 | ||
248 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
249 | ||
250 | gdb_test "print funclocal_bss" "\\\$$decimal = 103" \ | |
251 | "print funclocal_bss at foo" | |
252 | ||
c906108c SS |
253 | gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \ |
254 | "print foo::funclocal_bss at foo" | |
255 | ||
ba9b20a7 | 256 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
257 | 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" |
258 | ||
259 | ||
260 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
261 | ||
262 | gdb_test "print funclocal_ro" "\\\$$decimal = 203" \ | |
263 | "print funclocal_ro at foo" | |
264 | ||
c906108c SS |
265 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \ |
266 | "print foo::funclocal_ro at foo" | |
267 | ||
ba9b20a7 | 268 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
269 | 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" |
270 | ||
271 | ||
272 | # Print scope1.c::bar::funclocal, which is 4 | |
273 | ||
c906108c SS |
274 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" \ |
275 | "print bar::funclocal at foo" | |
276 | ||
ba9b20a7 | 277 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
278 | 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" |
279 | gdb_stop_suppressing_tests; | |
280 | ||
281 | } | |
282 | ||
283 | proc test_at_bar {} { | |
284 | global gdb_prompt | |
285 | global decimal | |
286 | global det_file | |
287 | global srcdir | |
288 | global subdir | |
c906108c SS |
289 | |
290 | if [gdb_test "next" ".*" "" ] { | |
291 | gdb_suppress_tests ; | |
292 | } | |
293 | ||
294 | ||
295 | # Print scope0.c::filelocal, which is 1 | |
296 | ||
297 | 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"] { | |
298 | gdb_suppress_tests ; | |
299 | } | |
300 | ||
301 | ||
302 | # Print scope0.c::filelocal_bss, which is 101 | |
303 | ||
304 | 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"] { | |
305 | gdb_suppress_tests ; | |
306 | } | |
307 | ||
308 | ||
309 | # Print scope0.c::filelocal_ro, which is 201 | |
310 | ||
ba9b20a7 | 311 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
312 | setup_xfail "powerpc-*-*" |
313 | 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"] { | |
314 | gdb_suppress_tests ; | |
315 | } | |
316 | ||
317 | ||
318 | # Print scope1.c::filelocal, which is 2 | |
319 | ||
320 | if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] { | |
321 | gdb_suppress_tests ; | |
322 | } | |
323 | ||
324 | ||
ba9b20a7 | 325 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
326 | 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"] { |
327 | gdb_suppress_tests ; | |
328 | } | |
329 | ||
330 | ||
331 | # Print scope1.c::filelocal_bss, which is 102 | |
332 | ||
333 | if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] { | |
334 | gdb_suppress_tests ; | |
335 | } | |
336 | ||
337 | ||
ba9b20a7 | 338 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
339 | 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"] { |
340 | gdb_suppress_tests ; | |
341 | } | |
342 | ||
343 | ||
344 | # Print scope1.c::filelocal_ro, which is 202 | |
345 | ||
346 | if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] { | |
347 | gdb_suppress_tests ; | |
348 | } | |
349 | ||
350 | ||
ba9b20a7 | 351 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
352 | 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"] { |
353 | gdb_suppress_tests ; | |
354 | } | |
355 | ||
356 | ||
357 | # Print scope1.c::foo::funclocal, which is 3 | |
358 | ||
c906108c SS |
359 | if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] { |
360 | gdb_suppress_tests ; | |
361 | } | |
362 | ||
363 | ||
ba9b20a7 | 364 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
365 | 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"] { |
366 | gdb_suppress_tests ; | |
367 | } | |
368 | ||
369 | ||
370 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
371 | ||
372 | if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] { | |
373 | gdb_suppress_tests ; | |
374 | } | |
375 | ||
376 | ||
ba9b20a7 | 377 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
378 | 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"] { |
379 | gdb_suppress_tests ; | |
380 | } | |
381 | ||
382 | ||
383 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
384 | ||
385 | if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] { | |
386 | gdb_suppress_tests ; | |
387 | } | |
388 | ||
389 | ||
ba9b20a7 | 390 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
391 | 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"] { |
392 | gdb_suppress_tests ; | |
393 | } | |
394 | ||
395 | ||
396 | # Print scope1.c::bar::funclocal, which is 4 | |
397 | ||
398 | if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] { | |
399 | gdb_suppress_tests ; | |
400 | } | |
401 | ||
402 | ||
403 | if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] { | |
404 | gdb_suppress_tests ; | |
405 | } | |
406 | ||
407 | ||
ba9b20a7 | 408 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
409 | 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"] { |
410 | gdb_suppress_tests ; | |
411 | } | |
412 | ||
413 | ||
414 | # Print scope1.c::bar::funclocal_bss, which is 104 | |
415 | ||
416 | if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] { | |
417 | gdb_suppress_tests ; | |
418 | } | |
419 | ||
420 | ||
421 | if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] { | |
422 | gdb_suppress_tests ; | |
423 | } | |
424 | ||
425 | ||
ba9b20a7 | 426 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
427 | 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"] { |
428 | gdb_suppress_tests ; | |
429 | } | |
430 | gdb_stop_suppressing_tests; | |
431 | ||
432 | } | |
433 | ||
434 | # This test has little to do with local scopes, but it is in scope.exp anyway. | |
435 | # That's life. | |
436 | ||
437 | proc test_at_autovars {} { | |
438 | global gdb_prompt | |
439 | global decimal | |
440 | global hex | |
441 | global srcfile | |
442 | ||
443 | # Test symbol table lookup with 100 local (auto) variables. | |
444 | ||
445 | gdb_breakpoint marker1 | |
446 | ||
447 | if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] { | |
448 | gdb_suppress_tests; | |
449 | } | |
450 | ||
660fd469 | 451 | if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] { |
c906108c SS |
452 | gdb_suppress_tests ; |
453 | } | |
454 | ||
455 | set count 0 | |
456 | while {$count < 100} { | |
457 | if [gdb_test "print i$count" ".* = $count" "" ] { | |
458 | gdb_suppress_tests ; | |
459 | } | |
460 | ||
461 | set count [expr $count+1] | |
462 | } | |
463 | clear_xfail "*-*-*" | |
464 | pass "$count auto variables correctly initialized" | |
465 | ||
466 | # Test that block variable sorting is not screwing us. | |
467 | gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order" | |
468 | } | |
469 | ||
470 | proc test_at_localscopes {} { | |
471 | global gdb_prompt | |
472 | global decimal | |
473 | global hex | |
474 | global srcfile | |
475 | ||
476 | gdb_breakpoint marker2 | |
477 | gdb_breakpoint marker3 | |
478 | gdb_breakpoint marker4 | |
479 | ||
480 | if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] { | |
481 | gdb_suppress_tests; | |
482 | } | |
660fd469 | 483 | if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] { |
c906108c SS |
484 | gdb_suppress_tests ; |
485 | } | |
486 | ||
487 | # Should be at first (outermost) scope. Check values. | |
488 | ||
489 | gdb_test "print localval" " = 10" "print localval, outer scope" | |
490 | gdb_test "print localval1" " = 11" "print localval1, outer scope" | |
491 | gdb_test "print localval2" "No symbol \"localval2\" in current context." \ | |
492 | "print localval2, outer scope" | |
493 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
494 | "print localval3, outer scope" | |
495 | ||
496 | if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \ | |
497 | "continue to marker3 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
498 | if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] { |
499 | gdb_suppress_tests | |
500 | } | |
c906108c SS |
501 | |
502 | # Should be at next (first nested) scope. Check values. | |
503 | ||
504 | gdb_test "print localval" " = 20" \ | |
505 | "print localval, first nested scope" | |
506 | gdb_test "print localval1" " = 11" "print localval1, first nested scope" | |
507 | gdb_test "print localval2" " = 12" "print localval2, first nested scope" | |
508 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
509 | "print localval3, first nested scope" | |
510 | ||
511 | # This test will only fail if the file was compiled by gcc, but | |
512 | # there's no way to check that. | |
c906108c SS |
513 | if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \ |
514 | "continue to marker4 in scope.exp"] then { gdb_suppress_tests } | |
660fd469 MS |
515 | if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] { |
516 | gdb_suppress_tests | |
517 | } | |
c906108c SS |
518 | |
519 | gdb_test "print localval" " = 30" "print localval, innermost scope" | |
520 | gdb_test "print localval1" " = 11" "print localval1, innermost scope" | |
521 | gdb_test "print localval2" " = 12" "print localval2, innermost scope" | |
522 | gdb_test "print localval3" " = 13" "print localval3, innermost scope" | |
523 | gdb_stop_suppressing_tests; | |
524 | } | |
525 | ||
526 | # Start with a fresh gdb. | |
527 | ||
528 | gdb_exit | |
529 | gdb_start | |
530 | gdb_reinitialize_dir $srcdir/$subdir | |
531 | gdb_load ${binfile} | |
532 | ||
533 | if [istarget "*-*-vxworks*"] { | |
534 | set timeout 120 | |
535 | verbose "Timeout is now $timeout seconds" 2 | |
536 | } | |
537 | ||
538 | # Test that variables in various segments print out correctly before | |
539 | # the program is run. | |
540 | ||
541 | # AIX--sections get mapped to the same address so we can't get the right one. | |
542 | setup_xfail "rs6000-*-*" | |
543 | setup_xfail "powerpc-*-*" | |
544 | ||
545 | gdb_test "print 'scope0.c'::filelocal_ro" "= 201" | |
546 | ||
547 | # gdb currently cannot access bss memory on some targets if the inferior | |
548 | # is not running. | |
549 | # | |
550 | # For PA boards using monitor/remote-pa.c, the bss test is going to | |
551 | # randomly fail. We've already put remote-pa on the target stack, | |
552 | # so we actually read memory from the board. Problem is crt0.o | |
553 | # is responsible for clearing bss and that hasnt' happened yet. | |
554 | # | |
555 | # This is a problem for all non-native targets. -- manson | |
676a0442 | 556 | if [is_remote target] { |
c906108c SS |
557 | unsupported "print 'scope0.c'::filelocal_bss before run" |
558 | } else { | |
559 | gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ | |
560 | "print 'scope0.c'::filelocal_bss before run" | |
561 | } | |
562 | ||
563 | gdb_test "print 'scope0.c'::filelocal" "= 1" \ | |
564 | "print 'scope0.c'::filelocal before run" | |
565 | ||
566 | if [runto_main] then { test_at_main } | |
567 | if [istarget "mips-idt-*"] then { | |
568 | # Restart because IDT/SIM runs out of file descriptors. | |
569 | gdb_exit | |
570 | gdb_start | |
571 | gdb_reinitialize_dir $srcdir/$subdir | |
572 | gdb_load ${binfile} | |
573 | } | |
574 | if [runto foo] then { test_at_foo } | |
575 | if [istarget "mips-idt-*"] then { | |
576 | # Restart because IDT/SIM runs out of file descriptors. | |
577 | gdb_exit | |
578 | gdb_start | |
579 | gdb_reinitialize_dir $srcdir/$subdir | |
580 | gdb_load ${binfile} | |
581 | } | |
582 | if [runto bar] then { test_at_bar } | |
583 | if [istarget "mips-idt-*"] then { | |
584 | # Restart because IDT/SIM runs out of file descriptors. | |
585 | gdb_exit | |
586 | gdb_start | |
587 | gdb_reinitialize_dir $srcdir/$subdir | |
588 | gdb_load ${binfile} | |
589 | } | |
590 | if [runto localscopes] then { test_at_localscopes } | |
591 | if [istarget "mips-idt-*"] then { | |
592 | # Restart because IDT/SIM runs out of file descriptors. | |
593 | gdb_exit | |
594 | gdb_start | |
595 | gdb_reinitialize_dir $srcdir/$subdir | |
596 | gdb_load ${binfile} | |
597 | } | |
598 | if [runto autovars] then { test_at_autovars } | |
599 | ||
600 | if [istarget "*-*-vxworks*"] { | |
601 | set timeout 120 | |
602 | verbose "Timeout is now $timeout seconds" 2 | |
603 | } |