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 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
342 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
343 "set variable signed char=-1 (-1)"
345 gdb_test "set variable v_signed_char=0xFF" ""
346 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
347 gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
348 "set variable signed char=0xFF (0xFF)"
352 # test "set variable" for type "unsigned char"
354 send "set variable v_unsigned_char=0\n"
358 send "print v_unsigned_char\n"
360 -re ".\[0-9\]* = 0 \'.000\'.*$prompt $" { pass "set variable unsigned char=0" }
361 -re "$prompt $" { fail "set variable unsigned char=0" }
362 timeout { fail "(timeout) set variable unsigned char=0" }
365 -re "$prompt $" { fail "set variable unsigned char=0" }
366 timeout { fail "(timeout) set variable unsigned char=0" }
370 send "set variable v_unsigned_char=1\n"
374 send "print v_unsigned_char\n"
376 -re ".\[0-9\]* = 1 \'.001\'.*$prompt $" { pass "set variable unsigned char=1" }
377 -re "$prompt $" { fail "set variable unsigned char=1" }
378 timeout { fail "(timeout) set variable unsigned char=1" }
381 -re "$prompt $" { fail "set variable unsigned char=1" }
382 timeout { fail "(timeout) set variable unsigned char=1" }
386 send "set variable v_unsigned_char=27\n"
390 send "print v_unsigned_char\n"
392 -re ".\[0-9\]* = 27 \'.e\'.*$prompt $" { pass "set variable unsigned char=27 (Esc)" }
393 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
394 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
397 -re "$prompt $" { fail "set variable unsigned char=27 (Esc)" }
398 timeout { fail "(timeout) set variable unsigned char=27 (Esc)" }
402 send "set variable v_unsigned_char=32\n"
406 send "print v_unsigned_char\n"
408 -re ".\[0-9\]* = 32 \' \'.*$prompt $" { pass "set variable unsigned char=32 (SPC)" }
409 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
410 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
413 -re "$prompt $" { fail "set variable unsigned char=32 (SPC)" }
414 timeout { fail "(timeout) set variable unsigned char=32 (SPC)" }
418 send "set variable v_unsigned_char=65\n"
422 send "print v_unsigned_char\n"
424 -re ".\[0-9\]* = 65 \'A\'.*$prompt $" { pass "set variable unsigned char=65 ('A')" }
425 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
426 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
429 -re "$prompt $" { fail "set variable unsigned char=65 ('A')" }
430 timeout { fail "(timeout) set variable unsigned char=65 ('A')" }
434 send "set variable v_unsigned_char=97\n"
438 send "print v_unsigned_char\n"
440 -re ".\[0-9\]* = 97 \'a\'.*$prompt $" { pass "set variable unsigned char=97 ('a')" }
441 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
442 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
445 -re "$prompt $" { fail "set variable unsigned char=97 ('a')" }
446 timeout { fail "(timeout) set variable unsigned char=97 ('a')" }
450 send "set variable v_unsigned_char=126\n"
454 send "print v_unsigned_char\n"
456 -re ".\[0-9\]* = 126 \'~\'.*$prompt $" { pass "set variable unsigned char=126 ('~')" }
457 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
458 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
461 -re "$prompt $" { fail "set variable unsigned char=126 ('~')" }
462 timeout { fail "(timeout) set variable unsigned char=126 ('~')" }
466 send "set variable v_unsigned_char=~0\n"
470 send "print v_unsigned_char\n"
472 -re ".\[0-9\]* = 255 \'.377\'.*$prompt $" { pass "set variable unsigned char=255 (8-bit)" }
473 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
474 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
477 -re "$prompt $" { fail "set variable unsigned char=255 (8-bit)" }
478 timeout { fail "(timeout) set variable unsigned char=255 (8-bit)" }
483 # test "set variable" for type "short"
485 send "set variable v_short=0\n"
489 send "print v_short\n"
491 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable short=0" }
492 -re "$prompt $" { fail "set variable short=0" }
493 timeout { fail "(timeout) set variable short=0" }
496 -re "$prompt $" { fail "set variable short=0" }
497 timeout { fail "(timeout) set variable short=0" }
501 send "set variable v_short=1\n"
505 send "print v_short\n"
507 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable short=1" }
508 -re "$prompt $" { fail "set variable short=1" }
509 timeout { fail "(timeout) set variable short=1" }
512 -re "$prompt $" { fail "set variable short=1" }
513 timeout { fail "(timeout) set variable short=1" }
517 send "set variable v_short=-1\n"
521 send "print v_short\n"
523 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable short=-1 (minus)" }
524 -re "$prompt $" { fail "set variable short=-1 (minus)" }
525 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
528 -re "$prompt $" { fail "set variable short=-1 (minus)" }
529 timeout { fail "(timeout) set variable short=-1 (minus)" }
534 # test "set variable" for type "signed short"
536 send "set variable v_signed_short=0\n"
540 send "print v_signed_short\n"
542 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed short=0" }
543 -re "$prompt $" { fail "set variable signed short=0" }
544 timeout { fail "(timeout) set variable signed short=0" }
547 -re "$prompt $" { fail "set variable signed short=0" }
548 timeout { fail "(timeout) set variable signed short=0" }
552 send "set variable v_signed_short=1\n"
556 send "print v_signed_short\n"
558 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed short=1" }
559 -re "$prompt $" { fail "set variable signed short=1" }
560 timeout { fail "(timeout) set variable signed short=1" }
563 -re "$prompt $" { fail "set variable signed short=1" }
564 timeout { fail "(timeout) set variable signed short=1" }
568 send "set variable v_signed_short=-1\n"
572 send "print v_signed_short\n"
574 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed short=-1 (minus)" }
575 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
576 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
579 -re "$prompt $" { fail "set variable signed short=-1 (minus)" }
580 timeout { fail "(timeout) set variable signed short=-1 (minus)" }
585 # test "set variable" for type "unsigned short"
587 send "set variable v_unsigned_short=0\n"
591 send "print v_unsigned_short\n"
593 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned short=0" }
594 -re "$prompt $" { fail "set variable unsigned short=0" }
595 timeout { fail "(timeout) set variable unsigned short=0" }
598 -re "$prompt $" { fail "set variable unsigned short=0" }
599 timeout { fail "(timeout) set variable unsigned short=0" }
603 send "set variable v_unsigned_short=1\n"
607 send "print v_unsigned_short\n"
609 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned short=1" }
610 -re "$prompt $" { fail "set variable unsigned short=1" }
611 timeout { fail "(timeout) set variable unsigned short=1" }
614 -re "$prompt $" { fail "set variable unsigned short=1" }
615 timeout { fail "(timeout) set variable unsigned short=1" }
619 send "set variable v_unsigned_short=~0\n"
623 send "print v_unsigned_short\n"
625 -re ".\[0-9\]* = 65535.*$prompt $" { pass "set variable unsigned short=~0 (minus)" }
626 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
627 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
630 -re "$prompt $" { fail "set variable unsigned short=~0 (minus)" }
631 timeout { fail "(timeout) set variable unsigned short=~0 (minus)" }
636 # test "set variable" for type "int"
638 send "set variable v_int=0\n"
644 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable int=0" }
645 -re "$prompt $" { fail "set variable int=0" }
646 timeout { fail "(timeout) set variable int=0" }
649 -re "$prompt $" { fail "set variable int=0" }
650 timeout { fail "(timeout) set variable int=0" }
654 send "set variable v_int=1\n"
660 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable int=1" }
661 -re "$prompt $" { fail "set variable int=1" }
662 timeout { fail "(timeout) set variable int=1" }
665 -re "$prompt $" { fail "set variable int=1" }
666 timeout { fail "(timeout) set variable int=1" }
670 send "set variable v_int=-1\n"
676 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable int=-1 (minus)" }
677 -re "$prompt $" { fail "set variable int=-1 (minus)" }
678 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
681 -re "$prompt $" { fail "set variable int=-1 (minus)" }
682 timeout { fail "(timeout) set variable int=-1 (minus)" }
687 # test "set variable" for type "signed int"
689 send "set variable v_signed_int=0\n"
693 send "print v_signed_int\n"
695 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed int=0" }
696 -re "$prompt $" { fail "set variable signed int=0" }
697 timeout { fail "(timeout) set variable signed int=0" }
700 -re "$prompt $" { fail "set variable signed int=0" }
701 timeout { fail "(timeout) set variable signed int=0" }
705 send "set variable v_signed_int=1\n"
709 send "print v_signed_int\n"
711 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed int=1" }
712 -re "$prompt $" { fail "set variable signed int=1" }
713 timeout { fail "(timeout) set variable signed int=1" }
716 -re "$prompt $" { fail "set variable signed int=1" }
717 timeout { fail "(timeout) set variable signed int=1" }
721 send "set variable v_signed_int=-1\n"
725 send "print v_signed_int\n"
727 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed int=-1 (minus)" }
728 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
729 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
732 -re "$prompt $" { fail "set variable signed int=-1 (minus)" }
733 timeout { fail "(timeout) set variable signed int=-1 (minus)" }
738 # test "set variable" for type "unsigned int"
740 send "set variable v_unsigned_int=0\n"
744 send "print v_unsigned_int\n"
746 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned int=0" }
747 -re "$prompt $" { fail "set variable unsigned int=0" }
748 timeout { fail "(timeout) set variable unsigned int=0" }
751 -re "$prompt $" { fail "set variable unsigned int=0" }
752 timeout { fail "(timeout) set variable unsigned int=0" }
756 send "set variable v_unsigned_int=1\n"
760 send "print v_unsigned_int\n"
762 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned int=1" }
763 -re "$prompt $" { fail "set variable unsigned int=1" }
764 timeout { fail "(timeout) set variable unsigned int=1" }
767 -re "$prompt $" { fail "set variable unsigned int=1" }
768 timeout { fail "(timeout) set variable unsigned int=1" }
772 send "set variable v_unsigned_int=~0\n"
776 send "print v_unsigned_int\n"
778 -re ".\[0-9\]* = 4294967295.*$prompt $" { pass "set variable unsigned int=~0 (minus)" }
779 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
780 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
783 -re "$prompt $" { fail "set variable unsigned int=~0 (minus)" }
784 timeout { fail "(timeout) set variable unsigned int=~0 (minus)" }
789 # test "set variable" for type "long"
791 send "set variable v_long=0\n"
795 send "print v_long\n"
797 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable long=0" }
798 -re "$prompt $" { fail "set variable long=0" }
799 timeout { fail "(timeout) set variable long=0" }
802 -re "$prompt $" { fail "set variable long=0" }
803 timeout { fail "(timeout) set variable long=0" }
807 send "set variable v_long=1\n"
811 send "print v_long\n"
813 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable long=1" }
814 -re "$prompt $" { fail "set variable long=1" }
815 timeout { fail "(timeout) set variable long=1" }
818 -re "$prompt $" { fail "set variable long=1" }
819 timeout { fail "(timeout) set variable long=1" }
823 send "set variable v_long=-1\n"
827 send "print v_long\n"
829 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable long=-1 (minus)" }
830 -re "$prompt $" { fail "set variable long=-1 (minus)" }
831 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
834 -re "$prompt $" { fail "set variable long=-1 (minus)" }
835 timeout { fail "(timeout) set variable long=-1 (minus)" }
840 # test "set variable" for type "signed long"
842 send "set variable v_signed_long=0\n"
846 send "print v_signed_long\n"
848 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable signed long=0" }
849 -re "$prompt $" { fail "set variable signed long=0" }
850 timeout { fail "(timeout) set variable signed long=0" }
853 -re "$prompt $" { fail "set variable signed long=0" }
854 timeout { fail "(timeout) set variable signed long=0" }
858 send "set variable v_signed_long=1\n"
862 send "print v_signed_long\n"
864 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable signed long=1" }
865 -re "$prompt $" { fail "set variable signed long=1" }
866 timeout { fail "(timeout) set variable signed long=1" }
869 -re "$prompt $" { fail "set variable signed long=1" }
870 timeout { fail "(timeout) set variable signed long=1" }
874 send "set variable v_signed_long=-1\n"
878 send "print v_signed_long\n"
880 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable signed long=-1 (minus)" }
881 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
882 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
885 -re "$prompt $" { fail "set variable signed long=-1 (minus)" }
886 timeout { fail "(timeout) set variable signed long=-1 (minus)" }
891 # test "set variable" for type "unsigned long"
893 send "set variable v_unsigned_long=0\n"
897 send "print v_unsigned_long\n"
899 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable unsigned long=0" }
900 -re "$prompt $" { fail "set variable unsigned long=0" }
901 timeout { fail "(timeout) set variable unsigned long=0" }
904 -re "$prompt $" { fail "set variable unsigned long=0" }
905 timeout { fail "(timeout) set variable unsigned long=0" }
909 send "set variable v_unsigned_long=1\n"
913 send "print v_unsigned_long\n"
915 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable unsigned long=1" }
916 -re "$prompt $" { fail "set variable unsigned long=1" }
917 timeout { fail "(timeout) set variable unsigned long=1" }
920 -re "$prompt $" { fail "set variable unsigned long=1" }
921 timeout { fail "(timeout) set variable unsigned long=1" }
925 send "set variable v_unsigned_long=~0\n"
929 send "print v_unsigned_long\n"
931 -re ".\[0-9\]* = $ulong_minus_1.*$prompt $" { pass "set variable unsigned long=~0 (minus)" }
932 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
933 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
936 -re "$prompt $" { fail "set variable unsigned long=~0 (minus)" }
937 timeout { fail "(timeout) set variable unsigned long=~0 (minus)" }
942 # test "set variable" for type "float"
944 send "set variable v_float=0.0\n"
948 send "print v_float\n"
950 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable float=0" }
951 -re "$prompt $" { fail "set variable float=0" }
952 timeout { fail "(timeout) set variable float=0" }
955 -re "$prompt $" { fail "set variable float=0" }
956 timeout { fail "(timeout) set variable float=0" }
960 send "set variable v_float=1.0\n"
964 send "print v_float\n"
966 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable float=1" }
967 -re "$prompt $" { fail "set variable float=1" }
968 timeout { fail "(timeout) set variable float=1" }
971 -re "$prompt $" { fail "set variable float=1" }
972 timeout { fail "(timeout) set variable float=1" }
976 send "set variable v_float=-1.0\n"
980 send "print v_float\n"
982 -re ".\[0-9\]* = -1.*$prompt $" { pass "set variable float=-1 (minus)" }
983 -re "$prompt $" { fail "set variable float=-1 (minus)" }
984 timeout { fail "(timeout) set variable signed float=-1 (minus)" }
987 -re "$prompt $" { fail "set variable float=-1 (minus)" }
988 timeout { fail "(timeout) set variable float=-1 (minus)" }
993 # test "set variable" for type "double"
995 send "set variable v_double=0.0\n"
999 send "print v_double\n"
1001 -re ".\[0-9\]* = 0.*$prompt $" { pass "set variable double=0" }
1002 -re "$prompt $" { fail "set variable double=0" }
1003 timeout { fail "(timeout) set variable double=0" }
1006 -re "$prompt $" { fail "set variable double=0" }
1007 timeout { fail "(timeout) set variable double=0" }
1011 send "set variable v_double=1.0\n"
1015 send "print v_double\n"
1017 -re ".\[0-9\]* = 1.*$prompt $" { pass "set variable double=1" }
1018 -re "$prompt $" { fail "set variable double=1" }
1019 timeout { fail "(timeout) set variable double=1" }
1022 -re "$prompt $" { fail "set variable double=1" }
1023 timeout { fail "(timeout) set variable double=1" }
1027 send "set variable v_double=-1.0\n"
1029 -re "set.*$prompt $"\
1031 send "print v_double\n"
1033 -re "print.*.\[0-9\]* = -1.*$prompt $" { pass "set variable double=-1 (minus)" }
1034 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1035 timeout { fail "(timeout) set variable double=-1 (minus)" }
1038 -re "$prompt $" { fail "set variable double=-1 (minus)" }
1039 timeout { fail "(timeout) set variable double=-1 (minus)" }
1044 # test "set variable" for "char array[2]"
1046 send "set variable v_char_array\[0\]='h'\n"
1047 expect -re "$prompt $"
1048 send "set variable v_char_array\[1\]='i'\n"
1050 -re "set.*$prompt $"\
1052 send "print v_char_array\n"
1054 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable char array=\"hi\" (string)" }
1055 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1056 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1059 -re "$prompt $" { fail "set variable char array=\"hi\" (string)" }
1060 timeout { fail "(timeout) set variable char array=\"hi\" (string)" }
1065 # test "set variable" for "signed char array[2]"
1067 send "set variable v_signed_char_array\[0\]='h'\n"
1068 expect -re "$prompt $"
1069 send "set variable v_signed_char_array\[1\]='i'\n"
1071 -re "set.*$prompt $"\
1073 send "print v_signed_char_array\n"
1075 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable signed char array=\"hi\" (string)" }
1076 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1077 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1080 -re "$prompt $" { fail "set variable signed char array=\"hi\" (string)" }
1081 timeout { fail "(timeout) set variable signed char array=\"hi\" (string)" }
1086 # test "set variable" for "unsigned char array[2]"
1088 send "set variable v_unsigned_char_array\[0\]='h'\n"
1089 expect -re "$prompt $"
1090 send "set variable v_unsigned_char_array\[1\]='i'\n"
1092 -re "set.*$prompt $"\
1094 send "print v_unsigned_char_array\n"
1096 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" { pass "set variable unsigned char array=\"hi\" (string)" }
1097 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1098 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1101 -re "$prompt $" { fail "set variable unsigned char array=\"hi\" (string)" }
1102 timeout { fail "(timeout) set variable unsigned char array=\"hi\" (string)" }
1107 # test "set variable" for "short array[2]"
1109 send "set variable v_short_array\[0\]=123\n"
1110 expect -re "$prompt $"
1111 send "set variable v_short_array\[1\]=-456\n"
1113 -re "set.*$prompt $"\
1115 send "print v_short_array\n"
1117 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable short array" }
1118 -re "$prompt $" { fail "set variable short array" }
1119 timeout { fail "(timeout) set variable short array" }
1122 -re "$prompt $" { fail "set variable short array" }
1123 timeout { fail "(timeout) set variable short array" }
1128 # test "set variable" for "signed short array[2]"
1130 send "set variable v_signed_short_array\[0\]=123\n"
1131 expect -re "$prompt $"
1132 send "set variable v_signed_short_array\[1\]=-456\n"
1134 -re "set.*$prompt $"\
1136 send "print v_signed_short_array\n"
1138 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed short array" }
1139 -re "$prompt $" { fail "set variable signed short array" }
1140 timeout { fail "(timeout) set variable signed short array" }
1143 -re "$prompt $" { fail "set variable signed short array" }
1144 timeout { fail "(timeout) set variable signed short array" }
1149 # test "set variable" for "unsigned short array[2]"
1151 send "set variable v_unsigned_short_array\[0\]=123\n"
1152 expect -re "$prompt $"
1153 send "set variable v_unsigned_short_array\[1\]=-456\n"
1155 -re "set.*$prompt $"\
1157 send "print v_unsigned_short_array\n"
1159 -re "print.*.\[0-9\]* =.*\{123,.*65080\}.*$prompt $" { pass "set variable unsigned short array" }
1160 -re "$prompt $" { fail "set variable unsigned short array" }
1161 timeout { fail "(timeout) set variable unsigned short array" }
1164 -re "$prompt $" { fail "set variable unsigned short array" }
1165 timeout { fail "(timeout) set variable unsigned short array" }
1170 # test "set variable" for "int array[2]"
1172 send "set variable v_int_array\[0\]=123\n"
1173 expect -re "$prompt $"
1174 send "set variable v_int_array\[1\]=-456\n"
1176 -re "set.*$prompt $"\
1178 send "print v_int_array\n"
1180 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable int array" }
1181 -re "$prompt $" { fail "set variable int array" }
1182 timeout { fail "(timeout) set variable int array" }
1185 -re "$prompt $" { fail "set variable int array" }
1186 timeout { fail "(timeout) set variable int array" }
1191 # test "set variable" for "signed int array[2]"
1193 send "set variable v_signed_int_array\[0\]=123\n"
1194 expect -re "$prompt $"
1195 send "set variable v_signed_int_array\[1\]=-456\n"
1197 -re "set.*$prompt $"\
1199 send "print v_signed_int_array\n"
1201 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed int array" }
1202 -re "$prompt $" { fail "set variable signed int array" }
1203 timeout { fail "(timeout) set variable signed int array" }
1206 -re "$prompt $" { fail "set variable signed int array" }
1207 timeout { fail "(timeout) set variable signed int array" }
1213 # test "set variable" for "unsigned int array[2]"
1215 send "set variable v_unsigned_int_array\[0\]=123\n"
1216 expect -re "$prompt $"
1217 send "set variable v_unsigned_int_array\[1\]=-456\n"
1219 -re "set.*$prompt $"\
1221 send "print v_unsigned_int_array\n"
1223 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" { pass "set variable unsigned int array" }
1224 -re "$prompt $" { fail "set variable unsigned int array" }
1225 timeout { fail "(timeout) set variable unsigned int array" }
1228 -re "$prompt $" { fail "set variable unsigned int array" }
1229 timeout { fail "(timeout) set variable unsigned int array" }
1234 # test "set variable" for "long array[2]"
1236 send "set variable v_long_array\[0\]=123\n"
1237 expect -re "$prompt $"
1238 send "set variable v_long_array\[1\]=-456\n"
1240 -re "set.*$prompt $"\
1242 send "print v_long_array\n"
1244 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable long array" }
1245 -re "$prompt $" { fail "set variable long array" }
1246 timeout { fail "(timeout) set variable long array" }
1249 -re "$prompt $" { fail "set variable long array" }
1250 timeout { fail "(timeout) set variable long array" }
1255 # test "set variable" for "signed long array[2]"
1257 send "set variable v_signed_long_array\[0\]=123\n"
1258 expect -re "$prompt $"
1259 send "set variable v_signed_long_array\[1\]=-456\n"
1261 -re "set.*$prompt $"\
1263 send "print v_signed_long_array\n"
1265 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable signed long array" }
1266 -re "$prompt $" { fail "set variable signed long array" }
1267 timeout { fail "(timeout) set variable signed long array" }
1270 -re "$prompt $" { fail "set variable signed long array" }
1271 timeout { fail "(timeout) set variable signed long array" }
1277 # test "set variable" for "unsigned long array[2]"
1279 send "set variable v_unsigned_long_array\[0\]=123\n"
1280 expect -re "$prompt $"
1281 send "set variable v_unsigned_long_array\[1\]=-456\n"
1285 send "print v_unsigned_long_array\n"
1287 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" { pass "set variable unsigned long array" }
1288 -re "$prompt $" { fail "set variable unsigned long array" }
1289 timeout { fail "(timeout) set variable unsigned long array" }
1292 -re "$prompt $" { fail "set variable unsigned long array" }
1293 timeout { fail "(timeout) set variable unsigned long array" }
1298 # test "set variable" for "float array[2]"
1300 send "set variable v_float_array\[0\]=123.0\n"
1301 expect -re "$prompt $"
1302 send "set variable v_float_array\[1\]=-456.0\n"
1306 send "print v_float_array\n"
1308 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable float array" }
1309 -re "$prompt $" { fail "set variable float array" }
1310 timeout { fail "(timeout) set variable float array" }
1313 -re "$prompt $" { fail "set variable float array" }
1314 timeout { fail "(timeout) set variable float array" }
1319 # test "set variable" for "double array[2]"
1321 send "set variable v_double_array\[0\]=123.0\n"
1322 expect -re "$prompt $"
1323 send "set variable v_double_array\[1\]=-456.0\n"
1327 send "print v_double_array\n"
1329 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" { pass "set variable double array" }
1330 -re "$prompt $" { fail "set variable double array" }
1331 timeout { fail "(timeout) set variable double array" }
1334 -re "$prompt $" { fail "set variable double array" }
1335 timeout { fail "(timeout) set variable double array" }
1340 # test "set variable" for type "char *"
1342 send "set v_char_pointer=v_char_array\n"
1343 expect -re "set.*$prompt $"
1344 send "set variable *(v_char_pointer)='h'\n"
1345 expect -re "set.*$prompt $"
1346 send "set variable *(v_char_pointer+1)='i'\n"
1348 -re "set.*$prompt $" {
1349 send "print v_char_array\n"
1351 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1352 send "print *(v_char_pointer+1)\n"
1354 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable char pointer=\"hi\" (string)" }
1355 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1356 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1360 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1361 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1364 -re "$prompt $" { fail "set variable char pointer=\"hi\" (string)" }
1365 timeout { fail "(timeout) set variable char pointer=\"hi\" (string)" }
1370 # test "set variable" for type "signed char *"
1372 send "set v_signed_char_pointer=v_signed_char_array\n"
1373 expect -re "set.*$prompt $"
1374 send "set variable *(v_signed_char_pointer)='h'\n"
1375 expect -re "set.*$prompt $"
1376 send "set variable *(v_signed_char_pointer+1)='i'\n"
1378 -re "set.*$prompt $" {
1379 send "print v_signed_char_array\n"
1381 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1382 send "print *(v_signed_char_pointer+1)\n"
1384 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable signed char pointer=\"hi\" (string)" }
1385 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1386 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1390 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1391 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1394 -re "$prompt $" { fail "set variable signed char pointer=\"hi\" (string)" }
1395 timeout { fail "(timeout) set variable signed char pointer=\"hi\" (string)" }
1400 # test "set variable" for type "unsigned char *"
1402 send "set v_unsigned_char_pointer=v_unsigned_char_array\n"
1403 expect -re "set.*$prompt $"
1404 send "set variable *(v_unsigned_char_pointer)='h'\n"
1405 expect -re "set.*$prompt $"
1406 send "set variable *(v_unsigned_char_pointer+1)='i'\n"
1408 -re "set.*$prompt $" {
1409 send "print v_unsigned_char_array\n"
1411 -re "print.*.\[0-9\]* =.*\"hi\".*$prompt $" {
1412 send "print *(v_unsigned_char_pointer+1)\n"
1414 -re "print.*.\[0-9\]* = 105 \'i\'.*$prompt $" { pass "set variable unsigned char pointer=\"hi\" (string)" }
1415 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1416 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1420 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1421 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1424 -re "$prompt $" { fail "set variable unsigned char pointer=\"hi\" (string)" }
1425 timeout { fail "(timeout) set variable unsigned char pointer=\"hi\" (string)" }
1430 # test "set variable" for type "short *"
1432 send "set v_short_pointer=v_short_array\n"
1433 expect -re "set.*$prompt $"
1434 send "set variable *(v_short_pointer)=123\n"
1435 expect -re "set.*$prompt $"
1436 send "set variable *(v_short_pointer+1)=-456\n"
1438 -re "set.*$prompt $" {
1439 send "print v_short_array\n"
1441 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1442 send "print *(v_short_pointer+1)\n"
1444 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable short pointer" }
1445 -re "$prompt $" { fail "set variable short pointer" }
1446 timeout { fail "(timeout) set variable short pointer" }
1450 -re "$prompt $" { fail "set variable short pointer" }
1451 timeout { fail "(timeout) set variable short pointer" }
1454 -re "$prompt $" { fail "set variable short pointer" }
1455 timeout { fail "(timeout) set variable short pointer" }
1460 # test "set variable" for type "signed short *"
1462 gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
1463 gdb_test "set variable *(v_signed_short_pointer)=123" ""
1464 gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
1465 gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\{123,.*-456\}" \
1466 "set variable signed short pointer"
1467 gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
1471 # test "set variable" for type "unsigned short *"
1473 gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
1474 gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
1475 gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
1476 gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\{123,.*65080\}" \
1477 "set variable unsigned short pointer"
1478 gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
1482 # test "set variable" for type "int *"
1484 send "set v_int_pointer=v_int_array\n"
1485 expect -re "set.*$prompt $"
1486 send "set variable *(v_int_pointer)=123\n"
1487 expect -re "set.*$prompt $"
1488 send "set variable *(v_int_pointer+1)=-456\n"
1490 -re "set.*$prompt $" {
1491 send "print v_int_array\n"
1493 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1494 send "print *(v_int_pointer+1)\n"
1496 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable int pointer" }
1497 -re "$prompt $" { fail "set variable int pointer" }
1498 timeout { fail "(timeout) set variable int pointer" }
1502 -re "$prompt $" { fail "set variable int pointer" }
1503 timeout { fail "(timeout) set variable int pointer" }
1506 -re "$prompt $" { fail "set variable int pointer" }
1507 timeout { fail "(timeout) set variable int pointer" }
1512 # test "set variable" for type "signed int *"
1514 send "set v_signed_int_pointer=v_signed_int_array\n"
1515 expect -re "set.*$prompt $"
1516 send "set variable *(v_signed_int_pointer)=123\n"
1517 expect -re "set.*$prompt $"
1518 send "set variable *(v_signed_int_pointer+1)=-456\n"
1520 -re "set.*$prompt $" {
1521 send "print v_signed_int_array\n"
1523 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1524 send "print *(v_signed_int_pointer+1)\n"
1526 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed int pointer" }
1527 -re "$prompt $" { fail "set variable signed int pointer" }
1528 timeout { fail "(timeout) set variable signed int pointer" }
1532 -re "$prompt $" { fail "set variable signed int pointer" }
1533 timeout { fail "(timeout) set variable signed int pointer" }
1536 -re "$prompt $" { fail "set variable signed int pointer" }
1537 timeout { fail "(timeout) set variable signed int pointer" }
1542 # test "set variable" for type "unsigned int *"
1544 send "set v_unsigned_int_pointer=v_unsigned_int_array\n"
1545 expect -re "set.*$prompt $"
1546 send "set variable *(v_unsigned_int_pointer)=123\n"
1547 expect -re "set.*$prompt $"
1548 send "set variable *(v_unsigned_int_pointer+1)=-456\n"
1550 -re "set.*$prompt $" {
1551 send "print v_unsigned_int_array\n"
1553 -re "print.*.\[0-9\]* =.*\{123,.*4294966840\}.*$prompt $" {
1554 send "print *(v_unsigned_int_pointer+1)\n"
1556 -re "print.*.\[0-9\]* = 4294966840.*$prompt $" { pass "set variable unsigned int pointer" }
1557 -re "$prompt $" { fail "set variable unsigned int pointer" }
1558 timeout { fail "(timeout) set variable unsigned int pointer" }
1562 -re "$prompt $" { fail "set variable unsigned int pointer" }
1563 timeout { fail "(timeout) set variable unsigned int pointer" }
1566 -re "$prompt $" { fail "set variable unsigned int pointer" }
1567 timeout { fail "(timeout) set variable unsigned int pointer" }
1572 # test "set variable" for type "long *"
1574 send "set v_long_pointer=v_long_array\n"
1575 expect -re "set.*$prompt $"
1576 send "set variable *(v_long_pointer)=123\n"
1577 expect -re "set.*$prompt $"
1578 send "set variable *(v_long_pointer+1)=-456\n"
1580 -re "set.*$prompt $" {
1581 send "print v_long_array\n"
1583 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1584 send "print *(v_long_pointer+1)\n"
1586 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable long pointer" }
1587 -re "$prompt $" { fail "set variable long pointer" }
1588 timeout { fail "(timeout) set variable long pointer" }
1592 -re "$prompt $" { fail "set variable long pointer" }
1593 timeout { fail "(timeout) set variable long pointer" }
1596 -re "$prompt $" { fail "set variable long pointer" }
1597 timeout { fail "(timeout) set variable long pointer" }
1602 # test "set variable" for type "signed long *"
1604 send "set v_signed_long_pointer=v_signed_long_array\n"
1605 expect -re "set.*$prompt $"
1606 send "set variable *(v_signed_long_pointer)=123\n"
1607 expect -re "set.*$prompt $"
1608 send "set variable *(v_signed_long_pointer+1)=-456\n"
1610 -re "set.*$prompt $" {
1611 send "print v_signed_long_array\n"
1613 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1614 send "print *(v_signed_long_pointer+1)\n"
1616 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable signed long pointer" }
1617 -re "$prompt $" { fail "set variable signed long pointer" }
1618 timeout { fail "(timeout) set variable signed long pointer" }
1622 -re "$prompt $" { fail "set variable signed long pointer" }
1623 timeout { fail "(timeout) set variable signed long pointer" }
1626 -re "$prompt $" { fail "set variable signed long pointer" }
1627 timeout { fail "(timeout) set variable signed long pointer" }
1632 # test "set variable" for type "unsigned long *"
1634 send "set v_unsigned_long_pointer=v_unsigned_long_array\n"
1635 expect -re "set.*$prompt $"
1636 send "set variable *(v_unsigned_long_pointer)=123\n"
1637 expect -re "set.*$prompt $"
1638 send "set variable *(v_unsigned_long_pointer+1)=-456\n"
1640 -re "set.*$prompt $" {
1641 send "print v_unsigned_long_array\n"
1643 -re "print.*.\[0-9\]* =.*\{123,.*$ulong_minus_456\}.*$prompt $" {
1644 send "print *(v_unsigned_long_pointer+1)\n"
1646 -re "print.*.\[0-9\]* = $ulong_minus_456.*$prompt $" { pass "set variable unsigned long pointer" }
1647 -re "$prompt $" { fail "set variable unsigned long pointer" }
1648 timeout { fail "(timeout) set variable unsigned long pointer" }
1652 -re "$prompt $" { fail "set variable unsigned long pointer" }
1653 timeout { fail "(timeout) set variable unsigned long pointer" }
1656 -re "$prompt $" { fail "set variable unsigned long pointer" }
1657 timeout { fail "(timeout) set variable unsigned long pointer" }
1662 # test "set variable" for type "float *"
1664 send "set v_float_pointer=v_float_array\n"
1665 expect -re "set.*$prompt $"
1666 send "set variable *(v_float_pointer)=123.0\n"
1667 expect -re "set.*$prompt $"
1668 send "set variable *(v_float_pointer+1)=-456.0\n"
1670 -re "set.*$prompt $" {
1671 send "print v_float_array\n"
1673 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1674 send "print *(v_float_pointer+1)\n"
1676 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable float pointer" }
1677 -re "$prompt $" { fail "set variable float pointer" }
1678 timeout { fail "(timeout) set variable float pointer" }
1682 -re "$prompt $" { fail "set variable float pointer" }
1683 timeout { fail "(timeout) set variable float pointer" }
1686 -re "$prompt $" { fail "set variable float pointer" }
1687 timeout { fail "(timeout) set variable float pointer" }
1692 # test "set variable" for type "double *"
1694 send "set v_double_pointer=v_double_array\n"
1695 expect -re "set.*$prompt $"
1696 send "set variable *(v_double_pointer)=123.0\n"
1697 expect -re "set.*$prompt $"
1698 send "set variable *(v_double_pointer+1)=-456.0\n"
1700 -re "set.*$prompt $" {
1701 send "print v_double_array\n"
1703 -re "print.*.\[0-9\]* =.*\{123,.*-456\}.*$prompt $" {
1704 send "print *(v_double_pointer+1)\n"
1706 -re "print.*.\[0-9\]* = -456.*$prompt $" { pass "set variable double pointer" }
1707 -re "$prompt $" { fail "set variable double pointer" }
1708 timeout { fail "(timeout) set variable double pointer" }
1712 -re "$prompt $" { fail "set variable double pointer" }
1713 timeout { fail "(timeout) set variable double pointer" }
1716 -re "$prompt $" { fail "set variable double pointer" }
1717 timeout { fail "(timeout) set variable double pointer" }
1722 # test "set variable" for struct members
1724 send "set variable v_struct1.v_char_member='h'\n"
1726 -re "set.*$prompt $"\
1728 send "print v_struct1.v_char_member\n"
1730 -re "print.*.\[0-9\]* = 104 \'h\'.*$prompt $" { pass "set variable structure char member" }
1731 -re "$prompt $" { fail "set variable structure char member" }
1732 timeout { fail "(timeout) set variable structure char member" }
1735 -re "$prompt $" { fail "set variable structure char member" }
1736 timeout { fail "(timeout) set variable structure char member" }
1740 send "set variable v_struct1.v_short_member=1\n"
1742 -re "set.*$prompt $"\
1744 send "print v_struct1.v_short_member\n"
1746 -re "print.*.\[0-9\]* = 1.*$prompt $" { pass "set variable structure short member" }
1747 -re "$prompt $" { fail "set variable structure short member" }
1748 timeout { fail "(timeout) set variable structure short member" }
1751 -re "$prompt $" { fail "set variable structure short member" }
1752 timeout { fail "(timeout) set variable structure short member" }
1756 send "set variable v_struct1.v_int_member=2\n"
1758 -re "set.*$prompt $"\
1760 send "print v_struct1.v_int_member\n"
1762 -re "print.*.\[0-9\]* = 2.*$prompt $" { pass "set variable structure int member" }
1763 -re "$prompt $" { fail "set variable structure int member" }
1764 timeout { fail "(timeout) set variable structure int member" }
1767 -re "$prompt $" { fail "set variable structure int member" }
1768 timeout { fail "(timeout) set variable structure int member" }
1772 send "set variable v_struct1.v_long_member=3\n"
1774 -re "set.*$prompt $"\
1776 send "print v_struct1.v_long_member\n"
1778 -re "print.*.\[0-9\]* = 3.*$prompt $" { pass "set variable structure long member" }
1779 -re "$prompt $" { fail "set variable structure long member" }
1780 timeout { fail "(timeout) set variable structure long member" }
1783 -re "$prompt $" { fail "set variable structure long member" }
1784 timeout { fail "(timeout) set variable structure long member" }
1788 send "set variable v_struct1.v_float_member=4.0\n"
1790 -re "set.*$prompt $"\
1792 send "print v_struct1.v_float_member\n"
1794 -re "print.*.\[0-9\]* = 4.*$prompt $" { pass "set variable structure float member" }
1795 -re "$prompt $" { fail "set variable structure float member" }
1796 timeout { fail "(timeout) set variable structure float member" }
1799 -re "$prompt $" { fail "set variable structure float member" }
1800 timeout { fail "(timeout) set variable structure float member" }
1804 send "set variable v_struct1.v_double_member=5.0\n"
1806 -re "set.*$prompt $"\
1808 send "print v_struct1.v_double_member\n"
1810 -re "print.*.\[0-9\]* = 5.*$prompt $" { pass "set variable structure double member" }
1811 -re "$prompt $" { fail "set variable structure double member" }
1812 timeout { fail "(timeout) set variable structure double member" }
1815 -re "$prompt $" { fail "set variable structure double member" }
1816 timeout { fail "(timeout) set variable structure double member" }
1820 gdb_test "print v_struct1" \
1821 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1822 .*v_int_member = 2,.*\
1823 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1824 "set print structure #1"
1826 # This should be an error. GCC extensions for structure constants require
1827 # the type of the structure to be specified, as in
1828 # v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37}
1829 # GDB should do the same if it wants to provide this feature.
1830 gdb_test "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" "Invalid.*"
1832 # And after the error the structure should be unchanged.
1833 gdb_test "print v_struct1" \
1834 "print.*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\
1835 .*v_int_member = 2,.*\
1836 v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
1837 "set print structure #2"
1839 # Test printing of enumeration bitfields.
1840 # GNU C supports them, some other compilers don't.
1842 if {$gcc_compiled} then {
1843 gdb_test "print sef.field=sm1" "print.*.\[0-9\]* = sm1"
1844 gdb_test "print sef.field" "print.*.\[0-9\]* = sm1" "print sef.field (sm1)"
1845 gdb_test "print sef.field=s1" "print.*.\[0-9\]* = s1"
1846 gdb_test "print sef.field" "print.*.\[0-9\]* = s1" "print sef.field (s1)"
1847 gdb_test "print uef.field=u1" "print.*.\[0-9\]* = u1"
1848 gdb_test "print uef.field" "print.*.\[0-9\]* = u1" "print uef.field (u1)"
1849 gdb_test "print uef.field=u2" "print.*.\[0-9\]* = u2"
1850 gdb_test "print uef.field" "print.*.\[0-9\]* = u2" "print uef.field (u2)"