Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 1988-2020 Free Software Foundation, Inc. |
c906108c SS |
2 | |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # This file was written by Rob Savoye. (rob@cygnus.com) |
17 | ||
c906108c SS |
18 | # |
19 | # test running programs | |
20 | # | |
c906108c | 21 | |
822bd149 TT |
22 | standard_testfile .c ptype1.c |
23 | ||
5b362f04 | 24 | if {[prepare_for_testing "failed to prepare" ${testfile} \ |
822bd149 TT |
25 | [list $srcfile $srcfile2] {debug nowarnings}]} { |
26 | return -1 | |
c906108c SS |
27 | } |
28 | ||
29 | # Create and source the file that provides information about the compiler | |
30 | # used to compile the test case. | |
4c93b1db | 31 | if [get_compiler_info] { |
ae59b1da | 32 | return -1 |
c906108c SS |
33 | } |
34 | ||
c906108c SS |
35 | # Test ptype of unnamed enumeration members before any action causes |
36 | # the partial symbol table to be expanded to full symbols. This fails | |
37 | # with stabs compilers which fail to use a nameless stab (such as | |
38 | # pre-2.4.5 versions of gcc and most non-gcc compilers). | |
39 | ||
65731a6b MS |
40 | gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" { |
41 | -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $" { | |
42 | # The workaround is in effect. As this is a compiler, not GDB, | |
43 | # bug, we'll make it a PASS but perhaps it should be an XFAIL. | |
44 | pass "ptype unnamed enumeration member (worked around)" | |
45 | } | |
46 | -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $" { | |
47 | pass "ptype unnamed enumeration member" | |
48 | } | |
c906108c SS |
49 | } |
50 | ||
51 | # | |
52 | # test ptype command with structures | |
53 | # | |
54 | # Here and elsewhere, we accept | |
55 | # "long", "long int", or "int" for long variables (whatis.exp already | |
56 | # has an XFAIL for "int" (Sun cc bug), so no need to fail it here). | |
57 | gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype structure" | |
58 | ||
59 | ||
60 | # Test the equivalence between '.' and '->' for struct member references. | |
61 | ||
62 | if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then { | |
63 | return -1 | |
64 | } | |
65 | if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then { | |
66 | return -1 | |
67 | } | |
68 | if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then { | |
69 | return -1 | |
70 | } | |
71 | if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then { | |
72 | return -1 | |
73 | } | |
74 | ||
75 | ||
76 | # IBM's xlc puts out bogus stabs--the stuff field is type 42, | |
77 | # which isn't defined. | |
78 | ||
085dd6e6 | 79 | gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure" |
c906108c SS |
80 | |
81 | # | |
82 | # test ptype command with unions | |
83 | # | |
84 | gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\] (unsigned |)char v_char_member;.*\[\r\n\] (short|short int) v_short_member;.*\[\r\n\] int v_int_member;.*\[\r\n\] (long|long int|int) v_long_member;.*\[\r\n\] float v_float_member;.*\[\r\n\] double v_double_member;.*\[\r\n\]\}.*" "ptype union" | |
85 | ||
86 | # IBM's xlc puts out bogus stabs--the stuff field is type 42, | |
87 | # which isn't defined. | |
085dd6e6 | 88 | gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union" |
c906108c SS |
89 | |
90 | # | |
91 | # test ptype command with enums | |
92 | # | |
93 | ||
94 | gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" | |
95 | ||
96 | gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" | |
97 | ||
98 | ||
99 | # | |
100 | # test ptype command with enums as typedef | |
101 | # | |
085dd6e6 | 102 | gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" |
c906108c SS |
103 | |
104 | # And check that whatis shows the name, not "enum {...}". | |
105 | # This probably fails for all DWARF 1 cases, so assume so for now. -fnf | |
106 | # The problem with xlc is that the stabs look like | |
107 | # :t51=eFALSE:0,TRUE:1,; | |
108 | # boolean:t55=51 | |
109 | # v_boolean:G51 | |
110 | # GDB's behavior is correct; the type which the variable is defined | |
111 | # as (51) doesn't have a name. Only 55 has a name. | |
112 | ||
b6304613 | 113 | if {!$gcc_compiled} { |
a0b3c4fd JM |
114 | setup_xfail "rs6000-*-*" "i*86-*-sysv4*" |
115 | setup_xfail "hppa*-*-*" CLLbs14773 | |
085dd6e6 | 116 | } |
dfcd3bfb JM |
117 | |
118 | # For get_debug_format to do its job, we need to have a current source file. | |
e777225b | 119 | gdb_test "list -q main" ".*" |
9846de1b | 120 | get_debug_format |
085dd6e6 | 121 | gdb_test "whatis v_boolean" "type = (enum |)boolean" \ |
c906108c SS |
122 | "whatis unnamed typedef'd enum (compiler bug in IBM's xlc)" |
123 | ||
124 | # Same thing with struct and union. | |
085dd6e6 | 125 | gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.* |
c906108c SS |
126 | *double v_double_member;.* |
127 | *int v_int_member;.*\}" "printing typedef'd struct" | |
128 | ||
085dd6e6 | 129 | gdb_test "ptype t_union3" "type = union (t_union3 |)\{.* |
c906108c SS |
130 | *double v_double_member;.* |
131 | *int v_int_member;.*\}" "printing typedef'd union" | |
132 | ||
085dd6e6 | 133 | gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum" |
c906108c SS |
134 | |
135 | # | |
136 | # test ptype command with out-of-order enum values | |
137 | # | |
138 | gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" | |
139 | ||
140 | # | |
141 | # test ptype command with a named enum's value | |
142 | # | |
143 | gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" | |
144 | ||
145 | gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2" | |
146 | ||
147 | # | |
148 | # test ptype command with basic C types | |
149 | # | |
150 | # I've commented most of this out because it duplicates tests in whatis.exp. | |
151 | # I've just left in a token test or 2 which is designed to test that ptype | |
152 | # acts like whatis for basic types. If it is thought to be necessary to | |
153 | # test both whatis and ptype for all the types, the tests should be | |
154 | # merged into whatis.exp, or else maintenance will be a royal pain -kingdon | |
cc30c4bd | 155 | #setup_xfail "mips-sgi-*" |
c906108c SS |
156 | #send "ptype v_char\n" |
157 | #gdb_expect { | |
158 | # -re "type = char.*$gdb_prompt $" { pass "ptype char" } | |
159 | # -re ".*$gdb_prompt $" { fail "ptype char" } | |
160 | # timeout { fail "(timeout) ptype char" } | |
161 | #} | |
162 | # | |
163 | # | |
9fbfe2dc | 164 | #setup_xfail "mips-*-*" |
c906108c SS |
165 | #send "ptype v_signed_char\n" |
166 | #gdb_expect { | |
167 | # -re "type = signed char.*$gdb_prompt $" { pass "ptype signed char" } | |
168 | # -re ".*$gdb_prompt $" { fail "ptype signed char" } | |
169 | # timeout { fail "(timeout) ptype signed char" } | |
170 | #} | |
171 | # | |
172 | # | |
173 | #send "ptype v_unsigned_char\n" | |
174 | #gdb_expect { | |
175 | # -re "type = unsigned char.*$gdb_prompt $" { pass "ptype unsigned char" } | |
176 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char" } | |
177 | # timeout { fail "(timeout) ptype unsigned char" } | |
178 | #} | |
179 | ||
180 | gdb_test "ptype v_short" "type = short(| int).*" "ptype short" | |
181 | ||
182 | #send "ptype v_signed_short\n" | |
183 | #gdb_expect { | |
184 | # -re "type = short.*$gdb_prompt $" { pass "ptype signed short" } | |
185 | # -re ".*$gdb_prompt $" { fail "ptype signed short" } | |
186 | # timeout { fail "(timeout) ptype signed short" } | |
187 | #} | |
188 | # | |
189 | # | |
190 | #send "ptype v_unsigned_short\n" | |
191 | #gdb_expect { | |
192 | # -re "type = unsigned short.*$gdb_prompt $" { pass "ptype unsigned short" } | |
193 | # -re ".*$gdb_prompt $" { fail "ptype unsigned short" } | |
194 | # timeout { fail "(timeout) ptype unsigned short" } | |
195 | #} | |
196 | ||
197 | ||
198 | gdb_test "ptype v_int" "type = int.*" "ptype int" | |
199 | ||
200 | #send "ptype v_signed_int\n" | |
201 | #gdb_expect { | |
202 | # -re "type = int.*$gdb_prompt $" { pass "ptype signed int" } | |
203 | # -re ".*$gdb_prompt $" { fail "ptype signed int" } | |
204 | # timeout { fail "(timeout) ptype signed int" } | |
205 | #} | |
206 | # | |
207 | # | |
208 | #send "ptype v_unsigned_int\n" | |
209 | #gdb_expect { | |
210 | # -re "type = unsigned int.*$gdb_prompt $" { pass "ptype unsigned int" } | |
211 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int" } | |
212 | # timeout { fail "(timeout) ptype unsigned int" } | |
213 | #} | |
214 | # | |
215 | # | |
216 | #send "ptype v_long\n" | |
217 | #gdb_expect { | |
218 | # -re "type = long.*$gdb_prompt $" { pass "ptype long" } | |
219 | # -re ".*$gdb_prompt $" { fail "ptype long" } | |
220 | # timeout { fail "(timeout) ptype long" } | |
221 | #} | |
222 | # | |
223 | # | |
224 | #send "ptype v_signed_long\n" | |
225 | #gdb_expect { | |
226 | # -re "type = long.*$gdb_prompt $" { pass "ptype signed long" } | |
227 | # -re ".*$gdb_prompt $" { fail "ptype signed long" } | |
228 | # timeout { fail "(timeout) ptype signed long" } | |
229 | #} | |
230 | # | |
231 | # | |
232 | #send "ptype v_unsigned_long\n" | |
233 | #gdb_expect { | |
234 | # -re "type = unsigned long.*$gdb_prompt $" { pass "ptype unsigned long" } | |
235 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long" } | |
236 | # timeout { fail "(timeout) ptype unsigned long" } | |
237 | #} | |
238 | # | |
239 | # | |
240 | #send "ptype v_float\n" | |
241 | #gdb_expect { | |
242 | # -re "type = float.*$gdb_prompt $" { pass "ptype float" } | |
243 | # -re ".*$gdb_prompt $" { fail "ptype float" } | |
244 | # timeout { fail "(timeout) ptype float" } | |
245 | #} | |
246 | # | |
247 | # | |
248 | #send "ptype v_double\n" | |
249 | #gdb_expect { | |
250 | # -re "type = double.*$gdb_prompt $" { pass "ptype double" } | |
251 | # -re ".*$gdb_prompt $" { fail "ptype double" } | |
252 | # timeout { fail "(timeout) ptype double" } | |
253 | #} | |
254 | ||
255 | ||
256 | # | |
257 | # test ptype command with arrays | |
258 | # | |
cc30c4bd | 259 | #setup_xfail "mips-sgi-*" |
c906108c SS |
260 | #send "ptype v_char_array\n" |
261 | #gdb_expect { | |
262 | # -re "type = char .2..*$gdb_prompt $" { pass "ptype char array" } | |
263 | # -re ".*$gdb_prompt $" { fail "ptype char array" } | |
264 | # timeout { fail "(timeout) ptype char array" } | |
265 | #} | |
266 | # | |
267 | # | |
9fbfe2dc | 268 | #setup_xfail "mips-*-*" |
c906108c SS |
269 | #send "ptype v_signed_char_array\n" |
270 | #gdb_expect { | |
271 | # -re "type = (|signed )char .2..*$gdb_prompt $" { pass "ptype signed char array" } | |
272 | # -re ".*$gdb_prompt $" { fail "ptype signed char array" } | |
273 | # timeout { fail "(timeout) ptype signed char array" } | |
274 | #} | |
275 | # | |
276 | # | |
277 | #send "ptype v_unsigned_char_array\n" | |
278 | #gdb_expect { | |
279 | # -re "type = unsigned char .2..*$gdb_prompt $" { pass "ptype unsigned char array" } | |
280 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char array" } | |
281 | # timeout { fail "(timeout) ptype unsigned char array" } | |
282 | #} | |
283 | # | |
284 | # | |
285 | # | |
286 | #send "ptype v_int_array\n" | |
287 | #gdb_expect { | |
288 | # -re "type = int .2..*$gdb_prompt $" { pass "ptype int array" } | |
289 | # -re ".*$gdb_prompt $" { fail "ptype int array" } | |
290 | # timeout { fail "(timeout) ptype int array" } | |
291 | #} | |
292 | # | |
293 | # | |
294 | #send "ptype v_signed_int_array\n" | |
295 | #gdb_expect { | |
296 | # -re "type = int .2..*$gdb_prompt $" { pass "ptype signed int array" } | |
297 | # -re ".*$gdb_prompt $" { fail "ptype signed int array" } | |
298 | # timeout { fail "(timeout) ptype signed int array" } | |
299 | #} | |
300 | # | |
301 | # | |
302 | #send "ptype v_unsigned_int_array\n" | |
303 | #gdb_expect { | |
304 | # -re "type = unsigned int .2..*$gdb_prompt $" { pass "ptype unsigned int array" } | |
305 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int array" } | |
306 | # timeout { fail "(timeout) ptype unsigned int array" } | |
307 | #} | |
308 | # | |
309 | # | |
310 | #send "ptype v_long_array\n" | |
311 | #gdb_expect { | |
312 | # -re "type = (long|int|long int) .2..*$gdb_prompt $" { | |
313 | # pass "ptype long array" } | |
314 | # -re ".*$gdb_prompt $" { fail "ptype long array" } | |
315 | # timeout { fail "(timeout) ptype long array" } | |
316 | #} | |
317 | # | |
318 | # | |
319 | #send "ptype v_signed_long_array\n" | |
320 | #gdb_expect { | |
321 | # -re "type = (long|int|long int) .2..*$gdb_prompt $" { | |
322 | # pass "ptype signed long array" } | |
323 | # -re ".*$gdb_prompt $" { fail "ptype signed long array" } | |
324 | # timeout { fail "(timeout) ptype signed long array" } | |
325 | #} | |
326 | # | |
327 | # | |
328 | #send "ptype v_unsigned_long_array\n" | |
329 | #gdb_expect { | |
330 | # -re "type = unsigned long .2..*$gdb_prompt $" { pass "ptype unsigned long array" } | |
331 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long array" } | |
332 | # timeout { fail "(timeout) ptype unsigned long array" } | |
333 | #} | |
334 | # | |
335 | # | |
336 | #send "ptype v_float_array\n" | |
337 | #gdb_expect { | |
338 | # -re "type = float .2..*$gdb_prompt $" { pass "ptype float array" } | |
339 | # -re ".*$gdb_prompt $" { fail "ptype float array" } | |
340 | # timeout { fail "(timeout) ptype float array" } | |
341 | #} | |
342 | # | |
343 | # | |
344 | #send "ptype v_double_array\n" | |
345 | #gdb_expect { | |
346 | # -re "type = double .2..*$gdb_prompt $" { pass "ptype double array" } | |
347 | # -re ".*$gdb_prompt $" { fail "ptype double array" } | |
348 | # timeout { fail "(timeout) ptype double array" } | |
349 | #} | |
350 | # | |
351 | ||
352 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" } | |
c906108c SS |
353 | gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]" |
354 | ||
350b1b26 AB |
355 | gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]" |
356 | ||
c906108c SS |
357 | # |
358 | ## | |
359 | ## test ptype command with pointers | |
360 | ## | |
cc30c4bd | 361 | #setup_xfail "mips-sgi-*" |
c906108c SS |
362 | #send "ptype v_char_pointer\n" |
363 | #gdb_expect { | |
364 | # -re "type = char \*.*$gdb_prompt $" { pass "ptype char pointer" } | |
365 | # -re ".*$gdb_prompt $" { fail "ptype char pointer" } | |
366 | # timeout { fail "(timeout) ptype char pointer" } | |
367 | #} | |
368 | # | |
369 | # | |
9fbfe2dc | 370 | #setup_xfail "mips-*-*" |
c906108c SS |
371 | #send "ptype v_signed_char_pointer\n" |
372 | #gdb_expect { | |
373 | # -re "type = (|signed )char \*.*$gdb_prompt $" | |
374 | # { pass "ptype signed char pointer" } | |
375 | # -re ".*$gdb_prompt $" { fail "ptype signed char pointer" } | |
376 | # timeout { fail "(timeout) ptype signed char pointer" } | |
377 | #} | |
378 | # | |
379 | # | |
380 | #send "ptype v_unsigned_char_pointer\n" | |
381 | #gdb_expect { | |
382 | # -re "type = unsigned char \*.*$gdb_prompt $" { pass "ptype unsigned char pointer" } | |
383 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char pointer" } | |
384 | # timeout { fail "(timeout) ptype unsigned char pointer" } | |
385 | #} | |
386 | # | |
387 | # | |
388 | #send "ptype v_short_pointer\n" | |
389 | #gdb_expect { | |
390 | # -re "type = (short|short int) \*.*$gdb_prompt $" { pass "ptype short pointer" } | |
391 | # -re ".*$gdb_prompt $" { fail "ptype short pointer" } | |
392 | # timeout { fail "(timeout) ptype short pointer" } | |
393 | #} | |
394 | # | |
395 | # | |
396 | #send "ptype v_signed_short_pointer\n" | |
397 | #gdb_expect { | |
398 | # -re "type = short \*.*$gdb_prompt $" { pass "ptype signed short pointer" } | |
399 | # -re ".*$gdb_prompt $" { fail "ptype signed short pointer" } | |
400 | # timeout { fail "(timeout) ptype signed short pointer" } | |
401 | #} | |
402 | # | |
403 | # | |
404 | #send "ptype v_unsigned_short_pointer\n" | |
405 | #gdb_expect { | |
406 | # -re "type = unsigned short \*.*$gdb_prompt $" { pass "ptype unsigned short pointer" } | |
407 | # -re ".*$gdb_prompt $" { fail "ptype unsigned short pointer" } | |
408 | # timeout { fail "(timeout) ptype unsigned short pointer" } | |
409 | #} | |
410 | # | |
411 | # | |
412 | #send "ptype v_int_pointer\n" | |
413 | #gdb_expect { | |
414 | # -re "type = int \*.*$gdb_prompt $" { pass "ptype int pointer" } | |
415 | # -re ".*$gdb_prompt $" { fail "ptype int pointer" } | |
416 | # timeout { fail "(timeout) ptype int pointer" } | |
417 | #} | |
418 | # | |
419 | # | |
420 | #send "ptype v_signed_int_pointer\n" | |
421 | #gdb_expect { | |
422 | # -re "type = int \*.*$gdb_prompt $" { pass "ptype signed int pointer" } | |
423 | # -re ".*$gdb_prompt $" { fail "ptype signed int pointer" } | |
424 | # timeout { fail "(timeout) ptype signed int pointer" } | |
425 | #} | |
426 | # | |
427 | # | |
428 | #send "ptype v_unsigned_int_pointer\n" | |
429 | #gdb_expect { | |
430 | # -re "type = unsigned int \*.*$gdb_prompt $" { pass "ptype unsigned int pointer" } | |
431 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int pointer" } | |
432 | # timeout { fail "(timeout) ptype unsigned int pointer" } | |
433 | #} | |
434 | # | |
435 | # | |
436 | #send "ptype v_long_pointer\n" | |
437 | #gdb_expect { | |
438 | # -re "type = long \*.*$gdb_prompt $" { pass "ptype long pointer" } | |
439 | # -re ".*$gdb_prompt $" { fail "ptype long pointer" } | |
440 | # timeout { fail "(timeout) ptype long pointer" } | |
441 | #} | |
442 | # | |
443 | # | |
444 | #send "ptype v_signed_long_pointer\n" | |
445 | #gdb_expect { | |
446 | # -re "type = long \*.*$gdb_prompt $" { pass "ptype signed long pointer" } | |
447 | # -re ".*$gdb_prompt $" { fail "ptype signed long pointer" } | |
448 | # timeout { fail "(timeout) ptype signed long pointer" } | |
449 | #} | |
450 | # | |
451 | # | |
452 | #send "ptype v_unsigned_long_pointer\n" | |
453 | #gdb_expect { | |
454 | # -re "type = unsigned long \*.*$gdb_prompt $" { pass "ptype unsigned long pointer" } | |
455 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long pointer" } | |
456 | # timeout { fail "(timeout) ptype unsigned long pointer" } | |
457 | #} | |
458 | # | |
459 | # | |
460 | #send "ptype v_float_pointer\n" | |
461 | #gdb_expect { | |
462 | # -re "type = float \*.*$gdb_prompt $" { pass "ptype float pointer" } | |
463 | # -re ".*$gdb_prompt $" { fail "ptype float pointer" } | |
464 | # timeout { fail "(timeout) ptype float pointer" } | |
465 | #} | |
466 | # | |
467 | # | |
468 | #send "ptype v_double_pointer\n" | |
469 | #gdb_expect { | |
470 | # -re "type = double \*.*$gdb_prompt $" { pass "ptype double pointer" } | |
471 | # -re ".*$gdb_prompt $" { fail "ptype double pointer" } | |
472 | # timeout { fail "(timeout) ptype double pointer" } | |
473 | #} | |
474 | ||
475 | # | |
476 | # test ptype command with nested structure and union | |
477 | # | |
085dd6e6 JM |
478 | gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\ |
479 | .*int outer_int;.*\[\r\n\]+\ | |
b6304613 SM |
480 | .*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\ |
481 | .*(union|) inner_union inner_union_instance;.*\[\r\n\]+\ | |
482 | .*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure" | |
c906108c | 483 | |
b6304613 | 484 | gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure" |
c906108c | 485 | |
b6304613 | 486 | gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union" |
c906108c | 487 | |
b6304613 | 488 | gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] (struct |)inner_struct inner_struct_instance;.*\[\r\n\] (union |)inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure" |
c906108c | 489 | |
b6304613 | 490 | gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int" |
c906108c | 491 | |
b6304613 | 492 | gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2" |
c906108c | 493 | |
b6304613 | 494 | gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int" |
c906108c | 495 | |
b6304613 | 496 | gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union" |
c906108c | 497 | |
919809b9 JB |
498 | # Print the type description of variable the_highest, and verify that |
499 | # the type description for the fields whose type is anonymous are | |
500 | # correctly printed (at nesting level 1 and 2). | |
501 | ||
502 | gdb_test "ptype the_highest" \ | |
11af934b | 503 | "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" |
919809b9 JB |
504 | |
505 | # Print the type descrption for one of the fields of variable the_highest. | |
506 | # The purpose is to verify that the type of a field that was printed above | |
507 | # as "struct {...}" is now printed in a more descriptive way (because the | |
508 | # nesting level is now one level less). | |
509 | ||
510 | gdb_test "ptype the_highest.anonymous_level_1" \ | |
511 | "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ | |
512 | "ptype the_highest" | |
a640f7fc JB |
513 | |
514 | get_debug_format | |
515 | ||
516 | # Print the type of the identifier ID, and check the response: | |
517 | # - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular | |
518 | # expression; it's a literal string. | |
519 | # - If we instead see the unprototyped type PLAIN, and we're using STABS | |
520 | # generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits | |
521 | # prototyped function types in STABS. Like PROTOTYPED, PLAIN is a | |
522 | # literal string, not a regular expression. | |
a6c727b2 DJ |
523 | # - If we see OVERPROTOTYPED, it's an xfail for RealView; RealView |
524 | # does not distinguish prototyped and unprototyped functions, and | |
525 | # GDB defaults to prototyped. | |
a640f7fc | 526 | # - Otherwise, it's a failure. |
a6c727b2 | 527 | proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } { |
a640f7fc JB |
528 | global gdb_prompt |
529 | global gcc_compiled | |
530 | ||
a6c727b2 | 531 | # Turn the arguments, which are literal strings, into |
a640f7fc | 532 | # regular expressions by quoting any special characters they contain. |
a6c727b2 DJ |
533 | foreach var { prototyped plain overprototyped } { |
534 | eval "set val \$$var" | |
535 | regsub -all "\[\]\[*()\]" $val "\\\\&" val | |
536 | regsub -all "short int" $val "short( int)?" val | |
537 | regsub -all "long int" $val "long( int)?" val | |
538 | eval "set $var \$val" | |
539 | } | |
a640f7fc | 540 | |
65731a6b | 541 | gdb_test_multiple "ptype $id" "ptype $id" { |
a640f7fc JB |
542 | -re "type = $prototyped\[\r\n\]+$gdb_prompt $" { |
543 | pass "ptype $id" | |
544 | } | |
545 | -re "type = $plain\[\r\n\]+$gdb_prompt $" { | |
546 | if {$gcc_compiled} { setup_xfail_format "stabs" } | |
547 | fail "ptype $id (compiler doesn't emit prototyped types)" | |
548 | } | |
a6c727b2 DJ |
549 | -re "type = $overprototyped\[\r\n\]+$gdb_prompt $" { |
550 | if { [test_compiler_info "armcc-*"] } { | |
551 | setup_xfail "*-*-*" | |
552 | } | |
553 | fail "ptype $id (compiler doesn't emit unprototyped types)" | |
554 | } | |
a640f7fc JB |
555 | } |
556 | } | |
557 | ||
558 | ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \ | |
559 | "int (*)()" | |
a6c727b2 DJ |
560 | ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \ |
561 | "double (*)(void)" | |
a640f7fc JB |
562 | ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()" |
563 | ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()" | |
564 | ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \ | |
565 | "int *(*)()" | |
566 | ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \ | |
a6c727b2 DJ |
567 | "int (*)()" \ |
568 | "int (*)(int (*)(void), int (*)(void), int)" | |
a640f7fc JB |
569 | ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \ |
570 | "int (*(*)())()" | |
571 | ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \ | |
572 | "int (*(*(*)())())()" | |
573 | ||
f4d85314 FF |
574 | # Test printing type of typedefs in different scopes, with same name |
575 | # but different type. | |
576 | ||
f6978de9 | 577 | gdb_test "list intfoo" ".*" |
f4d85314 | 578 | gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo" |
f6978de9 | 579 | gdb_test "list charfoo" ".*" |
f4d85314 | 580 | gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo" |
f6978de9 | 581 | gdb_test "list intfoo" ".*" |
f4d85314 | 582 | gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo" |
f6978de9 | 583 | gdb_test "list charfoo" ".*" |
f4d85314 FF |
584 | gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo" |
585 | ||
c906108c SS |
586 | # Test printing type of string constants and array constants, but |
587 | # requires a running process. These call malloc, and can take a long | |
588 | # time to execute over a slow serial link, so increase the timeout. | |
589 | ||
c906108c SS |
590 | if [runto_main] then { |
591 | ||
c906108c | 592 | if [target_info exists gdb,cannot_call_functions] { |
bc6c7af4 | 593 | unsupported "this target can not call functions" |
c906108c SS |
594 | continue |
595 | } | |
596 | ||
9846de1b JM |
597 | # We need to up this because this can be really slow on some boards. |
598 | # (malloc() is called as part of the test). | |
97f2ed50 DJ |
599 | set prev_timeout $timeout |
600 | set timeout 60 | |
9846de1b | 601 | |
c906108c SS |
602 | gdb_test "ptype \"abc\"" "type = char \\\[4\\\]" |
603 | gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]" | |
604 | gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]" | |
605 | gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]" | |
606 | gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]" | |
607 | gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]" | |
608 | gdb_test "ptype {4,5,6}\[2\]" "type = int" | |
63092375 | 609 | gdb_test "ptype *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory." |
ce75a98f | 610 | |
97f2ed50 DJ |
611 | set timeout $prev_timeout |
612 | ||
ce75a98f | 613 | # Test ptype of user register |
11af934b | 614 | gdb_test "ptype \$pc" "void \\(\\*\\)\\(\\)" |
c906108c | 615 | } |