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