* gdb.base/completion.exp: Recognize the more detailed error
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / overlays.exp
1 # Copyright 1997, 1998 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 #
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19 #
20 # This file was written by Michael Snyder (msnyder@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 #
27 # test running programs
28 #
29
30 set prms_id 0
31 set bug_id 0
32
33 if [istarget "d10v-*-*"] then {
34 set linker_script "${srcdir}/${subdir}/d10v.ld";
35 } elseif [istarget "m32r-*-*"] then {
36 set linker_script "${srcdir}/${subdir}/m32r.ld";
37 } else {
38 verbose "Skipping overlay test -- not implemented for this target."
39 return
40 }
41
42 set testfile "overlays"
43 set binfile ${objdir}/${subdir}/${testfile}
44 set srcfile ${srcdir}/${subdir}/${testfile}.c
45 set foo ${srcdir}/${subdir}/foo.c
46 set bar ${srcdir}/${subdir}/bar.c
47 set baz ${srcdir}/${subdir}/baz.c
48 set grbx ${srcdir}/${subdir}/grbx.c
49
50 if {[gdb_compile "${srcfile}" "${testfile}.o" object {debug}] != ""} then {
51 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
52 }
53 if {[gdb_compile "${srcdir}/${subdir}/ovlymgr.c" ovlymgr.o object {debug}] != ""} then {
54 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
55 }
56 if {[gdb_compile "${foo}" foo.o object {debug} ] != ""} then {
57 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
58 }
59
60 if {[gdb_compile "${bar}" bar.o object {debug}] != ""} then {
61 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
62 }
63 if {[gdb_compile "${baz}" baz.o object {debug}] != ""} then {
64 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
65 }
66 if {[gdb_compile "${grbx}" grbx.o object {debug}] != ""} then {
67 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
68 }
69 if {[gdb_compile "${testfile}.o ovlymgr.o foo.o bar.o baz.o grbx.o" ${binfile} executable "ldscript=-Wl,-T$linker_script"] != "" } {
70 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
71 }
72
73 remote_exec build "mv ${testfile}.o foo.o bar.o baz.o grbx.o ovlymgr.o ${objdir}/${subdir}"
74
75
76 gdb_start
77 gdb_reinitialize_dir $srcdir/$subdir
78 gdb_load ${binfile}
79
80 #
81 # set it up at a breakpoint so we can play with the variable values
82 #
83
84 if ![runto_main] then {
85 gdb_suppress_tests;
86 }
87
88 # couple of convenience variables
89 set fptrcast [string_to_regexp "(int (*)(int))"]
90 set iptrcast [string_to_regexp "(int *)"]
91
92 gdb_test "overlay manual" ""
93 gdb_test "overlay list" "No sections are mapped." "List with none mapped"
94
95 # capture the LMA addresses of [foo bar baz grbx foox barx bazx grbxx]
96
97 gdb_test "print \$foo_lma = &foo" \
98 ".* $fptrcast 0x.* <\\*foo\\*>" "foo load addr"
99 gdb_test "print \$bar_lma = &bar" \
100 ".* $fptrcast 0x.* <\\*bar\\*>" "bar load addr"
101 gdb_test "print \$baz_lma = &baz" \
102 ".* $fptrcast 0x.* <\\*baz\\*>" "baz load addr"
103 gdb_test "print \$grbx_lma = &grbx" \
104 ".* $fptrcast 0x.* <\\*grbx\\*>" "grbx load addr"
105 gdb_test "print \$foox_lma = &foox" \
106 ".* $iptrcast 0x.*" "foox load addr"
107 gdb_test "print \$barx_lma = &barx" \
108 ".* $iptrcast 0x.*" "barx load addr"
109 gdb_test "print \$bazx_lma = &bazx" \
110 ".* $iptrcast 0x.*" "bazx load addr"
111 gdb_test "print \$grbxx_lma = &grbxx" \
112 ".* $iptrcast 0x.*" "grbxx load addr"
113
114 # map each overlay successively, and
115 # capture the VMA addresses of [foo bar baz grbx foox barx bazx grbxx]
116
117 gdb_test "overlay map .ovly0" ""
118 gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "List ovly0"
119 gdb_test "print \$foo_vma = &foo" \
120 ".* $fptrcast 0x.* <foo>" "foo runtime addr"
121
122 gdb_test "overlay map .ovly1" ""
123 gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "List ovly1"
124 gdb_test "print \$bar_vma = &bar" \
125 ".* $fptrcast 0x.* <bar>" "bar runtime addr"
126
127 gdb_test "overlay map .ovly2" ""
128 gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "List ovly2"
129 gdb_test "print \$baz_vma = &baz" \
130 ".* $fptrcast 0x.* <baz>" "baz runtime addr"
131
132 gdb_test "overlay map .ovly3" ""
133 gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "List ovly3"
134 gdb_test "print \$grbx_vma = &grbx" \
135 ".* $fptrcast 0x.* <grbx>" "grbx runtime addr"
136
137 gdb_test "overlay map .data00" ""
138 gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "List data00"
139 gdb_test "print \$foox_vma = &foox" \
140 ".* $iptrcast 0x.*" "foox runtime addr"
141
142 gdb_test "overlay map .data01" ""
143 gdb_test "overlay list" "Section .data01, loaded .*, mapped .*" "List data01"
144 gdb_test "print \$barx_vma = &barx" \
145 ".* $iptrcast 0x.*" "barx runtime addr"
146
147 gdb_test "overlay map .data02" ""
148 gdb_test "overlay list" "Section .data02, loaded .*, mapped .*" "List data02"
149 gdb_test "print \$bazx_vma = &bazx" \
150 ".* $iptrcast 0x.*" "bazx runtime addr"
151
152 gdb_test "overlay map .data03" ""
153 gdb_test "overlay list" "Section .data03, loaded .*, mapped .*" "List data03"
154 gdb_test "print \$grbxx_vma = &grbxx" \
155 ".* $iptrcast 0x.*" "grbxx runtime addr"
156
157 # Verify that LMA != VMA
158
159 gdb_test "print \$foo_lma != \$foo_vma" ".* = 1" "foo's LMA != VMA"
160 gdb_test "print \$bar_lma != \$bar_vma" ".* = 1" "bar's LMA != VMA"
161 gdb_test "print \$baz_lma != \$baz_vma" ".* = 1" "baz's LMA != VMA"
162 gdb_test "print \$grbx_lma != \$grbx_vma" ".* = 1" "grbx's LMA != VMA"
163 gdb_test "print \$foox_lma != \$foox_vma" ".* = 1" "foox's LMA != VMA"
164 gdb_test "print \$barx_lma != \$barx_vma" ".* = 1" "barx's LMA != VMA"
165 gdb_test "print \$bazx_lma != \$bazx_vma" ".* = 1" "bazx's LMA != VMA"
166 gdb_test "print \$grbxx_lma != \$grbxx_vma" ".* = 1" "grbxx's LMA != VMA"
167
168 # Verify that early-mapped overlays have been bumped out
169 # by later-mapped overlays layed over in the same VMA range.
170
171 send_gdb "overlay list\n"
172 gdb_expect {
173 -re ".*ovly0, " { fail ".ovly0 not unmapped by .ovly1" }
174 -re ".*ovly2, " { fail ".ovly2 not unmapped by .ovly3" }
175 -re ".*data00," { fail ".data00 not unmapped by .data01" }
176 -re ".*data02," { fail ".data02 not unmapped by .data03" }
177 -re ".*$gdb_prompt $" { pass "Automatic unmapping" }
178 timeout { fail "(timeout) Automatic unmapping" }
179 }
180
181 # Verify that both sec1 and sec2 can be loaded simultaneously.
182 proc simultaneous_pair { sec1 sec2 } {
183 global gdb_prompt
184
185 set pairname "$sec1 and $sec2 mapped simultaneously"
186 gdb_test "overlay map $sec1" "" "$pairname: map $sec1"
187 gdb_test "overlay map $sec2" "" "$pairname: map $sec2"
188
189 set seen_sec1 0
190 set seen_sec2 0
191
192 send_gdb "overlay list\n"
193 gdb_expect {
194 -re ".*[string_to_regexp $sec1], " { set seen_sec1 1; exp_continue }
195 -re ".*[string_to_regexp $sec2], " { set seen_sec2 1; exp_continue }
196 -re ".*$gdb_prompt $" {
197 if {$seen_sec1 && $seen_sec2} {
198 pass "$pairname"
199 } else {
200 fail "$pairname"
201 }
202 }
203 timeout { fail "(timeout) $pairname" }
204 }
205 }
206
207 simultaneous_pair .ovly0 .ovly2
208 simultaneous_pair .ovly0 .ovly3
209 simultaneous_pair .ovly1 .ovly2
210 simultaneous_pair .ovly1 .ovly3
211
212 simultaneous_pair .data00 .data02
213 simultaneous_pair .data00 .data03
214 simultaneous_pair .data01 .data02
215 simultaneous_pair .data01 .data03
216
217 # test automatic mode
218
219 gdb_test "overlay auto" ""
220 gdb_test "overlay list" "No sections are mapped." "List none mapped (auto)"
221 gdb_test "break foo" "Breakpoint .*at .*file .*foo.c.*" "break foo"
222 gdb_test "break bar" "Breakpoint .*at .*file .*bar.c.*" "break bar"
223 gdb_test "break baz" "Breakpoint .*at .*file .*baz.c.*" "break baz"
224 gdb_test "break grbx" "Breakpoint .*at .*file .*grbx.c.*" "break grbx"
225
226 send_gdb "continue\n"
227 gdb_expect {
228 -re "Breakpoint .* foo .x=1. at .*$gdb_prompt $" { pass "hit foo" }
229 -re ".*$gdb_prompt $" { fail "hit foo" }
230 timeout { fail "(timeout) hit foo" }
231 }
232
233 send_gdb "backtrace\n"
234 gdb_expect {
235 -re "#0 .*foo .*#1 .*main .*$gdb_prompt $" { pass "BT foo" }
236 -re ".*$gdb_prompt $" { fail "BT foo" }
237 timeout { fail "(timeout) BT foo" }
238 }
239
240
241 send_gdb "continue\n"
242 gdb_expect {
243 -re "Breakpoint .* bar .x=1. at .*$gdb_prompt $" { pass "hit bar" }
244 -re ".*$gdb_prompt $" { fail "hit bar" }
245 timeout { fail "(timeout) hit bar" }
246 }
247
248 send_gdb "backtrace\n"
249 gdb_expect {
250 -re "#0 .*bar .*#1 .*main .*$gdb_prompt $" { pass "BT bar" }
251 -re ".*$gdb_prompt $" { fail "BT bar" }
252 timeout { fail "(timeout) BT bar" }
253 }
254
255 send_gdb "continue\n"
256 gdb_expect {
257 -re "Breakpoint .* baz .x=1. at .*$gdb_prompt $" { pass "hit baz" }
258 -re ".*$gdb_prompt $" { fail "hit baz" }
259 timeout { fail "(timeout) hit baz" }
260 }
261
262 send_gdb "backtrace\n"
263 gdb_expect {
264 -re "#0 .*baz .*#1 .*main .*$gdb_prompt $" { pass "BT baz" }
265 -re ".*$gdb_prompt $" { fail "BT baz" }
266 timeout { fail "(timeout) BT baz" }
267 }
268
269 send_gdb "continue\n"
270 gdb_expect {
271 -re "Breakpoint .* grbx .x=1. at .*$gdb_prompt $" { pass "hit grbx" }
272 -re ".*$gdb_prompt $" { fail "hit grbx" }
273 timeout { fail "(timeout) hit grbx" }
274 }
275
276 send_gdb "backtrace\n"
277 gdb_expect {
278 -re "#0 .*grbx .*#1 .*main .*$gdb_prompt $" { pass "BT grbx" }
279 -re ".*$gdb_prompt $" { fail "BT grbx" }
280 timeout { fail "(timeout) BT grbx" }
281 }
282
This page took 0.040712 seconds and 4 git commands to generate.