1 # Copyright (C) 1997 Free Software Foundation, Inc.
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.
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.
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. */
17 # This file was written by srikanth (with huge chunks borrowed from old ones)
23 # o catch load command does not stop for implicit loads.
27 # o sharedlibrary command ignores its argument and ends
28 # up loading every shared library there is ...
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
38 # o gdb prints static and extern variables in shlibs incorrectly.
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.
52 if { [skip_hp_tests] } { continue }
57 # are we on a target board
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
67 clear_xfail "hppa*-*-*hpux*"
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
78 # Build the shared libraries this test case needs.
82 if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${testfile1}" object {debug additional_flags=+z}] != "" } {
83 perror "Couldn't compile ${testfile}1.c"
87 if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${testfile2}" object {debug additional_flags=+z}] != ""} {
88 perror "Couldn't compile ${testfile}2.c"
92 remote_exec build "ld -b ${testfile1} -o ${libfile1}"
93 remote_exec build "ld -b ${testfile2} -o ${libfile2}"
97 if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile1} ${libfile2}" "${binfile}" executable {debug additional_flags=-Ae -Wl,-aarchive}] != "" } {
98 perror "Couldn't build ${binfile}"
102 # Start with a fresh gdb
106 gdb_reinitialize_dir $srcdir/$subdir
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.
112 gdb_test "catch load" "Catchpoint \[0-9\]* .load <any library>.*" \
113 "set generic catch load"
115 # Verify that implicit shlib loads are caught and reported.
118 -re ".*solib-d1.*$gdb_prompt $" {
119 pass "Catch implicit load at startup"
121 -re "Program exited.*$gdb_prompt $" {
122 fail "CLLbs14756 || CLLbs16090 came back ???"
124 timeout { fail "(timeout) implicit library load" }
129 gdb_reinitialize_dir $srcdir/$subdir
132 if ![runto_main] { fail "breakpoint at main did not trigger ?" }
134 # verify that we print globals from shlibs correctly.
135 gdb_test "p global_from_primary" " = 5678" \
136 "print global from shlib (CLLbs15725)"
138 gdb_test "p global_from_secondary" " = 9012" \
139 "print global from shlib (CLLbs15725)"
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)"
145 if { ![runto function_from_secondary] } { return }
146 gdb_test "p local_static" " = 3456" "print local static variable (CLLbs15725)"
150 gdb_reinitialize_dir $srcdir/$subdir
153 gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
156 perror "C function calling tests suppressed"
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 !"
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 !"
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 !"
171 gdb_test "list function_from_primary" \
172 "No line number known for function_from_primary.*" \
173 "turning off auto shlib debug loading"
175 send_gdb "sharedlibrary solib-d1\n"
177 -re "Reading symbols from.*solib-d1.*$gdb_prompt $" {
178 pass "loading primary library on demand (1)"
180 -re "--Adding symbols for shared library.*solib-d1.*$gdb_prompt $" {
181 pass "loading primary library on demand (2)"
183 -re "$gdb_prompt $" { fail "loading primary library on demand (3)" }
184 timeout { fail "(timeout) loading primary library on demand" }
187 # make sure that load above of primary also did not pull in secondary.
188 send_gdb "list function_from_secondary\n"
190 -re "No symbol.*context.*$gdb_prompt $" {
191 pass "loaded only what we needed (1)"
193 -re "No line number known for function_from_secondary.*$gdb_prompt $" {
194 pass "loaded only what we needed (2)"
196 -re ".*9012.*$gdb_prompt $" { fail "Oops ! CLLbs15382 came back ?" }
197 timeout { fail "(timeout) printing global" }
202 gdb_reinitialize_dir $srcdir/$subdir
205 gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading"
207 gdb_test "set stop-on-solib-event 1" "" "stop-on-solib-event"
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)
214 -re "Stopped due to shared library event.*$gdb_prompt $" {
215 pass "stop for shlib event"
217 -re "Program exited.*$gdb_prompt $" {
218 fail "Bug CLLbs16090 came back ?"
220 timeout { fail "(timeout) stop for shlib event " }
223 gdb_test "b main" "Breakpoint 1 at.*" "set breakpoint on main"
225 gdb_test "set stop-on-solib-event 0" "" "stop-on-solib-event (timeout)"
227 # verify that we set breakpoint on the function and not the export stub
228 gdb_test "cont" "Breakpoint 1.*main.*" "run to main"
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"
234 -re "Breakpoint.*deferred.*garbage.*library containing.*is loaded.*$gdb_prompt $" {
235 pass " set deferred breakpoint (1)"
237 -re "Breakpoint 2 at 0x.*$gdb_prompt $" {
238 pass " set deferred breakpoint (2)"
240 -re "$gdb_prompt $" { fail " set deferred breakpoint (3)" }
241 timeout { fail "(timeout) set deferred breakpoint" }
244 # make sure that the sharedlibrary command enables any deferred breakpoints
246 send_gdb "sharedlibrary lib\n"
248 -re "Reading.*solib-d1.*$gdb_prompt $" {
249 pass "load up all shared libs (1)"
251 -re "Loading.*dld.sl.*--Adding symbols.*solib-d1.*$gdb_prompt $" {
252 pass "load up all shared libs (2)"
254 -re "$gdb_prompt $" { fail "load up all libraries" }
255 timeout { fail "(timeout) load all libraries " }
258 # do we stop at garbage ? If yes ok.
259 gdb_test "cont" "Breakpoint.*garbage.*" "deferred breakpoint enabled"