17804164244e38ea2408f655693bc8b2a44dc1a3
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / so-thresh.exp
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
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 srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32
33 if [get_compiler_info ${binfile}] {
34 return -1
35 }
36
37 # This testcase is automatically generated, via the
38 # gen-so-thresh program, which also should
39 # live in this same directory.
40 #
41 # The generator produces:
42 # - so-thresh.c
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
47 #
48 # Making with so-thresh.mk produces:
49 # - so-thresh
50 # - 3 shared libraries that are linked against, named
51 # libXX-so-thresh.sl
52 #
53 # We build gen-so-thresh, run it, and then make with
54 # the makefile it produces.
55 #
56 set genfile gen_${testfile}
57 set gen_srcfile ${genfile}.c
58 set gen_binfile ${genfile}
59 set gen_makefile ${testfile}.mk
60
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
63 # seem to fail...
64 #
65 set timeout 60
66
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.)
70 #
71 #cd gdb.base
72
73 # Ensure that the testcase is built. This may cause the generator to
74 # be built & run.
75 #
76 # Warning! The final link of this testcase is not for the
77 # faint-hearted nor under-disked machine!
78 #
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.
83 #
84
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}\\\""
88
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.
93 #
94 # On HP-UX, it is the size threshhold (in megabytes) at which to
95 # stop auto loading of symbol tables.
96 #
97 if ![istarget "hppa*-hp-hpux*"] then {
98 setup_xfail "*-*-*"
99 }
100
101 # Start with a fresh gdb
102 #
103 gdb_exit
104 gdb_start
105 gdb_reinitialize_dir $srcdir/$subdir
106 gdb_load ${binfile}
107
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.
111 #
112
113 # On HP-UX, the help text for auto-solib-add mentions that it
114 # serves as a threshhold.
115 #
116 send_gdb "help set auto-solib-add\n"
117 gdb_expect {
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"}
125 -re "$gdb_prompt $"\
126 {fail "help set auto-solib-add"}
127 timeout {fail "(timeout) help set auto-solib-add"}
128 }
129
130 # On HP-UX, the threshhold is by default set to 50, which means
131 # 50 megabytes.
132 #
133 send_gdb "show auto-solib-add\n"
134 gdb_expect {
135 -re "Autoloading size threshold .in megabytes. of shared library symbols is 100.*$gdb_prompt $"\
136 {pass "show auto-solib-add (default is 100)"}
137 -re "$gdb_prompt $"\
138 {fail "show auto-solib-add (default is 100)"}
139 timeout {fail "(timeout) show auto-solib-add (default is 100)"}
140 }
141
142 send_gdb "set auto-solib-add 1\n"
143 gdb_expect {
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"}
149 }
150
151
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.
157 #
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.
160 #
161 send_gdb "break main\n"
162 gdb_expect {
163 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
164 {pass "set break at main"}
165 -re "$gdb_prompt $"\
166 {fail "set break at main"}
167 timeout {fail "(timeout) set break at main"}
168 }
169
170 send_gdb "run\n"
171 gdb_expect {
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"}
178 -re "$gdb_prompt $"\
179 {fail "run to main hit auto-solib-add threshold"}
180 timeout {fail "(timeout) run to main hit auto-solib-add threshold"}
181 }
182
183 # Verify that "info share" mentions something about libraries whose
184 # symbols weren't loaded.
185 #
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...)
190 #
191 send_gdb "info sharedlibrary\n"
192 gdb_expect {
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"
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 and info sharedlib"}
200 timeout {fail "(timeout) add-symbol-file and info sharedlib"}
201 }}
202 -re "$gdb_prompt $"\
203 {fail "add-symbol-file and info sharedlib"}
204 timeout {fail "(timeout) add-symbol-file and info sharedlib"}
205 }
206 }
207 -re "$gdb_prompt $"\
208 {fail "info sharedlibrary shows shlibs with unloaded symbols"}
209 timeout {fail "(timeout) info sharedlibrary shows shlibs with unloaded symbols"}
210 }
211
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.)
214 #
215
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)
218 #
219 #send_gdb "add-symbol-file lib02_$testfile.sl $expect_out(1,string)\n"
220 #gdb_expect {
221 # -re "add symbol table.*y or n.*$"\
222 # {send_gdb "y\n"
223 # gdb_expect {
224 # -re "$gdb_prompt $" {pass "add-symbol-file"}
225 # timeout {fail "(timeout) add-symbol-file"}
226 # }}
227 # -re "$gdb_prompt $"\
228 # {fail "add-symbol-file"}
229 # timeout {fail "(timeout) add-symbol-file"}
230 #}
231
232 # Verify that we can manually load the symbols for all libraries
233 # which weren't already loaded.
234 #
235 # Warning! On a machine with little free swap space, this may
236 # fail!
237 #
238 send_gdb "sharedlibrary\n"
239 gdb_expect {
240 -re "Reading symbols from.*done.*$gdb_prompt $"\
241 {pass "sharedlibrary"}
242 -re "$gdb_prompt $"\
243 {fail "sharedlibrary"}
244 timeout {fail "(timeout) sharedlibrary"}
245 }
246
247 # Rerun the program, this time verifying that we can set the
248 # threshhold high enough to avoid hitting it.
249 #
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.
253 #
254 gdb_exit
255 gdb_start
256 gdb_reinitialize_dir $srcdir/$subdir
257 gdb_load ${binfile}
258
259 send_gdb "break main\n"
260 gdb_expect {
261 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
262 {pass "set break at main"}
263 -re "$gdb_prompt $"\
264 {fail "set break at main"}
265 timeout {fail "(timeout) set break at main"}
266 }
267
268 send_gdb "set auto-solib-add 9999\n"
269 gdb_expect {
270 -re "$gdb_prompt $"\
271 {pass "set auto-solib-add threshold to practical infinity"}
272 timeout {fail "(timeout) set auto-solib-add threshold to practical infinity"}
273 }
274 send_gdb "run\n"
275 gdb_expect {
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)"}
282 -re "$gdb_prompt $"\
283 {pass "rerun with threshold at practical infinity"}
284 timeout {fail "(timeout) rerun with threshold at practical infinity"}
285 }
286
287 # Rerun the program, this time altogether disabling the auto loading
288 # feature. There should be no information at all about shared
289 # libraries now.
290 #
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...
295 #
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.
299 #
300 gdb_exit
301 gdb_start
302 gdb_reinitialize_dir $srcdir/$subdir
303 gdb_load ${binfile}
304
305 send_gdb "break main\n"
306 gdb_expect {
307 -re "Breakpoint \[0-9\]* at.*$gdb_prompt $"\
308 {pass "set break at main"}
309 -re "$gdb_prompt $"\
310 {fail "set break at main"}
311 timeout {fail "(timeout) set break at main"}
312 }
313
314 send_gdb "set auto-solib-add 0\n"
315 gdb_expect {
316 -re "$gdb_prompt $"\
317 {pass "set auto-solib-add threshold to 0"}
318 timeout {fail "(timeout) set auto-solib-add threshold to 0"}
319 }
320 send_gdb "run\n"
321 gdb_expect {
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)"}
328 -re "$gdb_prompt $"\
329 {pass "rerun with threshold at 0"}
330 timeout {fail "(timeout) rerun with threshold at 0"}
331 }
332
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
335 # all of them were.)
336 #
337 # Note that we set the GDB "height" variable to prevent GDB from
338 # prompting
339 #
340 # Warning! On a machine with little free swap space, this may
341 # fail!
342 #
343 send_gdb "set height 9999\n"
344 gdb_expect {
345 -re "$gdb_prompt $"\
346 {pass "set screen page height to practical infinity"}
347 timeout {fail "(timeout) set screen page height to practical infinity"}
348 }
349 send_gdb "sharedlibrary\n"
350 gdb_expect {
351 -re ".*Reading symbols from .*/lib02-so-thresh\\.sl\\.\\.\\.done\\..*$gdb_prompt $"\
352 {pass "manually load all symbols"}
353 -re "$gdb_prompt $"\
354 {fail "manually load all symbols"}
355 timeout {fail "(timeout) manually load all symbols"}
356 }
357
358 #cd ..
359 return 0
This page took 0.042736 seconds and 3 git commands to generate.