scope.exp revision 1.3 1 1.3 christos # Copyright 1992-2015 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos # This file was written by Fred Fish. (fnf (at) cygnus.com)
17 1.1 christos
18 1.1 christos
19 1.1 christos standard_testfile scope0.c scope1.c
20 1.1 christos
21 1.1 christos if {[prepare_for_testing ${testfile}.exp ${testfile} \
22 1.1 christos [list $srcfile $srcfile2] {debug}]} {
23 1.1 christos return -1
24 1.1 christos }
25 1.1 christos
26 1.1 christos # Create and source the file that provides information about the compiler
27 1.1 christos # used to compile the test case.
28 1.1 christos if [get_compiler_info] {
29 1.1 christos return -1
30 1.1 christos }
31 1.1 christos
32 1.1 christos # Test locating various things when stopped just inside main, after
33 1.1 christos # running init0(). To prevent cascading of errors, we report the
34 1.1 christos # first one and quit. If all pass, then we print the pass results.
35 1.1 christos
36 1.1 christos proc test_at_main {} {
37 1.1 christos global gdb_prompt
38 1.1 christos global decimal
39 1.1 christos global det_file
40 1.1 christos global srcdir
41 1.1 christos global subdir
42 1.1 christos global hp_cc_compiler
43 1.1 christos
44 1.1 christos # skip past init0.
45 1.1 christos # This used to do an extra "next" if the first one didn't get us
46 1.1 christos # over the call to init0, to handle calls to __main in the
47 1.1 christos # prologue, etc. But if a breakpoint at main doesn't leave us on
48 1.1 christos # the first line of real code in the function, that's a GDB bug.
49 1.1 christos gdb_test "next" "$decimal.*foo \\(\\);" "next over init0() in main"
50 1.1 christos
51 1.1 christos # Print scope0.c::filelocal, which is 1
52 1.1 christos
53 1.1 christos if [gdb_test "print filelocal" "\\\$$decimal = 1" "print filelocal" ] {
54 1.1 christos gdb_suppress_tests
55 1.1 christos }
56 1.1 christos
57 1.1 christos
58 1.1 christos 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"] {
59 1.1 christos gdb_suppress_tests
60 1.1 christos }
61 1.1 christos
62 1.1 christos
63 1.1 christos # Print scope0.c::filelocal_bss, which is 101
64 1.1 christos
65 1.1 christos if [gdb_test "print filelocal_bss" "\\\$$decimal = 101" "print filelocal_bss" ] {
66 1.1 christos gdb_suppress_tests
67 1.1 christos }
68 1.1 christos
69 1.1 christos
70 1.1 christos 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"] {
71 1.1 christos gdb_suppress_tests
72 1.1 christos }
73 1.1 christos
74 1.1 christos
75 1.1 christos # Print scope0.c::filelocal_ro, which is 201
76 1.1 christos
77 1.1 christos # No clue why the rs6000 fails this test.
78 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
79 1.1 christos if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] {
80 1.1 christos gdb_suppress_tests
81 1.1 christos }
82 1.1 christos
83 1.1 christos
84 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
85 1.1 christos 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"] {
86 1.1 christos gdb_suppress_tests
87 1.1 christos }
88 1.1 christos
89 1.1 christos
90 1.1 christos # Print scope1.c::filelocal, which is 2
91 1.1 christos
92 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
93 1.1 christos 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"] {
94 1.1 christos gdb_suppress_tests
95 1.1 christos }
96 1.1 christos
97 1.1 christos
98 1.1 christos # Print scope1.c::filelocal_bss, which is 102
99 1.1 christos
100 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
101 1.1 christos 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"] {
102 1.1 christos gdb_suppress_tests
103 1.1 christos }
104 1.1 christos
105 1.1 christos
106 1.1 christos # Print scope1.c::filelocal_ro, which is 202
107 1.1 christos
108 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
109 1.1 christos if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs}
110 1.1 christos 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"] {
111 1.1 christos gdb_suppress_tests
112 1.1 christos }
113 1.1 christos
114 1.1 christos
115 1.1 christos # Print scope1.c::foo::funclocal, which is 3
116 1.1 christos
117 1.1 christos if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal" ] {
118 1.1 christos gdb_suppress_tests
119 1.1 christos }
120 1.1 christos
121 1.1 christos
122 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
123 1.1 christos 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"] {
124 1.1 christos gdb_suppress_tests
125 1.1 christos }
126 1.1 christos
127 1.1 christos
128 1.1 christos # Print scope1.c::foo::funclocal_ro, which is 203
129 1.1 christos
130 1.1 christos if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro" ] {
131 1.1 christos gdb_suppress_tests
132 1.1 christos }
133 1.1 christos
134 1.1 christos
135 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
136 1.1 christos 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"] {
137 1.1 christos gdb_suppress_tests
138 1.1 christos }
139 1.1 christos
140 1.1 christos
141 1.1 christos # Print scope1.c::bar::funclocal, which is 4
142 1.1 christos
143 1.1 christos if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal" ] {
144 1.1 christos gdb_suppress_tests
145 1.1 christos }
146 1.1 christos
147 1.1 christos
148 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
149 1.1 christos 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"] {
150 1.1 christos gdb_suppress_tests
151 1.1 christos }
152 1.1 christos gdb_stop_suppressing_tests
153 1.1 christos
154 1.1 christos }
155 1.1 christos
156 1.1 christos proc test_at_foo {} {
157 1.1 christos global gdb_prompt
158 1.1 christos global decimal
159 1.1 christos global det_file
160 1.1 christos global srcdir
161 1.1 christos global subdir
162 1.1 christos
163 1.1 christos if [gdb_test "next" ".*bar \\(\\);" "" ] {
164 1.1 christos gdb_suppress_tests
165 1.1 christos }
166 1.1 christos
167 1.1 christos
168 1.1 christos # Print scope0.c::filelocal, which is 1
169 1.1 christos
170 1.1 christos 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"] {
171 1.1 christos gdb_suppress_tests
172 1.1 christos }
173 1.1 christos
174 1.1 christos
175 1.1 christos # Print scope0.c::filelocal_bss, which is 101
176 1.1 christos
177 1.1 christos 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"] {
178 1.1 christos gdb_suppress_tests
179 1.1 christos }
180 1.1 christos
181 1.1 christos
182 1.1 christos # Print scope0.c::filelocal_ro, which is 201
183 1.1 christos
184 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
185 1.1 christos 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"] {
186 1.1 christos gdb_suppress_tests
187 1.1 christos }
188 1.1 christos
189 1.1 christos
190 1.1 christos gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
191 1.1 christos
192 1.1 christos # Print scope1.c::filelocal, which is 2
193 1.1 christos
194 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
195 1.1 christos 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"] {
196 1.1 christos gdb_suppress_tests
197 1.1 christos }
198 1.1 christos
199 1.1 christos
200 1.1 christos gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
201 1.1 christos "print filelocal_bss at foo"
202 1.1 christos
203 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
204 1.1 christos 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"
205 1.1 christos
206 1.1 christos
207 1.1 christos gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
208 1.1 christos "print filelocal_ro at foo"
209 1.1 christos
210 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
211 1.1 christos 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"
212 1.1 christos
213 1.1 christos
214 1.1 christos # Print scope1.c::foo::funclocal, which is 3
215 1.1 christos
216 1.1 christos gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
217 1.1 christos
218 1.1 christos gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
219 1.1 christos "print foo::funclocal at foo"
220 1.1 christos
221 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
222 1.1 christos 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"
223 1.1 christos
224 1.1 christos
225 1.1 christos # Print scope1.c::foo::funclocal_bss, which is 103
226 1.1 christos
227 1.1 christos gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
228 1.1 christos "print funclocal_bss at foo"
229 1.1 christos
230 1.1 christos gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
231 1.1 christos "print foo::funclocal_bss at foo"
232 1.1 christos
233 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
234 1.1 christos 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"
235 1.1 christos
236 1.1 christos
237 1.1 christos # Print scope1.c::foo::funclocal_ro, which is 203
238 1.1 christos
239 1.1 christos gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
240 1.1 christos "print funclocal_ro at foo"
241 1.1 christos
242 1.1 christos gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
243 1.1 christos "print foo::funclocal_ro at foo"
244 1.1 christos
245 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
246 1.1 christos 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"
247 1.1 christos
248 1.1 christos
249 1.1 christos # Print scope1.c::bar::funclocal, which is 4
250 1.1 christos
251 1.1 christos gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
252 1.1 christos "print bar::funclocal at foo"
253 1.1 christos
254 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
255 1.1 christos 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"
256 1.1 christos gdb_stop_suppressing_tests
257 1.1 christos
258 1.1 christos }
259 1.1 christos
260 1.1 christos proc test_at_bar {} {
261 1.1 christos global gdb_prompt
262 1.1 christos global decimal
263 1.1 christos global det_file
264 1.1 christos global srcdir
265 1.1 christos global subdir
266 1.1 christos
267 1.1 christos if [gdb_test "next" ".*" "" ] {
268 1.1 christos gdb_suppress_tests
269 1.1 christos }
270 1.1 christos
271 1.1 christos
272 1.1 christos # Print scope0.c::filelocal, which is 1
273 1.1 christos
274 1.1 christos 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"] {
275 1.1 christos gdb_suppress_tests
276 1.1 christos }
277 1.1 christos
278 1.1 christos
279 1.1 christos # Print scope0.c::filelocal_bss, which is 101
280 1.1 christos
281 1.1 christos 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"] {
282 1.1 christos gdb_suppress_tests
283 1.1 christos }
284 1.1 christos
285 1.1 christos
286 1.1 christos # Print scope0.c::filelocal_ro, which is 201
287 1.1 christos
288 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
289 1.1 christos 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"] {
290 1.1 christos gdb_suppress_tests
291 1.1 christos }
292 1.1 christos
293 1.1 christos
294 1.1 christos # Print scope1.c::filelocal, which is 2
295 1.1 christos
296 1.1 christos if [gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" ] {
297 1.1 christos gdb_suppress_tests
298 1.1 christos }
299 1.1 christos
300 1.1 christos
301 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
302 1.1 christos 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"] {
303 1.1 christos gdb_suppress_tests
304 1.1 christos }
305 1.1 christos
306 1.1 christos
307 1.1 christos # Print scope1.c::filelocal_bss, which is 102
308 1.1 christos
309 1.1 christos if [gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" ] {
310 1.1 christos gdb_suppress_tests
311 1.1 christos }
312 1.1 christos
313 1.1 christos
314 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
315 1.1 christos 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"] {
316 1.1 christos gdb_suppress_tests
317 1.1 christos }
318 1.1 christos
319 1.1 christos
320 1.1 christos # Print scope1.c::filelocal_ro, which is 202
321 1.1 christos
322 1.1 christos if [gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" ] {
323 1.1 christos gdb_suppress_tests
324 1.1 christos }
325 1.1 christos
326 1.1 christos
327 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
328 1.1 christos 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"] {
329 1.1 christos gdb_suppress_tests
330 1.1 christos }
331 1.1 christos
332 1.1 christos
333 1.1 christos # Print scope1.c::foo::funclocal, which is 3
334 1.1 christos
335 1.1 christos if [gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" ] {
336 1.1 christos gdb_suppress_tests
337 1.1 christos }
338 1.1 christos
339 1.1 christos
340 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
341 1.1 christos 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"] {
342 1.1 christos gdb_suppress_tests
343 1.1 christos }
344 1.1 christos
345 1.1 christos
346 1.1 christos # Print scope1.c::foo::funclocal_bss, which is 103
347 1.1 christos
348 1.1 christos if [gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" ] {
349 1.1 christos gdb_suppress_tests
350 1.1 christos }
351 1.1 christos
352 1.1 christos
353 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
354 1.1 christos 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"] {
355 1.1 christos gdb_suppress_tests
356 1.1 christos }
357 1.1 christos
358 1.1 christos
359 1.1 christos # Print scope1.c::foo::funclocal_ro, which is 203
360 1.1 christos
361 1.1 christos if [gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" ] {
362 1.1 christos gdb_suppress_tests
363 1.1 christos }
364 1.1 christos
365 1.1 christos
366 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
367 1.1 christos 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"] {
368 1.1 christos gdb_suppress_tests
369 1.1 christos }
370 1.1 christos
371 1.1 christos
372 1.1 christos # Print scope1.c::bar::funclocal, which is 4
373 1.1 christos
374 1.1 christos if [gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" ] {
375 1.1 christos gdb_suppress_tests
376 1.1 christos }
377 1.1 christos
378 1.1 christos
379 1.1 christos if [gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" ] {
380 1.1 christos gdb_suppress_tests
381 1.1 christos }
382 1.1 christos
383 1.1 christos
384 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
385 1.1 christos 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"] {
386 1.1 christos gdb_suppress_tests
387 1.1 christos }
388 1.1 christos
389 1.1 christos
390 1.1 christos # Print scope1.c::bar::funclocal_bss, which is 104
391 1.1 christos
392 1.1 christos if [gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" ] {
393 1.1 christos gdb_suppress_tests
394 1.1 christos }
395 1.1 christos
396 1.1 christos
397 1.1 christos if [gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" ] {
398 1.1 christos gdb_suppress_tests
399 1.1 christos }
400 1.1 christos
401 1.1 christos
402 1.1 christos if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" }
403 1.1 christos 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"] {
404 1.1 christos gdb_suppress_tests
405 1.1 christos }
406 1.1 christos gdb_stop_suppressing_tests
407 1.1 christos
408 1.1 christos }
409 1.1 christos
410 1.1 christos # This test has little to do with local scopes, but it is in scope.exp anyway.
411 1.1 christos # That's life.
412 1.1 christos
413 1.1 christos proc test_at_autovars {} {
414 1.1 christos global gdb_prompt
415 1.1 christos global decimal
416 1.1 christos global hex
417 1.1 christos global srcfile
418 1.1 christos
419 1.1 christos # Test symbol table lookup with 100 local (auto) variables.
420 1.1 christos
421 1.1 christos gdb_breakpoint marker1
422 1.1 christos
423 1.1 christos if [gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1"] {
424 1.1 christos gdb_suppress_tests
425 1.1 christos }
426 1.1 christos
427 1.1 christos if [gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" ] {
428 1.1 christos gdb_suppress_tests
429 1.1 christos }
430 1.1 christos
431 1.1 christos set count 0
432 1.1 christos while {$count < 100} {
433 1.1 christos if [gdb_test "print i$count" ".* = $count" "" ] {
434 1.1 christos gdb_suppress_tests
435 1.1 christos }
436 1.1 christos
437 1.1 christos set count [expr $count+1]
438 1.1 christos }
439 1.1 christos clear_xfail "*-*-*"
440 1.1 christos pass "$count auto variables correctly initialized"
441 1.1 christos
442 1.1 christos # Test that block variable sorting is not screwing us.
443 1.1 christos gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order"
444 1.1 christos }
445 1.1 christos
446 1.1 christos proc test_at_localscopes {} {
447 1.1 christos global gdb_prompt
448 1.1 christos global decimal
449 1.1 christos global hex
450 1.1 christos global srcfile
451 1.1 christos
452 1.1 christos gdb_breakpoint marker2
453 1.1 christos gdb_breakpoint marker3
454 1.1 christos gdb_breakpoint marker4
455 1.1 christos
456 1.1 christos if [gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2"] {
457 1.1 christos gdb_suppress_tests
458 1.1 christos }
459 1.1 christos if [gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" ] {
460 1.1 christos gdb_suppress_tests
461 1.1 christos }
462 1.1 christos
463 1.1 christos # Should be at first (outermost) scope. Check values.
464 1.1 christos
465 1.1 christos gdb_test "print localval" " = 10" "print localval, outer scope"
466 1.1 christos gdb_test "print localval1" " = 11" "print localval1, outer scope"
467 1.1 christos gdb_test "print localval2" "No symbol \"localval2\" in current context." \
468 1.1 christos "print localval2, outer scope"
469 1.1 christos gdb_test "print localval3" "No symbol \"localval3\" in current context." \
470 1.1 christos "print localval3, outer scope"
471 1.1 christos
472 1.1 christos if [gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \
473 1.1 christos "continue to marker3 in scope.exp"] then { gdb_suppress_tests }
474 1.1 christos if [gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp"] {
475 1.1 christos gdb_suppress_tests
476 1.1 christos }
477 1.1 christos
478 1.1 christos # Should be at next (first nested) scope. Check values.
479 1.1 christos
480 1.1 christos gdb_test "print localval" " = 20" \
481 1.1 christos "print localval, first nested scope"
482 1.1 christos gdb_test "print localval1" " = 11" "print localval1, first nested scope"
483 1.1 christos gdb_test "print localval2" " = 12" "print localval2, first nested scope"
484 1.1 christos gdb_test "print localval3" "No symbol \"localval3\" in current context." \
485 1.1 christos "print localval3, first nested scope"
486 1.1 christos
487 1.1 christos # This test will only fail if the file was compiled by gcc, but
488 1.1 christos # there's no way to check that.
489 1.1 christos if [gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \
490 1.1 christos "continue to marker4 in scope.exp"] then { gdb_suppress_tests }
491 1.1 christos if [gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp"] {
492 1.1 christos gdb_suppress_tests
493 1.1 christos }
494 1.1 christos
495 1.1 christos gdb_test "print localval" " = 30" "print localval, innermost scope"
496 1.1 christos gdb_test "print localval1" " = 11" "print localval1, innermost scope"
497 1.1 christos gdb_test "print localval2" " = 12" "print localval2, innermost scope"
498 1.1 christos gdb_test "print localval3" " = 13" "print localval3, innermost scope"
499 1.1 christos gdb_stop_suppressing_tests
500 1.1 christos }
501 1.1 christos
502 1.1 christos # Test that variables in various segments print out correctly before
503 1.1 christos # the program is run.
504 1.1 christos
505 1.1 christos # AIX--sections get mapped to the same address so we can't get the right one.
506 1.1 christos setup_xfail "rs6000-*-*"
507 1.1 christos
508 1.1 christos gdb_test "print 'scope0.c'::filelocal_ro" "= 201"
509 1.1 christos
510 1.1 christos # gdb currently cannot access bss memory on some targets if the inferior
511 1.1 christos # is not running.
512 1.1 christos #
513 1.1 christos # For PA boards using monitor/remote-pa.c, the bss test is going to
514 1.1 christos # randomly fail. We've already put remote-pa on the target stack,
515 1.1 christos # so we actually read memory from the board. Problem is crt0.o
516 1.1 christos # is responsible for clearing bss and that hasnt' happened yet.
517 1.1 christos #
518 1.1 christos # This is a problem for all non-native targets. -- manson
519 1.1 christos if [is_remote target] {
520 1.1 christos unsupported "print 'scope0.c'::filelocal_bss before run"
521 1.1 christos } else {
522 1.1 christos gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \
523 1.1 christos "print 'scope0.c'::filelocal_bss before run"
524 1.1 christos }
525 1.1 christos
526 1.1 christos gdb_test "print 'scope0.c'::filelocal" "= 1" \
527 1.1 christos "print 'scope0.c'::filelocal before run"
528 1.1 christos
529 1.1 christos if [runto_main] then { test_at_main }
530 1.1 christos if [runto foo] then { test_at_foo }
531 1.1 christos if [runto bar] then { test_at_bar }
532 1.1 christos if [runto localscopes] then { test_at_localscopes }
533 1.1 christos if [runto autovars] then { test_at_autovars }
534