1 # Copyright 1997, 1998, 1999, 2001, 2003, 2004, 2006, 2007, 2008
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
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.
27 # If the test directory was not created by configure then skip
29 if ![file isdirectory ${objdir}/${subdir}] then {
37 set srcfile ${objdir}/${subdir}/weird.s
38 set binfile ${objdir}/${subdir}/weirdx.o
40 if { [ get_compiler_info "$binfile" ] } {
44 if { $hp_cc_compiler || $hp_aCC_compiler } {
45 # The native hp-ux assembler does not support stabs at all.
46 # If the compiler is native hp-ux, of course the assembler is too.
47 # But if someone builds gcc with the native assembler (not recommended)
48 # rather than the gnu assembler, then this logic will not suppress it.
49 # -- chastain 2004-01-07
50 unsupported "stabs with hp-ux assembler"
58 # Mips/alpha targets that use gcc with mips-tfile put out the stabs
59 # assembler directives embedded in comments. If the assembler
60 # file is then processed with native cc, all stabs directives
62 # Skip the rest of the stabs tests for this case.
63 send_gdb "ptype inttype\n"
65 -re "^ptype inttype\r*\ntype = inttype.*$gdb_prompt $" {
68 -re ".*$gdb_prompt $" {
69 setup_xfail "mips-*-*"
70 setup_xfail "alpha-*-*"
71 fail "stabs not found"
74 default { fail "checking for stabs" }
82 print_weird_var attr32
83 print_weird_var attr33
84 print_weird_var attr35
85 print_weird_var attr36
86 print_weird_var attr37
87 print_weird_var attr38
88 print_weird_var attr39
89 print_weird_var attr41
90 print_weird_var attr42
91 print_weird_var attr43
92 print_weird_var attr44
93 print_weird_var attr46
94 print_weird_var attr47
95 print_weird_var attr58
96 print_weird_var attr59
97 print_weird_var attr60
98 print_weird_var attr61
99 print_weird_var attr62
100 print_weird_var attr63
101 print_weird_var attr64
102 print_weird_var attr65
103 print_weird_var attr66
104 print_weird_var attr67
105 print_weird_var attr68
106 print_weird_var attr69
107 print_weird_var attr70
108 print_weird_var attr71
109 print_weird_var attr72
110 print_weird_var attr73
111 print_weird_var attr74
112 print_weird_var attr75
113 print_weird_var attr76
114 print_weird_var attr77
115 print_weird_var attr78
116 print_weird_var attr79
117 print_weird_var attr80
118 print_weird_var attr81
119 print_weird_var attr82
120 print_weird_var attr83
121 print_weird_var attr84
122 print_weird_var attr85
123 print_weird_var attr86
124 print_weird_var attr87
125 print_weird_var attr88
126 print_weird_var attr89
127 print_weird_var attr90
128 print_weird_var attr91
129 print_weird_var attr92
130 print_weird_var attr93
131 print_weird_var attr94
132 print_weird_var attr95
133 print_weird_var attr96
134 print_weird_var attr97
135 print_weird_var attr98
136 print_weird_var attr99
137 print_weird_var attr100
138 print_weird_var attr101
139 print_weird_var attr102
140 print_weird_var attr103
141 print_weird_var attr104
142 print_weird_var attr105
143 print_weird_var attr106
144 print_weird_var attr107
145 print_weird_var attr108
146 print_weird_var attr109
147 print_weird_var attr110
148 print_weird_var attr111
149 print_weird_var attr112
150 print_weird_var attr113
151 print_weird_var attr114
152 print_weird_var attr115
153 print_weird_var attr116
154 print_weird_var attr117
155 print_weird_var attr118
156 print_weird_var attr119
157 print_weird_var attr120
158 print_weird_var attr121
159 print_weird_var attr122
160 print_weird_var attr123
161 print_weird_var attr124
162 print_weird_var attr125
163 print_weird_var attr126
165 gdb_test "p const69" " = 69" "'e' constant on non-enum type"
166 gdb_test "whatis const69" "type = (unsigned int|inttype)" "whatis const69"
168 gdb_test "p sizeof (const70)" " = 2" "'e' constant with embedded type"
170 gdb_test "p bad_neg0" " = \{field0 = 42, field2 =.*field3 = 45\}" "p bad_neg0"
172 gdb_test "ptype inttype" "type = (unsigned int|inttype)" "ptype on inttype"
173 gdb_test "p sizeof (float72type)" " = 9" "unrecognized floating point type"
175 # This big number needs to be kept as one piece
176 gdb_test "p/x int256var" " = 0x0*2a0000002b0000002c0000002d0000002d0000002c0000002b0000002a" "print very big integer"
178 gdb_test "whatis consth" "type = inttype" "whatis consth"
179 gdb_test "whatis consth2" "type = inttype" "whatis consth2"
181 # GDB does not yet understand S constants
183 gdb_test "p/x bad_neg0const" " = \{field0 = 0x11222211, field2 =.*\
184 field3 = 0x77888877\}" "print struct constant"
186 gdb_test "ptype bad_type0" "type = .*" "print bad_type0"
187 gdb_test "ptype bad_type1" "type = .*" "print bad_type1"
189 # GDB does not yet support arrays indexed by anything at all unusual
191 gdb_test "p array0" " = \\{42, 43, 44, 45, 46, 47\\}" "array0 with strange index"
193 gdb_test "p array1" " = \\{42, 43, 44\\}" "array1 with strange index"
195 # GDB does not yet support this feature
196 gdb_test "whatis one_var" "type = inttype_one" \
197 "whatis one_var (known failure in gdb 4.10)"
198 # But do make sure that it prints as something reasonable
199 gdb_test "whatis one_var" "type = inttype(|_one)" \
200 "whatis one_var test 2"
202 gdb_test "whatis two_var" "type = inttype_two" \
203 "whatis two_var (known failure in gdb 4.10)"
204 # But do make sure that it prints as something reasonable
205 gdb_test "whatis two_var" "type = inttype(|_two)" \
206 "whatis two_var test 2"
209 gdb_test "whatis pointer_to_int_var" "type = int \[*\]"
211 gdb_test "whatis intp_var" "type = intp"
213 gdb_test "p common0var0" "= 42"
214 # GDB seems to only understand common blocks local to a function.
215 # These variables never get relocated to be relative to the common
217 # I'm not sure whether it is valid to have a common block which
218 # is not local to a function.
220 gdb_test "p common0var1" "= 24"
222 gdb_test "p common0var2" "= 22"
225 proc print_weird_var { var } {
228 # Make sure that the variable gets printed out correctly, without
229 # any sort of warning message.
230 gdb_test_multiple "print $var" "variable $var printed property" {
231 -re "^print $var\r*\n.\[0-9\]* = 42.*$gdb_prompt $" {
232 pass "variable $var printed properly"
234 -re ".*$gdb_prompt $" {
235 fail "variable $var printed properly"
239 # Make sure that the stabs did get loaded in a sensible way.
240 # If somehow the stabs got skipped, then the above test can
241 # pass because GDB assumes int for variables without a stab.
243 # This doesn't work because 32=45 doesn't preserve the name in
244 # gdb (as of 14 Sep 93 anyway).
245 #gdb_test "whatis $var" "type = (unsigned int|inttype)"
247 # But the size should be right.
248 gdb_test "print sizeof ($var)" "= 4"
252 # Don't use gdb_load; it doesn't bitch if the loading produced some
253 # error messages during symbol reading.
256 set sedscript ${srcdir}/${subdir}/aout.sed
257 switch -glob ${target_triplet} {
259 set sedscript ${srcdir}/${subdir}/hppa.sed
262 set sedscript ${srcdir}/${subdir}/ecoff.sed
265 set sedscript ${srcdir}/${subdir}/xcoff.sed
268 set sedscript ${srcdir}/${subdir}/xcoff.sed
271 set sedscript ${srcdir}/${subdir}/aout.sed
274 set sedscript ${srcdir}/${subdir}/xcoff.sed
277 set sedscript ${srcdir}/${subdir}/ecoff.sed
281 # Hope this is a Unix box.
282 set exec_output [remote_exec build "sed" "-f ${sedscript}" "${srcdir}/${subdir}/weird.def" "${srcfile}"]
283 if { [lindex $exec_output 0] != 0 } {
284 perror "Couldn't make test case. $exec_output"
288 if { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } {
293 remote_file build delete ${srcfile}
295 # Start with a fresh gdb
298 gdb_reinitialize_dir $srcdir/$subdir
300 set binfile [remote_download host ${binfile} object.o]
301 send_gdb "file $binfile\n"
302 # If $binfile is very long, a \r (but not a \n) will echo in the
303 # middle of the echo of the command. So to match the echo, we
304 # would like to match anything not containing \n
305 # (we would prefer to be sure not to match any warning message).
306 # But \[^\n\]* doesn't seem to work, so instead use the heuristic
307 # that a filename won't contain a space and a warning message will.
308 # But spaces following by backspaces aren't really spaces.
310 -re "^file (\[^ \]| +\008)*\r*\n" {
313 -re "A program is being debugged already.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\)" {
317 -re "^Reading symbols from .*$binfile\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" {
318 pass "weirdx.o read without error"
320 -re ".*$gdb_prompt $" {
321 fail "Errors reading weirdx.o"
324 perror "couldn't load $binfile into $GDB (timed out)."
327 eof { fail "(eof) cannot read weirdx.o" }
332 remote_file host delete ${binfile}