Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 1992-2022 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 | ||
e0bd9202 | 36 | proc_with_prefix test_at_main {} { |
c906108c SS |
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 | |
0ac85db5 SM |
51 | gdb_test "print filelocal" "\\\$$decimal = 1" |
52 | 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" | |
c906108c SS |
53 | |
54 | # Print scope0.c::filelocal_bss, which is 101 | |
0ac85db5 SM |
55 | gdb_test "print filelocal_bss" "\\\$$decimal = 101" |
56 | 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" | |
c906108c SS |
57 | |
58 | # Print scope0.c::filelocal_ro, which is 201 | |
59 | ||
15656118 | 60 | # No clue why the rs6000 fails this test. |
ba9b20a7 | 61 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 62 | gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" |
c906108c | 63 | |
ba9b20a7 | 64 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 65 | 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" |
c906108c SS |
66 | |
67 | # Print scope1.c::filelocal, which is 2 | |
ba9b20a7 | 68 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 69 | 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" |
c906108c SS |
70 | |
71 | # Print scope1.c::filelocal_bss, which is 102 | |
ba9b20a7 | 72 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 73 | 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" |
c906108c SS |
74 | |
75 | # Print scope1.c::filelocal_ro, which is 202 | |
ba9b20a7 | 76 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 77 | 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" |
c906108c SS |
78 | |
79 | # Print scope1.c::foo::funclocal, which is 3 | |
0ac85db5 | 80 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" |
c906108c | 81 | |
ba9b20a7 | 82 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 83 | 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" |
c906108c SS |
84 | |
85 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
0ac85db5 | 86 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" |
c906108c | 87 | |
ba9b20a7 | 88 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 89 | 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" |
c906108c SS |
90 | |
91 | # Print scope1.c::bar::funclocal, which is 4 | |
0ac85db5 | 92 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" |
c906108c | 93 | |
ba9b20a7 | 94 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 95 | 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" |
c906108c SS |
96 | } |
97 | ||
e0bd9202 | 98 | proc_with_prefix test_at_foo {} { |
c906108c SS |
99 | global gdb_prompt |
100 | global decimal | |
101 | global det_file | |
102 | global srcdir | |
103 | global subdir | |
c906108c | 104 | |
0ac85db5 | 105 | gdb_test "next" ".*bar \\(\\);" |
c906108c SS |
106 | |
107 | # Print scope0.c::filelocal, which is 1 | |
0ac85db5 | 108 | 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" |
c906108c SS |
109 | |
110 | # Print scope0.c::filelocal_bss, which is 101 | |
0ac85db5 | 111 | 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" |
c906108c SS |
112 | |
113 | # Print scope0.c::filelocal_ro, which is 201 | |
ba9b20a7 | 114 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 115 | 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" |
c906108c SS |
116 | |
117 | ||
c906108c | 118 | # Print scope1.c::filelocal, which is 2 |
0ac85db5 | 119 | gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo" |
c906108c | 120 | |
ba9b20a7 | 121 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 122 | 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" |
c906108c SS |
123 | |
124 | gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ | |
125 | "print filelocal_bss at foo" | |
126 | ||
ba9b20a7 | 127 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
128 | 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" |
129 | ||
130 | ||
131 | gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ | |
132 | "print filelocal_ro at foo" | |
133 | ||
ba9b20a7 | 134 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
135 | 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" |
136 | ||
137 | ||
138 | # Print scope1.c::foo::funclocal, which is 3 | |
139 | ||
140 | gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo" | |
141 | ||
c906108c SS |
142 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" \ |
143 | "print foo::funclocal at foo" | |
144 | ||
ba9b20a7 | 145 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
146 | 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" |
147 | ||
148 | ||
149 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
150 | ||
151 | gdb_test "print funclocal_bss" "\\\$$decimal = 103" \ | |
152 | "print funclocal_bss at foo" | |
153 | ||
c906108c SS |
154 | gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \ |
155 | "print foo::funclocal_bss at foo" | |
156 | ||
ba9b20a7 | 157 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
158 | 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" |
159 | ||
160 | ||
161 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
162 | ||
163 | gdb_test "print funclocal_ro" "\\\$$decimal = 203" \ | |
164 | "print funclocal_ro at foo" | |
165 | ||
c906108c SS |
166 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \ |
167 | "print foo::funclocal_ro at foo" | |
168 | ||
ba9b20a7 | 169 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c SS |
170 | 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" |
171 | ||
172 | ||
173 | # Print scope1.c::bar::funclocal, which is 4 | |
174 | ||
c906108c SS |
175 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" \ |
176 | "print bar::funclocal at foo" | |
177 | ||
ba9b20a7 | 178 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
c906108c | 179 | 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" |
c906108c SS |
180 | |
181 | } | |
182 | ||
e0bd9202 | 183 | proc_with_prefix test_at_bar {} { |
c906108c SS |
184 | global gdb_prompt |
185 | global decimal | |
186 | global det_file | |
187 | global srcdir | |
188 | global subdir | |
c906108c | 189 | |
0ac85db5 | 190 | gdb_test "next" |
c906108c SS |
191 | |
192 | # Print scope0.c::filelocal, which is 1 | |
0ac85db5 | 193 | 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" |
c906108c | 194 | |
0ac85db5 SM |
195 | # Print scope0.c::filelocal_bss, which is 101 |
196 | 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" | |
c906108c | 197 | |
0ac85db5 | 198 | # Print scope0.c::filelocal_ro, which is 201 |
ba9b20a7 | 199 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 200 | 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" |
c906108c SS |
201 | |
202 | # Print scope1.c::filelocal, which is 2 | |
0ac85db5 | 203 | gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar" |
c906108c | 204 | |
ba9b20a7 | 205 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 206 | 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" |
c906108c SS |
207 | |
208 | # Print scope1.c::filelocal_bss, which is 102 | |
0ac85db5 | 209 | gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar" |
c906108c | 210 | |
ba9b20a7 | 211 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 212 | 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" |
c906108c SS |
213 | |
214 | # Print scope1.c::filelocal_ro, which is 202 | |
0ac85db5 | 215 | gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar" |
c906108c | 216 | |
ba9b20a7 | 217 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 218 | 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" |
c906108c SS |
219 | |
220 | # Print scope1.c::foo::funclocal, which is 3 | |
0ac85db5 | 221 | gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar" |
c906108c | 222 | |
ba9b20a7 | 223 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 224 | 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" |
c906108c SS |
225 | |
226 | # Print scope1.c::foo::funclocal_bss, which is 103 | |
0ac85db5 | 227 | gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar" |
c906108c | 228 | |
ba9b20a7 | 229 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 230 | 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" |
c906108c SS |
231 | |
232 | # Print scope1.c::foo::funclocal_ro, which is 203 | |
0ac85db5 | 233 | gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar" |
c906108c | 234 | |
ba9b20a7 | 235 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 236 | 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" |
c906108c SS |
237 | |
238 | # Print scope1.c::bar::funclocal, which is 4 | |
0ac85db5 SM |
239 | gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar" |
240 | gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar" | |
c906108c | 241 | |
ba9b20a7 | 242 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 243 | 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" |
c906108c SS |
244 | |
245 | # Print scope1.c::bar::funclocal_bss, which is 104 | |
0ac85db5 SM |
246 | gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar" |
247 | gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar" | |
c906108c | 248 | |
ba9b20a7 | 249 | if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } |
0ac85db5 | 250 | 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" |
c906108c SS |
251 | } |
252 | ||
253 | # This test has little to do with local scopes, but it is in scope.exp anyway. | |
254 | # That's life. | |
255 | ||
e0bd9202 | 256 | proc_with_prefix test_at_autovars {} { |
c906108c SS |
257 | global gdb_prompt |
258 | global decimal | |
259 | global hex | |
260 | global srcfile | |
261 | ||
262 | # Test symbol table lookup with 100 local (auto) variables. | |
263 | ||
264 | gdb_breakpoint marker1 | |
265 | ||
0ac85db5 SM |
266 | gdb_test "cont" "Break.* marker1 \\(\\) at .*:$decimal.*" "continue to marker1" |
267 | gdb_test "up" ".*autovars.*" "up from marker1 in scope.exp" | |
c906108c SS |
268 | |
269 | set count 0 | |
270 | while {$count < 100} { | |
0ac85db5 | 271 | gdb_test "print i$count" ".* = $count" "" |
c906108c SS |
272 | set count [expr $count+1] |
273 | } | |
274 | clear_xfail "*-*-*" | |
275 | pass "$count auto variables correctly initialized" | |
276 | ||
277 | # Test that block variable sorting is not screwing us. | |
278 | gdb_test "frame" "#.*autovars \\(bcd=5, abc=6\\).*" "args in correct order" | |
279 | } | |
280 | ||
e0bd9202 | 281 | proc_with_prefix test_at_localscopes {} { |
c906108c SS |
282 | global gdb_prompt |
283 | global decimal | |
284 | global hex | |
285 | global srcfile | |
286 | ||
287 | gdb_breakpoint marker2 | |
288 | gdb_breakpoint marker3 | |
289 | gdb_breakpoint marker4 | |
290 | ||
0ac85db5 SM |
291 | gdb_test "cont" "Break.* marker2 \\(\\) at .*:$decimal.*" "continue to marker2" |
292 | gdb_test "up" ".*localscopes.*" "up from marker2 in scopes.exp" | |
c906108c SS |
293 | |
294 | # Should be at first (outermost) scope. Check values. | |
295 | ||
296 | gdb_test "print localval" " = 10" "print localval, outer scope" | |
297 | gdb_test "print localval1" " = 11" "print localval1, outer scope" | |
298 | gdb_test "print localval2" "No symbol \"localval2\" in current context." \ | |
299 | "print localval2, outer scope" | |
300 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
301 | "print localval3, outer scope" | |
302 | ||
0ac85db5 SM |
303 | gdb_test "cont" "Break.* marker3 \\(\\) at .*:$decimal.*" \ |
304 | "continue to marker3 in scope.exp" | |
305 | gdb_test "up" ".*localscopes.*" "up from marker3 in scope.exp" | |
c906108c SS |
306 | |
307 | # Should be at next (first nested) scope. Check values. | |
308 | ||
309 | gdb_test "print localval" " = 20" \ | |
310 | "print localval, first nested scope" | |
311 | gdb_test "print localval1" " = 11" "print localval1, first nested scope" | |
312 | gdb_test "print localval2" " = 12" "print localval2, first nested scope" | |
313 | gdb_test "print localval3" "No symbol \"localval3\" in current context." \ | |
314 | "print localval3, first nested scope" | |
315 | ||
316 | # This test will only fail if the file was compiled by gcc, but | |
317 | # there's no way to check that. | |
0ac85db5 SM |
318 | gdb_test "cont" "Break.* marker4.*at .*:$decimal.*" \ |
319 | "continue to marker4 in scope.exp" | |
320 | gdb_test "up" ".*localscopes.*" "up from marker4 in scope.exp" | |
c906108c SS |
321 | |
322 | gdb_test "print localval" " = 30" "print localval, innermost scope" | |
323 | gdb_test "print localval1" " = 11" "print localval1, innermost scope" | |
324 | gdb_test "print localval2" " = 12" "print localval2, innermost scope" | |
325 | gdb_test "print localval3" " = 13" "print localval3, innermost scope" | |
c906108c SS |
326 | } |
327 | ||
f5ca0032 PA |
328 | # Note, we don't pass a binfile to clean_restart because we need to |
329 | # avoid gdb_load here. With remote targets, gdb_load connects to the | |
330 | # remote target, and we specificaly want the following tests to run | |
331 | # before the program is started. | |
332 | clean_restart | |
333 | gdb_file_cmd $binfile | |
334 | ||
c906108c SS |
335 | # Test that variables in various segments print out correctly before |
336 | # the program is run. | |
337 | ||
338 | # AIX--sections get mapped to the same address so we can't get the right one. | |
339 | setup_xfail "rs6000-*-*" | |
c906108c SS |
340 | |
341 | gdb_test "print 'scope0.c'::filelocal_ro" "= 201" | |
342 | ||
f5ca0032 | 343 | # Check that gdb can access bss memory if the inferior is not running. |
c906108c | 344 | # |
f5ca0032 PA |
345 | # Note the care above about avoiding gdb_load. Otherwise, for |
346 | # embedded stub-like boards, this test would randomly fail. If we'd | |
347 | # already put target remote on the target stack, we'd read memory from | |
348 | # the board instead of the program's binary, and we would have | |
349 | # connected before crt0.o had had a chance to clear bss. | |
350 | gdb_test "print 'scope0.c'::filelocal_bss" "= 0" \ | |
351 | "print 'scope0.c'::filelocal_bss before run" | |
c906108c SS |
352 | |
353 | gdb_test "print 'scope0.c'::filelocal" "= 1" \ | |
354 | "print 'scope0.c'::filelocal before run" | |
355 | ||
356 | if [runto_main] then { test_at_main } | |
c906108c | 357 | if [runto foo] then { test_at_foo } |
c906108c | 358 | if [runto bar] then { test_at_bar } |
c906108c | 359 | if [runto localscopes] then { test_at_localscopes } |
c906108c | 360 | if [runto autovars] then { test_at_autovars } |