OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.base/] [overlays.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
#   Copyright 1997, 1998, 2002 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
set hexx "0x\[0-9abcdefABCDEF\]+"
92
 
93
gdb_test "overlay manual" ""
94
gdb_test "overlay list" "No sections are mapped." "List with none mapped"
95
 
96
# capture the LMA addresses of [foo bar baz grbx foox barx bazx grbxx]
97
 
98
proc get_func_address { func func_sym msg } {
99
    global gdb_prompt
100
    global fptrcast
101
    global hexx
102
 
103
    set func_addr 0
104
    send_gdb "print $func\n"
105
    gdb_expect {
106
        -re "\\$\[0-9\]+ = $fptrcast (${hexx}) <$func_sym>.*$gdb_prompt $" {
107
            set func_addr $expect_out(1,string)
108
            pass "get $msg"
109
        }
110
        -re ".*$gdb_prompt $" {
111
            fail "get $msg"
112
        }
113
        default {
114
            fail "get $msg (timeout)"
115
        }
116
    }
117
    return $func_addr
118
}
119
 
120
set foo_lma  [get_func_address "foo"  "\\*foo\\*"  "foo  load address"]
121
set bar_lma  [get_func_address "bar"  "\\*bar\\*"  "bar  load address"]
122
set baz_lma  [get_func_address "baz"  "\\*baz\\*"  "baz  load address"]
123
set grbx_lma [get_func_address "grbx" "\\*grbx\\*" "grbx load address"]
124
 
125
gdb_test "print \$foox_lma = &foox" \
126
        ".* $iptrcast 0x.*"  "foox load addr"
127
gdb_test "print \$barx_lma = &barx" \
128
        ".* $iptrcast 0x.*"  "barx load addr"
129
gdb_test "print \$bazx_lma = &bazx" \
130
        ".* $iptrcast 0x.*"  "bazx load addr"
131
gdb_test "print \$grbxx_lma = &grbxx" \
132
        ".* $iptrcast 0x.*" "grbxx load addr"
133
 
134
# map each overlay successively, and
135
# capture the VMA addresses of [foo bar baz grbx foox barx bazx grbxx]
136
 
137
gdb_test "overlay map .ovly0" ""
138
gdb_test "overlay list" "Section .ovly0, loaded at.*, mapped at.*" "List ovly0"
139
set foo_vma [get_func_address "foo"  "foo"  "foo  runtime address"]
140
 
141
gdb_test "overlay map .ovly1" ""
142
gdb_test "overlay list" "Section .ovly1, loaded at.*, mapped at.*" "List ovly1"
143
set bar_vma [get_func_address "bar"  "bar"  "bar  runtime address"]
144
 
145
gdb_test "overlay map .ovly2" ""
146
gdb_test "overlay list" "Section .ovly2, loaded at.*, mapped at.*" "List ovly2"
147
set baz_vma [get_func_address "baz"  "baz"  "baz  runtime address"]
148
 
149
gdb_test "overlay map .ovly3" ""
150
gdb_test "overlay list" "Section .ovly3, loaded at.*, mapped at.*" "List ovly3"
151
set grbx_vma [get_func_address "grbx" "grbx" "grbx runtime address"]
152
 
153
gdb_test "overlay map .data00" ""
154
gdb_test "overlay list" "Section .data00, loaded .*, mapped .*" "List data00"
155
gdb_test "print \$foox_vma = &foox" \
156
        ".* $iptrcast 0x.*"  "foox runtime addr"
157
 
158
gdb_test "overlay map .data01" ""
159
gdb_test "overlay list" "Section .data01, loaded .*, mapped .*" "List data01"
160
gdb_test "print \$barx_vma = &barx" \
161
        ".* $iptrcast 0x.*"  "barx runtime addr"
162
 
163
gdb_test "overlay map .data02" ""
164
gdb_test "overlay list" "Section .data02, loaded .*, mapped .*" "List data02"
165
gdb_test "print \$bazx_vma = &bazx" \
166
        ".* $iptrcast 0x.*"  "bazx runtime addr"
167
 
168
gdb_test "overlay map .data03" ""
169
gdb_test "overlay list" "Section .data03, loaded .*, mapped .*" "List data03"
170
gdb_test "print \$grbxx_vma = &grbxx" \
171
        ".* $iptrcast 0x.*"  "grbxx runtime addr"
172
 
173
# Verify that LMA != VMA
174
 
175
gdb_test "print $foo_lma   != $foo_vma" ".* = 1"   "foo's LMA   != VMA"
176
gdb_test "print $bar_lma   != $bar_vma" ".* = 1"   "bar's LMA   != VMA"
177
gdb_test "print $baz_lma   != $baz_vma" ".* = 1"   "baz's LMA   != VMA"
178
gdb_test "print $grbx_lma  != $grbx_vma" ".* = 1"  "grbx's LMA  != VMA"
179
gdb_test "print \$foox_lma  != \$foox_vma" ".* = 1"  "foox's LMA  != VMA"
180
gdb_test "print \$barx_lma  != \$barx_vma" ".* = 1"  "barx's LMA  != VMA"
181
gdb_test "print \$bazx_lma  != \$bazx_vma" ".* = 1"  "bazx's LMA  != VMA"
182
gdb_test "print \$grbxx_lma != \$grbxx_vma" ".* = 1" "grbxx's LMA != VMA"
183
 
184
# Verify that early-mapped overlays have been bumped out
185
# by later-mapped overlays layed over in the same VMA range.
186
 
187
send_gdb "overlay list\n"
188
gdb_expect {
189
    -re ".*ovly0, "             { fail ".ovly0  not unmapped by .ovly1"  }
190
    -re ".*ovly2, "             { fail ".ovly2  not unmapped by .ovly3"  }
191
    -re ".*data00,"             { fail ".data00 not unmapped by .data01" }
192
    -re ".*data02,"             { fail ".data02 not unmapped by .data03" }
193
    -re ".*$gdb_prompt $"       { pass "Automatic unmapping"             }
194
    timeout                     { fail "(timeout) Automatic unmapping"   }
195
}
196
 
197
# Verify that both sec1 and sec2 can be loaded simultaneously.
198
proc simultaneous_pair { sec1 sec2 } {
199
    global gdb_prompt
200
 
201
    set pairname "$sec1 and $sec2 mapped simultaneously"
202
    gdb_test "overlay map $sec1" "" "$pairname: map $sec1"
203
    gdb_test "overlay map $sec2" "" "$pairname: map $sec2"
204
 
205
    set seen_sec1 0
206
    set seen_sec2 0
207
 
208
    send_gdb "overlay list\n"
209
    gdb_expect {
210
        -re ".*[string_to_regexp $sec1], " { set seen_sec1 1; exp_continue }
211
        -re ".*[string_to_regexp $sec2], " { set seen_sec2 1; exp_continue }
212
        -re ".*$gdb_prompt $" {
213
            if {$seen_sec1 && $seen_sec2} {
214
                pass "$pairname"
215
            } else {
216
                fail "$pairname"
217
            }
218
        }
219
        timeout { fail "(timeout) $pairname" }
220
    }
221
}
222
 
223
simultaneous_pair .ovly0 .ovly2
224
simultaneous_pair .ovly0 .ovly3
225
simultaneous_pair .ovly1 .ovly2
226
simultaneous_pair .ovly1 .ovly3
227
 
228
simultaneous_pair .data00 .data02
229
simultaneous_pair .data00 .data03
230
simultaneous_pair .data01 .data02
231
simultaneous_pair .data01 .data03
232
 
233
# test automatic mode
234
 
235
gdb_test "overlay auto" ""
236
gdb_test "overlay list" "No sections are mapped." "List none mapped (auto)"
237
gdb_test "break foo"  "Breakpoint .*at .*file .*foo.c.*"  "break foo"
238
gdb_test "break bar"  "Breakpoint .*at .*file .*bar.c.*"  "break bar"
239
gdb_test "break baz"  "Breakpoint .*at .*file .*baz.c.*"  "break baz"
240
gdb_test "break grbx" "Breakpoint .*at .*file .*grbx.c.*" "break grbx"
241
 
242
send_gdb "continue\n"
243
gdb_expect {
244
    -re "Breakpoint .* foo .x=1. at .*$gdb_prompt $" { pass   "hit foo" }
245
    -re ".*$gdb_prompt $"                            { fail   "hit foo" }
246
    timeout                                  { fail "(timeout) hit foo" }
247
}
248
 
249
send_gdb "backtrace\n"
250
gdb_expect {
251
    -re "#0 .*foo .*#1 .*main .*$gdb_prompt $"       { pass   "BT foo" }
252
    -re ".*$gdb_prompt $"                            { fail   "BT foo" }
253
    timeout                                  { fail "(timeout) BT foo" }
254
}
255
 
256
 
257
send_gdb "continue\n"
258
gdb_expect {
259
    -re "Breakpoint .* bar .x=1. at .*$gdb_prompt $" { pass   "hit bar" }
260
    -re ".*$gdb_prompt $"                            { fail   "hit bar" }
261
    timeout                                  { fail "(timeout) hit bar" }
262
}
263
 
264
send_gdb "backtrace\n"
265
gdb_expect {
266
    -re "#0 .*bar .*#1 .*main .*$gdb_prompt $"       { pass   "BT bar" }
267
    -re ".*$gdb_prompt $"                            { fail   "BT bar" }
268
    timeout                                  { fail "(timeout) BT bar" }
269
}
270
 
271
send_gdb "continue\n"
272
gdb_expect {
273
    -re "Breakpoint .* baz .x=1. at .*$gdb_prompt $" { pass   "hit baz" }
274
    -re ".*$gdb_prompt $"                            { fail   "hit baz" }
275
    timeout                                  { fail "(timeout) hit baz" }
276
}
277
 
278
send_gdb "backtrace\n"
279
gdb_expect {
280
    -re "#0 .*baz .*#1 .*main .*$gdb_prompt $"       { pass   "BT baz" }
281
    -re ".*$gdb_prompt $"                            { fail   "BT baz" }
282
    timeout                                  { fail "(timeout) BT baz" }
283
}
284
 
285
send_gdb "continue\n"
286
gdb_expect {
287
    -re "Breakpoint .* grbx .x=1. at .*$gdb_prompt $" { pass   "hit grbx" }
288
    -re ".*$gdb_prompt $"                             { fail   "hit grbx" }
289
    timeout                                   { fail "(timeout) hit grbx" }
290
}
291
 
292
send_gdb "backtrace\n"
293
gdb_expect {
294
    -re "#0 .*grbx .*#1 .*main .*$gdb_prompt $"      { pass   "BT grbx" }
295
    -re ".*$gdb_prompt $"                            { fail   "BT grbx" }
296
    timeout                                  { fail "(timeout) BT grbx" }
297
}
298
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.