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