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