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