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