1 # Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
21 # This file was written by Rob Savoye. (rob@cygnus.com)
28 # test running programs
35 if ![file exists $objdir/$subdir/$binfile] then {
36 perror "$objdir/$subdir/$binfile does not exist."
42 gdb_reinitialize_dir $srcdir/$subdir
43 gdb_load $objdir/$subdir/$binfile
45 source gdb.base/setvar.ci
48 # set it up at a breakpoint so we canplay with the variable values
50 send "set print sevenbit-strings\n" ; expect -re "$prompt $"
52 if ![runto_main] then {
53 perror "couldn't run to breakpoint"
57 # Determine expected output for unsigned long variables,
58 # the output varies with sizeof (unsigned long).
60 set ulong_minus_1 4294967295
61 set ulong_minus_456 4294966840
62 send "print sizeof (unsigned long)\n"
64 -re ".\[0-9\]* = 4.*$prompt $" {}
65 -re ".\[0-9\]* = 8.*$prompt $" {
66 set ulong_minus_1 18446744073709551615
67 set ulong_minus_456 18446744073709551160
70 fail "getting sizeof unsigned long"
72 default { fail "(timeout) getting sizeof unsigned long" }
76 # test "set variable" for type "char"
78 # Because bare char types can be either signed or unsigned, we just test the
79 # range of values that are common to both (0-127).
81 send "set variable v_char=0\n"
87 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable char=0" }
88 -re "$prompt $" { fail "set variable char=0" }
89 timeout { fail "(timeout) set variable char=0" }
92 -re "$prompt $" { fail "set variable char=0" }
93 timeout { fail "(timeout) set variable char=0" }
97 send "set variable v_char=1\n"
101 send "print v_char\n"
103 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable char=1" }
104 -re "$prompt $" { fail "set variable char=1" }
105 timeout { fail "(timeout) set variable char=1" }
108 -re "$prompt $" { fail "set variable char=1" }
109 timeout { fail "(timeout) set variable char=1" }
113 send "set variable v_char=27\n"
117 send "print v_char\n"
119 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable char=27 (Esc)" }
120 -re "$prompt $" { fail "set variable char=27 (Esc)" }
121 timeout { fail "(timeout) set variable char=27 (Esc)" }
124 -re "$prompt $" { fail "set variable char=27 (Esc)" }
125 timeout { fail "(timeout) set variable char=27 (Esc)" }
129 send "set variable v_char=32\n"
133 send "print v_char\n"
135 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable char=32 (SPC)" }
136 -re "$prompt $" { fail "set variable char=32 (SPC)" }
137 timeout { fail "(timeout) set variable char=32 (SPC)" }
140 -re "$prompt $" { fail "set variable char=32 (SPC)" }
141 timeout { fail "(timeout) set variable char=32 (SPC)" }
145 send "set variable v_char=65\n"
149 send "print v_char\n"
151 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable char=65 ('A')" }
152 -re "$prompt $" { fail "set variable char=65 ('A')" }
153 timeout { fail "(timeout) set variable char=65 ('A')" }
156 -re "$prompt $" { fail "set variable char=65 ('A')" }
157 timeout { fail "(timeout) set variable char=65 ('A')" }
161 send "set variable v_char=97\n"
165 send "print v_char\n"
167 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable char=97 ('a')" }
168 -re "$prompt $" { fail "set variable char=97 ('a')" }
169 timeout { fail "(timeout) set variable char=97 ('a')" }
172 -re "$prompt $" { fail "set variable char=97 ('a')" }
173 timeout { fail "(timeout) set variable char=97 ('a')" }
177 send "set variable v_char=126\n"
181 send "print v_char\n"
183 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable char=126 ('~')" }
184 -re "$prompt $" { fail "set variable char=126 ('~')" }
185 timeout { fail "(timeout) set variable char=126 ('~')" }
188 -re "$prompt $" { fail "set variable char=126 ('~')" }
189 timeout { fail "(timeout) set variable char=126 ('~')" }
193 send "set variable v_char=127\n"
197 send "print v_char\n"
199 -re ".\[0-9\]* = 127 \'.177\'.*$prompt $" { pass "set variable char=127 (8-bit)" }
200 -re "$prompt $" { fail "set variable char=127 (8-bit)" }
201 timeout { fail "(timeout) set variable char=127 (8-bit)" }
204 -re "$prompt $" { fail "set variable char=127 (8-bit)" }
205 timeout { fail "(timeout) set variable char=127 (8-bit)" }
210 # test "set variable" for type "signed char"
212 send "set variable v_char=0\n"
216 send "print v_signed_char\n"
218 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable signed char=0" }
219 -re "$prompt $" { fail "set variable signed char=0" }
220 timeout { fail "(timeout) set variable signed char=0" }
223 -re "$prompt $" { fail "set variable signed char=0" }
224 timeout { fail "(timeout) set variable signed char=0" }
228 send "set variable v_signed_char=1\n"
232 send "print v_signed_char\n"
234 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable signed char=1" }
235 -re "$prompt $" { fail "set variable signed char=1" }
236 timeout { fail "(timeout) set variable signed char=1" }
239 -re "$prompt $" { fail "set variable signed char=1" }
240 timeout { fail "(timeout) set variable signed char=1" }
244 send "set variable v_signed_char=27\n"
248 send "print v_signed_char\n"
250 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable signed char=27 (Esc)" }
251 -re "$prompt $" { fail "set variable signed char=27 (Esc)" }
252 timeout { fail "(timeout) set variable signed char=27 (Esc)" }
255 -re "$prompt $" { fail "set variable signed char=27 (Esc)" }
256 timeout { fail "(timeout) set variable signed char=27 (Esc)" }
260 send "set variable v_signed_char=32\n"
264 send "print v_signed_char\n"
266 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable signed char=32 (SPC)" }
267 -re "$prompt $" { fail "set variable signed char=32 (SPC)" }
268 timeout { fail "(timeout) set variable signed char=32 (SPC)" }
271 -re "$prompt $" { fail "set variable signed char=32 (SPC)" }
272 timeout { fail "(timeout) set variable signed char=32 (SPC)" }
276 send "set variable v_signed_char=65\n"
280 send "print v_signed_char\n"
282 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable signed char=65 ('A')" }
283 -re "$prompt $" { fail "set variable signed char=65 ('A')" }
284 timeout { fail "(timeout) set variable signed char=65 ('A')" }
287 -re "$prompt $" { fail "set variable signed char=65 ('A')" }
288 timeout { fail "(timeout) set variable signed char=65 ('A')" }
292 send "set variable v_signed_char=97\n"
296 send "print v_signed_char\n"
298 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable signed char=97 ('a')" }
299 -re "$prompt $" { fail "set variable signed char=97 ('a')" }
300 timeout { fail "(timeout) set variable signed char=97 ('a')" }
303 -re "$prompt $" { fail "set variable signed char=97 ('a')" }
304 timeout { fail "(timeout) set variable signed char=97 ('a')" }
308 send "set variable v_signed_char=126\n"
312 send "print v_signed_char\n"
314 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable signed char=126 ('~')" }
315 -re "$prompt $" { fail "set variable signed char=126 ('~')" }
316 timeout { fail "(timeout) set variable signed char=126 ('~')" }
319 -re "$prompt $" { fail "set variable signed char=126 ('~')" }
320 timeout { fail "(timeout) set variable signed char=126 ('~')" }
324 send "set variable v_signed_char=127\n"
328 send "print v_signed_char\n"
330 -re ".\[0-9\]* = 127 \'.177\'.*$prompt $" { pass "set variable signed char=127 (8-bit)" }
331 -re "$prompt $" { fail "set variable signed char=127 (8-bit)" }
332 timeout { fail "(timeout) set variable signed char=127 (8-bit)" }
335 -re "$prompt $" { fail "set variable signed char=127 (8-bit)" }
336 timeout { fail "(timeout) set variable signed char=127 (8-bit)" }
340 gdb_test "set variable v_signed_char=-1" ""
341 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
342 "set variable signed char=-1 (-1)"
344 gdb_test "set variable v_signed_char=0xFF" ""
345 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
346 "set variable signed char=0xFF (0xFF)"
350 # test "set variable" for type "unsigned char"
352 send "set variable v_unsigned_char=0\n"
356 send "print v_unsigned_char\n"
358 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable unsigned char=0" }
359 -re "$prompt $" { fail "set variable unsigned char=0" }
360 timeout { fail "(timeout) set variable unsigned char=0" }
363 -re "$prompt $" { fail "set variable unsigned char=0" }
364 timeout { fail "(timeout) set variable unsigned char=0" }
368 send "set variable v_unsigned_char=1\n"
372 send "print v_unsigned_char\n"
374 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable unsigned char=1" }
375 -re "$prompt $" { fail "set variable unsigned char=1" }
376 timeout { fail "(timeout) set variable unsigned char=1" }
379 -re "$prompt $" { fail "set variable unsigned char=1" }
380 timeout { fail "(timeout) set variable unsigned char=1" }
384 send "set variable v_unsigned_char=27\n"
388 send "print v_unsigned_char\n"
390 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable unsigned char=27 (Esc)" }
391 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
392 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
395 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
396 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
400 send "set variable v_unsigned_char=32\n"
404 send "print v_unsigned_char\n"
406 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable unsigned char=32 (SPC)" }
407 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
408 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
411 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
412 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
416 send "set variable v_unsigned_char=65\n"
420 send "print v_unsigned_char\n"
422 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable unsigned char=65 ('A')" }
423 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
424 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
427 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
428 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
432 send "set variable v_unsigned_char=97\n"
436 send "print v_unsigned_char\n"
438 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable unsigned char=97 ('a')" }
439 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
440 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
443 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
444 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
448 send "set variable v_unsigned_char=126\n"
452 send "print v_unsigned_char\n"
454 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable unsigned char=126 ('~')" }
455 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
456 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
459 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
460 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
464 send "set variable v_unsigned_char=~0\n"
468 send "print v_unsigned_char\n"
470 -re ".\[0-9\]* = 255 \'.377\'.*$prompt $" { pass "set variable unsigned char=255 (8-bit)" }
471 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
472 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
475 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
476 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
481 # test "set variable" for type "short"
483 send "set variable v_short=0\n"
487 send "print v_short\n"
489 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable short=0" }
490 -re "$prompt $" { fail "set variable short=0" }
491 timeout { fail "(timeout) set variable short=0" }
494 -re "$prompt $" { fail "set variable short=0" }
495 timeout { fail "(timeout) set variable short=0" }
499 send "set variable v_short=1\n"
503 send "print v_short\n"
505 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable short=1" }
506 -re "$prompt $" { fail "set variable short=1" }
507 timeout { fail "(timeout) set variable short=1" }
510 -re "$prompt $" { fail "set variable short=1" }
511 timeout { fail "(timeout) set variable short=1" }
515 send "set variable v_short=-1\n"
519 send "print v_short\n"
521 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable short=-1 (minus)" }
522 -re "$prompt $" { fail "set variable short=-1 (minus)" }
523 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
526 -re "$prompt $" { fail "set variable short=-1 (minus)" }
527 timeout { fail "(timeout) set variable short=-1 (minus)" }
532 # test "set variable" for type "signed short"
534 send "set variable v_signed_short=0\n"
538 send "print v_signed_short\n"
540 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed short=0" }
541 -re "$prompt $" { fail "set variable signed short=0" }
542 timeout { fail "(timeout) set variable signed short=0" }
545 -re "$prompt $" { fail "set variable signed short=0" }
546 timeout { fail "(timeout) set variable signed short=0" }
550 send "set variable v_signed_short=1\n"
554 send "print v_signed_short\n"
556 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed short=1" }
557 -re "$prompt $" { fail "set variable signed short=1" }
558 timeout { fail "(timeout) set variable signed short=1" }
561 -re "$prompt $" { fail "set variable signed short=1" }
562 timeout { fail "(timeout) set variable signed short=1" }
566 send "set variable v_signed_short=-1\n"
570 send "print v_signed_short\n"
572 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed short=-1 (minus)" }
573 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
574 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
577 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
578 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
583 # test "set variable" for type "unsigned short"
585 send "set variable v_unsigned_short=0\n"
589 send "print v_unsigned_short\n"
591 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned short=0" }
592 -re "$prompt $" { fail "set variable unsigned short=0" }
593 timeout { fail "(timeout) set variable unsigned short=0" }
596 -re "$prompt $" { fail "set variable unsigned short=0" }
597 timeout { fail "(timeout) set variable unsigned short=0" }
601 send "set variable v_unsigned_short=1\n"
605 send "print v_unsigned_short\n"
607 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned short=1" }
608 -re "$prompt $" { fail "set variable unsigned short=1" }
609 timeout { fail "(timeout) set variable unsigned short=1" }
612 -re "$prompt $" { fail "set variable unsigned short=1" }
613 timeout { fail "(timeout) set variable unsigned short=1" }
617 send "set variable v_unsigned_short=~0\n"
621 send "print v_unsigned_short\n"
623 -re ".\[0-9\]* = 65535.*$prompt $" { pass "set variable unsigned short=~0 (minus)" }
624 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
625 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
628 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
629 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
634 # test "set variable" for type "int"
636 send "set variable v_int=0\n"
642 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable int=0" }
643 -re "$prompt $" { fail "set variable int=0" }
644 timeout { fail "(timeout) set variable int=0" }
647 -re "$prompt $" { fail "set variable int=0" }
648 timeout { fail "(timeout) set variable int=0" }
652 send "set variable v_int=1\n"
658 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable int=1" }
659 -re "$prompt $" { fail "set variable int=1" }
660 timeout { fail "(timeout) set variable int=1" }
663 -re "$prompt $" { fail "set variable int=1" }
664 timeout { fail "(timeout) set variable int=1" }
668 send "set variable v_int=-1\n"
674 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable int=-1 (minus)" }
675 -re "$prompt $" { fail "set variable int=-1 (minus)" }
676 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
679 -re "$prompt $" { fail "set variable int=-1 (minus)" }
680 timeout { fail "(timeout) set variable int=-1 (minus)" }
685 # test "set variable" for type "signed int"
687 send "set variable v_signed_int=0\n"
691 send "print v_signed_int\n"
693 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed int=0" }
694 -re "$prompt $" { fail "set variable signed int=0" }
695 timeout { fail "(timeout) set variable signed int=0" }
698 -re "$prompt $" { fail "set variable signed int=0" }
699 timeout { fail "(timeout) set variable signed int=0" }
703 send "set variable v_signed_int=1\n"
707 send "print v_signed_int\n"
709 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed int=1" }
710 -re "$prompt $" { fail "set variable signed int=1" }
711 timeout { fail "(timeout) set variable signed int=1" }
714 -re "$prompt $" { fail "set variable signed int=1" }
715 timeout { fail "(timeout) set variable signed int=1" }
719 send "set variable v_signed_int=-1\n"
723 send "print v_signed_int\n"
725 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed int=-1 (minus)" }
726 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
727 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
730 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
731 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
736 # test "set variable" for type "unsigned int"
738 send "set variable v_unsigned_int=0\n"
742 send "print v_unsigned_int\n"
744 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned int=0" }
745 -re "$prompt $" { fail "set variable unsigned int=0" }
746 timeout { fail "(timeout) set variable unsigned int=0" }
749 -re "$prompt $" { fail "set variable unsigned int=0" }
750 timeout { fail "(timeout) set variable unsigned int=0" }
754 send "set variable v_unsigned_int=1\n"
758 send "print v_unsigned_int\n"
760 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned int=1" }
761 -re "$prompt $" { fail "set variable unsigned int=1" }
762 timeout { fail "(timeout) set variable unsigned int=1" }
765 -re "$prompt $" { fail "set variable unsigned int=1" }
766 timeout { fail "(timeout) set variable unsigned int=1" }
770 send "set variable v_unsigned_int=~0\n"
774 send "print v_unsigned_int\n"
776 -re ".\[0-9\]* = 4294967295.*$prompt $" { pass "set variable unsigned int=~0 (minus)" }
777 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
778 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
781 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
782 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
787 # test "set variable" for type "long"
789 send "set variable v_long=0\n"
793 send "print v_long\n"
795 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable long=0" }
796 -re "$prompt $" { fail "set variable long=0" }
797 timeout { fail "(timeout) set variable long=0" }
800 -re "$prompt $" { fail "set variable long=0" }
801 timeout { fail "(timeout) set variable long=0" }
805 send "set variable v_long=1\n"
809 send "print v_long\n"
811 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable long=1" }
812 -re "$prompt $" { fail "set variable long=1" }
813 timeout { fail "(timeout) set variable long=1" }
816 -re "$prompt $" { fail "set variable long=1" }
817 timeout { fail "(timeout) set variable long=1" }
821 send "set variable v_long=-1\n"
825 send "print v_long\n"
827 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable long=-1 (minus)" }
828 -re "$prompt $" { fail "set variable long=-1 (minus)" }
829 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
832 -re "$prompt $" { fail "set variable long=-1 (minus)" }
833 timeout { fail "(timeout) set variable long=-1 (minus)" }
838 # test "set variable" for type "signed long"
840 send "set variable v_signed_long=0\n"
844 send "print v_signed_long\n"
846 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed long=0" }
847 -re "$prompt $" { fail "set variable signed long=0" }
848 timeout { fail "(timeout) set variable signed long=0" }
851 -re "$prompt $" { fail "set variable signed long=0" }
852 timeout { fail "(timeout) set variable signed long=0" }
856 send "set variable v_signed_long=1\n"
860 send "print v_signed_long\n"
862 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed long=1" }
863 -re "$prompt $" { fail "set variable signed long=1" }
864 timeout { fail "(timeout) set variable signed long=1" }
867 -re "$prompt $" { fail "set variable signed long=1" }
868 timeout { fail "(timeout) set variable signed long=1" }
872 send "set variable v_signed_long=-1\n"
876 send "print v_signed_long\n"
878 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed long=-1 (minus)" }
879 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
880 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
883 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
884 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
889 # test "set variable" for type "unsigned long"
891 send "set variable v_unsigned_long=0\n"
895 send "print v_unsigned_long\n"
897 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned long=0" }
898 -re "$prompt $" { fail "set variable unsigned long=0" }
899 timeout { fail "(timeout) set variable unsigned long=0" }
902 -re "$prompt $" { fail "set variable unsigned long=0" }
903 timeout { fail "(timeout) set variable unsigned long=0" }
907 send "set variable v_unsigned_long=1\n"
911 send "print v_unsigned_long\n"
913 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned long=1" }
914 -re "$prompt $" { fail "set variable unsigned long=1" }
915 timeout { fail "(timeout) set variable unsigned long=1" }
918 -re "$prompt $" { fail "set variable unsigned long=1" }
919 timeout { fail "(timeout) set variable unsigned long=1" }
923 send "set variable v_unsigned_long=~0\n"
927 send "print v_unsigned_long\n"
929 -re ".\[0-9\]* = $ulong_minus_1.*$prompt $" { pass "set variable unsigned long=~0 (minus)" }
930 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
931 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
934 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
935 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
940 # test "set variable" for type "float"
942 send "set variable v_float=0.0\n"
946 send "print v_float\n"
948 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable float=0" }
949 -re "$prompt $" { fail "set variable float=0" }
950 timeout { fail "(timeout) set variable float=0" }
953 -re "$prompt $" { fail "set variable float=0" }
954 timeout { fail "(timeout) set variable float=0" }
958 send "set variable v_float=1.0\n"
962 send "print v_float\n"
964 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable float=1" }
965 -re "$prompt $" { fail "set variable float=1" }
966 timeout { fail "(timeout) set variable float=1" }
969 -re "$prompt $" { fail "set variable float=1" }
970 timeout { fail "(timeout) set variable float=1" }
974 send "set variable v_float=-1.0\n"
978 send "print v_float\n"
980 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable float=-1 (minus)" }
981 -re "$prompt $" { fail "set variable float=-1 (minus)" }
982 timeout { fail "(timeout) set variable signed float=-1 (minus)" }
985 -re "$prompt $" { fail "set variable float=-1 (minus)" }
986 timeout { fail "(timeout) set variable float=-1 (minus)" }
991 # test "set variable" for type "double"
993 send "set variable v_double=0.0\n"
997 send "print v_double\n"
999 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable double=0" }
1000 -re "$prompt $" { fail "set variable double=0" }
1001 timeout { fail "(timeout) set variable double=0" }
1004 -re "$prompt $" { fail "set variable double=0" }
1005 timeout { fail "(timeout) set variable double=0" }
1009 send "set variable v_double=1.0\n"
1013 send "print v_double\n"
1015 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable double=1" }
1016 -re "$prompt $" { fail "set variable double=1" }
1017 timeout { fail "(timeout) set variable double=1" }
1020 -re "$prompt $" { fail "set variable double=1" }
1021 timeout { fail "(timeout) set variable double=1" }
1025 send "set variable v_double=-1.0\n"
1027 -re "set.*$prompt $"\
1029 send "print v_double\n"
1031 -re "print.*.\[0-9\]* = -1.*$prompt $" { pass "set variable double=-1 (minus)" }
1032 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1033 timeout { fail "(timeout) set variable double=-1 (minus)" }
1036 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1037 timeout { fail "(timeout) set variable double=-1 (minus)" }
1042 # test "set variable" for "char array[2]"
1044 send "set variable v_char_array\[0\]='h'\n"
1045 expect -re "$prompt $"
1046 send "set variable v_char_array\[1\]='i'\n"
1048 -re "set.*$prompt $"\
1050 send "print v_char_array\n"
1052 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable char array=\"hi\" (string)" }
1053 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1054 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1057 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1058 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1063 # test "set variable" for "signed char array[2]"
1065 send "set variable v_signed_char_array\[0\]='h'\n"
1066 expect -re "$prompt $"
1067 send "set variable v_signed_char_array\[1\]='i'\n"
1069 -re "set.*$prompt $"\
1071 send "print v_signed_char_array\n"
1073 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable signed char array=\"hi\" (string)" }
1074 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1075 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1078 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1079 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1084 # test "set variable" for "unsigned char array[2]"
1086 send "set variable v_unsigned_char_array\[0\]='h'\n"
1087 expect -re "$prompt $"
1088 send "set variable v_unsigned_char_array\[1\]='i'\n"
1090 -re "set.*$prompt $"\
1092 send "print v_unsigned_char_array\n"
1094 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable unsigned char array=\"hi\" (string)" }
1095 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1096 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1099 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1100 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1105 # test "set variable" for "short array[2]"
1107 send "set variable v_short_array\[0\]=123\n"
1108 expect -re "$prompt $"
1109 send "set variable v_short_array\[1\]=-456\n"
1111 -re "set.*$prompt $"\
1113 send "print v_short_array\n"
1115 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable short array" }
1116 -re "$prompt $" { fail "set variable short array" }
1117 timeout { fail "(timeout) set variable short array" }
1120 -re "$prompt $" { fail "set variable short array" }
1121 timeout { fail "(timeout) set variable short array" }
1126 # test "set variable" for "signed short array[2]"
1128 send "set variable v_signed_short_array\[0\]=123\n"
1129 expect -re "$prompt $"
1130 send "set variable v_signed_short_array\[1\]=-456\n"
1132 -re "set.*$prompt $"\
1134 send "print v_signed_short_array\n"
1136 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed short array" }
1137 -re "$prompt $" { fail "set variable signed short array" }
1138 timeout { fail "(timeout) set variable signed short array" }
1141 -re "$prompt $" { fail "set variable signed short array" }
1142 timeout { fail "(timeout) set variable signed short array" }
1147 # test "set variable" for "unsigned short array[2]"
1149 send "set variable v_unsigned_short_array\[0\]=123\n"
1150 expect -re "$prompt $"
1151 send "set variable v_unsigned_short_array\[1\]=-456\n"
1153 -re "set.*$prompt $"\
1155 send "print v_unsigned_short_array\n"
1157 -re "print.*.\[0-9\]* =.*\{123,.*65080\}.*$prompt $" { pass "set variable unsigned short array" }
1158 -re "$prompt $" { fail "set variable unsigned short array" }
1159 timeout { fail "(timeout) set variable unsigned short array" }
1162 -re "$prompt $" { fail "set variable unsigned short array" }
1163 timeout { fail "(timeout) set variable unsigned short array" }
1168 # test "set variable" for "int array[2]"
1170 send "set variable v_int_array\[0\]=123\n"
1171 expect -re "$prompt $"
1172 send "set variable v_int_array\[1\]=-456\n"
1174 -re "set.*$prompt $"\
1176 send "print v_int_array\n"
1178 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable int array" }
1179 -re "$prompt $" { fail "set variable int array" }
1180 timeout { fail "(timeout) set variable int array" }
1183 -re "$prompt $" { fail "set variable int array" }
1184 timeout { fail "(timeout) set variable int array" }
1189 # test "set variable" for "signed int array[2]"
1191 send "set variable v_signed_int_array\[0\]=123\n"
1192 expect -re "$prompt $"
1193 send "set variable v_signed_int_array\[1\]=-456\n"
1195 -re "set.*$prompt $"\
1197 send "print v_signed_int_array\n"
1199 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed int array" }
1200 -re "$prompt $" { fail "set variable signed int array" }
1201 timeout { fail "(timeout) set variable signed int array" }
1204 -re "$prompt $" { fail "set variable signed int array" }
1205 timeout { fail "(timeout) set variable signed int array" }
1211 # test "set variable" for "unsigned int array[2]"
1213 send "set variable v_unsigned_int_array\[0\]=123\n"
1214 expect -re "$prompt $"
1215 send "set variable v_unsigned_int_array\[1\]=-456\n"
1217 -re "set.*$prompt $"\
1219 send "print v_unsigned_int_array\n"
1221 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" { pass "set variable unsigned int array" }
1222 -re "$prompt $" { fail "set variable unsigned int array" }
1223 timeout { fail "(timeout) set variable unsigned int array" }
1226 -re "$prompt $" { fail "set variable unsigned int array" }
1227 timeout { fail "(timeout) set variable unsigned int array" }
1232 # test "set variable" for "long array[2]"
1234 send "set variable v_long_array\[0\]=123\n"
1235 expect -re "$prompt $"
1236 send "set variable v_long_array\[1\]=-456\n"
1238 -re "set.*$prompt $"\
1240 send "print v_long_array\n"
1242 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable long array" }
1243 -re "$prompt $" { fail "set variable long array" }
1244 timeout { fail "(timeout) set variable long array" }
1247 -re "$prompt $" { fail "set variable long array" }
1248 timeout { fail "(timeout) set variable long array" }
1253 # test "set variable" for "signed long array[2]"
1255 send "set variable v_signed_long_array\[0\]=123\n"
1256 expect -re "$prompt $"
1257 send "set variable v_signed_long_array\[1\]=-456\n"
1259 -re "set.*$prompt $"\
1261 send "print v_signed_long_array\n"
1263 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed long array" }
1264 -re "$prompt $" { fail "set variable signed long array" }
1265 timeout { fail "(timeout) set variable signed long array" }
1268 -re "$prompt $" { fail "set variable signed long array" }
1269 timeout { fail "(timeout) set variable signed long array" }
1275 # test "set variable" for "unsigned long array[2]"
1277 send "set variable v_unsigned_long_array\[0\]=123\n"
1278 expect -re "$prompt $"
1279 send "set variable v_unsigned_long_array\[1\]=-456\n"
1283 send "print v_unsigned_long_array\n"
1285 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" { pass "set variable unsigned long array" }
1286 -re "$prompt $" { fail "set variable unsigned long array" }
1287 timeout { fail "(timeout) set variable unsigned long array" }
1290 -re "$prompt $" { fail "set variable unsigned long array" }
1291 timeout { fail "(timeout) set variable unsigned long array" }
1296 # test "set variable" for "float array[2]"
1298 send "set variable v_float_array\[0\]=123.0\n"
1299 expect -re "$prompt $"
1300 send "set variable v_float_array\[1\]=-456.0\n"
1304 send "print v_float_array\n"
1306 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable float array" }
1307 -re "$prompt $" { fail "set variable float array" }
1308 timeout { fail "(timeout) set variable float array" }
1311 -re "$prompt $" { fail "set variable float array" }
1312 timeout { fail "(timeout) set variable float array" }
1317 # test "set variable" for "double array[2]"
1319 send "set variable v_double_array\[0\]=123.0\n"
1320 expect -re "$prompt $"
1321 send "set variable v_double_array\[1\]=-456.0\n"
1325 send "print v_double_array\n"
1327 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable double array" }
1328 -re "$prompt $" { fail "set variable double array" }
1329 timeout { fail "(timeout) set variable double array" }
1332 -re "$prompt $" { fail "set variable double array" }
1333 timeout { fail "(timeout) set variable double array" }
1338 # test "set variable" for type "char *"
1340 send "set v_char_pointer=v_char_array\n"
1341 expect -re "set.*$prompt $"
1342 send "set variable *(v_char_pointer)='h'\n"
1343 expect -re "set.*$prompt $"
1344 send "set variable *(v_char_pointer+1)='i'\n"
1346 -re "set.*$prompt $" {
1347 send "print v_char_array\n"
1349 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1350 send "print *(v_char_pointer+1)\n"
1352 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable char pointer=\"hi\" (string)" }
1353 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1354 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1358 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1359 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1362 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1363 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1368 # test "set variable" for type "signed char *"
1370 send "set v_signed_char_pointer=v_signed_char_array\n"
1371 expect -re "set.*$prompt $"
1372 send "set variable *(v_signed_char_pointer)='h'\n"
1373 expect -re "set.*$prompt $"
1374 send "set variable *(v_signed_char_pointer+1)='i'\n"
1376 -re "set.*$prompt $" {
1377 send "print v_signed_char_array\n"
1379 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1380 send "print *(v_signed_char_pointer+1)\n"
1382 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable signed char pointer=\"hi\" (string)" }
1383 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1384 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1388 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1389 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1392 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1393 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1398 # test "set variable" for type "unsigned char *"
1400 send "set v_unsigned_char_pointer=v_unsigned_char_array\n"
1401 expect -re "set.*$prompt $"
1402 send "set variable *(v_unsigned_char_pointer)='h'\n"
1403 expect -re "set.*$prompt $"
1404 send "set variable *(v_unsigned_char_pointer+1)='i'\n"
1406 -re "set.*$prompt $" {
1407 send "print v_unsigned_char_array\n"
1409 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1410 send "print *(v_unsigned_char_pointer+1)\n"
1412 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable unsigned char pointer=\"hi\" (string)" }
1413 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1414 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1418 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1419 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1422 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1423 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1428 # test "set variable" for type "short *"
1430 send "set v_short_pointer=v_short_array\n"
1431 expect -re "set.*$prompt $"
1432 send "set variable *(v_short_pointer)=123\n"
1433 expect -re "set.*$prompt $"
1434 send "set variable *(v_short_pointer+1)=-456\n"
1436 -re "set.*$prompt $" {
1437 send "print v_short_array\n"
1439 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1440 send "print *(v_short_pointer+1)\n"
1442 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable short pointer" }
1443 -re "$prompt $" { fail "set variable short pointer" }
1444 timeout { fail "(timeout) set variable short pointer" }
1448 -re "$prompt $" { fail "set variable short pointer" }
1449 timeout { fail "(timeout) set variable short pointer" }
1452 -re "$prompt $" { fail "set variable short pointer" }
1453 timeout { fail "(timeout) set variable short pointer" }
1458 # test "set variable" for type "signed short *"
1460 gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
1461 gdb_test "set variable *(v_signed_short_pointer)=123" ""
1462 gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
1463 gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
1464 "set variable signed short pointer"
1465 gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
1469 # test "set variable" for type "unsigned short *"
1471 gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
1472 gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
1473 gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
1474 gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}" \
1475 "set variable unsigned short pointer"
1476 gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
1480 # test "set variable" for type "int *"
1482 send "set v_int_pointer=v_int_array\n"
1483 expect -re "set.*$prompt $"
1484 send "set variable *(v_int_pointer)=123\n"
1485 expect -re "set.*$prompt $"
1486 send "set variable *(v_int_pointer+1)=-456\n"
1488 -re "set.*$prompt $" {
1489 send "print v_int_array\n"
1491 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1492 send "print *(v_int_pointer+1)\n"
1494 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable int pointer" }
1495 -re "$prompt $" { fail "set variable int pointer" }
1496 timeout { fail "(timeout) set variable int pointer" }
1500 -re "$prompt $" { fail "set variable int pointer" }
1501 timeout { fail "(timeout) set variable int pointer" }
1504 -re "$prompt $" { fail "set variable int pointer" }
1505 timeout { fail "(timeout) set variable int pointer" }
1510 # test "set variable" for type "signed int *"
1512 send "set v_signed_int_pointer=v_signed_int_array\n"
1513 expect -re "set.*$prompt $"
1514 send "set variable *(v_signed_int_pointer)=123\n"
1515 expect -re "set.*$prompt $"
1516 send "set variable *(v_signed_int_pointer+1)=-456\n"
1518 -re "set.*$prompt $" {
1519 send "print v_signed_int_array\n"
1521 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1522 send "print *(v_signed_int_pointer+1)\n"
1524 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed int pointer" }
1525 -re "$prompt $" { fail "set variable signed int pointer" }
1526 timeout { fail "(timeout) set variable signed int pointer" }
1530 -re "$prompt $" { fail "set variable signed int pointer" }
1531 timeout { fail "(timeout) set variable signed int pointer" }
1534 -re "$prompt $" { fail "set variable signed int pointer" }
1535 timeout { fail "(timeout) set variable signed int pointer" }
1540 # test "set variable" for type "unsigned int *"
1542 send "set v_unsigned_int_pointer=v_unsigned_int_array\n"
1543 expect -re "set.*$prompt $"
1544 send "set variable *(v_unsigned_int_pointer)=123\n"
1545 expect -re "set.*$prompt $"
1546 send "set variable *(v_unsigned_int_pointer+1)=-456\n"
1548 -re "set.*$prompt $" {
1549 send "print v_unsigned_int_array\n"
1551 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" {
1552 send "print *(v_unsigned_int_pointer+1)\n"
1554 -re "print.*.\[0-9\]* = 4294966840.*$prompt $" { pass "set variable unsigned int pointer" }
1555 -re "$prompt $" { fail "set variable unsigned int pointer" }
1556 timeout { fail "(timeout) set variable unsigned int pointer" }
1560 -re "$prompt $" { fail "set variable unsigned int pointer" }
1561 timeout { fail "(timeout) set variable unsigned int pointer" }
1564 -re "$prompt $" { fail "set variable unsigned int pointer" }
1565 timeout { fail "(timeout) set variable unsigned int pointer" }
1570 # test "set variable" for type "long *"
1572 send "set v_long_pointer=v_long_array\n"
1573 expect -re "set.*$prompt $"
1574 send "set variable *(v_long_pointer)=123\n"
1575 expect -re "set.*$prompt $"
1576 send "set variable *(v_long_pointer+1)=-456\n"
1578 -re "set.*$prompt $" {
1579 send "print v_long_array\n"
1581 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1582 send "print *(v_long_pointer+1)\n"
1584 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable long pointer" }
1585 -re "$prompt $" { fail "set variable long pointer" }
1586 timeout { fail "(timeout) set variable long pointer" }
1590 -re "$prompt $" { fail "set variable long pointer" }
1591 timeout { fail "(timeout) set variable long pointer" }
1594 -re "$prompt $" { fail "set variable long pointer" }
1595 timeout { fail "(timeout) set variable long pointer" }
1600 # test "set variable" for type "signed long *"
1602 send "set v_signed_long_pointer=v_signed_long_array\n"
1603 expect -re "set.*$prompt $"
1604 send "set variable *(v_signed_long_pointer)=123\n"
1605 expect -re "set.*$prompt $"
1606 send "set variable *(v_signed_long_pointer+1)=-456\n"
1608 -re "set.*$prompt $" {
1609 send "print v_signed_long_array\n"
1611 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1612 send "print *(v_signed_long_pointer+1)\n"
1614 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed long pointer" }
1615 -re "$prompt $" { fail "set variable signed long pointer" }
1616 timeout { fail "(timeout) set variable signed long pointer" }
1620 -re "$prompt $" { fail "set variable signed long pointer" }
1621 timeout { fail "(timeout) set variable signed long pointer" }
1624 -re "$prompt $" { fail "set variable signed long pointer" }
1625 timeout { fail "(timeout) set variable signed long pointer" }
1630 # test "set variable" for type "unsigned long *"
1632 send "set v_unsigned_long_pointer=v_unsigned_long_array\n"
1633 expect -re "set.*$prompt $"
1634 send "set variable *(v_unsigned_long_pointer)=123\n"
1635 expect -re "set.*$prompt $"
1636 send "set variable *(v_unsigned_long_pointer+1)=-456\n"
1638 -re "set.*$prompt $" {
1639 send "print v_unsigned_long_array\n"
1641 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" {
1642 send "print *(v_unsigned_long_pointer+1)\n"
1644 -re "print.*.\[0-9\]* = $ulong_minus_456.*$prompt $" { pass "set variable unsigned long pointer" }
1645 -re "$prompt $" { fail "set variable unsigned long pointer" }
1646 timeout { fail "(timeout) set variable unsigned long pointer" }
1650 -re "$prompt $" { fail "set variable unsigned long pointer" }
1651 timeout { fail "(timeout) set variable unsigned long pointer" }
1654 -re "$prompt $" { fail "set variable unsigned long pointer" }
1655 timeout { fail "(timeout) set variable unsigned long pointer" }
1660 # test "set variable" for type "float *"
1662 send "set v_float_pointer=v_float_array\n"
1663 expect -re "set.*$prompt $"
1664 send "set variable *(v_float_pointer)=123.0\n"
1665 expect -re "set.*$prompt $"
1666 send "set variable *(v_float_pointer+1)=-456.0\n"
1668 -re "set.*$prompt $" {
1669 send "print v_float_array\n"
1671 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1672 send "print *(v_float_pointer+1)\n"
1674 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable float pointer" }
1675 -re "$prompt $" { fail "set variable float pointer" }
1676 timeout { fail "(timeout) set variable float pointer" }
1680 -re "$prompt $" { fail "set variable float pointer" }
1681 timeout { fail "(timeout) set variable float pointer" }
1684 -re "$prompt $" { fail "set variable float pointer" }
1685 timeout { fail "(timeout) set variable float pointer" }
1690 # test "set variable" for type "double *"
1692 send "set v_double_pointer=v_double_array\n"
1693 expect -re "set.*$prompt $"
1694 send "set variable *(v_double_pointer)=123.0\n"
1695 expect -re "set.*$prompt $"
1696 send "set variable *(v_double_pointer+1)=-456.0\n"
1698 -re "set.*$prompt $" {
1699 send "print v_double_array\n"
1701 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1702 send "print *(v_double_pointer+1)\n"
1704 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable double pointer" }
1705 -re "$prompt $" { fail "set variable double pointer" }
1706 timeout { fail "(timeout) set variable double pointer" }
1710 -re "$prompt $" { fail "set variable double pointer" }
1711 timeout { fail "(timeout) set variable double pointer" }
1714 -re "$prompt $" { fail "set variable double pointer" }
1715 timeout { fail "(timeout) set variable double pointer" }
1720 # test "set variable" for struct members
1722 send "set variable v_struct1.v_char_member='h'\n"
1724 -re "set.*$prompt $"\
1726 send "print v_struct1.v_char_member\n"
1728 -re "print.*.\[0-9\]* = 104 \'h\'.*$prompt $" { pass "set variable structure char member" }
1729 -re "$prompt $" { fail "set variable structure char member" }
1730 timeout { fail "(timeout) set variable structure char member" }
1733 -re "$prompt $" { fail "set variable structure char member" }
1734 timeout { fail "(timeout) set variable structure char member" }
1738 send "set variable v_struct1.v_short_member=1\n"
1740 -re "set.*$prompt $"\
1742 send "print v_struct1.v_short_member\n"
1744 -re "print.*.\[0-9\]* = 1.*$prompt $" { pass "set variable structure short member" }
1745 -re "$prompt $" { fail "set variable structure short member" }
1746 timeout { fail "(timeout) set variable structure short member" }
1749 -re "$prompt $" { fail "set variable structure short member" }
1750 timeout { fail "(timeout) set variable structure short member" }
1754 send "set variable v_struct1.v_int_member=2\n"
1756 -re "set.*$prompt $"\
1758 send "print v_struct1.v_int_member\n"
1760 -re "print.*.\[0-9\]* = 2.*$prompt $" { pass "set variable structure int member" }
1761 -re "$prompt $" { fail "set variable structure int member" }
1762 timeout { fail "(timeout) set variable structure int member" }
1765 -re "$prompt $" { fail "set variable structure int member" }
1766 timeout { fail "(timeout) set variable structure int member" }
1770 send "set variable v_struct1.v_long_member=3\n"
1772 -re "set.*$prompt $"\
1774 send "print v_struct1.v_long_member\n"
1776 -re "print.*.\[0-9\]* = 3.*$prompt $" { pass "set variable structure long member" }
1777 -re "$prompt $" { fail "set variable structure long member" }
1778 timeout { fail "(timeout) set variable structure long member" }
1781 -re "$prompt $" { fail "set variable structure long member" }
1782 timeout { fail "(timeout) set variable structure long member" }
1786 send "set variable v_struct1.v_float_member=4.0\n"
1788 -re "set.*$prompt $"\
1790 send "print v_struct1.v_float_member\n"
1792 -re "print.*.\[0-9\]* = 4.*$prompt $" { pass "set variable structure float member" }
1793 -re "$prompt $" { fail "set variable structure float member" }
1794 timeout { fail "(timeout) set variable structure float member" }
1797 -re "$prompt $" { fail "set variable structure float member" }
1798 timeout { fail "(timeout) set variable structure float member" }
1802 send "set variable v_struct1.v_double_member=5.0\n"
1804 -re "set.*$prompt $"\
1806 send "print v_struct1.v_double_member\n"
1808 -re "print.*.\[0-9\]* = 5.*$prompt $" { pass "set variable structure double member" }
1809 -re "$prompt $" { fail "set variable structure double member" }
1810 timeout { fail "(timeout) set variable structure double member" }
1813 -re "$prompt $" { fail "set variable structure double member" }
1814 timeout { fail "(timeout) set variable structure double member" }
1818 gdb_test "print v_struct1" \
1819 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1820 .*v_int_member = 2,.*\
1821 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1822 "set print structure #1"
1824 # This should be an error. GCC extensions for structure constants require
1825 # the type of the structure to be specified, as in
1826 # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
1827 # GDB should do the same if it wants to provide this feature.
1828 gdb_test "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" "Invalid.*"
1830 # And after the error the structure should be unchanged.
1831 gdb_test "print v_struct1" \
1832 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1833 .*v_int_member = 2,.*\
1834 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1835 "set print structure #2"
1837 # Test printing of enumeration bitfields.
1838 # GNU C supports them, some other compilers don't.
1840 if {$gcc_compiled} then {
1841 gdb_test "print sef.field=sm1" "print.*.\[0-9\]* = sm1"
1842 gdb_test "print sef.field" "print.*.\[0-9\]* = sm1" "print sef.field (sm1)"
1843 gdb_test "print sef.field=s1" "print.*.\[0-9\]* = s1"
1844 gdb_test "print sef.field" "print.*.\[0-9\]* = s1" "print sef.field (s1)"
1845 gdb_test "print uef.field=u1" "print.*.\[0-9\]* = u1"
1846 gdb_test "print uef.field" "print.*.\[0-9\]* = u1" "print uef.field (u1)"
1847 gdb_test "print uef.field=u2" "print.*.\[0-9\]* = u2"
1848 gdb_test "print uef.field" "print.*.\[0-9\]* = u2" "print uef.field (u2)"