1 # Copyright 1997-2013 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
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.
21 set srcfile [standard_output_file weird.s]
22 set binfile [standard_output_file weirdx.o]
24 if { [ get_compiler_info ] } {
28 if { $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"
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
46 # Skip the rest of the stabs tests for this case.
47 send_gdb "ptype inttype\n"
49 -re "^ptype inttype\r*\ntype = inttype.*$gdb_prompt $" {
52 -re ".*$gdb_prompt $" {
53 setup_xfail "mips-*-*"
54 setup_xfail "alpha-*-*"
55 fail "stabs not found"
58 default { fail "checking for stabs" }
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
149 gdb_test "p const69" " = 69" "'e' constant on non-enum type"
150 gdb_test "whatis const69" "type = (unsigned int|inttype)" "whatis const69"
152 gdb_test "p sizeof (const70)" " = 2" "'e' constant with embedded type"
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"
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"
160 gdb_test "p bad_neg0" " = \{field0 = 42, field2 =.*field3 = 45\}" "p bad_neg0"
162 gdb_test "ptype inttype" "type = (unsigned int|inttype)" "ptype on inttype"
163 gdb_test "p sizeof (float72type)" " = 9" "unrecognized floating point type"
165 # This big number needs to be kept as one piece
166 gdb_test "p/x int256var" " = 0x0*2a0000002b0000002c0000002d0000002d0000002c0000002b0000002a" "print very big integer"
168 gdb_test "whatis consth" "type = inttype" "whatis consth"
169 gdb_test "whatis consth2" "type = inttype" "whatis consth2"
171 # GDB does not yet understand S constants
173 gdb_test "p/x bad_neg0const" " = \{field0 = 0x11222211, field2 =.*\
174 field3 = 0x77888877\}" "print struct constant"
176 gdb_test "ptype bad_type0" "type = .*" "print bad_type0"
177 gdb_test "ptype bad_type1" "type = .*" "print bad_type1"
179 # GDB does not yet support arrays indexed by anything at all unusual
181 gdb_test "p array0" " = \\{42, 43, 44, 45, 46, 47\\}" "array0 with strange index"
183 gdb_test "p array1" " = \\{42, 43, 44\\}" "array1 with strange index"
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"
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"
199 gdb_test "whatis pointer_to_int_var" "type = int \[*\]"
201 gdb_test "whatis intp_var" "type = intp"
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
207 # I'm not sure whether it is valid to have a common block which
208 # is not local to a function.
210 gdb_test "p common0var1" "= 24"
212 gdb_test "p common0var2" "= 22"
215 proc print_weird_var { var } {
218 # Make sure that the variable gets printed out correctly, without
219 # any sort of warning message.
220 gdb_test_multiple "print $var" "variable $var printed property" {
221 -re "^print $var\r*\n.\[0-9\]* = 42.*$gdb_prompt $" {
222 pass "variable $var printed properly"
224 -re ".*$gdb_prompt $" {
225 fail "variable $var printed properly"
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.
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)"
237 # But the size should be right.
238 gdb_test "print sizeof ($var)" "= 4"
242 # Don't use gdb_load; it doesn't bitch if the loading produced some
243 # error messages during symbol reading.
246 set sedscript ${srcdir}/${subdir}/aout.sed
249 switch -glob ${target_triplet} {
251 set sedscript ${srcdir}/${subdir}/hppa.sed
254 set sedscript ${srcdir}/${subdir}/ecoff.sed
257 set sedscript ${srcdir}/${subdir}/xcoff.sed
261 set sedscript ${srcdir}/${subdir}/xcoff.sed
265 set sedscript ${srcdir}/${subdir}/aout.sed
268 set sedscript ${srcdir}/${subdir}/xcoff.sed
272 set sedscript ${srcdir}/${subdir}/ecoff.sed
276 # Hope this is a Unix box.
277 set exec_output [remote_exec build "sed" "${sedoptions} -f ${sedscript}" "${srcdir}/${subdir}/weird.def" "${srcfile}"]
278 if { [lindex $exec_output 0] != 0 } {
279 perror "Couldn't make test case. $exec_output"
283 if { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } {
288 remote_file build delete ${srcfile}
290 # Start with a fresh gdb
293 gdb_reinitialize_dir $srcdir/$subdir
295 set binfile [remote_download host ${binfile} object.o]
296 send_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.
305 -re "^file (\[^ \]| +\008)*\r*\n" {
308 -re "A program is being debugged already.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\)" {
312 -re "^Reading symbols from .*$binfile\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" {
313 pass "weirdx.o read without error"
315 -re ".*$gdb_prompt $" {
316 fail "Errors reading weirdx.o"
319 perror "couldn't load $binfile into $GDB (timed out)."
322 eof { fail "(eof) cannot read weirdx.o" }
327 remote_file host delete ${binfile}