1 |
106 |
markom |
# Copyright (C) 1997, 1998 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 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 |
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
18 |
|
|
# bug-gdb@prep.ai.mit.edu
|
19 |
|
|
|
20 |
|
|
if $tracelevel then {
|
21 |
|
|
strace $tracelevel
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
set prms_id 0
|
25 |
|
|
set bug_id 0
|
26 |
|
|
|
27 |
|
|
if { [skip_hp_tests] } then { continue }
|
28 |
|
|
|
29 |
|
|
set testfile "so-thresh"
|
30 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
31 |
|
|
|
32 |
|
|
if [get_compiler_info ${binfile}] {
|
33 |
|
|
return -1
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
# This testcase is relatively large, and therefore can take awhile to
|
37 |
|
|
# load. We'd best set the timeout to something suitable, or we may
|
38 |
|
|
# seem to fail...
|
39 |
|
|
#
|
40 |
|
|
set timeout 60
|
41 |
|
|
|
42 |
|
|
# Build procedure for this testcase:
|
43 |
|
|
# ${srcdir}/${subdir}/so-thresh.sh ${subdir}
|
44 |
|
|
# which calls,
|
45 |
|
|
# make -f ${srcdir}/${subdir}/so-thresh.mk
|
46 |
|
|
# which builds,
|
47 |
|
|
# genso-thresh (from genso-thresh.c)
|
48 |
|
|
# which generates,
|
49 |
|
|
# lib00-so-thresh.c
|
50 |
|
|
# lib01-so-thresh.c
|
51 |
|
|
# lib02-so-thresh.c
|
52 |
|
|
# so-thresh.lopt (link options file)
|
53 |
|
|
# lib0*-so-thresh.sl (from .c files above)
|
54 |
|
|
# so-thresh (from so-thresh.c)
|
55 |
|
|
# using lib0*-so-thresh.sl and so-thresh.lopt
|
56 |
|
|
#
|
57 |
|
|
# Since so-thresh.mk requires SRCDIR and OBJDIR macro definitions,
|
58 |
|
|
# and SRCDIR / OBJDIR could be in relative path format, we use
|
59 |
|
|
# so-thresh.sh script to pin down SRCDIR / OBJDIR (using $PWD/ prefix
|
60 |
|
|
# when detected relative path values for srcdir / objdir), before the
|
61 |
|
|
# 'cd $subdir' call (when this can be done in TCL here, we can call
|
62 |
|
|
# make directly instead).
|
63 |
|
|
#
|
64 |
|
|
# remote_exec build "sh -c \\\"cd ${objdir}/${subdir}\\; make -v -f ${srcdir}/${subdir}/${testfile}.mk clean require_shlibs all SRCDIR=${srcdir}/${subdir} OBJDIR=${objdir}/${subdir}\\\""
|
65 |
|
|
|
66 |
|
|
send_user "Making with '${srcdir}/${subdir}/${testfile}.sh $subdir ...\n"
|
67 |
|
|
remote_exec build "${srcdir}/${subdir}/${testfile}.sh $subdir"
|
68 |
|
|
|
69 |
|
|
# Only HP-UX (and any other platforms using SOM shared libraries, I
|
70 |
|
|
# guess) interprets the auto-solib-add variable as a threshhold,
|
71 |
|
|
# rather than a boolean that strictly enables or disables automatic
|
72 |
|
|
# loading of shlib symbol tables.
|
73 |
|
|
#
|
74 |
|
|
# On HP-UX, it is the size threshhold (in megabytes) at which to
|
75 |
|
|
# stop auto loading of symbol tables.
|
76 |
|
|
#
|
77 |
|
|
if ![istarget "hppa*-hp-hpux*"] then {
|
78 |
|
|
setup_xfail "*-*-*"
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
# Start with a fresh gdb
|
82 |
|
|
#
|
83 |
|
|
gdb_exit
|
84 |
|
|
gdb_start
|
85 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
86 |
|
|
gdb_load ${binfile}
|
87 |
|
|
|
88 |
|
|
# This is a test of gdb's ability on HP-UX to stop automatically
|
89 |
|
|
# loading symbols of shared libraries, when the total size of the
|
90 |
|
|
# debugger's symbol table reaches a specified threshhold.
|
91 |
|
|
#
|
92 |
|
|
|
93 |
|
|
# On HP-UX, the help text for auto-solib-add mentions that it
|
94 |
|
|
# serves as a threshhold.
|
95 |
|
|
#
|
96 |
|
|
send_gdb "help set auto-solib-add\n"
|
97 |
|
|
gdb_expect {
|
98 |
|
|
-re "Set autoloading size threshold .in megabytes. of shared library symbols.*
|
99 |
|
|
If nonzero, symbols from all shared object libraries will be loaded.*
|
100 |
|
|
automatically when the inferior begins execution or when the dynamic linker.*
|
101 |
|
|
informs gdb that a new library has been loaded, until the symbol table.*
|
102 |
|
|
of the program and libraries exceeds this threshold.*
|
103 |
|
|
Otherwise, symbols must be loaded manually, using `sharedlibrary'.*$gdb_prompt $"\
|
104 |
|
|
{pass "help set auto-solib-add"}
|
105 |
|
|
-re "$gdb_prompt $"\
|
106 |
|
|
{fail "help set auto-solib-add"}
|
107 |
|
|
timeout {fail "(timeout) help set auto-solib-add"}
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
# On HP-UX, the threshhold is by default set to 50, which means
|
111 |
|
|
# 50 megabytes.
|
112 |
|
|
#
|
113 |
|
|
send_gdb "show auto-solib-add\n"
|
114 |
|
|
gdb_expect {
|
115 |
|
|
-re "Autoloading size threshold .in megabytes. of shared library symbols is $decimal.*$gdb_prompt $"\
|
116 |
|
|
{pass "show auto-solib-add "}
|
117 |
|
|
-re "Autoloading size threshold \(in megabytes\) of shared library symbols is $decimal.$gdb_prompt $"\
|
118 |
|
|
{pass "show auto-solib-add "}
|
119 |
|
|
-re "$gdb_prompt $"\
|
120 |
|
|
{fail "show auto-solib-add "}
|
121 |
|
|
timeout {fail "(timeout) show auto-solib-add "}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
send_gdb "set auto-solib-add 1\n"
|
125 |
|
|
gdb_expect {
|
126 |
|
|
-re ".*$gdb_prompt $"
|
127 |
|
|
{pass "set auto-solib-add to 1"}
|
128 |
|
|
-re ".*$gdb_prompt $"
|
129 |
|
|
{fail "set auto-solib-add to 1"}
|
130 |
|
|
timeout {fail "(timeout) set auto-solib-add to 1"}
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
# We have manually verified that our testcase exceeds 1 Mbytes
|
135 |
|
|
# of heap space in GDB to hold the symbols for the main program
|
136 |
|
|
# and all associated linked-against libraries. Thus, when we
|
137 |
|
|
# run to the program's main, and therefore notice all the linked-
|
138 |
|
|
# against shlibs, we expect to hit the threshhold.
|
139 |
|
|
#
|
140 |
|
|
# (Note that we're not using the expect [runto main] function here,
|
141 |
|
|
# 'cause we want to match on output from the run command.
|
142 |
|
|
#
|
143 |
|
|
send_gdb "break main\n"
|
144 |
|
|
gdb_expect {
|
145 |
|
|
-re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
|
146 |
|
|
{pass "1 set break at main"}
|
147 |
|
|
-re "$gdb_prompt $"\
|
148 |
|
|
{fail "1 set break at main"}
|
149 |
|
|
timeout {fail "(timeout) 1 set break at main"}
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
send_gdb "run\n"
|
153 |
|
|
gdb_expect {
|
154 |
|
|
-re ".*warning. Symbols for some libraries have not been loaded, because.*
|
155 |
|
|
doing so would exceed the size threshold specified by auto-solib-add.*
|
156 |
|
|
To manually load symbols, use the 'sharedlibrary' command.*
|
157 |
|
|
To raise the threshold, set auto-solib-add to a larger value and rerun.*
|
158 |
|
|
the program.*$gdb_prompt $"\
|
159 |
|
|
{pass "run to main hit auto-solib-add threshold"}
|
160 |
|
|
-re "$gdb_prompt $"\
|
161 |
|
|
{fail "run to main hit auto-solib-add threshold"}
|
162 |
|
|
timeout {fail "(timeout) run to main hit auto-solib-add threshold"}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
# Verify that "info share" mentions something about libraries whose
|
166 |
|
|
# symbols weren't loaded.
|
167 |
|
|
#
|
168 |
|
|
# We'll assume that at least the last two shlib's symbols weren't
|
169 |
|
|
# loaded. As a side-effect of matching this pattern, the text start
|
170 |
|
|
# address of the last one is captured in expect_out(1,string).
|
171 |
|
|
# (we'll need it for the 'add-symbol-file' command in a nonce...)
|
172 |
|
|
#
|
173 |
|
|
send_gdb "info sharedlibrary\n"
|
174 |
|
|
gdb_expect {
|
175 |
|
|
-re ".*lib01_$testfile.sl .*symbols not loaded.*0x\[0-9\]* (0x\[0-9a-fA-F\]*).*$gdb_prompt $"\
|
176 |
|
|
{ send_gdb "add-symbol-file lib02_$testfile.sl $expect_out(1,string)\n"
|
177 |
|
|
gdb_expect {
|
178 |
|
|
-re "add symbol table.*y or n.*$"\
|
179 |
|
|
{send_gdb "y\n"
|
180 |
|
|
gdb_expect {
|
181 |
|
|
-re "$gdb_prompt $" {pass "add-symbol-file and info sharedlib"}
|
182 |
|
|
timeout {fail "(timeout) add-symbol-file and info sharedlib"}
|
183 |
|
|
}}
|
184 |
|
|
-re "$gdb_prompt $"\
|
185 |
|
|
{fail "add-symbol-file and info sharedlib"}
|
186 |
|
|
timeout {fail "(timeout) add-symbol-file and info sharedlib"}
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
-re "$gdb_prompt $" {
|
190 |
|
|
setup_xfail hppa*-*-* CHFts24108
|
191 |
|
|
fail "info sharedlibrary shows shlibs with unloaded symbols"
|
192 |
|
|
}
|
193 |
|
|
timeout {fail "(timeout) info sharedlibrary shows shlibs with unloaded symbols"}
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
# Verify that we can manually load the symbol table of a library
|
197 |
|
|
# whose symbols weren't loaded. (We'll pick the last one.)
|
198 |
|
|
#
|
199 |
|
|
|
200 |
|
|
# I moved this test inside the one above, because the expect_out array is not ok if the
|
201 |
|
|
# previous test has failed, and expect would error out (elz)
|
202 |
|
|
#
|
203 |
|
|
#send_gdb "add-symbol-file lib02_$testfile.sl $expect_out(1,string)\n"
|
204 |
|
|
#gdb_expect {
|
205 |
|
|
# -re "add symbol table.*y or n.*$"\
|
206 |
|
|
# {send_gdb "y\n"
|
207 |
|
|
# gdb_expect {
|
208 |
|
|
# -re "$gdb_prompt $" {pass "add-symbol-file"}
|
209 |
|
|
# timeout {fail "(timeout) add-symbol-file"}
|
210 |
|
|
# }}
|
211 |
|
|
# -re "$gdb_prompt $"\
|
212 |
|
|
# {fail "add-symbol-file"}
|
213 |
|
|
# timeout {fail "(timeout) add-symbol-file"}
|
214 |
|
|
#}
|
215 |
|
|
|
216 |
|
|
# Verify that we can manually load the symbols for all libraries
|
217 |
|
|
# which weren't already loaded.
|
218 |
|
|
#
|
219 |
|
|
# Warning! On a machine with little free swap space, this may
|
220 |
|
|
# fail!
|
221 |
|
|
#
|
222 |
|
|
send_gdb "sharedlibrary\n"
|
223 |
|
|
gdb_expect {
|
224 |
|
|
-re "Reading symbols from.*done.*$gdb_prompt $"\
|
225 |
|
|
{pass "sharedlibrary"}
|
226 |
|
|
-re "$gdb_prompt $" {
|
227 |
|
|
setup_xfail hppa*-*-* CHFts24108
|
228 |
|
|
fail "sharedlibrary"
|
229 |
|
|
}
|
230 |
|
|
timeout {fail "(timeout) sharedlibrary"}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
# Rerun the program, this time verifying that we can set the
|
234 |
|
|
# threshhold high enough to avoid hitting it.
|
235 |
|
|
#
|
236 |
|
|
# It appears that gdb isn't freeing memory when rerunning, as one
|
237 |
|
|
# would expect. To avoid potentially hitting a virtual memory
|
238 |
|
|
# ceiling, start with a fresh gdb.
|
239 |
|
|
#
|
240 |
|
|
gdb_exit
|
241 |
|
|
gdb_start
|
242 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
243 |
|
|
gdb_load ${binfile}
|
244 |
|
|
|
245 |
|
|
send_gdb "break main\n"
|
246 |
|
|
gdb_expect {
|
247 |
|
|
-re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
|
248 |
|
|
{pass "2 set break at main"}
|
249 |
|
|
-re "$gdb_prompt $"\
|
250 |
|
|
{fail "2 set break at main"}
|
251 |
|
|
timeout {fail "(timeout) 2 set break at main"}
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
send_gdb "set auto-solib-add 9999\n"
|
255 |
|
|
gdb_expect {
|
256 |
|
|
-re "$gdb_prompt $"\
|
257 |
|
|
{pass "set auto-solib-add threshold to practical infinity"}
|
258 |
|
|
timeout {fail "(timeout) set auto-solib-add threshold to practical infinity"}
|
259 |
|
|
}
|
260 |
|
|
send_gdb "run\n"
|
261 |
|
|
gdb_expect {
|
262 |
|
|
-re ".*warning. Symbols for some libraries have not been loaded, because.*
|
263 |
|
|
doing so would exceed the size threshold specified by auto-solib-add.*
|
264 |
|
|
To manually load symbols, use the 'sharedlibrary' command.*
|
265 |
|
|
To raise the threshold, set auto-solib-add to a larger value and rerun.*
|
266 |
|
|
the program.*$gdb_prompt $"\
|
267 |
|
|
{fail "rerun threshold at practical infinity (still hit threshold)"}
|
268 |
|
|
-re "$gdb_prompt $"\
|
269 |
|
|
{pass "rerun with threshold at practical infinity"}
|
270 |
|
|
timeout {fail "(timeout) rerun with threshold at practical infinity"}
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
# Rerun the program, this time altogether disabling the auto loading
|
274 |
|
|
# feature. There should be no information at all about shared
|
275 |
|
|
# libraries now.
|
276 |
|
|
#
|
277 |
|
|
# ??rehrauer: Personally, I'd call that a bug, since it doesn't give
|
278 |
|
|
# you the ability to manually load single shlibs (you need the text
|
279 |
|
|
# start address that 'info share' normall gives you). On the other
|
280 |
|
|
# hand, one can easily choose to load them all...
|
281 |
|
|
#
|
282 |
|
|
# It appears that gdb isn't freeing memory when rerunning, as one
|
283 |
|
|
# would expect. To avoid potentially hitting a virtual memory
|
284 |
|
|
# ceiling, start with a fresh gdb.
|
285 |
|
|
#
|
286 |
|
|
gdb_exit
|
287 |
|
|
gdb_start
|
288 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
289 |
|
|
gdb_load ${binfile}
|
290 |
|
|
|
291 |
|
|
send_gdb "break main\n"
|
292 |
|
|
gdb_expect {
|
293 |
|
|
-re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
|
294 |
|
|
{pass "3 set break at main"}
|
295 |
|
|
-re "$gdb_prompt $"\
|
296 |
|
|
{fail "3 set break at main"}
|
297 |
|
|
timeout {fail "(timeout) 3 set break at main"}
|
298 |
|
|
}
|
299 |
|
|
|
300 |
|
|
send_gdb "set auto-solib-add 0\n"
|
301 |
|
|
gdb_expect {
|
302 |
|
|
-re "$gdb_prompt $"\
|
303 |
|
|
{pass "set auto-solib-add threshold to 0"}
|
304 |
|
|
timeout {fail "(timeout) set auto-solib-add threshold to 0"}
|
305 |
|
|
}
|
306 |
|
|
send_gdb "run\n"
|
307 |
|
|
gdb_expect {
|
308 |
|
|
-re ".*warning. Symbols for some libraries have not been loaded, because.*
|
309 |
|
|
doing so would exceed the size threshold specified by auto-solib-add.*
|
310 |
|
|
To manually load symbols, use the 'sharedlibrary' command.*
|
311 |
|
|
To raise the threshold, set auto-solib-add to a larger value and rerun.*
|
312 |
|
|
the program.*$gdb_prompt $"\
|
313 |
|
|
{fail "rerun threshold at 0 (still hit threshold)"}
|
314 |
|
|
-re "$gdb_prompt $"\
|
315 |
|
|
{pass "rerun with threshold at 0"}
|
316 |
|
|
timeout {fail "(timeout) rerun with threshold at 0"}
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
# Verify that we can still manually load symbols for all libraries.
|
320 |
|
|
# (We'll assume that if the last shlib's symbols are loaded, that
|
321 |
|
|
# all of them were.)
|
322 |
|
|
#
|
323 |
|
|
# Note that we set the GDB "height" variable to prevent GDB from
|
324 |
|
|
# prompting
|
325 |
|
|
#
|
326 |
|
|
# Warning! On a machine with little free swap space, this may
|
327 |
|
|
# fail!
|
328 |
|
|
#
|
329 |
|
|
send_gdb "set height 9999\n"
|
330 |
|
|
gdb_expect {
|
331 |
|
|
-re "$gdb_prompt $"\
|
332 |
|
|
{pass "set screen page height to practical infinity"}
|
333 |
|
|
timeout {fail "(timeout) set screen page height to practical infinity"}
|
334 |
|
|
}
|
335 |
|
|
send_gdb "sharedlibrary\n"
|
336 |
|
|
gdb_expect {
|
337 |
|
|
-re ".*Reading symbols from .*/lib02-so-thresh\\.sl\\.\\.\\.done\\..*$gdb_prompt $"\
|
338 |
|
|
{pass "manually load all symbols"}
|
339 |
|
|
-re "$gdb_prompt $" {
|
340 |
|
|
setup_xfail hppa*-*-* CHFts24108
|
341 |
|
|
fail "manually load all symbols (CHFts24108)"
|
342 |
|
|
}
|
343 |
|
|
timeout {fail "(timeout) manually load all symbols"}
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
return 0
|