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