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