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