* builtins.exp, pr-5016.{ch,exp}, result.{ch,exp},
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.chill / tests1.exp
1 # Copyright (C) 1995 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 tests various Chill values, expressions, and types.
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 if [skip_chill_tests] then { continue }
27
28 set testfile "tests1"
29 set srcfile ${srcdir}/$subdir/${testfile}.ch
30 set binfile ${objdir}/${subdir}/${testfile}.exe
31 if { [compile "${srcfile} -g -w -o ${binfile} ${CHILL_RT0} ${CHILL_LIB}"] != "" } {
32 perror "Couldn't compile ${srcfile}"
33 return -1
34 }
35
36 # Set the current language to chill. This counts as a test. If it
37 # fails, then we skip the other tests.
38
39 proc set_lang_chill {} {
40 global prompt
41 global binfile objdir subdir
42
43 verbose "loading file '$binfile'"
44 gdb_load $binfile
45 send "set language chill\n"
46 expect {
47 -re ".*$prompt $" {}
48 timeout { fail "set language chill (timeout)" ; return 0 }
49 }
50
51 send "show language\n"
52 expect {
53 -re ".* source language is \"chill\".*$prompt $" {
54 pass "set language to \"chill\""
55 send "break dummyfunc\n"
56 expect {
57 -re ".*$prompt $" {
58 send "run\n"
59 expect -re ".*$prompt $" {}
60 return 1
61 }
62 timeout {
63 fail "can't set breakpoint (timeout)"
64 return 0
65 }
66 }
67 }
68 -re ".*$prompt $" {
69 fail "setting language to \"chill\""
70 return 0
71 }
72 timeout {
73 fail "can't show language (timeout)"
74 return 0
75 }
76 }
77 }
78
79 # Testing printing of a specific value. Increment passcount for
80 # success or issue fail message for failure. In both cases, return
81 # a 1 to indicate that more tests can proceed. However a timeout
82 # is a serious error, generates a special fail message, and causes
83 # a 0 to be returned to indicate that more tests are likely to fail
84 # as well.
85 #
86 # Args are:
87 #
88 # First one is string to send to gdb
89 # Second one is string to match gdb result to
90 # Third one is an optional message to be printed
91
92 proc test_print_accept { args } {
93 global prompt
94 global passcount
95 global verbose
96
97 if [llength $args]==3 then {
98 set message [lindex $args 2]
99 } else {
100 set message [lindex $args 0]
101 }
102 set sendthis [lindex $args 0]
103 set expectthis [lindex $args 1]
104 set result [gdb_test $sendthis ".* = ${expectthis}" $message]
105 if $result==0 {incr passcount}
106 return $result
107 }
108
109 # Testing printing of a specific value. Increment passcount for
110 # success or issue fail message for failure. In both cases, return
111 # a 1 to indicate that more tests can proceed. However a timeout
112 # is a serious error, generates a special fail message, and causes
113 # a 0 to be returned to indicate that more tests are likely to fail
114 # as well.
115
116 # various tests if modes are treated correctly
117 # using ptype
118 proc test_modes {} {
119 global passcount
120
121 verbose "testing chill modes"
122 set passcount 0
123
124 # discrete modes
125 test_print_accept "ptype BYTE" "byte"
126 test_print_accept "ptype UBYTE" "ubyte"
127 test_print_accept "ptype INT" "int"
128 test_print_accept "ptype UINT" "uint"
129 test_print_accept "ptype LONG" "long"
130 test_print_accept "ptype ULONG" "ulong"
131 test_print_accept "ptype BOOL" "bool"
132 test_print_accept "ptype CHAR" "char"
133
134 test_print_accept "ptype set1" "SET \[(\]aaa, bbb, ccc\[)\]" \
135 "print unnumbered set mode"
136 test_print_accept "ptype nset1" "SET \[(\]na = 1, nb = 34, nc = 20\[)\]" \
137 "print numbered set mode"
138
139 # mp:
140 # display maybe in hex values ?
141 #
142 test_print_accept "ptype r11" "ubyte \\(0:255\\)" \
143 "print ubyte range mode"
144 test_print_accept "ptype r12" "uint \\(0:65535\\)" \
145 "print uint range mode"
146 # test_print_accept "ptype r13" "ulong \\(0:4294967295\\)" \
147 # "print ulong range mode"
148 test_print_accept "ptype r14" "byte \\(-128:127\\)" \
149 "print byte range mode"
150 test_print_accept "ptype r15" "int \\(-32768:32767\\)" \
151 "print int range mode"
152 test_print_accept "ptype r16" "long \\(-2147483648:2147483647\\)" \
153 "print long range mode"
154
155 test_print_accept "ptype r2" "set1 \\(bbb:ccc\\)" \
156 "print unnumbered set range mode"
157 setup_xfail "*-*-*"
158 test_print_accept "ptype r3" "nset1 \\(na:na\\)" \
159 "print numbered set range mode"
160 # really this order ?
161 # I'm not sure what should happen for the next two tests.
162 setup_xfail "*-*-*"
163 test_print_accept "ptype r4" "nset1 \\(nb = 34:nc = 20\\)" \
164 "print numbered set range mode"
165 setup_xfail "*-*-*"
166 test_print_accept "ptype r5" "nset1 \\(na = 1, nb = 34, nc = 20\\)" \
167 "print numbered set range mode"
168
169 # powerset modes
170 test_print_accept "ptype pm1" \
171 "POWERSET SET \[(\]p1, p2, p3, p4, p5, p6, p7, p8, p9, p10\[)\]" \
172 "print powerset mode 1"
173 test_print_accept "ptype pm2" "POWERSET byte \\(1:8\\)" \
174 "print powerset mode 2"
175 test_print_accept "ptype pm3" "POWERSET int \\(-32768:32767\\)" \
176 "print powerset mode 3"
177 test_print_accept "ptype pm4" "POWERSET long \\(-32768:32768\\)" \
178 "print powerset mode 4"
179 test_print_accept "ptype pm5" \
180 "POWERSET long \\(-2147483648:2147483647\\)" \
181 "print powerset mode 5"
182
183 # reference modes
184 test_print_accept "ptype ref1" "REF pm1" \
185 "print reference to powerset mode"
186 test_print_accept "ptype ref2" "REF byte" \
187 "print reference to byte"
188 test_print_accept "ptype ref3" "PTR" \
189 "print free reference type"
190
191 # procedure modes
192 # FIXME: we have to talk about this ...
193 test_print_accept "ptype prm1" \
194 "REF PROC \[(\]\[)\]" \
195 "print procedure mode 1"
196 setup_xfail "*-*-*"
197 test_print_accept "ptype prm2" \
198 "REF PROC \[(\]bool in, int out long inout\[)\] RETURNS \[(\]char\[)\]" \
199 "print procedure mode 2"
200 setup_xfail "*-*-*"
201 test_print_accept "ptype prm3" \
202 "REF PROC \[(\]pm1, ref loc\[)\] RETURNS \[(\]ref3\[)\]" \
203 "print procedure mode 3"
204 setup_xfail "*-*-*"
205 test_print_accept "ptype prm4" \
206 "\[(\] \[)\] EXCEPTIONS \[(\]ex1, ex2, ex3\[)\]" \
207 "print procedure mode 4"
208 setup_xfail "*-*-*"
209 test_print_accept "ptype prm5" \
210 "REF PROC \[(\]r11, r16 inout, r5 out\[)\] RETURNS \[(\]r2\[)\] EXCEPTIONS \[(\]ex1\[)\]" \
211 "print procedure mode 5"
212
213 # synchronization modes
214 # FIXME: since gdb doesn't process events & buffers so far, this has be
215 # filled later...
216 xfail "synchronization mode handling"
217
218 # timing modes
219 test_print_accept "ptype DURATION" "duration"
220 test_print_accept "ptype TIME" "time"
221
222 # string modes
223 # some tests are done in chillvars.exp
224 test_print_accept "ptype strm1" "CHARS \\(5\\)" "print char string mode"
225 test_print_accept "ptype strm2" "CHARS \[(\]7\[)\] VARYING" \
226 "print varying char string mode"
227 test_print_accept "ptype bstr1" "BOOLS \\(20\\)" "print bit string mode"
228
229 test_print_accept "ptype B'000'" "BOOLS \\(3\\)" "bit string literal"
230 test_print_accept "ptype B'11110000'" "BOOLS \\(8\\)" "bit string literal"
231 # FIXME: adjust error message
232 gdb_test "ptype B'00110211'" {.*Too-large digit.*[.]} \
233 "reject invalid bitstring"
234
235 # array modes
236 # some tests are done in chillvars.exp
237 test_print_accept "ptype arr1m" "ARRAY \\(1:100\\) set1" \
238 "print array mode 1"
239 test_print_accept "ptype arr2m" "ARRAY \\(1:100\\) ARRAY \\(1:100\\) set1"\
240 "print array mode 2"
241 test_print_accept "ptype arr3m" "ARRAY \\(0:255\\) ARRAY \\(0:65535\\) ARRAY \\(-128:127\\) set1" \
242 "print array mode 3"
243 setup_xfail "*-*-*"
244 test_print_accept "ptype arr4m" "ARRAY \\(b:c\\) ARRAY \\(na = 1:na = 1\\) ARRAY \\(nc:nb\\) ARRAY \\(na = 1:nc = 20\\) POWERSET SET \[(\]p1, p2, p3, p4, p5, p6, p7, p8, p9, p10\[)\]" \
245 "print array mode 4"
246
247 # structure modes
248 # some checks are in chillvars.exp
249 # setup_xfail "*-*-*"
250 test_print_accept "ptype stru1m" "STRUCT \\(.*a long,.*b long,.*CASE OF.*:.*ch1 CHARS \\(20\\).*:.*ch2 CHARS \\(10\\).*ELSE.*ch3 CHARS \\(1\\).*ESAC.*\\)" \
251 "print structure mode 1"
252 #setup_xfail "*-*-*"
253 test_print_accept "ptype stru2m" "STRUCT \\(.*f set1,.*CASE OF.*:.*ch1 CHARS \\(20\\).*:.*ch2 CHARS \\(10\\) VARYING.*ELSE.*ch3 CHARS \\(0\\) VARYING.*ESAC.*\\)" \
254 "print structure mode 2"
255 #setup_xfail "*-*-*"
256 test_print_accept "ptype stru3m" "STRUCT \\(.*f r3,.*CASE OF.*:.*ch1 CHARS \\(20\\).*ESAC.*\\)" \
257 "print structure mode 3"
258 # setup_xfail "*-*-*"
259 test_print_accept "ptype stru4m" "STRUCT \\(.*i long,.*CASE OF.*:.*i1 int,.*i11 int,.*b1 bool,.*c1 char.*:.*i2 long,.*i22 long,.*bs2 BOOLS \\(10\\).*:.*s3 STRUCT \\(.*i3 int,.*CASE OF.*:.*foo long.*ELSE.*bar char.*ESAC.*\\).*ELSE.*x stru2m.*ESAC,.*y stru3m.*\\)" \
260 "print structure mode 4"
261
262
263 if $passcount then {
264 pass "$passcount correct modes printed"
265 }
266 }
267
268 # various tests if locations are treated correctly
269 # read access using ptype, print, whatis
270 proc test_locations {} {
271 global passcount
272
273 set passcount 0
274 verbose "testing read access to locations"
275 # various location tests can be found in chillvars.exp
276
277 # set locations
278 test_print_accept "ptype s1l" "SET \\(aaa, bbb, ccc\\)" \
279 "print mode of set location"
280 test_print_accept "whatis s1l" "set1" \
281 "print modename of set location"
282 test_print_accept "print s1l" "ccc" "print set location"
283 test_print_accept "ptype s2l" "SET \\(na = 1, nb = 34, nc = 20\\)" \
284 "print mode of numbered set location"
285 test_print_accept "whatis s2l" "nset1" \
286 "print mode name of numbered set location"
287 test_print_accept "print s2l" "nb" "print numberes set location"
288
289 # range modes
290 test_print_accept "ptype rl1" "ubyte \\(0:255\\)" \
291 "print mode of range location"
292 test_print_accept "whatis rl1" "r11" \
293 "print mode name of range location"
294 test_print_accept "print rl1" "3" \
295 "print range location"
296
297 test_print_accept "ptype rl2" "ubyte \\(0:255\\)" \
298 "print mode of range location"
299 test_print_accept "whatis rl2" "r11" \
300 "print mode name of range location"
301 test_print_accept "print rl2" "0" \
302 "print range location"
303
304 test_print_accept "ptype rl3" "ubyte \\(0:255\\)" \
305 "print mode of range location"
306 test_print_accept "whatis rl3" "r11" \
307 "print mode name of range location"
308 test_print_accept "print rl3" "255" \
309 "print range location"
310
311 test_print_accept "ptype rl5" "uint \\(0:65535\\)" \
312 "print mode of range location"
313 test_print_accept "whatis rl5" "r12" \
314 "print mode name of range location"
315 test_print_accept "print rl5" "65530" \
316 "print range location"
317
318 test_print_accept "ptype rl6" "uint \\(0:65535\\)" \
319 "print mode of range location"
320 test_print_accept "whatis rl6" "r12" \
321 "print mode name of range location"
322 test_print_accept "print rl6" "0" \
323 "print range location"
324
325 test_print_accept "ptype rl7" "uint \\(0:65535\\)" \
326 "print mode of range location"
327 test_print_accept "whatis rl7" "r12" \
328 "print mode name of range location"
329 test_print_accept "print rl7" "65535" \
330 "print range location"
331
332 # test_print_accept "ptype rl9" "ulong \\(0:4294967295\\)" \
333 # "print mode of range location"
334 # test_print_accept "whatis rl9" "r13" \
335 # "print mode name of range location"
336 # test_print_accept "print rl9" "128" \
337 # "print range location"
338
339 # test_print_accept "ptype rl10" "ulong \\(0:4294967295\\)" \
340 # "print mode of range location"
341 # test_print_accept "whatis rl10" "r13" \
342 # "print mode name of range location"
343 # test_print_accept "print rl10" "0" \
344 # "print range location"
345
346 # test_print_accept "ptype rl11" "ulong \\(0:4294967295\\)" \
347 # "print mode of range location"
348 # test_print_accept "whatis rl11" "r13" \
349 # "print mode name of range location"
350 # test_print_accept "print rl11" "4294967295" \
351 # "print range location"
352
353 test_print_accept "ptype rl13" "byte \\(-128:127\\)" \
354 "print mode of range location"
355 test_print_accept "whatis rl13" "r14" \
356 "print mode name of range location"
357 test_print_accept "print rl13" "-121" \
358 "print range location"
359
360 test_print_accept "ptype rl14" "byte \\(-128:127\\)" \
361 "print mode of range location"
362 test_print_accept "whatis rl14" "r14" \
363 "print mode name of range location"
364 test_print_accept "print rl14" "-128" \
365 "print range location"
366
367 test_print_accept "ptype rl15" "byte \\(-128:127\\)" \
368 "print mode of range location"
369 test_print_accept "whatis rl15" "r14" \
370 "print mode name of range location"
371 test_print_accept "print rl15" "127" \
372 "print range location"
373
374 test_print_accept "ptype rl17" "int \\(-32768:32767\\)" \
375 "print mode of range location"
376 test_print_accept "whatis rl17" "r15" \
377 "print mode name of range location"
378 test_print_accept "print rl17" "-32720" \
379 "print range location"
380
381 test_print_accept "ptype rl18" "int \\(-32768:32767\\)" \
382 "print mode of range location"
383 test_print_accept "whatis rl18" "r15" \
384 "print mode name of range location"
385 test_print_accept "print rl18" "-32768" \
386 "print range location"
387
388 test_print_accept "ptype rl19" "int \\(-32768:32767\\)" \
389 "print mode of range location"
390 test_print_accept "whatis rl19" "r15" \
391 "print mode name of range location"
392 test_print_accept "print rl19" "32767" \
393 "print range location"
394
395 test_print_accept "ptype rl21" "long \\(-2147483648:2147483647\\)" \
396 "print mode of range location"
397 test_print_accept "whatis rl21" "r16" \
398 "print mode name of range location"
399 test_print_accept "print rl21" "2147483643" \
400 "print range location"
401
402 test_print_accept "ptype rl22" "long \\(-2147483648:2147483647\\)" \
403 "print mode of range location"
404 test_print_accept "whatis rl22" "r16" \
405 "print mode name of range location"
406 test_print_accept "print rl22" "-2147483648" \
407 "print range location"
408
409 test_print_accept "ptype rl23" "long \\(-2147483648:2147483647\\)" \
410 "print mode of range location"
411 test_print_accept "whatis rl23" "r16" \
412 "print mode name of range location"
413 test_print_accept "print rl23" "2147483647" \
414 "print range location"
415
416 # powerset locations
417 test_print_accept "ptype pl1" \
418 "POWERSET SET \\(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10\\)" \
419 "print mode of powerset location 1"
420 test_print_accept "whatis pl1" "pm1" \
421 "print mode mode name of powerset location"
422 test_print_accept "print pl1" \
423 "\[\[\]p1:p10\[\]\]" \
424 "print powerset location 1"
425 test_print_accept "print pl2" {\[\]} \
426 "print powerset location 2"
427 test_print_accept "print pl3" "\[\[\]p1, p10\[\]\]" \
428 "print powerset location 3"
429 test_print_accept "print pl4" {\[p1:p2, p4:p6, p8:p10\]} \
430 "print powerset location 4"
431 test_print_accept "print pl5" {\[p1:p4, p6, p8:p10\]} \
432 "print powerset location 5"
433 test_print_accept "print pl6" {\[p1, p3:p8, p10\]} \
434 "print powerset location 6"
435
436 test_print_accept "ptype pl7" \
437 "POWERSET byte \\(1:8\\)" \
438 "print mode of byte powerset location"
439 test_print_accept "whatis pl7" "pm2" \
440 "print modename of byte powerset location"
441 test_print_accept "print pl7" {\[1:8\]} \
442 "print powerset location 7"
443
444 test_print_accept "ptype pl8" \
445 "POWERSET int \\(-32768:32767\\)" \
446 "print mode of int powerset location"
447 test_print_accept "whatis pl8" "pm3" \
448 "print modename of int powerset location"
449 test_print_accept "print pl8" {\[-32768:32767\]} \
450 "print powerset location 8"
451
452 # test_print_accept "ptype pl9" \
453 # "POWERSET long \\(-2147483648:2147483647\\)" \
454 # "print mode of long powerset location"
455 # test_print_accept "whatis pl9" "pm5" \
456 # "print modename of long powerset location"
457 # test_print_accept "print pl9" {\[-2147483648:2147483647\]} \
458 # "print powerset location 9"
459
460 # reference modes
461 test_print_accept "ptype ref3l" "PTR" "print mode of reference location"
462 setup_xfail "*-*-*"
463 test_print_accept "whatis ref3l" "ref3" \
464 "print modename of reference location"
465 setup_xfail "*-*-*"
466 test_print_accept "print ref3l" "ref3\\(H'.*\\)" \
467 "print reference location"
468 test_print_accept "ptype ref4l" "PTR" "print mode of reference location"
469 setup_xfail "*-*-*"
470 test_print_accept "whatis ref4l" "ref4" \
471 "print modename of reference location"
472 setup_xfail "*-*-*"
473 test_print_accept "print ref4l" "ref4\\(H'.*\\)" \
474 "print reference location"
475 test_print_accept "ptype ref5l" "PTR" "print mode of reference location"
476 test_print_accept "whatis ref5l" "PTR" \
477 "print modename of reference location"
478 test_print_accept "print ref5l" "PTR\\(H'.*\\)" \
479 "print reference location"
480
481 # dereference a little bit..
482 test_print_accept "print ref6l->syn_int" "42" \
483 "dereference reference to synmode location"
484 test_print_accept "print ref7l->int" "-42" \
485 "dereference reference to predefined mode location"
486 test_print_accept "print ref8l->pm1" \
487 "\[\[\]p1:p10\[\]\]" \
488 "dereference reference to newmode location"
489
490 # synchronization mode locations
491 # FIXME: synchronization modes are not supported so far...
492 xfail "no synchronization mode location support, not implemented yet"
493
494 # timing mode locations
495 # FIXME: callbacks to abstime, inttime not implemented
496 xfail "timing modes not implemented properly yet"
497
498 # char string locations
499 # some tests are don in chillvars.exp
500 test_print_accept "ptype strl1" \
501 "CHARS \\(7\\) VARYING" \
502 "print varying string location"
503 test_print_accept "whatis strl1" "strm2" \
504 "print string locationa mode name"
505 test_print_accept "print strl1" \
506 "\"hansi\"//c\"00\"" \
507 "print string location"
508 # string elements
509 test_print_accept "print strl1(0)" "\'h\'" \
510 "print string element 1"
511 test_print_accept "print strl1(5)" "C\'00\'" \
512 "print string element 2"
513 test_print_accept "print strl1(3)" "\'s\'" \
514 "print string element 3"
515 test_print_accept "ptype strl1(0)" "char" \
516 "print mode of string element"
517 # slices
518 test_print_accept "print strl1(3:4)" "\"si\"" \
519 "print string slice 1"
520 test_print_accept "print strl1(0:5)" \
521 "\"hansi\"//c\"00\"" \
522 "print string slice 2"
523 test_print_accept "print strl1(0:0)" "\"h\"" \
524 "print string slice 3"
525 test_print_accept "print strl1(0 up 6)" \
526 "\"hansi\"//c\"00\"" \
527 "print string slice 4"
528 # FIXME: adjust error message, when implented
529 gdb_test "print strl1(6 up 1)" \
530 ".*slice.*out of range.*" \
531 "print invalid string slice length"
532 gdb_test "print strl1(-1 up 5)" \
533 ".*slice.*out of range.*" \
534 "print invalid string slice length"
535 gdb_test "print strl1(-1:5)" \
536 ".*slice.*out of range.*" \
537 "print invalid string slice"
538 gdb_test "print strl1(-1:7)" \
539 ".*slice.*out of range.*" \
540 "print invalid string slice"
541 gdb_test "print strl1(0 up -1)" \
542 ".*slice.*out of range.*" \
543 "print invalid string slice length"
544 gdb_test "print strl1(0 up 0)" {""}
545
546 # bitstring locations
547 test_print_accept "ptype bstr1" \
548 "BOOLS \\(20\\)" \
549 "print mode of bitstring location"
550 test_print_accept "whatis bstrl1" "bstr1" \
551 "print mode name of bitstring location"
552 test_print_accept "print bstrl1" \
553 "B'10101010101010101010'" \
554 "print bitstring location"
555
556 test_print_accept "ptype bstrl1(0)" "bool|BOOL" \
557 "print mode of bitstring element"
558 test_print_accept "print bstrl1(0)" "TRUE" \
559 "print bitstring element 1"
560 test_print_accept "print bstrl1(19)" "FALSE" \
561 "print bitstring element 2"
562 test_print_accept "print bstrl1(10)" "TRUE" \
563 "print bitstring element 3"
564
565 test_print_accept "print bstrl1(0:19)" \
566 "B'10101010101010101010'" \
567 "print bitstring location slice 1"
568 test_print_accept "print bstrl1(0:0)" \
569 "B'1'" \
570 "print bitstring location slice 2"
571 test_print_accept "print bstrl1(3:9)" \
572 "B'0101010'" \
573 "print bitstring location slice 3"
574 test_print_accept "print bstrl1(0 up 20)" \
575 "B'10101010101010101010'" \
576 "print bitstring location slice 4"
577 test_print_accept "print bstrl1(19 up 1)" \
578 "B'0'" \
579 "print bitstring location slice 5"
580 gdb_test "print bstrl1(20 up 1)" \
581 ".*slice out of range.*" \
582 "print invalid bitstring slice (20 up 1)"
583 gdb_test "print bstrl1(-4:5)" \
584 ".*slice out of range.*" \
585 "print invalid bitstring slice (-4:5)"
586 gdb_test "print bstrl1(-1:up 1)" \
587 ".*invalid expression syntax.*" \
588 "print invalid bitstring slice (-1:ip 1)"
589 gdb_test "print bstrl1(-1:20)" \
590 ".*slice out of range.*" \
591 "print invalid bitstring slice (-1:20)"
592 gdb_test "print bstrl1(0 up -1)" \
593 ".*slice out of range.*" \
594 "print invalid bitstring slice (0 up -1)"
595 test_print_accept "print bstrl1(4 up 0)" "B''"
596
597 # array mode locations
598 gdb_test_exact "ptype arrl1" \
599 "ARRAY (1:100) set1" \
600 "print mode of array location"
601 gdb_test "whatis arrl1" "arr1m" \
602 "print mode name of array location"
603 gdb_test_exact "print arrl1" {[(1:100): aaa]} \
604 "print array location"
605 test_print_accept "ptype arrl1(1)" \
606 "SET \\(aaa, bbb, ccc\\)" \
607 "print mode of array element"
608 gdb_test_exact "print arrl3" \
609 {[(1:5): [(1:3): [(1:2): -2147483648]]]} \
610 "print array location 2"
611 gdb_test_exact "print arrl3(1)" \
612 {[(1:3): [(1:2): -2147483648]]} \
613 "print array location 3"
614 gdb_test_exact "ptype arrl3(1)" \
615 {ARRAY (1:3) ARRAY (1:2) long} \
616 "print mode of array element"
617 test_print_accept "print arrl3(5)" \
618 {\[\(1:3\): \[\(1:2\): -2147483648\]\]} \
619 "print array location 4"
620 test_print_accept "print arrl3(1,1)" \
621 {\[\(1:2\): -2147483648\]} \
622 "print array location 5"
623 test_print_accept "ptype arrl3(1,1)" \
624 {ARRAY \(1:2\) long} \
625 "print mode of array element"
626 test_print_accept "print arrl3(5,3)" \
627 {\[\(1:2\): -2147483648\]} \
628 "print array location 6"
629 test_print_accept "print arrl3(1,1,1)" \
630 "-2147483648" \
631 "print array location 7"
632 test_print_accept "print arrl3(5,3,2)" \
633 "-2147483648" \
634 "print array location 8"
635 test_print_accept "print arrl3(1)(3)(2)" \
636 "-2147483648" \
637 "print array location 9"
638
639 # reject the following range fails
640 # FIXME: adjust error messages
641 gdb_test "print arrl3(-1)" \
642 ".*out of range.*" \
643 "check invalid array indices 1"
644 gdb_test "print arrl3(6)" \
645 ".*out of range.*" \
646 "check invalid array indices 2"
647 gdb_test "print arrl3(0,0)" \
648 ".*out of range.*" \
649 "check invalid array indices 3"
650 gdb_test "print arrl3(1,0)" \
651 ".*out of range.*" \
652 "check invalid array indices 4"
653 gdb_test "print arrl3(1,4)" \
654 ".*out of range.*" \
655 "check invalid array indices 5"
656 gdb_test "print arrl3(6,4)" \
657 ".*out of range.*" \
658 "check invalid array indices 6"
659 gdb_test "print arrl3(1,1,0)" \
660 ".*out of range.*" \
661 "check invalid array indices 7"
662 gdb_test "print arrl3(6,4,0)" \
663 ".*out of range.*" \
664 "check invalid array indices 8"
665 gdb_test "print arrl3(1,1,3)" \
666 ".*out of range.*" \
667 "check invalid array indices 9"
668
669 gdb_test "print arrl3(0)(0)" \
670 ".* array or string index out of range.*" \
671 "check invalid array indices 10"
672 gdb_test "print arrl3(1)(0)" \
673 ".* array or string index out of range.*" \
674 "check invalid array indices 11"
675 gdb_test "print arrl3(1)(4)" \
676 ".* array or string index out of range.*" \
677 "check invalid array indices 12"
678 gdb_test "print arrl3(6)(4)" \
679 ".* array or string index out of range.*" \
680 "check invalid array indices 13"
681 gdb_test "print arrl3(1)(1)(0)" \
682 ".* array or string index out of range.*" \
683 "check invalid array indices 14"
684 gdb_test "print arrl3(6)(4)(0)" \
685 ".* array or string index out of range.*" \
686 "check invalid array indices 15"
687 gdb_test "print arrl3(1)(1)(3)" \
688 ".* array or string index out of range.*" \
689 "check invalid array indices 16"
690
691 # slices
692 test_print_accept "print arrl4(1:3)" \
693 {\[\(1:2\): \[\(1:3\): \[\(1:2\): -2147483648\]\], \(3\): \[\(1:3\): \[\(1:2\): 100\]\]\]} \
694 "print array slice 1"
695 test_print_accept "ptype arrl4(1:3)" \
696 {ARRAY \(1:3\) ARRAY \(1:3\) ARRAY \(1:2\) long} \
697 "print mode of array slice"
698 # The next one is bogus:
699 # test_print_accept "print arrl4(5, 2:3, 1)" \
700 # # FIXME: maybe the '(1): ' in the inner tupel should be omitted ? \
701 # {\[(2): \[\(1\): 100\], \(3\):\[\(1\): 100\]\]} \
702 # "print array slice 2"
703 test_print_accept "print arrl4(1 up 4)" \
704 {\[\(1:2\): \[\(1:3\): \[\(1:2\): -2147483648\]\], \(3\): \[\(1:3\): \[\(1:2\): 100\]\], \(4\): \[\(1:3\): \[\(1:2\): -2147483648\]\]\]} \
705 "print array slice 3"
706 # The next two are bogus:
707 # test_print_accept "print arrl4(3, 2 up 1)" \
708 # {\[\(2:3\): \[\(1:2\): 100\]\]} \
709 # "print array slice 4"
710 # test_print_accept "print arrl4(1:2, 1 up 1, 2)" \
711 # {\[\(1\): \[\(1\): \[\(2\): -2147483648\], \(2\): \[\(2\): -2147483648\]\], \(2\): \[\(1\): \[\(2\): -2147483648\], \(2\): \[\(2\): -2147483648\]\]\]} \
712 # "print array slice 4"
713 # reject invalid slices
714 # FIXME: adjust error messages
715 gdb_test "print arrl4(5:6)" \
716 ".*slice out of range.*" \
717 "check invalid range 1"
718 gdb_test "print arrl4(0:1)" \
719 ".*slice out of range.*" \
720 "check invalid range 2"
721 gdb_test "print arrl4(0:6)" \
722 ".*slice out of range.*" \
723 "check invalid range 3"
724 gdb_test "print arrl4(3:2)" \
725 ".*slice out of range.*" \
726 "check invalid range 4"
727 gdb_test "print arrl4(1,3:4)" \
728 ".*syntax error.*" \
729 "check invalid range 5"
730 gdb_test "print arrl4(1,0:1)" \
731 ".*syntax error.*" \
732 "check invalid range 6"
733 gdb_test "print arrl4(1,0:4)" \
734 ".*syntax error.*" \
735 "check invalid range 7"
736 gdb_test "print arrl4(1,3:2)" \
737 ".*syntax error.*" \
738 "check invalid range 8"
739 gdb_test "print arrl4(5 up 2)" \
740 ".*slice out of range.*" \
741 "check invalid range 9"
742 gdb_test "print arrl4(-1 up 1)" \
743 ".*slice out of range.*" \
744 "check invalid range 10"
745 gdb_test "print arrl4(-1 up 7)" \
746 ".*slice out of range.*" \
747 "check invalid range 11"
748 gdb_test "print arrl4(1 up 0)" \
749 ".*slice out of range.*" \
750 "check invalid range 12"
751 gdb_test "print arrl4(1,3 up 1)" \
752 ".*syntax error.*" \
753 "check invalid range 13"
754 gdb_test "print arrl4(1,-1 up 1)" \
755 ".*syntax error.*" \
756 "check invalid range 14"
757 gdb_test "print arrl4(1,-1 up 5)" \
758 ".*syntax error.*" \
759 "check invalid range 15"
760 gdb_test "print arrl4(1,2 up 0)" \
761 ".*syntax error.*" \
762 "check invalid range 16"
763
764 # structure modes
765 # some tests are in chillvars.exp
766 # FIXME: no tag processing implemented do maybe adjust these tests
767 setup_xfail "*-*-*"
768 test_print_accept "ptype stru1m" \
769 "STRUCT \\(.*a long,.*b long,.*CASE b OF.*\\(42\\):.*ch1 CHARS\\(20\\),.*\\(52\\):.*ch2 CHARS\\(10\\).*ELSE.*ch3 CHARS\\(1\\).*ESAC.*\\)" \
770 "print mode of structure location 1"
771 test_print_accept "whatis strul1" "stru1m" \
772 "print mode name of structure location 1"
773 setup_xfail "*-*-*"
774 test_print_accept "print strul1" \
775 {\[\.a: -2147483648, \.b: 42, \.\(b\): \{\(42\) = \[\.ch1: \"12345678900987654321\"\], \(52\) = \[\.ch2: \"1234567890\"\], (else) = \[\.ch3: \"1\"\]\}\]} \
776 "print structure location 1"
777 test_print_accept "print strul1.a" \
778 "-2147483648" \
779 "print field of structure location 1"
780 test_print_accept "print strul1.b" "42" \
781 "print field of structure location 1"
782 test_print_accept "print strul1.ch1" \
783 "\"12345678900987654321\"" \
784 "print field of structure location 1"
785 setup_xfail "*-*-*"
786 test_print_accept "print strul1.ch2" \
787 "\"1234567890\".*warning: tag field value does'nt match" \
788 "print field of structure location 1"
789 setup_xfail "*-*-*"
790 test_print_accept "print strul1.ch3" \
791 "\"1\".*warning: tag field value does'nt match" \
792 "print field of structure location 1"
793
794 if $passcount then {
795 pass "$passcount correct locations printed"
796 }
797 }
798
799 # Start with a fresh gdb.
800
801 gdb_exit
802 gdb_start
803 gdb_reinitialize_dir $srcdir/$subdir
804
805 send "set print sevenbit-strings\n" ; expect -re ".*$prompt $"
806
807 if [set_lang_chill] then {
808 test_modes
809 test_locations
810 } else {
811 warning "$test_name tests suppressed."
812 }
This page took 0.049605 seconds and 4 git commands to generate.