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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.hp/] [gdb.defects/] [solib-d.exp] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
#   Copyright (C) 1997 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
# This file was written by srikanth (with huge chunks borrowed from old ones)
18
#
19
# Regression test for
20
#
21
#     CLLbs14756
22
#
23
#         o catch load command does not stop for implicit loads.
24
#
25
#     CLLbs15382
26
#
27
#         o sharedlibrary command ignores its argument and ends
28
#           up loading every shared library there is ...
29
#
30
#     CLLbs15582
31
#
32
#         o info line non-existent-function dumps core
33
#         o clear non-existent function dumps core
34
#         o xbreak non-existent-function dumps core
35
#
36
#     CLLbs15725
37
#
38
#         o gdb prints static and extern variables in shlibs incorrectly.
39
#
40
#     CLLbs16090
41
#
42
#         o deferred breakpoints should kick in for shlibs loaded explicitly
43
#           with the sharedlibrary command.
44
#         o GDB confuses export stubs with actual function.
45
#
46
#
47
 
48
if $tracelevel {
49
    strace $tracelevel
50
}
51
 
52
if { [skip_hp_tests] } { continue }
53
 
54
set prms_id 0
55
set bug_id 0
56
 
57
# are we on a target board
58
if ![isnative] {
59
    return
60
}
61
 
62
# This test is presently only valid on HP-UX, since it requires
63
# that we use HP-UX-specific compiler & linker options to build
64
# the testcase.
65
#
66
setup_xfail "*-*-*"
67
clear_xfail "hppa*-*-*hpux*"
68
 
69
set prototypes 0
70
set testfile "solib-d"
71
set srcfile ${testfile}.c
72
set binfile ${objdir}/${subdir}/${testfile}
73
set testfile1 ${objdir}/${subdir}/${testfile}1.o
74
set testfile2 ${objdir}/${subdir}/${testfile}2.o
75
set libfile1 ${objdir}/${subdir}/${testfile}1.sl
76
set libfile2 ${objdir}/${subdir}/${testfile}2.sl
77
 
78
# Build the shared libraries this test case needs.
79
#
80
#cd ${subdir}
81
 
82
if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${testfile1}" object {debug additional_flags=+z}] != "" } {
83
    perror "Couldn't compile ${testfile}1.c"
84
    return -1
85
}
86
 
87
if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${testfile2}" object {debug additional_flags=+z}] != ""} {
88
    perror "Couldn't compile ${testfile}2.c"
89
    return -1
90
}
91
 
92
remote_exec build "ld -b ${testfile1} -o ${libfile1}"
93
remote_exec build "ld -b ${testfile2} -o ${libfile2}"
94
 
95
# Build the test case
96
 
97
if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile1} ${libfile2}" "${binfile}" executable {debug additional_flags=-Ae -Wl,-aarchive}] != "" } {
98
    perror "Couldn't build ${binfile}"
99
    return -1
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
 
109
# Verify that we can set a generic catchpoint on shlib loads.  I.e., that
110
# we can catch any shlib load, without specifying the name.
111
#
112
gdb_test "catch load" "Catchpoint \[0-9\]* .load .*" \
113
    "set generic catch load"
114
 
115
# Verify that implicit shlib loads are caught and reported.
116
send_gdb "run\n"
117
gdb_expect {
118
    -re ".*solib-d1.*$gdb_prompt $" {
119
        pass "Catch implicit load at startup"
120
    }
121
    -re "Program exited.*$gdb_prompt $" {
122
        fail "CLLbs14756 || CLLbs16090 came back ???"
123
    }
124
    timeout { fail "(timeout) implicit library load" }
125
}
126
 
127
gdb_exit
128
gdb_start
129
gdb_reinitialize_dir $srcdir/$subdir
130
gdb_load ${binfile}
131
 
132
if ![runto_main] { fail "breakpoint at main did not trigger ?" }
133
 
134
# verify that we print globals from shlibs correctly.
135
gdb_test "p global_from_primary" " = 5678" \
136
    "print global from shlib (CLLbs15725)"
137
 
138
gdb_test "p global_from_secondary" " = 9012" \
139
    "print global from shlib (CLLbs15725)"
140
 
141
# verify that we print static variables from shlibs correctly.
142
if { ![runto function_from_primary] } { return }
143
gdb_test "p file_static" " = 1234" "print file static variable (CLLbs15725)"
144
 
145
if { ![runto function_from_secondary] } { return }
146
gdb_test "p local_static" " = 3456" "print local static variable (CLLbs15725)"
147
 
148
gdb_exit
149
gdb_start
150
gdb_reinitialize_dir $srcdir/$subdir
151
gdb_load ${binfile}
152
 
153
gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
154
 
155
if ![runto_main] {
156
    perror "C function calling tests suppressed"
157
}
158
 
159
# verify that "clear non-existent-symbol" does not crash
160
gdb_test "clear junkfunc" "Location not found.*" \
161
    "clear non-existent function does not dump core !"
162
 
163
# verify that "info line non-existent-symbol" does not crash
164
gdb_test "info line junkfunc" "Location not found.*" \
165
    "info line junkfunc does not dump core !"
166
 
167
# verify that "xbreak non-existent-symbol" does not crash
168
gdb_test "xbreak junkfunc" "Function \"junkfunc\" not defined.*" \
169
    "xbreak junkfunc does not dump core !"
170
 
171
gdb_test "list function_from_primary" \
172
    "No line number known for function_from_primary.*" \
173
    "turning off auto shlib debug loading"
174
 
175
send_gdb "sharedlibrary solib-d1\n"
176
gdb_expect {
177
    -re "Reading symbols from.*solib-d1.*$gdb_prompt $" {
178
        pass "loading primary library on demand (1)"
179
    }
180
    -re "--Adding symbols for shared library.*solib-d1.*$gdb_prompt $" {
181
        pass "loading primary library on demand (2)"
182
    }
183
    -re "$gdb_prompt $" { fail "loading primary library on demand (3)" }
184
    timeout { fail "(timeout) loading primary library on demand" }
185
}
186
 
187
# make sure that load above of primary also did not pull in secondary.
188
send_gdb "list function_from_secondary\n"
189
gdb_expect {
190
    -re "No symbol.*context.*$gdb_prompt $" {
191
        pass "loaded only what we needed (1)"
192
    }
193
    -re "No line number known for function_from_secondary.*$gdb_prompt $" {
194
        pass "loaded only what we needed (2)"
195
    }
196
    -re ".*9012.*$gdb_prompt $" { fail "Oops ! CLLbs15382 came back ?" }
197
    timeout { fail "(timeout) printing global" }
198
}
199
 
200
gdb_exit
201
gdb_start
202
gdb_reinitialize_dir $srcdir/$subdir
203
gdb_load ${binfile}
204
 
205
gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
206
 
207
gdb_test "set stop-on-solib-event 1" "" "stop-on-solib-event"
208
 
209
# verify that we set breakpoint on the function and not the export stub
210
# used to be that we set bp on the export stub of _start and thus miss
211
# shlib loads in some cases (where the stub exists)
212
send_gdb "run\n"
213
gdb_expect {
214
    -re "Stopped due to shared library event.*$gdb_prompt $" {
215
        pass "stop for shlib event"
216
    }
217
    -re "Program exited.*$gdb_prompt $" {
218
        fail "Bug CLLbs16090 came back ?"
219
    }
220
    timeout { fail "(timeout) stop for shlib event " }
221
}
222
 
223
gdb_test "b main" "Breakpoint 1 at.*" "set breakpoint on main"
224
 
225
gdb_test "set stop-on-solib-event 0" "" "stop-on-solib-event (timeout)"
226
 
227
# verify that we set breakpoint on the function and not the export stub
228
gdb_test "cont" "Breakpoint 1.*main.*" "run to main"
229
 
230
# On PA64 we read in the unwind info and linker symbol table which lets
231
# us set the breakpoint and not defer it.
232
send_gdb "b garbage\n"
233
gdb_expect {
234
    -re "Breakpoint.*deferred.*garbage.*library containing.*is loaded.*$gdb_prompt $" {
235
        pass " set deferred breakpoint (1)"
236
    }
237
    -re "Breakpoint 2 at 0x.*$gdb_prompt $" {
238
        pass " set deferred breakpoint (2)"
239
    }
240
    -re "$gdb_prompt $" { fail " set deferred breakpoint (3)" }
241
    timeout { fail "(timeout) set deferred breakpoint" }
242
}
243
 
244
# make sure that the sharedlibrary command enables any deferred breakpoints
245
# that it should.
246
send_gdb "sharedlibrary lib\n"
247
gdb_expect {
248
    -re "Reading.*solib-d1.*$gdb_prompt $" {
249
        pass "load up all shared libs (1)"
250
    }
251
    -re "Loading.*dld.sl.*--Adding symbols.*solib-d1.*$gdb_prompt $" {
252
        pass "load up all shared libs (2)"
253
    }
254
    -re "$gdb_prompt $" { fail "load up all libraries" }
255
    timeout { fail "(timeout) load all libraries " }
256
}
257
 
258
# do we stop at garbage ? If yes ok.
259
gdb_test "cont" "Breakpoint.*garbage.*" "deferred breakpoint enabled"
260
 
261
gdb_exit
262
return 0

powered by: WebSVN 2.1.0

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