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