]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright (C) 1997, 2007 Free Software Foundation, Inc. |
7be570e7 JM |
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 | ||
afabe08c JL |
78 | # Create and source the file that provides information about the compiler |
79 | # used to compile the test case. | |
80 | if [get_compiler_info ${binfile}] { | |
81 | return -1; | |
82 | } | |
83 | ||
84 | # set up appropriate compile option to recognize long double | |
85 | if {$hp_aCC_compiler || $hp_cc_compiler} { | |
86 | set picflag "+z" | |
87 | set ansiflag "-Ae" | |
88 | } else { | |
89 | set picflag "-fpic" | |
90 | set ansiflag "" | |
91 | } | |
92 | ||
93 | ||
7be570e7 JM |
94 | # Build the shared libraries this test case needs. |
95 | # | |
96 | #cd ${subdir} | |
97 | ||
afabe08c | 98 | if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${testfile1}" object "{debug additional_flags=${picflag}}"] != "" } { |
7be570e7 JM |
99 | perror "Couldn't compile ${testfile}1.c" |
100 | return -1 | |
101 | } | |
102 | ||
afabe08c | 103 | if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${testfile2}" object "{debug additional_flags=${picflag}}"] != ""} { |
7be570e7 JM |
104 | perror "Couldn't compile ${testfile}2.c" |
105 | return -1 | |
106 | } | |
107 | ||
108 | remote_exec build "ld -b ${testfile1} -o ${libfile1}" | |
109 | remote_exec build "ld -b ${testfile2} -o ${libfile2}" | |
110 | ||
111 | # Build the test case | |
112 | ||
afabe08c | 113 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile1} ${libfile2}" "${binfile}" executable "{debug additional_flags=${ansiflag} -Wl,-aarchive}"] != "" } { |
7be570e7 JM |
114 | perror "Couldn't build ${binfile}" |
115 | return -1 | |
116 | } | |
117 | ||
118 | # Start with a fresh gdb | |
119 | ||
120 | gdb_exit | |
121 | gdb_start | |
122 | gdb_reinitialize_dir $srcdir/$subdir | |
123 | gdb_load ${binfile} | |
124 | ||
125 | # Verify that we can set a generic catchpoint on shlib loads. I.e., that | |
126 | # we can catch any shlib load, without specifying the name. | |
127 | # | |
128 | gdb_test "catch load" "Catchpoint \[0-9\]* .load <any library>.*" \ | |
129 | "set generic catch load" | |
130 | ||
131 | # Verify that implicit shlib loads are caught and reported. | |
132 | send_gdb "run\n" | |
133 | gdb_expect { | |
134 | -re ".*solib-d1.*$gdb_prompt $" { | |
135 | pass "Catch implicit load at startup" | |
136 | } | |
137 | -re "Program exited.*$gdb_prompt $" { | |
138 | fail "CLLbs14756 || CLLbs16090 came back ???" | |
139 | } | |
140 | timeout { fail "(timeout) implicit library load" } | |
141 | } | |
142 | ||
143 | gdb_exit | |
144 | gdb_start | |
145 | gdb_reinitialize_dir $srcdir/$subdir | |
146 | gdb_load ${binfile} | |
147 | ||
148 | if ![runto_main] { fail "breakpoint at main did not trigger ?" } | |
149 | ||
150 | # verify that we print globals from shlibs correctly. | |
151 | gdb_test "p global_from_primary" " = 5678" \ | |
152 | "print global from shlib (CLLbs15725)" | |
153 | ||
154 | gdb_test "p global_from_secondary" " = 9012" \ | |
155 | "print global from shlib (CLLbs15725)" | |
156 | ||
157 | # verify that we print static variables from shlibs correctly. | |
158 | if { ![runto function_from_primary] } { return } | |
159 | gdb_test "p file_static" " = 1234" "print file static variable (CLLbs15725)" | |
160 | ||
161 | if { ![runto function_from_secondary] } { return } | |
162 | gdb_test "p local_static" " = 3456" "print local static variable (CLLbs15725)" | |
163 | ||
164 | gdb_exit | |
165 | gdb_start | |
166 | gdb_reinitialize_dir $srcdir/$subdir | |
167 | gdb_load ${binfile} | |
168 | ||
169 | gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading" | |
170 | ||
171 | if ![runto_main] { | |
172 | perror "C function calling tests suppressed" | |
173 | } | |
174 | ||
175 | # verify that "clear non-existent-symbol" does not crash | |
176 | gdb_test "clear junkfunc" "Location not found.*" \ | |
177 | "clear non-existent function does not dump core !" | |
178 | ||
179 | # verify that "info line non-existent-symbol" does not crash | |
180 | gdb_test "info line junkfunc" "Location not found.*" \ | |
181 | "info line junkfunc does not dump core !" | |
182 | ||
183 | # verify that "xbreak non-existent-symbol" does not crash | |
184 | gdb_test "xbreak junkfunc" "Function \"junkfunc\" not defined.*" \ | |
185 | "xbreak junkfunc does not dump core !" | |
186 | ||
187 | gdb_test "list function_from_primary" \ | |
188 | "No line number known for function_from_primary.*" \ | |
189 | "turning off auto shlib debug loading" | |
190 | ||
191 | send_gdb "sharedlibrary solib-d1\n" | |
192 | gdb_expect { | |
193 | -re "Reading symbols from.*solib-d1.*$gdb_prompt $" { | |
194 | pass "loading primary library on demand (1)" | |
195 | } | |
196 | -re "--Adding symbols for shared library.*solib-d1.*$gdb_prompt $" { | |
197 | pass "loading primary library on demand (2)" | |
198 | } | |
199 | -re "$gdb_prompt $" { fail "loading primary library on demand (3)" } | |
200 | timeout { fail "(timeout) loading primary library on demand" } | |
201 | } | |
202 | ||
203 | # make sure that load above of primary also did not pull in secondary. | |
204 | send_gdb "list function_from_secondary\n" | |
205 | gdb_expect { | |
206 | -re "No symbol.*context.*$gdb_prompt $" { | |
207 | pass "loaded only what we needed (1)" | |
208 | } | |
209 | -re "No line number known for function_from_secondary.*$gdb_prompt $" { | |
210 | pass "loaded only what we needed (2)" | |
211 | } | |
212 | -re ".*9012.*$gdb_prompt $" { fail "Oops ! CLLbs15382 came back ?" } | |
213 | timeout { fail "(timeout) printing global" } | |
214 | } | |
215 | ||
216 | gdb_exit | |
217 | gdb_start | |
218 | gdb_reinitialize_dir $srcdir/$subdir | |
219 | gdb_load ${binfile} | |
220 | ||
221 | gdb_test "set auto-solib-add 0" "" "turn off auto shlib debug loading" | |
222 | ||
223 | gdb_test "set stop-on-solib-event 1" "" "stop-on-solib-event" | |
224 | ||
225 | # verify that we set breakpoint on the function and not the export stub | |
226 | # used to be that we set bp on the export stub of _start and thus miss | |
227 | # shlib loads in some cases (where the stub exists) | |
228 | send_gdb "run\n" | |
229 | gdb_expect { | |
230 | -re "Stopped due to shared library event.*$gdb_prompt $" { | |
231 | pass "stop for shlib event" | |
232 | } | |
233 | -re "Program exited.*$gdb_prompt $" { | |
234 | fail "Bug CLLbs16090 came back ?" | |
235 | } | |
236 | timeout { fail "(timeout) stop for shlib event " } | |
237 | } | |
238 | ||
239 | gdb_test "b main" "Breakpoint 1 at.*" "set breakpoint on main" | |
240 | ||
241 | gdb_test "set stop-on-solib-event 0" "" "stop-on-solib-event (timeout)" | |
242 | ||
243 | # verify that we set breakpoint on the function and not the export stub | |
244 | gdb_test "cont" "Breakpoint 1.*main.*" "run to main" | |
245 | ||
246 | # On PA64 we read in the unwind info and linker symbol table which lets | |
247 | # us set the breakpoint and not defer it. | |
248 | send_gdb "b garbage\n" | |
249 | gdb_expect { | |
250 | -re "Breakpoint.*deferred.*garbage.*library containing.*is loaded.*$gdb_prompt $" { | |
251 | pass " set deferred breakpoint (1)" | |
252 | } | |
253 | -re "Breakpoint 2 at 0x.*$gdb_prompt $" { | |
254 | pass " set deferred breakpoint (2)" | |
255 | } | |
256 | -re "$gdb_prompt $" { fail " set deferred breakpoint (3)" } | |
257 | timeout { fail "(timeout) set deferred breakpoint" } | |
258 | } | |
259 | ||
260 | # make sure that the sharedlibrary command enables any deferred breakpoints | |
261 | # that it should. | |
262 | send_gdb "sharedlibrary lib\n" | |
263 | gdb_expect { | |
264 | -re "Reading.*solib-d1.*$gdb_prompt $" { | |
265 | pass "load up all shared libs (1)" | |
266 | } | |
267 | -re "Loading.*dld.sl.*--Adding symbols.*solib-d1.*$gdb_prompt $" { | |
268 | pass "load up all shared libs (2)" | |
269 | } | |
270 | -re "$gdb_prompt $" { fail "load up all libraries" } | |
271 | timeout { fail "(timeout) load all libraries " } | |
272 | } | |
273 | ||
274 | # do we stop at garbage ? If yes ok. | |
275 | gdb_test "cont" "Breakpoint.*garbage.*" "deferred breakpoint enabled" | |
276 | ||
277 | gdb_exit | |
278 | return 0 |