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