1 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
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.
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.
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. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
27 if { [skip_hp_tests] } then { continue }
29 set testfile "so-thresh"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
33 if [get_compiler_info ${binfile}] {
37 # This testcase is automatically generated, via the
38 # gen-so-thresh program, which also should
39 # live in this same directory.
41 # The generator produces:
43 # - 3 .c files named libXX-so-thresh.c
44 # - a makefile named so-thresh.mk with a
45 # target named "so-thresh" that will compile
46 # and link the testcase
48 # Making with so-thresh.mk produces:
50 # - 3 shared libraries that are linked against, named
53 # We build gen-so-thresh, run it, and then make with
54 # the makefile it produces.
56 set genfile gen_${testfile}
57 set gen_srcfile ${genfile}.c
58 set gen_binfile ${genfile}
59 set gen_makefile ${testfile}.mk
61 # This testcase is relatively large, and therefore can take awhile to
62 # load. We'd best set the timeout to something suitable, or we may
67 # It's easiest to build and run the testcase in this directory. (Linking
68 # against shlibs puts relative paths to them in the a.out, so it's best
69 # if we remain in this directory for the entire test run.)
73 # Ensure that the testcase is built. This may cause the generator to
76 # Warning! The final link of this testcase is not for the
77 # faint-hearted nor under-disked machine!
79 # ??rehrauer: I tried for a very long time to get make invoked
80 # directly here, rather than invoking a script to do it. I
81 # finally gave up in frustration; I'm not sure why it wouldn't
82 # work that way, but this method DOES work, albeit clumsily.
85 send_user "Making with ${testfile}.mk ...\n"
86 # 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}\\\""
87 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}\\\""
89 # Only HP-UX (and any other platforms using SOM shared libraries, I
90 # guess) interprets the auto-solib-add variable as a threshhold,
91 # rather than a boolean that strictly enables or disables automatic
92 # loading of shlib symbol tables.
94 # On HP-UX, it is the size threshhold (in megabytes) at which to
95 # stop auto loading of symbol tables.
97 if ![istarget "hppa*-hp-hpux*"] then {
101 # Start with a fresh gdb
105 gdb_reinitialize_dir $srcdir/$subdir
108 # This is a test of gdb's ability on HP-UX to stop automatically
109 # loading symbols of shared libraries, when the total size of the
110 # debugger's symbol table reaches a specified threshhold.
113 # On HP-UX, the help text for auto-solib-add mentions that it
114 # serves as a threshhold.
116 send_gdb "help set auto-solib-add\n"
118 -re "Set autoloading size threshold .in megabytes. of shared library symbols.*
119 If nonzero, symbols from all shared object libraries will be loaded.*
120 automatically when the inferior begins execution or when the dynamic linker.*
121 informs gdb that a new library has been loaded, until the symbol table.*
122 of the program and libraries exceeds this threshold.*
123 Otherwise, symbols must be loaded manually, using `sharedlibrary'.*$gdb_prompt $"\
124 {pass "help set auto-solib-add"}
126 {fail "help set auto-solib-add"}
127 timeout {fail "(timeout) help set auto-solib-add"}
130 # On HP-UX, the threshhold is by default set to 50, which means
133 send_gdb "show auto-solib-add\n"
135 -re "Autoloading size threshold .in megabytes. of shared library symbols is 100.*$gdb_prompt $"\
136 {pass "show auto-solib-add (default is 100)"}
138 {fail "show auto-solib-add (default is 100)"}
139 timeout {fail "(timeout) show auto-solib-add (default is 100)"}
142 send_gdb "set auto-solib-add 1\n"
144 -re ".*$gdb_prompt $"
145 {pass "set auto-solib-add to 1"}
146 -re ".*$gdb_prompt $"
147 {fail "set auto-solib-add to 1"}
148 timeout {fail "(timeout) set auto-solib-add to 1"}
152 # We have manually verified that our testcase exceeds 1 Mbytes
153 # of heap space in GDB to hold the symbols for the main program
154 # and all associated linked-against libraries. Thus, when we
155 # run to the program's main, and therefore notice all the linked-
156 # against shlibs, we expect to hit the threshhold.
158 # (Note that we're not using the expect [runto main] function here,
159 # 'cause we want to match on output from the run command.
161 send_gdb "break main\n"
163 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
164 {pass "set break at main"}
166 {fail "set break at main"}
167 timeout {fail "(timeout) set break at main"}
172 -re ".*warning. Symbols for some libraries have not been loaded, because.*
173 doing so would exceed the size threshold specified by auto-solib-add.*
174 To manually load symbols, use the 'sharedlibrary' command.*
175 To raise the threshold, set auto-solib-add to a larger value and rerun.*
176 the program.*$gdb_prompt $"\
177 {pass "run to main hit auto-solib-add threshold"}
179 {fail "run to main hit auto-solib-add threshold"}
180 timeout {fail "(timeout) run to main hit auto-solib-add threshold"}
183 # Verify that "info share" mentions something about libraries whose
184 # symbols weren't loaded.
186 # We'll assume that at least the last two shlib's symbols weren't
187 # loaded. As a side-effect of matching this pattern, the text start
188 # address of the last one is captured in expect_out(1,string).
189 # (we'll need it for the 'add-symbol-file' command in a nonce...)
191 send_gdb "info sharedlibrary\n"
193 -re ".*lib01_$testfile.sl .*symbols not loaded.*0x\[0-9\]* (0x\[0-9a-fA-F\]*).*$gdb_prompt $"\
194 { send_gdb "add-symbol-file lib02_$testfile.sl $expect_out(1,string)\n"
196 -re "add symbol table.*y or n.*$"\
199 -re "$gdb_prompt $" {pass "add-symbol-file and info sharedlib"}
200 timeout {fail "(timeout) add-symbol-file and info sharedlib"}
203 {fail "add-symbol-file and info sharedlib"}
204 timeout {fail "(timeout) add-symbol-file and info sharedlib"}
208 {fail "info sharedlibrary shows shlibs with unloaded symbols"}
209 timeout {fail "(timeout) info sharedlibrary shows shlibs with unloaded symbols"}
212 # Verify that we can manually load the symbol table of a library
213 # whose symbols weren't loaded. (We'll pick the last one.)
216 # I moved this test inside the one above, because the expect_out array is not ok if the
217 # previous test has failed, and expect would error out (elz)
219 #send_gdb "add-symbol-file lib02_$testfile.sl $expect_out(1,string)\n"
221 # -re "add symbol table.*y or n.*$"\
224 # -re "$gdb_prompt $" {pass "add-symbol-file"}
225 # timeout {fail "(timeout) add-symbol-file"}
227 # -re "$gdb_prompt $"\
228 # {fail "add-symbol-file"}
229 # timeout {fail "(timeout) add-symbol-file"}
232 # Verify that we can manually load the symbols for all libraries
233 # which weren't already loaded.
235 # Warning! On a machine with little free swap space, this may
238 send_gdb "sharedlibrary\n"
240 -re "Reading symbols from.*done.*$gdb_prompt $"\
241 {pass "sharedlibrary"}
243 {fail "sharedlibrary"}
244 timeout {fail "(timeout) sharedlibrary"}
247 # Rerun the program, this time verifying that we can set the
248 # threshhold high enough to avoid hitting it.
250 # It appears that gdb isn't freeing memory when rerunning, as one
251 # would expect. To avoid potentially hitting a virtual memory
252 # ceiling, start with a fresh gdb.
256 gdb_reinitialize_dir $srcdir/$subdir
259 send_gdb "break main\n"
261 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
262 {pass "set break at main"}
264 {fail "set break at main"}
265 timeout {fail "(timeout) set break at main"}
268 send_gdb "set auto-solib-add 9999\n"
271 {pass "set auto-solib-add threshold to practical infinity"}
272 timeout {fail "(timeout) set auto-solib-add threshold to practical infinity"}
276 -re ".*warning. Symbols for some libraries have not been loaded, because.*
277 doing so would exceed the size threshold specified by auto-solib-add.*
278 To manually load symbols, use the 'sharedlibrary' command.*
279 To raise the threshold, set auto-solib-add to a larger value and rerun.*
280 the program.*$gdb_prompt $"\
281 {fail "rerun threshold at practical infinity (still hit threshold)"}
283 {pass "rerun with threshold at practical infinity"}
284 timeout {fail "(timeout) rerun with threshold at practical infinity"}
287 # Rerun the program, this time altogether disabling the auto loading
288 # feature. There should be no information at all about shared
291 # ??rehrauer: Personally, I'd call that a bug, since it doesn't give
292 # you the ability to manually load single shlibs (you need the text
293 # start address that 'info share' normall gives you). On the other
294 # hand, one can easily choose to load them all...
296 # It appears that gdb isn't freeing memory when rerunning, as one
297 # would expect. To avoid potentially hitting a virtual memory
298 # ceiling, start with a fresh gdb.
302 gdb_reinitialize_dir $srcdir/$subdir
305 send_gdb "break main\n"
307 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
308 {pass "set break at main"}
310 {fail "set break at main"}
311 timeout {fail "(timeout) set break at main"}
314 send_gdb "set auto-solib-add 0\n"
317 {pass "set auto-solib-add threshold to 0"}
318 timeout {fail "(timeout) set auto-solib-add threshold to 0"}
322 -re ".*warning. Symbols for some libraries have not been loaded, because.*
323 doing so would exceed the size threshold specified by auto-solib-add.*
324 To manually load symbols, use the 'sharedlibrary' command.*
325 To raise the threshold, set auto-solib-add to a larger value and rerun.*
326 the program.*$gdb_prompt $"\
327 {fail "rerun threshold at 0 (still hit threshold)"}
329 {pass "rerun with threshold at 0"}
330 timeout {fail "(timeout) rerun with threshold at 0"}
333 # Verify that we can still manually load symbols for all libraries.
334 # (We'll assume that if the last shlib's symbols are loaded, that
337 # Note that we set the GDB "height" variable to prevent GDB from
340 # Warning! On a machine with little free swap space, this may
343 send_gdb "set height 9999\n"
346 {pass "set screen page height to practical infinity"}
347 timeout {fail "(timeout) set screen page height to practical infinity"}
349 send_gdb "sharedlibrary\n"
351 -re ".*Reading symbols from .*/lib02-so-thresh\\.sl\\.\\.\\.done\\..*$gdb_prompt $"\
352 {pass "manually load all symbols"}
354 {fail "manually load all symbols"}
355 timeout {fail "(timeout) manually load all symbols"}