]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.hp/gdb.defects/solib-d.exp
use gnulib's update-copyright script to update copyright years
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.defects / solib-d.exp
CommitLineData
7b6bb8da
JB
1# Copyright (C) 1997, 2007, 2008, 2009, 2010, 2011
2# Free Software Foundation, Inc.
7be570e7
JM
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
7be570e7 7# (at your option) any later version.
e22f8b7c 8#
7be570e7
JM
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
7be570e7 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>. */
7be570e7
JM
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
48if $tracelevel {
49 strace $tracelevel
50}
51
52if { [skip_hp_tests] } { continue }
53
7be570e7
JM
54
55# are we on a target board
56if ![isnative] {
57 return
58}
59
60# This test is presently only valid on HP-UX, since it requires
61# that we use HP-UX-specific compiler & linker options to build
62# the testcase.
63#
64setup_xfail "*-*-*"
65clear_xfail "hppa*-*-*hpux*"
66
67set prototypes 0
68set testfile "solib-d"
69set srcfile ${testfile}.c
70set binfile ${objdir}/${subdir}/${testfile}
71set testfile1 ${objdir}/${subdir}/${testfile}1.o
72set testfile2 ${objdir}/${subdir}/${testfile}2.o
73set libfile1 ${objdir}/${subdir}/${testfile}1.sl
74set libfile2 ${objdir}/${subdir}/${testfile}2.sl
75
afabe08c
JL
76# Create and source the file that provides information about the compiler
77# used to compile the test case.
78if [get_compiler_info ${binfile}] {
79 return -1;
80}
81
82# set up appropriate compile option to recognize long double
83if {$hp_aCC_compiler || $hp_cc_compiler} {
84 set picflag "+z"
85 set ansiflag "-Ae"
86} else {
87 set picflag "-fpic"
88 set ansiflag ""
89}
90
91
7be570e7
JM
92# Build the shared libraries this test case needs.
93#
94#cd ${subdir}
95
afabe08c 96if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${testfile1}" object "{debug additional_flags=${picflag}}"] != "" } {
7be570e7
JM
97 perror "Couldn't compile ${testfile}1.c"
98 return -1
99}
100
afabe08c 101if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${testfile2}" object "{debug additional_flags=${picflag}}"] != ""} {
7be570e7
JM
102 perror "Couldn't compile ${testfile}2.c"
103 return -1
104}
105
106remote_exec build "ld -b ${testfile1} -o ${libfile1}"
107remote_exec build "ld -b ${testfile2} -o ${libfile2}"
108
109# Build the test case
110
afabe08c 111if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile1} ${libfile2}" "${binfile}" executable "{debug additional_flags=${ansiflag} -Wl,-aarchive}"] != "" } {
7be570e7
JM
112 perror "Couldn't build ${binfile}"
113 return -1
114}
115
116# Start with a fresh gdb
117
118gdb_exit
119gdb_start
120gdb_reinitialize_dir $srcdir/$subdir
121gdb_load ${binfile}
122
123# Verify that we can set a generic catchpoint on shlib loads. I.e., that
124# we can catch any shlib load, without specifying the name.
125#
126gdb_test "catch load" "Catchpoint \[0-9\]* .load <any library>.*" \
127 "set generic catch load"
128
129# Verify that implicit shlib loads are caught and reported.
130send_gdb "run\n"
131gdb_expect {
132 -re ".*solib-d1.*$gdb_prompt $" {
133 pass "Catch implicit load at startup"
134 }
fda326dd 135 -re "Inferior \[0-9\]+ exited.*$gdb_prompt $" {
7be570e7
JM
136 fail "CLLbs14756 || CLLbs16090 came back ???"
137 }
138 timeout { fail "(timeout) implicit library load" }
139}
140
141gdb_exit
142gdb_start
143gdb_reinitialize_dir $srcdir/$subdir
144gdb_load ${binfile}
145
146if ![runto_main] { fail "breakpoint at main did not trigger ?" }
147
148# verify that we print globals from shlibs correctly.
149gdb_test "p global_from_primary" " = 5678" \
150 "print global from shlib (CLLbs15725)"
151
152gdb_test "p global_from_secondary" " = 9012" \
153 "print global from shlib (CLLbs15725)"
154
155# verify that we print static variables from shlibs correctly.
156if { ![runto function_from_primary] } { return }
157gdb_test "p file_static" " = 1234" "print file static variable (CLLbs15725)"
158
159if { ![runto function_from_secondary] } { return }
160gdb_test "p local_static" " = 3456" "print local static variable (CLLbs15725)"
161
162gdb_exit
163gdb_start
164gdb_reinitialize_dir $srcdir/$subdir
165gdb_load ${binfile}
166
167gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
168
169if ![runto_main] {
170 perror "C function calling tests suppressed"
171}
172
173# verify that "clear non-existent-symbol" does not crash
174gdb_test "clear junkfunc" "Location not found.*" \
175 "clear non-existent function does not dump core !"
176
177# verify that "info line non-existent-symbol" does not crash
178gdb_test "info line junkfunc" "Location not found.*" \
179 "info line junkfunc does not dump core !"
180
181# verify that "xbreak non-existent-symbol" does not crash
182gdb_test "xbreak junkfunc" "Function \"junkfunc\" not defined.*" \
183 "xbreak junkfunc does not dump core !"
184
185gdb_test "list function_from_primary" \
186 "No line number known for function_from_primary.*" \
187 "turning off auto shlib debug loading"
188
189send_gdb "sharedlibrary solib-d1\n"
190gdb_expect {
191 -re "Reading symbols from.*solib-d1.*$gdb_prompt $" {
192 pass "loading primary library on demand (1)"
193 }
194 -re "--Adding symbols for shared library.*solib-d1.*$gdb_prompt $" {
195 pass "loading primary library on demand (2)"
196 }
197 -re "$gdb_prompt $" { fail "loading primary library on demand (3)" }
198 timeout { fail "(timeout) loading primary library on demand" }
199}
200
201# make sure that load above of primary also did not pull in secondary.
202send_gdb "list function_from_secondary\n"
203gdb_expect {
204 -re "No symbol.*context.*$gdb_prompt $" {
205 pass "loaded only what we needed (1)"
206 }
207 -re "No line number known for function_from_secondary.*$gdb_prompt $" {
208 pass "loaded only what we needed (2)"
209 }
210 -re ".*9012.*$gdb_prompt $" { fail "Oops ! CLLbs15382 came back ?" }
211 timeout { fail "(timeout) printing global" }
212}
213
214gdb_exit
215gdb_start
216gdb_reinitialize_dir $srcdir/$subdir
217gdb_load ${binfile}
218
219gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
220
221gdb_test "set stop-on-solib-event 1" "" "stop-on-solib-event"
222
223# verify that we set breakpoint on the function and not the export stub
224# used to be that we set bp on the export stub of _start and thus miss
225# shlib loads in some cases (where the stub exists)
226send_gdb "run\n"
227gdb_expect {
228 -re "Stopped due to shared library event.*$gdb_prompt $" {
229 pass "stop for shlib event"
230 }
fda326dd 231 -re "Inferior \[0-9\]+ exited.*$gdb_prompt $" {
7be570e7
JM
232 fail "Bug CLLbs16090 came back ?"
233 }
234 timeout { fail "(timeout) stop for shlib event " }
235}
236
237gdb_test "b main" "Breakpoint 1 at.*" "set breakpoint on main"
238
239gdb_test "set stop-on-solib-event 0" "" "stop-on-solib-event (timeout)"
240
241# verify that we set breakpoint on the function and not the export stub
242gdb_test "cont" "Breakpoint 1.*main.*" "run to main"
243
244# On PA64 we read in the unwind info and linker symbol table which lets
245# us set the breakpoint and not defer it.
246send_gdb "b garbage\n"
247gdb_expect {
248 -re "Breakpoint.*deferred.*garbage.*library containing.*is loaded.*$gdb_prompt $" {
249 pass " set deferred breakpoint (1)"
250 }
251 -re "Breakpoint 2 at 0x.*$gdb_prompt $" {
252 pass " set deferred breakpoint (2)"
253 }
254 -re "$gdb_prompt $" { fail " set deferred breakpoint (3)" }
255 timeout { fail "(timeout) set deferred breakpoint" }
256}
257
258# make sure that the sharedlibrary command enables any deferred breakpoints
259# that it should.
260send_gdb "sharedlibrary lib\n"
261gdb_expect {
262 -re "Reading.*solib-d1.*$gdb_prompt $" {
263 pass "load up all shared libs (1)"
264 }
265 -re "Loading.*dld.sl.*--Adding symbols.*solib-d1.*$gdb_prompt $" {
266 pass "load up all shared libs (2)"
267 }
268 -re "$gdb_prompt $" { fail "load up all libraries" }
269 timeout { fail "(timeout) load all libraries " }
270}
271
272# do we stop at garbage ? If yes ok.
273gdb_test "cont" "Breakpoint.*garbage.*" "deferred breakpoint enabled"
274
275gdb_exit
276return 0