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