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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [shlib-call.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
#   Copyright (C) 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
# file to test calls into shared libraries
21
# the source files for this test are:
22
#
23
# shmain.c
24
# shr1.c (shared lib)
25
# shr2.c (shared lib)
26
# ss.h (header for shr2.c)
27
#
28
# file written by Elena Zannoni: elz@ch.apollo.com
29
#
30
 
31
#debug shmain
32
#prop lib shr1.sl
33
#prop lib shr2.sl
34
 
35
if $tracelevel then {
36
        strace $tracelevel
37
}
38
 
39
set prms_id 0
40
set bug_id 0
41
 
42
# are we on a target board?
43
if ![isnative] then {
44
    return 0
45
}
46
 
47
set testfile "shmain"
48
set libfile "shr"
49
set srcfile ${testfile}.c
50
set binfile ${objdir}/${subdir}/${testfile}
51
 
52
# build the first test case
53
if [get_compiler_info ${binfile}] {
54
    return -1
55
}
56
 
57
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } {
58
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
59
}
60
 
61
 
62
# Build the shared libraries this test case needs.
63
#
64
 
65
if {$gcc_compiled == 0} {
66
    if [istarget "hppa*-hp-hpux*"] then {
67
        set additional_flags "additional_flags=+z"
68
    } else {
69
        # don't know what the compiler is...
70
        set additional_flags ""
71
    }
72
} else {
73
    set additional_flags "additional_flags=-fpic"
74
}
75
 
76
if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${objdir}/${subdir}/${libfile}1.o" object [list debug $additional_flags]] != ""} {
77
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
78
}
79
 
80
if {[gdb_compile "${srcdir}/${subdir}/${libfile}2.c" "${objdir}/${subdir}/${libfile}2.o" object [list debug $additional_flags]] != ""} {
81
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
82
}
83
 
84
if [istarget "hppa*-*-hpux*"] {
85
    remote_exec build "ld -b ${objdir}/${subdir}/${libfile}1.o -o ${objdir}/${subdir}/${libfile}1.sl"
86
    remote_exec build "ld -b ${objdir}/${subdir}/${libfile}2.o -o ${objdir}/${subdir}/${libfile}2.sl"
87
} else {
88
    set additional_flags "additional_flags=-shared"
89
    if {[gdb_compile "${objdir}/${subdir}/${libfile}1.o" "${objdir}/${subdir}/${libfile}1.sl" executable [list debug $additional_flags]] != ""} {
90
        gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
91
    }
92
    if {[gdb_compile "${objdir}/${subdir}/${libfile}2.o" "${objdir}/${subdir}/${libfile}2.sl" executable [list debug $additional_flags]] != ""} {
93
        gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
94
    }
95
}
96
if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}1.sl ${objdir}/${subdir}/${libfile}2.sl" "${binfile}" executable {debug}] != ""} {
97
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
98
}
99
 
100
 
101
 
102
# Start with a fresh gdb.
103
 
104
gdb_exit
105
gdb_start
106
gdb_reinitialize_dir $srcdir/$subdir
107
gdb_load ${binfile}
108
send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
109
send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
110
send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
111
 
112
 
113
if ![runto_main] then {
114
        perror "C function calling tests suppressed"
115
}
116
 
117
 
118
#step -over
119
 
120
    send_gdb "next\n"
121
    gdb_expect {
122
        -re ".*g = shr1\\(g\\).*$gdb_prompt $" {pass "next to shr1"}
123
        -re ".*$gdb_prompt $" { fail "next to shr1" }
124
        timeout { fail "next to shr1 (timeout)" }
125
    }
126
 
127
 
128
 
129
#print g
130
 
131
send_gdb "print g\n"
132
gdb_expect {
133
    -re ".*\[0-9\]* = 1.*$gdb_prompt $" {
134
        pass "print g"
135
      }
136
    -re ".*$gdb_prompt $" { fail "print  g" }
137
    timeout           { fail "(timeout) print g" }
138
  }
139
 
140
 
141
#step -over
142
    send_gdb "next\n"
143
    gdb_expect {
144
        -re ".*address of sgs is $hex.*g = shr2\\(g\\).*$gdb_prompt $" {
145
             pass "next over shr1" }
146
        -re ".*$gdb_prompt $" { fail "next over shr1" }
147
        timeout { fail "next over shr1 (timeout)" }
148
    }
149
 
150
#print g
151
send_gdb "print g\n"
152
gdb_expect {
153
    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
154
        pass "print g" }
155
    -re ".*$gdb_prompt $" { fail "print  g" }
156
    timeout           { fail "(timeout) print g" }
157
  }
158
 
159
#print shr1(1)
160
send_gdb "print shr1(1)\n"
161
gdb_expect {
162
    -re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" {
163
        pass "print shr1(1)" }
164
    -re ".*$gdb_prompt $" { fail "print  shr1(1)" }
165
    timeout           { fail "(timeout) print shr1(1)" }
166
  }
167
 
168
#print shr1(g)
169
send_gdb "print shr1(g)\n"
170
gdb_expect {
171
    -re ".*address of sgs is $hex.*\[0-9\]* = 4.*$gdb_prompt $" {
172
        pass "print shr1(g)" }
173
    -re ".*$gdb_prompt $" { fail "print  shr1(g)" }
174
    timeout           { fail "(timeout) print shr1(g)" }
175
  }
176
 
177
#break shr2
178
#go
179
gdb_test "break shr2" \
180
    "Breakpoint.*file.*shr2.c, line.*" \
181
    "breakpoint function shr2"
182
 
183
gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, shr2 \\(.*\\) at.*shr2\\.c:7.*7.*return 2.x;" \
184
"run until breakpoint set at a function"
185
 
186
 
187
#print shr1(1)
188
send_gdb "print shr1(1)\n"
189
gdb_expect {
190
    -re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" {
191
        pass "print shr1(1)"
192
      }
193
    -re ".*$gdb_prompt $" { fail "print  shr1(1)" }
194
    timeout           { fail "(timeout) print shr1(1)" }
195
  }
196
 
197
#print mainshr1(1)
198
send_gdb "print mainshr1(1)\n"
199
gdb_expect {
200
    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
201
        pass "print mainshr1(1) from shlib func"
202
      }
203
    -re ".*$gdb_prompt $" { fail "print  mainshr1(1) from shlib func" }
204
    timeout           { fail "(timeout) print mainshr1(1) from shlib func" }
205
  }
206
 
207
#step -return
208
    send_gdb "step\n"
209
    gdb_expect {
210
        -re ".*\\\}.*$gdb_prompt $" { pass "step inside shr2 (shlib func)"}
211
        -re ".*$gdb_prompt $" { fail "step inside shr2 (shlib func)" }
212
        timeout { fail "step inside shr2 (shlib func) (timeout)" }
213
    }
214
 
215
    send_gdb "step\n"
216
    gdb_expect {
217
        -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" { pass "step out of shr2 to main"}
218
        -re ".*$gdb_prompt $" { fail "step out of shr2 to main" }
219
        timeout { fail "step out of shr2 to main (timeout)" }
220
    }
221
 
222
#print mainshr1(1)
223
send_gdb "print mainshr1(1)\n"
224
gdb_expect {
225
    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
226
        pass "print mainshr1(1)"
227
      }
228
    -re ".*$gdb_prompt $" { fail "print  mainshr1(1) from main" }
229
    timeout           { fail "(timeout) print mainshr1(1) from main" }
230
  }
231
 
232
#step
233
    send_gdb "step\n"
234
    gdb_expect {
235
        -re ".*mainshr1 \\(g=4\\) at.*return 2.g;.*$gdb_prompt $" { pass "step into mainshr1"}
236
        -re ".*$gdb_prompt $" { fail "step into mainshr1" }
237
        timeout { fail "step into mainshr1 (timeout)" }
238
    }
239
 
240
# Start with a fresh gdb.
241
 
242
gdb_exit
243
gdb_start
244
gdb_reinitialize_dir $srcdir/$subdir
245
gdb_load ${binfile}
246
send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
247
send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
248
send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
249
 
250
# PR's 16495, 18213
251
# test that we can re-set breakpoints in shared libraries
252
gdb_test "break shr1" "Breakpoint 1.*" "set bp in shared library"
253
gdb_test "run" "Starting program:.*Breakpoint 1,.*" "run to bp in shared library"
254
gdb_test "cont" ".*Program exited normally..*"
255
gdb_test "run" "Starting program:.*Breakpoint 1,.*" "re-run to bp in shared library (PR's 16495, 18213)"
256
gdb_test "cont" ".*Program exited normally..*"
257
 
258
return 0

powered by: WebSVN 2.1.0

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