]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc. |
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 | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
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. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program; if not, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Rob Savoye. (rob@cygnus.com) | |
21 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | # | |
27 | # test running programs | |
28 | # | |
29 | set prms_id 0 | |
30 | set bug_id 0 | |
31 | ||
32 | set testfile "ptype" | |
33 | set srcfile ${testfile}.c | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
36 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
37 | } | |
38 | ||
39 | # Create and source the file that provides information about the compiler | |
40 | # used to compile the test case. | |
41 | if [get_compiler_info ${binfile}] { | |
42 | return -1; | |
43 | } | |
44 | ||
45 | gdb_exit | |
46 | gdb_start | |
47 | gdb_reinitialize_dir $srcdir/$subdir | |
48 | gdb_load ${binfile} | |
49 | ||
50 | # Test ptype of unnamed enumeration members before any action causes | |
51 | # the partial symbol table to be expanded to full symbols. This fails | |
52 | # with stabs compilers which fail to use a nameless stab (such as | |
53 | # pre-2.4.5 versions of gcc and most non-gcc compilers). | |
54 | ||
55 | send_gdb "ptype red1\n" | |
56 | gdb_expect { | |
57 | -re "type = enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $"\ | |
58 | { | |
59 | # The workaround is in effect. As this is a compiler, not GDB, | |
60 | # bug, we'll make it a PASS but perhaps it should be an XFAIL. | |
61 | pass "ptype unnamed enumeration member (worked around)" | |
62 | } | |
63 | -re "type = enum \{red1, green1, blue1\}.*$gdb_prompt $"\ | |
64 | { pass "ptype unnamed enumeration member" } | |
65 | -re ".*$gdb_prompt $" { fail "ptype unnamed enumeration member" } | |
66 | timeout { fail "(timeout) ptype unnamed enumeration member" } | |
67 | } | |
68 | ||
69 | # | |
70 | # test ptype command with structures | |
71 | # | |
72 | # Here and elsewhere, we accept | |
73 | # "long", "long int", or "int" for long variables (whatis.exp already | |
74 | # has an XFAIL for "int" (Sun cc bug), so no need to fail it here). | |
75 | 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" | |
76 | ||
77 | ||
78 | # Test the equivalence between '.' and '->' for struct member references. | |
79 | ||
80 | if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then { | |
81 | return -1 | |
82 | } | |
83 | if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then { | |
84 | return -1 | |
85 | } | |
86 | if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then { | |
87 | return -1 | |
88 | } | |
89 | if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then { | |
90 | return -1 | |
91 | } | |
92 | ||
93 | ||
94 | # IBM's xlc puts out bogus stabs--the stuff field is type 42, | |
95 | # which isn't defined. | |
96 | ||
085dd6e6 | 97 | 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 |
98 | |
99 | # | |
100 | # test ptype command with unions | |
101 | # | |
102 | 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" | |
103 | ||
104 | # IBM's xlc puts out bogus stabs--the stuff field is type 42, | |
105 | # which isn't defined. | |
085dd6e6 | 106 | 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 |
107 | |
108 | # | |
109 | # test ptype command with enums | |
110 | # | |
111 | ||
112 | gdb_test "ptype primary" "type = enum .red, green, blue.*" "ptype unnamed enumeration" | |
113 | ||
114 | gdb_test "ptype enum colors" "type = enum colors \{yellow, purple, pink\}.*" "ptype named enumeration" | |
115 | ||
116 | ||
117 | # | |
118 | # test ptype command with enums as typedef | |
119 | # | |
085dd6e6 | 120 | gdb_test "ptype boolean" "type = enum (boolean |)\{FALSE, TRUE\}.*" "ptype unnamed typedef'd enumeration" |
c906108c SS |
121 | |
122 | # And check that whatis shows the name, not "enum {...}". | |
123 | # This probably fails for all DWARF 1 cases, so assume so for now. -fnf | |
124 | # The problem with xlc is that the stabs look like | |
125 | # :t51=eFALSE:0,TRUE:1,; | |
126 | # boolean:t55=51 | |
127 | # v_boolean:G51 | |
128 | # GDB's behavior is correct; the type which the variable is defined | |
129 | # as (51) doesn't have a name. Only 55 has a name. | |
130 | ||
085dd6e6 JM |
131 | if {!$gcc_compiled && !$hp_aCC_compiler} { |
132 | setup_xfail "rs6000-*-*" "i*86-*-sysv4*" "hppa*-*-*" # CLLbs14773 | |
133 | } | |
9846de1b | 134 | get_debug_format |
c906108c | 135 | setup_xfail_format "DWARF 1" |
085dd6e6 | 136 | gdb_test "whatis v_boolean" "type = (enum |)boolean" \ |
c906108c SS |
137 | "whatis unnamed typedef'd enum (compiler bug in IBM's xlc)" |
138 | ||
139 | # Same thing with struct and union. | |
085dd6e6 | 140 | gdb_test "ptype t_struct3" "type = struct (t_struct3 |)\{.* |
c906108c SS |
141 | *double v_double_member;.* |
142 | *int v_int_member;.*\}" "printing typedef'd struct" | |
143 | ||
085dd6e6 | 144 | gdb_test "ptype t_union3" "type = union (t_union3 |)\{.* |
c906108c SS |
145 | *double v_double_member;.* |
146 | *int v_int_member;.*\}" "printing typedef'd union" | |
147 | ||
085dd6e6 | 148 | gdb_test "ptype enum bvals" "type = enum bvals \{my_false, my_true\}.*" "ptype named typedef'd enumf'd enum" |
c906108c SS |
149 | |
150 | # | |
151 | # test ptype command with out-of-order enum values | |
152 | # | |
153 | gdb_test "ptype enum misordered" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype misordered enumeration" | |
154 | ||
155 | # | |
156 | # test ptype command with a named enum's value | |
157 | # | |
158 | gdb_test "ptype three" "type = enum misordered \{two = 2, one = 1, zero = 0, three = 3\}.*" "ptype named enumeration member" | |
159 | ||
160 | gdb_test "ptype red" "type = enum \{red, green, blue\}.*" "ptype unnamed enumeration member #2" | |
161 | ||
162 | # | |
163 | # test ptype command with basic C types | |
164 | # | |
165 | # I've commented most of this out because it duplicates tests in whatis.exp. | |
166 | # I've just left in a token test or 2 which is designed to test that ptype | |
167 | # acts like whatis for basic types. If it is thought to be necessary to | |
168 | # test both whatis and ptype for all the types, the tests should be | |
169 | # merged into whatis.exp, or else maintenance will be a royal pain -kingdon | |
170 | #setup_xfail "i960-*-*" 1821 | |
171 | #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*" | |
172 | #send "ptype v_char\n" | |
173 | #gdb_expect { | |
174 | # -re "type = char.*$gdb_prompt $" { pass "ptype char" } | |
175 | # -re ".*$gdb_prompt $" { fail "ptype char" } | |
176 | # timeout { fail "(timeout) ptype char" } | |
177 | #} | |
178 | # | |
179 | # | |
180 | #setup_xfail "mips-*-*" "a29k-*-*" | |
181 | #send "ptype v_signed_char\n" | |
182 | #gdb_expect { | |
183 | # -re "type = signed char.*$gdb_prompt $" { pass "ptype signed char" } | |
184 | # -re ".*$gdb_prompt $" { fail "ptype signed char" } | |
185 | # timeout { fail "(timeout) ptype signed char" } | |
186 | #} | |
187 | # | |
188 | # | |
189 | #send "ptype v_unsigned_char\n" | |
190 | #gdb_expect { | |
191 | # -re "type = unsigned char.*$gdb_prompt $" { pass "ptype unsigned char" } | |
192 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char" } | |
193 | # timeout { fail "(timeout) ptype unsigned char" } | |
194 | #} | |
195 | ||
196 | gdb_test "ptype v_short" "type = short(| int).*" "ptype short" | |
197 | ||
198 | #send "ptype v_signed_short\n" | |
199 | #gdb_expect { | |
200 | # -re "type = short.*$gdb_prompt $" { pass "ptype signed short" } | |
201 | # -re ".*$gdb_prompt $" { fail "ptype signed short" } | |
202 | # timeout { fail "(timeout) ptype signed short" } | |
203 | #} | |
204 | # | |
205 | # | |
206 | #send "ptype v_unsigned_short\n" | |
207 | #gdb_expect { | |
208 | # -re "type = unsigned short.*$gdb_prompt $" { pass "ptype unsigned short" } | |
209 | # -re ".*$gdb_prompt $" { fail "ptype unsigned short" } | |
210 | # timeout { fail "(timeout) ptype unsigned short" } | |
211 | #} | |
212 | ||
213 | ||
214 | gdb_test "ptype v_int" "type = int.*" "ptype int" | |
215 | ||
216 | #send "ptype v_signed_int\n" | |
217 | #gdb_expect { | |
218 | # -re "type = int.*$gdb_prompt $" { pass "ptype signed int" } | |
219 | # -re ".*$gdb_prompt $" { fail "ptype signed int" } | |
220 | # timeout { fail "(timeout) ptype signed int" } | |
221 | #} | |
222 | # | |
223 | # | |
224 | #send "ptype v_unsigned_int\n" | |
225 | #gdb_expect { | |
226 | # -re "type = unsigned int.*$gdb_prompt $" { pass "ptype unsigned int" } | |
227 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int" } | |
228 | # timeout { fail "(timeout) ptype unsigned int" } | |
229 | #} | |
230 | # | |
231 | # | |
232 | #send "ptype v_long\n" | |
233 | #gdb_expect { | |
234 | # -re "type = long.*$gdb_prompt $" { pass "ptype long" } | |
235 | # -re ".*$gdb_prompt $" { fail "ptype long" } | |
236 | # timeout { fail "(timeout) ptype long" } | |
237 | #} | |
238 | # | |
239 | # | |
240 | #send "ptype v_signed_long\n" | |
241 | #gdb_expect { | |
242 | # -re "type = long.*$gdb_prompt $" { pass "ptype signed long" } | |
243 | # -re ".*$gdb_prompt $" { fail "ptype signed long" } | |
244 | # timeout { fail "(timeout) ptype signed long" } | |
245 | #} | |
246 | # | |
247 | # | |
248 | #send "ptype v_unsigned_long\n" | |
249 | #gdb_expect { | |
250 | # -re "type = unsigned long.*$gdb_prompt $" { pass "ptype unsigned long" } | |
251 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long" } | |
252 | # timeout { fail "(timeout) ptype unsigned long" } | |
253 | #} | |
254 | # | |
255 | # | |
256 | #send "ptype v_float\n" | |
257 | #gdb_expect { | |
258 | # -re "type = float.*$gdb_prompt $" { pass "ptype float" } | |
259 | # -re ".*$gdb_prompt $" { fail "ptype float" } | |
260 | # timeout { fail "(timeout) ptype float" } | |
261 | #} | |
262 | # | |
263 | # | |
264 | #send "ptype v_double\n" | |
265 | #gdb_expect { | |
266 | # -re "type = double.*$gdb_prompt $" { pass "ptype double" } | |
267 | # -re ".*$gdb_prompt $" { fail "ptype double" } | |
268 | # timeout { fail "(timeout) ptype double" } | |
269 | #} | |
270 | ||
271 | ||
272 | # | |
273 | # test ptype command with arrays | |
274 | # | |
275 | #setup_xfail "i960-*-*" 1821 | |
276 | #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*" | |
277 | #send "ptype v_char_array\n" | |
278 | #gdb_expect { | |
279 | # -re "type = char .2..*$gdb_prompt $" { pass "ptype char array" } | |
280 | # -re ".*$gdb_prompt $" { fail "ptype char array" } | |
281 | # timeout { fail "(timeout) ptype char array" } | |
282 | #} | |
283 | # | |
284 | # | |
285 | #setup_xfail "mips-*-*" "a29k-*-*" | |
286 | #send "ptype v_signed_char_array\n" | |
287 | #gdb_expect { | |
288 | # -re "type = (|signed )char .2..*$gdb_prompt $" { pass "ptype signed char array" } | |
289 | # -re ".*$gdb_prompt $" { fail "ptype signed char array" } | |
290 | # timeout { fail "(timeout) ptype signed char array" } | |
291 | #} | |
292 | # | |
293 | # | |
294 | #send "ptype v_unsigned_char_array\n" | |
295 | #gdb_expect { | |
296 | # -re "type = unsigned char .2..*$gdb_prompt $" { pass "ptype unsigned char array" } | |
297 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char array" } | |
298 | # timeout { fail "(timeout) ptype unsigned char array" } | |
299 | #} | |
300 | # | |
301 | # | |
302 | # | |
303 | #send "ptype v_int_array\n" | |
304 | #gdb_expect { | |
305 | # -re "type = int .2..*$gdb_prompt $" { pass "ptype int array" } | |
306 | # -re ".*$gdb_prompt $" { fail "ptype int array" } | |
307 | # timeout { fail "(timeout) ptype int array" } | |
308 | #} | |
309 | # | |
310 | # | |
311 | #send "ptype v_signed_int_array\n" | |
312 | #gdb_expect { | |
313 | # -re "type = int .2..*$gdb_prompt $" { pass "ptype signed int array" } | |
314 | # -re ".*$gdb_prompt $" { fail "ptype signed int array" } | |
315 | # timeout { fail "(timeout) ptype signed int array" } | |
316 | #} | |
317 | # | |
318 | # | |
319 | #send "ptype v_unsigned_int_array\n" | |
320 | #gdb_expect { | |
321 | # -re "type = unsigned int .2..*$gdb_prompt $" { pass "ptype unsigned int array" } | |
322 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int array" } | |
323 | # timeout { fail "(timeout) ptype unsigned int array" } | |
324 | #} | |
325 | # | |
326 | # | |
327 | #send "ptype v_long_array\n" | |
328 | #gdb_expect { | |
329 | # -re "type = (long|int|long int) .2..*$gdb_prompt $" { | |
330 | # pass "ptype long array" } | |
331 | # -re ".*$gdb_prompt $" { fail "ptype long array" } | |
332 | # timeout { fail "(timeout) ptype long array" } | |
333 | #} | |
334 | # | |
335 | # | |
336 | #send "ptype v_signed_long_array\n" | |
337 | #gdb_expect { | |
338 | # -re "type = (long|int|long int) .2..*$gdb_prompt $" { | |
339 | # pass "ptype signed long array" } | |
340 | # -re ".*$gdb_prompt $" { fail "ptype signed long array" } | |
341 | # timeout { fail "(timeout) ptype signed long array" } | |
342 | #} | |
343 | # | |
344 | # | |
345 | #send "ptype v_unsigned_long_array\n" | |
346 | #gdb_expect { | |
347 | # -re "type = unsigned long .2..*$gdb_prompt $" { pass "ptype unsigned long array" } | |
348 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long array" } | |
349 | # timeout { fail "(timeout) ptype unsigned long array" } | |
350 | #} | |
351 | # | |
352 | # | |
353 | #send "ptype v_float_array\n" | |
354 | #gdb_expect { | |
355 | # -re "type = float .2..*$gdb_prompt $" { pass "ptype float array" } | |
356 | # -re ".*$gdb_prompt $" { fail "ptype float array" } | |
357 | # timeout { fail "(timeout) ptype float array" } | |
358 | #} | |
359 | # | |
360 | # | |
361 | #send "ptype v_double_array\n" | |
362 | #gdb_expect { | |
363 | # -re "type = double .2..*$gdb_prompt $" { pass "ptype double array" } | |
364 | # -re ".*$gdb_prompt $" { fail "ptype double array" } | |
365 | # timeout { fail "(timeout) ptype double array" } | |
366 | #} | |
367 | # | |
368 | ||
369 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "i*86-*-sysv4*" } | |
370 | setup_xfail_format "DWARF 1" | |
085dd6e6 | 371 | if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"} |
c906108c SS |
372 | gdb_test "ptype t_char_array" "type = (|unsigned )char \\\[0?\\\]" |
373 | ||
374 | # | |
375 | ## | |
376 | ## test ptype command with pointers | |
377 | ## | |
378 | #setup_xfail "i960-*-*" 1821 | |
379 | #setup_xfail "mips-idt-*" "mips-sgi-*" "a29k-*-*" | |
380 | #send "ptype v_char_pointer\n" | |
381 | #gdb_expect { | |
382 | # -re "type = char \*.*$gdb_prompt $" { pass "ptype char pointer" } | |
383 | # -re ".*$gdb_prompt $" { fail "ptype char pointer" } | |
384 | # timeout { fail "(timeout) ptype char pointer" } | |
385 | #} | |
386 | # | |
387 | # | |
388 | #setup_xfail "mips-*-*" "a29k-*-*" | |
389 | #send "ptype v_signed_char_pointer\n" | |
390 | #gdb_expect { | |
391 | # -re "type = (|signed )char \*.*$gdb_prompt $" | |
392 | # { pass "ptype signed char pointer" } | |
393 | # -re ".*$gdb_prompt $" { fail "ptype signed char pointer" } | |
394 | # timeout { fail "(timeout) ptype signed char pointer" } | |
395 | #} | |
396 | # | |
397 | # | |
398 | #send "ptype v_unsigned_char_pointer\n" | |
399 | #gdb_expect { | |
400 | # -re "type = unsigned char \*.*$gdb_prompt $" { pass "ptype unsigned char pointer" } | |
401 | # -re ".*$gdb_prompt $" { fail "ptype unsigned char pointer" } | |
402 | # timeout { fail "(timeout) ptype unsigned char pointer" } | |
403 | #} | |
404 | # | |
405 | # | |
406 | #send "ptype v_short_pointer\n" | |
407 | #gdb_expect { | |
408 | # -re "type = (short|short int) \*.*$gdb_prompt $" { pass "ptype short pointer" } | |
409 | # -re ".*$gdb_prompt $" { fail "ptype short pointer" } | |
410 | # timeout { fail "(timeout) ptype short pointer" } | |
411 | #} | |
412 | # | |
413 | # | |
414 | #send "ptype v_signed_short_pointer\n" | |
415 | #gdb_expect { | |
416 | # -re "type = short \*.*$gdb_prompt $" { pass "ptype signed short pointer" } | |
417 | # -re ".*$gdb_prompt $" { fail "ptype signed short pointer" } | |
418 | # timeout { fail "(timeout) ptype signed short pointer" } | |
419 | #} | |
420 | # | |
421 | # | |
422 | #send "ptype v_unsigned_short_pointer\n" | |
423 | #gdb_expect { | |
424 | # -re "type = unsigned short \*.*$gdb_prompt $" { pass "ptype unsigned short pointer" } | |
425 | # -re ".*$gdb_prompt $" { fail "ptype unsigned short pointer" } | |
426 | # timeout { fail "(timeout) ptype unsigned short pointer" } | |
427 | #} | |
428 | # | |
429 | # | |
430 | #send "ptype v_int_pointer\n" | |
431 | #gdb_expect { | |
432 | # -re "type = int \*.*$gdb_prompt $" { pass "ptype int pointer" } | |
433 | # -re ".*$gdb_prompt $" { fail "ptype int pointer" } | |
434 | # timeout { fail "(timeout) ptype int pointer" } | |
435 | #} | |
436 | # | |
437 | # | |
438 | #send "ptype v_signed_int_pointer\n" | |
439 | #gdb_expect { | |
440 | # -re "type = int \*.*$gdb_prompt $" { pass "ptype signed int pointer" } | |
441 | # -re ".*$gdb_prompt $" { fail "ptype signed int pointer" } | |
442 | # timeout { fail "(timeout) ptype signed int pointer" } | |
443 | #} | |
444 | # | |
445 | # | |
446 | #send "ptype v_unsigned_int_pointer\n" | |
447 | #gdb_expect { | |
448 | # -re "type = unsigned int \*.*$gdb_prompt $" { pass "ptype unsigned int pointer" } | |
449 | # -re ".*$gdb_prompt $" { fail "ptype unsigned int pointer" } | |
450 | # timeout { fail "(timeout) ptype unsigned int pointer" } | |
451 | #} | |
452 | # | |
453 | # | |
454 | #send "ptype v_long_pointer\n" | |
455 | #gdb_expect { | |
456 | # -re "type = long \*.*$gdb_prompt $" { pass "ptype long pointer" } | |
457 | # -re ".*$gdb_prompt $" { fail "ptype long pointer" } | |
458 | # timeout { fail "(timeout) ptype long pointer" } | |
459 | #} | |
460 | # | |
461 | # | |
462 | #send "ptype v_signed_long_pointer\n" | |
463 | #gdb_expect { | |
464 | # -re "type = long \*.*$gdb_prompt $" { pass "ptype signed long pointer" } | |
465 | # -re ".*$gdb_prompt $" { fail "ptype signed long pointer" } | |
466 | # timeout { fail "(timeout) ptype signed long pointer" } | |
467 | #} | |
468 | # | |
469 | # | |
470 | #send "ptype v_unsigned_long_pointer\n" | |
471 | #gdb_expect { | |
472 | # -re "type = unsigned long \*.*$gdb_prompt $" { pass "ptype unsigned long pointer" } | |
473 | # -re ".*$gdb_prompt $" { fail "ptype unsigned long pointer" } | |
474 | # timeout { fail "(timeout) ptype unsigned long pointer" } | |
475 | #} | |
476 | # | |
477 | # | |
478 | #send "ptype v_float_pointer\n" | |
479 | #gdb_expect { | |
480 | # -re "type = float \*.*$gdb_prompt $" { pass "ptype float pointer" } | |
481 | # -re ".*$gdb_prompt $" { fail "ptype float pointer" } | |
482 | # timeout { fail "(timeout) ptype float pointer" } | |
483 | #} | |
484 | # | |
485 | # | |
486 | #send "ptype v_double_pointer\n" | |
487 | #gdb_expect { | |
488 | # -re "type = double \*.*$gdb_prompt $" { pass "ptype double pointer" } | |
489 | # -re ".*$gdb_prompt $" { fail "ptype double pointer" } | |
490 | # timeout { fail "(timeout) ptype double pointer" } | |
491 | #} | |
492 | ||
493 | # | |
494 | # test ptype command with nested structure and union | |
495 | # | |
085dd6e6 JM |
496 | if {$hp_aCC_compiler} { |
497 | set outer "outer_struct::" | |
498 | set struct "" | |
499 | set union "" | |
500 | } else { | |
501 | set outer "" | |
502 | set struct "struct" | |
503 | set union "union" | |
504 | } | |
505 | gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\ | |
506 | .*int outer_int;.*\[\r\n\]+\ | |
507 | .*(struct|) ${outer}inner_struct inner_struct_instance;.*\[\r\n\]+\ | |
508 | .*(union|) ${outer}inner_union inner_union_instance;.*\[\r\n\]+\ | |
509 | .*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure" | |
c906108c | 510 | |
085dd6e6 | 511 | gdb_test "ptype ${struct} ${outer}inner_struct" "type = struct ${outer}inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure" |
c906108c | 512 | |
085dd6e6 | 513 | gdb_test "ptype ${union} ${outer}inner_union" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union" |
c906108c | 514 | |
085dd6e6 | 515 | gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\] int outer_int;.*\[\r\n\] (struct |)${outer}inner_struct inner_struct_instance;.*\[\r\n\] (union |)${outer}inner_union inner_union_instance;.*\[\r\n\] (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure" |
c906108c SS |
516 | |
517 | gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int" | |
518 | ||
085dd6e6 | 519 | gdb_test "ptype nested_su.inner_struct_instance" "type = struct ${outer}inner_struct \{.*\[\r\n\] int inner_int;.*\[\r\n\] (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2" |
c906108c SS |
520 | |
521 | gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int" | |
522 | ||
085dd6e6 | 523 | gdb_test "ptype nested_su.inner_union_instance" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union" |
c906108c SS |
524 | |
525 | # Test printing type of string constants and array constants, but | |
526 | # requires a running process. These call malloc, and can take a long | |
527 | # time to execute over a slow serial link, so increase the timeout. | |
528 | ||
529 | # UDI can't do this (PR 2416). XFAIL is not suitable, because attempting | |
530 | # the operation causes a slow painful death rather than a nice simple failure. | |
531 | ||
532 | if [runto_main] then { | |
533 | ||
c906108c SS |
534 | if [target_info exists gdb,cannot_call_functions] { |
535 | setup_xfail "*-*-*" 2416 | |
536 | fail "This target can not call functions" | |
537 | continue | |
538 | } | |
539 | ||
9846de1b JM |
540 | # We need to up this because this can be really slow on some boards. |
541 | # (malloc() is called as part of the test). | |
542 | set timeout 60; | |
543 | ||
c906108c SS |
544 | gdb_test "ptype \"abc\"" "type = char \\\[4\\\]" |
545 | gdb_test "ptype {'a','b','c'}" "type = char \\\[3\\\]" | |
546 | gdb_test "ptype {0,1,2}" "type = int \\\[3\\\]" | |
547 | gdb_test "ptype {(long)0,(long)1,(long)2}" "type = long \\\[3\\\]" | |
548 | gdb_test "ptype {(float)0,(float)1,(float)2}" "type = float \\\[3\\\]" | |
549 | gdb_test "ptype {{0,1,2},{3,4,5}}" "type = int \\\[2\\\]\\\[3\\\]" | |
550 | gdb_test "ptype {4,5,6}\[2\]" "type = int" | |
551 | gdb_test "ptype *&{4,5,6}\[1\]" "type = int" | |
552 | } |