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