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