]>
Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1997, 1998, 1999 Free Software Foundation, Inc. |
c906108c SS |
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 | # [email protected] | |
19 | ||
20 | # Test that GDB properly ignores invalid stabs. | |
21 | # Also test that GDB can debug a .o file, and that it doesn't mind | |
22 | # a file that's more minimal than what a compiler normally puts out. | |
23 | if $tracelevel then { | |
24 | strace $tracelevel | |
25 | } | |
26 | ||
27 | # If the test directory was not created by configure then skip | |
28 | # this test. | |
29 | if ![file isdirectory ${objdir}/${subdir}] then { | |
30 | return 0 | |
31 | } | |
32 | ||
33 | set prms_id 0 | |
34 | set bug_id 0 | |
35 | ||
36 | proc do_tests {} { | |
37 | global binfile | |
38 | global gdb_prompt | |
39 | ||
40 | # Mips/alpha targets that use gcc with mips-tfile put out the stabs | |
41 | # assembler directives embedded in comments. If the assembler | |
42 | # file is then processed with native cc, all stabs directives | |
43 | # will be lost. | |
44 | # Skip the rest of the stabs tests for this case. | |
45 | send_gdb "ptype inttype\n" | |
46 | gdb_expect { | |
47 | -re "^ptype inttype\r*\ntype = inttype.*$gdb_prompt $" { | |
48 | pass "stabs found" | |
49 | } | |
50 | -re ".*$gdb_prompt $" { | |
51 | setup_xfail "mips-*-*" | |
52 | setup_xfail "alpha-*-*" | |
53 | fail "stabs not found" | |
54 | return | |
55 | } | |
56 | default { fail "checking for stabs" } | |
57 | } | |
58 | ||
59 | print_weird_var var0 | |
60 | print_weird_var var1 | |
61 | print_weird_var var2 | |
62 | print_weird_var var3 | |
63 | ||
64 | print_weird_var attr32 | |
65 | print_weird_var attr33 | |
66 | print_weird_var attr35 | |
67 | print_weird_var attr36 | |
68 | print_weird_var attr37 | |
69 | print_weird_var attr38 | |
70 | print_weird_var attr39 | |
71 | print_weird_var attr41 | |
72 | print_weird_var attr42 | |
73 | print_weird_var attr43 | |
74 | print_weird_var attr44 | |
75 | print_weird_var attr46 | |
76 | print_weird_var attr47 | |
77 | print_weird_var attr58 | |
78 | print_weird_var attr59 | |
79 | print_weird_var attr60 | |
80 | print_weird_var attr61 | |
81 | print_weird_var attr62 | |
82 | print_weird_var attr63 | |
83 | print_weird_var attr64 | |
84 | print_weird_var attr65 | |
85 | print_weird_var attr66 | |
86 | print_weird_var attr67 | |
87 | print_weird_var attr68 | |
88 | print_weird_var attr69 | |
89 | print_weird_var attr70 | |
90 | print_weird_var attr71 | |
91 | print_weird_var attr72 | |
92 | print_weird_var attr73 | |
93 | print_weird_var attr74 | |
94 | print_weird_var attr75 | |
95 | print_weird_var attr76 | |
96 | print_weird_var attr77 | |
97 | print_weird_var attr78 | |
98 | print_weird_var attr79 | |
99 | print_weird_var attr80 | |
100 | print_weird_var attr81 | |
101 | print_weird_var attr82 | |
102 | print_weird_var attr83 | |
103 | print_weird_var attr84 | |
104 | print_weird_var attr85 | |
105 | print_weird_var attr86 | |
106 | print_weird_var attr87 | |
107 | print_weird_var attr88 | |
108 | print_weird_var attr89 | |
109 | print_weird_var attr90 | |
110 | print_weird_var attr91 | |
111 | print_weird_var attr92 | |
112 | print_weird_var attr93 | |
113 | print_weird_var attr94 | |
114 | print_weird_var attr95 | |
115 | print_weird_var attr96 | |
116 | print_weird_var attr97 | |
117 | print_weird_var attr98 | |
118 | print_weird_var attr99 | |
119 | print_weird_var attr100 | |
120 | print_weird_var attr101 | |
121 | print_weird_var attr102 | |
122 | print_weird_var attr103 | |
123 | print_weird_var attr104 | |
124 | print_weird_var attr105 | |
125 | print_weird_var attr106 | |
126 | print_weird_var attr107 | |
127 | print_weird_var attr108 | |
128 | print_weird_var attr109 | |
129 | print_weird_var attr110 | |
130 | print_weird_var attr111 | |
131 | print_weird_var attr112 | |
132 | print_weird_var attr113 | |
133 | print_weird_var attr114 | |
134 | print_weird_var attr115 | |
135 | print_weird_var attr116 | |
136 | print_weird_var attr117 | |
137 | print_weird_var attr118 | |
138 | print_weird_var attr119 | |
139 | print_weird_var attr120 | |
140 | print_weird_var attr121 | |
141 | print_weird_var attr122 | |
142 | print_weird_var attr123 | |
143 | print_weird_var attr124 | |
144 | print_weird_var attr125 | |
145 | print_weird_var attr126 | |
146 | ||
147 | gdb_test "p const69" " = 69" "'e' constant on non-enum type" | |
148 | gdb_test "whatis const69" "type = (unsigned int|inttype)" "whatis const69" | |
149 | ||
150 | gdb_test "p sizeof (const70)" " = 2" "'e' constant with embedded type" | |
151 | ||
152 | gdb_test "p bad_neg0" " = \{field0 = 42, field2 =.*field3 = 45\}" "p bad_neg0" | |
153 | ||
154 | gdb_test "ptype inttype" "type = (unsigned int|inttype)" "ptype on inttype" | |
155 | gdb_test "p sizeof (float72type)" " = 9" "unrecognized floating point type" | |
156 | ||
157 | # This big number needs to be kept as one piece | |
158 | gdb_test "p/x int256var" " = 0x0*2a0000002b0000002c0000002d0000002d0000002c0000002b0000002a" "print very big integer" | |
159 | ||
160 | gdb_test "whatis consth" "type = inttype" "whatis consth" | |
161 | gdb_test "whatis consth2" "type = inttype" "whatis consth2" | |
162 | ||
163 | # GDB does not yet understand S constants | |
164 | setup_xfail "*-*-*" | |
165 | gdb_test "p/x bad_neg0const" " = \{field0 = 0x11222211, field2 =.*\ | |
166 | field3 = 0x77888877\}" "print struct constant" | |
167 | ||
168 | gdb_test "ptype bad_type0" "type = .*" "print bad_type0" | |
169 | gdb_test "ptype bad_type1" "type = .*" "print bad_type1" | |
170 | ||
171 | # GDB does not yet support arrays indexed by anything at all unusual | |
172 | setup_xfail "*-*-*" | |
cb135b83 | 173 | gdb_test "p array0" " = \\{42, 43, 44, 45, 46, 47\\}" "array0 with strange index" |
c906108c | 174 | setup_xfail "*-*-*" |
cb135b83 | 175 | gdb_test "p array1" " = \\{42, 43, 44\\}" "array1 with strange index" |
c906108c SS |
176 | |
177 | # GDB does not yet support this feature | |
178 | gdb_test "whatis one_var" "type = inttype_one" \ | |
179 | "whatis one_var (known failure in gdb 4.10)" | |
180 | # But do make sure that it prints as something reasonable | |
181 | gdb_test "whatis one_var" "type = inttype(|_one)" \ | |
182 | "whatis one_var test 2" | |
183 | ||
184 | gdb_test "whatis two_var" "type = inttype_two" \ | |
185 | "whatis two_var (known failure in gdb 4.10)" | |
186 | # But do make sure that it prints as something reasonable | |
187 | gdb_test "whatis two_var" "type = inttype(|_two)" \ | |
188 | "whatis two_var test 2" | |
189 | ||
190 | setup_xfail "*-*-*" | |
191 | gdb_test "whatis pointer_to_int_var" "type = int \[*\]" | |
192 | setup_xfail "*-*-*" | |
193 | gdb_test "whatis intp_var" "type = intp" | |
194 | ||
195 | gdb_test "p common0var0" "= 42" | |
196 | # GDB seems to only understand common blocks local to a function. | |
197 | # These variables never get relocated to be relative to the common | |
198 | # block. | |
199 | # I'm not sure whether it is valid to have a common block which | |
200 | # is not local to a function. | |
201 | setup_xfail "*-*-*" | |
202 | gdb_test "p common0var1" "= 24" | |
203 | setup_xfail "*-*-*" | |
204 | gdb_test "p common0var2" "= 22" | |
c906108c SS |
205 | } |
206 | ||
207 | proc print_weird_var { var } { | |
208 | global gdb_prompt | |
209 | ||
210 | # Make sure that the variable gets printed out correctly, without | |
211 | # any sort of warning message. | |
212 | send_gdb "print $var\n" | |
213 | gdb_expect { | |
214 | -re "^print $var\r*\n.\[0-9\]* = 42.*$gdb_prompt $" { | |
215 | pass "variable $var printed properly" | |
216 | } | |
217 | -re ".*$gdb_prompt $" { | |
0398c9aa | 218 | fail "variable $var printed properly" |
c906108c | 219 | } |
0398c9aa AC |
220 | timeout { fail "variable $var printed properly (timeout)" } |
221 | eof { fail "variable $var printed properly (eof)" } | |
c906108c SS |
222 | } |
223 | ||
224 | # Make sure that the stabs did get loaded in a sensible way. | |
225 | # If somehow the stabs got skipped, then the above test can | |
226 | # pass because GDB assumes int for variables without a stab. | |
227 | ||
228 | # This doesn't work because 32=45 doesn't preserve the name in | |
229 | # gdb (as of 14 Sep 93 anyway). | |
230 | #gdb_test "whatis $var" "type = (unsigned int|inttype)" | |
231 | ||
232 | # But the size should be right. | |
233 | gdb_test "print sizeof ($var)" "= 4" | |
234 | } | |
235 | ||
236 | ||
237 | # Don't use gdb_load; it doesn't bitch if the loading produced some | |
238 | # error messages during symbol reading. | |
239 | set testfile weird | |
240 | set srcfile ${objdir}/${subdir}/weird.s | |
241 | set binfile ${objdir}/${subdir}/weirdx.o | |
242 | ||
243 | global target_os | |
244 | set sedscript ${srcdir}/${subdir}/aout.sed | |
245 | switch -glob ${target_triplet} { | |
246 | "hppa*-*-*" { | |
247 | set sedscript ${srcdir}/${subdir}/hppa.sed | |
248 | } | |
249 | "mips-*-ecoff" { | |
250 | set sedscript ${srcdir}/${subdir}/ecoff.sed | |
251 | } | |
252 | "powerpc-*-aix*" { | |
253 | set sedscript ${srcdir}/${subdir}/xcoff.sed | |
254 | } | |
255 | "rs6000-*-aix*" { | |
256 | set sedscript ${srcdir}/${subdir}/xcoff.sed | |
257 | } | |
258 | "*-*-aout" { | |
259 | set sedscript ${srcdir}/${subdir}/aout.sed | |
260 | } | |
261 | "*-*-xcoff" { | |
262 | set sedscript ${srcdir}/${subdir}/xcoff.sed | |
263 | } | |
264 | "alpha-*-*" { | |
265 | set sedscript ${srcdir}/${subdir}/ecoff.sed | |
266 | } | |
267 | } | |
268 | ||
269 | ||
270 | # Hope this is a Unix box. | |
271 | set exec_output [remote_exec build "sed" "-f ${sedscript}" "${srcdir}/${subdir}/weird.def" "${srcfile}"] | |
272 | if { [lindex $exec_output 0] != 0 } { | |
273 | perror "Couldn't make test case. $exec_output" | |
274 | return -1 | |
275 | } | |
276 | ||
7a292a7a SS |
277 | # HP's assembler has no idea of what to do with .stab directives; detect the |
278 | # use of HP compilers and escape from here. (No doubt a better heuristic | |
279 | # could be devised.) | |
280 | ||
281 | if { [ info exists CC ] && [ string first "/opt/ansic/bin/cc" "$CC" ] >= 0 } then { continue } | |
282 | ||
c906108c SS |
283 | if { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } { |
284 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
285 | } | |
286 | ||
287 | remote_file build delete ${srcfile} | |
288 | ||
289 | # Start with a fresh gdb | |
290 | gdb_exit | |
291 | gdb_start | |
292 | gdb_reinitialize_dir $srcdir/$subdir | |
293 | ||
294 | set binfile [remote_download host ${binfile} object.o] | |
295 | send_gdb "file $binfile\n" | |
296 | # If $binfile is very long, a \r (but not a \n) will echo in the | |
297 | # middle of the echo of the command. So to match the echo, we | |
298 | # would like to match anything not containing \n | |
299 | # (we would prefer to be sure not to match any warning message). | |
300 | # But \[^\n\]* doesn't seem to work, so instead use the heuristic | |
301 | # that a filename won't contain a space and a warning message will. | |
302 | # But spaces following by backspaces aren't really spaces. | |
303 | gdb_expect 60 { | |
304 | -re "^file (\[^ \]| +\008)*\r*\n" { | |
305 | exp_continue | |
306 | } | |
307 | -re "A program is being debugged already. Kill it\\? \\(y or n\\)" { | |
308 | send_gdb "y\n" | |
309 | exp_continue | |
310 | } | |
3fcf0ced | 311 | -re "^Reading symbols from $binfile\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" { |
c906108c SS |
312 | pass "weirdx.o read without error" |
313 | } | |
314 | -re ".*$gdb_prompt $" { | |
315 | fail "Errors reading weirdx.o" | |
316 | } | |
317 | timeout { | |
318 | perror "couldn't load $binfile into $GDB (timed out)." | |
319 | return -1 | |
320 | } | |
321 | eof { fail "(eof) cannot read weirdx.o" } | |
322 | } | |
323 | ||
324 | do_tests | |
325 | ||
326 | remote_file host delete ${binfile} | |
327 | ||
328 | return 0 |