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