]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.stabs/weird.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.stabs / weird.exp
1 # Copyright (C) 1997 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 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 # bug-gdb@prep.ai.mit.edu
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 "*-*-*"
173 gdb_test "p array0" " = \{42, 43, 44, 45, 46, 47\}" "array0 with strange index"
174 setup_xfail "*-*-*"
175 gdb_test "p array1" " = \{42, 43, 44\}" "array1 with strange index"
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"
205
206 # this long line must be continous, not with "/" escaping the newline
207 gdb_test "p v_comb" "{<> = {<> = {x = 42}, \[_a-zA-Z$.\]* = \[0-9xa-fA-F\]*, a = 43}, <> = {\[_a-zA-Z$.\]* = \[0-9xa-fA-F\]*, b = 44}, comb = 45}"
208 }
209
210 proc print_weird_var { var } {
211 global gdb_prompt
212
213 # Make sure that the variable gets printed out correctly, without
214 # any sort of warning message.
215 send_gdb "print $var\n"
216 gdb_expect {
217 -re "^print $var\r*\n.\[0-9\]* = 42.*$gdb_prompt $" {
218 pass "variable $var printed properly"
219 }
220 -re ".*$gdb_prompt $" {
221 fail "variable $var not printed properly"
222 }
223 timeout { fail "variable $var not printed (timeout)" }
224 eof { fail "(eof) variable $var not printed" }
225 }
226
227 # Make sure that the stabs did get loaded in a sensible way.
228 # If somehow the stabs got skipped, then the above test can
229 # pass because GDB assumes int for variables without a stab.
230
231 # This doesn't work because 32=45 doesn't preserve the name in
232 # gdb (as of 14 Sep 93 anyway).
233 #gdb_test "whatis $var" "type = (unsigned int|inttype)"
234
235 # But the size should be right.
236 gdb_test "print sizeof ($var)" "= 4"
237 }
238
239
240 # Don't use gdb_load; it doesn't bitch if the loading produced some
241 # error messages during symbol reading.
242 set testfile weird
243 set srcfile ${objdir}/${subdir}/weird.s
244 set binfile ${objdir}/${subdir}/weirdx.o
245
246 global target_os
247 set sedscript ${srcdir}/${subdir}/aout.sed
248 switch -glob ${target_triplet} {
249 "hppa*-*-*" {
250 set sedscript ${srcdir}/${subdir}/hppa.sed
251 }
252 "mips-*-ecoff" {
253 set sedscript ${srcdir}/${subdir}/ecoff.sed
254 }
255 "powerpc-*-aix*" {
256 set sedscript ${srcdir}/${subdir}/xcoff.sed
257 }
258 "rs6000-*-aix*" {
259 set sedscript ${srcdir}/${subdir}/xcoff.sed
260 }
261 "*-*-aout" {
262 set sedscript ${srcdir}/${subdir}/aout.sed
263 }
264 "*-*-xcoff" {
265 set sedscript ${srcdir}/${subdir}/xcoff.sed
266 }
267 "alpha-*-*" {
268 set sedscript ${srcdir}/${subdir}/ecoff.sed
269 }
270 }
271
272
273 # Hope this is a Unix box.
274 set exec_output [remote_exec build "sed" "-f ${sedscript}" "${srcdir}/${subdir}/weird.def" "${srcfile}"]
275 if { [lindex $exec_output 0] != 0 } {
276 perror "Couldn't make test case. $exec_output"
277 return -1
278 }
279
280 if { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } {
281 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
282 }
283
284 remote_file build delete ${srcfile}
285
286 # Start with a fresh gdb
287 gdb_exit
288 gdb_start
289 gdb_reinitialize_dir $srcdir/$subdir
290
291 set binfile [remote_download host ${binfile} object.o]
292 send_gdb "file $binfile\n"
293 # If $binfile is very long, a \r (but not a \n) will echo in the
294 # middle of the echo of the command. So to match the echo, we
295 # would like to match anything not containing \n
296 # (we would prefer to be sure not to match any warning message).
297 # But \[^\n\]* doesn't seem to work, so instead use the heuristic
298 # that a filename won't contain a space and a warning message will.
299 # But spaces following by backspaces aren't really spaces.
300 gdb_expect 60 {
301 -re "^file (\[^ \]| +\008)*\r*\n" {
302 exp_continue
303 }
304 -re "A program is being debugged already. Kill it\\? \\(y or n\\)" {
305 send_gdb "y\n"
306 exp_continue
307 }
308 -re "^Reading symbols from $binfile\\.\\.\\.done\.\r*\n$gdb_prompt $" {
309 pass "weirdx.o read without error"
310 }
311 -re ".*$gdb_prompt $" {
312 fail "Errors reading weirdx.o"
313 }
314 timeout {
315 perror "couldn't load $binfile into $GDB (timed out)."
316 return -1
317 }
318 eof { fail "(eof) cannot read weirdx.o" }
319 }
320
321 do_tests
322
323 remote_file host delete ${binfile}
324
325 return 0