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