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