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