Fix for PR gdb/1543.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.base-hp / so-thresh.exp
1 # Copyright (C) 1997, 1998, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>. */
15
16 if $tracelevel then {
17 strace $tracelevel
18 }
19
20 set prms_id 0
21 set bug_id 0
22
23 if { [skip_hp_tests] } then { continue }
24
25 set testfile "so-thresh"
26 set binfile ${objdir}/${subdir}/${testfile}
27
28 if [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 #
36 set 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
62 remote_exec build "${srcdir}/${subdir}/${testfile}.sh $subdir"
63
64 # Only HP-UX (and any other platforms using SOM shared libraries, I
65 # guess) interprets the auto-solib-limit variable as a threshhold,
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 #
72 if ![istarget "hppa*-hp-hpux*"] then {
73 setup_xfail "*-*-*"
74 }
75
76 # Start with a fresh gdb
77 #
78 gdb_exit
79 gdb_start
80 gdb_reinitialize_dir $srcdir/$subdir
81 gdb_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
88 # On HP-UX, the help text for auto-solib-limit mentions that it
89 # serves as a threshhold.
90 #
91 send_gdb "help set auto-solib-limit\n"
92 gdb_expect {
93 -re "Set threshold .in Mb. for autoloading shared library symbols.*
94 When shared library autoloading is enabled, new libraries will be loaded.*
95 only until the total size of shared library symbols exceeds this.*
96 threshold in megabytes. Is ignored when using .sharedlibrary.*$gdb_prompt $"\
97 {pass "help set auto-solib-limit"}
98 -re "$gdb_prompt $"\
99 {fail "help set auto-solib-limit"}
100 timeout {fail "(timeout) help set auto-solib-limit"}
101 }
102
103 # On HP-UX, the threshhold is by default set to 50, which means
104 # 50 megabytes.
105 #
106 send_gdb "show auto-solib-limit\n"
107 gdb_expect {
108 -re "Threshold .in Mb. for autoloading shared library symbols is $decimal.*$gdb_prompt $"\
109 {pass "show auto-solib-limit "}
110 -re "$gdb_prompt $"\
111 {fail "show auto-solib-limit "}
112 timeout {fail "(timeout) show auto-solib-limit "}
113 }
114
115 send_gdb "set auto-solib-limit 1\n"
116 gdb_expect {
117 -re ".*$gdb_prompt $"
118 {pass "set auto-solib-limit to 1"}
119 -re ".*$gdb_prompt $"
120 {fail "set auto-solib-limit to 1"}
121 timeout {fail "(timeout) set auto-solib-limit to 1"}
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 #
134 send_gdb "break main\n"
135 gdb_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
143 send_gdb "run\n"
144 gdb_expect {
145 -re ".*warning. Symbols for some libraries have not been loaded, because.*
146 doing so would exceed the size threshold specified by auto-solib-limit.*
147 To manually load symbols, use the 'sharedlibrary' command.*
148 To raise the threshold, set auto-solib-limit to a larger value and rerun.*
149 the program.*$gdb_prompt $"\
150 {pass "run to main hit auto-solib-limit threshold"}
151 -re "$gdb_prompt $"\
152 {fail "run to main hit auto-solib-limit threshold"}
153 timeout {fail "(timeout) run to main hit auto-solib-limit threshold"}
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 #
164 send_gdb "info sharedlibrary\n"
165 gdb_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 #
213 send_gdb "sharedlibrary\n"
214 gdb_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 #
231 gdb_exit
232 gdb_start
233 gdb_reinitialize_dir $srcdir/$subdir
234 gdb_load ${binfile}
235
236 send_gdb "break main\n"
237 gdb_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
245 send_gdb "set auto-solib-limit 9999\n"
246 gdb_expect {
247 -re "$gdb_prompt $"\
248 {pass "set auto-solib-limit threshold to practical infinity"}
249 timeout {fail "(timeout) set auto-solib-limit threshold to practical infinity"}
250 }
251 send_gdb "run\n"
252 gdb_expect {
253 -re ".*warning. Symbols for some libraries have not been loaded, because.*
254 doing so would exceed the size threshold specified by auto-solib-limit.*
255 To manually load symbols, use the 'sharedlibrary' command.*
256 To raise the threshold, set auto-solib-limit to a larger value and rerun.*
257 the 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 #
277 gdb_exit
278 gdb_start
279 gdb_reinitialize_dir $srcdir/$subdir
280 gdb_load ${binfile}
281
282 send_gdb "break main\n"
283 gdb_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
291 send_gdb "set auto-solib-limit 0\n"
292 gdb_expect {
293 -re "$gdb_prompt $"\
294 {pass "set auto-solib-limit threshold to 0"}
295 timeout {fail "(timeout) set auto-solib-limit threshold to 0"}
296 }
297 send_gdb "run\n"
298 gdb_expect {
299 -re ".*warning. Symbols for some libraries have not been loaded, because.*
300 doing so would exceed the size threshold specified by auto-solib-limit.*
301 To manually load symbols, use the 'sharedlibrary' command.*
302 To raise the threshold, set auto-solib-limit to a larger value and rerun.*
303 the 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 #
320 send_gdb "set height 9999\n"
321 gdb_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 }
326 send_gdb "sharedlibrary\n"
327 gdb_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
337 return 0
This page took 0.037566 seconds and 4 git commands to generate.