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