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