configure script for gdb.asm, initial source debugging test.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.asm / source.exp
1 # Copyright (C) 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 Kendra.
21
22 return
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 #
29 # test running programs
30 #
31
32 set prms_id 0
33 set bug_id 0
34
35 if [istarget "d10v-*-*"] then {
36 set linker_script "${srcdir}/${subdir}/d10v.ld";
37 } elseif [istarget "m32r-*-*"] then {
38 set linker_script "${srcdir}/${subdir}/m32r.ld";
39 } else {
40 verbose "Skipping overlay test -- not implemented for this target."
41 return
42 }
43
44 set testfile "overlays"
45 set binfile ${objdir}/${subdir}/${testfile}
46 set srcfile ${srcdir}/${subdir}/${testfile}.c
47 set foo ${srcdir}/${subdir}/foo.c
48 set bar ${srcdir}/${subdir}/bar.c
49 set baz ${srcdir}/${subdir}/baz.c
50 set grbx ${srcdir}/${subdir}/grbx.c
51
52 if {[gdb_compile "${srcfile}" "${testfile}.o" object {debug}] != ""} then {
53 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
54 }
55 if {[gdb_compile "${srcdir}/${subdir}/ovlymgr.c" ovlymgr.o object {debug}] != ""} then {
56 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
57 }
58 if {[gdb_compile "${foo}" foo.o object {debug} ] != ""} then {
59 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
60 }
61
62 if {[gdb_compile "${bar}" bar.o object {debug}] != ""} then {
63 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
64 }
65 if {[gdb_compile "${baz}" baz.o object {debug}] != ""} then {
66 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
67 }
68 if {[gdb_compile "${grbx}" grbx.o object {debug}] != ""} then {
69 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
70 }
71 if { [gdb_compile "${testfile}.o ovlymgr.o foo.o bar.o baz.o grbx.o -T${linker_script}" ${binfile} executable ""] != "" } {
72 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
73 }
74
75 remote_exec build "mv ${testfile}.o foo.o bar.o baz.o grbx.o ovlymgr.o ${objdir}/${subdir}"
76
77
78 gdb_start
79 gdb_reinitialize_dir $srcdir/$subdir
80 gdb_load ${binfile}
81
82 #
83 # set it up at a breakpoint so we can play with the variable values
84 #
85
86 if ![runto_main] then {
87 gdb_suppress_tests;
88 }
89
90 # couple of convenience variables
91 set fptrcast [string_to_regexp "(int (*)(int))"]
92 set iptrcast [string_to_regexp "(int *)"]
93
94 gdb_test "overlay manual" ""
95 gdb_test "overlay list" "No sections are mapped." "List with none mapped"
96
97 # capture the LMA addresses of [foo bar baz grbx foox barx bazx grbxx]
98
99 gdb_test "print \$foo_lma = &foo" \
100 ".* $fptrcast 0x.* <\\*foo\\*>" "foo load addr"
101 gdb_test "print \$bar_lma = &bar" \
102 ".* $fptrcast 0x.* <\\*bar\\*>" "bar load addr"
103 gdb_test "print \$baz_lma = &baz" \
104 ".* $fptrcast 0x.* <\\*baz\\*>" "baz load addr"
105 gdb_test "print \$grbx_lma = &grbx" \
106 ".* $fptrcast 0x.* <\\*grbx\\*>" "grbx load addr"
107 gdb_test "print \$foox_lma = &foox" \
108 ".* $iptrcast 0x.*" "foox load addr"
109 gdb_test "print \$barx_lma = &barx" \
110 ".* $iptrcast 0x.*" "barx load addr"
111 gdb_test "print \$bazx_lma = &bazx" \
112 ".* $iptrcast 0x.*" "bazx load addr"
113 gdb_test "print \$grbxx_lma = &grbxx" \
114 ".* $iptrcast 0x.*" "grbxx load addr"
115
116 # map each overlay successively, and
117 # capture the VMA addresses of [foo bar baz grbx foox barx bazx grbxx]
118
119 gdb_test "overlay map .ovly0" ""
120 gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "List ovly0"
121 gdb_test "print \$foo_vma = &foo" \
122 ".* $fptrcast 0x.* <foo>" "foo runtime addr"
123
124 gdb_test "overlay map .ovly1" ""
125 gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "List ovly1"
126 gdb_test "print \$bar_vma = &bar" \
127 ".* $fptrcast 0x.* <bar>" "bar runtime addr"
128
129 gdb_test "overlay map .ovly2" ""
130 gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "List ovly2"
131 gdb_test "print \$baz_vma = &baz" \
132 ".* $fptrcast 0x.* <baz>" "baz runtime addr"
133
134 gdb_test "overlay map .ovly3" ""
135 gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "List ovly3"
136 gdb_test "print \$grbx_vma = &grbx" \
137 ".* $fptrcast 0x.* <grbx>" "grbx runtime addr"
138
139 gdb_test "overlay map .data00" ""
140 gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "List data00"
141 gdb_test "print \$foox_vma = &foox" \
142 ".* $iptrcast 0x.*" "foox runtime addr"
143
144 gdb_test "overlay map .data01" ""
145 gdb_test "overlay list" "Section .data01, loaded .*, mapped .*" "List data01"
146 gdb_test "print \$barx_vma = &barx" \
147 ".* $iptrcast 0x.*" "barx runtime addr"
148
149 gdb_test "overlay map .data02" ""
150 gdb_test "overlay list" "Section .data02, loaded .*, mapped .*" "List data02"
151 gdb_test "print \$bazx_vma = &bazx" \
152 ".* $iptrcast 0x.*" "bazx runtime addr"
153
154 gdb_test "overlay map .data03" ""
155 gdb_test "overlay list" "Section .data03, loaded .*, mapped .*" "List data03"
156 gdb_test "print \$grbxx_vma = &grbxx" \
157 ".* $iptrcast 0x.*" "grbxx runtime addr"
158
159 # Verify that LMA != VMA
160
161 gdb_test "print \$foo_lma != \$foo_vma" ".* = 1" "foo's LMA != VMA"
162 gdb_test "print \$bar_lma != \$bar_vma" ".* = 1" "bar's LMA != VMA"
163 gdb_test "print \$baz_lma != \$baz_vma" ".* = 1" "baz's LMA != VMA"
164 gdb_test "print \$grbx_lma != \$grbx_vma" ".* = 1" "grbx's LMA != VMA"
165 gdb_test "print \$foox_lma != \$foox_vma" ".* = 1" "foox's LMA != VMA"
166 gdb_test "print \$barx_lma != \$barx_vma" ".* = 1" "barx's LMA != VMA"
167 gdb_test "print \$bazx_lma != \$bazx_vma" ".* = 1" "bazx's LMA != VMA"
168 gdb_test "print \$grbxx_lma != \$grbxx_vma" ".* = 1" "grbxx's LMA != VMA"
169
170 # Verify that early-mapped overlays have been bumped out
171 # by later-mapped overlays layed over in the same VMA range.
172
173 send_gdb "overlay list\n"
174 gdb_expect {
175 -re ".*ovly0, " { fail ".ovly0 not unmapped by .ovly1" }
176 -re ".*ovly2, " { fail ".ovly2 not unmapped by .ovly3" }
177 -re ".*data00," { fail ".data00 not unmapped by .data01" }
178 -re ".*data02," { fail ".data02 not unmapped by .data03" }
179 -re ".*$gdb_prompt $" { pass "Automatic unmapping" }
180 timeout { fail "(timeout) Automatic unmapping" }
181 }
182
183 # test automatic mode
184
185 gdb_test "overlay auto" ""
186 gdb_test "overlay list" "No sections are mapped." "List none mapped (auto)"
187 gdb_test "break foo" "Breakpoint .*at .*file .*foo.c.*" "break foo"
188 gdb_test "break bar" "Breakpoint .*at .*file .*bar.c.*" "break bar"
189 gdb_test "break baz" "Breakpoint .*at .*file .*baz.c.*" "break baz"
190 gdb_test "break grbx" "Breakpoint .*at .*file .*grbx.c.*" "break grbx"
191
192 send_gdb "continue\n"
193 gdb_expect {
194 -re "Breakpoint .* foo .x=1. at .*$gdb_prompt $" { pass "hit foo" }
195 -re ".*$gdb_prompt $" { fail "hit foo" }
196 timeout { fail "(timeout) hit foo" }
197 }
198
199 send_gdb "backtrace\n"
200 gdb_expect {
201 -re "#0 .*foo .*#1 .*main .*$gdb_prompt $" { pass "BT foo" }
202 -re ".*$gdb_prompt $" { fail "BT foo" }
203 timeout { fail "(timeout) BT foo" }
204 }
205
206
207 send_gdb "continue\n"
208 gdb_expect {
209 -re "Breakpoint .* bar .x=1. at .*$gdb_prompt $" { pass "hit bar" }
210 -re ".*$gdb_prompt $" { fail "hit bar" }
211 timeout { fail "(timeout) hit bar" }
212 }
213
214 send_gdb "backtrace\n"
215 gdb_expect {
216 -re "#0 .*bar .*#1 .*main .*$gdb_prompt $" { pass "BT bar" }
217 -re ".*$gdb_prompt $" { fail "BT bar" }
218 timeout { fail "(timeout) BT bar" }
219 }
220
221 send_gdb "continue\n"
222 gdb_expect {
223 -re "Breakpoint .* baz .x=1. at .*$gdb_prompt $" { pass "hit baz" }
224 -re ".*$gdb_prompt $" { fail "hit baz" }
225 timeout { fail "(timeout) hit baz" }
226 }
227
228 send_gdb "backtrace\n"
229 gdb_expect {
230 -re "#0 .*baz .*#1 .*main .*$gdb_prompt $" { pass "BT baz" }
231 -re ".*$gdb_prompt $" { fail "BT baz" }
232 timeout { fail "(timeout) BT baz" }
233 }
234
235 send_gdb "continue\n"
236 gdb_expect {
237 -re "Breakpoint .* grbx .x=1. at .*$gdb_prompt $" { pass "hit grbx" }
238 -re ".*$gdb_prompt $" { fail "hit grbx" }
239 timeout { fail "(timeout) hit grbx" }
240 }
241
242 send_gdb "backtrace\n"
243 gdb_expect {
244 -re "#0 .*grbx .*#1 .*main .*$gdb_prompt $" { pass "BT grbx" }
245 -re ".*$gdb_prompt $" { fail "BT grbx" }
246 timeout { fail "(timeout) BT grbx" }
247 }
248
This page took 0.034034 seconds and 4 git commands to generate.